[525312] fix NPE in CPS tests

Logging is now correctly set up so that the such errors can at least be
seen on the console

Bug: 525312
Change-Id: I1f5080205828a0925d8b0243c4d8be9e43438796
Signed-off-by: Abel Hegedus <abel.hegedus@incquerylabs.com>
diff --git a/cps/tests/org.eclipse.viatra.examples.cps.tests.util/src/org/eclipse/viatra/examples/cps/tests/util/CPSTestBase.xtend b/cps/tests/org.eclipse.viatra.examples.cps.tests.util/src/org/eclipse/viatra/examples/cps/tests/util/CPSTestBase.xtend
index 9a640f5..a84b1dd 100644
--- a/cps/tests/org.eclipse.viatra.examples.cps.tests.util/src/org/eclipse/viatra/examples/cps/tests/util/CPSTestBase.xtend
+++ b/cps/tests/org.eclipse.viatra.examples.cps.tests.util/src/org/eclipse/viatra/examples/cps/tests/util/CPSTestBase.xtend
@@ -26,10 +26,10 @@
 	def static setupRootLogger() {
 		doStandaloneEMFSetup()
 		
-		Logger.getLogger("cps.xform").level = PropertiesUtil.getCPSXformLogLevel
+		Logger.getLogger("cps.xform").initLoggerForLevel(PropertiesUtil.getCPSXformLogLevel, COMMON_LAYOUT)
 		Logger.getLogger("cps.generator").initLoggerForLevel(PropertiesUtil.getCPSGeneratorLogLevel, COMMON_LAYOUT)
 		Logger.getLogger("cps.performance").initLoggerForLevel(PropertiesUtil.getCPSGeneratorLogLevel, COMMON_LAYOUT)
-		Logger.getLogger("org.eclipse.viatra.query").level = PropertiesUtil.getIncQueryLogLevel
+		Logger.getLogger("org.eclipse.viatra.query").initLoggerForLevel(PropertiesUtil.getIncQueryLogLevel, COMMON_LAYOUT)
 		Logger.getLogger("cps.mondosam").initLoggerForLevel(PropertiesUtil.getBenchmarkLogLevel, COMMON_LAYOUT)
 		Logger.getLogger("cps.stats").initLoggerForLevel(PropertiesUtil.getStatsLogLevel, STATS_LAYOUT)
 		Logger.getLogger("cps.proto").initLoggerForLevel(PropertiesUtil.getCPSGeneratorLogLevel, COMMON_LAYOUT)
@@ -44,16 +44,17 @@
 	}
 	
 	def static initLoggerForLevel(Logger logger, Level level, String patternLayout) {
-		var ConsoleAppender ca = new ConsoleAppender();
-		val logFilePath = "./results/log/log.log";
-		val fileAppender = new FileAppender(new PatternLayout(patternLayout+FILE_LOG_LAYOUT_PREFIX),logFilePath,true);
-		fileAppender.threshold = Level.DEBUG;
-		ca.setWriter(new OutputStreamWriter(System.out));
-		ca.setLayout(new PatternLayout(patternLayout));
-		logger.setAdditivity(false);
-		logger.removeAllAppenders();
-		logger.addAppender(ca);
-		logger.addAppender(fileAppender);
-		logger.setLevel(level);
+		var ConsoleAppender ca = new ConsoleAppender()
+		val logFilePath = "./results/log/log.log"
+		val fileAppender = new FileAppender(new PatternLayout(patternLayout+FILE_LOG_LAYOUT_PREFIX),logFilePath,true)
+		fileAppender.threshold = Level.INFO
+		ca.setWriter(new OutputStreamWriter(System.out))
+		ca.setLayout(new PatternLayout(patternLayout))
+		ca.threshold = Level.WARN
+		logger.setAdditivity(false)
+		logger.removeAllAppenders()
+		logger.addAppender(ca)
+		logger.addAppender(fileAppender)
+		logger.setLevel(level)
 	}
 }
diff --git a/cps/tests/org.eclipse.viatra.examples.cps.xform.m2m.tests/src/org/eclipse/viatra/examples/cps/xform/m2m/tests/mappings/ActionMappingTest.xtend b/cps/tests/org.eclipse.viatra.examples.cps.xform.m2m.tests/src/org/eclipse/viatra/examples/cps/xform/m2m/tests/mappings/ActionMappingTest.xtend
index c6af7b3..d15fa28 100644
--- a/cps/tests/org.eclipse.viatra.examples.cps.xform.m2m.tests/src/org/eclipse/viatra/examples/cps/xform/m2m/tests/mappings/ActionMappingTest.xtend
+++ b/cps/tests/org.eclipse.viatra.examples.cps.xform.m2m.tests/src/org/eclipse/viatra/examples/cps/xform/m2m/tests/mappings/ActionMappingTest.xtend
@@ -14,15 +14,14 @@
 import org.eclipse.viatra.examples.cps.cyberPhysicalSystem.Transition
 import org.eclipse.viatra.examples.cps.deployment.BehaviorTransition
 import org.eclipse.viatra.examples.cps.traceability.CPSToDeployment
-import org.eclipse.viatra.examples.cps.xform.m2m.tests.CPS2DepTest
 import org.eclipse.viatra.examples.cps.xform.m2m.launcher.CPSTransformationWrapper
+import org.eclipse.viatra.examples.cps.xform.m2m.tests.CPS2DepTest
 import org.junit.Ignore
 import org.junit.Test
 import org.junit.runner.RunWith
 import org.junit.runners.Parameterized
 
 import static org.junit.Assert.*
-import org.eclipse.emf.ecore.util.EcoreUtil
 
 @RunWith(Parameterized)
 class ActionMappingTest extends CPS2DepTest {
@@ -813,7 +812,9 @@
 		cps2dep.assertActionMapping(transition, transition2)
 		
 		info("Removing host instance for wait")
-		EcoreUtil.delete(hostInstance2);
+		appInstance2.allocatedTo = null
+		hostInstance.communicateWith -= hostInstance2
+		host2.instances -= hostInstance2
 		executeTransformation
 		
 		cps2dep.assertNoTrigger(transition)