Skip to content
Snippets Groups Projects
Commit be939129 authored by Sebastian Krings's avatar Sebastian Krings
Browse files

add test project to units plugin

parent 2e456eef
No related branches found
No related tags found
No related merge requests found
<?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>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>de.prob.units.tests</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>
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
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Tests
Bundle-SymbolicName: de.prob.units.tests
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: de.prob.units.tests.Activator
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
de.prob.units;bundle-version="1.0.0",
org.junit;bundle-version="4.8.2",
org.rodinp.core;bundle-version="[1.3.1,1.7.0)",
de.prob.core;bundle-version="9.3.0",
org.eventb.core;bundle-version="[2.1.0,2.6.0)"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
This diff is collapsed.
package de.prob.units.tests;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
import junit.framework.TestCase;
/**
* @author htson
* <p>
* This abstract class contains utility methods supporting testing.
* </p>
*/
public abstract class AbstractTests extends TestCase {
/**
* Constructor: Create max_size test case.
*/
public AbstractTests() {
super();
}
/**
* Constructor: Create max_size test case with the given name.
*
* @param name
* the name of test
*/
public AbstractTests(String name) {
super(name);
}
/**
* Utility method to compare two string collections. The expected collection
* is given in terms of an array of strings. The actual collection is given
* as a collection of strings. The two are the same if the number of
* elements is the same and every element of the expected collection appear
* in the actual collection.
*
* @param msg
* a message.
* @param actual
* actual collection of strings.
* @param expected
* expected array of strings.
*/
protected static void assertSameStrings(String msg,
Collection<String> actual, String... expected) {
assertEquals(msg + ": Incorrect number of elements\n", expected.length,
actual.size());
for (String exp : expected) {
assertTrue(msg + ": Expected element " + exp + " not found",
actual.contains(exp));
}
}
/**
* Utility method to compare two arrays of strings. The two are the same if
* the number of elements is the same, and the strings at the same index are
* the same.
*
* @param msg
* a message.
* @param actual
* actual array of strings.
* @param expected
* expected array of strings.
*/
protected static void assertSameStrings(String msg, String[] actual,
String... expected) {
assertEquals(msg + ": Incorrect number of strings\n", expected.length,
actual.length);
for (int i = 0; i < expected.length; i++) {
assertEquals(msg, expected[i], actual[i]);
}
}
/**
* Utility method to compare two arrays of objects. The two are the same if
* the number of elements is the same, and the objects at the same index are
* the same.
*
* @param msg
* a message.
* @param expected
* expected array of objects.
* @param actual
* actual array of objects.
*/
protected static void assertSameObjects(String msg, Object[] expected,
Object[] actual) {
assertEquals(msg + ": Incorrect number of objects\n", expected.length,
actual.length);
for (int i = 0; i < expected.length; i++) {
assertEquals(msg, expected[i], actual[i]);
}
}
/**
* Utility method to compare two maps of objects to objects. The two are the
* same if the key sets are the same (using
* {@link #assertSameSet(String, Set, Set)}), and for each key, they map to
* the same value.
*
* @param msg
* a messages.
* @param expected
* expected map.
* @param actual
* actual map.
*/
protected void assertSameMap(String msg,
Map<? extends Object, ? extends Object> expected,
Map<? extends Object, ? extends Object> actual) {
Set<? extends Object> expectedKeySet = expected.keySet();
Set<? extends Object> actualKeySet = actual.keySet();
assertSameSet(msg, expectedKeySet, actualKeySet);
for (Object key : expectedKeySet) {
assertEquals(msg, expected.get(key), actual.get(key));
}
}
/**
* Utility method to compare two sets of objects. The two are the same if
* they have the same number of elements, and each element of the expected
* set appears in the actual set.
*
* @param msg
* @param expected
* @param actual
*/
protected void assertSameSet(String msg, Set<? extends Object> expected,
Set<? extends Object> actual) {
assertEquals(msg + ": The number of elements must be the same",
expected.size(), actual.size());
for (Object elm : expected) {
assertTrue(msg + ": expected element " + elm + " not found",
actual.contains(elm));
}
}
}
\ No newline at end of file
package de.prob.units.tests;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "de.prob.units.tests"; //$NON-NLS-1$
// The shared instance
private static Activator plugin;
/**
* The constructor
*/
public Activator() {
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
}
package de.prob.units.tests;
import java.io.PrintWriter;
import java.io.StringWriter;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException;
import org.eventb.core.IEventBProject;
import org.eventb.core.IMachineRoot;
import org.junit.Before;
import org.junit.Test;
import de.prob.core.translator.TranslationFailedException;
import de.prob.eventb.translator.TranslatorFactory;
public class PragmaTranslatorTest extends AbstractEventBTests {
private StringWriter stringWriter;
private PrintWriter writer;
@Before
@Override
protected void setUp() throws Exception {
super.setUp();
stringWriter = new StringWriter();
writer = new PrintWriter(stringWriter);
}
@Test
public void testMachineWithVariables() throws CoreException,
TranslationFailedException {
IEventBProject project = createEventBProject("TestProject");
IMachineRoot machine = createMachine(project, "TestMachine");
createVariable(machine, "v1");
createInvariant(machine, "inv1", "v1=5", false);
// save file and build workspace - this triggers static check, and
// generates missing files
machine.getRodinFile().save(monitor, false);
workspace.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
// there should be one variable and one SC variable
assertEquals(1, machine.getVariables().length);
assertEquals(1, machine.getSCMachineRoot().getSCVariables().length);
TranslatorFactory.translate(machine, writer);
assertEquals(
"package(load_event_b_project([event_b_model(none,'TestMachine',[sees(none,[]),variables(none,[identifier(none,v1)]),invariant(none,[equal(rodinpos('TestMachine',inv1,'('),identifier(none,v1),integer(none,5))]),theorems(none,[]),events(none,[])])],[],[exporter_version(2)],_Error)).\n",
stringWriter.getBuffer().toString());
}
}
include 'de.prob.core', 'de.prob.core.tests', 'de.bmotionstudio.gef.editor' ,'de.bmotionstudio.rodin', 'de.bmotionstudio.help' , 'de.prob.plugin', 'de.prob.ui', 'de.prob2.feature', 'de.prob.units', 'de.prob2.units.feature'
include 'de.prob.core', 'de.prob.core.tests', 'de.bmotionstudio.gef.editor' ,'de.bmotionstudio.rodin', 'de.bmotionstudio.help' , 'de.prob.plugin', 'de.prob.ui', 'de.prob2.feature', 'de.prob.units', 'de.prob.units.tests', 'de.prob2.units.feature'
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment