diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2011-06-14 08:57:19 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2011-06-14 08:57:19 +0000 |
commit | 41cfd14858db52e8c3b8abd21a7f1944d14e4b0e (patch) | |
tree | fcb3383865e67da6aa30d46967542a4086feb4e1 /sca-java-2.x | |
parent | 95bd96114e639620b34b132a0a11079fa9139e25 (diff) |
Update to support using a node.xml config file in the domain directory
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1135417 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
3 files changed, 62 insertions, 1 deletions
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/TuscanyRuntime.java b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/TuscanyRuntime.java index 69d2d24840..5d84933374 100644 --- a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/TuscanyRuntime.java +++ b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/TuscanyRuntime.java @@ -163,7 +163,9 @@ public class TuscanyRuntime { /* * Create a node from a file system directory. - * The directory can contain: + * If the directory is actually a file use createNodeFromXML + * if the directory contains a file named node.xml then use createNodeFromXML + * Otherwise, the directory can contain: * domain.properties * contributions - jar, zip, or exploded directories * sca-contribution.xml metaData files to override whats in a contribution @@ -173,6 +175,15 @@ public class TuscanyRuntime { */ public Node createNode(File directory) throws ContributionReadException, ValidationException, ActivationException, XMLStreamException, IOException { + if (!directory.isDirectory()) { + return createNodeFromXML(directory.toURI().toURL().toString()); + } + + File nodeXML = new File(directory, "node.xml"); + if (nodeXML.exists()) { + return createNodeFromXML(nodeXML.toURI().toURL().toString()); + } + Properties domainProps = new Properties(); File propsFile = new File(directory, "domain.properties"); if (propsFile.exists()) { diff --git a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/DirectoryDomainTestCase.java b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/DirectoryDomainTestCase.java index fb863402c6..5bf1f53690 100644 --- a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/DirectoryDomainTestCase.java +++ b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/DirectoryDomainTestCase.java @@ -69,4 +69,27 @@ public class DirectoryDomainTestCase { Assert.assertEquals("sample", ic.getJavaExports().get(0));
}
+ @Test
+ public void testNodeXMLFile() throws ContributionReadException, ActivationException, ValidationException, XMLStreamException, IOException {
+ Node node = TuscanyRuntime.newInstance().createNode(new File("src/test/resources/helloworldNode.xml"));
+ Assert.assertEquals("helloworld", node.getDomainName());
+ List<String> cs = node.getInstalledContributionURIs();
+ Assert.assertEquals(1, cs.size());
+ Assert.assertEquals("sample-helloworld", cs.get(0));
+ Map<String, List<String>> startedComposites = node.getStartedCompositeURIs();
+ Assert.assertEquals(1, startedComposites.size());
+ Assert.assertEquals("helloworld.composite", startedComposites.get("sample-helloworld").get(0));
+ }
+
+ @Test
+ public void testNodeXMLDomain() throws ContributionReadException, ActivationException, ValidationException, XMLStreamException, IOException {
+ Node node = TuscanyRuntime.newInstance().createNode(new File("src/test/resources/test-domains/NodeXMLDomain"));
+ Assert.assertEquals("helloworld", node.getDomainName());
+ List<String> cs = node.getInstalledContributionURIs();
+ Assert.assertEquals(1, cs.size());
+ Assert.assertEquals("sample-helloworld", cs.get(0));
+ Map<String, List<String>> startedComposites = node.getStartedCompositeURIs();
+ Assert.assertEquals(1, startedComposites.size());
+ Assert.assertEquals("helloworld.composite", startedComposites.get("sample-helloworld").get(0));
+ }
}
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/test/resources/test-domains/NodeXMLDomain/node.xml b/sca-java-2.x/trunk/modules/domain-node/src/test/resources/test-domains/NodeXMLDomain/node.xml new file mode 100644 index 0000000000..1fe1ccff14 --- /dev/null +++ b/sca-java-2.x/trunk/modules/domain-node/src/test/resources/test-domains/NodeXMLDomain/node.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<node xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ domain="helloworld">
+
+ <contribution location="../../sample-helloworld.jar" startDeployables="true" />
+
+</node>
\ No newline at end of file |