Simantics integration STS 87/3887/5
authorAntti Villberg <antti.villberg@semantum.fi>
Thu, 20 Feb 2020 09:20:46 +0000 (11:20 +0200)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Fri, 21 Feb 2020 22:05:45 +0000 (22:05 +0000)
gitlab #472

Change-Id: Ic65e158b277f7a1a9b4ce788f95f4dec5ab89ac4

18 files changed:
bundles/org.simantics.tests.modelled.ontology/graph/Tests.pgraph
bundles/org.simantics.tests.modelled.ui.ontology/graph/TestsUI.pgraph
bundles/org.simantics.tests.modelled.ui/src/org/simantics/tests/modelled/ui/STSSuiteSorterRule.java
bundles/org.simantics.tests.modelled/scl/Simantics/Tests.scl
bundles/org.simantics.tests.modelled/src/org/simantics/tests/modelled/TestsGraphUtils.java
bundles/org.simantics.tests.modelled/src/org/simantics/tests/modelled/utils/ModelledSTSTest.java
bundles/org.simantics.tests.modelled/src/org/simantics/tests/modelled/utils/STSSuiteTestCollector.java
tests/org.simantics.tests.integration/.classpath [new file with mode: 0644]
tests/org.simantics.tests.integration/.project [new file with mode: 0644]
tests/org.simantics.tests.integration/META-INF/MANIFEST.MF [new file with mode: 0644]
tests/org.simantics.tests.integration/SimanticsIntegrationTests.pgraph [new file with mode: 0644]
tests/org.simantics.tests.integration/SimanticsIntegrationTests.sharedLibrary [new file with mode: 0644]
tests/org.simantics.tests.integration/SimanticsIntegrationTests.tg [new file with mode: 0644]
tests/org.simantics.tests.integration/build.properties [new file with mode: 0644]
tests/org.simantics.tests.integration/pom.xml [new file with mode: 0644]
tests/org.simantics.tests.integration/src/org/simantics/tests/integration/RuntimeSTSSuite.java [new file with mode: 0644]
tests/org.simantics.tests.integration/src/org/simantics/tests/integration/SimanticsIntegrationTestSuite.java [new file with mode: 0644]
tests/pom.xml

index 59d9e578cafde5b49df06921c4fe8d4859cd562d..5f50128615da1a01a0bf64fa017fbc71298a627f 100644 (file)
@@ -7,8 +7,8 @@ TESTS = <http://www.simantics.org/Tests-1.0> : L0.Ontology
     L0.HasResourceClass "org.simantics.tests.modelled.ontology.TestsResource"
 
 TESTS.SCLMain : L0.SCLModule
-    L0.SCLModule.definition _ : L0.String 
-      @L0.loadString "scl/SCLMain.scl" 
+    L0.SCLModule.definition _ : L0.String
+      @L0.loadString "scl/SCLMain.scl"
 
 TESTS.STSTest.definition <R L0.HasProperty : L0.TotalFunction : SEL.GenericParameterType
     L0.HasRange L0.String
@@ -16,7 +16,7 @@ TESTS.STSTest.definition <R L0.HasProperty : L0.TotalFunction : SEL.GenericParam
 
 TESTS.STSTest.executionPriority <R L0.HasProperty : L0.TotalFunction : SEL.GenericParameterType
     L0.HasRange L0.Integer
-    L0.HasLabel "Execution priority" 
+    L0.HasLabel "Execution priority"
 
 TESTS.ignore <R L0.HasProperty : L0.TotalFunction : SEL.GenericParameterType
     L0.HasRange L0.Boolean
@@ -32,8 +32,9 @@ TESTS.STSTest <T L0.Entity
     @L0.assert TESTS.ignore false
     @L0.assert TESTS.ignoreReason ""
     @L0.assert TESTS.dependencies ""
+    @L0.scl MOD.contentDumpFunction "stsTestContentDump" "Resource -> <ReadGraph> Vector Byte"
 
-TESTS.STSTest : MOD.TypeWithChangeInformation 
+TESTS.STSTest : MOD.TypeWithChangeInformation
 TESTS.STSTest : L0.TypeWithIdentifier
 
 TESTS.STSSuite <T L0.Entity
@@ -43,7 +44,7 @@ TESTS.STSSuite <T L0.Entity
     @L0.assert TESTS.dependencies ""
     @L0.assert TESTS.STSTest.executionPriority -1
 
-TESTS.STSSuite : MOD.TypeWithChangeInformation 
+TESTS.STSSuite : MOD.TypeWithChangeInformation
 TESTS.STSSuite : L0.TypeWithIdentifier
 
 TESTS.STSVariable <T L0.Entity
index bcae4c4805e8f96a48815bc8bb051f9f677af7bf..ab6b5352dfc18b5cbf8111bf04749c5a448c0d53 100644 (file)
@@ -11,8 +11,8 @@ TestsUI = <http://www.simantics.org/TestsUI-1.0> : L0.Ontology
     L0.HasResourceClass "org.simantics.tests.modelled.ui.ontology.TestsUIResource"
 
 TestsUI.SCLMain : L0.SCLModule
-    L0.SCLModule.definition _ : L0.String 
-      @L0.loadString "scl/SCLMain.scl" 
+    L0.SCLModule.definition _ : L0.String
+      @L0.loadString "scl/SCLMain.scl"
 
 TestsUI.testImage : IMAGE.PngImage
   @L0.loadBytes "images/test.png"
@@ -35,6 +35,8 @@ MBC
     @VP.namedRelationChildRule    TestsUI.Contributions.STSSuites           L0.Entity                              L0.ConsistsOf TESTS.STSSuite
     @VP.namedConstantImageRule    TestsUI.Contributions.SuiteImage          TESTS.STSSuite                         TestsUI.testSuiteImage
     @VP.namedRelationChildRule    TestsUI.Contributions.STSTests            L0.Entity                              L0.ConsistsOf TESTS.STSTest
+    @VP.namedRelationChildRule    TestsUI.Contributions.SuiteModules        TESTS.STSSuite                         L0.ConsistsOf L0.SCLModule
+    @VP.namedRelationChildRule    TestsUI.Contributions.TestModules         TESTS.STSTest                          L0.ConsistsOf L0.SCLModule
     @VP.customImageRule           TESTS.STSTest                             MBC.TestImageRule
     @VP.namedRelationChildRule    TestsUI.Contributions.STSVariables        L0.Entity                              L0.ConsistsOf TESTS.STSVariable
     @VP.namedConstantImageRule    TestsUI.Contributions.VariableImage       TESTS.STSVariable                      SILK.page_white_edit
@@ -98,3 +100,11 @@ MAC
         VP.ActionContribution.HasNodeType TESTS.STSSuite
         VP.ActionContribution.HasNodeType TESTS.STSTest
         VP.ActionContribution.HasAction ACTIONS.NewSTSVariable
+    VP.BrowseContext.HasActionContribution _ : VP.ActionContribution
+        L0.HasLabel "SCL Module"
+        VP.ActionContribution.HasImage SILK.page_white_text
+        VP.ActionContribution.HasCategory VP.NewActionCategory
+        VP.ActionContribution.HasNodeType TESTS.STSSuite
+        VP.ActionContribution.HasNodeType TESTS.STSTest
+        VP.ActionContribution.HasAction MOD.ModelingActionContext.Actions.NewSCLModule
+        VP.ActionContribution.IsVisibleIf MOD.ModelingActionContext.Tests.IsContainerNotPublished
index 78de04dc48f1edf6765566b4f17f24b119d023c6..b29545df4e44384fed33698f3d87864a2b43b755 100644 (file)
@@ -33,69 +33,72 @@ import org.simantics.utils.strings.AlphanumComparator;
 
 public class STSSuiteSorterRule implements SorterRule, Sorter {
 
-       @Override
-       public boolean isCompatible(Class<?> contentType) {
-               return contentType.equals(Resource.class);
-       }
-
-       @Override
-       public Sorter getSorter(ReadGraph graph, Object content) throws DatabaseException {
-               return this;
-       }
-       
-       @Override
-       public void sort(ReadGraph graph, BrowseContext context, List<NodeContext> nodes) throws DatabaseException 
-       {
-               try {
-                       STSTestComparator stc = new STSTestComparator();
-                       stc.graph = graph;
-                       Collections.sort(nodes, stc);
-               } catch (RuntimeDatabaseException e) {
-                       if (e.getCause()!=null && e.getCause() instanceof DatabaseException) throw (DatabaseException) e.getCause();
-                       throw e;
-               }
-       }
-       
-       static class STSTestQuery extends ResourceRead<Pair<Integer, String>> {
-
-               public STSTestQuery(Resource resource) {
-                       super(resource);
-               }
-
-               @Override
-               public Pair<Integer, String> perform(ReadGraph graph) throws DatabaseException {
-                       Layer0 L0 = Layer0.getInstance(graph);
-                       TestsResource TESTS = TestsResource.getInstance(graph);
-                       
-                       String name = graph.getRelatedValue2(resource, L0.HasName, Bindings.STRING);
-               Integer priority = graph.getRelatedValue2(resource, TESTS.STSTest_executionPriority, Bindings.INTEGER);
-
-               return new Pair<Integer, String>(priority, name);
-           }
-
-       }
-       
-       static class STSTestComparator implements Comparator<NodeContext> {
-               ReadGraph graph;
-
-               @Override
-               public int compare(NodeContext nc1, NodeContext nc2) {
-                       Resource r1 = (Resource) nc1.getConstant(BuiltinKeys.INPUT);
-                       Resource r2 = (Resource) nc2.getConstant(BuiltinKeys.INPUT);
-                       
-                       try {
-                               Pair<Integer, String> test1 = graph.sync(new STSTestQuery(r1));
-                               Pair<Integer, String> test2 = graph.sync(new STSTestQuery(r2));
+    @Override
+    public boolean isCompatible(Class<?> contentType) {
+        return contentType.equals(Resource.class);
+    }
+
+    @Override
+    public Sorter getSorter(ReadGraph graph, Object content) throws DatabaseException {
+        return this;
+    }
+
+    @Override
+    public void sort(ReadGraph graph, BrowseContext context, List<NodeContext> nodes) throws DatabaseException
+    {
+        try {
+            STSTestComparator stc = new STSTestComparator();
+            stc.graph = graph;
+            Collections.sort(nodes, stc);
+        } catch (RuntimeDatabaseException e) {
+            if (e.getCause()!=null && e.getCause() instanceof DatabaseException) throw (DatabaseException) e.getCause();
+            throw e;
+        }
+    }
+
+    static class STSTestQuery extends ResourceRead<Pair<Integer, String>> {
+
+        public STSTestQuery(Resource resource) {
+            super(resource);
+        }
+
+        @Override
+        public Pair<Integer, String> perform(ReadGraph graph) throws DatabaseException {
+            Layer0 L0 = Layer0.getInstance(graph);
+            TestsResource TESTS = TestsResource.getInstance(graph);
+            String name = graph.getRelatedValue2(resource, L0.HasName, Bindings.STRING);
+            if(graph.isInstanceOf(resource, TESTS.STSTest)) {
+                Integer priority = graph.getRelatedValue2(resource, TESTS.STSTest_executionPriority, Bindings.INTEGER);
+                return new Pair<Integer, String>(priority, name);
+            } else {
+                return new Pair<Integer, String>(0, name);
+            }
+
+        }
+
+    }
+
+    static class STSTestComparator implements Comparator<NodeContext> {
+        ReadGraph graph;
+
+        @Override
+        public int compare(NodeContext nc1, NodeContext nc2) {
+            Resource r1 = (Resource) nc1.getConstant(BuiltinKeys.INPUT);
+            Resource r2 = (Resource) nc2.getConstant(BuiltinKeys.INPUT);
+
+            try {
+                Pair<Integer, String> test1 = graph.sync(new STSTestQuery(r1));
+                Pair<Integer, String> test2 = graph.sync(new STSTestQuery(r2));
 
                 if (test1.first < test2.first)
                     return -1;
                 else if (test1.first > test2.first)
                     return 1;
                 else return AlphanumComparator.COMPARATOR.compare(test1.second, test2.second);
-                
-                       } catch (DatabaseException e) {
-                               throw new RuntimeDatabaseException(e);
-                       }
-               }
-       }
+
+            } catch (DatabaseException e) {
+                throw new RuntimeDatabaseException(e);
+            }
+        }
+    }
 }
index ce3cfb1548a0b316571afd533c443f84087558ea..1d044ae60c064cff414fe0bb0c75a4d5bf539744 100644 (file)
@@ -4,3 +4,4 @@ importJava "org.simantics.tests.modelled.TestsGraphUtils" where
     createSTSTest :: Resource -> <WriteGraph, Proc> Resource
     createSTSSuite :: Resource -> <WriteGraph, Proc> Resource
     createSTSVariable :: Resource -> <WriteGraph, Proc> Resource
+    stsTestContentDump :: Resource -> <ReadGraph> Vector Byte
index c5253bd5a37ad138d159b4b7b938ad3a159cbf6e..846261938c090de6f4eefc1724c6ed17a7e06eb3 100644 (file)
@@ -3,12 +3,14 @@ package org.simantics.tests.modelled;
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.StringReader;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.regex.Pattern;
 
 import org.simantics.databoard.Bindings;
+import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.WriteGraph;
 import org.simantics.db.common.utils.NameUtils;
@@ -27,49 +29,54 @@ import org.simantics.scl.osgi.SCLOsgi;
 import org.simantics.scl.runtime.reporting.SCLReportingHandler;
 import org.simantics.tests.modelled.ontology.TestsResource;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 public class TestsGraphUtils {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(TestsGraphUtils.class);
+
     private static final String STS_TEST_PREFIX = "STSTest";
     private static final String STS_SUITE_PREFIX = "STSSuite";
     private static final String STS_VARIABLE_PREFIX = "STSVariable";
-    
+
     private TestsGraphUtils() {}
-    
+
     public static Resource createSTSVariable(WriteGraph graph, Resource parent) throws DatabaseException {
         String name = NameUtils.findFreshEscapedName(graph, STS_VARIABLE_PREFIX, parent);
         Resource stsVariable = graph.newResource();
-        
+
         Layer0 L0 = Layer0.getInstance(graph);
         TestsResource TESTS = TestsResource.getInstance(graph);
-        
+
         graph.claim(parent, L0.ConsistsOf, L0.PartOf, stsVariable);
         graph.claim(stsVariable, L0.InstanceOf, TESTS.STSVariable);
         graph.claimLiteral(stsVariable, L0.HasName, name, Bindings.STRING);
         graph.claimLiteral(stsVariable, TESTS.STSVariable_definition, "", Bindings.STRING);
         return stsVariable;
     }
-    
+
     public static Resource createSTSTest(WriteGraph graph, Resource parent) throws DatabaseException {
         String name = NameUtils.findFreshEscapedName(graph, STS_TEST_PREFIX, parent);
         Resource stsTest = graph.newResource();
-        
+
         Layer0 L0 = Layer0.getInstance(graph);
         TestsResource TESTS = TestsResource.getInstance(graph);
-        
+
         graph.claim(parent, L0.ConsistsOf, L0.PartOf, stsTest);
         graph.claim(stsTest, L0.InstanceOf, TESTS.STSTest);
         graph.claimLiteral(stsTest, L0.HasName, name, Bindings.STRING);
         graph.claimLiteral(stsTest, TESTS.STSTest_definition, "", Bindings.STRING);
         return stsTest;
     }
-    
+
     public static Resource createSTSSuite(WriteGraph graph, Resource parent) throws DatabaseException {
         String name = NameUtils.findFreshEscapedName(graph, STS_SUITE_PREFIX, parent);
         Resource stsSuite = graph.newResource();
-        
+
         Layer0 L0 = Layer0.getInstance(graph);
         TestsResource TESTS = TestsResource.getInstance(graph);
-        
+
         graph.claim(parent, L0.ConsistsOf, L0.PartOf, stsSuite);
         graph.claim(stsSuite, L0.InstanceOf, TESTS.STSSuite);
         graph.claimLiteral(stsSuite, L0.HasName, name, Bindings.STRING);
@@ -77,11 +84,11 @@ public class TestsGraphUtils {
     }
 
     public static CombinedCoverage runSTSTestDefinition(String definition, List<Pattern> moduleNameFilters, SCLReportingHandler handler) throws IOException {
-        
+
 //        ModuleRepository repo = SCLOsgi.MODULE_REPOSITORY;
         ModuleRepository repo = new ModuleRepository(SCLOsgi.SOURCE_REPOSITORY);
         repo.setAdvisor(new ModuleCompilationOptionsAdvisor() {
-            
+
             @Override
             public ModuleCompilationOptions getOptions(String moduleName) {
                 boolean coverage = false;
@@ -94,13 +101,13 @@ public class TestsGraphUtils {
                 return new ModuleCompilationOptions(coverage);
             }
         });
-        
+
         CommandSession session = new CommandSession(repo, handler);
         TestScriptExecutor executor = new TestScriptExecutor(session, new BufferedReader(new StringReader(definition)), handler);
         try {
             executor.execute();
         } catch (Throwable t) {
-            t.printStackTrace();
+            LOGGER.error("Failed to execute test definition:\n{}", definition, t);
         }
         Collection<RuntimeModule> runtimeModules = session.getRuntimeEnvironment().getRuntimeModules();
         List<Module> modules = new ArrayList<>(runtimeModules.size());
@@ -110,4 +117,11 @@ public class TestsGraphUtils {
         CombinedCoverage coverage = CoverageUtils.getCoverage(modules);
         return coverage;
     }
+
+    public static byte[] stsTestContentDump(ReadGraph graph, Resource test) throws DatabaseException {
+        TestsResource TESTS = TestsResource.getInstance(graph);
+        String def = graph.getRelatedValue(test, TESTS.STSTest_definition, Bindings.STRING);
+        return def.getBytes(StandardCharsets.UTF_8);
+    }
+
 }
index 78964403f95057464a929d8ea81e0622dea54a8b..492f8d11aa31380a0a50e15862d56b5f4a21475c 100644 (file)
@@ -28,18 +28,20 @@ public class ModelledSTSTest {
     private final String code;
     private final int priority;
     private final boolean ignored;
+    private Set<String> imports;
     private Set<String> dependencies;
     private Set<String> unresolvedDependencies;
-    
+
     private CombinedCoverage coverage;
     private Map<String, String> variables;
 
-    ModelledSTSTest(String name, String parentName, String code, int priority, boolean ignored, Set<String> dependencies, Map<String, String> variables) {
+    ModelledSTSTest(String name, String parentName, String code, int priority, boolean ignored, Set<String> imports, Set<String> dependencies, Map<String, String> variables) {
         this.name = name;
         this.parentName = parentName;
         this.code = code;
         this.priority = priority;
         this.ignored = ignored;
+        this.imports = imports;
         this.dependencies = dependencies;
         this.unresolvedDependencies = new HashSet<>(dependencies);
         this.variables = variables;
@@ -97,14 +99,14 @@ public class ModelledSTSTest {
             return value;
         }
     }
-    
+
     public List<CommandSessionVariable> run(List<CommandSessionVariable> vars) throws IOException {
 //        ModuleRepository repo = new ModuleRepository(SCLOsgi.SOURCE_REPOSITORY);
        ModuleRepository repo = SCLOsgi.MODULE_REPOSITORY;
         CommandSession session = null;
         try {
 //            repo.setAdvisor(new ModuleCompilationOptionsAdvisor() {
-//                
+//
 //                @Override
 //                public ModuleCompilationOptions getOptions(String moduleName) {
 //                    // TODO: default to false
@@ -119,24 +121,28 @@ public class ModelledSTSTest {
 //                    return new ModuleCompilationOptions(coverage);
     //                    }
 //            });
-            
+
             SCLReportingHandler handler = (SCLReportingHandler) SCLContext.getCurrent().get(SCLReportingHandler.REPORTING_HANDLER);
             session = new CommandSession(repo, handler);
-            
+
+            for(String imp : imports) {
+                session.execute("import \"" + imp + "\"");
+            }
+
             for (CommandSessionVariable var : vars)
                 session.setVariable(var.getName(), var.getType(), var.getValue());
-            
+
             for (Map.Entry<String, String> entry : variables.entrySet())
                 session.setVariable(entry.getKey(), Types.STRING, entry.getValue());
-            
-            new TestScriptExecutor(session, new BufferedReader(new StringReader(code)), handler, true).execute();
+
+            new TestScriptExecutor(session, new BufferedReader(new StringReader(code)), handler, false).execute();
             STSSuiteTestCollector.setTestCoverage(this, session);
-            
+
             // Return variables from this session
             List<CommandSessionVariable> result = new ArrayList<>();
             for (String var : session.getVariables())
                 result.add(new CommandSessionVariable(var, session.getVariableType(var), session.getVariableValue(var)));
-            
+
             return result;
         } finally {
             // remember to flush this repository
@@ -149,11 +155,11 @@ public class ModelledSTSTest {
     public Set<String> getDependencies() {
         return dependencies;
     }
-    
+
     public Set<String> getUnresolvedDependencies() {
         return unresolvedDependencies;
     }
-    
+
     public boolean resolveDependency(String testDep) {
         return unresolvedDependencies.remove(testDep);
     }
@@ -164,6 +170,7 @@ public class ModelledSTSTest {
         int result = 1;
         result = prime * result + ((code == null) ? 0 : code.hashCode());
         result = prime * result + ((coverage == null) ? 0 : coverage.hashCode());
+        result = prime * result + ((imports == null) ? 0 : imports.hashCode());
         result = prime * result + ((dependencies == null) ? 0 : dependencies.hashCode());
         result = prime * result + (ignored ? 1231 : 1237);
         result = prime * result + ((name == null) ? 0 : name.hashCode());
@@ -192,6 +199,11 @@ public class ModelledSTSTest {
                 return false;
         } else if (!coverage.equals(other.coverage))
             return false;
+        if (imports== null) {
+            if (other.imports != null)
+                return false;
+        } else if (!imports.equals(other.imports))
+            return false;
         if (dependencies == null) {
             if (other.dependencies != null)
                 return false;
index 56d43aec9ad47db272aea9905636ee30e9b20355..e04144f6d003e073cca780f33fb04bd37e6bf9f5 100644 (file)
@@ -7,6 +7,7 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.regex.Pattern;
 
 import org.simantics.Simantics;
@@ -15,7 +16,9 @@ import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.common.request.ObjectsWithType;
 import org.simantics.db.common.request.UniqueRead;
+import org.simantics.db.common.utils.CommonDBUtils;
 import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.QueryIndexUtils;
 import org.simantics.layer0.Layer0;
 import org.simantics.modeling.ModelingUtils;
 import org.simantics.scl.compiler.commands.CommandSession;
@@ -52,7 +55,7 @@ public class STSSuiteTestCollector {
                 for (Resource sharedOntology : sharedOntologies) {
                     if (LOGGER.isInfoEnabled())
                         LOGGER.info("Searching {} for modelled tests", graph.getURI(sharedOntology));
-                    List<Resource> stsSuites = ModelingUtils.searchByType(graph, sharedOntology, TESTS.STSSuite);
+                    List<Resource> stsSuites = QueryIndexUtils.searchByType(graph, sharedOntology, TESTS.STSSuite);
                     for (Resource stsSuite : stsSuites) {
                         try {
                             Collection<Resource> tests = graph.syncRequest(new ObjectsWithType(stsSuite, L0.ConsistsOf, TESTS.STSTest));
@@ -76,7 +79,27 @@ public class STSSuiteTestCollector {
     }
     
 
+    public static void collectTestImports(ReadGraph graph, Resource resource, Set<String> imports) throws DatabaseException {
+        Layer0 L0 = Layer0.getInstance(graph);
+        TestsResource TESTS = TestsResource.getInstance(graph);
+        if(graph.isInstanceOf(resource, TESTS.STSTest) || graph.isInstanceOf(resource, TESTS.STSSuite)) {
+            for(Resource module : CommonDBUtils.objectsWithType(graph, resource, L0.ConsistsOf, L0.SCLModule)) {
+                String uri = graph.getPossibleURI(module);
+                if(uri != null)
+                    imports.add(uri);
+            }
+            Resource parent = graph.getPossibleObject(resource, L0.PartOf);
+            if(parent != null)
+                collectTestImports(graph, parent, imports);
+        } else if(graph.isInstanceOf(resource, L0.IndexRoot)) {
+            Resource sclMain = CommonDBUtils.getPossibleChild(graph, resource, L0.SCLModule, "SCLMain");
+            if(sclMain != null)
+                imports.add(graph.getURI(sclMain));
+        }
+    }
+    
     public static ModelledSTSTest toModelledTest(ReadGraph graph, Resource test) throws DatabaseException {
+        
         Layer0 L0 = Layer0.getInstance(graph);
         TestsResource TESTS = TestsResource.getInstance(graph);
         String testName = graph.getRelatedValue(test, L0.HasName, Bindings.STRING);
@@ -88,13 +111,17 @@ public class STSSuiteTestCollector {
         String[] actualDeps = dependencies.isEmpty() ? new String[0] : dependencies.split(",");
         
         // collect variables
-        Collection<Resource> stsVariables = graph.getObjects(test, L0.ConsistsOf);
+        Collection<Resource> stsVariables = CommonDBUtils.objectsWithType(graph, test, L0.ConsistsOf, TESTS.STSVariable);
         Map<String, String> variables = new HashMap<>(stsVariables.size());
         for (Resource stsVariable : stsVariables) {
             String name = graph.getRelatedValue(stsVariable, L0.HasName, Bindings.STRING);
             String value = graph.getRelatedValue(stsVariable, TESTS.STSVariable_definition);
             variables.put(name, value);
         }
+        
+        Set<String> imports = new HashSet<>();
+        collectTestImports(graph, test, imports);
+        
         Resource parent = graph.getSingleObject(test, L0.PartOf);
         String parentName;
         String possibleURI = graph.getPossibleURI(parent);
@@ -102,7 +129,8 @@ public class STSSuiteTestCollector {
             parentName = possibleURI;
         else
             parentName = graph.getRelatedValue2(parent, L0.HasName, Bindings.STRING);
-        return new ModelledSTSTest(testName, parentName, code, priority != null ? priority : -1, ignored != null ? ignored : false, new HashSet<>(Arrays.asList(actualDeps)), variables);
+        return new ModelledSTSTest(testName, parentName, code, priority != null ? priority : -1, ignored != null ? ignored : false, imports, new HashSet<>(Arrays.asList(actualDeps)), variables);
+        
     }
 
     public static ModelledSTSSuite toModelledSuite(ReadGraph graph, Resource suite, List<ModelledSTSTest> children) throws DatabaseException {
diff --git a/tests/org.simantics.tests.integration/.classpath b/tests/org.simantics.tests.integration/.classpath
new file mode 100644 (file)
index 0000000..4058b66
--- /dev/null
@@ -0,0 +1,9 @@
+<?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.simantics.tests.integration/.project b/tests/org.simantics.tests.integration/.project
new file mode 100644 (file)
index 0000000..5faedf3
--- /dev/null
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.simantics.tests.integration</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>
+               <buildCommand>
+                       <name>org.eclipse.m2e.core.maven2Builder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.m2e.core.maven2Nature</nature>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/tests/org.simantics.tests.integration/META-INF/MANIFEST.MF b/tests/org.simantics.tests.integration/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..bfbaa85
--- /dev/null
@@ -0,0 +1,15 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Simantics Integration STS
+Bundle-SymbolicName: org.simantics.tests.integration
+Bundle-Version: 1.0.0.qualifier
+Bundle-Vendor: Semantum Oy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Require-Bundle: org.eclipse.osgi,
+ org.junit,
+ org.simantics.tests.modelled,
+ org.simantics.modeling,
+ org.simantics.db.testing,
+ org.slf4j.api,
+ org.simantics.application,
+ org.simantics.scl.osgi
diff --git a/tests/org.simantics.tests.integration/SimanticsIntegrationTests.pgraph b/tests/org.simantics.tests.integration/SimanticsIntegrationTests.pgraph
new file mode 100644 (file)
index 0000000..ad930e8
--- /dev/null
@@ -0,0 +1,17 @@
+L0 = <http://www.simantics.org/Layer0-1.1>
+PlatformUI = <http://www.simantics.org/PlatformUI-1.0>
+Tests = <http://www.simantics.org/Tests-1.0>
+
+BASE = <http://SimanticsIntegrationTests@A> : PlatformUI.SharedOntology
+  @L0.new
+BASE.Layer0 : Tests.STSSuite
+BASE.Layer0.Layer0Exists : Tests.STSTest
+  Tests.STSTest.definition "70a8e455d4fa52f3e0ea81767b99a7506cfd2a712ef165686513fed02be148a2" // "> uriOf (resource \"http://www.simantics.org/Layer0-1.1\")\r\n\"http://www.simantics.org/Layer0-1.1..
+BASE.Layer0.Layer0Exists.SCLModule : L0.SCLModule
+  L0.SCLModule.definition ""
+BASE.Layer0.NameTests : Tests.STSTest
+  Tests.STSTest.definition "> nameOf layer0\r\n\"Layer0-1.1\""
+BASE.Layer0.SCL : L0.SCLModule
+  L0.SCLModule.definition "31c1a9551e06151fb93142e5e1d2756e56ebfb6f5f8799b22e2eb95c170c9bd9" // "include \"./../SCLMain\"\r\ninclude \"http://www.simantics.org/Layer0-1.1\" as L0\r\n\r\nlayer0 :: ..
+BASE.SCLMain : L0.SCLModule
+  L0.SCLModule.definition "include \"Simantics/DB\""
diff --git a/tests/org.simantics.tests.integration/SimanticsIntegrationTests.sharedLibrary b/tests/org.simantics.tests.integration/SimanticsIntegrationTests.sharedLibrary
new file mode 100644 (file)
index 0000000..8d46525
Binary files /dev/null and b/tests/org.simantics.tests.integration/SimanticsIntegrationTests.sharedLibrary differ
diff --git a/tests/org.simantics.tests.integration/SimanticsIntegrationTests.tg b/tests/org.simantics.tests.integration/SimanticsIntegrationTests.tg
new file mode 100644 (file)
index 0000000..b4d9a2b
Binary files /dev/null and b/tests/org.simantics.tests.integration/SimanticsIntegrationTests.tg differ
diff --git a/tests/org.simantics.tests.integration/build.properties b/tests/org.simantics.tests.integration/build.properties
new file mode 100644 (file)
index 0000000..aaa80a7
--- /dev/null
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               SimanticsIntegrationTests.tg
diff --git a/tests/org.simantics.tests.integration/pom.xml b/tests/org.simantics.tests.integration/pom.xml
new file mode 100644 (file)
index 0000000..6941bf8
--- /dev/null
@@ -0,0 +1,64 @@
+<?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>
+        <groupId>org.simantics</groupId>
+        <artifactId>org.simantics.root.tests</artifactId>
+        <version>1.0.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>org.simantics.tests.integration</artifactId>
+    <version>1.0.0-SNAPSHOT</version>
+    <packaging>eclipse-test-plugin</packaging>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.eclipse.tycho</groupId>
+                <artifactId>target-platform-configuration</artifactId>
+                    <configuration>
+                        <target>
+                            <artifact>
+                                <groupId>org.simantics</groupId>
+                                <artifactId>org.simantics.sdk.build.targetdefinition</artifactId>
+                                <version>1.0.0-SNAPSHOT</version>
+                            </artifact>
+                        </target>
+                    <dependency-resolution>
+                        <extraRequirements>
+                            <requirement>
+                                <type>eclipse-feature</type>
+                                <id>org.simantics.sdk</id>
+                                <versionRange>0.0.0</versionRange>
+                            </requirement>
+                            <requirement>
+                                <type>eclipse-feature</type>
+                                <id>org.simantics.tests.modelled.feature</id>
+                                <versionRange>0.0.0</versionRange>
+                            </requirement>
+                            <requirement>
+                                <type>eclipse-feature</type>
+                                <id>org.simantics.modeling</id>
+                                <versionRange>0.0.0</versionRange>
+                            </requirement>
+                        </extraRequirements>
+                    </dependency-resolution>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.eclipse.tycho</groupId>
+                <artifactId>tycho-surefire-plugin</artifactId>
+                <version>${tycho.version}</version>
+                <configuration>
+                    <application>org.eclipse.pde.junit.runtime.coretestapplication</application>
+                    <testClass>org.simantics.tests.integration.SimanticsIntegrationTestSuite</testClass>
+                    <forkMode>once</forkMode>
+                    <argLine>-Xms2512m -Xmx2512m</argLine>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
\ No newline at end of file
diff --git a/tests/org.simantics.tests.integration/src/org/simantics/tests/integration/RuntimeSTSSuite.java b/tests/org.simantics.tests.integration/src/org/simantics/tests/integration/RuntimeSTSSuite.java
new file mode 100644 (file)
index 0000000..f7c342a
--- /dev/null
@@ -0,0 +1,8 @@
+package org.simantics.tests.integration;
+
+import org.junit.runner.RunWith;
+import org.simantics.tests.modelled.junit.v2.ModelledSTSRunner;
+
+@RunWith(ModelledSTSRunner.class)
+public class RuntimeSTSSuite {
+}
\ No newline at end of file
diff --git a/tests/org.simantics.tests.integration/src/org/simantics/tests/integration/SimanticsIntegrationTestSuite.java b/tests/org.simantics.tests.integration/src/org/simantics/tests/integration/SimanticsIntegrationTestSuite.java
new file mode 100644 (file)
index 0000000..766b9fc
--- /dev/null
@@ -0,0 +1,11 @@
+package org.simantics.tests.integration;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+  RuntimeSTSSuite.class
+})
+public class SimanticsIntegrationTestSuite {
+}
\ No newline at end of file
index c5093e8530a36bd0e752901d8bb3787e908cac7a..b51195ff7c6ee7458207faf1932e29690eaf56be 100644 (file)
@@ -29,5 +29,6 @@
     <modules>
         <module>org.simantics.scl.compiler.tests</module>
         <module>org.simantics.scl.osgi.tests</module>
+        <module>org.simantics.tests.integration</module>
     </modules>
 </project>