You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by an...@apache.org on 2010/07/03 08:30:18 UTC

svn commit: r960160 - in /tuscany/sca-java-2.x/trunk/modules/domain-node/src: main/java/org/apache/tuscany/sca/node2/ main/java/org/apache/tuscany/sca/node2/impl/ test/java/org/apache/tuscany/sca/node2/

Author: antelder
Date: Sat Jul  3 06:30:18 2010
New Revision: 960160

URL: http://svn.apache.org/viewvc?rev=960160&view=rev
Log:
Clean up factory instantiation, add a static helper to create simple nodes, and update impl to correctly resolve dependencies for installed contributions

Modified:
    tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/Node.java
    tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/NodeFactory.java
    tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/impl/DeployedComposite.java
    tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/impl/NodeImpl.java
    tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/DeployerTestCase.java
    tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/NodeTestCase.java

Modified: tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/Node.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/Node.java?rev=960160&r1=960159&r2=960160&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/Node.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/Node.java Sat Jul  3 06:30:18 2010
@@ -137,7 +137,7 @@ public interface Node {
      * @throws ValidationException 
      */
     String addDeploymentComposite(String contributionURI, Reader compositeXML) throws ContributionReadException, XMLStreamException, ActivationException, ValidationException;
-    String addDeploymentComposite(String contributionURI, Composite composite) throws ActivationException;
+    String addDeploymentComposite(String contributionURI, Composite composite) throws ActivationException, ValidationException;
 
     /**
      * 4599 10.5.2 add Deployment Composite & update Deployment Composite
@@ -183,8 +183,9 @@ public interface Node {
      *  
      * @param compositeURI
      * @throws ActivationException 
+     * @throws ValidationException 
      */
-    void addToDomainLevelComposite(String compositeURI) throws ActivationException;
+    void addToDomainLevelComposite(String compositeURI) throws ActivationException, ValidationException;
     
     /**
      * 4687 10.7.2 remove From Domain-Level Composite

Modified: tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/NodeFactory.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/NodeFactory.java?rev=960160&r1=960159&r2=960160&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/NodeFactory.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/NodeFactory.java Sat Jul  3 06:30:18 2010
@@ -44,22 +44,64 @@ public class NodeFactory {
     private ExtensibleDomainRegistryFactory domainRegistryFactory;
     private RuntimeAssemblyFactory assemblyFactory;
 
-    // TODO: keep this method?
-    public static Node createNode() {
-        return new NodeFactory().createNode("default");
+    /**
+     * A helper method to simplify creating a Node with an installed contributions
+     * @param compositeURI  URI of a composite to run relative to the first contribution
+     *         if compositeURI is null then all deployable composites in the first contribution will be run 
+     * @param contributionURLs  URLs to contributions to install
+     * @return a Node with installed contributions
+     */
+    public static Node createNode(String compositeURI, String... contributionURLs) {
+        try {
+            
+            Node node = newInstance().createOneoffNode();
+            String uri = "";
+            for (int i=contributionURLs.length-1; i>-1; i--) {
+                boolean runDeployables = (i==0) && (compositeURI == null);
+                int lastDot = contributionURLs[i].lastIndexOf('.');
+                int lastSep = contributionURLs[i].lastIndexOf("/");
+                if (lastDot > -1 && lastSep > -1 && lastDot > lastSep) {
+                    uri = contributionURLs[i].substring(lastSep+1, lastDot);
+                } else {
+                    uri = contributionURLs[i];
+                }
+
+                node.installContribution(uri, contributionURLs[i], null, null, runDeployables);
+            }
+            if (compositeURI != null) {
+                if (uri.endsWith("/")) {
+                    uri = uri + compositeURI;
+                } else {
+                    uri = uri + "/" + compositeURI;
+                }
+                node.addToDomainLevelComposite(uri);
+            }
+            return node;
+            
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
     }
 
-    public NodeFactory() {
-        init(null);
+    public static NodeFactory newInstance() {
+        return new NodeFactory(null);
+    }
+    public static NodeFactory newInstance(Properties config) {
+        return new NodeFactory(config);
     }
 
-    public NodeFactory(Properties config) {
+    protected NodeFactory(Properties config) {
         init(config);
     }
 
-    public Node createNode(String domainName) {
-        EndpointRegistry endpointRegistry = domainRegistryFactory.getEndpointRegistry("default", domainName);
-        return new NodeImpl(domainName, deployer, compositeActivator, endpointRegistry, extensionPointRegistry);
+    public Node createNode(String domainURI) {
+        EndpointRegistry endpointRegistry = domainRegistryFactory.getEndpointRegistry("default", domainURI);
+        return new NodeImpl(domainURI, deployer, compositeActivator, endpointRegistry, extensionPointRegistry, null);
+    }
+
+    protected Node createOneoffNode() {
+        EndpointRegistry endpointRegistry = domainRegistryFactory.getEndpointRegistry("default", "default");
+        return new NodeImpl("default", deployer, compositeActivator, endpointRegistry, extensionPointRegistry, this);
     }
 
     public void stop() {
@@ -91,8 +133,6 @@ public class NodeFactory {
         extensionPointRegistry.getExtensionPoint(ModuleActivatorExtensionPoint.class);
 
         this.domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(extensionPointRegistry);
-//        DomainRegistryFactory domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(extensionPointRegistry);
-//        domainRegistryFactory.getEndpointRegistry(config.getProperty("reguri"), config.getProperty("defaultDomainName"));
 
     }
     /**

Modified: tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/impl/DeployedComposite.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/impl/DeployedComposite.java?rev=960160&r1=960159&r2=960160&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/impl/DeployedComposite.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/impl/DeployedComposite.java Sat Jul  3 06:30:18 2010
@@ -59,7 +59,7 @@ public class DeployedComposite {
                              Deployer deployer,
                              CompositeActivator compositeActivator,
                              EndpointRegistry endpointRegistry,
-                             ExtensionPointRegistry extensionPointRegistry) throws ActivationException {
+                             ExtensionPointRegistry extensionPointRegistry) throws ValidationException, ActivationException {
         this.composite = composite;
         this.installedContribution = ic;
         this.dependedOnContributions = dependedOnContributions;
@@ -69,12 +69,14 @@ public class DeployedComposite {
         this.extensionPointRegistry = extensionPointRegistry;
         try {
             init();
-        } catch (Exception e) {
+        } catch (ContributionResolveException e) {
+            throw new ActivationException(e);
+        } catch (CompositeBuilderException e) {
             throw new ActivationException(e);
         }
     }
 
-    protected void init() throws ValidationException, ContributionResolveException, CompositeBuilderException, ActivationException {
+    protected void init() throws ValidationException, ActivationException, ContributionResolveException, CompositeBuilderException {
         
         List<Contribution> contribution = new ArrayList<Contribution>();
         contribution.add(installedContribution.getContribution());

Modified: tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/impl/NodeImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/impl/NodeImpl.java?rev=960160&r1=960159&r2=960160&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/impl/NodeImpl.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/node2/impl/NodeImpl.java Sat Jul  3 06:30:18 2010
@@ -31,7 +31,6 @@ import java.util.Set;
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
 
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
 import org.apache.tuscany.sca.assembly.Composite;
 import org.apache.tuscany.sca.common.java.io.IOHelper;
 import org.apache.tuscany.sca.contribution.Artifact;
@@ -39,11 +38,11 @@ import org.apache.tuscany.sca.contributi
 import org.apache.tuscany.sca.contribution.ContributionMetadata;
 import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
 import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.core.FactoryExtensionPoint;
 import org.apache.tuscany.sca.deployment.Deployer;
 import org.apache.tuscany.sca.monitor.Monitor;
 import org.apache.tuscany.sca.monitor.ValidationException;
 import org.apache.tuscany.sca.node2.Node;
+import org.apache.tuscany.sca.node2.NodeFactory;
 import org.apache.tuscany.sca.runtime.ActivationException;
 import org.apache.tuscany.sca.runtime.CompositeActivator;
 import org.apache.tuscany.sca.runtime.EndpointRegistry;
@@ -59,13 +58,15 @@ public class NodeImpl implements Node {
     private CompositeActivator compositeActivator;
     private EndpointRegistry endpointRegistry;
     private ExtensionPointRegistry extensionPointRegistry;
+    private NodeFactory nodeFactory;
     
-    public NodeImpl(String domainName, Deployer deployer, CompositeActivator compositeActivator, EndpointRegistry endpointRegistry, ExtensionPointRegistry extensionPointRegistry) {
+    public NodeImpl(String domainName, Deployer deployer, CompositeActivator compositeActivator, EndpointRegistry endpointRegistry, ExtensionPointRegistry extensionPointRegistry, NodeFactory nodeFactory) {
         this.domainName = domainName;
         this.deployer = deployer;
         this.compositeActivator = compositeActivator;
         this.endpointRegistry = endpointRegistry;
         this.extensionPointRegistry = extensionPointRegistry;
+        this.nodeFactory = nodeFactory;
     }
 
     public String installContribution(String contributionURL) throws ContributionReadException, ActivationException, ValidationException {
@@ -112,7 +113,38 @@ public class NodeImpl implements Node {
             for (Composite c : ic.getDefaultDeployables()) {
                 runComposite(c, ic);
             }
+        } else {
+            contribution.getDeployables().clear();
+            
+            List<Contribution> dependentContributions = calculateDependentContributions(ic);
+
+            Monitor monitor = deployer.createMonitor();
+            try {
+                deployer.resolve(contribution, dependentContributions, monitor);
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+            monitor.analyzeProblems();
+        }
+    }
+
+    protected List<Contribution> calculateDependentContributions(InstalledContribution ic) {
+        List<Contribution> dependentContributions = new ArrayList<Contribution>();
+        if (ic.getDependentContributionURIs() != null) {
+            // if the install specified dependent uris use just those contributions
+            for (String uri : ic.getDependentContributionURIs()) {
+                InstalledContribution dependee = installedContributions.get(uri);
+                if (dependee != null) {
+                    dependentContributions.add(dependee.getContribution());
+                }
+            }
+        } else {
+            // otherwise use all available contributions for dependents
+            for (InstalledContribution ics : installedContributions.values()) {
+                dependentContributions.add(ics.getContribution());
+            }
         }
+        return dependentContributions;
     }
 
     public String addDeploymentComposite(String contributionURI, Reader compositeXML) throws ContributionReadException, XMLStreamException, ActivationException, ValidationException {
@@ -122,7 +154,7 @@ public class NodeImpl implements Node {
         return addDeploymentComposite(contributionURI, composite);
     }
 
-    public String addDeploymentComposite(String contributionURI, Composite composite) throws ActivationException {
+    public String addDeploymentComposite(String contributionURI, Composite composite) throws ActivationException, ValidationException {
         InstalledContribution ic = installedContributions.get(contributionURI);
         if (ic == null) {
             throw new IllegalArgumentException("contribution not installed: " + contributionURI);
@@ -132,7 +164,7 @@ public class NodeImpl implements Node {
         return compositeArtifcatURI;
     }
 
-    public void addToDomainLevelComposite(String compositeURI) throws ActivationException {
+    public void addToDomainLevelComposite(String compositeURI) throws ActivationException, ValidationException {
         String contributionURI = getContributionUriForArtifact(compositeURI);
         InstalledContribution ic = installedContributions.get(contributionURI);
         if (ic == null) {
@@ -222,6 +254,9 @@ public class NodeImpl implements Node {
                 e.printStackTrace();
             }
         }
+        if (nodeFactory != null) {
+            nodeFactory.stop();
+        }
     }
 
     public <T> T getService(Class<T> interfaze, String serviceURI) throws NoSuchServiceException {
@@ -272,22 +307,8 @@ public class NodeImpl implements Node {
         return contributionURI;
     }
 
-    protected void runComposite(Composite c, InstalledContribution ic) throws ActivationException {
-        List<Contribution> dependentContributions = new ArrayList<Contribution>();
-        if (ic.getDependentContributionURIs() != null) {
-            // if the install specified dependent uris use just those contributions
-            for (String uri : ic.getDependentContributionURIs()) {
-                InstalledContribution dependee = installedContributions.get(uri);
-                if (dependee != null) {
-                    dependentContributions.add(dependee.getContribution());
-                }
-            }
-        } else {
-            // otherwise use all available contributions for dependents
-            for (InstalledContribution ics : installedContributions.values()) {
-                dependentContributions.add(ics.getContribution());
-            }
-        }
+    protected void runComposite(Composite c, InstalledContribution ic) throws ActivationException, ValidationException {
+        List<Contribution> dependentContributions = calculateDependentContributions(ic);
 
         DeployedComposite dc = new DeployedComposite(c, ic, dependentContributions, deployer, compositeActivator, endpointRegistry, extensionPointRegistry);
         ic.getDeployedComposites().add(dc);
@@ -309,14 +330,4 @@ public class NodeImpl implements Node {
         }
         return dependentContributionURIs;
     }
-
-    public Deployer getDeployer() {
-        return deployer;
-    }
-
-    public AssemblyFactory getAssemblyFactory() {
-        FactoryExtensionPoint factories = extensionPointRegistry.getExtensionPoint(FactoryExtensionPoint.class);
-        return factories.getFactory(AssemblyFactory.class);
-    }
-
 }

Modified: tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/DeployerTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/DeployerTestCase.java?rev=960160&r1=960159&r2=960160&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/DeployerTestCase.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/DeployerTestCase.java Sat Jul  3 06:30:18 2010
@@ -42,7 +42,7 @@ public class DeployerTestCase {
 
     @Test
     public void testInstalledContribution() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, MalformedURLException {
-        NodeFactory nodeFactory = new NodeFactory();
+        NodeFactory nodeFactory = NodeFactory.newInstance();
         Node node = nodeFactory.createNode("myDomain");
         
         Deployer deployer = nodeFactory.getDeployer();
@@ -58,7 +58,7 @@ public class DeployerTestCase {
 
     @Test
     public void testAddDeploymentComposite() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, MalformedURLException, XMLStreamException {
-        NodeFactory nodeFactory = new NodeFactory();
+        NodeFactory nodeFactory = NodeFactory.newInstance();
         Node node = nodeFactory.createNode("myDomain");
         
         node.installContribution("foo", "src/test/resources/sample-helloworld-nodeployable.jar", null, null, true);

Modified: tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/NodeTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/NodeTestCase.java?rev=960160&r1=960159&r2=960160&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/NodeTestCase.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/NodeTestCase.java Sat Jul  3 06:30:18 2010
@@ -38,30 +38,30 @@ public class NodeTestCase {
 
     @Test
     public void testInstallDeployable() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
-        Node section10 = NodeFactory.createNode();
-        section10.installContribution("helloworld", "src/test/resources/sample-helloworld.jar", null, null, true);
+        Node node = NodeFactory.newInstance().createNode("default");
+        node.installContribution("helloworld", "src/test/resources/sample-helloworld.jar", null, null, true);
 
-//        Helloworld helloworldService = section10.getService(Helloworld.class, "HelloworldComponent");
+//        Helloworld helloworldService = node.getService(Helloworld.class, "HelloworldComponent");
 //        Assert.assertEquals("Hello petra", helloworldService.sayHello("petra"));
     }
 
     @Ignore("TODO: fails with Sun JDK due to SCA properties issue")
     @Test
     public void testInstallWithDependent() throws NoSuchServiceException, ContributionReadException, ActivationException, ValidationException {
-        Node section10 = NodeFactory.createNode();
-        section10.installContribution("store", "/Tuscany/svn/2.x-trunk/itest/T3558/src/test/resources/sample-store.jar", null, null, true);
-        section10.installContribution("store-client", "/Tuscany/svn/2.x-trunk/itest/T3558/src/test/resources/sample-store-client.jar", null, null, true);
+        Node node = NodeFactory.newInstance().createNode("default");
+        node.installContribution("store", "/Tuscany/svn/2.x-trunk/itest/T3558/src/test/resources/sample-store.jar", null, null, true);
+        node.installContribution("store-client", "/Tuscany/svn/2.x-trunk/itest/T3558/src/test/resources/sample-store-client.jar", null, null, true);
 
-//        Helloworld helloworldService = section10.getService(Helloworld.class, "HelloworldComponent");
+//        Helloworld helloworldService = node.getService(Helloworld.class, "HelloworldComponent");
 //        Assert.assertEquals("Hello petra", helloworldService.sayHello("petra"));
     }
 
     @Test
     public void testInstallNoDeployable() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
-        Node section10 = NodeFactory.createNode();
-        section10.installContribution("helloworld", "src/test/resources/sample-helloworld-nodeployable.jar", null, null, true);
+        Node node = NodeFactory.newInstance().createNode("default");
+        node.installContribution("helloworld", "src/test/resources/sample-helloworld-nodeployable.jar", null, null, true);
 
-//        SCAClientFactory scaClientFactory = section10.getSCAClientFactory();
+//        SCAClientFactory scaClientFactory = node.getSCAClientFactory();
 //        try {
 //            scaClientFactory.getService(Helloworld.class, "HelloworldComponent");
 //            Assert.fail();
@@ -69,44 +69,44 @@ public class NodeTestCase {
 //            // expected as there is no deployables
 //        }
 
-        section10.addToDomainLevelComposite("helloworld" + "/helloworld.composite");
+        node.addToDomainLevelComposite("helloworld" + "/helloworld.composite");
 //        Helloworld helloworldService = scaClientFactory.getService(Helloworld.class, "HelloworldComponent");
 //        Assert.assertEquals("Hello petra", helloworldService.sayHello("petra"));
     }
 
     @Test
     public void testGetInstalledContributions() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
-        Node section10 = NodeFactory.createNode();
-        section10.installContribution("foo", "src/test/resources/sample-helloworld-nodeployable.jar", null, null, true);
-        List<String> ics = section10.getInstalledContributions();
+        Node node = NodeFactory.newInstance().createNode("default");
+        node.installContribution("foo", "src/test/resources/sample-helloworld-nodeployable.jar", null, null, true);
+        List<String> ics = node.getInstalledContributions();
         Assert.assertEquals(1, ics.size());
         Assert.assertEquals("foo", ics.get(0));
     }
 
     @Test
     public void testGetDeployedCompostes() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, MalformedURLException, ActivationException, ValidationException {
-        Node section10 = NodeFactory.createNode();
-        section10.installContribution("foo", "src/test/resources/sample-helloworld.jar", null, null, true);
-        List<String> dcs = section10.getDeployedCompostes("foo");
+        Node node = NodeFactory.newInstance().createNode("default");
+        node.installContribution("foo", "src/test/resources/sample-helloworld.jar", null, null, true);
+        List<String> dcs = node.getDeployedCompostes("foo");
         Assert.assertEquals(1, dcs.size());
         Assert.assertEquals("foo/helloworld.composite", dcs.get(0));
     }
 
     @Test
     public void testRemoveComposte() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, MalformedURLException, ActivationException, ValidationException {
-        Node section10 = NodeFactory.createNode();
-        section10.installContribution("foo", "src/test/resources/sample-helloworld.jar", null, null, true);
-        section10.removeFromDomainLevelComposite("foo/helloworld.composite");
-        List<String> dcs = section10.getDeployedCompostes("foo");
+        Node node = NodeFactory.newInstance().createNode("default");
+        node.installContribution("foo", "src/test/resources/sample-helloworld.jar", null, null, true);
+        node.removeFromDomainLevelComposite("foo/helloworld.composite");
+        List<String> dcs = node.getDeployedCompostes("foo");
         Assert.assertEquals(0, dcs.size());
     }
 
     @Test
     public void testInstallWithMetaData() throws ContributionReadException, ActivationException, ValidationException {
-        Node section10 = NodeFactory.createNode();
-        ((NodeImpl)section10).installContribution("helloworld", "src/test/resources/sample-helloworld-nodeployable.jar", "src/test/resources/sca-contribution-generated.xml", null, true);
+        Node node = NodeFactory.newInstance().createNode("default");
+        ((NodeImpl)node).installContribution("helloworld", "src/test/resources/sample-helloworld-nodeployable.jar", "src/test/resources/sca-contribution-generated.xml", null, true);
 
-        List<String> dcs = section10.getDeployedCompostes("helloworld");
+        List<String> dcs = node.getDeployedCompostes("helloworld");
         Assert.assertEquals(1, dcs.size());
         Assert.assertEquals("helloworld/helloworld.composite", dcs.get(0));
 
@@ -116,8 +116,28 @@ public class NodeTestCase {
 
     @Test
     public void testURI() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
-        Node section10 = NodeFactory.createNode();
-        String uri = section10.installContribution("src/test/resources/sample-helloworld.jar");
+        Node node = NodeFactory.newInstance().createNode("default");
+        String uri = node.installContribution("src/test/resources/sample-helloworld.jar");
         Assert.assertEquals("sample-helloworld", uri);
     }
+
+    @Test
+    public void testStaticCreate() {
+        Node node = NodeFactory.createNode("helloworld.composite", "src/test/resources/sample-helloworld.jar");
+        List<String> cs = node.getInstalledContributions();
+        Assert.assertEquals(1, cs.size());
+        List<String> dcs = node.getDeployedCompostes(cs.get(0));
+        Assert.assertEquals(1, dcs.size());
+        Assert.assertEquals("sample-helloworld/helloworld.composite", dcs.get(0));
+    }
+
+    @Test
+    public void testStaticCreateWithNullComposite() {
+        Node node = NodeFactory.createNode(null, "src/test/resources/sample-helloworld.jar");
+        List<String> cs = node.getInstalledContributions();
+        Assert.assertEquals(1, cs.size());
+        List<String> dcs = node.getDeployedCompostes(cs.get(0));
+        Assert.assertEquals(1, dcs.size());
+        Assert.assertEquals("sample-helloworld/helloworld.composite", dcs.get(0));
+    }
 }