]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.osgi/src/org/simantics/scl/osgi/internal/BundleTestScriptRepository.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.scl.osgi / src / org / simantics / scl / osgi / internal / BundleTestScriptRepository.java
index 9bbebd30b1a65ca7932a5ec5d7db3a27fef31045..689ffc3289a81d82321a4107b5797e6887441619 100644 (file)
@@ -1,76 +1,76 @@
-package org.simantics.scl.osgi.internal;\r
-\r
-import java.net.URL;\r
-import java.util.ArrayList;\r
-import java.util.Collection;\r
-import java.util.Enumeration;\r
-\r
-import org.osgi.framework.Bundle;\r
-import org.osgi.framework.BundleContext;\r
-import org.osgi.framework.BundleEvent;\r
-import org.osgi.service.component.ComponentContext;\r
-import org.osgi.service.component.annotations.Activate;\r
-import org.osgi.service.component.annotations.Component;\r
-import org.osgi.service.component.annotations.Deactivate;\r
-import org.osgi.util.tracker.BundleTracker;\r
-import org.simantics.scl.compiler.testing.TestRunnable;\r
-import org.simantics.scl.compiler.testing.repository.TestRepository;\r
-\r
-import gnu.trove.map.hash.THashMap;\r
-\r
-@Component\r
-public class BundleTestScriptRepository implements TestRepository {\r
-    \r
-    Tracker tracker;\r
-    THashMap<String, BundleTestScriptRunnable> testsRunnables = new THashMap<String, BundleTestScriptRunnable>();\r
-    THashMap<Bundle, ArrayList<String>> testsPerBundle = new THashMap<Bundle, ArrayList<String>>();\r
-\r
-    @Activate\r
-    public void activate(ComponentContext context) {\r
-        tracker = new Tracker(context.getBundleContext());\r
-        tracker.open();\r
-    }\r
-    \r
-    @Deactivate\r
-    public void deactivate() {\r
-        tracker.close();\r
-    }\r
-    \r
-    class Tracker extends BundleTracker<Bundle> {\r
-        public Tracker(BundleContext context) {\r
-            super(context, 0xffffffff, null);\r
-        }\r
-        \r
-        @Override\r
-        synchronized public Bundle addingBundle(Bundle bundle, BundleEvent event) {\r
-            Enumeration<URL> urls = bundle.findEntries("sclTests", "*.sts", true);\r
-            if(urls != null) {\r
-                ArrayList<String> modulesInThisBundle = new ArrayList<String>();\r
-                while(urls.hasMoreElements()) {\r
-                    URL url = urls.nextElement();\r
-                    String path = url.getPath();\r
-                    String testName = path.substring(10, path.length()-4);\r
-                    testsRunnables.put(testName, new BundleTestScriptRunnable(testName, url));\r
-                    modulesInThisBundle.add(testName);\r
-                }\r
-                testsPerBundle.put(bundle, modulesInThisBundle);\r
-            }\r
-            return bundle;\r
-        }\r
-        \r
-        @Override\r
-        synchronized public void removedBundle(Bundle bundle, BundleEvent event,\r
-                Bundle object) {\r
-            ArrayList<String> moduleList = testsPerBundle.get(bundle);\r
-            if(moduleList != null)\r
-                for(String moduleName : moduleList)\r
-                    testsRunnables.remove(moduleName);\r
-        }\r
-    };\r
-    \r
-    @Override\r
-    public void collectTests(Collection<TestRunnable> tests) {\r
-        tests.addAll(testsRunnables.values());\r
-    }\r
-\r
-}\r
+package org.simantics.scl.osgi.internal;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Enumeration;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
+import org.osgi.service.component.ComponentContext;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.util.tracker.BundleTracker;
+import org.simantics.scl.compiler.testing.TestRunnable;
+import org.simantics.scl.compiler.testing.repository.TestRepository;
+
+import gnu.trove.map.hash.THashMap;
+
+@Component
+public class BundleTestScriptRepository implements TestRepository {
+    
+    Tracker tracker;
+    THashMap<String, BundleTestScriptRunnable> testsRunnables = new THashMap<String, BundleTestScriptRunnable>();
+    THashMap<Bundle, ArrayList<String>> testsPerBundle = new THashMap<Bundle, ArrayList<String>>();
+
+    @Activate
+    public void activate(ComponentContext context) {
+        tracker = new Tracker(context.getBundleContext());
+        tracker.open();
+    }
+    
+    @Deactivate
+    public void deactivate() {
+        tracker.close();
+    }
+    
+    class Tracker extends BundleTracker<Bundle> {
+        public Tracker(BundleContext context) {
+            super(context, 0xffffffff, null);
+        }
+        
+        @Override
+        synchronized public Bundle addingBundle(Bundle bundle, BundleEvent event) {
+            Enumeration<URL> urls = bundle.findEntries("sclTests", "*.sts", true);
+            if(urls != null) {
+                ArrayList<String> modulesInThisBundle = new ArrayList<String>();
+                while(urls.hasMoreElements()) {
+                    URL url = urls.nextElement();
+                    String path = url.getPath();
+                    String testName = path.substring(10, path.length()-4);
+                    testsRunnables.put(testName, new BundleTestScriptRunnable(testName, url));
+                    modulesInThisBundle.add(testName);
+                }
+                testsPerBundle.put(bundle, modulesInThisBundle);
+            }
+            return bundle;
+        }
+        
+        @Override
+        synchronized public void removedBundle(Bundle bundle, BundleEvent event,
+                Bundle object) {
+            ArrayList<String> moduleList = testsPerBundle.get(bundle);
+            if(moduleList != null)
+                for(String moduleName : moduleList)
+                    testsRunnables.remove(moduleName);
+        }
+    };
+    
+    @Override
+    public void collectTests(Collection<TestRunnable> tests) {
+        tests.addAll(testsRunnables.values());
+    }
+
+}