]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - tests/org.simantics.scl.osgi.tests/src/org/simantics/scl/osgi/tests/TestSCLOsgi.java
Export all platform SCL documentation into HTML during test build
[simantics/platform.git] / tests / org.simantics.scl.osgi.tests / src / org / simantics / scl / osgi / tests / TestSCLOsgi.java
index 35a74c4f62c9189ed6712606ad7247de16d04f07..227381147552c8889994835de885bc6bee584eb4 100644 (file)
@@ -1,75 +1,60 @@
-package org.simantics.scl.osgi.tests;\r
-\r
-import java.util.ArrayList;\r
-import java.util.concurrent.atomic.AtomicInteger;\r
-\r
-import org.eclipse.core.runtime.IProgressMonitor;\r
-import org.eclipse.core.runtime.NullProgressMonitor;\r
-import org.junit.AfterClass;\r
-import org.junit.Assert;\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.simantics.PlatformException;\r
-import org.simantics.Simantics;\r
-import org.simantics.application.arguments.Arguments;\r
-import org.simantics.application.arguments.IArgumentFactory;\r
-import org.simantics.application.arguments.IArguments;\r
-import org.simantics.application.arguments.SimanticsArguments;\r
-import org.simantics.scl.compiler.errors.DoesNotExist;\r
-import org.simantics.scl.compiler.errors.Failable;\r
-import org.simantics.scl.compiler.module.Module;\r
-import org.simantics.scl.osgi.SCLOsgi;\r
-\r
-import gnu.trove.procedure.TObjectProcedure;\r
-\r
-\r
-public class TestSCLOsgi {\r
-    private static IProgressMonitor progress = new NullProgressMonitor();\r
-    \r
-    @BeforeClass\r
-    public static void setupDatabase() throws PlatformException {\r
-        String[] args = new String[0];\r
-        IArgumentFactory<?>[] accepted = {\r
-                SimanticsArguments.RECOVERY_POLICY_FIX_ERRORS,\r
-                SimanticsArguments.ONTOLOGY_RECOVERY_POLICY_REINSTALL,\r
-                SimanticsArguments.SERVER,\r
-                SimanticsArguments.LOCAL_SERVER_PORT,\r
-        };\r
-        IArguments arguments = Arguments.parse(args, accepted);\r
-        Simantics.startUpHeadless(arguments, progress);\r
-    }\r
-    \r
-    @AfterClass\r
-    public static void teardownDatabase() throws PlatformException {\r
-        Simantics.shutdown(progress);\r
-    }\r
-    \r
-    @Test\r
-    public void testDataJsonExists() {\r
-        ArrayList<String> modulesWithErrors = new ArrayList<String>(); \r
-        SCLOsgi.SOURCE_REPOSITORY.forAllModules(new TObjectProcedure<String>() {\r
-            @Override\r
-            public boolean execute(String moduleName) {\r
-                System.out.print(moduleName);\r
-                System.out.print(" - ");\r
-                Failable<Module> module = SCLOsgi.MODULE_REPOSITORY.getModule(moduleName);\r
-                if(module.didSucceed())\r
-                    System.out.println("succeeded");\r
-                else if(module == DoesNotExist.INSTANCE)\r
-                    System.out.println("does not exist"); // should not happen\r
-                else {\r
-                    System.out.println("error");\r
-                    modulesWithErrors.add(moduleName);\r
-                }\r
-                return true;\r
-            }\r
-        });\r
-        if(!modulesWithErrors.isEmpty()) {\r
-            StringBuilder b = new StringBuilder();\r
-            b.append("Some SCL modules failed to compile:");\r
-            for(String module : modulesWithErrors)\r
-                b.append(' ').append(module);\r
-            Assert.fail(b.toString());\r
-        }\r
-    }\r
-}\r
+package org.simantics.scl.osgi.tests;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.simantics.PlatformException;
+import org.simantics.Simantics;
+import org.simantics.application.arguments.Arguments;
+import org.simantics.application.arguments.IArgumentFactory;
+import org.simantics.application.arguments.IArguments;
+import org.simantics.application.arguments.SimanticsArguments;
+import org.simantics.scl.compiler.markdown.html.GenerateAllHtmlDocumentation;
+import org.simantics.scl.osgi.SCLOsgi;
+
+public class TestSCLOsgi {
+    private static IProgressMonitor progress = new NullProgressMonitor();
+    
+    @BeforeClass
+    public static void setupDatabase() throws PlatformException {
+        String[] args = new String[0];
+        IArgumentFactory<?>[] accepted = {
+                SimanticsArguments.RECOVERY_POLICY_FIX_ERRORS,
+                SimanticsArguments.ONTOLOGY_RECOVERY_POLICY_REINSTALL,
+                SimanticsArguments.SERVER,
+                SimanticsArguments.LOCAL_SERVER_PORT,
+        };
+        IArguments arguments = Arguments.parse(args, accepted);
+        Simantics.setDefaultDatabaseDriver("acorn");
+        Simantics.startUpHeadless(arguments, progress);
+    }
+    
+    @AfterClass
+    public static void teardownDatabase() throws PlatformException {
+        Simantics.shutdown(progress);
+    }
+    
+    @Test
+    public void testDataJsonExists() {
+        String possibleError = SCLOsgi.compileAllModules();
+        if(possibleError != null) {
+            Assert.fail(possibleError);
+        }
+    }
+    
+    @Test
+    public void exportAllSCLDocumentation() throws IOException {
+        // "./scldoc" evaluates to "tests/org.simantics.scl.osgi.tests/scldoc" when these tests are ran with Tycho/Maven
+        Path dir = Paths.get("./scldoc");
+        Files.createDirectories(dir);
+        GenerateAllHtmlDocumentation.generate(SCLOsgi.MODULE_REPOSITORY, dir);
+    }
+}