[Sharelibs] Add testing framework and tests for sharelibs

Change-Id: Ibcc5c7219d7d295217fce4530e006efd58c2fe27
Signed-off-by: Pedro Cuadra <pedro.cuadrachamorro001@stud.fh-dortmund.de>
diff --git a/build/org.eclipse.app4mc.build/pom.xml b/build/org.eclipse.app4mc.build/pom.xml
index 1f11f1f..921227a 100644
--- a/build/org.eclipse.app4mc.build/pom.xml
+++ b/build/org.eclipse.app4mc.build/pom.xml
@@ -149,6 +149,7 @@
 		<module>../../tests/org.eclipse.app4mc.amalthea.converters.072.test</module>
 		<module>../../tests/org.eclipse.app4mc.amalthea.converters.080.test</module>
 		<module>../../tests/org.eclipse.app4mc.amalthea.validation.test</module>
+		<module>../../tests/org.eclipse.app4mc.multicore.sharelibs.test</module>
 		<module>../../tests/org.eclipse.app4mc.rcptt</module>
 		<module>../../tests/org.eclipse.app4mc.amalthea.model.test</module>
 	</modules>
diff --git a/plugins/org.eclipse.app4mc.multicore.sharelibs/META-INF/MANIFEST.MF b/plugins/org.eclipse.app4mc.multicore.sharelibs/META-INF/MANIFEST.MF
index dd57e40..6aca243 100644
--- a/plugins/org.eclipse.app4mc.multicore.sharelibs/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.app4mc.multicore.sharelibs/META-INF/MANIFEST.MF
@@ -12,10 +12,12 @@
  org.eclipse.emf,
  org.eclipse.app4mc.amalthea.model,
  org.eclipse.app4mc.amalthea.workflow.core,
- com.google.guava
+ com.google.guava,
+ org.junit
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
 Bundle-ActivationPolicy: lazy
 Export-Package: org.eclipse.app4mc.multicore.sharelibs,
  org.eclipse.app4mc.multicore.sharelibs.modelchecker,
  org.eclipse.app4mc.multicore.sharelibs.modelchecker.logger,
- org.eclipse.app4mc.multicore.sharelibs.modelchecker.specs
+ org.eclipse.app4mc.multicore.sharelibs.modelchecker.specs,
+ org.eclipse.app4mc.multicore.sharelibs.utframework
diff --git a/plugins/org.eclipse.app4mc.multicore.sharelibs/src/org/eclipse/app4mc/multicore/sharelibs/UniversalHandler.java b/plugins/org.eclipse.app4mc.multicore.sharelibs/src/org/eclipse/app4mc/multicore/sharelibs/UniversalHandler.java
index 3d8f13b..918f8fe 100644
--- a/plugins/org.eclipse.app4mc.multicore.sharelibs/src/org/eclipse/app4mc/multicore/sharelibs/UniversalHandler.java
+++ b/plugins/org.eclipse.app4mc.multicore.sharelibs/src/org/eclipse/app4mc/multicore/sharelibs/UniversalHandler.java
@@ -36,6 +36,7 @@
 import org.eclipse.app4mc.amalthea.model.StimuliModel;
 import org.eclipse.app4mc.amalthea.sphinx.AmaltheaResourceFactory;
 import org.eclipse.app4mc.multicore.sharelibs.modelchecker.logger.LogView;
+import org.eclipse.app4mc.multicore.sharelibs.utframework.TestUtil;
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IResource;
@@ -119,11 +120,16 @@
 
 		final String viewId = "org.eclipse.app4mc.multicore.sharelibs.modelchecker.views.ModelCheckerView";
 
-		try {
-			this.modelCheckerView = (LogView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
-					.findView(viewId);
 
-			this.modelCheckerView.setFocus();
+		try {
+			// For testing env we don't need model checker view
+			if (!TestUtil.isTesting()) {
+				this.modelCheckerView = (LogView)
+
+				PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(viewId);
+
+				this.modelCheckerView.setFocus();
+			}
 		}
 		catch (final Exception e) {
 			System.out.println("Warning! Not possible to show model checker view");
diff --git a/plugins/org.eclipse.app4mc.multicore.sharelibs/src/org/eclipse/app4mc/multicore/sharelibs/modelchecker/ModelDescription.java b/plugins/org.eclipse.app4mc.multicore.sharelibs/src/org/eclipse/app4mc/multicore/sharelibs/modelchecker/ModelDescription.java
index 7e7c3df..ffd3bb9 100644
--- a/plugins/org.eclipse.app4mc.multicore.sharelibs/src/org/eclipse/app4mc/multicore/sharelibs/modelchecker/ModelDescription.java
+++ b/plugins/org.eclipse.app4mc.multicore.sharelibs/src/org/eclipse/app4mc/multicore/sharelibs/modelchecker/ModelDescription.java
@@ -57,11 +57,7 @@
 	 * @return created model description
 	 */
 	public static ModelDescription builder(final ModelSpecLogger logger) {
-		final ModelDescription modelDesc = new ModelDescription();
-
-		modelDesc.logger = logger;
-
-		return modelDesc;
+		return builder(logger, null);
 	}
 
 
@@ -73,11 +69,7 @@
 	 * @return created model description
 	 */
 	public static ModelDescription builder(final String name) {
-		final ModelDescription modelDesc = new ModelDescription();
-
-		modelDesc.name = name;
-
-		return modelDesc;
+		return builder(null, name);
 	}
 
 	/**
@@ -92,8 +84,13 @@
 	public static ModelDescription builder(final ModelSpecLogger logger, final String name) {
 		final ModelDescription modelDesc = new ModelDescription();
 
-		modelDesc.logger = logger;
-		modelDesc.name = name;
+		if (logger != null) {
+			modelDesc.logger = logger;
+		}
+
+		if (name != null) {
+			modelDesc.name = name;
+		}
 
 		return modelDesc;
 	}
@@ -135,6 +132,13 @@
 			catch (final Exception e) {
 				spec.log("Unable to check spec \"" + spec.getName() + "\" because a " + e.toString()
 						+ " was encountered.");
+
+				severtiy = EntrySeverity.of(spec.getSeverityLevel());
+
+				// Compare the severity of the spec with the failing
+				checkOk &= severtiy.compareTo(this.failSeverity) < 0;
+
+
 			}
 		}
 
diff --git a/plugins/org.eclipse.app4mc.multicore.sharelibs/src/org/eclipse/app4mc/multicore/sharelibs/modelchecker/ModelSpec.java b/plugins/org.eclipse.app4mc.multicore.sharelibs/src/org/eclipse/app4mc/multicore/sharelibs/modelchecker/ModelSpec.java
index 4c015d6..ab9a2f5 100644
--- a/plugins/org.eclipse.app4mc.multicore.sharelibs/src/org/eclipse/app4mc/multicore/sharelibs/modelchecker/ModelSpec.java
+++ b/plugins/org.eclipse.app4mc.multicore.sharelibs/src/org/eclipse/app4mc/multicore/sharelibs/modelchecker/ModelSpec.java
@@ -19,14 +19,8 @@
 import org.eclipse.app4mc.multicore.sharelibs.modelchecker.specs.ModelSpecAmount;
 import org.eclipse.app4mc.multicore.sharelibs.modelchecker.specs.ModelSpecHasModelType;
 
-import com.google.common.collect.HashMultimap;
-
 public abstract class ModelSpec {
 	/**
-	 * Elements to be checked parsed form the model.
-	 */
-	private final HashMultimap<String, Object> elements = HashMultimap.create();
-	/**
 	 * Logging level of the spec.
 	 */
 	protected EntrySeverityLevel severity;
@@ -108,14 +102,6 @@
 	protected abstract boolean checkSpec(final Amalthea model) throws Exception;
 
 	/**
-	 * @see java.lang.Object#toString()
-	 */
-	@Override
-	public String toString() {
-		return this.elements.toString();
-	}
-
-	/**
 	 * Get the logger.
 	 *
 	 * @return logger
diff --git a/plugins/org.eclipse.app4mc.multicore.sharelibs/src/org/eclipse/app4mc/multicore/sharelibs/modelchecker/logger/ModelSpecLogger.java b/plugins/org.eclipse.app4mc.multicore.sharelibs/src/org/eclipse/app4mc/multicore/sharelibs/modelchecker/logger/ModelSpecLogger.java
index 57bee73..b0101a5 100644
--- a/plugins/org.eclipse.app4mc.multicore.sharelibs/src/org/eclipse/app4mc/multicore/sharelibs/modelchecker/logger/ModelSpecLogger.java
+++ b/plugins/org.eclipse.app4mc.multicore.sharelibs/src/org/eclipse/app4mc/multicore/sharelibs/modelchecker/logger/ModelSpecLogger.java
@@ -157,4 +157,13 @@
 		return severity.getSeverityLevel();
 	}
 
+	/**
+	 * Get the amount of entries in the log
+	 *
+	 * @return amount of entries in the log
+	 */
+	public int getLogSize() {
+		return this.log.size();
+	}
+
 }
diff --git a/plugins/org.eclipse.app4mc.multicore.sharelibs/src/org/eclipse/app4mc/multicore/sharelibs/utframework/ModelLoader.java b/plugins/org.eclipse.app4mc.multicore.sharelibs/src/org/eclipse/app4mc/multicore/sharelibs/utframework/ModelLoader.java
new file mode 100644
index 0000000..0d7e85c
--- /dev/null
+++ b/plugins/org.eclipse.app4mc.multicore.sharelibs/src/org/eclipse/app4mc/multicore/sharelibs/utframework/ModelLoader.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Dortmund University of Applied Sciences and Arts and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Dortmund University of Applied Sciences and Arts - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.app4mc.multicore.sharelibs.utframework;
+
+import org.eclipse.app4mc.amalthea.model.Amalthea;
+import org.eclipse.app4mc.amalthea.model.AmaltheaLoader;
+import org.eclipse.emf.common.util.URI;
+
+public class ModelLoader {
+
+	/**
+	 * Democar example model
+	 */
+	public final static String DEMOCAR = "../../examples/org.eclipse.app4mc.amalthea.example.democar/AMALTHEA_Democar.amxmi";
+	/**
+	 * Democar mapping with task model
+	 */
+	public final static String DEMOCAR_WITH_TASKS = "../../examples/org.eclipse.app4mc.amalthea.example.democar.mapping/model/AMALTHEA_Democar_MappingExample_withTasks.amxmi";
+	/**
+	 * Democar mapping
+	 */
+	public final static String DEMOCAR_HW = "../../examples/org.eclipse.app4mc.amalthea.example.democar.mapping/model/AMALTHEA_Democar_MappingExample-hw.amxmi";
+
+
+	/**
+	 * Get the specified model.
+	 *
+	 * @param model
+	 *            model to obtain
+	 *
+	 * @return loaded model
+	 */
+	public static Amalthea getModel(final String model) {
+		return AmaltheaLoader.loadFromFile(getURI(model));
+	}
+
+
+	/**
+	 * Get the URI of a provided model
+	 *
+	 * @param model
+	 *            model path
+	 *
+	 * @return uri of the model
+	 */
+	public static URI getURI(final String model) {
+		return URI.createFileURI(model);
+	}
+
+}
diff --git a/plugins/org.eclipse.app4mc.multicore.sharelibs/src/org/eclipse/app4mc/multicore/sharelibs/utframework/TestUtil.java b/plugins/org.eclipse.app4mc.multicore.sharelibs/src/org/eclipse/app4mc/multicore/sharelibs/utframework/TestUtil.java
new file mode 100644
index 0000000..40404b5
--- /dev/null
+++ b/plugins/org.eclipse.app4mc.multicore.sharelibs/src/org/eclipse/app4mc/multicore/sharelibs/utframework/TestUtil.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Dortmund University of Applied Sciences and Arts and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Dortmund University of Applied Sciences and Arts - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.app4mc.multicore.sharelibs.utframework;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class TestUtil {
+	/**
+	 * Flag to check the stack trace only once
+	 */
+	private static boolean testingChecked = false;
+	/**
+	 * Is testing flag
+	 */
+	private static boolean isTesting = false;
+
+	/**
+	 * Tells if the testing is running.
+	 *
+	 * @return true if testing is running and false otherwise
+	 */
+	public static boolean isTesting() {
+		// Check if the stack trace has been checked if not check it
+		if (!testingChecked) {
+			isTesting = checkIsTesting();
+			testingChecked = true;
+		}
+
+		return isTesting;
+	}
+
+	/**
+	 * Check the Stack trace for a org.junit
+	 *
+	 * @return true if org.junit is present in the stack trace
+	 */
+	private static boolean checkIsTesting() {
+		final StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
+		final List<StackTraceElement> list = Arrays.asList(stackTrace);
+		for (final StackTraceElement element : list) {
+			if (element.getClassName().startsWith("org.junit.")) {
+				return true;
+			}
+		}
+		return false;
+	}
+}
diff --git a/tests/org.eclipse.app4mc.multicore.sharelibs.test/.classpath b/tests/org.eclipse.app4mc.multicore.sharelibs.test/.classpath
new file mode 100644
index 0000000..eca7bdb
--- /dev/null
+++ b/tests/org.eclipse.app4mc.multicore.sharelibs.test/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/tests/org.eclipse.app4mc.multicore.sharelibs.test/.gitignore b/tests/org.eclipse.app4mc.multicore.sharelibs.test/.gitignore
new file mode 100644
index 0000000..92145bc
--- /dev/null
+++ b/tests/org.eclipse.app4mc.multicore.sharelibs.test/.gitignore
@@ -0,0 +1,2 @@
+/bin/
+/target/
\ No newline at end of file
diff --git a/tests/org.eclipse.app4mc.multicore.sharelibs.test/.project b/tests/org.eclipse.app4mc.multicore.sharelibs.test/.project
new file mode 100644
index 0000000..a834479
--- /dev/null
+++ b/tests/org.eclipse.app4mc.multicore.sharelibs.test/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.eclipse.app4mc.multicore.sharelibs.test</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>
diff --git a/tests/org.eclipse.app4mc.multicore.sharelibs.test/.settings/org.eclipse.jdt.core.prefs b/tests/org.eclipse.app4mc.multicore.sharelibs.test/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..31d3a78
--- /dev/null
+++ b/tests/org.eclipse.app4mc.multicore.sharelibs.test/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,100 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled
+org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
+org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
+org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
+org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
+org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
+org.eclipse.jdt.core.compiler.problem.deadCode=warning
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
+org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=warning
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
+org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
+org.eclipse.jdt.core.compiler.problem.nullReference=warning
+org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
+org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
+org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning
+org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=warning
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/tests/org.eclipse.app4mc.multicore.sharelibs.test/META-INF/MANIFEST.MF b/tests/org.eclipse.app4mc.multicore.sharelibs.test/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..207c550
--- /dev/null
+++ b/tests/org.eclipse.app4mc.multicore.sharelibs.test/META-INF/MANIFEST.MF
@@ -0,0 +1,9 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: APP4MC Multicore Sharelibs Test
+Bundle-SymbolicName: org.eclipse.app4mc.multicore.sharelibs.test
+Bundle-Version: 0.8.1.qualifier
+Fragment-Host: org.eclipse.app4mc.multicore.sharelibs
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Require-Bundle: org.junit
+Bundle-Vendor: Eclipse.org
diff --git a/tests/org.eclipse.app4mc.multicore.sharelibs.test/build.properties b/tests/org.eclipse.app4mc.multicore.sharelibs.test/build.properties
new file mode 100644
index 0000000..e88172f
--- /dev/null
+++ b/tests/org.eclipse.app4mc.multicore.sharelibs.test/build.properties
@@ -0,0 +1,5 @@
+
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .
diff --git a/tests/org.eclipse.app4mc.multicore.sharelibs.test/pom.xml b/tests/org.eclipse.app4mc.multicore.sharelibs.test/pom.xml
new file mode 100644
index 0000000..d411742
--- /dev/null
+++ b/tests/org.eclipse.app4mc.multicore.sharelibs.test/pom.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+	<modelVersion>4.0.0</modelVersion>
+
+	<parent>
+		<relativePath>../../build/org.eclipse.app4mc.build/pom.xml</relativePath>
+		<groupId>org.eclipse.app4mc.build</groupId>
+		<artifactId>parent</artifactId>
+		<version>0.8.1-SNAPSHOT</version>
+	</parent>
+
+	<artifactId>org.eclipse.app4mc.multicore.sharelibs.test</artifactId>
+	<packaging>eclipse-test-plugin</packaging>
+
+</project>
diff --git a/tests/org.eclipse.app4mc.multicore.sharelibs.test/src/org/eclipse/app4mc/multicore/sharelibs/modelchecker/ModelCheckerTest.java b/tests/org.eclipse.app4mc.multicore.sharelibs.test/src/org/eclipse/app4mc/multicore/sharelibs/modelchecker/ModelCheckerTest.java
new file mode 100644
index 0000000..7bc46d9
--- /dev/null
+++ b/tests/org.eclipse.app4mc.multicore.sharelibs.test/src/org/eclipse/app4mc/multicore/sharelibs/modelchecker/ModelCheckerTest.java
@@ -0,0 +1,465 @@
+package org.eclipse.app4mc.multicore.sharelibs.modelchecker;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import org.eclipse.app4mc.amalthea.model.Amalthea;
+import org.eclipse.app4mc.amalthea.model.AmaltheaFactory;
+import org.eclipse.app4mc.multicore.sharelibs.modelchecker.ModelDescription;
+import org.eclipse.app4mc.multicore.sharelibs.modelchecker.ModelSpec;
+import org.eclipse.app4mc.multicore.sharelibs.modelchecker.ModelSpecAmountOperation;
+import org.eclipse.app4mc.multicore.sharelibs.modelchecker.ModelSpecAmountType;
+import org.eclipse.app4mc.multicore.sharelibs.modelchecker.ModelSpecModelType;
+import org.eclipse.app4mc.multicore.sharelibs.modelchecker.logger.EntrySeverityLevel;
+import org.eclipse.app4mc.multicore.sharelibs.modelchecker.logger.ModelSpecLogger;
+import org.eclipse.app4mc.multicore.sharelibs.modelchecker.specs.ModelSpecAmount;
+import org.eclipse.app4mc.multicore.sharelibs.modelchecker.specs.ModelSpecHasModelType;
+import org.eclipse.app4mc.multicore.sharelibs.utframework.ModelLoader;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ModelCheckerTest {
+
+	Amalthea testModel = null;
+
+	@Before
+	public void setUp() {
+		this.testModel = ModelLoader.getModel(ModelLoader.DEMOCAR);
+		// Remove all runnables
+		this.testModel.getSwModel().getRunnables().clear();
+		// Remove HW model
+		this.testModel.setHwModel(null);
+	}
+
+
+	@Test
+	public void testSeverityLevel() {
+
+		// Verify that the software model is working
+		assertNotNull(this.testModel);
+		assertNotNull(this.testModel.getSwModel());
+
+		// Verify all runnable are gone
+		assertEquals(0, this.testModel.getSwModel().getRunnables().size());
+
+		final ModelSpecAmount spec = ModelSpec.ofAmount(ModelSpecAmountType.RUNNABLE)
+				.compareWith(ModelSpecAmountOperation.NOT_EQUAL, 0);
+
+		// Set it as error
+		ModelDescription modelDesc = ModelDescription.builder().addSpec(spec.setSeverity(EntrySeverityLevel.ERROR));
+
+		boolean checkres = modelDesc.checkModel(this.testModel);
+
+		// It should return false since it shall fail
+		assertFalse(checkres);
+
+		// Set as warning
+		modelDesc = ModelDescription.builder().addSpec(spec.setSeverity(EntrySeverityLevel.WARNING));
+
+		checkres = modelDesc.checkModel(this.testModel);
+
+		// It shouldn't fail
+		assertTrue(checkres);
+
+		// Change the failing level to Warning
+		modelDesc.setFailSeverityLevel(EntrySeverityLevel.WARNING);
+
+		checkres = modelDesc.checkModel(this.testModel);
+
+		// It hast to fail
+		assertFalse(checkres);
+
+		// Check that error still failing
+		modelDesc = ModelDescription.builder().addSpec(spec.setSeverity(EntrySeverityLevel.ERROR))
+				.setFailSeverityLevel(EntrySeverityLevel.WARNING);
+		checkres = modelDesc.checkModel(this.testModel);
+		assertFalse(checkres);
+
+		// That for lower severities doesn't fail
+		modelDesc = ModelDescription.builder().addSpec(spec.setSeverity(EntrySeverityLevel.OK))
+				.setFailSeverityLevel(EntrySeverityLevel.WARNING);
+		checkres = modelDesc.checkModel(this.testModel);
+		assertTrue(checkres);
+		modelDesc = ModelDescription.builder().addSpec(spec.setSeverity(EntrySeverityLevel.INFO))
+				.setFailSeverityLevel(EntrySeverityLevel.WARNING);
+		checkres = modelDesc.checkModel(this.testModel);
+		assertTrue(checkres);
+
+	}
+
+	@Test
+	public void testAllSeverities() {
+
+		// Verify that the software model is working
+		assertNotNull(this.testModel);
+		assertNotNull(this.testModel.getSwModel());
+
+		// Verify all runnable are gone
+		assertEquals(0, this.testModel.getSwModel().getRunnables().size());
+
+		final ModelSpecAmount spec = ModelSpec.ofAmount(ModelSpecAmountType.RUNNABLE)
+				.compareWith(ModelSpecAmountOperation.NOT_EQUAL, 0);
+
+		// Set it as error
+		ModelDescription modelDesc = ModelDescription.builder().addSpec(spec.setSeverity(EntrySeverityLevel.ERROR));
+
+		boolean checkres = modelDesc.checkModel(this.testModel);
+
+		// It should return false since it shall fail
+		assertFalse(checkres);
+
+		// Set as warning
+		modelDesc = ModelDescription.builder().addSpec(spec.setSeverity(EntrySeverityLevel.WARNING));
+
+		checkres = modelDesc.checkModel(this.testModel);
+
+		// It shouldn't fail
+		assertTrue(checkres);
+
+		// Set as Info
+		modelDesc = ModelDescription.builder().addSpec(spec.setSeverity(EntrySeverityLevel.INFO));
+
+		checkres = modelDesc.checkModel(this.testModel);
+
+		// It shouldn't fail
+		assertTrue(checkres);
+
+		// Set as Info
+		modelDesc = ModelDescription.builder().addSpec(spec.setSeverity(EntrySeverityLevel.OK));
+
+		checkres = modelDesc.checkModel(this.testModel);
+
+		// It shouldn't fail
+		assertTrue(checkres);
+
+	}
+
+	@Test
+	public void testAllAmountOperations() {
+
+		// Verify that the software model is working
+		assertNotNull(this.testModel);
+		assertNotNull(this.testModel.getSwModel());
+
+		// Verify all runnable are gone
+		assertEquals(0, this.testModel.getSwModel().getRunnables().size());
+
+		final ModelSpecAmount spec = ModelSpec.ofAmount(ModelSpecAmountType.RUNNABLE)
+				.compareWith(ModelSpecAmountOperation.NOT_EQUAL, 0).setSeverity(EntrySeverityLevel.ERROR);
+
+		// Set it as error
+		ModelDescription modelDesc = ModelDescription.builder().addSpec(spec);
+
+		boolean checkres = modelDesc.checkModel(this.testModel);
+
+		// It should return false since it shall fail
+		assertFalse(checkres);
+
+		spec.compareWith(ModelSpecAmountOperation.GREATER, 0);
+		modelDesc = ModelDescription.builder().addSpec(spec);
+
+		checkres = modelDesc.checkModel(this.testModel);
+
+		// It should return false since it shall fail
+		assertFalse(checkres);
+
+		spec.compareWith(ModelSpecAmountOperation.GREATER_EQUAL, 0);
+		modelDesc = ModelDescription.builder().addSpec(spec);
+
+		checkres = modelDesc.checkModel(this.testModel);
+
+		// It should return false since it shall fail
+		assertTrue(checkres);
+
+		spec.compareWith(ModelSpecAmountOperation.EQUAL, 0);
+		modelDesc = ModelDescription.builder().addSpec(spec);
+
+		checkres = modelDesc.checkModel(this.testModel);
+
+		// It should return false since it shall fail
+		assertTrue(checkres);
+
+		spec.compareWith(ModelSpecAmountOperation.LESS, 0);
+		modelDesc = ModelDescription.builder().addSpec(spec);
+
+		checkres = modelDesc.checkModel(this.testModel);
+
+		// It should return false since it shall fail
+		assertFalse(checkres);
+
+		spec.compareWith(ModelSpecAmountOperation.LESS_EQUAL, 0);
+		modelDesc = ModelDescription.builder().addSpec(spec);
+
+		checkres = modelDesc.checkModel(this.testModel);
+
+		// It should return false since it shall fail
+		assertTrue(checkres);
+
+	}
+
+	@Test
+	public void testAllTypes() {
+
+		// Verify that the software model is working
+		assertNotNull(this.testModel);
+		assertNotNull(this.testModel.getSwModel());
+
+		// Verify all runnable are gone
+		assertEquals(0, this.testModel.getSwModel().getRunnables().size());
+
+		final ModelSpecAmount spec = ModelSpec.ofAmount(ModelSpecAmountType.RUNNABLE)
+				.compareWith(ModelSpecAmountOperation.NOT_EQUAL, 0).setSeverity(EntrySeverityLevel.ERROR);
+
+		// Set it as error
+		ModelDescription modelDesc = ModelDescription.builder().addSpec(spec);
+
+		boolean checkres = modelDesc.checkModel(this.testModel);
+
+		// It should return false since it shall fail
+		assertFalse(checkres);
+
+		spec.compareWith(ModelSpecAmountOperation.EQUAL, 0);
+		modelDesc = ModelDescription.builder().addSpec(spec);
+
+		checkres = modelDesc.checkModel(this.testModel);
+
+		// It should return false since it shall fail
+		assertTrue(checkres);
+
+		spec.compareWith(ModelSpecAmountOperation.GREATER_EQUAL, 0);
+		modelDesc = ModelDescription.builder().addSpec(spec);
+
+		checkres = modelDesc.checkModel(this.testModel);
+
+		// It should return false since it shall fail
+		assertTrue(checkres);
+
+		spec.compareWith(ModelSpecAmountOperation.EQUAL, 0);
+		modelDesc = ModelDescription.builder().addSpec(spec);
+
+		checkres = modelDesc.checkModel(this.testModel);
+
+		// It should return false since it shall fail
+		assertTrue(checkres);
+
+		spec.compareWith(ModelSpecAmountOperation.LESS, 0);
+		modelDesc = ModelDescription.builder().addSpec(spec);
+
+		checkres = modelDesc.checkModel(this.testModel);
+
+		// It should return false since it shall fail
+		assertFalse(checkres);
+
+		spec.compareWith(ModelSpecAmountOperation.LESS_EQUAL, 0);
+		modelDesc = ModelDescription.builder().addSpec(spec);
+
+		checkres = modelDesc.checkModel(this.testModel);
+
+		// It should return false since it shall fail
+		assertTrue(checkres);
+
+	}
+
+	@Test
+	public void testHasModelType() {
+
+		// Verify that the software model is working
+		assertNotNull(this.testModel);
+		assertNotNull(this.testModel.getSwModel());
+
+		// Verify that the HW model failed
+		assertNull(this.testModel.getHwModel());
+
+		// Verify all runnable are gone
+		assertEquals(0, this.testModel.getSwModel().getRunnables().size());
+
+		ModelSpecHasModelType spec = ModelSpec.ofHasModel(ModelSpecModelType.HW_MODEL)
+				.setSeverity(EntrySeverityLevel.ERROR);
+
+		// Set it as error
+		ModelDescription modelDesc = ModelDescription.builder().addSpec(spec);
+
+		boolean checkres = modelDesc.checkModel(this.testModel);
+
+		// It should return false since it shall fail
+		assertFalse(checkres);
+
+		spec = ModelSpec.ofHasModel(ModelSpecModelType.SW_MODEL).setSeverity(EntrySeverityLevel.ERROR);
+
+		modelDesc = ModelDescription.builder().addSpec(spec);
+
+		checkres = modelDesc.checkModel(this.testModel);
+
+		// Now it has the model and should fail
+		assertTrue(checkres);
+
+
+	}
+
+	@Test
+	public void testHasAllModelType() {
+
+		// Verify that the software model is working
+		assertNotNull(this.testModel);
+		assertNotNull(this.testModel.getSwModel());
+
+		final Amalthea emptyModel = AmaltheaFactory.eINSTANCE.createAmalthea();
+
+		// Verify that all models are empty
+		assertNull(emptyModel.getHwModel());
+		assertNull(emptyModel.getCommonElements());
+		assertNull(emptyModel.getComponentsModel());
+		assertNull(emptyModel.getConfigModel());
+		assertNull(emptyModel.getConstraintsModel());
+		// assertNull(emptyModel.getCustomProperties());
+		assertNull(emptyModel.getEventModel());
+		assertNull(emptyModel.getHwModel());
+		assertNull(emptyModel.getMappingModel());
+		assertNull(emptyModel.getOsModel());
+		assertNull(emptyModel.getPropertyConstraintsModel());
+		assertNull(emptyModel.getStimuliModel());
+		assertNull(emptyModel.getSwModel());
+
+
+		for (final ModelSpecModelType type : ModelSpecModelType.values()) {
+			final ModelSpecHasModelType spec = ModelSpec.ofHasModel(type).setSeverity(EntrySeverityLevel.ERROR);
+
+			final ModelDescription modelDesc = ModelDescription.builder().addSpec(spec);
+
+			final boolean checkres = modelDesc.checkModel(emptyModel);
+
+			// It should return false since it shall fail
+			assertFalse(checkres);
+		}
+
+	}
+
+	@Test
+	public void testAllAmountTypes() {
+
+		// Verify that the software model is working
+		assertNotNull(this.testModel);
+		assertNotNull(this.testModel.getSwModel());
+
+		final Amalthea emptyModel = AmaltheaFactory.eINSTANCE.createAmalthea();
+		emptyModel.setSwModel(AmaltheaFactory.eINSTANCE.createSWModel());
+		emptyModel.setHwModel(AmaltheaFactory.eINSTANCE.createHWModel());
+
+		// We have to create the entire path to cores to be sure that we are
+		// testing it
+		emptyModel.getHwModel().setSystem(AmaltheaFactory.eINSTANCE.createHwSystem());
+
+
+		for (final ModelSpecAmountType type : ModelSpecAmountType.values()) {
+			ModelSpecAmount spec = ModelSpec.ofAmount(type).compareWith(ModelSpecAmountOperation.NOT_EQUAL, 0)
+					.setSeverity(EntrySeverityLevel.ERROR);
+
+			ModelDescription modelDesc = ModelDescription.builder().addSpec(spec);
+
+			boolean checkres = modelDesc.checkModel(emptyModel);
+
+			// It should return false since it shall fail
+			assertFalse(checkres);
+
+			spec = ModelSpec.ofAmount(type).compareWith(ModelSpecAmountOperation.EQUAL, 0)
+					.setSeverity(EntrySeverityLevel.ERROR);
+
+			modelDesc = ModelDescription.builder().addSpec(spec);
+
+			checkres = modelDesc.checkModel(emptyModel);
+
+			// It should return false since it shall fail
+			assertTrue(checkres);
+		}
+
+	}
+
+	@Test
+	public void testFailingOnException() {
+
+		final Amalthea emptyModel = AmaltheaFactory.eINSTANCE.createAmalthea();
+
+		ModelSpecAmount spec = ModelSpec.ofAmount(ModelSpecAmountType.RUNNABLE)
+				.compareWith(ModelSpecAmountOperation.NOT_EQUAL, 0).setSeverity(EntrySeverityLevel.ERROR);
+
+		ModelDescription modelDesc = ModelDescription.builder().addSpec(spec);
+
+		boolean checkres = modelDesc.checkModel(emptyModel);
+
+		// It should return false since it shall fail
+		assertFalse(checkres);
+
+		spec = ModelSpec.ofAmount(ModelSpecAmountType.RUNNABLE).compareWith(ModelSpecAmountOperation.NOT_EQUAL, 0)
+				.setSeverity(EntrySeverityLevel.WARNING);
+
+		modelDesc = ModelDescription.builder().addSpec(spec);
+
+		checkres = modelDesc.checkModel(emptyModel);
+
+		// It should return false since it shall fail
+		assertTrue(checkres);
+
+
+	}
+
+	@Test
+	public void testConcatBuilderLogger() {
+
+		final ModelSpecLogger logger = new ModelSpecLogger();
+
+		// Verify that the software model is working
+		assertNotNull(this.testModel);
+		assertNotNull(this.testModel.getSwModel());
+
+		// Verify that the HW model failed
+		assertNull(this.testModel.getHwModel());
+
+		// Verify all runnable are gone
+		assertEquals(0, this.testModel.getSwModel().getRunnables().size());
+
+		final ModelSpecHasModelType spec = ModelSpec.ofHasModel(ModelSpecModelType.HW_MODEL)
+				.setSeverity(EntrySeverityLevel.ERROR);
+
+		// Set it as error
+		final ModelDescription modelDesc = ModelDescription.builder(logger).addSpec(spec);
+
+		assertEquals(0, logger.getLogSize());
+
+		boolean checkres = modelDesc.checkModel(this.testModel);
+
+		// It should return false since it shall fail
+		assertFalse(checkres);
+
+		assertEquals(1, logger.getLogSize());
+
+		modelDesc.printLog();
+
+
+		final ModelDescription modelDesc2 = ModelDescription.builder("Name 1").addSpec(spec);
+
+		modelDesc2.concatLog(modelDesc);
+
+		checkres = modelDesc2.checkModel(this.testModel);
+
+		// Now it has the model and should fail
+		assertFalse(checkres);
+
+		assertEquals(2, logger.getLogSize());
+
+		final ModelDescription modelDesc3 = ModelDescription.builder(logger, "Name 1").addSpec(spec);
+
+		checkres = modelDesc3.checkModel(ModelLoader.getURI(ModelLoader.DEMOCAR));
+
+		// Original Model Has HW model
+		assertTrue(checkres);
+
+		assertEquals(2, logger.getLogSize());
+
+		modelDesc3.printLog();
+
+	}
+
+}
\ No newline at end of file
diff --git a/tests/org.eclipse.app4mc.multicore.sharelibs.test/src/org/eclipse/app4mc/multicore/sharelibs/utframework/ModelLoaderTest.java b/tests/org.eclipse.app4mc.multicore.sharelibs.test/src/org/eclipse/app4mc/multicore/sharelibs/utframework/ModelLoaderTest.java
new file mode 100644
index 0000000..7ee7f4a
--- /dev/null
+++ b/tests/org.eclipse.app4mc.multicore.sharelibs.test/src/org/eclipse/app4mc/multicore/sharelibs/utframework/ModelLoaderTest.java
@@ -0,0 +1,40 @@
+package org.eclipse.app4mc.multicore.sharelibs.utframework;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertNull;
+
+import org.eclipse.app4mc.amalthea.model.Amalthea;
+import org.eclipse.app4mc.multicore.sharelibs.utframework.ModelLoader;
+import org.junit.Test;
+
+public class ModelLoaderTest {
+
+	@Test
+	public void testSingleLoad() {
+		final Amalthea testModel = ModelLoader.getModel(ModelLoader.DEMOCAR);
+		assertNotNull(testModel);
+		assertNotNull(testModel.getSwModel());
+	}
+
+	@Test
+	public void testDualLoads() {
+		final Amalthea testModel0 = ModelLoader.getModel(ModelLoader.DEMOCAR);
+		final Amalthea testModel1 = ModelLoader.getModel(ModelLoader.DEMOCAR);
+
+		assertNotNull(testModel0);
+		assertNotNull(testModel1);
+		assertNotNull(testModel0.getSwModel());
+		assertNotNull(testModel1.getSwModel());
+
+		// Modify one of the models
+		testModel0.setSwModel(null);
+		assertNull(testModel0.getSwModel());
+
+		// Test that both models are independent from each other
+		assertNotSame(testModel0.getSwModel(), testModel1.getSwModel());
+
+
+	}
+
+}
\ No newline at end of file