summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-2.x/trunk')
-rw-r--r--sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/ConfigAttributesImpl.java35
-rw-r--r--sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java117
-rw-r--r--sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/ConfigTestCase.java64
-rw-r--r--sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/GetServiceTestCase.java23
-rw-r--r--sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.java23
-rw-r--r--sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/OneNodeTestCase.java2
-rw-r--r--sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/StopStartNodesTestCase.java10
7 files changed, 57 insertions, 217 deletions
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/ConfigAttributesImpl.java b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/ConfigAttributesImpl.java
deleted file mode 100644
index 9a10cbd306..0000000000
--- a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/ConfigAttributesImpl.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.tuscany.sca.domain.node;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.tuscany.sca.management.ConfigAttributes;
-
-public class ConfigAttributesImpl implements ConfigAttributes {
-
- private Map<String, String> attributes = new HashMap<String, String>();
-
- public Map<String, String> getAttributes() {
- return attributes;
- }
-
-}
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java
index 2c9e6dfb77..f6c6dca6ec 100644
--- a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java
+++ b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java
@@ -28,10 +28,8 @@ import java.util.Map;
import org.apache.tuscany.sca.assembly.Endpoint;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.UtilityExtensionPoint;
-import org.apache.tuscany.sca.management.ConfigAttributes;
import org.apache.tuscany.sca.node.Node;
import org.apache.tuscany.sca.node.NodeFactory;
-import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
import org.apache.tuscany.sca.node.impl.NodeImpl;
import org.apache.tuscany.sca.runtime.DomainRegistryFactory;
import org.apache.tuscany.sca.runtime.EndpointRegistry;
@@ -41,57 +39,37 @@ import org.oasisopen.sca.client.SCAClient;
public class DomainNode {
- public static final String DOMAIN_NAME_ATTR = "domainName";
- public static final String DOMAIN_SCHEME_ATTR = "domainScheme";
- public static final String DEFAULT_DOMAIN_SCHEME = "vm";
- public static final String DEFAULT_DOMAIN_NAME = "defaultDomain";
+ private static final String DEFAULT_DOMAIN_SCHEME = "vm";
+ private static final String DEFAULT_DOMAIN_NAME = "defaultDomain";
+ private static final String DEFAULT_CONFIG_URI = DEFAULT_DOMAIN_SCHEME + "://" + DEFAULT_DOMAIN_NAME;
- private ConfigAttributes configAttributes = new ConfigAttributesImpl();
+ private String domainName;
private String domainRegistryURI;
private NodeFactory nodeFactory;
private Map<String, Node> nodes = new HashMap<String, Node>();
public DomainNode() {
- this(DEFAULT_DOMAIN_SCHEME + "://" + DEFAULT_DOMAIN_NAME);
+ this(DEFAULT_CONFIG_URI, new String[]{});
}
- public DomainNode(String configURI) {
- this.domainRegistryURI = configURI;
- parseConfigURI(configURI);
- start();
+ public DomainNode(String... contributionLocations) {
+ this(DEFAULT_CONFIG_URI, contributionLocations);
}
- public DomainNode(String configURI, String... contributionLocations) {
+ public DomainNode(String configURI, String[] contributionLocations) {
this.domainRegistryURI = configURI;
- parseConfigURI(configURI);
- start();
+ initDomainName(configURI);
+ nodeFactory = NodeFactory.getInstance(domainName);
for (String loc : contributionLocations) {
addContribution(loc);
}
}
-
- public void start() {
- if (nodeFactory != null) {
- throw new IllegalStateException("The node is already started");
- }
-
- nodeFactory = NodeFactory.getInstance(configAttributes.getAttributes().get(DOMAIN_NAME_ATTR));
- }
-
- public boolean isStarted() {
- return nodeFactory != null;
- }
public void stop() {
- if (nodeFactory == null) {
- throw new IllegalStateException("The node is not started");
- }
-
for (Node node : nodes.values()) {
node.stop();
}
-
}
public String addContribution(String location) {
@@ -104,12 +82,7 @@ public class DomainNode {
if (nodes.containsKey(uri)) {
throw new IllegalArgumentException("contribution already added: " + uri);
}
- NodeConfiguration configuration = nodeFactory.createNodeConfiguration();
- configuration.addContribution(uri, location);
- configuration.setDomainRegistryURI(domainRegistryURI);
- configuration.setDomainURI(configAttributes.getAttributes().get(DOMAIN_NAME_ATTR));
- configuration.setURI(uri);
- Node node = nodeFactory.createNode(configuration).start();
+ Node node = nodeFactory.createNode((String)null, new String[] {uri}, new String[] {location}).start();
nodes.put(uri, node);
}
@@ -121,50 +94,8 @@ public class DomainNode {
node.stop();
}
- public ConfigAttributes getConfigAttributes() {
- return configAttributes;
- }
-
public String getDomainName() {
- return configAttributes.getAttributes().get(DOMAIN_NAME_ATTR);
- }
-
- protected void parseConfigURI(String configURI) {
- URI uri = URI.create(fixScheme(configURI));
- String dn = uri.getHost();
- if (dn == null || dn.length() < 1) {
- dn = DEFAULT_DOMAIN_NAME;
- }
- configAttributes.getAttributes().put(DOMAIN_NAME_ATTR, dn);
- String scheme = uri.getScheme();
- if (scheme != null && scheme.length() > 0) {
- configAttributes.getAttributes().put(DOMAIN_SCHEME_ATTR, scheme);
- }
-
- String query = uri.getQuery();
- if (query != null && query.length() > 0) {
- String[] params = query.split("&");
- for (String param : params){
- String name = param.split("=")[0];
- String value = param.split("=")[1];
- configAttributes.getAttributes().put(name, value);
- }
- }
- }
-
- /**
- * I keep typing the scheme part with just a colon instead of colon slash slash
- * which URI doesn't parse properly which irritates me so fix it up here
- */
- private String fixScheme(String uri) {
- int i = uri.indexOf(":");
- if (i > -1 && uri.charAt(i+1) != '/') {
- uri = uri.replaceFirst(":", ":/");
- }
- if (i > -1 && uri.charAt(i+2) != '/') {
- uri = uri.replaceFirst(":/", "://");
- }
- return uri;
+ return domainName;
}
public String getDomainConfigURI() {
@@ -201,4 +132,28 @@ public class DomainNode {
throw new IllegalStateException(e);
}
}
+
+ protected void initDomainName(String configURI) {
+ URI uri = URI.create(fixScheme(configURI));
+ String dn = uri.getHost();
+ if (dn == null || dn.length() < 1) {
+ dn = DEFAULT_DOMAIN_NAME;
+ }
+ domainName = dn;
+ }
+
+ /**
+ * I keep typing the scheme part with just a colon instead of colon slash slash
+ * which URI doesn't parse properly which irritates me so fix it up here
+ */
+ protected String fixScheme(String uri) {
+ int i = uri.indexOf(":");
+ if (i > -1 && uri.charAt(i+1) != '/') {
+ uri = uri.replaceFirst(":", ":/");
+ }
+ if (i > -1 && uri.charAt(i+2) != '/') {
+ uri = uri.replaceFirst(":/", "://");
+ }
+ return uri;
+ }
}
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/ConfigTestCase.java b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/ConfigTestCase.java
deleted file mode 100644
index 1d31a5467f..0000000000
--- a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/ConfigTestCase.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.tuscany.sca.domain.node;
-
-import static org.junit.Assert.assertEquals;
-
-import org.apache.tuscany.sca.domain.node.DomainNode;
-import org.junit.Test;
-
-/**
- * This shows how to test the Calculator service component.
- */
-public class ConfigTestCase{
-
- @Test
- public void testConfig() throws Exception {
- DomainNode domain = new DomainNode("foo://someDomain:1234?p1=x&p2=y");
- assertEquals(4, domain.getConfigAttributes().getAttributes().size());
- assertEquals("someDomain", domain.getDomainName());
- assertEquals("foo", domain.getConfigAttributes().getAttributes().get("domainScheme"));
- assertEquals("someDomain", domain.getConfigAttributes().getAttributes().get("domainName"));
- assertEquals("x", domain.getConfigAttributes().getAttributes().get("p1"));
- assertEquals("y", domain.getConfigAttributes().getAttributes().get("p2"));
- }
-
- @Test
- public void testConfig1() throws Exception {
- DomainNode domain = new DomainNode("foo:someDomain:1234?p1=x&p2=y");
- assertEquals(4, domain.getConfigAttributes().getAttributes().size());
- assertEquals("someDomain", domain.getDomainName());
- assertEquals("foo", domain.getConfigAttributes().getAttributes().get("domainScheme"));
- assertEquals("someDomain", domain.getConfigAttributes().getAttributes().get("domainName"));
- assertEquals("x", domain.getConfigAttributes().getAttributes().get("p1"));
- assertEquals("y", domain.getConfigAttributes().getAttributes().get("p2"));
- }
-
- @Test
- public void testConfig2() throws Exception {
- DomainNode domain = new DomainNode("foo:/someDomain:1234?p1=x&p2=y");
- assertEquals(4, domain.getConfigAttributes().getAttributes().size());
- assertEquals("someDomain", domain.getDomainName());
- assertEquals("foo", domain.getConfigAttributes().getAttributes().get("domainScheme"));
- assertEquals("someDomain", domain.getConfigAttributes().getAttributes().get("domainName"));
- assertEquals("x", domain.getConfigAttributes().getAttributes().get("p1"));
- assertEquals("y", domain.getConfigAttributes().getAttributes().get("p2"));
- }
-}
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/GetServiceTestCase.java b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/GetServiceTestCase.java
index f8399cf9eb..bee9e0b25a 100644
--- a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/GetServiceTestCase.java
+++ b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/GetServiceTestCase.java
@@ -21,14 +21,12 @@ package org.apache.tuscany.sca.domain.node;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import itest.nodes.Helloworld;
import static org.junit.Assert.fail;
+import itest.nodes.Helloworld;
-import org.apache.tuscany.sca.domain.node.DomainNode;
import org.junit.After;
import org.junit.Test;
import org.oasisopen.sca.SCARuntimeException;
-import org.oasisopen.sca.client.SCAClient;
/**
* This shows how to test the Calculator service component.
@@ -40,8 +38,8 @@ public class GetServiceTestCase{
@Test
public void testTwoNodesSameDomain() throws Exception {
- serviceNode = new DomainNode("vm://fooDomain", "target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar");
- clientNode = new DomainNode("vm://fooDomain", "target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar");
+ serviceNode = new DomainNode("target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar");
+ clientNode = new DomainNode("target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar");
Helloworld service = serviceNode.getService(Helloworld.class, "HelloworldService");
assertNotNull(service);
@@ -50,23 +48,16 @@ public class GetServiceTestCase{
Helloworld client = clientNode.getService(Helloworld.class, "HelloworldClient");
assertNotNull(client);
assertEquals("Hi Hello Petra", client.sayHello("Petra"));
-
- if (clientNode != null && clientNode.isStarted()) {
- clientNode.stop();
- }
- if (serviceNode != null && serviceNode.isStarted()) {
- serviceNode.stop();
- }
}
@Test
public void testTwoNodesDifferentDomains() throws Exception {
- serviceNode = new DomainNode("vm://fooDomain", "target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar");
+ serviceNode = new DomainNode("vm://fooDomain", new String[]{"target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar"});
Helloworld service = serviceNode.getService(Helloworld.class, "HelloworldService");
assertNotNull(service);
assertEquals("Hello Petra", service.sayHello("Petra"));
- clientNode = new DomainNode("vm://barDomain", "target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar");
+ clientNode = new DomainNode("vm://barDomain", new String[] {"target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar"});
Helloworld client = clientNode.getService(Helloworld.class, "HelloworldClient");
assertNotNull(client);
@@ -81,10 +72,10 @@ public class GetServiceTestCase{
@After
public void tearDownAfterClass() throws Exception {
- if (clientNode != null && clientNode.isStarted()) {
+ if (clientNode != null) {
clientNode.stop();
}
- if (serviceNode != null && serviceNode.isStarted()) {
+ if (serviceNode != null) {
serviceNode.stop();
}
}
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.java b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.java
index 20d7470a66..d901ba4280 100644
--- a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.java
+++ b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.java
@@ -40,33 +40,26 @@ public class MultipleNodesPerJVMTestCase{
@Test
public void testTwoNodesSameDomain() throws Exception {
- serviceNode = new DomainNode("vm://fooDomain", "target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar");
- clientNode = new DomainNode("vm://fooDomain", "target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar");
+ serviceNode = new DomainNode("target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar");
+ clientNode = new DomainNode("target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar");
- Helloworld service = SCAClient.getService(Helloworld.class, "fooDomain/HelloworldService");
+ Helloworld service = SCAClient.getService(Helloworld.class, "defaultDomain/HelloworldService");
assertNotNull(service);
assertEquals("Hello Petra", service.sayHello("Petra"));
- Helloworld client = SCAClient.getService(Helloworld.class, "fooDomain/HelloworldClient");
+ Helloworld client = SCAClient.getService(Helloworld.class, "defaultDomain/HelloworldClient");
assertNotNull(client);
assertEquals("Hi Hello Petra", client.sayHello("Petra"));
-
- if (clientNode != null && clientNode.isStarted()) {
- clientNode.stop();
- }
- if (serviceNode != null && serviceNode.isStarted()) {
- serviceNode.stop();
- }
}
@Test
public void testTwoNodesDifferentDomains() throws Exception {
- serviceNode = new DomainNode("vm://fooDomain", "target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar");
+ serviceNode = new DomainNode("vm://fooDomain", new String[]{"target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar"});
Helloworld service = SCAClient.getService(Helloworld.class, "fooDomain/HelloworldService");
assertNotNull(service);
assertEquals("Hello Petra", service.sayHello("Petra"));
- clientNode = new DomainNode("vm://barDomain", "target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar");
+ clientNode = new DomainNode("vm://barDomain", new String[]{"target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar"});
Helloworld client = SCAClient.getService(Helloworld.class, "barDomain/HelloworldClient");
assertNotNull(client);
@@ -81,10 +74,10 @@ public class MultipleNodesPerJVMTestCase{
@After
public void tearDownAfterClass() throws Exception {
- if (clientNode != null && clientNode.isStarted()) {
+ if (clientNode != null) {
clientNode.stop();
}
- if (serviceNode != null && serviceNode.isStarted()) {
+ if (serviceNode != null) {
serviceNode.stop();
}
}
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/OneNodeTestCase.java b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/OneNodeTestCase.java
index a5c829b87f..100cbde17a 100644
--- a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/OneNodeTestCase.java
+++ b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/OneNodeTestCase.java
@@ -95,7 +95,7 @@ public class OneNodeTestCase{
@After
public void tearDownAfterClass() throws Exception {
- if (domain != null && domain.isStarted()) {
+ if (domain != null) {
domain.stop();
}
}
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/StopStartNodesTestCase.java b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/StopStartNodesTestCase.java
index 3ee89b0a04..fdfd3fa0cb 100644
--- a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/StopStartNodesTestCase.java
+++ b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/StopStartNodesTestCase.java
@@ -38,8 +38,8 @@ public class StopStartNodesTestCase{
@Test
public void testTwoNodesSameDomain() throws Exception {
- serviceNode = new DomainNode("vm://fooDomain", "target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar");
- clientNode = new DomainNode("vm://fooDomain", "target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar");
+ serviceNode = new DomainNode("vm://fooDomain", new String[]{"target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar"});
+ clientNode = new DomainNode("vm://fooDomain", new String[]{"target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar"});
Helloworld service = SCAClient.getService(Helloworld.class, "fooDomain/HelloworldService");
assertNotNull(service);
@@ -60,7 +60,7 @@ public class StopStartNodesTestCase{
// expected
}
- serviceNode = new DomainNode("vm://fooDomain", "target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar");
+ serviceNode = new DomainNode("vm://fooDomain", new String[]{"target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar"});
client = SCAClient.getService(Helloworld.class, "fooDomain/HelloworldClient");
assertNotNull(client);
assertEquals("Hi Hello Petra", client.sayHello("Petra"));
@@ -68,10 +68,10 @@ public class StopStartNodesTestCase{
@After
public void tearDownAfterClass() throws Exception {
- if (clientNode != null && clientNode.isStarted()) {
+ if (clientNode != null) {
clientNode.stop();
}
- if (serviceNode != null && serviceNode.isStarted()) {
+ if (serviceNode != null) {
serviceNode.stop();
}
}