Skip to content
Snippets Groups Projects
Commit 665d124b authored by erbel's avatar erbel
Browse files

Added Test Cases

parent df28c136
No related branches found
No related tags found
No related merge requests found
package de.ugoe.cs.rwm.mocci;
import static org.junit.Assert.assertTrue;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.eclipse.cmf.occi.core.Configuration;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.epsilon.emc.emf.CachedResourceSet;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.modmacao.occi.platform.Componentlink;
import org.modmacao.occi.platform.impl.PlatformFactoryImpl;
import de.ugoe.cs.rwm.docci.MartDeployer;
import de.ugoe.cs.rwm.docci.ModelUtility;
......@@ -41,20 +42,33 @@ public class MapeTest {
@Test
public void Monitor() {
Monitor monitor = MAPE.monitor();
assertTrue(monitor.getAllCPUs() == 1);
}
@Test
public void Analyze() {
Monitor monitor = MAPE.monitor();
String analysis = MAPE.analyze(monitor);
if(monitor.getCritCPUs() == 1) {
assertTrue(analysis.equals("upScale"));
}
if(monitor.getNoneCPUs() == 1) {
assertTrue(analysis.equals("downScale"));
}
}
@Test
public void Plan() {
Monitor monitor = MAPE.monitor();
String analysis = MAPE.analyze(monitor);
MAPE.runtimeModel = MAPE.plan(analysis);
}
Resource res = MAPE.plan(analysis);
if(analysis.equals("upScale")) {
Configuration pre = (Configuration) MAPE.runtimeModel.getContents().get(0);
Configuration post = (Configuration) res.getContents().get(0);
assertTrue(pre.getResources().size()<post.getResources().size());
}
}
@Test
public void Execute() {
......@@ -62,6 +76,7 @@ public class MapeTest {
String analysis = MAPE.analyze(monitor);
MAPE.runtimeModel = MAPE.plan(analysis);
MAPE.execute(MAPE.runtimeModel);
assertTrue(TestUtility.equalsRuntime(MAPE.runtimeModel, MAPE.conn));
}
}
......
......@@ -129,4 +129,34 @@ public class TestUtility {
return assertion;
}
public static boolean equalsRuntime(Resource desiredModel, Connector conn) {
Path deployedOCCI = Paths.get(System.getProperty("user.home") + "/.rwm/runtime.occic");
conn.loadRuntimeModel(deployedOCCI);
org.eclipse.emf.ecore.resource.Resource runtimeModel = ModelUtility.loadOCCIintoEMFResource(deployedOCCI);
Comparator comp = ComparatorFactory.getComparator("Simple", desiredModel, runtimeModel);
boolean assertion = true;
System.out.println("MISSING ELEMENTS:");
for (EObject obj : comp.getMissingElements()) {
// Network check due to provider network
if (obj.eClass().getName().equals("Network") == false) {
System.out.println(obj);
assertion = false;
}
}
System.out.println("NEW ELEMENTS:");
for (EObject obj : comp.getNewElements()) {
// Network check due to provider network
if (obj.eClass().getName().equals("Network") == false) {
System.out.println(obj);
assertion = false;
}
}
return assertion;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment