Browse Source

moved base tests to base

Andreas Mülder 10 years ago
parent
commit
d3a0abb889

+ 7 - 0
plugins/org.yakindu.base.types.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.6"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

+ 28 - 0
plugins/org.yakindu.base.types.test/.project

@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.yakindu.base.types.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>

+ 7 - 0
plugins/org.yakindu.base.types.test/.settings/org.eclipse.jdt.core.prefs

@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6

+ 9 - 0
plugins/org.yakindu.base.types.test/META-INF/MANIFEST.MF

@@ -0,0 +1,9 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Base Types Tests
+Bundle-SymbolicName: org.yakindu.base.types.test
+Bundle-Version: 2.4.1.qualifier
+Bundle-Vendor: statecharts.org
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Require-Bundle: org.yakindu.base.types,
+ org.junit

+ 4 - 0
plugins/org.yakindu.base.types.test/build.properties

@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .

+ 15 - 0
plugins/org.yakindu.base.types.test/pom.xml

@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+	xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<groupId>org.yakindu.base</groupId>
+		<artifactId>org.yakindu.base.releng</artifactId>
+		<version>2.4.1-SNAPSHOT</version>
+		<relativePath>../org.yakindu.base.releng/pom.xml</relativePath>
+	</parent>
+	<artifactId>org.yakindu.base.types.test</artifactId>
+	<groupId>org.yakindu.base.plugins</groupId>
+	<packaging>eclipse-test-plugin</packaging>
+</project>

+ 112 - 0
plugins/org.yakindu.base.types.test/src/org/yakindu/base/types/test/AbstractTypeSystemTest.java

@@ -0,0 +1,112 @@
+/**
+ * Copyright (c) 2015 committers of YAKINDU 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:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
+package org.yakindu.base.types.test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.yakindu.base.types.PrimitiveType;
+import org.yakindu.base.types.Type;
+import org.yakindu.base.types.TypesFactory;
+import org.yakindu.base.types.typesystem.AbstractTypeSystem;
+
+/**
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
+public class AbstractTypeSystemTest extends AbstractTypeSystem {
+
+	private static final String SUB_TYPE = "SubType";
+	private static final String SUB_TYPE2 = "SubType2";
+	private static final String SUPER_TYPE = "SuperType";
+	private static final String SIMPLE_TYPE = "SimpleType";
+	private static final String CONVERSION_SUB_TYPE = "ConversionSubType";
+	private static final String CONVERSION_TYPE = "ConversionType";
+
+	private Type superType;
+	private Type subType;
+	private Type subType2;
+	private Type simpleType;
+	private Type conversionType;
+	private Type conversionSubType;
+
+	@Override
+	protected void initBuiltInTypes() {
+		// SubType extends SuperType
+		superType = createPrimitive(SUPER_TYPE);
+		declareType(superType, SUPER_TYPE);
+		subType = createPrimitive(SUB_TYPE);
+		declareType(subType, SUB_TYPE);
+		declareSuperType(superType, subType);
+		// SubType2 extends Supertype
+		subType2 = createPrimitive(SUB_TYPE2);
+		declareType(subType2, SUB_TYPE2);
+		declareSuperType(superType, subType2);
+		// SimpleType
+		simpleType = createPrimitive(SIMPLE_TYPE);
+		declareType(simpleType, SIMPLE_TYPE);
+		//simpleType can be converted into Conversiontype
+		conversionType = createPrimitive(CONVERSION_TYPE);
+		declareConversion(simpleType, conversionType);
+		conversionSubType = createPrimitive(CONVERSION_SUB_TYPE);
+		declareSuperType(conversionType, conversionSubType);
+		
+	}
+
+	protected Type createPrimitive(String name) {
+		PrimitiveType result = TypesFactory.eINSTANCE.createPrimitiveType();
+		result.setName(name);
+		return result;
+	}
+
+	@Test
+	public void testGetSuperType() throws Exception {
+		assertTrue(isSame(superType, getSuperType(subType)));
+
+	}
+
+	@Test
+	public void testIsSuperType() throws Exception {
+		assertTrue(isSuperType(subType, superType));
+		assertFalse(isSuperType(superType, subType));
+	}
+
+	@Test
+	public void testHaveCommonType() throws Exception {
+		assertTrue(haveCommonType(subType, subType2));
+		assertTrue(haveCommonType(subType, superType));
+		assertTrue(haveCommonType(superType, subType));
+		assertFalse(haveCommonType(superType, simpleType));
+	}
+
+	@Test
+	public void testGetCommonType() throws Exception {
+		assertTrue(isSame(superType, getCommonType(subType, subType2)));
+		assertTrue(isSame(superType, getCommonType(subType, superType)));
+		assertTrue(isSame(superType, getCommonType(superType, subType)));
+
+		assertNull(getCommonType(superType, simpleType));
+	}
+	
+	@Test
+	public void testGetCommonTypeWithConversion() throws Exception {
+		assertTrue(isSame(conversionType, getCommonType(conversionType, simpleType)));
+		assertTrue(isSame(conversionType, getCommonType(conversionType, conversionSubType)));
+	}
+
+	@Override
+	public Object defaultValue(Type type) {
+		return null;
+	}
+
+}

+ 22 - 0
plugins/org.yakindu.base.types.test/src/org/yakindu/base/types/test/AllTests.java

@@ -0,0 +1,22 @@
+/**
+ * Copyright (c) 2015 committers of YAKINDU 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:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
+package org.yakindu.base.types.test;
+
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
+@SuiteClasses(AbstractTypeSystemTest.class)
+public class AllTests {
+
+}