diff options
Diffstat (limited to '')
162 files changed, 3253 insertions, 6861 deletions
diff --git a/branches/sca-equinox/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceRemoteTestCase.java b/branches/sca-equinox/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceRemoteTestCase.java index ba9020811c..927e91a8bc 100644 --- a/branches/sca-equinox/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceRemoteTestCase.java +++ b/branches/sca-equinox/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceRemoteTestCase.java @@ -25,10 +25,10 @@ import java.io.File; import junit.framework.Assert;
-import org.apache.tuscany.sca.node.SCAClient;
-import org.apache.tuscany.sca.node.SCAContribution;
-import org.apache.tuscany.sca.node.SCANode;
-import org.apache.tuscany.sca.node.SCANodeFactory;
+import org.apache.tuscany.sca.node.Client;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -40,8 +40,8 @@ import org.junit.Test; */
public class CallableReferenceRemoteTestCase {
- private static SCANode nodeA;
- private static SCANode nodeB;
+ private static Node nodeA;
+ private static Node nodeB;
private static AComponent acomponent;
@@ -52,21 +52,21 @@ public class CallableReferenceRemoteTestCase { System.out.println("Setting up nodes");
- SCANodeFactory nodeFactory = SCANodeFactory.newInstance();
- nodeA = nodeFactory.createSCANode(new File("src/main/resources/nodeA/CompositeA.composite").toURL().toString(),
- new SCAContribution("TestContribution",
+ NodeFactory nodeFactory = NodeFactory.newInstance();
+ nodeA = nodeFactory.createNode(new File("src/main/resources/nodeA/CompositeA.composite").toURL().toString(),
+ new Contribution("TestContribution",
new File("src/main/resources/nodeA").toURL().toString()));
- nodeB = nodeFactory.createSCANode(new File("src/main/resources/nodeB/CompositeB.composite").toURL().toString(),
- new SCAContribution("TestContribution",
+ nodeB = nodeFactory.createNode(new File("src/main/resources/nodeB/CompositeB.composite").toURL().toString(),
+ new Contribution("TestContribution",
new File("src/main/resources/nodeB").toURL().toString()));
nodeA.start();
nodeB.start();
- acomponent = ((SCAClient)nodeA).getService(AComponent.class, "AComponent/AComponent");
+ acomponent = ((Client)nodeA).getService(AComponent.class, "AComponent/AComponent");
} catch (Throwable ex) {
System.out.println(ex.toString());
diff --git a/branches/sca-equinox/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationWSDLTestCase.java b/branches/sca-equinox/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationWSDLTestCase.java index 9df966ebc2..6c3cbe462c 100644 --- a/branches/sca-equinox/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationWSDLTestCase.java +++ b/branches/sca-equinox/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationWSDLTestCase.java @@ -24,10 +24,10 @@ import java.io.File; import org.apache.tuscany.sca.itest.conversational.impl.ConversationalClientStatelessImpl;
-import org.apache.tuscany.sca.node.SCAClient;
-import org.apache.tuscany.sca.node.SCAContribution;
-import org.apache.tuscany.sca.node.SCANode;
-import org.apache.tuscany.sca.node.SCANodeFactory;
+import org.apache.tuscany.sca.node.Client;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@@ -35,20 +35,20 @@ import org.junit.Test; public class ConversationWSDLTestCase {
- private SCANode node;
+ private Node node;
private ConversationalClient conversationalStatelessClientStatefulService;
@Before
public void setUp() throws Exception {
- SCANodeFactory nodeFactory = SCANodeFactory.newInstance();
- node = nodeFactory.createSCANode(new File("src/main/resources/ConversationalWSDL/conversationalWSDL.composite").toURL().toString(),
- new SCAContribution("TestContribution",
+ NodeFactory nodeFactory = NodeFactory.newInstance();
+ node = nodeFactory.createNode(new File("src/main/resources/ConversationalWSDL/conversationalWSDL.composite").toURL().toString(),
+ new Contribution("TestContribution",
new File("src/main/resources/ConversationalWSDL").toURL().toString()));
node.start();
- conversationalStatelessClientStatefulService = ((SCAClient)node).getService(ConversationalClient.class, "ConversationalStatelessClientStatefulService");
+ conversationalStatelessClientStatefulService = ((Client)node).getService(ConversationalClient.class, "ConversationalStatelessClientStatefulService");
ConversationalClientStatelessImpl.calls = new StringBuffer();
diff --git a/branches/sca-equinox/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/NonConversationalCallbackTestCase.java b/branches/sca-equinox/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/NonConversationalCallbackTestCase.java index ebd1e55dac..051b6b9fc1 100644 --- a/branches/sca-equinox/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/NonConversationalCallbackTestCase.java +++ b/branches/sca-equinox/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/NonConversationalCallbackTestCase.java @@ -29,17 +29,17 @@ import org.apache.tuscany.sca.itest.conversational.impl.ConversationalClientStat import org.apache.tuscany.sca.itest.conversational.impl.ConversationalServiceStatefulImpl;
import org.apache.tuscany.sca.itest.conversational.impl.ConversationalServiceStatefulNonConversationalCallbackImpl;
import org.apache.tuscany.sca.itest.conversational.impl.ConversationalServiceStatelessImpl;
-import org.apache.tuscany.sca.node.SCAClient;
-import org.apache.tuscany.sca.node.SCAContribution;
-import org.apache.tuscany.sca.node.SCANode;
-import org.apache.tuscany.sca.node.SCANodeFactory;
+import org.apache.tuscany.sca.node.Client;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
public class NonConversationalCallbackTestCase {
- private static SCANode node;
+ private static Node node;
private static ConversationalClient conversationalStatelessClientStatelessService;
private static ConversationalClient conversationalStatelessClientStatefulService;
private static ConversationalClient conversationalStatefulClientStatelessService;
@@ -50,28 +50,28 @@ public class NonConversationalCallbackTestCase { @BeforeClass
public static void setUp() throws Exception {
try {
- SCANodeFactory nodeFactory = SCANodeFactory.newInstance();
- node = nodeFactory.createSCANode(new File("src/main/resources/Conversational/conversational.composite").toURL().toString(),
- new SCAContribution("TestContribution",
+ NodeFactory nodeFactory = NodeFactory.newInstance();
+ node = nodeFactory.createNode(new File("src/main/resources/Conversational/conversational.composite").toURL().toString(),
+ new Contribution("TestContribution",
new File("src/main/resources/Conversational").toURL().toString()));
node.start();
- conversationalStatelessClientStatelessService = ((SCAClient)node).getService(ConversationalClient.class,
+ conversationalStatelessClientStatelessService = ((Client)node).getService(ConversationalClient.class,
"ConversationalStatelessClientStatelessService");
- conversationalStatelessClientStatefulService = ((SCAClient)node).getService(ConversationalClient.class,
+ conversationalStatelessClientStatefulService = ((Client)node).getService(ConversationalClient.class,
"ConversationalStatelessClientStatefulService");
- conversationalStatefulClientStatelessService = ((SCAClient)node).getService(ConversationalClient.class,
+ conversationalStatefulClientStatelessService = ((Client)node).getService(ConversationalClient.class,
"ConversationalStatefulClientStatelessService");
- conversationalStatefulClientStatefulService = ((SCAClient)node).getService(ConversationalClient.class,
+ conversationalStatefulClientStatefulService = ((Client)node).getService(ConversationalClient.class,
"ConversationalStatefulClientStatefulService");
- conversationalStatelessClientRequestService = ((SCAClient)node).getService(ConversationalClient.class,
+ conversationalStatelessClientRequestService = ((Client)node).getService(ConversationalClient.class,
"ConversationalStatelessClientRequestService");
- conversationalStatefulClientNonConversationalCallbackStatelessService = ((SCAClient)node).getService(ConversationalClient.class,
+ conversationalStatefulClientNonConversationalCallbackStatelessService = ((Client)node).getService(ConversationalClient.class,
"ConversationalStatefulClientNonConversationalCallbackStatefulService");
// reset the place where we record the sequence of calls passing
diff --git a/branches/sca-equinox/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/RequestScopeTestCase.java b/branches/sca-equinox/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/RequestScopeTestCase.java index 2c16145f54..b9530c132b 100644 --- a/branches/sca-equinox/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/RequestScopeTestCase.java +++ b/branches/sca-equinox/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/RequestScopeTestCase.java @@ -30,17 +30,17 @@ import org.apache.tuscany.sca.itest.conversational.impl.ConversationalClientStat import org.apache.tuscany.sca.itest.conversational.impl.ConversationalServiceRequestImpl;
import org.apache.tuscany.sca.itest.conversational.impl.ConversationalServiceStatefulImpl;
import org.apache.tuscany.sca.itest.conversational.impl.ConversationalServiceStatelessImpl;
-import org.apache.tuscany.sca.node.SCAClient;
-import org.apache.tuscany.sca.node.SCAContribution;
-import org.apache.tuscany.sca.node.SCANode;
-import org.apache.tuscany.sca.node.SCANodeFactory;
+import org.apache.tuscany.sca.node.Client;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
public class RequestScopeTestCase {
- private static SCANode node;
+ private static Node node;
private static ConversationalClient conversationalStatelessClientStatelessService;
private static ConversationalClient conversationalStatelessClientStatefulService;
private static ConversationalClient conversationalStatefulClientStatelessService;
@@ -51,28 +51,28 @@ public class RequestScopeTestCase { @BeforeClass
public static void setUp() throws Exception {
try {
- SCANodeFactory nodeFactory = SCANodeFactory.newInstance();
- node = nodeFactory.createSCANode(new File("src/main/resources/Conversational/conversational.composite").toURL().toString(),
- new SCAContribution("TestContribution",
+ NodeFactory nodeFactory = NodeFactory.newInstance();
+ node = nodeFactory.createNode(new File("src/main/resources/Conversational/conversational.composite").toURL().toString(),
+ new Contribution("TestContribution",
new File("src/main/resources/Conversational").toURL().toString()));
node.start();
- conversationalStatelessClientStatelessService = ((SCAClient)node).getService(ConversationalClient.class,
+ conversationalStatelessClientStatelessService = ((Client)node).getService(ConversationalClient.class,
"ConversationalStatelessClientStatelessService");
- conversationalStatelessClientStatefulService = ((SCAClient)node).getService(ConversationalClient.class,
+ conversationalStatelessClientStatefulService = ((Client)node).getService(ConversationalClient.class,
"ConversationalStatelessClientStatefulService");
- conversationalStatefulClientStatelessService = ((SCAClient)node).getService(ConversationalClient.class,
+ conversationalStatefulClientStatelessService = ((Client)node).getService(ConversationalClient.class,
"ConversationalStatefulClientStatelessService");
- conversationalStatefulClientStatefulService = ((SCAClient)node).getService(ConversationalClient.class,
+ conversationalStatefulClientStatefulService = ((Client)node).getService(ConversationalClient.class,
"ConversationalStatefulClientStatefulService");
- conversationalStatelessClientRequestService = ((SCAClient)node).getService(ConversationalClient.class,
+ conversationalStatelessClientRequestService = ((Client)node).getService(ConversationalClient.class,
"ConversationalStatelessClientRequestService");
- conversationalStatefulClientNonConversationalCallbackStatelessService = ((SCAClient)node).getService(ConversationalClient.class,
+ conversationalStatefulClientNonConversationalCallbackStatelessService = ((Client)node).getService(ConversationalClient.class,
"ConversationalStatefulClientNonConversationalCallbackStatefulService");
// reset the place where we record the sequence of calls passing
diff --git a/branches/sca-equinox/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/StatefulStatefulTestCase.java b/branches/sca-equinox/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/StatefulStatefulTestCase.java index 4166e6acdf..1e5f6adcf1 100644 --- a/branches/sca-equinox/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/StatefulStatefulTestCase.java +++ b/branches/sca-equinox/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/StatefulStatefulTestCase.java @@ -29,17 +29,17 @@ import org.apache.tuscany.sca.itest.conversational.impl.ConversationalClientStat import org.apache.tuscany.sca.itest.conversational.impl.ConversationalClientStatelessImpl;
import org.apache.tuscany.sca.itest.conversational.impl.ConversationalServiceStatefulImpl;
import org.apache.tuscany.sca.itest.conversational.impl.ConversationalServiceStatelessImpl;
-import org.apache.tuscany.sca.node.SCAClient;
-import org.apache.tuscany.sca.node.SCAContribution;
-import org.apache.tuscany.sca.node.SCANode;
-import org.apache.tuscany.sca.node.SCANodeFactory;
+import org.apache.tuscany.sca.node.Client;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
public class StatefulStatefulTestCase {
- private static SCANode node;
+ private static Node node;
private static ConversationalClient conversationalStatelessClientStatelessService;
private static ConversationalClient conversationalStatelessClientStatefulService;
private static ConversationalClient conversationalStatefulClientStatelessService;
@@ -50,28 +50,28 @@ public class StatefulStatefulTestCase { @BeforeClass
public static void setUp() throws Exception {
try {
- SCANodeFactory nodeFactory = SCANodeFactory.newInstance();
- node = nodeFactory.createSCANode(new File("src/main/resources/Conversational/conversational.composite").toURL().toString(),
- new SCAContribution("TestContribution",
+ NodeFactory nodeFactory = NodeFactory.newInstance();
+ node = nodeFactory.createNode(new File("src/main/resources/Conversational/conversational.composite").toURL().toString(),
+ new Contribution("TestContribution",
new File("src/main/resources/Conversational").toURL().toString()));
node.start();
- conversationalStatelessClientStatelessService = ((SCAClient)node).getService(ConversationalClient.class,
+ conversationalStatelessClientStatelessService = ((Client)node).getService(ConversationalClient.class,
"ConversationalStatelessClientStatelessService");
- conversationalStatelessClientStatefulService = ((SCAClient)node).getService(ConversationalClient.class,
+ conversationalStatelessClientStatefulService = ((Client)node).getService(ConversationalClient.class,
"ConversationalStatelessClientStatefulService");
- conversationalStatefulClientStatelessService = ((SCAClient)node).getService(ConversationalClient.class,
+ conversationalStatefulClientStatelessService = ((Client)node).getService(ConversationalClient.class,
"ConversationalStatefulClientStatelessService");
- conversationalStatefulClientStatefulService = ((SCAClient)node).getService(ConversationalClient.class,
+ conversationalStatefulClientStatefulService = ((Client)node).getService(ConversationalClient.class,
"ConversationalStatefulClientStatefulService");
- conversationalStatelessClientRequestService = ((SCAClient)node).getService(ConversationalClient.class,
+ conversationalStatelessClientRequestService = ((Client)node).getService(ConversationalClient.class,
"ConversationalStatelessClientRequestService");
- conversationalStatefulClientNonConversationalCallbackStatelessService = ((SCAClient)node).getService(ConversationalClient.class,
+ conversationalStatefulClientNonConversationalCallbackStatelessService = ((Client)node).getService(ConversationalClient.class,
"ConversationalStatefulClientNonConversationalCallbackStatefulService");
// reset the place where we record the sequence of calls passing
diff --git a/branches/sca-equinox/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/StatefulStatelessTestCase.java b/branches/sca-equinox/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/StatefulStatelessTestCase.java index 6023b7cd53..8a110477b5 100644 --- a/branches/sca-equinox/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/StatefulStatelessTestCase.java +++ b/branches/sca-equinox/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/StatefulStatelessTestCase.java @@ -29,17 +29,17 @@ import org.apache.tuscany.sca.itest.conversational.impl.ConversationalClientStat import org.apache.tuscany.sca.itest.conversational.impl.ConversationalClientStatelessImpl;
import org.apache.tuscany.sca.itest.conversational.impl.ConversationalServiceStatefulImpl;
import org.apache.tuscany.sca.itest.conversational.impl.ConversationalServiceStatelessImpl;
-import org.apache.tuscany.sca.node.SCAClient;
-import org.apache.tuscany.sca.node.SCAContribution;
-import org.apache.tuscany.sca.node.SCANode;
-import org.apache.tuscany.sca.node.SCANodeFactory;
+import org.apache.tuscany.sca.node.Client;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
public class StatefulStatelessTestCase {
- private static SCANode node;
+ private static Node node;
private static ConversationalClient conversationalStatelessClientStatelessService;
private static ConversationalClient conversationalStatelessClientStatefulService;
private static ConversationalClient conversationalStatefulClientStatelessService;
@@ -50,28 +50,28 @@ public class StatefulStatelessTestCase { @BeforeClass
public static void setUp() throws Exception {
try {
- SCANodeFactory nodeFactory = SCANodeFactory.newInstance();
- node = nodeFactory.createSCANode(new File("src/main/resources/Conversational/conversational.composite").toURL().toString(),
- new SCAContribution("TestContribution",
+ NodeFactory nodeFactory = NodeFactory.newInstance();
+ node = nodeFactory.createNode(new File("src/main/resources/Conversational/conversational.composite").toURL().toString(),
+ new Contribution("TestContribution",
new File("src/main/resources/Conversational").toURL().toString()));
node.start();
- conversationalStatelessClientStatelessService = ((SCAClient)node).getService(ConversationalClient.class,
+ conversationalStatelessClientStatelessService = ((Client)node).getService(ConversationalClient.class,
"ConversationalStatelessClientStatelessService");
- conversationalStatelessClientStatefulService = ((SCAClient)node).getService(ConversationalClient.class,
+ conversationalStatelessClientStatefulService = ((Client)node).getService(ConversationalClient.class,
"ConversationalStatelessClientStatefulService");
- conversationalStatefulClientStatelessService = ((SCAClient)node).getService(ConversationalClient.class,
+ conversationalStatefulClientStatelessService = ((Client)node).getService(ConversationalClient.class,
"ConversationalStatefulClientStatelessService");
- conversationalStatefulClientStatefulService = ((SCAClient)node).getService(ConversationalClient.class,
+ conversationalStatefulClientStatefulService = ((Client)node).getService(ConversationalClient.class,
"ConversationalStatefulClientStatefulService");
- conversationalStatelessClientRequestService = ((SCAClient)node).getService(ConversationalClient.class,
+ conversationalStatelessClientRequestService = ((Client)node).getService(ConversationalClient.class,
"ConversationalStatelessClientRequestService");
- conversationalStatefulClientNonConversationalCallbackStatelessService = ((SCAClient)node).getService(ConversationalClient.class,
+ conversationalStatefulClientNonConversationalCallbackStatelessService = ((Client)node).getService(ConversationalClient.class,
"ConversationalStatefulClientNonConversationalCallbackStatefulService");
// reset the place where we record the sequence of calls passing
diff --git a/branches/sca-equinox/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/StatelessStatefulTestCase.java b/branches/sca-equinox/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/StatelessStatefulTestCase.java index fb3a3cec6f..79ac9262c6 100644 --- a/branches/sca-equinox/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/StatelessStatefulTestCase.java +++ b/branches/sca-equinox/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/StatelessStatefulTestCase.java @@ -28,17 +28,17 @@ import org.apache.tuscany.sca.itest.conversational.impl.ConversationalClientStat import org.apache.tuscany.sca.itest.conversational.impl.ConversationalClientStatelessImpl;
import org.apache.tuscany.sca.itest.conversational.impl.ConversationalServiceStatefulImpl;
import org.apache.tuscany.sca.itest.conversational.impl.ConversationalServiceStatelessImpl;
-import org.apache.tuscany.sca.node.SCAClient;
-import org.apache.tuscany.sca.node.SCAContribution;
-import org.apache.tuscany.sca.node.SCANode;
-import org.apache.tuscany.sca.node.SCANodeFactory;
+import org.apache.tuscany.sca.node.Client;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
public class StatelessStatefulTestCase {
- private static SCANode node;
+ private static Node node;
private static ConversationalClient conversationalStatelessClientStatelessService;
private static ConversationalClient conversationalStatelessClientStatefulService;
private static ConversationalClient conversationalStatefulClientStatelessService;
@@ -49,28 +49,28 @@ public class StatelessStatefulTestCase { @BeforeClass
public static void setUp() throws Exception {
try {
- SCANodeFactory nodeFactory = SCANodeFactory.newInstance();
- node = nodeFactory.createSCANode(new File("src/main/resources/Conversational/conversational.composite").toURL().toString(),
- new SCAContribution("TestContribution",
+ NodeFactory nodeFactory = NodeFactory.newInstance();
+ node = nodeFactory.createNode(new File("src/main/resources/Conversational/conversational.composite").toURL().toString(),
+ new Contribution("TestContribution",
new File("src/main/resources/Conversational").toURL().toString()));
node.start();
- conversationalStatelessClientStatelessService = ((SCAClient)node).getService(ConversationalClient.class,
+ conversationalStatelessClientStatelessService = ((Client)node).getService(ConversationalClient.class,
"ConversationalStatelessClientStatelessService");
- conversationalStatelessClientStatefulService = ((SCAClient)node).getService(ConversationalClient.class,
+ conversationalStatelessClientStatefulService = ((Client)node).getService(ConversationalClient.class,
"ConversationalStatelessClientStatefulService");
- conversationalStatefulClientStatelessService = ((SCAClient)node).getService(ConversationalClient.class,
+ conversationalStatefulClientStatelessService = ((Client)node).getService(ConversationalClient.class,
"ConversationalStatefulClientStatelessService");
- conversationalStatefulClientStatefulService = ((SCAClient)node).getService(ConversationalClient.class,
+ conversationalStatefulClientStatefulService = ((Client)node).getService(ConversationalClient.class,
"ConversationalStatefulClientStatefulService");
- conversationalStatelessClientRequestService = ((SCAClient)node).getService(ConversationalClient.class,
+ conversationalStatelessClientRequestService = ((Client)node).getService(ConversationalClient.class,
"ConversationalStatelessClientRequestService");
- conversationalStatefulClientNonConversationalCallbackStatelessService = ((SCAClient)node).getService(ConversationalClient.class,
+ conversationalStatefulClientNonConversationalCallbackStatelessService = ((Client)node).getService(ConversationalClient.class,
"ConversationalStatefulClientNonConversationalCallbackStatefulService");
// reset the place where we record the sequence of calls passing
diff --git a/branches/sca-equinox/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/StatelessStatelessTestCase.java b/branches/sca-equinox/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/StatelessStatelessTestCase.java index 5fbe2c3f69..9aebae9ced 100644 --- a/branches/sca-equinox/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/StatelessStatelessTestCase.java +++ b/branches/sca-equinox/itest/conversations-ws/src/test/java/org/apache/tuscany/sca/itest/conversational/StatelessStatelessTestCase.java @@ -28,17 +28,17 @@ import org.apache.tuscany.sca.itest.conversational.impl.ConversationalClientStat import org.apache.tuscany.sca.itest.conversational.impl.ConversationalClientStatelessImpl;
import org.apache.tuscany.sca.itest.conversational.impl.ConversationalServiceStatefulImpl;
import org.apache.tuscany.sca.itest.conversational.impl.ConversationalServiceStatelessImpl;
-import org.apache.tuscany.sca.node.SCAClient;
-import org.apache.tuscany.sca.node.SCAContribution;
-import org.apache.tuscany.sca.node.SCANode;
-import org.apache.tuscany.sca.node.SCANodeFactory;
+import org.apache.tuscany.sca.node.Client;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
public class StatelessStatelessTestCase {
- private static SCANode node;
+ private static Node node;
private static ConversationalClient conversationalStatelessClientStatelessService;
private static ConversationalClient conversationalStatelessClientStatefulService;
private static ConversationalClient conversationalStatefulClientStatelessService;
@@ -49,28 +49,28 @@ public class StatelessStatelessTestCase { @BeforeClass
public static void setUp() throws Exception {
try {
- SCANodeFactory nodeFactory = SCANodeFactory.newInstance();
- node = nodeFactory.createSCANode(new File("src/main/resources/Conversational/conversational.composite").toURL().toString(),
- new SCAContribution("TestContribution",
+ NodeFactory nodeFactory = NodeFactory.newInstance();
+ node = nodeFactory.createNode(new File("src/main/resources/Conversational/conversational.composite").toURL().toString(),
+ new Contribution("TestContribution",
new File("src/main/resources/Conversational").toURL().toString()));
node.start();
- conversationalStatelessClientStatelessService = ((SCAClient)node).getService(ConversationalClient.class,
+ conversationalStatelessClientStatelessService = ((Client)node).getService(ConversationalClient.class,
"ConversationalStatelessClientStatelessService");
- conversationalStatelessClientStatefulService = ((SCAClient)node).getService(ConversationalClient.class,
+ conversationalStatelessClientStatefulService = ((Client)node).getService(ConversationalClient.class,
"ConversationalStatelessClientStatefulService");
- conversationalStatefulClientStatelessService = ((SCAClient)node).getService(ConversationalClient.class,
+ conversationalStatefulClientStatelessService = ((Client)node).getService(ConversationalClient.class,
"ConversationalStatefulClientStatelessService");
- conversationalStatefulClientStatefulService = ((SCAClient)node).getService(ConversationalClient.class,
+ conversationalStatefulClientStatefulService = ((Client)node).getService(ConversationalClient.class,
"ConversationalStatefulClientStatefulService");
- conversationalStatelessClientRequestService = ((SCAClient)node).getService(ConversationalClient.class,
+ conversationalStatelessClientRequestService = ((Client)node).getService(ConversationalClient.class,
"ConversationalStatelessClientRequestService");
- conversationalStatefulClientNonConversationalCallbackStatelessService = ((SCAClient)node).getService(ConversationalClient.class,
+ conversationalStatefulClientNonConversationalCallbackStatelessService = ((Client)node).getService(ConversationalClient.class,
"ConversationalStatefulClientNonConversationalCallbackStatefulService");
// reset the place where we record the sequence of calls passing
diff --git a/branches/sca-equinox/itest/databindings/jaxb-top-down/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/topdown/DatabindingTestCase.java b/branches/sca-equinox/itest/databindings/jaxb-top-down/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/topdown/DatabindingTestCase.java index da2fc8b108..5c82fe121f 100644 --- a/branches/sca-equinox/itest/databindings/jaxb-top-down/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/topdown/DatabindingTestCase.java +++ b/branches/sca-equinox/itest/databindings/jaxb-top-down/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/topdown/DatabindingTestCase.java @@ -27,9 +27,9 @@ import java.util.Map; import junit.framework.Assert; import org.apache.tuscany.sca.itest.databindings.jaxb.HelloServiceClient; -import org.apache.tuscany.sca.node.SCAClient; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Client; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -39,8 +39,8 @@ import org.junit.Test; */ public class DatabindingTestCase { - private static SCAClient client; - private static SCANode node; + private static Client client; + private static Node node; /** * Runs once before running the tests @@ -48,10 +48,10 @@ public class DatabindingTestCase { @BeforeClass public static void setUp() throws Exception { try { - SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); + NodeFactory nodeFactory = NodeFactory.newInstance(); node = nodeFactory.createSCANodeFromClassLoader("wsdl/wrapped/helloservice.composite", null); node.start(); - client = (SCAClient)node; + client = (Client)node; }catch(Throwable e) { e.printStackTrace(); } diff --git a/branches/sca-equinox/itest/databindings/jaxb-top-down/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/topdown/PrimitivesDatabindingTestCase.java b/branches/sca-equinox/itest/databindings/jaxb-top-down/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/topdown/PrimitivesDatabindingTestCase.java index 65b8a5abc3..4a292a8b7a 100644 --- a/branches/sca-equinox/itest/databindings/jaxb-top-down/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/topdown/PrimitivesDatabindingTestCase.java +++ b/branches/sca-equinox/itest/databindings/jaxb-top-down/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/topdown/PrimitivesDatabindingTestCase.java @@ -22,9 +22,9 @@ package org.apache.tuscany.sca.itest.databindings.jaxb.topdown; import junit.framework.Assert; import org.apache.tuscany.sca.itest.databindings.jaxb.PrimitivesServiceClient; -import org.apache.tuscany.sca.node.SCAClient; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Client; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -34,18 +34,18 @@ import org.junit.Test; */ public class PrimitivesDatabindingTestCase { - private static SCAClient domain; - private static SCANode node; + private static Client domain; + private static Node node; /** * Runs before each test method */ @BeforeClass public static void setUp() throws Exception { - SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); + NodeFactory nodeFactory = NodeFactory.newInstance(); node = nodeFactory.createSCANodeFromClassLoader("wsdl/wrapped/primitivesservice.composite", null); node.start(); - domain = (SCAClient)node; + domain = (Client)node; } /** diff --git a/branches/sca-equinox/itest/databindings/jaxb-top-down/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/topdown/StandardTypesDatabindingTestCase.java b/branches/sca-equinox/itest/databindings/jaxb-top-down/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/topdown/StandardTypesDatabindingTestCase.java index dc49f0f407..402ade0852 100644 --- a/branches/sca-equinox/itest/databindings/jaxb-top-down/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/topdown/StandardTypesDatabindingTestCase.java +++ b/branches/sca-equinox/itest/databindings/jaxb-top-down/src/test/java/org/apache/tuscany/sca/itest/databindings/jaxb/topdown/StandardTypesDatabindingTestCase.java @@ -55,9 +55,9 @@ import org.apache.axiom.attachments.ByteArrayDataSource; import org.apache.tuscany.sca.databinding.xml.String2Node; import org.apache.tuscany.sca.itest.databindings.jaxb.StandardTypesServiceClient; import org.apache.tuscany.sca.itest.databindings.jaxb.impl.StandardTypesTransformer; -import org.apache.tuscany.sca.node.SCAClient; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Client; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Ignore; @@ -69,18 +69,18 @@ import org.xml.sax.InputSource; */ public class StandardTypesDatabindingTestCase { - private static SCAClient domain; - private static SCANode node; + private static Client domain; + private static Node node; /** * Runs once before the tests */ @BeforeClass public static void setUp() throws Exception { - SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); + NodeFactory nodeFactory = NodeFactory.newInstance(); node = nodeFactory.createSCANodeFromClassLoader("wsdl/wrapped/standard-types-service.composite", null); node.start(); - domain = (SCAClient)node; + domain = (Client)node; } /** diff --git a/branches/sca-equinox/itest/late-reference-resolution/src/test/java/calculator/LateReferenceResolutionTestCase.java b/branches/sca-equinox/itest/late-reference-resolution/src/test/java/calculator/LateReferenceResolutionTestCase.java index ebe834028d..74e01259e2 100644 --- a/branches/sca-equinox/itest/late-reference-resolution/src/test/java/calculator/LateReferenceResolutionTestCase.java +++ b/branches/sca-equinox/itest/late-reference-resolution/src/test/java/calculator/LateReferenceResolutionTestCase.java @@ -23,10 +23,10 @@ import java.io.File; import junit.framework.Assert; -import org.apache.tuscany.sca.node.SCAClient; -import org.apache.tuscany.sca.node.SCAContribution; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Client; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.apache.tuscany.sca.node.launcher.DomainManagerLauncher; import org.junit.AfterClass; import org.junit.BeforeClass; @@ -38,9 +38,9 @@ import org.junit.Test; */ public class LateReferenceResolutionTestCase { - private static SCANode nodeA; - private static SCANode nodeB; - private static SCANode nodeC; + private static Node nodeA; + private static Node nodeB; + private static Node nodeC; private static CalculatorService calculatorService; @@ -53,22 +53,22 @@ public class LateReferenceResolutionTestCase { System.out.println("Setting up domain"); - SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); - nodeC = nodeFactory.createSCANode(new File("src/main/resources/nodeC/Calculator.composite").toURL().toString(), - new SCAContribution("NodeC", + NodeFactory nodeFactory = NodeFactory.newInstance(); + nodeC = nodeFactory.createNode(new File("src/main/resources/nodeC/Calculator.composite").toURL().toString(), + new Contribution("NodeC", new File("src/main/resources/nodeC").toURL().toString())); - nodeB = nodeFactory.createSCANode(new File("src/main/resources/nodeB/Calculator.composite").toURL().toString(), - new SCAContribution("NodeB", + nodeB = nodeFactory.createNode(new File("src/main/resources/nodeB/Calculator.composite").toURL().toString(), + new Contribution("NodeB", new File("src/main/resources/nodeB").toURL().toString())); - nodeA = nodeFactory.createSCANode(new File("src/main/resources/nodeA/Calculator.composite").toURL().toString(), - new SCAContribution("NodeA", + nodeA = nodeFactory.createNode(new File("src/main/resources/nodeA/Calculator.composite").toURL().toString(), + new Contribution("NodeA", new File("src/main/resources/nodeA").toURL().toString())); nodeC.start(); nodeB.start(); nodeA.start(); - SCAClient client = (SCAClient)nodeA; + Client client = (Client)nodeA; calculatorService = client.getService(CalculatorService.class, "CalculatorServiceComponentA"); diff --git a/branches/sca-equinox/itest/oneway/src/test/java/org/apache/tuscany/sca/itest/oneway/OneWayTestCase.java b/branches/sca-equinox/itest/oneway/src/test/java/org/apache/tuscany/sca/itest/oneway/OneWayTestCase.java index c490150ec5..776b6ffdf7 100644 --- a/branches/sca-equinox/itest/oneway/src/test/java/org/apache/tuscany/sca/itest/oneway/OneWayTestCase.java +++ b/branches/sca-equinox/itest/oneway/src/test/java/org/apache/tuscany/sca/itest/oneway/OneWayTestCase.java @@ -30,9 +30,9 @@ import junit.framework.Assert; import org.apache.tuscany.sca.core.invocation.NonBlockingInterceptor;
import org.apache.tuscany.sca.itest.oneway.impl.OneWayClientImpl;
import org.apache.tuscany.sca.itest.oneway.impl.OneWayServiceImpl;
-import org.apache.tuscany.sca.node.SCAClient;
-import org.apache.tuscany.sca.node.SCANode;
-import org.apache.tuscany.sca.node.SCANodeFactory;
+import org.apache.tuscany.sca.node.Client;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -49,7 +49,7 @@ public class OneWayTestCase { */
private static final int MAX_SLEEP_TIME = 10000;
- private SCANode node;
+ private Node node;
/**
* Initialise the SCADomain.
@@ -59,7 +59,7 @@ public class OneWayTestCase { @Before
public void setUp() throws Exception {
- SCANodeFactory nodeFactory = SCANodeFactory.newInstance();
+ NodeFactory nodeFactory = NodeFactory.newInstance();
node = nodeFactory.createSCANodeFromClassLoader("OneWayContribution/META-INF/sca-deployables/oneWay.composite", null);
node.start();
@@ -84,7 +84,7 @@ public class OneWayTestCase { @Test
public void testOneWay() throws Exception {
OneWayClient client =
- ((SCAClient)node).getService(OneWayClient.class, "OneWayClientComponent");
+ ((Client)node).getService(OneWayClient.class, "OneWayClientComponent");
int count = 100;
@@ -120,7 +120,7 @@ public class OneWayTestCase { @Test
public void testOneWayUsingNonBlockingInterceptorThrowsAnException() {
OneWayClient client =
- ((SCAClient)node).getService(OneWayClient.class, "OneWayClientComponentSCABinding");
+ ((Client)node).getService(OneWayClient.class, "OneWayClientComponentSCABinding");
// We need to modify the JDK Logger for the NonBlockingInterceptor so we
// can check that it logs a message for the @OneWay invocation that throws
diff --git a/branches/sca-equinox/itest/policy-security-basicauth/src/test/java/org/apache/tuscany/sca/itest/BasicAuthTestCase.java b/branches/sca-equinox/itest/policy-security-basicauth/src/test/java/org/apache/tuscany/sca/itest/BasicAuthTestCase.java index b6e0444d2d..10fbac4e20 100644 --- a/branches/sca-equinox/itest/policy-security-basicauth/src/test/java/org/apache/tuscany/sca/itest/BasicAuthTestCase.java +++ b/branches/sca-equinox/itest/policy-security-basicauth/src/test/java/org/apache/tuscany/sca/itest/BasicAuthTestCase.java @@ -24,9 +24,9 @@ import java.io.ByteArrayInputStream; import junit.framework.Assert; import helloworld.HelloWorldService; -import org.apache.tuscany.sca.node.SCAClient; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Client; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.apache.ws.security.util.Base64; import org.junit.AfterClass; import org.junit.BeforeClass; @@ -39,18 +39,18 @@ import com.meterware.httpunit.WebRequest; import com.meterware.httpunit.WebResponse; public class BasicAuthTestCase { - private static SCANode node; + private static Node node; private static HelloWorldService service; @BeforeClass public static void init() throws Exception { try { - SCANodeFactory factory = SCANodeFactory.newInstance(); + NodeFactory factory = NodeFactory.newInstance(); node = factory.createSCANodeFromClassLoader("helloworld.composite", BasicAuthTestCase.class.getClassLoader()); node.start(); - service = ((SCAClient)node).getService(HelloWorldService.class, "HelloWorldClientComponent"); + service = ((Client)node).getService(HelloWorldService.class, "HelloWorldClientComponent"); } catch (Exception ex) { ex.printStackTrace(); } diff --git a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/ComponentReferenceTargetNotFoundTestCase.java b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/ComponentReferenceTargetNotFoundTestCase.java index 18809f6af2..f4ba8eb4e6 100644 --- a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/ComponentReferenceTargetNotFoundTestCase.java +++ b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/ComponentReferenceTargetNotFoundTestCase.java @@ -27,10 +27,10 @@ import org.apache.tuscany.sca.core.UtilityExtensionPoint; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.MonitorFactory; import org.apache.tuscany.sca.monitor.Problem; -import org.apache.tuscany.sca.node.SCAClient; -import org.apache.tuscany.sca.node.SCAContribution; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Client; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.apache.tuscany.sca.node.impl.NodeImpl; /** @@ -39,13 +39,13 @@ import org.apache.tuscany.sca.node.impl.NodeImpl; public class ComponentReferenceTargetNotFoundTestCase extends TestCase { private CalculatorService calculatorService; - private SCANode node; + private Node node; @Override protected void setUp() throws Exception { - SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); - node = nodeFactory.createSCANode(new File("src/main/resources/ComponentReferenceTargetNotFound/Calculator.composite").toURL().toString(), - new SCAContribution("TestContribution", + NodeFactory nodeFactory = NodeFactory.newInstance(); + node = nodeFactory.createNode(new File("src/main/resources/ComponentReferenceTargetNotFound/Calculator.composite").toURL().toString(), + new Contribution("TestContribution", new File("src/main/resources/ComponentReferenceTargetNotFound").toURL().toString())); try { @@ -54,7 +54,7 @@ public class ComponentReferenceTargetNotFoundTestCase extends TestCase { // do nothing - the SCA binding throws and exception here // because the interface for the reference is not remotable } - calculatorService = ((SCAClient)node).getService(CalculatorService.class, "CalculatorServiceComponent"); + calculatorService = ((Client)node).getService(CalculatorService.class, "CalculatorServiceComponent"); } @Override diff --git a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/DuplicateImplementationPropertyNameTestCase.java b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/DuplicateImplementationPropertyNameTestCase.java index 83d3064381..96d8debd4a 100644 --- a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/DuplicateImplementationPropertyNameTestCase.java +++ b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/DuplicateImplementationPropertyNameTestCase.java @@ -27,22 +27,22 @@ import org.apache.tuscany.sca.core.UtilityExtensionPoint; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.MonitorFactory; import org.apache.tuscany.sca.monitor.Problem; -import org.apache.tuscany.sca.node.SCAContribution; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.apache.tuscany.sca.node.impl.NodeImpl; /** * This shows how to test the Calculator service component. */ public class DuplicateImplementationPropertyNameTestCase extends TestCase { - private SCANode node; + private Node node; @Override protected void setUp() throws Exception { - SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); - node = nodeFactory.createSCANode(new File("src/main/resources/DuplicateImplementationPropertyName/Calculator.composite").toURL().toString(), - new SCAContribution("TestContribution", + NodeFactory nodeFactory = NodeFactory.newInstance(); + node = nodeFactory.createNode(new File("src/main/resources/DuplicateImplementationPropertyName/Calculator.composite").toURL().toString(), + new Contribution("TestContribution", new File("src/main/resources/DuplicateImplementationPropertyName").toURL().toString())); } diff --git a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/DuplicateImplementationReferenceNameTestCase.java b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/DuplicateImplementationReferenceNameTestCase.java index 5b59a69f86..7246d6e0a3 100644 --- a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/DuplicateImplementationReferenceNameTestCase.java +++ b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/DuplicateImplementationReferenceNameTestCase.java @@ -27,9 +27,9 @@ import org.apache.tuscany.sca.core.UtilityExtensionPoint; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.MonitorFactory; import org.apache.tuscany.sca.monitor.Problem; -import org.apache.tuscany.sca.node.SCAContribution; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.apache.tuscany.sca.node.impl.NodeImpl; /** @@ -37,13 +37,13 @@ import org.apache.tuscany.sca.node.impl.NodeImpl; */ public class DuplicateImplementationReferenceNameTestCase extends TestCase { - private SCANode node; + private Node node; @Override protected void setUp() throws Exception { - SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); - node = nodeFactory.createSCANode(new File("src/main/resources/DuplicateImplementationReferenceName/Calculator.composite").toURL().toString(), - new SCAContribution("TestContribution", + NodeFactory nodeFactory = NodeFactory.newInstance(); + node = nodeFactory.createNode(new File("src/main/resources/DuplicateImplementationReferenceName/Calculator.composite").toURL().toString(), + new Contribution("TestContribution", new File("src/main/resources/DuplicateImplementationReferenceName").toURL().toString())); } diff --git a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/DuplicatePropertyNameTestCase.java b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/DuplicatePropertyNameTestCase.java index 13534d698d..3ffd10f36f 100644 --- a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/DuplicatePropertyNameTestCase.java +++ b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/DuplicatePropertyNameTestCase.java @@ -27,10 +27,10 @@ import org.apache.tuscany.sca.core.UtilityExtensionPoint; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.MonitorFactory; import org.apache.tuscany.sca.monitor.Problem; -import org.apache.tuscany.sca.node.SCAClient; -import org.apache.tuscany.sca.node.SCAContribution; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Client; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.apache.tuscany.sca.node.impl.NodeImpl; /** @@ -39,16 +39,16 @@ import org.apache.tuscany.sca.node.impl.NodeImpl; public class DuplicatePropertyNameTestCase extends TestCase { private CalculatorService calculatorService; - private SCANode node; + private Node node; @Override protected void setUp() throws Exception { - SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); - node = nodeFactory.createSCANode(new File("src/main/resources/DuplicatePropertyName/Calculator.composite").toURL().toString(), - new SCAContribution("TestContribution", + NodeFactory nodeFactory = NodeFactory.newInstance(); + node = nodeFactory.createNode(new File("src/main/resources/DuplicatePropertyName/Calculator.composite").toURL().toString(), + new Contribution("TestContribution", new File("src/main/resources/DuplicatePropertyName").toURL().toString())); node.start(); - calculatorService = ((SCAClient)node).getService(CalculatorService.class, "CalculatorServiceComponent"); + calculatorService = ((Client)node).getService(CalculatorService.class, "CalculatorServiceComponent"); } @Override diff --git a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/DuplicateReferenceNameTestCase.java b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/DuplicateReferenceNameTestCase.java index 627e1e975e..0e0e4cd2bd 100644 --- a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/DuplicateReferenceNameTestCase.java +++ b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/DuplicateReferenceNameTestCase.java @@ -27,10 +27,10 @@ import org.apache.tuscany.sca.core.UtilityExtensionPoint; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.MonitorFactory; import org.apache.tuscany.sca.monitor.Problem; -import org.apache.tuscany.sca.node.SCAClient; -import org.apache.tuscany.sca.node.SCAContribution; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Client; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.apache.tuscany.sca.node.impl.NodeImpl; /** @@ -39,16 +39,16 @@ import org.apache.tuscany.sca.node.impl.NodeImpl; public class DuplicateReferenceNameTestCase extends TestCase { private CalculatorService calculatorService; - private SCANode node; + private Node node; @Override protected void setUp() throws Exception { - SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); - node = nodeFactory.createSCANode(new File("src/main/resources/DuplicateReferenceName/Calculator.composite").toURL().toString(), - new SCAContribution("TestContribution", + NodeFactory nodeFactory = NodeFactory.newInstance(); + node = nodeFactory.createNode(new File("src/main/resources/DuplicateReferenceName/Calculator.composite").toURL().toString(), + new Contribution("TestContribution", new File("src/main/resources/DuplicateReferenceName").toURL().toString())); node.start(); - calculatorService = ((SCAClient)node).getService(CalculatorService.class, "CalculatorServiceComponent"); + calculatorService = ((Client)node).getService(CalculatorService.class, "CalculatorServiceComponent"); } @Override diff --git a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/MultipleBindingsForServiceTestCase.java b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/MultipleBindingsForServiceTestCase.java index 2f66235684..45c7af3d1f 100644 --- a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/MultipleBindingsForServiceTestCase.java +++ b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/MultipleBindingsForServiceTestCase.java @@ -27,10 +27,10 @@ import org.apache.tuscany.sca.core.UtilityExtensionPoint; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.MonitorFactory; import org.apache.tuscany.sca.monitor.Problem; -import org.apache.tuscany.sca.node.SCAClient; -import org.apache.tuscany.sca.node.SCAContribution; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Client; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.apache.tuscany.sca.node.impl.NodeImpl; /** @@ -39,16 +39,16 @@ import org.apache.tuscany.sca.node.impl.NodeImpl; public class MultipleBindingsForServiceTestCase extends TestCase { private CalculatorService calculatorService; - private SCANode node; + private Node node; @Override protected void setUp() throws Exception { - SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); - node = nodeFactory.createSCANode(new File("src/main/resources/MultipleBindingsForService/Calculator.composite").toURL().toString(), - new SCAContribution("TestContribution", + NodeFactory nodeFactory = NodeFactory.newInstance(); + node = nodeFactory.createNode(new File("src/main/resources/MultipleBindingsForService/Calculator.composite").toURL().toString(), + new Contribution("TestContribution", new File("src/main/resources/MultipleBindingsForService").toURL().toString())); node.start(); - calculatorService = ((SCAClient)node).getService(CalculatorService.class, "CalculatorServiceComponent"); + calculatorService = ((Client)node).getService(CalculatorService.class, "CalculatorServiceComponent"); } @Override diff --git a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/NoComponentImplementationTestCase.java b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/NoComponentImplementationTestCase.java index 48c165ab99..ef2d13aaaa 100644 --- a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/NoComponentImplementationTestCase.java +++ b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/NoComponentImplementationTestCase.java @@ -27,9 +27,9 @@ import org.apache.tuscany.sca.core.UtilityExtensionPoint; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.MonitorFactory; import org.apache.tuscany.sca.monitor.Problem; -import org.apache.tuscany.sca.node.SCAContribution; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.apache.tuscany.sca.node.impl.NodeImpl; /** @@ -38,13 +38,13 @@ import org.apache.tuscany.sca.node.impl.NodeImpl; public class NoComponentImplementationTestCase extends TestCase { private CalculatorService calculatorService; - private SCANode node; + private Node node; @Override protected void setUp() throws Exception { - SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); - node = nodeFactory.createSCANode(new File("src/main/resources/NoComponentImplementation/Calculator.composite").toURL().toString(), - new SCAContribution("TestContribution", + NodeFactory nodeFactory = NodeFactory.newInstance(); + node = nodeFactory.createNode(new File("src/main/resources/NoComponentImplementation/Calculator.composite").toURL().toString(), + new Contribution("TestContribution", new File("src/main/resources/NoComponentImplementation").toURL().toString())); } diff --git a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/NoCompositeNamespaceTestCase.java b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/NoCompositeNamespaceTestCase.java index 35789fbd43..9014fb00e5 100644 --- a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/NoCompositeNamespaceTestCase.java +++ b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/NoCompositeNamespaceTestCase.java @@ -27,10 +27,10 @@ import org.apache.tuscany.sca.core.UtilityExtensionPoint; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.MonitorFactory; import org.apache.tuscany.sca.monitor.Problem; -import org.apache.tuscany.sca.node.SCAClient; -import org.apache.tuscany.sca.node.SCAContribution; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Client; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.apache.tuscany.sca.node.impl.NodeImpl; /** @@ -39,16 +39,16 @@ import org.apache.tuscany.sca.node.impl.NodeImpl; public class NoCompositeNamespaceTestCase extends TestCase { private CalculatorService calculatorService; - private SCANode node; + private Node node; @Override protected void setUp() throws Exception { - SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); - node = nodeFactory.createSCANode(new File("src/main/resources/NoCompositeNamespace/Calculator.composite").toURL().toString(), - new SCAContribution("TestContribution", + NodeFactory nodeFactory = NodeFactory.newInstance(); + node = nodeFactory.createNode(new File("src/main/resources/NoCompositeNamespace/Calculator.composite").toURL().toString(), + new Contribution("TestContribution", new File("src/main/resources/NoCompositeNamespace").toURL().toString())); node.start(); - calculatorService = ((SCAClient)node).getService(CalculatorService.class, "CalculatorServiceComponent"); + calculatorService = ((Client)node).getService(CalculatorService.class, "CalculatorServiceComponent"); } @Override diff --git a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/NoMatchingBindingTestCase.java b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/NoMatchingBindingTestCase.java index 94d0e50312..69382b0456 100644 --- a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/NoMatchingBindingTestCase.java +++ b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/NoMatchingBindingTestCase.java @@ -27,10 +27,10 @@ import org.apache.tuscany.sca.core.UtilityExtensionPoint; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.MonitorFactory; import org.apache.tuscany.sca.monitor.Problem; -import org.apache.tuscany.sca.node.SCAClient; -import org.apache.tuscany.sca.node.SCAContribution; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Client; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.apache.tuscany.sca.node.impl.NodeImpl; /** @@ -39,17 +39,17 @@ import org.apache.tuscany.sca.node.impl.NodeImpl; public class NoMatchingBindingTestCase extends TestCase { private CalculatorService calculatorService; - private SCANode node; + private Node node; @Override protected void setUp() throws Exception { - SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); + NodeFactory nodeFactory = NodeFactory.newInstance(); node = - nodeFactory.createSCANode("Calculator.composite", new SCAContribution("TestContribution", new File("src/main/resources/NoMatchingBinding") + nodeFactory.createNode("Calculator.composite", new Contribution("TestContribution", new File("src/main/resources/NoMatchingBinding") .toURL().toString())); node.start(); - calculatorService = ((SCAClient)node).getService(CalculatorService.class, "CalculatorServiceComponent"); + calculatorService = ((Client)node).getService(CalculatorService.class, "CalculatorServiceComponent"); } @Override diff --git a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/PromotedReferenceNotFoundTestCase.java b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/PromotedReferenceNotFoundTestCase.java index afd533bcf4..057039b4df 100644 --- a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/PromotedReferenceNotFoundTestCase.java +++ b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/PromotedReferenceNotFoundTestCase.java @@ -27,10 +27,10 @@ import org.apache.tuscany.sca.core.UtilityExtensionPoint; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.MonitorFactory; import org.apache.tuscany.sca.monitor.Problem; -import org.apache.tuscany.sca.node.SCAClient; -import org.apache.tuscany.sca.node.SCAContribution; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Client; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.apache.tuscany.sca.node.impl.NodeImpl; /** @@ -39,16 +39,16 @@ import org.apache.tuscany.sca.node.impl.NodeImpl; public class PromotedReferenceNotFoundTestCase extends TestCase { private CalculatorService calculatorService; - private SCANode node; + private Node node; @Override protected void setUp() throws Exception { - SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); - node = nodeFactory.createSCANode(new File("src/main/resources/PromotedReferenceNotFound/Calculator.composite").toURL().toString(), - new SCAContribution("TestContribution", + NodeFactory nodeFactory = NodeFactory.newInstance(); + node = nodeFactory.createNode(new File("src/main/resources/PromotedReferenceNotFound/Calculator.composite").toURL().toString(), + new Contribution("TestContribution", new File("src/main/resources/PromotedReferenceNotFound").toURL().toString())); node.start(); - calculatorService = ((SCAClient)node).getService(CalculatorService.class, "CalculatorServiceComponent"); + calculatorService = ((Client)node).getService(CalculatorService.class, "CalculatorServiceComponent"); } @Override diff --git a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/PromotedServiceNotFoundTestCase.java b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/PromotedServiceNotFoundTestCase.java index 6ca4348f26..cda4f9cb57 100644 --- a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/PromotedServiceNotFoundTestCase.java +++ b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/PromotedServiceNotFoundTestCase.java @@ -27,10 +27,10 @@ import org.apache.tuscany.sca.core.UtilityExtensionPoint; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.MonitorFactory; import org.apache.tuscany.sca.monitor.Problem; -import org.apache.tuscany.sca.node.SCAClient; -import org.apache.tuscany.sca.node.SCAContribution; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Client; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.apache.tuscany.sca.node.impl.NodeImpl; /** @@ -39,16 +39,16 @@ import org.apache.tuscany.sca.node.impl.NodeImpl; public class PromotedServiceNotFoundTestCase extends TestCase { private CalculatorService calculatorService; - private SCANode node; + private Node node; @Override protected void setUp() throws Exception { - SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); - node = nodeFactory.createSCANode(new File("src/main/resources/PromotedServiceNotFound/Calculator.composite").toURL().toString(), - new SCAContribution("TestContribution", + NodeFactory nodeFactory = NodeFactory.newInstance(); + node = nodeFactory.createNode(new File("src/main/resources/PromotedServiceNotFound/Calculator.composite").toURL().toString(), + new Contribution("TestContribution", new File("src/main/resources/PromotedServiceNotFound").toURL().toString())); node.start(); - calculatorService = ((SCAClient)node).getService(CalculatorService.class, "CalculatorServiceComponent"); + calculatorService = ((Client)node).getService(CalculatorService.class, "CalculatorServiceComponent"); } @Override diff --git a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/PropertyAttributeMustSupplyNullTestCase.java b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/PropertyAttributeMustSupplyNullTestCase.java index 616d2743e2..e8475bb865 100644 --- a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/PropertyAttributeMustSupplyNullTestCase.java +++ b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/PropertyAttributeMustSupplyNullTestCase.java @@ -27,10 +27,10 @@ import org.apache.tuscany.sca.core.UtilityExtensionPoint; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.MonitorFactory; import org.apache.tuscany.sca.monitor.Problem; -import org.apache.tuscany.sca.node.SCAClient; -import org.apache.tuscany.sca.node.SCAContribution; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Client; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.apache.tuscany.sca.node.impl.NodeImpl; /** @@ -39,16 +39,16 @@ import org.apache.tuscany.sca.node.impl.NodeImpl; public class PropertyAttributeMustSupplyNullTestCase extends TestCase { private CalculatorService calculatorService; - private SCANode node; + private Node node; @Override protected void setUp() throws Exception { - SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); - node = nodeFactory.createSCANode(new File("src/main/resources/PropertyAttribute/CalculatorNullMustSupply.composite").toURL().toString(), - new SCAContribution("TestContribution", + NodeFactory nodeFactory = NodeFactory.newInstance(); + node = nodeFactory.createNode(new File("src/main/resources/PropertyAttribute/CalculatorNullMustSupply.composite").toURL().toString(), + new Contribution("TestContribution", new File("src/main/resources/PropertyAttribute").toURL().toString())); node.start(); - calculatorService = ((SCAClient)node).getService(CalculatorService.class, "CalculatorServiceComponent"); + calculatorService = ((Client)node).getService(CalculatorService.class, "CalculatorServiceComponent"); } @Override diff --git a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/PropertyAttributeTestCase.java b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/PropertyAttributeTestCase.java index c5b3026322..88721a18e2 100644 --- a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/PropertyAttributeTestCase.java +++ b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/PropertyAttributeTestCase.java @@ -27,10 +27,10 @@ import org.apache.tuscany.sca.core.UtilityExtensionPoint; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.MonitorFactory; import org.apache.tuscany.sca.monitor.Problem; -import org.apache.tuscany.sca.node.SCAClient; -import org.apache.tuscany.sca.node.SCAContribution; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Client; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.apache.tuscany.sca.node.impl.NodeImpl; /** @@ -39,16 +39,16 @@ import org.apache.tuscany.sca.node.impl.NodeImpl; public class PropertyAttributeTestCase extends TestCase { private CalculatorService calculatorService; - private SCANode node; + private Node node; @Override protected void setUp() throws Exception { - SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); - node = nodeFactory.createSCANode(new File("src/main/resources/PropertyAttribute/Calculator.composite").toURL().toString(), - new SCAContribution("TestContribution", + NodeFactory nodeFactory = NodeFactory.newInstance(); + node = nodeFactory.createNode(new File("src/main/resources/PropertyAttribute/Calculator.composite").toURL().toString(), + new Contribution("TestContribution", new File("src/main/resources/PropertyAttribute").toURL().toString())); node.start(); - calculatorService = ((SCAClient)node).getService(CalculatorService.class, "CalculatorServiceComponent"); + calculatorService = ((Client)node).getService(CalculatorService.class, "CalculatorServiceComponent"); } @Override diff --git a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/PropertyNotFoundTestCase.java b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/PropertyNotFoundTestCase.java index a096cfd41c..1a0739eaa5 100644 --- a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/PropertyNotFoundTestCase.java +++ b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/PropertyNotFoundTestCase.java @@ -27,10 +27,10 @@ import org.apache.tuscany.sca.core.UtilityExtensionPoint; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.MonitorFactory; import org.apache.tuscany.sca.monitor.Problem; -import org.apache.tuscany.sca.node.SCAClient; -import org.apache.tuscany.sca.node.SCAContribution; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Client; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.apache.tuscany.sca.node.impl.NodeImpl; /** @@ -39,16 +39,16 @@ import org.apache.tuscany.sca.node.impl.NodeImpl; public class PropertyNotFoundTestCase extends TestCase { private CalculatorService calculatorService; - private SCANode node; + private Node node; @Override protected void setUp() throws Exception { - SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); - node = nodeFactory.createSCANode(new File("src/main/resources/PropertyNotFound/Calculator.composite").toURL().toString(), - new SCAContribution("TestContribution", + NodeFactory nodeFactory = NodeFactory.newInstance(); + node = nodeFactory.createNode(new File("src/main/resources/PropertyNotFound/Calculator.composite").toURL().toString(), + new Contribution("TestContribution", new File("src/main/resources/PropertyNotFound").toURL().toString())); node.start(); - calculatorService = ((SCAClient)node).getService(CalculatorService.class, "CalculatorServiceComponent"); + calculatorService = ((Client)node).getService(CalculatorService.class, "CalculatorServiceComponent"); } @Override diff --git a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/PropertyOverrideManyAttributeTestCase.java b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/PropertyOverrideManyAttributeTestCase.java index 4558bc7df3..c20c551d92 100644 --- a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/PropertyOverrideManyAttributeTestCase.java +++ b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/PropertyOverrideManyAttributeTestCase.java @@ -27,10 +27,10 @@ import org.apache.tuscany.sca.core.UtilityExtensionPoint; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.MonitorFactory; import org.apache.tuscany.sca.monitor.Problem; -import org.apache.tuscany.sca.node.SCAClient; -import org.apache.tuscany.sca.node.SCAContribution; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Client; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.apache.tuscany.sca.node.impl.NodeImpl; /** @@ -39,16 +39,16 @@ import org.apache.tuscany.sca.node.impl.NodeImpl; public class PropertyOverrideManyAttributeTestCase extends TestCase { private CalculatorService calculatorService; - private SCANode node; + private Node node; @Override protected void setUp() throws Exception { - SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); - node = nodeFactory.createSCANode(new File("src/main/resources/PropertyAttribute/CalculatorOverrideManyAttribute.composite").toURL().toString(), - new SCAContribution("TestContribution", + NodeFactory nodeFactory = NodeFactory.newInstance(); + node = nodeFactory.createNode(new File("src/main/resources/PropertyAttribute/CalculatorOverrideManyAttribute.composite").toURL().toString(), + new Contribution("TestContribution", new File("src/main/resources/PropertyAttribute").toURL().toString())); node.start(); - calculatorService = ((SCAClient)node).getService(CalculatorService.class, "CalculatorServiceComponent"); + calculatorService = ((Client)node).getService(CalculatorService.class, "CalculatorServiceComponent"); } @Override diff --git a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/ReferenceIncompatibleComponentInterfaceTestCase.java b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/ReferenceIncompatibleComponentInterfaceTestCase.java index cff24f6616..7ae97638ce 100644 --- a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/ReferenceIncompatibleComponentInterfaceTestCase.java +++ b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/ReferenceIncompatibleComponentInterfaceTestCase.java @@ -27,10 +27,10 @@ import org.apache.tuscany.sca.core.UtilityExtensionPoint; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.MonitorFactory; import org.apache.tuscany.sca.monitor.Problem; -import org.apache.tuscany.sca.node.SCAClient; -import org.apache.tuscany.sca.node.SCAContribution; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Client; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.apache.tuscany.sca.node.impl.NodeImpl; /** @@ -39,16 +39,16 @@ import org.apache.tuscany.sca.node.impl.NodeImpl; public class ReferenceIncompatibleComponentInterfaceTestCase extends TestCase { private CalculatorService calculatorService; - private SCANode node; + private Node node; @Override protected void setUp() throws Exception { - SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); - node = nodeFactory.createSCANode(new File("src/main/resources/ReferenceIncompatibleComponentInterface/Calculator.composite").toURL().toString(), - new SCAContribution("TestContribution", + NodeFactory nodeFactory = NodeFactory.newInstance(); + node = nodeFactory.createNode(new File("src/main/resources/ReferenceIncompatibleComponentInterface/Calculator.composite").toURL().toString(), + new Contribution("TestContribution", new File("src/main/resources/ReferenceIncompatibleComponentInterface").toURL().toString())); node.start(); - calculatorService = ((SCAClient)node).getService(CalculatorService.class, "CalculatorServiceComponent"); + calculatorService = ((Client)node).getService(CalculatorService.class, "CalculatorServiceComponent"); } @Override diff --git a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/ReferenceIncompatibleInterfaceTestCase.java b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/ReferenceIncompatibleInterfaceTestCase.java index c6b4c65235..6e5eb41ba0 100644 --- a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/ReferenceIncompatibleInterfaceTestCase.java +++ b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/ReferenceIncompatibleInterfaceTestCase.java @@ -27,10 +27,10 @@ import org.apache.tuscany.sca.core.UtilityExtensionPoint; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.MonitorFactory; import org.apache.tuscany.sca.monitor.Problem; -import org.apache.tuscany.sca.node.SCAClient; -import org.apache.tuscany.sca.node.SCAContribution; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Client; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.apache.tuscany.sca.node.impl.NodeImpl; /** @@ -39,16 +39,16 @@ import org.apache.tuscany.sca.node.impl.NodeImpl; public class ReferenceIncompatibleInterfaceTestCase extends TestCase { private CalculatorService calculatorService; - private SCANode node; + private Node node; @Override protected void setUp() throws Exception { - SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); - node = nodeFactory.createSCANode(new File("src/main/resources/ReferenceIncompatibleInterface/Calculator.composite").toURL().toString(), - new SCAContribution("TestContribution", + NodeFactory nodeFactory = NodeFactory.newInstance(); + node = nodeFactory.createNode(new File("src/main/resources/ReferenceIncompatibleInterface/Calculator.composite").toURL().toString(), + new Contribution("TestContribution", new File("src/main/resources/ReferenceIncompatibleInterface").toURL().toString())); node.start(); - calculatorService = ((SCAClient)node).getService(CalculatorService.class, "CalculatorServiceComponent"); + calculatorService = ((Client)node).getService(CalculatorService.class, "CalculatorServiceComponent"); } @Override diff --git a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/ReferenceIncompatibleMultiplicityTestCase.java b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/ReferenceIncompatibleMultiplicityTestCase.java index c4ba0ecbcd..2eec73f815 100644 --- a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/ReferenceIncompatibleMultiplicityTestCase.java +++ b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/ReferenceIncompatibleMultiplicityTestCase.java @@ -27,10 +27,10 @@ import org.apache.tuscany.sca.core.UtilityExtensionPoint; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.MonitorFactory; import org.apache.tuscany.sca.monitor.Problem; -import org.apache.tuscany.sca.node.SCAClient; -import org.apache.tuscany.sca.node.SCAContribution; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Client; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.apache.tuscany.sca.node.impl.NodeImpl; /** @@ -39,16 +39,16 @@ import org.apache.tuscany.sca.node.impl.NodeImpl; public class ReferenceIncompatibleMultiplicityTestCase extends TestCase { private CalculatorService calculatorService; - private SCANode node; + private Node node; @Override protected void setUp() throws Exception { - SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); - node = nodeFactory.createSCANode(new File("src/main/resources/ReferenceIncompatibleMultiplicity/Calculator.composite").toURL().toString(), - new SCAContribution("TestContribution", + NodeFactory nodeFactory = NodeFactory.newInstance(); + node = nodeFactory.createNode(new File("src/main/resources/ReferenceIncompatibleMultiplicity/Calculator.composite").toURL().toString(), + new Contribution("TestContribution", new File("src/main/resources/ReferenceIncompatibleMultiplicity").toURL().toString())); node.start(); - calculatorService = ((SCAClient)node).getService(CalculatorService.class, "CalculatorServiceComponent"); + calculatorService = ((Client)node).getService(CalculatorService.class, "CalculatorServiceComponent"); } @Override diff --git a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/ReferenceWithoutTargetsTestCase.java b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/ReferenceWithoutTargetsTestCase.java index c75d2a0e9d..9b5adee7e6 100644 --- a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/ReferenceWithoutTargetsTestCase.java +++ b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/ReferenceWithoutTargetsTestCase.java @@ -27,10 +27,10 @@ import org.apache.tuscany.sca.core.UtilityExtensionPoint; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.MonitorFactory; import org.apache.tuscany.sca.monitor.Problem; -import org.apache.tuscany.sca.node.SCAClient; -import org.apache.tuscany.sca.node.SCAContribution; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Client; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.apache.tuscany.sca.node.impl.NodeImpl; /** @@ -39,16 +39,16 @@ import org.apache.tuscany.sca.node.impl.NodeImpl; public class ReferenceWithoutTargetsTestCase extends TestCase { private CalculatorService calculatorService; - private SCANode node; + private Node node; @Override protected void setUp() throws Exception { - SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); - node = nodeFactory.createSCANode(new File("src/main/resources/ReferenceWithoutTargets/Calculator.composite").toURL().toString(), - new SCAContribution("TestContribution", + NodeFactory nodeFactory = NodeFactory.newInstance(); + node = nodeFactory.createNode(new File("src/main/resources/ReferenceWithoutTargets/Calculator.composite").toURL().toString(), + new Contribution("TestContribution", new File("src/main/resources/ReferenceWithoutTargets").toURL().toString())); node.start(); - calculatorService = ((SCAClient)node).getService(CalculatorService.class, "CalculatorServiceComponent"); + calculatorService = ((Client)node).getService(CalculatorService.class, "CalculatorServiceComponent"); } @Override diff --git a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/ServiceNotFoundForComponentServiceTestCase.java b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/ServiceNotFoundForComponentServiceTestCase.java index 1215ddf06a..1b8116a469 100644 --- a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/ServiceNotFoundForComponentServiceTestCase.java +++ b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/ServiceNotFoundForComponentServiceTestCase.java @@ -27,10 +27,10 @@ import org.apache.tuscany.sca.core.UtilityExtensionPoint; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.MonitorFactory; import org.apache.tuscany.sca.monitor.Problem; -import org.apache.tuscany.sca.node.SCAClient; -import org.apache.tuscany.sca.node.SCAContribution; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Client; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.apache.tuscany.sca.node.impl.NodeImpl; /** @@ -39,16 +39,16 @@ import org.apache.tuscany.sca.node.impl.NodeImpl; public class ServiceNotFoundForComponentServiceTestCase extends TestCase { private CalculatorService calculatorService; - private SCANode node; + private Node node; @Override protected void setUp() throws Exception { - SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); - node = nodeFactory.createSCANode(new File("src/main/resources/ServiceNotFoundForComponentService/Calculator.composite").toURL().toString(), - new SCAContribution("TestContribution", + NodeFactory nodeFactory = NodeFactory.newInstance(); + node = nodeFactory.createNode(new File("src/main/resources/ServiceNotFoundForComponentService/Calculator.composite").toURL().toString(), + new Contribution("TestContribution", new File("src/main/resources/ServiceNotFoundForComponentService").toURL().toString())); node.start(); - calculatorService = ((SCAClient)node).getService(CalculatorService.class, "CalculatorServiceComponent"); + calculatorService = ((Client)node).getService(CalculatorService.class, "CalculatorServiceComponent"); } @Override diff --git a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/UnresolvedComponentImplementationTestCase.java b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/UnresolvedComponentImplementationTestCase.java index 31cf0779b0..c848cbb243 100644 --- a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/UnresolvedComponentImplementationTestCase.java +++ b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/UnresolvedComponentImplementationTestCase.java @@ -27,9 +27,9 @@ import org.apache.tuscany.sca.core.UtilityExtensionPoint; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.MonitorFactory; import org.apache.tuscany.sca.monitor.Problem; -import org.apache.tuscany.sca.node.SCAContribution; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.apache.tuscany.sca.node.impl.NodeImpl; /** @@ -38,13 +38,13 @@ import org.apache.tuscany.sca.node.impl.NodeImpl; public class UnresolvedComponentImplementationTestCase extends TestCase { private CalculatorService calculatorService; - private SCANode node; + private Node node; @Override protected void setUp() throws Exception { - SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); - node = nodeFactory.createSCANode(new File("src/main/resources/UnresolvedComponentImplementation/Calculator.composite").toURL().toString(), - new SCAContribution("TestContribution", + NodeFactory nodeFactory = NodeFactory.newInstance(); + node = nodeFactory.createNode(new File("src/main/resources/UnresolvedComponentImplementation/Calculator.composite").toURL().toString(), + new Contribution("TestContribution", new File("src/main/resources/UnresolvedComponentImplementation").toURL().toString())); } diff --git a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/XSDValidationTestCase.java b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/XSDValidationTestCase.java index 60b08764c1..bcd6637a03 100644 --- a/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/XSDValidationTestCase.java +++ b/branches/sca-equinox/itest/validation/src/test/java/calculator/warning/XSDValidationTestCase.java @@ -22,10 +22,10 @@ import java.io.File; import junit.framework.TestCase; -import org.apache.tuscany.sca.node.SCAClient; -import org.apache.tuscany.sca.node.SCAContribution; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Client; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; /** * This shows how to test the Calculator service component. @@ -33,18 +33,18 @@ import org.apache.tuscany.sca.node.SCANodeFactory; public class XSDValidationTestCase extends TestCase { private CalculatorService calculatorService; - private SCANode node; + private Node node; private Exception startUpException; @Override protected void setUp() throws Exception { - SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); + NodeFactory nodeFactory = NodeFactory.newInstance(); try { - node = nodeFactory.createSCANode(new File("src/main/resources/XsdValidation/Calculator.composite").toURL().toString(), - new SCAContribution("TestContribution", + node = nodeFactory.createNode(new File("src/main/resources/XsdValidation/Calculator.composite").toURL().toString(), + new Contribution("TestContribution", new File("src/main/resources/XsdValidation").toURL().toString())); node.start(); - calculatorService = ((SCAClient)node).getService(CalculatorService.class, "CalculatorServiceComponent"); + calculatorService = ((Client)node).getService(CalculatorService.class, "CalculatorServiceComponent"); } catch (Exception ex){ startUpException = ex; } diff --git a/branches/sca-equinox/modules/binding-atom-abdera/pom.xml b/branches/sca-equinox/modules/binding-atom-abdera/pom.xml index 5ae1fa7e0b..edb317e4a9 100644 --- a/branches/sca-equinox/modules/binding-atom-abdera/pom.xml +++ b/branches/sca-equinox/modules/binding-atom-abdera/pom.xml @@ -162,7 +162,7 @@ <dependency> <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-host-embedded</artifactId> + <artifactId>tuscany-node-impl</artifactId> <version>1.4-SNAPSHOT</version> <scope>test</scope> </dependency> diff --git a/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/AtomDeleteTestCase.java b/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/AtomDeleteTestCase.java index f9ac5f9c78..9cffe0ae49 100644 --- a/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/AtomDeleteTestCase.java +++ b/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/AtomDeleteTestCase.java @@ -8,37 +8,53 @@ import org.apache.abdera.Abdera; import org.apache.abdera.model.Content; import org.apache.abdera.model.Entry; import org.apache.tuscany.sca.binding.atom.collection.Collection; -import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.node.Client; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; public class AtomDeleteTestCase { - protected static SCADomain scaConsumerDomain; - protected static SCADomain scaProviderDomain; + protected static Node consumerNode; + protected static Node providerNode; protected static CustomerClient testService; protected static Abdera abdera; @BeforeClass public static void init() throws Exception { + try{ System.out.println(">>>AtomDeleteTestCase.init entry"); - scaProviderDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/atom/Provider.composite"); - scaConsumerDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/atom/Consumer.composite"); - testService = scaConsumerDomain.getService(CustomerClient.class, "CustomerClient"); + String contribution = ContributionLocationHelper.getContributionLocation(AtomDeleteTestCase.class); + providerNode = NodeFactory.newInstance().createNode( + "org/apache/tuscany/sca/binding/atom/Provider.composite", new Contribution("provider", contribution)); + consumerNode = NodeFactory.newInstance().createNode( + "org/apache/tuscany/sca/binding/atom/Consumer.composite", new Contribution("consumer", contribution)); + providerNode.start(); + consumerNode.start(); + testService = consumerNode.getService(CustomerClient.class, "CustomerClient"); abdera = new Abdera(); + } catch (Exception e) { + e.printStackTrace(); + + } } @AfterClass public static void destroy() throws Exception { // System.out.println(">>>AtomDeleteTestCase.destroy entry"); - scaConsumerDomain.close(); - scaProviderDomain.close(); + consumerNode.stop(); + consumerNode.destroy(); + providerNode.stop(); + providerNode.destroy(); } @Test public void testPrelim() throws Exception { - Assert.assertNotNull(scaProviderDomain); - Assert.assertNotNull(scaConsumerDomain); + Assert.assertNotNull(providerNode); + Assert.assertNotNull(consumerNode); Assert.assertNotNull(testService); Assert.assertNotNull(abdera); } diff --git a/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/AtomGetTestCase.java b/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/AtomGetTestCase.java index 8d78d167c3..eaa2bc4a97 100644 --- a/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/AtomGetTestCase.java +++ b/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/AtomGetTestCase.java @@ -6,37 +6,47 @@ import org.apache.abdera.Abdera; import org.apache.abdera.model.Content; import org.apache.abdera.model.Entry; import org.apache.tuscany.sca.binding.atom.collection.Collection; -import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; public class AtomGetTestCase { - protected static SCADomain scaConsumerDomain; - protected static SCADomain scaProviderDomain; + protected static Node consumerNode; + protected static Node providerNode; protected static CustomerClient testService; protected static Abdera abdera; @BeforeClass public static void init() throws Exception { System.out.println(">>>AtomGetTestCase.init entry"); - scaProviderDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/atom/Provider.composite"); - scaConsumerDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/atom/Consumer.composite"); - testService = scaConsumerDomain.getService(CustomerClient.class, "CustomerClient"); + String contribution = ContributionLocationHelper.getContributionLocation(AtomDeleteTestCase.class); + providerNode = NodeFactory.newInstance().createNode( + "org/apache/tuscany/sca/binding/atom/Provider.composite", new Contribution("provider", contribution)); + consumerNode = NodeFactory.newInstance().createNode( + "org/apache/tuscany/sca/binding/atom/Consumer.composite", new Contribution("consumer", contribution)); + providerNode.start(); + consumerNode.start(); + testService = consumerNode.getService(CustomerClient.class, "CustomerClient"); abdera = new Abdera(); } @AfterClass public static void destroy() throws Exception { // System.out.println(">>>AtomGetTestCase.destroy entry"); - scaConsumerDomain.close(); - scaProviderDomain.close(); + consumerNode.stop(); + consumerNode.destroy(); + providerNode.stop(); + providerNode.destroy(); } @Test public void testPrelim() throws Exception { - Assert.assertNotNull(scaProviderDomain); - Assert.assertNotNull(scaConsumerDomain); + Assert.assertNotNull(providerNode); + Assert.assertNotNull(consumerNode); Assert.assertNotNull(testService); Assert.assertNotNull(abdera); } diff --git a/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/AtomPostTestCase.java b/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/AtomPostTestCase.java index ef5fe5a873..ffe8a03f20 100644 --- a/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/AtomPostTestCase.java +++ b/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/AtomPostTestCase.java @@ -6,37 +6,47 @@ import org.apache.abdera.Abdera; import org.apache.abdera.model.Content; import org.apache.abdera.model.Entry; import org.apache.tuscany.sca.binding.atom.collection.Collection; -import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; public class AtomPostTestCase { - protected static SCADomain scaConsumerDomain; - protected static SCADomain scaProviderDomain; + protected static Node consumerNode; + protected static Node providerNode; protected static CustomerClient testService; protected static Abdera abdera; @BeforeClass public static void init() throws Exception { System.out.println(">>>AtomPostTestCase.init entry"); - scaProviderDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/atom/Provider.composite"); - scaConsumerDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/atom/Consumer.composite"); - testService = scaConsumerDomain.getService(CustomerClient.class, "CustomerClient"); + String contribution = ContributionLocationHelper.getContributionLocation(AtomDeleteTestCase.class); + providerNode = NodeFactory.newInstance().createNode( + "org/apache/tuscany/sca/binding/atom/Provider.composite", new Contribution("provider", contribution)); + consumerNode = NodeFactory.newInstance().createNode( + "org/apache/tuscany/sca/binding/atom/Consumer.composite", new Contribution("consumer", contribution)); + providerNode.start(); + consumerNode.start(); + testService = consumerNode.getService(CustomerClient.class, "CustomerClient"); abdera = new Abdera(); } @AfterClass public static void destroy() throws Exception { System.out.println(">>>AtomPostTestCase.destroy entry"); - scaConsumerDomain.close(); - scaProviderDomain.close(); + consumerNode.stop(); + consumerNode.destroy(); + providerNode.stop(); + providerNode.destroy(); } @Test public void testPrelim() throws Exception { - Assert.assertNotNull(scaProviderDomain); - Assert.assertNotNull(scaConsumerDomain); + Assert.assertNotNull(providerNode); + Assert.assertNotNull(consumerNode); Assert.assertNotNull(testService); Assert.assertNotNull(abdera); } diff --git a/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/AtomPutTestCase.java b/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/AtomPutTestCase.java index a5c1226780..08c1ed7ac9 100644 --- a/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/AtomPutTestCase.java +++ b/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/AtomPutTestCase.java @@ -8,37 +8,47 @@ import org.apache.abdera.Abdera; import org.apache.abdera.model.Content; import org.apache.abdera.model.Entry; import org.apache.tuscany.sca.binding.atom.collection.Collection; -import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; public class AtomPutTestCase { - protected static SCADomain scaConsumerDomain; - protected static SCADomain scaProviderDomain; + protected static Node consumerNode; + protected static Node providerNode; protected static CustomerClient testService; protected static Abdera abdera; @BeforeClass public static void init() throws Exception { System.out.println(">>>AtomPutTestCase.init entry"); - scaProviderDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/atom/Provider.composite"); - scaConsumerDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/atom/Consumer.composite"); - testService = scaConsumerDomain.getService(CustomerClient.class, "CustomerClient"); + String contribution = ContributionLocationHelper.getContributionLocation(AtomDeleteTestCase.class); + providerNode = NodeFactory.newInstance().createNode( + "org/apache/tuscany/sca/binding/atom/Provider.composite", new Contribution("provider", contribution)); + consumerNode = NodeFactory.newInstance().createNode( + "org/apache/tuscany/sca/binding/atom/Consumer.composite", new Contribution("consumer", contribution)); + providerNode.start(); + consumerNode.start(); + testService = consumerNode.getService(CustomerClient.class, "CustomerClient"); abdera = new Abdera(); } @AfterClass public static void destroy() throws Exception { // System.out.println(">>>AtomPutTestCase.destroy entry"); - scaConsumerDomain.close(); - scaProviderDomain.close(); + consumerNode.stop(); + consumerNode.destroy(); + providerNode.stop(); + providerNode.destroy(); } @Test public void testPrelim() throws Exception { - Assert.assertNotNull(scaProviderDomain); - Assert.assertNotNull(scaConsumerDomain); + Assert.assertNotNull(providerNode); + Assert.assertNotNull(consumerNode); Assert.assertNotNull(testService); Assert.assertNotNull(abdera); } diff --git a/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/Consumer.java b/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/Consumer.java index 34d3ed1d1c..5b4d995dc1 100644 --- a/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/Consumer.java +++ b/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/Consumer.java @@ -19,17 +19,24 @@ package org.apache.tuscany.sca.binding.atom; -import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; public class Consumer { public static void main(String[] args) throws Exception { - SCADomain scaDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/atom/Consumer.composite"); + String contribution = ContributionLocationHelper.getContributionLocation(AtomDeleteTestCase.class); + Node node = NodeFactory.newInstance().createNode( + "org/apache/tuscany/sca/binding/atom/Consumer.composite", new Contribution("consumer", contribution)); + node.start(); - CustomerClient testService = scaDomain.getService(CustomerClient.class, "CustomerClient"); + CustomerClient testService = node.getService(CustomerClient.class, "CustomerClient"); testService.testCustomerCollection(); - scaDomain.close(); + node.stop(); + node.destroy(); } } diff --git a/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ConsumerProviderAtomTestCase.java b/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ConsumerProviderAtomTestCase.java index 9af85a970c..383344f3cb 100644 --- a/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ConsumerProviderAtomTestCase.java +++ b/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ConsumerProviderAtomTestCase.java @@ -27,7 +27,10 @@ import org.apache.abdera.model.Content; import org.apache.abdera.model.Entry; import org.apache.abdera.model.Feed; import org.apache.tuscany.sca.binding.atom.collection.Collection; -import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -37,119 +40,126 @@ import org.junit.Test; */ public class ConsumerProviderAtomTestCase { - protected static SCADomain scaConsumerDomain; - protected static SCADomain scaProviderDomain; - protected static CustomerClient testService; - protected static Abdera abdera; - - @BeforeClass - public static void init() throws Exception { - System.out.println(">>>AtomBindingIntegratedTestCase.init entry"); - scaProviderDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/atom/Provider.composite"); - scaConsumerDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/atom/Consumer.composite"); - testService = scaConsumerDomain.getService(CustomerClient.class,"CustomerClient"); - abdera = new Abdera(); - } - - @AfterClass - public static void destroy() throws Exception { - System.out.println(">>>AtomBindingIntegratedTestCase.destroy entry"); - scaConsumerDomain.close(); - scaProviderDomain.close(); - } - - @Test - public void testPrelim() throws Exception { - Assert.assertNotNull(scaProviderDomain); - Assert.assertNotNull(scaConsumerDomain); - Assert.assertNotNull(testService); - Assert.assertNotNull(abdera); - } - - @Test - public void testEntry() throws Exception { - // System.out.println( getClass().getName() + ".testEntry entry" ); - Entry entry = abdera.newEntry(); - Assert.assertNotNull(entry); - - String testTitle = "Sponge Bob"; - entry.setTitle(testTitle); - Assert.assertEquals(testTitle, entry.getTitle()); - - String testContent = "This is the content"; - entry.setContent(testContent); - Assert.assertEquals(testContent, entry.getContent()); - - Date now = new Date(); - entry.setEdited(now); - Assert.assertEquals(now, entry.getEdited()); - - Date later = new Date(); - entry.setPublished(later); - Assert.assertEquals(later, entry.getPublished()); - - String testSummary = "This is the summary"; - entry.setSummary(testSummary); - Assert.assertEquals(testSummary, entry.getSummary()); - } - - @Test - public void testCustomerCollection() throws Exception { - System.out.println(getClass().getName() + ".testCustomerCollection entry"); - Collection resourceCollection = testService.getCustomerCollection(); - Assert.assertNotNull(resourceCollection); - - Entry newEntry = newEntry("Sponge Bob"); - System.out.println(">>> post entry=" + newEntry.getTitle()); - newEntry = resourceCollection.post(newEntry); - System.out.println("<<< post id=" + newEntry.getId() + " entry=" + newEntry.getTitle()); - - newEntry = newEntry("Jane Bond"); - System.out.println(">>> post entry=" + newEntry.getTitle()); - newEntry = resourceCollection.post(newEntry); - System.out.println("<<< post id=" + newEntry.getId() + " entry=" + newEntry.getTitle()); - - System.out.println(">>> get id=" + newEntry.getId()); - Entry entry = resourceCollection.get(newEntry.getId().toString()); - System.out.println("<<< get id=" + entry.getId() + " entry=" + entry.getTitle()); - - System.out.println(">>> put id=" + newEntry.getId() + " entry=" + entry.getTitle()); - resourceCollection.put(entry.getId().toString(), updateEntry(entry, "James Bond")); - System.out.println("<<< put id=" + entry.getId() + " entry=" + entry.getTitle()); - - System.out.println(">>> delete id=" + entry.getId()); - resourceCollection.delete(entry.getId().toString()); - System.out.println("<<< delete id=" + entry.getId()); - - System.out.println(">>> get collection"); - Feed feed = resourceCollection.getFeed(); - System.out.println("<<< get collection"); - for (Object o : feed.getEntries()) { - Entry e = (Entry)o; - System.out.println("id = " + e.getId() + " entry = " + e.getTitle()); - } - } - - private Entry newEntry(String value) { - Entry entry = abdera.newEntry(); - entry.setTitle("customer " + value); - - Content content = abdera.getFactory().newContent(); - content.setContentType(Content.Type.TEXT); - content.setValue(value); - entry.setContentElement(content); - - return entry; - } - - private Entry updateEntry(Entry entry, String value) { - entry.setTitle("customer " + value); - - Content content = abdera.getFactory().newContent(); - content.setContentType(Content.Type.TEXT); - content.setValue(value); - entry.setContentElement(content); - - return entry; - } -}
\ No newline at end of file + protected static Node consumerNode; + protected static Node providerNode; + protected static CustomerClient testService; + protected static Abdera abdera; + + @BeforeClass + public static void init() throws Exception { + System.out.println(">>>AtomBindingIntegratedTestCase.init entry"); + String contribution = ContributionLocationHelper.getContributionLocation(AtomDeleteTestCase.class); + providerNode = NodeFactory.newInstance().createNode( + "org/apache/tuscany/sca/binding/atom/Provider.composite", new Contribution("provider", contribution)); + consumerNode = NodeFactory.newInstance().createNode( + "org/apache/tuscany/sca/binding/atom/Consumer.composite", new Contribution("consumer", contribution)); + providerNode.start(); + consumerNode.start(); + testService = consumerNode.getService(CustomerClient.class, "CustomerClient"); + abdera = new Abdera(); + } + + @AfterClass + public static void destroy() throws Exception { + System.out.println(">>>AtomBindingIntegratedTestCase.destroy entry"); + consumerNode.stop(); + consumerNode.destroy(); + providerNode.stop(); + providerNode.destroy(); + } + + @Test + public void testPrelim() throws Exception { + Assert.assertNotNull(providerNode); + Assert.assertNotNull(consumerNode); + Assert.assertNotNull(testService); + Assert.assertNotNull(abdera); + } + + @Test + public void testEntry() throws Exception { + // System.out.println( getClass().getName() + ".testEntry entry" ); + Entry entry = abdera.newEntry(); + Assert.assertNotNull(entry); + + String testTitle = "Sponge Bob"; + entry.setTitle(testTitle); + Assert.assertEquals(testTitle, entry.getTitle()); + + String testContent = "This is the content"; + entry.setContent(testContent); + Assert.assertEquals(testContent, entry.getContent()); + + Date now = new Date(); + entry.setEdited(now); + Assert.assertEquals(now, entry.getEdited()); + + Date later = new Date(); + entry.setPublished(later); + Assert.assertEquals(later, entry.getPublished()); + + String testSummary = "This is the summary"; + entry.setSummary(testSummary); + Assert.assertEquals(testSummary, entry.getSummary()); + } + + @Test + public void testCustomerCollection() throws Exception { + System.out.println(getClass().getName() + ".testCustomerCollection entry"); + Collection resourceCollection = testService.getCustomerCollection(); + Assert.assertNotNull(resourceCollection); + + Entry newEntry = newEntry("Sponge Bob"); + System.out.println(">>> post entry=" + newEntry.getTitle()); + newEntry = resourceCollection.post(newEntry); + System.out.println("<<< post id=" + newEntry.getId() + " entry=" + newEntry.getTitle()); + + newEntry = newEntry("Jane Bond"); + System.out.println(">>> post entry=" + newEntry.getTitle()); + newEntry = resourceCollection.post(newEntry); + System.out.println("<<< post id=" + newEntry.getId() + " entry=" + newEntry.getTitle()); + + System.out.println(">>> get id=" + newEntry.getId()); + Entry entry = resourceCollection.get(newEntry.getId().toString()); + System.out.println("<<< get id=" + entry.getId() + " entry=" + entry.getTitle()); + + System.out.println(">>> put id=" + newEntry.getId() + " entry=" + entry.getTitle()); + resourceCollection.put(entry.getId().toString(), updateEntry(entry, "James Bond")); + System.out.println("<<< put id=" + entry.getId() + " entry=" + entry.getTitle()); + + System.out.println(">>> delete id=" + entry.getId()); + resourceCollection.delete(entry.getId().toString()); + System.out.println("<<< delete id=" + entry.getId()); + + System.out.println(">>> get collection"); + Feed feed = resourceCollection.getFeed(); + System.out.println("<<< get collection"); + for (Object o : feed.getEntries()) { + Entry e = (Entry)o; + System.out.println("id = " + e.getId() + " entry = " + e.getTitle()); + } + } + + private Entry newEntry(String value) { + Entry entry = abdera.newEntry(); + entry.setTitle("customer " + value); + + Content content = abdera.getFactory().newContent(); + content.setContentType(Content.Type.TEXT); + content.setValue(value); + entry.setContentElement(content); + + return entry; + } + + private Entry updateEntry(Entry entry, String value) { + entry.setTitle("customer " + value); + + Content content = abdera.getFactory().newContent(); + content.setContentType(Content.Type.TEXT); + content.setValue(value); + entry.setContentElement(content); + + return entry; + } +} diff --git a/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ContentNegotiationTest.java b/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ContentNegotiationTest.java index 08f8e3db2a..7ec9c1480e 100644 --- a/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ContentNegotiationTest.java +++ b/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ContentNegotiationTest.java @@ -20,230 +20,246 @@ package org.apache.tuscany.sca.binding.atom; import java.io.IOException;
import java.io.Reader;
-import java.text.SimpleDateFormat;
import java.util.Date;
import junit.framework.Assert;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import org.apache.tuscany.sca.binding.atom.collection.Collection;
-import org.apache.tuscany.sca.host.embedded.SCADomain;
-
import org.apache.abdera.Abdera;
-import org.apache.abdera.i18n.iri.IRI;
import org.apache.abdera.factory.Factory;
-import org.apache.abdera.model.Base;
+import org.apache.abdera.i18n.iri.IRI;
import org.apache.abdera.model.Content;
+import org.apache.abdera.model.Document;
import org.apache.abdera.model.Entry;
import org.apache.abdera.model.Feed;
-import org.apache.abdera.model.Document;
-import org.apache.abdera.model.Service;
+import org.apache.abdera.parser.Parser;
import org.apache.abdera.protocol.Response.ResponseType;
import org.apache.abdera.protocol.client.AbderaClient;
import org.apache.abdera.protocol.client.ClientResponse;
import org.apache.abdera.protocol.client.RequestOptions;
-import org.apache.abdera.protocol.client.util.BaseRequestEntity;
-import org.apache.abdera.util.EntityTag;
-import org.apache.abdera.parser.Parser;
-
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
/**
- * Tests use of content negotiation for Atom binding in Tuscany.
- * Uses the SCA provided Provider composite to act as a server.
- * Uses the Abdera provided Client to act as a client.
+ * Tests use of content negotiation for Atom binding in Tuscany. Uses the SCA
+ * provided Provider composite to act as a server. Uses the Abdera provided
+ * Client to act as a client.
*/
public class ContentNegotiationTest {
- public final static String providerURI = "http://localhost:8084/customer";
- protected static SCADomain scaProviderDomain;
- protected static CustomerClient testService;
+ public final static String providerURI = "http://localhost:8084/customer";
+ protected static Node providerNode;
protected static Abdera abdera;
protected static AbderaClient client;
- protected static Parser abderaParser;
+ protected static Parser abderaParser;
protected static String lastId;
- @BeforeClass
- public static void init() throws Exception {
- System.out.println(">>>ContentNegotiationTest.init");
- scaProviderDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/atom/Provider.composite");
- abdera = new Abdera();
- client = new AbderaClient(abdera);
- abderaParser = Abdera.getNewParser();
- }
-
- @AfterClass
- public static void destroy() throws Exception {
- System.out.println(">>>ContentNegotiationTest.destroy");
- scaProviderDomain.close();
- }
-
- @Test
- public void testPrelim() throws Exception {
- Assert.assertNotNull(scaProviderDomain);
- Assert.assertNotNull( client );
- }
-
+ @BeforeClass
+ public static void init() throws Exception {
+ System.out.println(">>>ContentNegotiationTest.init");
+ String contribution = ContributionLocationHelper.getContributionLocation(AtomDeleteTestCase.class);
+ providerNode = NodeFactory.newInstance().createNode(
+ "org/apache/tuscany/sca/binding/atom/Provider.composite", new Contribution("provider", contribution));
+ providerNode.start();
+ abdera = new Abdera();
+ client = new AbderaClient(abdera);
+ abderaParser = Abdera.getNewParser();
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ System.out.println(">>>ContentNegotiationTest.destroy");
+ providerNode.stop();
+ providerNode.destroy();
+ }
+
+ @Test
+ public void testPrelim() throws Exception {
+ Assert.assertNotNull(providerNode);
+ Assert.assertNotNull(client);
+ }
+
@Test
- public void testPost() throws Exception {
- System.out.println(">>>ContentNegotiationTest.testPost");
- // Testing of entry creation
- Factory factory = abdera.getFactory();
- String customerName = "Fred Farkle";
- Entry entry = factory.newEntry();
- entry.setTitle("customer " + customerName);
- entry.setUpdated(new Date());
- entry.addAuthor("Apache Tuscany");
- // ID created by collection.
- Content content = abdera.getFactory().newContent();
- content.setContentType(Content.Type.TEXT);
- content.setValue(customerName);
- entry.setContentElement(content);
-
- RequestOptions opts = new RequestOptions();
- final String contentType = "application/atom+xml; type=entry";
- opts.setContentType(contentType);
- // AtomTestCaseUtils.printRequestHeaders( "Post request headers", " ", opts );
- IRI colUri = new IRI(providerURI).resolve("customer");
- // res = client.post(colUri.toString() + "?test=foo", entry, opts);
- ClientResponse res = client.post(colUri.toString(), entry, opts);
-
- // Assert response status code is 201-OK.
- // Assert response header Content-Type: application/atom+xml; charset=UTF-8
- Assert.assertEquals(201, res.getStatus());
- String returnedContentType = res.getContentType().toString().trim();
- Assert.assertEquals(contentType, returnedContentType );
-
- String eTag = res.getHeader( "ETag" );
- if ( eTag != null)
- lastId = eTag.substring( 1, eTag.length()-1);
-
- // AtomTestCaseUtils.printResponseHeaders( "Entry post response headers:", " ", res );
- // System.out.println("Entry post response content:");
- // AtomTestCaseUtils.prettyPrint(abdera, res.getDocument());
- }
-
- @Test
- public void testXMLEntryGet() throws Exception {
- System.out.println(">>>ContentNegotiationTest.testXMLEntryGet");
- RequestOptions opts = new RequestOptions();
- opts.setHeader( "Accept", "application/atom+xml" );
-
- IRI colUri = new IRI(providerURI).resolve("customer");
- ClientResponse res = client.get(colUri.toString() + "/" + lastId, opts);
- Assert.assertEquals(200, res.getStatus());
- String returnedContentType = res.getContentType().toString().trim();
- // Assert.assertEquals(contentType, returnedContentType );
- res.release();
- }
-
- @Test
- public void testJSONEntryGet() throws Exception {
- System.out.println(">>>ContentNegotiationTest.testJSONEntryGet");
- RequestOptions opts = new RequestOptions();
- opts.setHeader( "Accept", "application/json" );
-
- IRI colUri = new IRI(providerURI).resolve("customer");
- ClientResponse res = client.get(colUri.toString() + "/" + lastId, opts);
- try {
- Assert.assertEquals(200, res.getStatus());
- // Abdera 0.4 throws exception on getContentType with application/json.
- // System.out.println( "ContentNegotiationTest.testJSONEntryGet contentType=" + res.getContentType());
- String contentType = res.getHeader( "Content-Type");
- Assert.assertTrue( -1 < contentType.indexOf( "application/json" ));
- // Following is a poor man's JSONObject test to avoid dependency on JSON libs.
- // JSONObject jsonResp = new JSONObject(res.);
- // Assert.assertEquals(12345, jsonResp.getInt("result"));
- String responseBody = readResponse( res.getReader() );
- Assert.assertTrue( responseBody.startsWith( "{") );
- Assert.assertTrue( responseBody.endsWith( "}") );
- Assert.assertTrue( -1 < responseBody.indexOf( "\"id\"" ));
- Assert.assertTrue( -1 < responseBody.indexOf( "\"title\"" ));
- Assert.assertTrue( -1 < responseBody.indexOf( "\"updated\"" ));
- // AtomTestCaseUtils.printResponseHeaders( "JSON Entry response headers:", " ", res );
- // System.out.println( "ContentNegotiationTest.testJSONEntryGet JSON entry body=" + responseBody );
- } finally {
- res.release();
- }
- }
-
- @Test
- public void testXMLFeedGet() throws Exception {
- System.out.println(">>>ContentNegotiationTest.testXMLFeedGet");
- RequestOptions opts = new RequestOptions();
- opts.setHeader( "Accept", "application/atom+xml" );
-
- // Atom feed request
- ClientResponse res = client.get(providerURI, opts);
- Assert.assertNotNull(res);
- try {
- // Asser feed provided since no predicates
- Assert.assertEquals(200, res.getStatus());
- Assert.assertEquals(ResponseType.SUCCESS, res.getType());
- // AtomTestCaseUtils.printResponseHeaders( "Feed response headers:", " ", res );
- // System.out.println("Feed response content:");
- // AtomTestCaseUtils.prettyPrint(abdera, res.getDocument());
-
- // Perform other tests on feed.
- Document<Feed> doc = res.getDocument();
- Assert.assertNotNull( doc );
- Feed feed = doc.getRoot();
- Assert.assertNotNull( feed );
- // RFC 4287 requires non-null id, title, updated elements
- Assert.assertNotNull( feed.getId() );
- Assert.assertNotNull( feed.getTitle() );
- Assert.assertNotNull( feed.getUpdated() );
- // AtomTestCaseUtils.printFeed( "Feed values", " ", feed );
- } finally {
- res.release();
- }
- }
-
- @Test
- public void testJSONFeedGet() throws Exception {
- System.out.println(">>>ContentNegotiationTest.testJSONFeedGet");
- RequestOptions opts = new RequestOptions();
- opts.setHeader( "Accept", "application/json" );
-
- // JSON feed request
- ClientResponse res = client.get(providerURI, opts);
- Assert.assertNotNull(res);
- try {
- // Assert feed provided since no predicates
- Assert.assertEquals(200, res.getStatus());
- // Abdera 0.4 throws exception on getContentType with application/json.
- // System.out.println( "ContentNegotiationTest.testJSONEntryGet contentType=" + res.getContentType());
- String contentType = res.getHeader( "Content-Type");
- Assert.assertTrue( -1 < contentType.indexOf( "application/json" ));
- // Following is a poor man's JSONObject test to avoid dependency on JSON libs.
- // JSONObject jsonResp = new JSONObject(res.);
- // Assert.assertEquals(12345, jsonResp.getInt("result"));
- String responseBody = readResponse( res.getReader() );
- Assert.assertTrue( responseBody.startsWith( "{") );
- Assert.assertTrue( responseBody.endsWith( "}") );
- Assert.assertTrue( -1 < responseBody.indexOf( "\"id\"" ));
- Assert.assertTrue( -1 < responseBody.indexOf( "\"title\"" ));
- Assert.assertTrue( -1 < responseBody.indexOf( "\"updated\"" ));
- Assert.assertTrue( -1 < responseBody.indexOf( "\"entries\"" ));
- // AtomTestCaseUtils.printResponseHeaders( "JSON Entry response headers:", " ", res );
- // System.out.println( "ContentNegotiationTest.testJSONEntryGet JSON entry body=" + responseBody );
- } finally {
- res.release();
- }
- }
-
- protected String readResponse( Reader responseReader ) {
- if ( responseReader == null ) return "";
- StringBuffer sb = new StringBuffer(1024);
- try {
- int charValue = 0;
- while ((charValue = responseReader.read()) != -1) {
- //result = result + (char) charValue;
- sb.append((char)charValue);
- }
- } catch ( IOException e ) {
- }
- return sb.toString();
- }
+ public void testPost() throws Exception {
+ System.out.println(">>>ContentNegotiationTest.testPost");
+ // Testing of entry creation
+ Factory factory = abdera.getFactory();
+ String customerName = "Fred Farkle";
+ Entry entry = factory.newEntry();
+ entry.setTitle("customer " + customerName);
+ entry.setUpdated(new Date());
+ entry.addAuthor("Apache Tuscany");
+ // ID created by collection.
+ Content content = abdera.getFactory().newContent();
+ content.setContentType(Content.Type.TEXT);
+ content.setValue(customerName);
+ entry.setContentElement(content);
+
+ RequestOptions opts = new RequestOptions();
+ final String contentType = "application/atom+xml; type=entry";
+ opts.setContentType(contentType);
+ // AtomTestCaseUtils.printRequestHeaders( "Post request headers", " ",
+ // opts );
+ IRI colUri = new IRI(providerURI).resolve("customer");
+ // res = client.post(colUri.toString() + "?test=foo", entry, opts);
+ ClientResponse res = client.post(colUri.toString(), entry, opts);
+
+ // Assert response status code is 201-OK.
+ // Assert response header Content-Type: application/atom+xml;
+ // charset=UTF-8
+ Assert.assertEquals(201, res.getStatus());
+ String returnedContentType = res.getContentType().toString().trim();
+ Assert.assertEquals(contentType, returnedContentType);
+
+ String eTag = res.getHeader("ETag");
+ if (eTag != null)
+ lastId = eTag.substring(1, eTag.length() - 1);
+
+ // AtomTestCaseUtils.printResponseHeaders(
+ // "Entry post response headers:", " ", res );
+ // System.out.println("Entry post response content:");
+ // AtomTestCaseUtils.prettyPrint(abdera, res.getDocument());
+ }
+
+ @Test
+ public void testXMLEntryGet() throws Exception {
+ System.out.println(">>>ContentNegotiationTest.testXMLEntryGet");
+ RequestOptions opts = new RequestOptions();
+ opts.setHeader("Accept", "application/atom+xml");
+
+ IRI colUri = new IRI(providerURI).resolve("customer");
+ ClientResponse res = client.get(colUri.toString() + "/" + lastId, opts);
+ Assert.assertEquals(200, res.getStatus());
+ String returnedContentType = res.getContentType().toString().trim();
+ // Assert.assertEquals(contentType, returnedContentType );
+ res.release();
+ }
+
+ @Test
+ public void testJSONEntryGet() throws Exception {
+ System.out.println(">>>ContentNegotiationTest.testJSONEntryGet");
+ RequestOptions opts = new RequestOptions();
+ opts.setHeader("Accept", "application/json");
+
+ IRI colUri = new IRI(providerURI).resolve("customer");
+ ClientResponse res = client.get(colUri.toString() + "/" + lastId, opts);
+ try {
+ Assert.assertEquals(200, res.getStatus());
+ // Abdera 0.4 throws exception on getContentType with
+ // application/json.
+ // System.out.println(
+ // "ContentNegotiationTest.testJSONEntryGet contentType=" +
+ // res.getContentType());
+ String contentType = res.getHeader("Content-Type");
+ Assert.assertTrue(-1 < contentType.indexOf("application/json"));
+ // Following is a poor man's JSONObject test to avoid dependency on
+ // JSON libs.
+ // JSONObject jsonResp = new JSONObject(res.);
+ // Assert.assertEquals(12345, jsonResp.getInt("result"));
+ String responseBody = readResponse(res.getReader());
+ Assert.assertTrue(responseBody.startsWith("{"));
+ Assert.assertTrue(responseBody.endsWith("}"));
+ Assert.assertTrue(-1 < responseBody.indexOf("\"id\""));
+ Assert.assertTrue(-1 < responseBody.indexOf("\"title\""));
+ Assert.assertTrue(-1 < responseBody.indexOf("\"updated\""));
+ // AtomTestCaseUtils.printResponseHeaders(
+ // "JSON Entry response headers:", " ", res );
+ // System.out.println(
+ // "ContentNegotiationTest.testJSONEntryGet JSON entry body=" +
+ // responseBody );
+ } finally {
+ res.release();
+ }
+ }
+
+ @Test
+ public void testXMLFeedGet() throws Exception {
+ System.out.println(">>>ContentNegotiationTest.testXMLFeedGet");
+ RequestOptions opts = new RequestOptions();
+ opts.setHeader("Accept", "application/atom+xml");
+
+ // Atom feed request
+ ClientResponse res = client.get(providerURI, opts);
+ Assert.assertNotNull(res);
+ try {
+ // Asser feed provided since no predicates
+ Assert.assertEquals(200, res.getStatus());
+ Assert.assertEquals(ResponseType.SUCCESS, res.getType());
+ // AtomTestCaseUtils.printResponseHeaders( "Feed response headers:",
+ // " ", res );
+ // System.out.println("Feed response content:");
+ // AtomTestCaseUtils.prettyPrint(abdera, res.getDocument());
+
+ // Perform other tests on feed.
+ Document<Feed> doc = res.getDocument();
+ Assert.assertNotNull(doc);
+ Feed feed = doc.getRoot();
+ Assert.assertNotNull(feed);
+ // RFC 4287 requires non-null id, title, updated elements
+ Assert.assertNotNull(feed.getId());
+ Assert.assertNotNull(feed.getTitle());
+ Assert.assertNotNull(feed.getUpdated());
+ // AtomTestCaseUtils.printFeed( "Feed values", " ", feed );
+ } finally {
+ res.release();
+ }
+ }
+
+ @Test
+ public void testJSONFeedGet() throws Exception {
+ System.out.println(">>>ContentNegotiationTest.testJSONFeedGet");
+ RequestOptions opts = new RequestOptions();
+ opts.setHeader("Accept", "application/json");
+
+ // JSON feed request
+ ClientResponse res = client.get(providerURI, opts);
+ Assert.assertNotNull(res);
+ try {
+ // Assert feed provided since no predicates
+ Assert.assertEquals(200, res.getStatus());
+ // Abdera 0.4 throws exception on getContentType with
+ // application/json.
+ // System.out.println(
+ // "ContentNegotiationTest.testJSONEntryGet contentType=" +
+ // res.getContentType());
+ String contentType = res.getHeader("Content-Type");
+ Assert.assertTrue(-1 < contentType.indexOf("application/json"));
+ // Following is a poor man's JSONObject test to avoid dependency on
+ // JSON libs.
+ // JSONObject jsonResp = new JSONObject(res.);
+ // Assert.assertEquals(12345, jsonResp.getInt("result"));
+ String responseBody = readResponse(res.getReader());
+ Assert.assertTrue(responseBody.startsWith("{"));
+ Assert.assertTrue(responseBody.endsWith("}"));
+ Assert.assertTrue(-1 < responseBody.indexOf("\"id\""));
+ Assert.assertTrue(-1 < responseBody.indexOf("\"title\""));
+ Assert.assertTrue(-1 < responseBody.indexOf("\"updated\""));
+ Assert.assertTrue(-1 < responseBody.indexOf("\"entries\""));
+ // AtomTestCaseUtils.printResponseHeaders(
+ // "JSON Entry response headers:", " ", res );
+ // System.out.println(
+ // "ContentNegotiationTest.testJSONEntryGet JSON entry body=" +
+ // responseBody );
+ } finally {
+ res.release();
+ }
+ }
+
+ protected String readResponse(Reader responseReader) {
+ if (responseReader == null)
+ return "";
+ StringBuffer sb = new StringBuffer(1024);
+ try {
+ int charValue = 0;
+ while ((charValue = responseReader.read()) != -1) {
+ // result = result + (char) charValue;
+ sb.append((char)charValue);
+ }
+ } catch (IOException e) {
+ }
+ return sb.toString();
+ }
}
diff --git a/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/Provider.java b/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/Provider.java index 3e1bf543e5..a881f2dd0a 100644 --- a/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/Provider.java +++ b/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/Provider.java @@ -21,13 +21,19 @@ package org.apache.tuscany.sca.binding.atom; import java.io.IOException; -import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; public class Provider { public static void main(String[] args) { - SCADomain scaDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/atom/Provider.composite"); + String contribution = ContributionLocationHelper.getContributionLocation(AtomDeleteTestCase.class); + Node node = NodeFactory.newInstance().createNode( + "org/apache/tuscany/sca/binding/atom/Provider.composite", new Contribution("provider", contribution)); + node.start(); System.out.println("Provider.composite ready..."); try { @@ -36,6 +42,7 @@ public class Provider { e.printStackTrace(); } - scaDomain.close(); + node.stop(); + node.destroy(); } } diff --git a/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderEntryEntityTagsTest.java b/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderEntryEntityTagsTest.java index fbdf9a05f7..bda697bcca 100644 --- a/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderEntryEntityTagsTest.java +++ b/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderEntryEntityTagsTest.java @@ -22,415 +22,456 @@ import java.text.SimpleDateFormat; import java.util.Date; import junit.framework.Assert; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -import org.apache.tuscany.sca.binding.atom.collection.Collection; -import org.apache.tuscany.sca.host.embedded.SCADomain; import org.apache.abdera.Abdera; -import org.apache.abdera.i18n.iri.IRI; import org.apache.abdera.factory.Factory; -import org.apache.abdera.model.Base; +import org.apache.abdera.i18n.iri.IRI; import org.apache.abdera.model.Content; import org.apache.abdera.model.Entry; -import org.apache.abdera.model.Feed; -import org.apache.abdera.model.Document; -import org.apache.abdera.model.Service; -import org.apache.abdera.protocol.Response.ResponseType; +import org.apache.abdera.parser.Parser; import org.apache.abdera.protocol.client.AbderaClient; import org.apache.abdera.protocol.client.ClientResponse; import org.apache.abdera.protocol.client.RequestOptions; import org.apache.abdera.protocol.client.util.BaseRequestEntity; -import org.apache.abdera.util.EntityTag; -import org.apache.abdera.parser.Parser; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; /** * Tests use of server provided entry entity tags for Atom binding in Tuscany. - * Tests conditional gets (e.g. get if-none-match) or conditional posts (post if-match) - * using entity tags or last modified header entries. - * Uses the SCA provided Provider composite to act as a server. - * Uses the Abdera provided Client to act as a client. + * Tests conditional gets (e.g. get if-none-match) or conditional posts (post + * if-match) using entity tags or last modified header entries. Uses the SCA + * provided Provider composite to act as a server. Uses the Abdera provided + * Client to act as a client. */ public class ProviderEntryEntityTagsTest { - public final static String providerURI = "http://localhost:8084/customer"; - protected static SCADomain scaConsumerDomain; - protected static SCADomain scaProviderDomain; - protected static CustomerClient testService; + public final static String providerURI = "http://localhost:8084/customer"; + protected static Node providerNode; protected static Abdera abdera; protected static AbderaClient client; - protected static Parser abderaParser; + protected static Parser abderaParser; protected static String eTag; protected static Date lastModified; - protected static final SimpleDateFormat dateFormat = new SimpleDateFormat( "EEE, dd MMM yyyy HH:mm:ss Z" ); // RFC 822 date time - - @BeforeClass - public static void init() throws Exception { - System.out.println(">>>ProviderEntryEntityTagsTest.init"); - scaProviderDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/atom/Provider.composite"); - abdera = new Abdera(); - client = new AbderaClient(abdera); - abderaParser = Abdera.getNewParser(); - } - - @AfterClass - public static void destroy() throws Exception { - System.out.println(">>>ProviderEntryEntityTagsTest.destroy"); - scaProviderDomain.close(); - } - - @Test - public void testPrelim() throws Exception { - Assert.assertNotNull(scaProviderDomain); - Assert.assertNotNull( client ); - } - + protected static final SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z"); // RFC + // 822 + // date + // time + + @BeforeClass + public static void init() throws Exception { + System.out.println(">>>ProviderEntryEntityTagsTest.init"); + String contribution = ContributionLocationHelper.getContributionLocation(AtomDeleteTestCase.class); + providerNode = NodeFactory.newInstance().createNode( + "org/apache/tuscany/sca/binding/atom/Provider.composite", new Contribution("provider", contribution)); + providerNode.start(); + abdera = new Abdera(); + client = new AbderaClient(abdera); + abderaParser = Abdera.getNewParser(); + } + + @AfterClass + public static void destroy() throws Exception { + System.out.println(">>>ProviderEntryEntityTagsTest.destroy"); + providerNode.stop(); + providerNode.destroy(); + } + @Test - public void testEmptyCachePost() throws Exception { - // Pseudo-code - // 1) Example HTTP POST request (new entry put, new etag response) - // User client post request - // POST /myblog/entries HTTP/1.1 - // Slug: First Post - // - // <?xml version="1.0" ?> - // <entry xmlns="http://www.w3.org/2005/Atom"> - // <title>Atom-Powered Robots Run Amok</title> - // <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id> - // <updated>2007-02-123T17:09:02Z</updated> - // <author><name>Captain Lansing</name></author> - // <content>It's something moving... solid metal</content> - // </entry> - - // Expected Atom server response (note unique ETag) - // HTTP/1.1 201 Created - // Date: Fri, 23 Feb 2007 21:17:11 GMT - // Content-Length: nnn - // Content-Type: application/atom+xml;type=entry - // Location: http://example.org/edit/first-post.atom - // Content-Location: http://example.org/edit/first-post.atom - // ETag: "e180ee84f0671b1" - // Last-Modified: Fri, 25 Jul 2008 14:36:44 -0500 - // - // <?xml version="1.0" ?> - // <entry xmlns="http://www.w3.org/2005/Atom"> - // <title>Atom-Powered Robots Run Amok</title> - // <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id> - // <updated>2007-02-123T17:09:02Z</updated> - // <author><name>Captain Lansing</name></author> - // <content>It's something moving... solid metal</content> - // </entry> - - // Testing of entry creation - Factory factory = abdera.getFactory(); - String customerName = "Fred Farkle"; - Entry entry = factory.newEntry(); - entry.setTitle("customer " + customerName); - entry.setUpdated(new Date()); - entry.addAuthor("Apache Tuscany"); - // ID created by collection. + public void testPrelim() throws Exception { + Assert.assertNotNull(providerNode); + Assert.assertNotNull(client); + } + + @Test + public void testEmptyCachePost() throws Exception { + // Pseudo-code + // 1) Example HTTP POST request (new entry put, new etag response) + // User client post request + // POST /myblog/entries HTTP/1.1 + // Slug: First Post + // + // <?xml version="1.0" ?> + // <entry xmlns="http://www.w3.org/2005/Atom"> + // <title>Atom-Powered Robots Run Amok</title> + // <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id> + // <updated>2007-02-123T17:09:02Z</updated> + // <author><name>Captain Lansing</name></author> + // <content>It's something moving... solid metal</content> + // </entry> + + // Expected Atom server response (note unique ETag) + // HTTP/1.1 201 Created + // Date: Fri, 23 Feb 2007 21:17:11 GMT + // Content-Length: nnn + // Content-Type: application/atom+xml;type=entry + // Location: http://example.org/edit/first-post.atom + // Content-Location: http://example.org/edit/first-post.atom + // ETag: "e180ee84f0671b1" + // Last-Modified: Fri, 25 Jul 2008 14:36:44 -0500 + // + // <?xml version="1.0" ?> + // <entry xmlns="http://www.w3.org/2005/Atom"> + // <title>Atom-Powered Robots Run Amok</title> + // <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id> + // <updated>2007-02-123T17:09:02Z</updated> + // <author><name>Captain Lansing</name></author> + // <content>It's something moving... solid metal</content> + // </entry> + + // Testing of entry creation + Factory factory = abdera.getFactory(); + String customerName = "Fred Farkle"; + Entry entry = factory.newEntry(); + entry.setTitle("customer " + customerName); + entry.setUpdated(new Date()); + entry.addAuthor("Apache Tuscany"); + // ID created by collection. // entry.setId(id); // auto-provided // entry.addLink("" + id, "edit"); // auto-provided // entry.addLink("" + id, "alternate"); // auto-provided - Content content = abdera.getFactory().newContent(); - content.setContentType(Content.Type.TEXT); - content.setValue(customerName); - entry.setContentElement(content); - - RequestOptions opts = new RequestOptions(); - final String contentType = "application/atom+xml; type=entry"; - opts.setContentType(contentType); - // AtomTestCaseUtils.printRequestHeaders( "Post request headers", " ", opts ); - IRI colUri = new IRI(providerURI).resolve("customer"); - // res = client.post(colUri.toString() + "?test=foo", entry, opts); - ClientResponse res = client.post(colUri.toString(), entry, opts); - - // Assert response status code is 201-OK. - // Assert response header Content-Type: application/atom+xml; charset=UTF-8 - // Assert response header Location: http://example.org/edit/first-post.atom - // Assert response header Content-Location: http://example.org/edit/first-post.atom - // Assert response header ETag: "e180ee84f0671b1" - // Assert response header Last-Modified: Fri, 25 Jul 2008 14:36:44 -0500 - // Assert collection size is 1. - Assert.assertEquals(201, res.getStatus()); - Assert.assertEquals(contentType, res.getContentType().toString().trim()); - // Assert.assertNotNull( res.getLocation().toString() ); - // Assert.assertEquals( "", res.getContentLocation().toString() ); - // Save eTag for subsequent tests; - eTag = res.getHeader( "ETag" ); - Assert.assertNotNull( eTag ); - lastModified = res.getLastModified(); - Assert.assertNotNull(lastModified); - } - - @Test - public void testDirtyCachePut() throws Exception { - // 2) Conditional PUT request (post with etag. entry provided is stale) - // User client PUT request - // PUT /edit/first-post.atom HTTP/1.1 - // > If-Match: "e180ee84f0671b1" - // - // <?xml version="1.0" ?> - // <entry xmlns="http://www.w3.org/2005/Atom"> - // <title>Atom-Powered Robots Run Amok</title> - // <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id> - // <updated>2007-02-24T16:34:06Z</updated> - // <author><name>Captain Lansing</name></author> - // <content>Update: it's a hoax!</content> - // </entry> - // Testing of entry creation - Factory factory = abdera.getFactory(); - String customerName = "Molly Ringwald"; - Entry entry = factory.newEntry(); - entry.setTitle("customer " + customerName); - entry.setUpdated( new Date()); - entry.addAuthor("Apache Tuscany"); - String id = eTag.substring( 1, eTag.length()-1); + Content content = abdera.getFactory().newContent(); + content.setContentType(Content.Type.TEXT); + content.setValue(customerName); + entry.setContentElement(content); + + RequestOptions opts = new RequestOptions(); + final String contentType = "application/atom+xml; type=entry"; + opts.setContentType(contentType); + // AtomTestCaseUtils.printRequestHeaders( "Post request headers", " ", + // opts ); + IRI colUri = new IRI(providerURI).resolve("customer"); + // res = client.post(colUri.toString() + "?test=foo", entry, opts); + ClientResponse res = client.post(colUri.toString(), entry, opts); + + // Assert response status code is 201-OK. + // Assert response header Content-Type: application/atom+xml; + // charset=UTF-8 + // Assert response header Location: + // http://example.org/edit/first-post.atom + // Assert response header Content-Location: + // http://example.org/edit/first-post.atom + // Assert response header ETag: "e180ee84f0671b1" + // Assert response header Last-Modified: Fri, 25 Jul 2008 14:36:44 -0500 + // Assert collection size is 1. + Assert.assertEquals(201, res.getStatus()); + Assert.assertEquals(contentType, res.getContentType().toString().trim()); + // Assert.assertNotNull( res.getLocation().toString() ); + // Assert.assertEquals( "", res.getContentLocation().toString() ); + // Save eTag for subsequent tests; + eTag = res.getHeader("ETag"); + Assert.assertNotNull(eTag); + lastModified = res.getLastModified(); + Assert.assertNotNull(lastModified); + } + + @Test + public void testDirtyCachePut() throws Exception { + // 2) Conditional PUT request (post with etag. entry provided is stale) + // User client PUT request + // PUT /edit/first-post.atom HTTP/1.1 + // > If-Match: "e180ee84f0671b1" + // + // <?xml version="1.0" ?> + // <entry xmlns="http://www.w3.org/2005/Atom"> + // <title>Atom-Powered Robots Run Amok</title> + // <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id> + // <updated>2007-02-24T16:34:06Z</updated> + // <author><name>Captain Lansing</name></author> + // <content>Update: it's a hoax!</content> + // </entry> + // Testing of entry creation + Factory factory = abdera.getFactory(); + String customerName = "Molly Ringwald"; + Entry entry = factory.newEntry(); + entry.setTitle("customer " + customerName); + entry.setUpdated(new Date()); + entry.addAuthor("Apache Tuscany"); + String id = eTag.substring(1, eTag.length() - 1); entry.setId(id); // auto-provided // entry.addLink("" + id, "edit"); // auto-provided // entry.addLink("" + id, "alternate"); // auto-provided - Content content = abdera.getFactory().newContent(); - content.setContentType(Content.Type.TEXT); - content.setValue(customerName); - entry.setContentElement(content); - - RequestOptions opts = new RequestOptions(); - final String contentType = "application/atom+xml; type=entry"; - opts.setContentType(contentType); - opts.setHeader( "If-None-Match", eTag); - - AtomTestCaseUtils.printRequestHeaders( "Put request headers", " ", opts ); - IRI colUri = new IRI(providerURI).resolve("customer"); - // res = client.post(colUri.toString() + "?test=foo", entry, opts); - id = eTag.substring( 1, eTag.length()-1); - // Warning. AbderaClient.put(String uri,Base base,RequestOptions options) caches on the client side. - // ClientResponse res = client.put(colUri.toString() + id, entry, opts); - ClientResponse res = client.put(colUri.toString() + "/" + id, new BaseRequestEntity( entry ), opts); - // Expected Atom server response (item was edited by another user) - // > HTTP/1.1 412 Precondition Failed - // Date: Sat, 24 Feb 2007 16:34:11 GMT - - // If-Match Assert response status code is 412. Precondition failed. - // If-None-Match Assert response status code is 200. OK - Assert.assertEquals(200, res.getStatus()); - // Put provides null body and no etags. - res.release(); - } - - @Test - public void testETagMissGet() throws Exception { - // 4) Conditional GET example (get with etag. etag not in cache) - // User client GET request - // GET /edit/first-post.atom HTTP/1.1 - // > If-None-Match: "e180ee84f0671b1" - - RequestOptions opts = new RequestOptions(); - final String contentType = "application/atom+xml; type=entry"; - opts.setContentType(contentType); - opts.setHeader( "If-None-Match", "123456"); - opts.setHeader( "Pragma", "no-cache"); // turn off client caching - - IRI colUri = new IRI(providerURI).resolve("customer"); - // res = client.post(colUri.toString() + "?test=foo", entry, opts); - String id = eTag.substring( 1, eTag.length()-1); - // Warning. AbderaClient.put(String uri,Base base,RequestOptions options) caches on the client side. - // ClientResponse res = client.put(colUri.toString() + id, entry, opts); - ClientResponse res = client.get(colUri.toString() + "/" + id, opts); - // Expected Atom server response (item was edited by another user) - // > HTTP/1.1 412 Precondition Failed - // Date: Sat, 24 Feb 2007 16:34:11 GMT - - // Atom server response (item was up to date) - // > HTTP/1.1 200 OK - // Date: Sat, 24 Feb 2007 13:17:11 GMT - // > ETag: "bb4f5e86e92ddb8549604a0df0763581" - // > Last-Modified: Mon, 28 Jul 2008 10:25:37 -0500 - - // Assert response status code is 200 OK. - // Assert header Content-Type: application/atom+xml;type=entry - // Assert header Location: http://example.org/edit/first-post.atom - // Assert header Content-Location: http://example.org/edit/first-post.atom - // Assert header ETag: "555555" (etag response != etag request) - // Assert header Last-Modified: Fri, 25 Jul 2008 14:36:44 -0500 - Assert.assertEquals(200, res.getStatus()); - Assert.assertEquals(contentType, res.getContentType().toString().trim()); - // Assert.assertNotNull( res.getLocation().toString() ); - // Assert.assertEquals( "", res.getContentLocation().toString() ); - Assert.assertNotNull( res.getHeader( "ETag" ) ); - lastModified = res.getLastModified(); - Assert.assertNotNull(lastModified); - res.release(); - } - - @Test - public void testETagHitGet() throws Exception { - // 3) Conditional GET example (get with etag. etag match) - // User client GET request - // GET /edit/first-post.atom HTTP/1.1 - // > If-None-Match: "e180ee84f0671b1" - - RequestOptions opts = new RequestOptions(); - final String contentType = "application/atom+xml; type=entry"; - opts.setContentType(contentType); - opts.setHeader( "If-None-Match", eTag); - opts.setHeader( "Pragma", "no-cache"); // turn off client caching - - IRI colUri = new IRI(providerURI).resolve("customer"); - // res = client.post(colUri.toString() + "?test=foo", entry, opts); - String id = eTag.substring( 1, eTag.length()-1); - // Warning. AbderaClient.put(String uri,Base base,RequestOptions options) caches on the client side. - // ClientResponse res = client.put(colUri.toString() + id, entry, opts); - ClientResponse res = client.get(colUri.toString() + "/" + id, opts); - // Atom server response (item was up to date) - // > HTTP/1.1 304 Not Modified - // Date: Sat, 24 Feb 2007 13:17:11 GMT - - // Assert response status code is 304 Not Modified. - // Assert header ETag: "e180ee84f0671b1" - // Assert header Last-Modified: Fri, 25 Jul 2008 14:36:44 -0500 - // Assert.assertEquals(304, res.getStatus()); - res.release(); - } - - - @Test - public void testUpToDateGet() throws Exception { - // 3) Conditional GET example (get with If-Mod. entry is up to date) - // User client GET request - // GET /edit/first-post.atom HTTP/1.1 - // > If-Modified-Since: Sat, 29 Oct 2025 19:43:31 GMT - RequestOptions opts = new RequestOptions(); - final String contentType = "application/atom+xml; type=entry"; - opts.setContentType(contentType); - opts.setHeader( "If-Modified-Since", "Sat, 29 Oct 2025 19:43:31 GMT"); // "EEE, dd MMM yyyy HH:mm:ss Z // RFC 822 Date - opts.setHeader( "Pragma", "no-cache"); // turn off client caching - - IRI colUri = new IRI(providerURI).resolve("customer"); - // res = client.post(colUri.toString() + "?test=foo", entry, opts); - String id = eTag.substring( 1, eTag.length()-1); - // Warning. AbderaClient.put(String uri,Base base,RequestOptions options) caches on the client side. - // ClientResponse res = client.put(colUri.toString() + id, entry, opts); - // Warning. AbderaClient.put(String uri,Base base,RequestOptions options) caches on the client side. - // ClientResponse res = client.get(colUri.toString() + "/" + id, opts); - ClientResponse res = client.execute( "GET", colUri.toString(), (BaseRequestEntity)null, opts); - - // Atom server response (item was up to date) - // > HTTP/1.1 304 Not Modified - // Date: Sat, 24 Feb 2007 13:17:11 GMT - - // Assert response status code is 304 Not Modified. - Assert.assertEquals(304, res.getStatus()); - res.release(); - } - - @Test - public void testOutOfDateGet() throws Exception { - // 4) Conditional GET example (get with If-Mod. entry is not to date) - // User client GET request - // GET /edit/first-post.atom HTTP/1.1 - // > If-Modified-Since: Sat, 29 Oct 1844 19:43:31 GMT - RequestOptions opts = new RequestOptions(); - final String contentType = "application/atom+xml; type=entry"; - opts.setContentType(contentType); - opts.setHeader( "If-Modified-Since", "Sat, 29 Oct 1844 19:43:31 GMT"); // "EEE, dd MMM yyyy HH:mm:ss Z // RFC 822 Date - opts.setHeader( "Pragma", "no-cache"); // turn off client caching - - IRI colUri = new IRI(providerURI).resolve("customer"); - // res = client.post(colUri.toString() + "?test=foo", entry, opts); - String id = eTag.substring( 1, eTag.length()-1); - // Warning. AbderaClient.put(String uri,Base base,RequestOptions options) caches on the client side. - // ClientResponse res = client.put(colUri.toString() + id, entry, opts); - ClientResponse res = client.get(colUri.toString() + "/" + id, opts); - - // Atom server response (item was up to date) - // > HTTP/1.1 200 OK - // Date: Sat, 24 Feb 2007 13:17:11 GMT - // > ETag: "bb4f5e86e92ddb8549604a0df0763581" - // > Last-Modified: Mon, 28 Jul 2008 10:25:37 -0500 - - // Assert response status code is 200 OK. - // Assert header ETag: "e180ee84f0671b1" - // Assert header Last-Modified: Greater than If-Mod - Assert.assertEquals(200, res.getStatus()); - Assert.assertEquals(contentType, res.getContentType().toString().trim()); - // Assert.assertNotNull( res.getLocation().toString() ); - // Assert.assertEquals( "", res.getContentLocation().toString() ); - Assert.assertNotNull( res.getHeader( "ETag" ) ); - lastModified = res.getLastModified(); - Assert.assertNotNull(lastModified); - res.release(); - } - - @Test - public void testUpToDateUnModGet() throws Exception { - // 3) Conditional GET example (get with If-Unmod. entry is up to date) - // User client GET request - // GET /edit/first-post.atom HTTP/1.1 - // > If-Unmodified-Since: Sat, 29 Oct 2025 19:43:31 GMT - RequestOptions opts = new RequestOptions(); - final String contentType = "application/atom+xml; type=entry"; - opts.setContentType(contentType); - opts.setHeader( "If-Unmodified-Since", "Sat, 29 Oct 2050 19:43:31 GMT" ); - opts.setHeader( "Pragma", "no-cache"); // turn off client caching - - IRI colUri = new IRI(providerURI).resolve("customer"); - // res = client.post(colUri.toString() + "?test=foo", entry, opts); - String id = eTag.substring( 1, eTag.length()-1); - // Warning. AbderaClient.put(String uri,Base base,RequestOptions options) caches on the client side. - // ClientResponse res = client.put(colUri.toString() + id, entry, opts); - ClientResponse res = client.get(colUri.toString() + "/" + id, opts); - - // Atom server response (item was up to date) - // > HTTP/1.1 304 Not Modified - // Date: Sat, 24 Feb 2007 13:17:11 GMT - - // Assert response status code is 304 Not Modified. - // Assert.assertEquals(304, res.getStatus()); - // TODO Update when If-Unmodified-Since enabled. - Assert.assertEquals(200, res.getStatus()); - res.release(); - } - - @Test - public void testOutOfDateUnModGet() throws Exception { - // 4) Conditional GET example (get with If-Unmod. entry is not to date) - // User client GET request - // GET /edit/first-post.atom HTTP/1.1 - // Host: example.org - // > If-Unmodified-Since: Sat, 29 Oct 1844 19:43:31 GMT - RequestOptions opts = new RequestOptions(); - final String contentType = "application/atom+xml; type=entry"; - opts.setContentType(contentType); - opts.setHeader( "If-Unmodified-Since", "Sat, 29 Oct 1844 19:43:31 GMT" ); - opts.setHeader( "Pragma", "no-cache"); // turn off client caching - - IRI colUri = new IRI(providerURI).resolve("customer"); - // res = client.post(colUri.toString() + "?test=foo", entry, opts); - String id = eTag.substring( 1, eTag.length()-1); - // Warning. AbderaClient.put(String uri,Base base,RequestOptions options) caches on the client side. - // ClientResponse res = client.put(colUri.toString() + id, entry, opts); - ClientResponse res = client.get(colUri.toString() + "/" + id, opts); - - // Atom server response (item was up to date) - // > HTTP/1.1 200 OK - // Date: Sat, 24 Feb 2007 13:17:11 GMT - // > ETag: "bb4f5e86e92ddb8549604a0df0763581" - // > Last-Modified: Mon, 28 Jul 2008 10:25:37 -0500 - - // Assert response status code is 200 OK. - // Assert header Content-Type: application/atom+xml;type=entry - // Assert header Location: http://example.org/edit/first-post.atom - // Assert header Content-Location: http://example.org/edit/first-post.atom - // Assert header ETag: "e180ee84f0671b1" - // Assert header Last-Modified: Less than If-Unmod - Assert.assertEquals(200, res.getStatus()); - Assert.assertEquals(contentType, res.getContentType().toString().trim()); - // Assert.assertNotNull( res.getLocation().toString() ); - // Assert.assertEquals( "", res.getContentLocation().toString() ); - Assert.assertNotNull( res.getHeader( "ETag" ) ); - lastModified = res.getLastModified(); - Assert.assertNotNull(lastModified); - res.release(); - } + Content content = abdera.getFactory().newContent(); + content.setContentType(Content.Type.TEXT); + content.setValue(customerName); + entry.setContentElement(content); + + RequestOptions opts = new RequestOptions(); + final String contentType = "application/atom+xml; type=entry"; + opts.setContentType(contentType); + opts.setHeader("If-None-Match", eTag); + + AtomTestCaseUtils.printRequestHeaders("Put request headers", " ", opts); + IRI colUri = new IRI(providerURI).resolve("customer"); + // res = client.post(colUri.toString() + "?test=foo", entry, opts); + id = eTag.substring(1, eTag.length() - 1); + // Warning. AbderaClient.put(String uri,Base base,RequestOptions + // options) caches on the client side. + // ClientResponse res = client.put(colUri.toString() + id, entry, opts); + ClientResponse res = client.put(colUri.toString() + "/" + id, new BaseRequestEntity(entry), opts); + // Expected Atom server response (item was edited by another user) + // > HTTP/1.1 412 Precondition Failed + // Date: Sat, 24 Feb 2007 16:34:11 GMT + + // If-Match Assert response status code is 412. Precondition failed. + // If-None-Match Assert response status code is 200. OK + Assert.assertEquals(200, res.getStatus()); + // Put provides null body and no etags. + res.release(); + } + + @Test + public void testETagMissGet() throws Exception { + // 4) Conditional GET example (get with etag. etag not in cache) + // User client GET request + // GET /edit/first-post.atom HTTP/1.1 + // > If-None-Match: "e180ee84f0671b1" + + RequestOptions opts = new RequestOptions(); + final String contentType = "application/atom+xml; type=entry"; + opts.setContentType(contentType); + opts.setHeader("If-None-Match", "123456"); + opts.setHeader("Pragma", "no-cache"); // turn off client caching + + IRI colUri = new IRI(providerURI).resolve("customer"); + // res = client.post(colUri.toString() + "?test=foo", entry, opts); + String id = eTag.substring(1, eTag.length() - 1); + // Warning. AbderaClient.put(String uri,Base base,RequestOptions + // options) caches on the client side. + // ClientResponse res = client.put(colUri.toString() + id, entry, opts); + ClientResponse res = client.get(colUri.toString() + "/" + id, opts); + // Expected Atom server response (item was edited by another user) + // > HTTP/1.1 412 Precondition Failed + // Date: Sat, 24 Feb 2007 16:34:11 GMT + + // Atom server response (item was up to date) + // > HTTP/1.1 200 OK + // Date: Sat, 24 Feb 2007 13:17:11 GMT + // > ETag: "bb4f5e86e92ddb8549604a0df0763581" + // > Last-Modified: Mon, 28 Jul 2008 10:25:37 -0500 + + // Assert response status code is 200 OK. + // Assert header Content-Type: application/atom+xml;type=entry + // Assert header Location: http://example.org/edit/first-post.atom + // Assert header Content-Location: + // http://example.org/edit/first-post.atom + // Assert header ETag: "555555" (etag response != etag request) + // Assert header Last-Modified: Fri, 25 Jul 2008 14:36:44 -0500 + Assert.assertEquals(200, res.getStatus()); + Assert.assertEquals(contentType, res.getContentType().toString().trim()); + // Assert.assertNotNull( res.getLocation().toString() ); + // Assert.assertEquals( "", res.getContentLocation().toString() ); + Assert.assertNotNull(res.getHeader("ETag")); + lastModified = res.getLastModified(); + Assert.assertNotNull(lastModified); + res.release(); + } + + @Test + public void testETagHitGet() throws Exception { + // 3) Conditional GET example (get with etag. etag match) + // User client GET request + // GET /edit/first-post.atom HTTP/1.1 + // > If-None-Match: "e180ee84f0671b1" + + RequestOptions opts = new RequestOptions(); + final String contentType = "application/atom+xml; type=entry"; + opts.setContentType(contentType); + opts.setHeader("If-None-Match", eTag); + opts.setHeader("Pragma", "no-cache"); // turn off client caching + + IRI colUri = new IRI(providerURI).resolve("customer"); + // res = client.post(colUri.toString() + "?test=foo", entry, opts); + String id = eTag.substring(1, eTag.length() - 1); + // Warning. AbderaClient.put(String uri,Base base,RequestOptions + // options) caches on the client side. + // ClientResponse res = client.put(colUri.toString() + id, entry, opts); + ClientResponse res = client.get(colUri.toString() + "/" + id, opts); + // Atom server response (item was up to date) + // > HTTP/1.1 304 Not Modified + // Date: Sat, 24 Feb 2007 13:17:11 GMT + + // Assert response status code is 304 Not Modified. + // Assert header ETag: "e180ee84f0671b1" + // Assert header Last-Modified: Fri, 25 Jul 2008 14:36:44 -0500 + // Assert.assertEquals(304, res.getStatus()); + res.release(); + } + + @Test + public void testUpToDateGet() throws Exception { + // 3) Conditional GET example (get with If-Mod. entry is up to date) + // User client GET request + // GET /edit/first-post.atom HTTP/1.1 + // > If-Modified-Since: Sat, 29 Oct 2025 19:43:31 GMT + RequestOptions opts = new RequestOptions(); + final String contentType = "application/atom+xml; type=entry"; + opts.setContentType(contentType); + opts.setHeader("If-Modified-Since", "Sat, 29 Oct 2025 19:43:31 GMT"); // "EEE, + // dd + // MMM + // yyyy + // HH + // : + // mm + // : + // ss + // Z + // / + // / + // RFC + // 822 + // Date + opts.setHeader("Pragma", "no-cache"); // turn off client caching + + IRI colUri = new IRI(providerURI).resolve("customer"); + // res = client.post(colUri.toString() + "?test=foo", entry, opts); + String id = eTag.substring(1, eTag.length() - 1); + // Warning. AbderaClient.put(String uri,Base base,RequestOptions + // options) caches on the client side. + // ClientResponse res = client.put(colUri.toString() + id, entry, opts); + // Warning. AbderaClient.put(String uri,Base base,RequestOptions + // options) caches on the client side. + // ClientResponse res = client.get(colUri.toString() + "/" + id, opts); + ClientResponse res = client.execute("GET", colUri.toString(), (BaseRequestEntity)null, opts); + + // Atom server response (item was up to date) + // > HTTP/1.1 304 Not Modified + // Date: Sat, 24 Feb 2007 13:17:11 GMT + + // Assert response status code is 304 Not Modified. + Assert.assertEquals(304, res.getStatus()); + res.release(); + } + + @Test + public void testOutOfDateGet() throws Exception { + // 4) Conditional GET example (get with If-Mod. entry is not to date) + // User client GET request + // GET /edit/first-post.atom HTTP/1.1 + // > If-Modified-Since: Sat, 29 Oct 1844 19:43:31 GMT + RequestOptions opts = new RequestOptions(); + final String contentType = "application/atom+xml; type=entry"; + opts.setContentType(contentType); + opts.setHeader("If-Modified-Since", "Sat, 29 Oct 1844 19:43:31 GMT"); // "EEE, + // dd + // MMM + // yyyy + // HH + // : + // mm + // : + // ss + // Z + // / + // / + // RFC + // 822 + // Date + opts.setHeader("Pragma", "no-cache"); // turn off client caching + + IRI colUri = new IRI(providerURI).resolve("customer"); + // res = client.post(colUri.toString() + "?test=foo", entry, opts); + String id = eTag.substring(1, eTag.length() - 1); + // Warning. AbderaClient.put(String uri,Base base,RequestOptions + // options) caches on the client side. + // ClientResponse res = client.put(colUri.toString() + id, entry, opts); + ClientResponse res = client.get(colUri.toString() + "/" + id, opts); + + // Atom server response (item was up to date) + // > HTTP/1.1 200 OK + // Date: Sat, 24 Feb 2007 13:17:11 GMT + // > ETag: "bb4f5e86e92ddb8549604a0df0763581" + // > Last-Modified: Mon, 28 Jul 2008 10:25:37 -0500 + + // Assert response status code is 200 OK. + // Assert header ETag: "e180ee84f0671b1" + // Assert header Last-Modified: Greater than If-Mod + Assert.assertEquals(200, res.getStatus()); + Assert.assertEquals(contentType, res.getContentType().toString().trim()); + // Assert.assertNotNull( res.getLocation().toString() ); + // Assert.assertEquals( "", res.getContentLocation().toString() ); + Assert.assertNotNull(res.getHeader("ETag")); + lastModified = res.getLastModified(); + Assert.assertNotNull(lastModified); + res.release(); + } + + @Test + public void testUpToDateUnModGet() throws Exception { + // 3) Conditional GET example (get with If-Unmod. entry is up to date) + // User client GET request + // GET /edit/first-post.atom HTTP/1.1 + // > If-Unmodified-Since: Sat, 29 Oct 2025 19:43:31 GMT + RequestOptions opts = new RequestOptions(); + final String contentType = "application/atom+xml; type=entry"; + opts.setContentType(contentType); + opts.setHeader("If-Unmodified-Since", "Sat, 29 Oct 2050 19:43:31 GMT"); + opts.setHeader("Pragma", "no-cache"); // turn off client caching + + IRI colUri = new IRI(providerURI).resolve("customer"); + // res = client.post(colUri.toString() + "?test=foo", entry, opts); + String id = eTag.substring(1, eTag.length() - 1); + // Warning. AbderaClient.put(String uri,Base base,RequestOptions + // options) caches on the client side. + // ClientResponse res = client.put(colUri.toString() + id, entry, opts); + ClientResponse res = client.get(colUri.toString() + "/" + id, opts); + + // Atom server response (item was up to date) + // > HTTP/1.1 304 Not Modified + // Date: Sat, 24 Feb 2007 13:17:11 GMT + + // Assert response status code is 304 Not Modified. + // Assert.assertEquals(304, res.getStatus()); + // TODO Update when If-Unmodified-Since enabled. + Assert.assertEquals(200, res.getStatus()); + res.release(); + } + + @Test + public void testOutOfDateUnModGet() throws Exception { + // 4) Conditional GET example (get with If-Unmod. entry is not to date) + // User client GET request + // GET /edit/first-post.atom HTTP/1.1 + // Host: example.org + // > If-Unmodified-Since: Sat, 29 Oct 1844 19:43:31 GMT + RequestOptions opts = new RequestOptions(); + final String contentType = "application/atom+xml; type=entry"; + opts.setContentType(contentType); + opts.setHeader("If-Unmodified-Since", "Sat, 29 Oct 1844 19:43:31 GMT"); + opts.setHeader("Pragma", "no-cache"); // turn off client caching + + IRI colUri = new IRI(providerURI).resolve("customer"); + // res = client.post(colUri.toString() + "?test=foo", entry, opts); + String id = eTag.substring(1, eTag.length() - 1); + // Warning. AbderaClient.put(String uri,Base base,RequestOptions + // options) caches on the client side. + // ClientResponse res = client.put(colUri.toString() + id, entry, opts); + ClientResponse res = client.get(colUri.toString() + "/" + id, opts); + + // Atom server response (item was up to date) + // > HTTP/1.1 200 OK + // Date: Sat, 24 Feb 2007 13:17:11 GMT + // > ETag: "bb4f5e86e92ddb8549604a0df0763581" + // > Last-Modified: Mon, 28 Jul 2008 10:25:37 -0500 + + // Assert response status code is 200 OK. + // Assert header Content-Type: application/atom+xml;type=entry + // Assert header Location: http://example.org/edit/first-post.atom + // Assert header Content-Location: + // http://example.org/edit/first-post.atom + // Assert header ETag: "e180ee84f0671b1" + // Assert header Last-Modified: Less than If-Unmod + Assert.assertEquals(200, res.getStatus()); + Assert.assertEquals(contentType, res.getContentType().toString().trim()); + // Assert.assertNotNull( res.getLocation().toString() ); + // Assert.assertEquals( "", res.getContentLocation().toString() ); + Assert.assertNotNull(res.getHeader("ETag")); + lastModified = res.getLastModified(); + Assert.assertNotNull(lastModified); + res.release(); + } } diff --git a/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderFeedEntityTagsTest.java b/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderFeedEntityTagsTest.java index faa7d414f5..4c6c2a04c2 100644 --- a/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderFeedEntityTagsTest.java +++ b/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderFeedEntityTagsTest.java @@ -22,335 +22,344 @@ import java.text.SimpleDateFormat; import java.util.Date; import junit.framework.Assert; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -import org.apache.tuscany.sca.host.embedded.SCADomain; import org.apache.abdera.Abdera; -import org.apache.abdera.i18n.iri.IRI; import org.apache.abdera.factory.Factory; -import org.apache.abdera.model.Base; +import org.apache.abdera.i18n.iri.IRI; +import org.apache.abdera.model.Collection; import org.apache.abdera.model.Content; +import org.apache.abdera.model.Document; import org.apache.abdera.model.Entry; import org.apache.abdera.model.Feed; -import org.apache.abdera.model.Document; -import org.apache.abdera.model.Service; -import org.apache.abdera.model.Collection; +import org.apache.abdera.parser.Parser; import org.apache.abdera.protocol.Response.ResponseType; import org.apache.abdera.protocol.client.AbderaClient; import org.apache.abdera.protocol.client.ClientResponse; import org.apache.abdera.protocol.client.RequestOptions; -import org.apache.abdera.protocol.client.util.BaseRequestEntity; -import org.apache.abdera.util.EntityTag; -import org.apache.abdera.parser.Parser; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; /** * Tests use of server provided feed entity tags for Atom binding in Tuscany. - * Tests conditional gets (e.g. get if-none-match) or conditional posts (post if-match) - * using entity tags and last modified entries in headers. - * Uses the SCA provided Provider composite to act as a server. - * Uses the Abdera provided Client to act as a client. + * Tests conditional gets (e.g. get if-none-match) or conditional posts (post + * if-match) using entity tags and last modified entries in headers. Uses the + * SCA provided Provider composite to act as a server. Uses the Abdera provided + * Client to act as a client. */ public class ProviderFeedEntityTagsTest { - public final static String providerURI = "http://localhost:8084/customer"; - protected static SCADomain scaConsumerDomain; - protected static SCADomain scaProviderDomain; - protected static CustomerClient testService; + public final static String providerURI = "http://localhost:8084/customer"; + protected static Node providerNode; protected static Abdera abdera; protected static AbderaClient client; - protected static Parser abderaParser; + protected static Parser abderaParser; protected static String eTag; protected static Date lastModified; - protected static final SimpleDateFormat dateFormat = new SimpleDateFormat( "EEE, dd MMM yyyy HH:mm:ss Z" ); // RFC 822 date time - - @BeforeClass - public static void init() throws Exception { - System.out.println(">>>ProviderFeedEntityTagsTest.init"); - scaProviderDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/atom/Provider.composite"); - abdera = new Abdera(); - client = new AbderaClient(abdera); - abderaParser = Abdera.getNewParser(); - } - - @AfterClass - public static void destroy() throws Exception { - System.out.println(">>>ProviderFeedEntityTagsTest.destroy"); - scaProviderDomain.close(); - } - - @Test - public void testPrelim() throws Exception { - Assert.assertNotNull(scaProviderDomain); - Assert.assertNotNull( client ); - } - - @Test - public void testFeedBasics() throws Exception { - System.out.println(">>>ProviderFeedEntityTagsTest.testFeedBasics"); - // Normal feed request - ClientResponse res = client.get(providerURI); - Assert.assertNotNull(res); - try { - // Asser feed provided since no predicates - Assert.assertEquals(200, res.getStatus()); - Assert.assertEquals(ResponseType.SUCCESS, res.getType()); - // AtomTestCaseUtils.printResponseHeaders( "Feed response headers:", " ", res ); - // System.out.println("Feed response content:"); - // AtomTestCaseUtils.prettyPrint(abdera, res.getDocument()); - - // Perform other tests on feed. - Document<Feed> doc = res.getDocument(); - Assert.assertNotNull( doc ); - Feed feed = doc.getRoot(); - Assert.assertNotNull( feed ); - printFeed( "Feed values", " ", feed ); - // RFC 4287 requires non-null id, title, updated elements - Assert.assertNotNull( feed.getId() ); - Assert.assertNotNull( feed.getTitle() ); - Assert.assertNotNull( feed.getUpdated() ); - - eTag = res.getHeader("ETag"); - Assert.assertNotNull( eTag ); - lastModified = res.getLastModified(); - Assert.assertNotNull( lastModified ); - } finally { - res.release(); - } - } - - @Test - public void testUnmodifiedGetIfMatch() throws Exception { - System.out.println(">>>ProviderFeedEntityTagsTest.testFeedUnmodifiedGetIfMatch"); - // Feed request with predicates - RequestOptions opts = new RequestOptions(); - final String contentType = "application/atom+xml"; - opts.setContentType(contentType); - opts.setHeader( "If-Match", eTag); - - ClientResponse res = client.get(providerURI, opts); - Assert.assertNotNull(res); - try { - String thisETag = res.getHeader("ETag"); - Assert.assertNotNull( thisETag ); - Date thisLastModified = res.getLastModified(); - Assert.assertNotNull( thisLastModified ); - - // Should return 200 - Feed provided since it matches etag. - Assert.assertEquals(200, res.getStatus()); - Assert.assertEquals(ResponseType.SUCCESS, res.getType()); - // AtomTestCaseUtils.printResponseHeaders( "Feed response headers:", " ", res ); - // System.out.println("Feed response content:"); - // AtomTestCaseUtils.prettyPrint(abdera, res.getDocument()); - } finally { - res.release(); - } - } - - @Test - public void testUnmodifiedGetIfNoneMatch() throws Exception { - System.out.println(">>>ProviderFeedEntityTagsTest.testFeedUnmodifiedGetIfNoneMatch"); - // Feed request with predicates - RequestOptions opts = new RequestOptions(); - final String contentType = "application/atom+xml"; - opts.setContentType(contentType); - opts.setHeader( "If-None-Match", eTag); - - ClientResponse res = client.get(providerURI, opts); - Assert.assertNotNull(res); - try { - // Should return 304 - Feed not provided since it matches ETag. - Assert.assertEquals(304, res.getStatus()); - } finally { - res.release(); - } - } - - @Test - public void testUnmodifiedGetIfUnModified() throws Exception { - System.out.println(">>>ProviderFeedEntityTagsTest.testFeedUnmodifiedGetIfUnModified"); - // Feed request with predicates - RequestOptions opts = new RequestOptions(); - final String contentType = "application/atom+xml"; - opts.setContentType(contentType); - opts.setHeader( "If-Unmodified-Since", dateFormat.format( new Date() )); - - ClientResponse res = client.get(providerURI, opts); - Assert.assertNotNull(res); - try { - // Should return 304 - Feed not provided since feed is modified since. - Assert.assertEquals(304, res.getStatus()); - } finally { - res.release(); - } - } - - @Test - public void testUnmodifiedGetIfModified() throws Exception { - System.out.println(">>>ProviderFeedEntityTagsTest.testFeedUnmodifiedGetIfModified"); - // Feed request with predicates - RequestOptions opts = new RequestOptions(); - final String contentType = "application/atom+xml"; - opts.setContentType(contentType); - opts.setHeader( "If-Modified-Since", dateFormat.format( new Date( 0 ) )); - - ClientResponse res = client.get(providerURI, opts); - Assert.assertNotNull(res); - try { - // Should return 200 - Feed provided since feed is changed. - Assert.assertEquals(200, res.getStatus()); - Assert.assertEquals(ResponseType.SUCCESS, res.getType()); - - String thisETag = res.getHeader("ETag"); - Assert.assertNotNull( thisETag ); - Date thisLastModified = res.getLastModified(); - Assert.assertNotNull( thisLastModified ); - } finally { - res.release(); - } - } - - @Test - public void testModifiedGetIfNoneMatch() throws Exception { - System.out.println(">>>ProviderFeedEntityTagsTest.testFeedModifiedGetIfNoneMatch"); - // Post some new content to the feed. - Factory factory = abdera.getFactory(); - String customerName = "Fred Farkle"; - Entry entry = factory.newEntry(); - entry.setTitle("customer " + customerName); - entry.setUpdated(new Date()); - entry.addAuthor("Apache Tuscany"); - Content content = abdera.getFactory().newContent(); - content.setContentType(Content.Type.TEXT); - content.setValue(customerName); - entry.setContentElement(content); - - RequestOptions opts = new RequestOptions(); - String contentType = "application/atom+xml; type=entry"; - opts.setContentType(contentType); - IRI colUri = new IRI(providerURI).resolve("customer"); - ClientResponse res = client.post(colUri.toString(), entry, opts); - - // Feed request with predicates - opts = new RequestOptions(); - contentType = "application/atom+xml"; - opts.setContentType(contentType); - opts.setHeader( "If-None-Match", eTag); - - res = client.get(providerURI, opts); - Assert.assertNotNull(res); - try { - String thisETag = res.getHeader("ETag"); - Assert.assertNotNull( thisETag ); - Date thisLastModified = res.getLastModified(); - Assert.assertNotNull( thisLastModified ); - - // Should return 200 - value since feed is changed - Assert.assertEquals(200, res.getStatus()); - Assert.assertEquals(ResponseType.SUCCESS, res.getType()); - - // AtomTestCaseUtils.printResponseHeaders( "Feed modified if-none-match response headers:", " ", res ); - // System.out.println("Feed response content:"); - // AtomTestCaseUtils.prettyPrint(abdera, res.getDocument()); - } finally { - res.release(); - } - } - - @Test - public void testModifiedGetIfMatch() throws Exception { - System.out.println(">>>ProviderFeedEntityTagsTest.testFeedModifiedGetIfMatch"); - // Feed request with predicates - RequestOptions opts = new RequestOptions(); - final String contentType = "application/atom+xml"; - opts.setContentType(contentType); - opts.setHeader( "If-Match", eTag); - - ClientResponse res = client.get(providerURI, opts); - Assert.assertNotNull(res); - try { - // Should return 412 - Precondition failed since feed changed. - Assert.assertEquals(412, res.getStatus()); - // AtomTestCaseUtils.printResponseHeaders( "Feed response headers:", " ", res ); - // System.out.println("Feed response content:"); - // AtomTestCaseUtils.prettyPrint(abdera, res.getDocument()); - } finally { - res.release(); - } - } - - @Test - public void testModifiedGetIfUnModified() throws Exception { - System.out.println(">>>ProviderFeedEntityTagsTest.testFeedUnmodifiedGetIfUnModified"); - // Feed request with predicates - RequestOptions opts = new RequestOptions(); - final String contentType = "application/atom+xml"; - opts.setContentType(contentType); - opts.setHeader( "If-Unmodified-Since", dateFormat.format( new Date() )); - - ClientResponse res = client.get(providerURI, opts); - Assert.assertNotNull(res); - try { - // Should return 304 - Feed not provided since feed is modified since. - Assert.assertEquals(304, res.getStatus()); - } finally { - res.release(); - } - } - - @Test - public void testModifiedGetIfModified() throws Exception { - System.out.println(">>>ProviderFeedEntityTagsTest.testFeedUnmodifiedGetIfModified"); - // Feed request with predicates - RequestOptions opts = new RequestOptions(); - final String contentType = "application/atom+xml"; - opts.setContentType(contentType); - opts.setHeader( "If-Modified-Since", dateFormat.format( lastModified )); - - ClientResponse res = client.get(providerURI, opts); - Assert.assertNotNull(res); - try { - // Should return 200 - Feed provided since feed is changed. - Assert.assertEquals(200, res.getStatus()); - Assert.assertEquals(ResponseType.SUCCESS, res.getType()); - - String thisETag = res.getHeader("ETag"); - Assert.assertNotNull( thisETag ); - Date thisLastModified = res.getLastModified(); - Assert.assertNotNull( thisLastModified ); - } finally { - res.release(); - } - } - - - public static void printFeed( String title, String indent, Feed feed ) { - if ( feed == null ) { - System.out.println( title + " feed is null"); - return; - } - - System.out.println( title ); - System.out.println( indent + "id=" + feed.getId() ); - System.out.println( indent + "title=" + feed.getTitle() ); - System.out.println( indent + "updated=" + feed.getUpdated() ); - System.out.println( indent + "author=" + feed.getAuthor() ); - Collection collection = feed.getCollection(); - if ( collection == null ) { - System.out.println( indent + "collection=null" ); - } else { - System.out.println( indent + "collection=" + collection ); - } - // System.out.println( indent + "collection size=" + feed.getCollection() ); - // for (Collection collection : workspace.getCollections()) { - // if (collection.getTitle().equals("customers")) { - // String expected = uri + "customers"; - // String actual = collection.getResolvedHref().toString(); - // assertEquals(expected, actual); - // } - // } - - } + protected static final SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z"); // RFC + // 822 + // date + // time + + @BeforeClass + public static void init() throws Exception { + System.out.println(">>>ProviderFeedEntityTagsTest.init"); + String contribution = ContributionLocationHelper.getContributionLocation(AtomDeleteTestCase.class); + providerNode = NodeFactory.newInstance().createNode( + "org/apache/tuscany/sca/binding/atom/Provider.composite", new Contribution("provider", contribution)); + providerNode.start(); + abdera = new Abdera(); + client = new AbderaClient(abdera); + abderaParser = Abdera.getNewParser(); + } + + @AfterClass + public static void destroy() throws Exception { + System.out.println(">>>ProviderFeedEntityTagsTest.destroy"); + providerNode.stop(); + providerNode.destroy(); + } + + @Test + public void testPrelim() throws Exception { + Assert.assertNotNull(providerNode); + Assert.assertNotNull(client); + } + + @Test + public void testFeedBasics() throws Exception { + System.out.println(">>>ProviderFeedEntityTagsTest.testFeedBasics"); + // Normal feed request + ClientResponse res = client.get(providerURI); + Assert.assertNotNull(res); + try { + // Asser feed provided since no predicates + Assert.assertEquals(200, res.getStatus()); + Assert.assertEquals(ResponseType.SUCCESS, res.getType()); + // AtomTestCaseUtils.printResponseHeaders( "Feed response headers:", + // " ", res ); + // System.out.println("Feed response content:"); + // AtomTestCaseUtils.prettyPrint(abdera, res.getDocument()); + + // Perform other tests on feed. + Document<Feed> doc = res.getDocument(); + Assert.assertNotNull(doc); + Feed feed = doc.getRoot(); + Assert.assertNotNull(feed); + printFeed("Feed values", " ", feed); + // RFC 4287 requires non-null id, title, updated elements + Assert.assertNotNull(feed.getId()); + Assert.assertNotNull(feed.getTitle()); + Assert.assertNotNull(feed.getUpdated()); + + eTag = res.getHeader("ETag"); + Assert.assertNotNull(eTag); + lastModified = res.getLastModified(); + Assert.assertNotNull(lastModified); + } finally { + res.release(); + } + } + + @Test + public void testUnmodifiedGetIfMatch() throws Exception { + System.out.println(">>>ProviderFeedEntityTagsTest.testFeedUnmodifiedGetIfMatch"); + // Feed request with predicates + RequestOptions opts = new RequestOptions(); + final String contentType = "application/atom+xml"; + opts.setContentType(contentType); + opts.setHeader("If-Match", eTag); + + ClientResponse res = client.get(providerURI, opts); + Assert.assertNotNull(res); + try { + String thisETag = res.getHeader("ETag"); + Assert.assertNotNull(thisETag); + Date thisLastModified = res.getLastModified(); + Assert.assertNotNull(thisLastModified); + + // Should return 200 - Feed provided since it matches etag. + Assert.assertEquals(200, res.getStatus()); + Assert.assertEquals(ResponseType.SUCCESS, res.getType()); + // AtomTestCaseUtils.printResponseHeaders( "Feed response headers:", + // " ", res ); + // System.out.println("Feed response content:"); + // AtomTestCaseUtils.prettyPrint(abdera, res.getDocument()); + } finally { + res.release(); + } + } + + @Test + public void testUnmodifiedGetIfNoneMatch() throws Exception { + System.out.println(">>>ProviderFeedEntityTagsTest.testFeedUnmodifiedGetIfNoneMatch"); + // Feed request with predicates + RequestOptions opts = new RequestOptions(); + final String contentType = "application/atom+xml"; + opts.setContentType(contentType); + opts.setHeader("If-None-Match", eTag); + + ClientResponse res = client.get(providerURI, opts); + Assert.assertNotNull(res); + try { + // Should return 304 - Feed not provided since it matches ETag. + Assert.assertEquals(304, res.getStatus()); + } finally { + res.release(); + } + } + + @Test + public void testUnmodifiedGetIfUnModified() throws Exception { + System.out.println(">>>ProviderFeedEntityTagsTest.testFeedUnmodifiedGetIfUnModified"); + // Feed request with predicates + RequestOptions opts = new RequestOptions(); + final String contentType = "application/atom+xml"; + opts.setContentType(contentType); + opts.setHeader("If-Unmodified-Since", dateFormat.format(new Date())); + + ClientResponse res = client.get(providerURI, opts); + Assert.assertNotNull(res); + try { + // Should return 304 - Feed not provided since feed is modified + // since. + Assert.assertEquals(304, res.getStatus()); + } finally { + res.release(); + } + } + + @Test + public void testUnmodifiedGetIfModified() throws Exception { + System.out.println(">>>ProviderFeedEntityTagsTest.testFeedUnmodifiedGetIfModified"); + // Feed request with predicates + RequestOptions opts = new RequestOptions(); + final String contentType = "application/atom+xml"; + opts.setContentType(contentType); + opts.setHeader("If-Modified-Since", dateFormat.format(new Date(0))); + + ClientResponse res = client.get(providerURI, opts); + Assert.assertNotNull(res); + try { + // Should return 200 - Feed provided since feed is changed. + Assert.assertEquals(200, res.getStatus()); + Assert.assertEquals(ResponseType.SUCCESS, res.getType()); + + String thisETag = res.getHeader("ETag"); + Assert.assertNotNull(thisETag); + Date thisLastModified = res.getLastModified(); + Assert.assertNotNull(thisLastModified); + } finally { + res.release(); + } + } + + @Test + public void testModifiedGetIfNoneMatch() throws Exception { + System.out.println(">>>ProviderFeedEntityTagsTest.testFeedModifiedGetIfNoneMatch"); + // Post some new content to the feed. + Factory factory = abdera.getFactory(); + String customerName = "Fred Farkle"; + Entry entry = factory.newEntry(); + entry.setTitle("customer " + customerName); + entry.setUpdated(new Date()); + entry.addAuthor("Apache Tuscany"); + Content content = abdera.getFactory().newContent(); + content.setContentType(Content.Type.TEXT); + content.setValue(customerName); + entry.setContentElement(content); + + RequestOptions opts = new RequestOptions(); + String contentType = "application/atom+xml; type=entry"; + opts.setContentType(contentType); + IRI colUri = new IRI(providerURI).resolve("customer"); + ClientResponse res = client.post(colUri.toString(), entry, opts); + + // Feed request with predicates + opts = new RequestOptions(); + contentType = "application/atom+xml"; + opts.setContentType(contentType); + opts.setHeader("If-None-Match", eTag); + + res = client.get(providerURI, opts); + Assert.assertNotNull(res); + try { + String thisETag = res.getHeader("ETag"); + Assert.assertNotNull(thisETag); + Date thisLastModified = res.getLastModified(); + Assert.assertNotNull(thisLastModified); + + // Should return 200 - value since feed is changed + Assert.assertEquals(200, res.getStatus()); + Assert.assertEquals(ResponseType.SUCCESS, res.getType()); + + // AtomTestCaseUtils.printResponseHeaders( + // "Feed modified if-none-match response headers:", " ", res ); + // System.out.println("Feed response content:"); + // AtomTestCaseUtils.prettyPrint(abdera, res.getDocument()); + } finally { + res.release(); + } + } + + @Test + public void testModifiedGetIfMatch() throws Exception { + System.out.println(">>>ProviderFeedEntityTagsTest.testFeedModifiedGetIfMatch"); + // Feed request with predicates + RequestOptions opts = new RequestOptions(); + final String contentType = "application/atom+xml"; + opts.setContentType(contentType); + opts.setHeader("If-Match", eTag); + + ClientResponse res = client.get(providerURI, opts); + Assert.assertNotNull(res); + try { + // Should return 412 - Precondition failed since feed changed. + Assert.assertEquals(412, res.getStatus()); + // AtomTestCaseUtils.printResponseHeaders( "Feed response headers:", + // " ", res ); + // System.out.println("Feed response content:"); + // AtomTestCaseUtils.prettyPrint(abdera, res.getDocument()); + } finally { + res.release(); + } + } + + @Test + public void testModifiedGetIfUnModified() throws Exception { + System.out.println(">>>ProviderFeedEntityTagsTest.testFeedUnmodifiedGetIfUnModified"); + // Feed request with predicates + RequestOptions opts = new RequestOptions(); + final String contentType = "application/atom+xml"; + opts.setContentType(contentType); + opts.setHeader("If-Unmodified-Since", dateFormat.format(new Date())); + + ClientResponse res = client.get(providerURI, opts); + Assert.assertNotNull(res); + try { + // Should return 304 - Feed not provided since feed is modified + // since. + Assert.assertEquals(304, res.getStatus()); + } finally { + res.release(); + } + } + + @Test + public void testModifiedGetIfModified() throws Exception { + System.out.println(">>>ProviderFeedEntityTagsTest.testFeedUnmodifiedGetIfModified"); + // Feed request with predicates + RequestOptions opts = new RequestOptions(); + final String contentType = "application/atom+xml"; + opts.setContentType(contentType); + opts.setHeader("If-Modified-Since", dateFormat.format(lastModified)); + + ClientResponse res = client.get(providerURI, opts); + Assert.assertNotNull(res); + try { + // Should return 200 - Feed provided since feed is changed. + Assert.assertEquals(200, res.getStatus()); + Assert.assertEquals(ResponseType.SUCCESS, res.getType()); + + String thisETag = res.getHeader("ETag"); + Assert.assertNotNull(thisETag); + Date thisLastModified = res.getLastModified(); + Assert.assertNotNull(thisLastModified); + } finally { + res.release(); + } + } + + public static void printFeed(String title, String indent, Feed feed) { + if (feed == null) { + System.out.println(title + " feed is null"); + return; + } + + System.out.println(title); + System.out.println(indent + "id=" + feed.getId()); + System.out.println(indent + "title=" + feed.getTitle()); + System.out.println(indent + "updated=" + feed.getUpdated()); + System.out.println(indent + "author=" + feed.getAuthor()); + Collection collection = feed.getCollection(); + if (collection == null) { + System.out.println(indent + "collection=null"); + } else { + System.out.println(indent + "collection=" + collection); + } + // System.out.println( indent + "collection size=" + + // feed.getCollection() ); + // for (Collection collection : workspace.getCollections()) { + // if (collection.getTitle().equals("customers")) { + // String expected = uri + "customers"; + // String actual = collection.getResolvedHref().toString(); + // assertEquals(expected, actual); + // } + // } + + } } diff --git a/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderServiceDocumentTest.java b/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderServiceDocumentTest.java index 816be8b6e5..93cbf29766 100644 --- a/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderServiceDocumentTest.java +++ b/branches/sca-equinox/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderServiceDocumentTest.java @@ -18,94 +18,98 @@ */ package org.apache.tuscany.sca.binding.atom; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.List; - import junit.framework.Assert; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -import org.apache.tuscany.sca.host.embedded.SCADomain; -import org.apache.tuscany.sca.binding.atom.collection.Collection; import org.apache.abdera.Abdera; -import org.apache.abdera.i18n.iri.IRI; -import org.apache.abdera.factory.Factory; import org.apache.abdera.model.Content; +import org.apache.abdera.model.Document; import org.apache.abdera.model.Entry; import org.apache.abdera.model.Feed; -import org.apache.abdera.model.Document; import org.apache.abdera.model.Service; +import org.apache.abdera.parser.Parser; import org.apache.abdera.protocol.Response.ResponseType; import org.apache.abdera.protocol.client.AbderaClient; import org.apache.abdera.protocol.client.ClientResponse; -import org.apache.abdera.protocol.client.RequestOptions; -import org.apache.abdera.parser.Parser; +import org.apache.tuscany.sca.binding.atom.collection.Collection; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; /** * Tests use of service documents provided by atom binding based collections. - * Uses the SCA provided Provider composite to act as a server. - * Uses the Abdera provided Client to act as a client. + * Uses the SCA provided Provider composite to act as a server. Uses the Abdera + * provided Client to act as a client. */ public class ProviderServiceDocumentTest { - public final static String providerURI = "http://localhost:8084/customer"; - protected static SCADomain scaProviderDomain; - protected static SCADomain scaConsumerDomain; + public final static String providerURI = "http://localhost:8084/customer"; + protected static Node providerNode; + protected static Node consumerNode; protected static CustomerClient testService; protected static Abdera abdera; protected static AbderaClient client; - protected static Parser abderaParser; - - @BeforeClass - public static void init() throws Exception { - scaProviderDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/atom/Provider.composite"); - scaConsumerDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/atom/Consumer.composite"); - testService = scaConsumerDomain.getService(CustomerClient.class, "CustomerClient"); - abdera = new Abdera(); - client = new AbderaClient(abdera); - abderaParser = Abdera.getNewParser(); - } - - @AfterClass - public static void destroy() throws Exception { - scaProviderDomain.close(); - } - - @Test - public void testPrelim() throws Exception { - Assert.assertNotNull(scaProviderDomain); - Assert.assertNotNull( client ); - } - - @Test - public void testFeedBasics() throws Exception { - // Normal feed request - ClientResponse res = client.get(providerURI); - Assert.assertNotNull(res); - try { - // Assert feed provided since no predicates - Assert.assertEquals(200, res.getStatus()); - Assert.assertEquals(ResponseType.SUCCESS, res.getType()); - // AtomTestCaseUtils.printResponseHeaders( "Feed response headers:", " ", res ); - // System.out.println("Feed response content:"); - // AtomTestCaseUtils.prettyPrint(abdera, res.getDocument()); - - // Perform other tests on feed. - Document<Feed> doc = res.getDocument(); - Assert.assertNotNull( doc ); - Feed feed = doc.getRoot(); - Assert.assertNotNull( feed ); - // printFeed( "Feed values", " ", feed ); - // RFC 4287 requires non-null id, title, updated elements - Assert.assertNotNull( feed.getId() ); - Assert.assertNotNull( feed.getTitle() ); - Assert.assertNotNull( feed.getUpdated() ); - } finally { - res.release(); - } - } + protected static Parser abderaParser; + + @BeforeClass + public static void init() throws Exception { + String contribution = ContributionLocationHelper.getContributionLocation(AtomDeleteTestCase.class); + providerNode = NodeFactory.newInstance().createNode( + "org/apache/tuscany/sca/binding/atom/Provider.composite", new Contribution("provider", contribution)); + consumerNode = NodeFactory.newInstance().createNode( + "org/apache/tuscany/sca/binding/atom/Consumer.composite", new Contribution("consumer", contribution)); + providerNode.start(); + consumerNode.start(); + testService = consumerNode.getService(CustomerClient.class, "CustomerClient"); + abdera = new Abdera(); + client = new AbderaClient(abdera); + abderaParser = Abdera.getNewParser(); + } + + @AfterClass + public static void destroy() throws Exception { + providerNode.stop(); + providerNode.destroy(); + consumerNode.stop(); + consumerNode.destroy(); + } + + @Test + public void testPrelim() throws Exception { + Assert.assertNotNull(providerNode); + Assert.assertNotNull(client); + } + + @Test + public void testFeedBasics() throws Exception { + // Normal feed request + ClientResponse res = client.get(providerURI); + Assert.assertNotNull(res); + try { + // Assert feed provided since no predicates + Assert.assertEquals(200, res.getStatus()); + Assert.assertEquals(ResponseType.SUCCESS, res.getType()); + // AtomTestCaseUtils.printResponseHeaders( "Feed response headers:", + // " ", res ); + // System.out.println("Feed response content:"); + // AtomTestCaseUtils.prettyPrint(abdera, res.getDocument()); + + // Perform other tests on feed. + Document<Feed> doc = res.getDocument(); + Assert.assertNotNull(doc); + Feed feed = doc.getRoot(); + Assert.assertNotNull(feed); + // printFeed( "Feed values", " ", feed ); + // RFC 4287 requires non-null id, title, updated elements + Assert.assertNotNull(feed.getId()); + Assert.assertNotNull(feed.getTitle()); + Assert.assertNotNull(feed.getUpdated()); + } finally { + res.release(); + } + } @Test public void testServiceDocumentGet() throws Exception { @@ -119,56 +123,57 @@ public class ProviderServiceDocumentTest { postEntry = postEntry("Count Dracula"); newEntry = resourceCollection.post(postEntry); - // Service document - ClientResponse res = client.get(providerURI + "/atomsvc"); - Assert.assertNotNull(res); - try { - // Asser feed provided since no predicates - Assert.assertEquals(200, res.getStatus()); - Assert.assertEquals(ResponseType.SUCCESS, res.getType()); - - // Perform other tests on feed. - // AtomTestCaseUtils.prettyPrint(abdera, res.getDocument()); - Document<Service> serviceDoc = res.getDocument(); - Service service = serviceDoc.getRoot(); - Assert.assertNotNull( service ); - org.apache.abdera.model.Collection collection = service.getCollection( "workspace", "customers" ); - String title = collection.getTitle(); - Assert.assertEquals("customers", title); - String href = collection.getHref().toString(); - Assert.assertTrue( href.contains( "customer") ); - } finally { - res.release(); - } + // Service document + ClientResponse res = client.get(providerURI + "/atomsvc"); + Assert.assertNotNull(res); + try { + // Asser feed provided since no predicates + Assert.assertEquals(200, res.getStatus()); + Assert.assertEquals(ResponseType.SUCCESS, res.getType()); + + // Perform other tests on feed. + // AtomTestCaseUtils.prettyPrint(abdera, res.getDocument()); + Document<Service> serviceDoc = res.getDocument(); + Service service = serviceDoc.getRoot(); + Assert.assertNotNull(service); + org.apache.abdera.model.Collection collection = service.getCollection("workspace", "customers"); + String title = collection.getTitle(); + Assert.assertEquals("customers", title); + String href = collection.getHref().toString(); + Assert.assertTrue(href.contains("customer")); + } finally { + res.release(); + } } - public static void printFeed( String title, String indent, Feed feed ) { - if ( feed == null ) { - System.out.println( title + " feed is null"); - return; - } - - System.out.println( title ); - System.out.println( indent + "id=" + feed.getId() ); - System.out.println( indent + "title=" + feed.getTitle() ); - System.out.println( indent + "updated=" + feed.getUpdated() ); - System.out.println( indent + "author=" + feed.getAuthor() ); - // Collection collection = feed.getCollection(); - // if ( collection == null ) { - // System.out.println( indent + "collection=null" ); - // } else { - // System.out.println( indent + "collection=" + collection ); - // } - // System.out.println( indent + "collection size=" + feed.getCollection() ); - // for (Collection collection : workspace.getCollections()) { - // if (collection.getTitle().equals("customers")) { - // String expected = uri + "customers"; - // String actual = collection.getResolvedHref().toString(); - // assertEquals(expected, actual); - // } - // } - - } + public static void printFeed(String title, String indent, Feed feed) { + if (feed == null) { + System.out.println(title + " feed is null"); + return; + } + + System.out.println(title); + System.out.println(indent + "id=" + feed.getId()); + System.out.println(indent + "title=" + feed.getTitle()); + System.out.println(indent + "updated=" + feed.getUpdated()); + System.out.println(indent + "author=" + feed.getAuthor()); + // Collection collection = feed.getCollection(); + // if ( collection == null ) { + // System.out.println( indent + "collection=null" ); + // } else { + // System.out.println( indent + "collection=" + collection ); + // } + // System.out.println( indent + "collection size=" + + // feed.getCollection() ); + // for (Collection collection : workspace.getCollections()) { + // if (collection.getTitle().equals("customers")) { + // String expected = uri + "customers"; + // String actual = collection.getResolvedHref().toString(); + // assertEquals(expected, actual); + // } + // } + + } private Entry postEntry(String value) { Entry entry = abdera.newEntry(); diff --git a/branches/sca-equinox/modules/binding-ejb-runtime/pom.xml b/branches/sca-equinox/modules/binding-ejb-runtime/pom.xml index c89585c95c..936c588788 100644 --- a/branches/sca-equinox/modules/binding-ejb-runtime/pom.xml +++ b/branches/sca-equinox/modules/binding-ejb-runtime/pom.xml @@ -73,7 +73,7 @@ <dependency> <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-host-embedded</artifactId> + <artifactId>tuscany-node-impl</artifactId> <version>1.4-SNAPSHOT</version> <scope>test</scope> </dependency> diff --git a/branches/sca-equinox/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/EJBReferenceTestCase.java b/branches/sca-equinox/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/EJBReferenceTestCase.java index 82471acb16..87616330dc 100644 --- a/branches/sca-equinox/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/EJBReferenceTestCase.java +++ b/branches/sca-equinox/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/EJBReferenceTestCase.java @@ -20,7 +20,10 @@ package org.apache.tuscany.sca.binding.ejb.tests; import junit.framework.TestCase; -import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import account.Customer; @@ -31,7 +34,7 @@ import account.Customer; */ public class EJBReferenceTestCase extends TestCase { private static final int MOCK_PORT = 8085; - private SCADomain scaDomain; + private Node node; @Override protected void setUp() throws Exception { @@ -39,7 +42,9 @@ public class EJBReferenceTestCase extends TestCase { System.setProperty("java.naming.provider.url", "ejbd://localhost:" + MOCK_PORT); System.setProperty("managed", "false"); - scaDomain = SCADomain.newInstance("account/account.composite"); + String contribution = ContributionLocationHelper.getContributionLocation(EJBReferenceTestCase.class); + node = NodeFactory.newInstance().createNode("account/account.composite", new Contribution("account", contribution)); + node.start(); // To capture the network traffic for the MockServer, uncomment the next line // new Thread(new SocketTracer(MOCK_PORT, OPENEJB_PORT)).start(); @@ -53,11 +58,12 @@ public class EJBReferenceTestCase extends TestCase { @Override protected void tearDown() throws Exception { - scaDomain.close(); + node.stop(); + node.destroy(); } public void testCalculator() throws Exception { - Customer customer = scaDomain.getService(Customer.class, "CustomerComponent"); + Customer customer = node.getService(Customer.class, "CustomerComponent"); // This is one of the customer numbers in bank application running on Geronimo String accountNo = "1234567890"; Double balance = customer.depositAmount(accountNo, new Double(100)); diff --git a/branches/sca-equinox/modules/binding-gdata-runtime-gsoc/pom.xml b/branches/sca-equinox/modules/binding-gdata-runtime-gsoc/pom.xml index fef1854daf..428bc1b801 100644 --- a/branches/sca-equinox/modules/binding-gdata-runtime-gsoc/pom.xml +++ b/branches/sca-equinox/modules/binding-gdata-runtime-gsoc/pom.xml @@ -135,12 +135,12 @@ <scope>test</scope> </dependency> - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-host-embedded</artifactId> - <version>1.4-SNAPSHOT</version> - <scope>test</scope> - </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-node-impl</artifactId> + <version>1.4-SNAPSHOT</version> + <scope>test</scope> + </dependency> <dependency> <groupId>junit</groupId> diff --git a/branches/sca-equinox/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/Consumer.java b/branches/sca-equinox/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/Consumer.java index 2517c7233a..50a3ec3886 100644 --- a/branches/sca-equinox/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/Consumer.java +++ b/branches/sca-equinox/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/Consumer.java @@ -19,7 +19,10 @@ package org.apache.tuscany.sca.binding.gdata; -import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import com.google.gdata.data.Entry; import com.google.gdata.data.Feed; @@ -30,8 +33,11 @@ public class Consumer { public static void main(String[] args) throws Exception { //Initialize the GData client service (Reference Binding test) - SCADomain scaDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/gdata/ConsumerGoogleBlogger.composite"); - CustomerClient testService = scaDomain.getService(CustomerClient.class, "CustomerClient"); + String contribution = ContributionLocationHelper.getContributionLocation(Consumer.class); + Node node = NodeFactory.newInstance().createNode( + "org/apache/tuscany/sca/binding/gdata/ConsumerGoogleBlogger.composite", new Contribution("consumer", contribution)); + node.start(); + CustomerClient testService = node.getService(CustomerClient.class, "CustomerClient"); Feed feed = testService.clientGetFeed(); diff --git a/branches/sca-equinox/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/ConsumerProviderTestCase.java b/branches/sca-equinox/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/ConsumerProviderTestCase.java index 3ac79e5f0a..e4d502357d 100644 --- a/branches/sca-equinox/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/ConsumerProviderTestCase.java +++ b/branches/sca-equinox/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/ConsumerProviderTestCase.java @@ -20,18 +20,23 @@ package org.apache.tuscany.sca.binding.gdata; import junit.framework.TestCase; -import org.apache.tuscany.sca.host.embedded.SCADomain; + +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.junit.After; import org.junit.Before; import org.junit.Test; + import com.google.gdata.data.Entry; import com.google.gdata.data.Feed; import com.google.gdata.data.PlainTextConstruct; public class ConsumerProviderTestCase extends TestCase { - private SCADomain scaDomainProvider = null; - private SCADomain scaDomainConsumer = null; + private Node providerNode = null; + private Node consumerNode = null; private CustomerClient testService = null; @Before @@ -40,18 +45,26 @@ public class ConsumerProviderTestCase extends TestCase { System.out.println("Method Test Start-----------------------------------------------------------------------"); // Setup the local GData servlet (Service Binding test) - scaDomainProvider = SCADomain.newInstance("org/apache/tuscany/sca/binding/gdata/Provider.composite"); + String contribution = ContributionLocationHelper.getContributionLocation(ConsumerProviderTestCase.class); + providerNode = NodeFactory.newInstance().createNode( + "org/apache/tuscany/sca/binding/gdata/Provider.composite", new Contribution("provider", contribution)); + providerNode.start(); System.out.println("[Debug Info] Provider.composite ready..."); // Initialize the GData client service (Reference Binding test) - scaDomainConsumer = SCADomain.newInstance("org/apache/tuscany/sca/binding/gdata/Consumer.composite"); - testService = scaDomainConsumer.getService(CustomerClient.class, "CustomerClient"); + consumerNode = NodeFactory.newInstance().createNode( + "org/apache/tuscany/sca/binding/gdata/Consumer.composite", new Contribution("consumer", contribution)); + consumerNode.start(); + testService = consumerNode.getService(CustomerClient.class, "CustomerClient"); } @After @Override public void tearDown() { - scaDomainProvider.close(); + providerNode.stop(); + providerNode.destroy(); + consumerNode.stop(); + consumerNode.destroy(); System.out.println("Method Test End------------------------------------------------------------------------"); System.out.println("\n\n"); } diff --git a/branches/sca-equinox/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleBloggerServiceTestCase.java b/branches/sca-equinox/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleBloggerServiceTestCase.java index b4f6ec7b36..902d251200 100644 --- a/branches/sca-equinox/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleBloggerServiceTestCase.java +++ b/branches/sca-equinox/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleBloggerServiceTestCase.java @@ -23,7 +23,10 @@ import java.net.URL; import junit.framework.TestCase; -import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -36,11 +39,10 @@ import com.google.gdata.data.PlainTextConstruct; public class GoogleBloggerServiceTestCase extends TestCase{ - private SCADomain scaDomainConsumer = null; + private Node consumerNode = null; private CustomerClient testService = null; public GoogleBloggerServiceTestCase(){ - } @Before @@ -49,8 +51,11 @@ public class GoogleBloggerServiceTestCase extends TestCase{ System.out.println("Method Test Start-----------------------------------------------------------------------"); //Initialize the GData client service (Reference Binding test) - scaDomainConsumer = SCADomain.newInstance("org/apache/tuscany/sca/binding/gdata/ConsumerGoogleBlogger.composite"); - testService = scaDomainConsumer.getService(CustomerClient.class, "CustomerClient"); + String contribution = ContributionLocationHelper.getContributionLocation(GoogleBloggerServiceTestCase.class); + consumerNode = NodeFactory.newInstance().createNode( + "org/apache/tuscany/sca/binding/gdata/ConsumerGoogleBlogger.composite", new Contribution("consumer", contribution)); + consumerNode.start(); + testService = consumerNode.getService(CustomerClient.class, "CustomerClient"); } @After @@ -58,6 +63,8 @@ public class GoogleBloggerServiceTestCase extends TestCase{ public void tearDown(){ System.out.println("Method Test End------------------------------------------------------------------------"); System.out.println("\n\n"); + consumerNode.stop(); + consumerNode.destroy(); } @Test diff --git a/branches/sca-equinox/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleCalendarServiceTestCase.java b/branches/sca-equinox/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleCalendarServiceTestCase.java index 882716575b..749dd41710 100644 --- a/branches/sca-equinox/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleCalendarServiceTestCase.java +++ b/branches/sca-equinox/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleCalendarServiceTestCase.java @@ -23,7 +23,10 @@ import java.net.URL; import junit.framework.TestCase; -import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -36,11 +39,10 @@ import com.google.gdata.data.PlainTextConstruct; public class GoogleCalendarServiceTestCase extends TestCase{ - private SCADomain scaDomainConsumer = null; + private Node consumerNode = null; private CustomerClient testService = null; public GoogleCalendarServiceTestCase(){ - } @Before @@ -49,8 +51,11 @@ public class GoogleCalendarServiceTestCase extends TestCase{ System.out.println("Method Test Start-----------------------------------------------------------------------"); //Initialize the GData client service (Reference Binding test) - scaDomainConsumer = SCADomain.newInstance("org/apache/tuscany/sca/binding/gdata/ConsumerGoogleCalendar.composite"); - testService = scaDomainConsumer.getService(CustomerClient.class, "CustomerClient"); + String contribution = ContributionLocationHelper.getContributionLocation(GoogleCalendarServiceTestCase.class); + consumerNode = NodeFactory.newInstance().createNode( + "org/apache/tuscany/sca/binding/gdata/ConsumerGoogleCalendar.composite", new Contribution("consumer", contribution)); + consumerNode.start(); + testService = consumerNode.getService(CustomerClient.class, "CustomerClient"); } @After @@ -58,6 +63,8 @@ public class GoogleCalendarServiceTestCase extends TestCase{ public void tearDown(){ System.out.println("Method Test End------------------------------------------------------------------------"); System.out.println("\n\n"); + consumerNode.stop(); + consumerNode.destroy(); } @Test diff --git a/branches/sca-equinox/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleContactsServiceTestCase.java b/branches/sca-equinox/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleContactsServiceTestCase.java index 959c153074..cab7196a69 100644 --- a/branches/sca-equinox/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleContactsServiceTestCase.java +++ b/branches/sca-equinox/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/GoogleContactsServiceTestCase.java @@ -23,7 +23,10 @@ import java.net.URL; import junit.framework.TestCase; -import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -36,7 +39,7 @@ import com.google.gdata.data.PlainTextConstruct; public class GoogleContactsServiceTestCase extends TestCase{ - private SCADomain scaDomainConsumer = null; + private Node consumerNode = null; private CustomerClient testService = null; public GoogleContactsServiceTestCase(){ @@ -49,8 +52,11 @@ public class GoogleContactsServiceTestCase extends TestCase{ System.out.println("Method Test Start-----------------------------------------------------------------------"); //Initialize the GData client service (Reference Binding test) - scaDomainConsumer = SCADomain.newInstance("org/apache/tuscany/sca/binding/gdata/ConsumerGoogleContacts.composite"); - testService = scaDomainConsumer.getService(CustomerClient.class, "CustomerClient"); + String contribution = ContributionLocationHelper.getContributionLocation(GoogleContactsServiceTestCase.class); + consumerNode = NodeFactory.newInstance().createNode( + "org/apache/tuscany/sca/binding/gdata/ConsumerGoogleContacts.composite", new Contribution("consumer", contribution)); + consumerNode.start(); + testService = consumerNode.getService(CustomerClient.class, "CustomerClient"); } @After @@ -58,6 +64,8 @@ public class GoogleContactsServiceTestCase extends TestCase{ public void tearDown(){ System.out.println("Method Test End------------------------------------------------------------------------"); System.out.println("\n\n"); + consumerNode.stop(); + consumerNode.destroy(); } @Test diff --git a/branches/sca-equinox/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/Provider.java b/branches/sca-equinox/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/Provider.java index 21bff30256..a9b12c3d32 100644 --- a/branches/sca-equinox/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/Provider.java +++ b/branches/sca-equinox/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/Provider.java @@ -21,13 +21,19 @@ package org.apache.tuscany.sca.binding.gdata; import java.io.IOException; -import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; public class Provider { public static void main(String[] args) { - SCADomain scaDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/gdata/Provider.composite"); + String contribution = ContributionLocationHelper.getContributionLocation(Provider.class); + Node node = NodeFactory.newInstance().createNode( + "org/apache/tuscany/sca/binding/gdata/Provider.composite", new Contribution("provider", contribution)); + node.start(); System.out.println("Provider.composite ready..."); try { @@ -36,6 +42,7 @@ public class Provider { e.printStackTrace(); } - scaDomain.close(); + node.stop(); + node.destroy(); } } diff --git a/branches/sca-equinox/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/StartLocalhostServlet.java b/branches/sca-equinox/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/StartLocalhostServlet.java index 2773398426..141f641575 100644 --- a/branches/sca-equinox/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/StartLocalhostServlet.java +++ b/branches/sca-equinox/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/StartLocalhostServlet.java @@ -21,13 +21,19 @@ package org.apache.tuscany.sca.binding.gdata; import java.io.IOException; -import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; public class StartLocalhostServlet { public static void main(String[] args) { - SCADomain scaDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/gdata/Provider.composite"); + String contribution = ContributionLocationHelper.getContributionLocation(Provider.class); + Node node = NodeFactory.newInstance().createNode( + "org/apache/tuscany/sca/binding/gdata/Provider.composite", new Contribution("provider", contribution)); + node.start(); System.out.println("Provider.composite ready..."); try { @@ -36,6 +42,7 @@ public class StartLocalhostServlet { e.printStackTrace(); } - scaDomain.close(); + node.stop(); + node.destroy(); } } diff --git a/branches/sca-equinox/modules/binding-gdata-runtime/pom.xml b/branches/sca-equinox/modules/binding-gdata-runtime/pom.xml index d40351d722..572470ccbd 100644 --- a/branches/sca-equinox/modules/binding-gdata-runtime/pom.xml +++ b/branches/sca-equinox/modules/binding-gdata-runtime/pom.xml @@ -106,11 +106,11 @@ <dependency> <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-host-embedded</artifactId> + <artifactId>tuscany-node-impl</artifactId> <version>1.4-SNAPSHOT</version> <scope>test</scope> </dependency> - + <dependency> <groupId>com.google.gdata</groupId> <artifactId>gdata-core</artifactId> diff --git a/branches/sca-equinox/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/calendarconsumer/CalendarConsumer.java b/branches/sca-equinox/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/calendarconsumer/CalendarConsumer.java index 35a692ac67..07cb62f410 100644 --- a/branches/sca-equinox/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/calendarconsumer/CalendarConsumer.java +++ b/branches/sca-equinox/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/calendarconsumer/CalendarConsumer.java @@ -18,6 +18,11 @@ */ package org.apache.tuscany.sca.binding.gdata.calendarconsumer; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; + import com.google.gdata.data.BaseEntry; import com.google.gdata.data.DateTime; import com.google.gdata.data.Entry; @@ -26,18 +31,20 @@ import com.google.gdata.data.Person; import com.google.gdata.data.PlainTextConstruct; import com.google.gdata.data.extensions.EventEntry; import com.google.gdata.data.extensions.When; -import org.apache.tuscany.sca.host.embedded.SCADomain; public class CalendarConsumer { public static void main(String... args) throws Exception { - SCADomain scaDomain; + Node node; CalendarConsumerImpl resourceCollection; //init - scaDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/gdata/CalendarConsumer.composite"); - resourceCollection = scaDomain.getService(CalendarConsumerImpl.class, "CalendarConsumer"); + String contribution = ContributionLocationHelper.getContributionLocation(CalendarConsumer.class); + node = NodeFactory.newInstance().createNode( + "org/apache/tuscany/sca/binding/gdata/CalendarConsumer.composite", new Contribution("consumer", contribution)); + node.start(); + resourceCollection = node.getService(CalendarConsumerImpl.class, "CalendarConsumer"); //test methods System.out.println( @@ -115,7 +122,8 @@ public class CalendarConsumer { } //close - scaDomain.close(); + node.stop(); + node.destroy(); } } diff --git a/branches/sca-equinox/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/calendarconsumer/CalendarConsumerTest.java b/branches/sca-equinox/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/calendarconsumer/CalendarConsumerTest.java index 211ae51ba2..15a9eea934 100644 --- a/branches/sca-equinox/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/calendarconsumer/CalendarConsumerTest.java +++ b/branches/sca-equinox/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/calendarconsumer/CalendarConsumerTest.java @@ -18,6 +18,20 @@ */ package org.apache.tuscany.sca.binding.gdata.calendarconsumer; +import static org.junit.Assert.assertNotNull; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.apache.tuscany.sca.data.collection.NotFoundException; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + import com.google.gdata.data.BaseEntry; import com.google.gdata.data.DateTime; import com.google.gdata.data.Feed; @@ -25,20 +39,11 @@ import com.google.gdata.data.Person; import com.google.gdata.data.PlainTextConstruct; import com.google.gdata.data.extensions.EventEntry; import com.google.gdata.data.extensions.When; -import java.util.logging.Level; -import java.util.logging.Logger; -import org.apache.tuscany.sca.host.embedded.SCADomain; -import org.apache.tuscany.sca.data.collection.NotFoundException; - -import org.junit.Test; -import org.junit.BeforeClass; -import org.junit.AfterClass; -import static org.junit.Assert.assertNotNull; //FIX-ME: the tests are executed in an incorrect order public class CalendarConsumerTest { - private static SCADomain scaDomain; + private static Node node; private Feed feed; private BaseEntry returnedEntry; private BaseEntry searchedEntry; @@ -47,13 +52,17 @@ public class CalendarConsumerTest { @BeforeClass public static void init() { - scaDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/gdata/CalendarConsumer.composite"); - consumer = scaDomain.getService(CalendarConsumerImpl.class, "CalendarConsumer"); + String contribution = ContributionLocationHelper.getContributionLocation(CalendarConsumer.class); + node = NodeFactory.newInstance().createNode( + "org/apache/tuscany/sca/binding/gdata/CalendarConsumer.composite", new Contribution("consumer", contribution)); + node.start(); + consumer = node.getService(CalendarConsumerImpl.class, "CalendarConsumer"); } @AfterClass public static void close() { - scaDomain.close(); + node.stop(); + node.destroy(); } @Test diff --git a/branches/sca-equinox/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/consumerprovider/Consumer.java b/branches/sca-equinox/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/consumerprovider/Consumer.java index 00055f28b2..f6c5f65358 100644 --- a/branches/sca-equinox/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/consumerprovider/Consumer.java +++ b/branches/sca-equinox/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/consumerprovider/Consumer.java @@ -19,18 +19,24 @@ package org.apache.tuscany.sca.binding.gdata.consumerprovider; -import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; public class Consumer { public static void main(String[] args) throws Exception { - SCADomain scaDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/gdata/Consumer.composite"); + String contribution = ContributionLocationHelper.getContributionLocation(Consumer.class); + Node node = NodeFactory.newInstance().createNode( + "org/apache/tuscany/sca/binding/gdata/Consumer.composite", new Contribution("consumer", contribution)); + node.start(); + CustomerClient testService = node.getService(CustomerClient.class, "CustomerClient"); - CustomerClient testService = scaDomain.getService(CustomerClient.class, "CustomerClient"); + testService.testCustomerCollection(); - testService.testCustomerCollection(); - - scaDomain.close(); + node.stop(); + node.destroy(); } } diff --git a/branches/sca-equinox/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/consumerprovider/Provider.java b/branches/sca-equinox/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/consumerprovider/Provider.java index 9beca538df..1d7d3f908e 100644 --- a/branches/sca-equinox/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/consumerprovider/Provider.java +++ b/branches/sca-equinox/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/consumerprovider/Provider.java @@ -18,17 +18,23 @@ */ package org.apache.tuscany.sca.binding.gdata.consumerprovider; -import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; public class Provider { public static void main(String[] args) throws Exception { - SCADomain scaDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/gdata/Provider.composite"); - + String contribution = ContributionLocationHelper.getContributionLocation(Provider.class); + Node node = NodeFactory.newInstance().createNode( + "org/apache/tuscany/sca/binding/gdata/Provider.composite", new Contribution("provider", contribution)); + node.start(); System.out.println("Ready for consultings..."); System.in.read(); - scaDomain.close(); + node.stop(); + node.destroy(); } } diff --git a/branches/sca-equinox/modules/binding-http-runtime/pom.xml b/branches/sca-equinox/modules/binding-http-runtime/pom.xml index 7174cf44a0..9cecd4ed46 100644 --- a/branches/sca-equinox/modules/binding-http-runtime/pom.xml +++ b/branches/sca-equinox/modules/binding-http-runtime/pom.xml @@ -56,7 +56,7 @@ <dependency> <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-host-embedded</artifactId> + <artifactId>tuscany-node-impl</artifactId> <version>1.4-SNAPSHOT</version> <scope>test</scope> </dependency> diff --git a/branches/sca-equinox/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/HTTPBindingCacheTestCase.java b/branches/sca-equinox/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/HTTPBindingCacheTestCase.java index bb5f6d5a8b..50022e9663 100644 --- a/branches/sca-equinox/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/HTTPBindingCacheTestCase.java +++ b/branches/sca-equinox/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/HTTPBindingCacheTestCase.java @@ -29,7 +29,10 @@ import java.util.Date; import junit.framework.TestCase; -import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; /** * HTTP binding unit tests. @@ -37,819 +40,831 @@ import org.apache.tuscany.sca.host.embedded.SCADomain; * @version $Rev$ $Date$ */ public class HTTPBindingCacheTestCase extends TestCase { - // RFC 822 date time - protected static final SimpleDateFormat dateFormat = new SimpleDateFormat( - "EEE, dd MMM yyyy HH:mm:ss Z"); - - // Request with no predicates in header. - private static final String REQUEST1 = "{0} /httpbinding/{1} HTTP/1.0\n" - + "Host: localhost\n" + "Content-Type: text/xml\n" - + "Connection: close\n" + "Content-Length: {2}" + "\n\n{3}"; - - // Request with predicates in header - private static final String REQUEST2 = "{0} /httpbinding/{1} HTTP/1.0\n" - + "Host: localhost\n" + "Content-Type: text/xml\n" + "{2}: {3}\n" // predicate (If-Match, If-None-Match, If-Modified-Since, If-NotModified-Since): value (date or ETag) - + "Connection: close\n" + "Content-Length: {4}" + "\n\n{5}"; - - private static final int HTTP_PORT = 8085; - - private SCADomain scaDomain; - - @Override - protected void setUp() throws Exception { - scaDomain = SCADomain.newInstance("testCache.composite"); - } - - @Override - protected void tearDown() throws Exception { - scaDomain.close(); - } - - /** - * Test invoking a POJO get method implementation using the HTTP binding. - * @throws Exception - */ - public void testGet() throws Exception { - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - int index = 0; - String content = ""; - String request = MessageFormat.format(REQUEST1, "GET", index, content - .getBytes().length, content); - os.write(request.getBytes()); - os.flush(); - - String document = read(client); - assertTrue(document.indexOf("<body><p>item=" + index) != -1); - } - - /** - * Test invoking a conditional method implementation using the HTTP binding. - * @throws Exception - */ - public void testConditionalGetIfModifiedNegative() throws Exception { - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - int index = 0; - String content = ""; - String request = MessageFormat.format(REQUEST2, "GET", index, - "If-Modified-Since", dateFormat.format(new Date(0)), content - .getBytes().length, content); - os.write(request.getBytes()); - os.flush(); - - String document = read(client); - // Should return item - assertTrue(document.indexOf("<body><p>item=" + index) != -1); - // Should return code 304 Not Modified. - // assertTrue(document.indexOf("HTTP/1.1 304") != -1); - } - - /** - * Test invoking a conditional method implementation using the HTTP binding. - * @throws Exception - */ - public void testConditionalGetIfModifiedPositive() throws Exception { - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - int index = 1; - String content = ""; - String request = MessageFormat.format(REQUEST2, "GET", index, - "If-Modified-Since", dateFormat.format(new Date(0)), content - .getBytes().length, content); - os.write(request.getBytes()); - os.flush(); - - String document = read(client); - // Should return item - // assertTrue(document.indexOf("<body><p>item=" + index) != -1); - // Should return code 304 Not Modified. - assertTrue(document.indexOf("HTTP/1.1 304") != -1); - } - - /** - * Test invoking a conditional method implementation using the HTTP binding. - * @throws Exception - */ - public void testConditionalGetIfUnmodifiedNegative() throws Exception { - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - int index = 1; - String content = ""; - String request = MessageFormat.format(REQUEST2, "GET", index, - "If-Unmodified-Since", dateFormat.format(new Date()), content - .getBytes().length, content); - os.write(request.getBytes()); - os.flush(); - - String document = read(client); - // Should return item - assertTrue(document.indexOf("<body><p>item=" + index) != -1); - // Should return code 304 Not Modified. - // assertTrue(document.indexOf("HTTP/1.1 304") != -1); - } - - /** - * Test invoking a conditional method implementation using the HTTP binding. - * @throws Exception - */ - public void testConditionalGetIfUnmodifiedPositive() throws Exception { - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - int index = 0; - String content = ""; - String request = MessageFormat.format(REQUEST2, "GET", index, - "If-Unmodified-Since", dateFormat.format(new Date(0)), content - .getBytes().length, content); - os.write(request.getBytes()); - os.flush(); - - String document = read(client); - // Should return item - // assertTrue(document.indexOf("<body><p>item=" + index) != -1); - // Should return code 412 PreconditionFailed. - assertTrue(document.indexOf("HTTP/1.1 412") != -1); - } - - /** - * Test invoking a conditional method implementation using the HTTP binding. - * @throws Exception - */ - public void testConditionalGetIfMatchNegative() throws Exception { - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - int index = 1; - String content = ""; - String request = MessageFormat.format(REQUEST2, "GET", index, - "If-Match", "eTagXXX", content.getBytes().length, content); - os.write(request.getBytes()); - os.flush(); - - String document = read(client); - // Should return item - // assertTrue(document.indexOf("<body><p>item=" + index) != -1); - // Should return code 412 precondition failed. - assertTrue(document.indexOf("HTTP/1.1 412") != -1); - } - - /** - * Test invoking a conditional method implementation using the HTTP binding. - * @throws Exception - */ - public void testConditionalGetIfMatchPositive() throws Exception { - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - int index = 0; - String content = ""; - String request = MessageFormat.format(REQUEST2, "GET", index, - "If-Match", "eTagXXX", content.getBytes().length, content); - os.write(request.getBytes()); - os.flush(); - - String document = read(client); - // Should return item - assertTrue(document.indexOf("<body><p>item=" + index) != -1); - // Should return code 412 PreconditionFailed. - // assertTrue(document.indexOf("HTTP/1.1 412") != -1); - } - - /** - * Test invoking a conditional method implementation using the HTTP binding. - * @throws Exception - */ - public void testConditionalGetIfNoneMatchNegative() throws Exception { - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - int index = 1; - String content = ""; - String request = MessageFormat.format(REQUEST2, "GET", index, - "If-None-Match", "eTagXXX", content.getBytes().length, content); - os.write(request.getBytes()); - os.flush(); - - String document = read(client); - // Should return item - assertTrue(document.indexOf("<body><p>item=" + index) != -1); - // Should return code 412 precondition failed. - // assertTrue(document.indexOf("HTTP/1.1 412") != -1); - } - - /** - * Test invoking a conditional method implementation using the HTTP binding. - * @throws Exception - */ - public void testConditionalGetIfNoneMatchPositive() throws Exception { - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - int index = 0; - String content = ""; - String request = MessageFormat.format(REQUEST2, "GET", index, - "If-None-Match", "eTagXXX", content.getBytes().length, content); - os.write(request.getBytes()); - os.flush(); - - String document = read(client); - // Should return item - // assertTrue(document.indexOf("<body><p>item=" + index) != -1); - // Should return code 412 PreconditionFailed. - assertTrue(document.indexOf("HTTP/1.1 412") != -1); - } - - /** - * Test invoking a POJO get method implementation using the HTTP binding. - * @throws Exception - */ - public void testDelete() throws Exception { - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - int index = 0; - String content = ""; - String request = MessageFormat.format(REQUEST1, "DELETE", index, - content.getBytes().length, content); - os.write(request.getBytes()); - os.flush(); - - String document = read(client); - assertTrue(document.indexOf("deleted item=" + index) != -1); - } - - /** - * Test invoking a conditional method implementation using the HTTP binding. - * @throws Exception - */ - public void testConditionalDeleteIfModifiedNegative() throws Exception { - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - int index = 0; - String content = ""; - String request = MessageFormat.format(REQUEST2, "DELETE", index, - "If-Modified-Since", dateFormat.format(new Date(0)), content - .getBytes().length, content); - os.write(request.getBytes()); - os.flush(); - - String document = read(client); - // Should return item - assertTrue(document.indexOf("deleted item=" + index) != -1); - // Should return code 304 Not Modified. - // assertTrue(document.indexOf("HTTP/1.1 304") != -1); - } - - /** - * Test invoking a conditional method implementation using the HTTP binding. - * @throws Exception - */ - public void testConditionalDeleteIfModifiedPositive() throws Exception { - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - int index = 1; - String content = ""; - String request = MessageFormat.format(REQUEST2, "DELETE", index, - "If-Modified-Since", dateFormat.format(new Date(0)), content - .getBytes().length, content); - os.write(request.getBytes()); - os.flush(); - - String document = read(client); - // Should return item - // assertTrue(document.indexOf("deleted item=" + index) != -1); - // Should return code 304 Not Modified. - assertTrue(document.indexOf("HTTP/1.1 304") != -1); - } - - /** - * Test invoking a conditional method implementation using the HTTP binding. - * @throws Exception - */ - public void testConditionalDeleteIfUnmodifiedNegative() throws Exception { - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - int index = 1; - String content = ""; - String request = MessageFormat.format(REQUEST2, "DELETE", index, - "If-Unmodified-Since", dateFormat.format(new Date()), content - .getBytes().length, content); - os.write(request.getBytes()); - os.flush(); - - String document = read(client); - // Should return item - assertTrue(document.indexOf("deleted item=" + index) != -1); - // Should return code 304 Not Modified. - // assertTrue(document.indexOf("HTTP/1.1 304") != -1); - } - - /** - * Test invoking a conditional method implementation using the HTTP binding. - * @throws Exception - */ - public void testConditionalDeleteIfUnmodifiedPositive() throws Exception { - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - int index = 0; - String content = ""; - String request = MessageFormat.format(REQUEST2, "DELETE", index, - "If-Unmodified-Since", dateFormat.format(new Date(0)), content - .getBytes().length, content); - os.write(request.getBytes()); - os.flush(); - - String document = read(client); - // Should return item - // assertTrue(document.indexOf("deleted item=" + index) != -1); - // Should return code 412 PreconditionFailed. - assertTrue(document.indexOf("HTTP/1.1 412") != -1); - } - - /** - * Test invoking a conditional method implementation using the HTTP binding. - * @throws Exception - */ - public void testConditionalDeleteIfMatchNegative() throws Exception { - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - int index = 1; - String content = ""; - String request = MessageFormat.format(REQUEST2, "DELETE", index, - "If-Match", "eTagXXX", content.getBytes().length, content); - os.write(request.getBytes()); - os.flush(); - - String document = read(client); - // Should return item - // assertTrue(document.indexOf("deleted item=" + index) != -1); - // Should return code 412 precondition failed. - assertTrue(document.indexOf("HTTP/1.1 412") != -1); - } - - /** - * Test invoking a conditional method implementation using the HTTP binding. - * @throws Exception - */ - public void testConditionalDeleteIfMatchPositive() throws Exception { - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - int index = 0; - String content = ""; - String request = MessageFormat.format(REQUEST2, "DELETE", index, - "If-Match", "eTagXXX", content.getBytes().length, content); - os.write(request.getBytes()); - os.flush(); - - String document = read(client); - // Should return item - assertTrue(document.indexOf("deleted item=" + index) != -1); - // Should return code 412 PreconditionFailed. - // assertTrue(document.indexOf("HTTP/1.1 412") != -1); - } - - /** - * Test invoking a conditional method implementation using the HTTP binding. - * @throws Exception - */ - public void testConditionalDeleteIfNoneMatchNegative() throws Exception { - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - int index = 1; - String content = ""; - String request = MessageFormat.format(REQUEST2, "DELETE", index, - "If-None-Match", "eTagXXX", content.getBytes().length, content); - os.write(request.getBytes()); - os.flush(); - - String document = read(client); - // Should return item - assertTrue(document.indexOf("deleted item=" + index) != -1); - // Should return code 412 precondition failed. - // assertTrue(document.indexOf("HTTP/1.1 412") != -1); - } - - /** - * Test invoking a conditional method implementation using the HTTP binding. - * @throws Exception - */ - public void testConditionalDeleteIfNoneMatchPositive() throws Exception { - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - int index = 0; - String content = ""; - String request = MessageFormat.format(REQUEST2, "DELETE", index, - "If-None-Match", "eTagXXX", content.getBytes().length, content); - os.write(request.getBytes()); - os.flush(); - - String document = read(client); - // Should return item - // assertTrue(document.indexOf("deleted item=" + index) != -1); - // Should return code 412 PreconditionFailed. - assertTrue(document.indexOf("HTTP/1.1 412") != -1); - } - - /** - * Test invoking a POJO get method implementation using the HTTP binding. - * @throws Exception - */ - public void testPost() throws Exception { - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - int index = 0; - String content = ""; - String request = MessageFormat.format(REQUEST1, "POST", index, content - .getBytes().length, content); - os.write(request.getBytes()); - os.flush(); - - String document = read(client); - assertTrue(document.indexOf("HTTP/1.1 200 OK") != -1); - } - - /** - * Test invoking a conditional method implementation using the HTTP binding. - * @throws Exception - */ - public void testConditionalPostIfModifiedNegative() throws Exception { - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - int index = 0; - String content = ""; - String request = MessageFormat.format(REQUEST2, "POST", index, - "If-Modified-Since", dateFormat.format(new Date()), content - .getBytes().length, content); - os.write(request.getBytes()); - os.flush(); - - String document = read(client); - // Should return code 200 OK - // assertTrue(document.indexOf("posted item=" + index) != -1); - assertTrue(document.indexOf("HTTP/1.1 200 OK") != -1); - // Should return code 304 Not Modified. - // assertTrue(document.indexOf("HTTP/1.1 304") != -1); - } - - /** - * Test invoking a conditional method implementation using the HTTP binding. - * @throws Exception - */ - public void testConditionalPostIfModifiedPositive() throws Exception { - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - int index = 1; - String content = ""; - String request = MessageFormat.format(REQUEST2, "POST", index, - "If-Modified-Since", dateFormat.format(new Date(0)), content - .getBytes().length, content); - os.write(request.getBytes()); - os.flush(); - - String document = read(client); - // Should return item - // assertTrue(document.indexOf("posted item=" + index) != -1); - // Should return code 304 Not Modified. - assertTrue(document.indexOf("HTTP/1.1 304") != -1); - } - - /** - * Test invoking a conditional method implementation using the HTTP binding. - * @throws Exception - */ - public void testConditionalPostIfUnmodifiedNegative() throws Exception { - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - int index = 1; - String content = ""; - String request = MessageFormat.format(REQUEST2, "POST", index, - "If-Unmodified-Since", dateFormat.format(new Date()), content - .getBytes().length, content); - os.write(request.getBytes()); - os.flush(); - - String document = read(client); - // Should return code 200 OK - assertTrue(document.indexOf("HTTP/1.1 200 OK") != -1); - // Should return code 304 Not Modified. - // assertTrue(document.indexOf("HTTP/1.1 304") != -1); - } - - /** - * Test invoking a conditional method implementation using the HTTP binding. - * @throws Exception - */ - public void testConditionalPostIfUnmodifiedPositive() throws Exception { - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - int index = 0; - String content = ""; - String request = MessageFormat.format(REQUEST2, "POST", index, - "If-Unmodified-Since", dateFormat.format(new Date(0)), content - .getBytes().length, content); - os.write(request.getBytes()); - os.flush(); - - String document = read(client); - // Should return item - // assertTrue(document.indexOf("posted item=" + index) != -1); - // Should return code 412 PreconditionFailed. - assertTrue(document.indexOf("HTTP/1.1 412") != -1); - } - - /** - * Test invoking a conditional method implementation using the HTTP binding. - * @throws Exception - */ - public void testConditionalPostIfMatchNegative() throws Exception { - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - int index = 1; - String content = ""; - String request = MessageFormat.format(REQUEST2, "POST", index, - "If-Match", "eTagMatch", content.getBytes().length, content); - os.write(request.getBytes()); - os.flush(); - - String document = read(client); - // Should return code 200 OK. - assertTrue(document.indexOf("HTTP/1.1 200 OK") != -1); - // Should return code 412 precondition failed. - // assertTrue(document.indexOf("HTTP/1.1 412") != -1); - } - - /** - * Test invoking a conditional method implementation using the HTTP binding. - * @throws Exception - */ - public void testConditionalPostIfMatchPositive() throws Exception { - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - int index = 0; - String content = ""; - String request = MessageFormat - .format(REQUEST2, "POST", index, "If-Match", "eTagNoneMatch", - content.getBytes().length, content); - os.write(request.getBytes()); - os.flush(); - - String document = read(client); - // Should return item - // assertTrue(document.indexOf("posted item=" + index) != -1); - // Should return code 412 PreconditionFailed. - assertTrue(document.indexOf("HTTP/1.1 412") != -1); - } - - /** - * Test invoking a conditional method implementation using the HTTP binding. - * @throws Exception - */ - public void testConditionalPostIfNoneMatchNegative() throws Exception { - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - int index = 1; - String content = ""; - String request = MessageFormat.format(REQUEST2, "POST", index, - "If-None-Match", "eTagNoneMatch", content.getBytes().length, - content); - os.write(request.getBytes()); - os.flush(); - - String document = read(client); - // Should return code 200 OK - assertTrue(document.indexOf("HTTP/1.1 200 OK") != -1); - // Should return code 412 precondition failed. - // assertTrue(document.indexOf("HTTP/1.1 412") != -1); - } - - /** - * Test invoking a conditional method implementation using the HTTP binding. - * @throws Exception - */ - public void testConditionalPostIfNoneMatchPositive() throws Exception { - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - int index = 0; - String content = ""; - String request = MessageFormat.format(REQUEST2, "POST", index, - "If-None-Match", "eTagMatch", content.getBytes().length, - content); - os.write(request.getBytes()); - os.flush(); - - String document = read(client); - // Should return item - // assertTrue(document.indexOf("posted item=" + index) != -1); - // Should return code 412 PreconditionFailed. - assertTrue(document.indexOf("HTTP/1.1 412") != -1); - } - - /** - * Test invoking a POJO get method implementation using the HTTP binding. - * @throws Exception - */ - public void testPut() throws Exception { - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - int index = 0; - String content = ""; - String request = MessageFormat.format(REQUEST1, "PUT", index, content - .getBytes().length, content); - os.write(request.getBytes()); - os.flush(); - - String document = read(client); - assertTrue(document.indexOf("updated item=" + index) != -1); - } - - /** - * Test invoking a conditional method implementation using the HTTP binding. - * @throws Exception - */ - public void testConditionalPutIfModifiedNegative() throws Exception { - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - int index = 0; - String content = ""; - String request = MessageFormat.format(REQUEST2, "PUT", index, - "If-Modified-Since", dateFormat.format(new Date(0)), content - .getBytes().length, content); - os.write(request.getBytes()); - os.flush(); - - String document = read(client); - // Should return item - assertTrue(document.indexOf("updated item=" + index) != -1); - // Should return code 304 Not Modified. - // assertTrue(document.indexOf("HTTP/1.1 304") != -1); - } - - /** - * Test invoking a conditional method implementation using the HTTP binding. - * @throws Exception - */ - public void testConditionalPutIfModifiedPositive() throws Exception { - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - int index = 1; - String content = ""; - String request = MessageFormat.format(REQUEST2, "PUT", index, - "If-Modified-Since", dateFormat.format(new Date(0)), content - .getBytes().length, content); - os.write(request.getBytes()); - os.flush(); - - String document = read(client); - // Should return item - // assertTrue(document.indexOf("updated item=" + index) != -1); - // Should return code 304 Not Modified. - assertTrue(document.indexOf("HTTP/1.1 304") != -1); - } - - /** - * Test invoking a conditional method implementation using the HTTP binding. - * @throws Exception - */ - public void testConditionalPutIfUnmodifiedNegative() throws Exception { - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - int index = 1; - String content = ""; - String request = MessageFormat.format(REQUEST2, "PUT", index, - "If-Unmodified-Since", dateFormat.format(new Date()), content - .getBytes().length, content); - os.write(request.getBytes()); - os.flush(); - - String document = read(client); - // Should return item - assertTrue(document.indexOf("updated item=" + index) != -1); - // Should return code 304 Not Modified. - // assertTrue(document.indexOf("HTTP/1.1 304") != -1); - } - - /** - * Test invoking a conditional method implementation using the HTTP binding. - * @throws Exception - */ - public void testConditionalPutIfUnmodifiedPositive() throws Exception { - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - int index = 0; - String content = ""; - String request = MessageFormat.format(REQUEST2, "PUT", index, - "If-Unmodified-Since", dateFormat.format(new Date(0)), content - .getBytes().length, content); - os.write(request.getBytes()); - os.flush(); - - String document = read(client); - // Should return item - // assertTrue(document.indexOf("updated item=" + index) != -1); - // Should return code 412 PreconditionFailed. - assertTrue(document.indexOf("HTTP/1.1 412") != -1); - } - - /** - * Test invoking a conditional method implementation using the HTTP binding. - * @throws Exception - */ - public void testConditionalPutIfMatchNegative() throws Exception { - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - int index = 1; - String content = ""; - String request = MessageFormat.format(REQUEST2, "PUT", index, - "If-Match", "eTagXXX", content.getBytes().length, content); - os.write(request.getBytes()); - os.flush(); - - String document = read(client); - // Should return item - // assertTrue(document.indexOf("updated item=" + index) != -1); - // Should return code 412 precondition failed. - assertTrue(document.indexOf("HTTP/1.1 412") != -1); - } - - /** - * Test invoking a conditional method implementation using the HTTP binding. - * @throws Exception - */ - public void testConditionalPutIfMatchPositive() throws Exception { - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - int index = 0; - String content = ""; - String request = MessageFormat.format(REQUEST2, "PUT", index, - "If-Match", "eTagXXX", content.getBytes().length, content); - os.write(request.getBytes()); - os.flush(); - - String document = read(client); - // Should return item - assertTrue(document.indexOf("updated item=" + index) != -1); - // Should return code 412 PreconditionFailed. - // assertTrue(document.indexOf("HTTP/1.1 412") != -1); - } - - /** - * Test invoking a conditional method implementation using the HTTP binding. - * @throws Exception - */ - public void testConditionalPutIfNoneMatchNegative() throws Exception { - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - int index = 1; - String content = ""; - String request = MessageFormat.format(REQUEST2, "PUT", index, - "If-None-Match", "eTagXXX", content.getBytes().length, content); - os.write(request.getBytes()); - os.flush(); - - String document = read(client); - // Should return item - assertTrue(document.indexOf("updated item=" + index) != -1); - // Should return code 412 precondition failed. - // assertTrue(document.indexOf("HTTP/1.1 412") != -1); - } - - /** - * Test invoking a conditional method implementation using the HTTP binding. - * @throws Exception - */ - public void testConditionalPutIfNoneMatchPositive() throws Exception { - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - int index = 0; - String content = ""; - String request = MessageFormat.format(REQUEST2, "PUT", index, - "If-None-Match", "eTagXXX", content.getBytes().length, content); - os.write(request.getBytes()); - os.flush(); - - String document = read(client); - // Should return item - // assertTrue(document.indexOf("updated item=" + index) != -1); - // Should return code 412 PreconditionFailed. - assertTrue(document.indexOf("HTTP/1.1 412") != -1); - } - - /** - * Read response stream from the given socket. - * @param socket - * @return - * @throws IOException - */ - private static String read(Socket socket) throws IOException { - BufferedReader reader = null; - try { - reader = new BufferedReader(new InputStreamReader(socket - .getInputStream())); - StringBuffer sb = new StringBuffer(); - String str; - while ((str = reader.readLine()) != null) { - sb.append(str); - } - return sb.toString(); - } finally { - if (reader != null) { - reader.close(); - } - } - } + // RFC 822 date time + protected static final SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z"); + + // Request with no predicates in header. + private static final String REQUEST1 = "{0} /httpbinding/{1} HTTP/1.0\n" + "Host: localhost\n" + "Content-Type: text/xml\n" + "Connection: close\n" + "Content-Length: {2}" + "\n\n{3}"; + + // Request with predicates in header + private static final String REQUEST2 = "{0} /httpbinding/{1} HTTP/1.0\n" + "Host: localhost\n" + "Content-Type: text/xml\n" + "{2}: {3}\n" // predicate + // ( + // If + // - + // Match + // , + // If + // - + // None + // - + // Match + // , + // If + // - + // Modified + // - + // Since + // , + // If + // - + // NotModified + // - + // Since + // ) + // : + // value + // ( + // date + // or + // ETag + // ) + + "Connection: close\n" + + "Content-Length: {4}" + + "\n\n{5}"; + + private static final int HTTP_PORT = 8085; + + private Node node; + + @Override + protected void setUp() throws Exception { + String contribution = ContributionLocationHelper.getContributionLocation(HTTPBindingCacheTestCase.class); + node = NodeFactory.newInstance().createNode("testCache.composite", new Contribution("test", contribution)); + node.start(); + } + + @Override + protected void tearDown() throws Exception { + node.stop(); + node.destroy(); + } + + /** + * Test invoking a POJO get method implementation using the HTTP binding. + * + * @throws Exception + */ + public void testGet() throws Exception { + Socket client = new Socket("127.0.0.1", HTTP_PORT); + OutputStream os = client.getOutputStream(); + int index = 0; + String content = ""; + String request = MessageFormat.format(REQUEST1, "GET", index, content.getBytes().length, content); + os.write(request.getBytes()); + os.flush(); + + String document = read(client); + assertTrue(document.indexOf("<body><p>item=" + index) != -1); + } + + /** + * Test invoking a conditional method implementation using the HTTP binding. + * + * @throws Exception + */ + public void testConditionalGetIfModifiedNegative() throws Exception { + Socket client = new Socket("127.0.0.1", HTTP_PORT); + OutputStream os = client.getOutputStream(); + int index = 0; + String content = ""; + String request = MessageFormat.format(REQUEST2, "GET", index, "If-Modified-Since", dateFormat.format(new Date(0)), content.getBytes().length, content); + os.write(request.getBytes()); + os.flush(); + + String document = read(client); + // Should return item + assertTrue(document.indexOf("<body><p>item=" + index) != -1); + // Should return code 304 Not Modified. + // assertTrue(document.indexOf("HTTP/1.1 304") != -1); + } + + /** + * Test invoking a conditional method implementation using the HTTP binding. + * + * @throws Exception + */ + public void testConditionalGetIfModifiedPositive() throws Exception { + Socket client = new Socket("127.0.0.1", HTTP_PORT); + OutputStream os = client.getOutputStream(); + int index = 1; + String content = ""; + String request = MessageFormat.format(REQUEST2, "GET", index, "If-Modified-Since", dateFormat.format(new Date(0)), content.getBytes().length, content); + os.write(request.getBytes()); + os.flush(); + + String document = read(client); + // Should return item + // assertTrue(document.indexOf("<body><p>item=" + index) != -1); + // Should return code 304 Not Modified. + assertTrue(document.indexOf("HTTP/1.1 304") != -1); + } + + /** + * Test invoking a conditional method implementation using the HTTP binding. + * + * @throws Exception + */ + public void testConditionalGetIfUnmodifiedNegative() throws Exception { + Socket client = new Socket("127.0.0.1", HTTP_PORT); + OutputStream os = client.getOutputStream(); + int index = 1; + String content = ""; + String request = MessageFormat.format(REQUEST2, "GET", index, "If-Unmodified-Since", dateFormat.format(new Date()), content.getBytes().length, content); + os.write(request.getBytes()); + os.flush(); + + String document = read(client); + // Should return item + assertTrue(document.indexOf("<body><p>item=" + index) != -1); + // Should return code 304 Not Modified. + // assertTrue(document.indexOf("HTTP/1.1 304") != -1); + } + + /** + * Test invoking a conditional method implementation using the HTTP binding. + * + * @throws Exception + */ + public void testConditionalGetIfUnmodifiedPositive() throws Exception { + Socket client = new Socket("127.0.0.1", HTTP_PORT); + OutputStream os = client.getOutputStream(); + int index = 0; + String content = ""; + String request = MessageFormat.format(REQUEST2, "GET", index, "If-Unmodified-Since", dateFormat.format(new Date(0)), content.getBytes().length, content); + os.write(request.getBytes()); + os.flush(); + + String document = read(client); + // Should return item + // assertTrue(document.indexOf("<body><p>item=" + index) != -1); + // Should return code 412 PreconditionFailed. + assertTrue(document.indexOf("HTTP/1.1 412") != -1); + } + + /** + * Test invoking a conditional method implementation using the HTTP binding. + * + * @throws Exception + */ + public void testConditionalGetIfMatchNegative() throws Exception { + Socket client = new Socket("127.0.0.1", HTTP_PORT); + OutputStream os = client.getOutputStream(); + int index = 1; + String content = ""; + String request = MessageFormat.format(REQUEST2, "GET", index, "If-Match", "eTagXXX", content.getBytes().length, content); + os.write(request.getBytes()); + os.flush(); + + String document = read(client); + // Should return item + // assertTrue(document.indexOf("<body><p>item=" + index) != -1); + // Should return code 412 precondition failed. + assertTrue(document.indexOf("HTTP/1.1 412") != -1); + } + + /** + * Test invoking a conditional method implementation using the HTTP binding. + * + * @throws Exception + */ + public void testConditionalGetIfMatchPositive() throws Exception { + Socket client = new Socket("127.0.0.1", HTTP_PORT); + OutputStream os = client.getOutputStream(); + int index = 0; + String content = ""; + String request = MessageFormat.format(REQUEST2, "GET", index, "If-Match", "eTagXXX", content.getBytes().length, content); + os.write(request.getBytes()); + os.flush(); + + String document = read(client); + // Should return item + assertTrue(document.indexOf("<body><p>item=" + index) != -1); + // Should return code 412 PreconditionFailed. + // assertTrue(document.indexOf("HTTP/1.1 412") != -1); + } + + /** + * Test invoking a conditional method implementation using the HTTP binding. + * + * @throws Exception + */ + public void testConditionalGetIfNoneMatchNegative() throws Exception { + Socket client = new Socket("127.0.0.1", HTTP_PORT); + OutputStream os = client.getOutputStream(); + int index = 1; + String content = ""; + String request = MessageFormat.format(REQUEST2, "GET", index, "If-None-Match", "eTagXXX", content.getBytes().length, content); + os.write(request.getBytes()); + os.flush(); + + String document = read(client); + // Should return item + assertTrue(document.indexOf("<body><p>item=" + index) != -1); + // Should return code 412 precondition failed. + // assertTrue(document.indexOf("HTTP/1.1 412") != -1); + } + + /** + * Test invoking a conditional method implementation using the HTTP binding. + * + * @throws Exception + */ + public void testConditionalGetIfNoneMatchPositive() throws Exception { + Socket client = new Socket("127.0.0.1", HTTP_PORT); + OutputStream os = client.getOutputStream(); + int index = 0; + String content = ""; + String request = MessageFormat.format(REQUEST2, "GET", index, "If-None-Match", "eTagXXX", content.getBytes().length, content); + os.write(request.getBytes()); + os.flush(); + + String document = read(client); + // Should return item + // assertTrue(document.indexOf("<body><p>item=" + index) != -1); + // Should return code 412 PreconditionFailed. + assertTrue(document.indexOf("HTTP/1.1 412") != -1); + } + + /** + * Test invoking a POJO get method implementation using the HTTP binding. + * + * @throws Exception + */ + public void testDelete() throws Exception { + Socket client = new Socket("127.0.0.1", HTTP_PORT); + OutputStream os = client.getOutputStream(); + int index = 0; + String content = ""; + String request = MessageFormat.format(REQUEST1, "DELETE", index, content.getBytes().length, content); + os.write(request.getBytes()); + os.flush(); + + String document = read(client); + assertTrue(document.indexOf("deleted item=" + index) != -1); + } + + /** + * Test invoking a conditional method implementation using the HTTP binding. + * + * @throws Exception + */ + public void testConditionalDeleteIfModifiedNegative() throws Exception { + Socket client = new Socket("127.0.0.1", HTTP_PORT); + OutputStream os = client.getOutputStream(); + int index = 0; + String content = ""; + String request = MessageFormat.format(REQUEST2, "DELETE", index, "If-Modified-Since", dateFormat.format(new Date(0)), content.getBytes().length, content); + os.write(request.getBytes()); + os.flush(); + + String document = read(client); + // Should return item + assertTrue(document.indexOf("deleted item=" + index) != -1); + // Should return code 304 Not Modified. + // assertTrue(document.indexOf("HTTP/1.1 304") != -1); + } + + /** + * Test invoking a conditional method implementation using the HTTP binding. + * + * @throws Exception + */ + public void testConditionalDeleteIfModifiedPositive() throws Exception { + Socket client = new Socket("127.0.0.1", HTTP_PORT); + OutputStream os = client.getOutputStream(); + int index = 1; + String content = ""; + String request = MessageFormat.format(REQUEST2, "DELETE", index, "If-Modified-Since", dateFormat.format(new Date(0)), content.getBytes().length, content); + os.write(request.getBytes()); + os.flush(); + + String document = read(client); + // Should return item + // assertTrue(document.indexOf("deleted item=" + index) != -1); + // Should return code 304 Not Modified. + assertTrue(document.indexOf("HTTP/1.1 304") != -1); + } + + /** + * Test invoking a conditional method implementation using the HTTP binding. + * + * @throws Exception + */ + public void testConditionalDeleteIfUnmodifiedNegative() throws Exception { + Socket client = new Socket("127.0.0.1", HTTP_PORT); + OutputStream os = client.getOutputStream(); + int index = 1; + String content = ""; + String request = MessageFormat.format(REQUEST2, "DELETE", index, "If-Unmodified-Since", dateFormat.format(new Date()), content.getBytes().length, content); + os.write(request.getBytes()); + os.flush(); + + String document = read(client); + // Should return item + assertTrue(document.indexOf("deleted item=" + index) != -1); + // Should return code 304 Not Modified. + // assertTrue(document.indexOf("HTTP/1.1 304") != -1); + } + + /** + * Test invoking a conditional method implementation using the HTTP binding. + * + * @throws Exception + */ + public void testConditionalDeleteIfUnmodifiedPositive() throws Exception { + Socket client = new Socket("127.0.0.1", HTTP_PORT); + OutputStream os = client.getOutputStream(); + int index = 0; + String content = ""; + String request = MessageFormat.format(REQUEST2, "DELETE", index, "If-Unmodified-Since", dateFormat.format(new Date(0)), content.getBytes().length, content); + os.write(request.getBytes()); + os.flush(); + + String document = read(client); + // Should return item + // assertTrue(document.indexOf("deleted item=" + index) != -1); + // Should return code 412 PreconditionFailed. + assertTrue(document.indexOf("HTTP/1.1 412") != -1); + } + + /** + * Test invoking a conditional method implementation using the HTTP binding. + * + * @throws Exception + */ + public void testConditionalDeleteIfMatchNegative() throws Exception { + Socket client = new Socket("127.0.0.1", HTTP_PORT); + OutputStream os = client.getOutputStream(); + int index = 1; + String content = ""; + String request = MessageFormat.format(REQUEST2, "DELETE", index, "If-Match", "eTagXXX", content.getBytes().length, content); + os.write(request.getBytes()); + os.flush(); + + String document = read(client); + // Should return item + // assertTrue(document.indexOf("deleted item=" + index) != -1); + // Should return code 412 precondition failed. + assertTrue(document.indexOf("HTTP/1.1 412") != -1); + } + + /** + * Test invoking a conditional method implementation using the HTTP binding. + * + * @throws Exception + */ + public void testConditionalDeleteIfMatchPositive() throws Exception { + Socket client = new Socket("127.0.0.1", HTTP_PORT); + OutputStream os = client.getOutputStream(); + int index = 0; + String content = ""; + String request = MessageFormat.format(REQUEST2, "DELETE", index, "If-Match", "eTagXXX", content.getBytes().length, content); + os.write(request.getBytes()); + os.flush(); + + String document = read(client); + // Should return item + assertTrue(document.indexOf("deleted item=" + index) != -1); + // Should return code 412 PreconditionFailed. + // assertTrue(document.indexOf("HTTP/1.1 412") != -1); + } + + /** + * Test invoking a conditional method implementation using the HTTP binding. + * + * @throws Exception + */ + public void testConditionalDeleteIfNoneMatchNegative() throws Exception { + Socket client = new Socket("127.0.0.1", HTTP_PORT); + OutputStream os = client.getOutputStream(); + int index = 1; + String content = ""; + String request = MessageFormat.format(REQUEST2, "DELETE", index, "If-None-Match", "eTagXXX", content.getBytes().length, content); + os.write(request.getBytes()); + os.flush(); + + String document = read(client); + // Should return item + assertTrue(document.indexOf("deleted item=" + index) != -1); + // Should return code 412 precondition failed. + // assertTrue(document.indexOf("HTTP/1.1 412") != -1); + } + + /** + * Test invoking a conditional method implementation using the HTTP binding. + * + * @throws Exception + */ + public void testConditionalDeleteIfNoneMatchPositive() throws Exception { + Socket client = new Socket("127.0.0.1", HTTP_PORT); + OutputStream os = client.getOutputStream(); + int index = 0; + String content = ""; + String request = MessageFormat.format(REQUEST2, "DELETE", index, "If-None-Match", "eTagXXX", content.getBytes().length, content); + os.write(request.getBytes()); + os.flush(); + + String document = read(client); + // Should return item + // assertTrue(document.indexOf("deleted item=" + index) != -1); + // Should return code 412 PreconditionFailed. + assertTrue(document.indexOf("HTTP/1.1 412") != -1); + } + + /** + * Test invoking a POJO get method implementation using the HTTP binding. + * + * @throws Exception + */ + public void testPost() throws Exception { + Socket client = new Socket("127.0.0.1", HTTP_PORT); + OutputStream os = client.getOutputStream(); + int index = 0; + String content = ""; + String request = MessageFormat.format(REQUEST1, "POST", index, content.getBytes().length, content); + os.write(request.getBytes()); + os.flush(); + + String document = read(client); + assertTrue(document.indexOf("HTTP/1.1 200 OK") != -1); + } + + /** + * Test invoking a conditional method implementation using the HTTP binding. + * + * @throws Exception + */ + public void testConditionalPostIfModifiedNegative() throws Exception { + Socket client = new Socket("127.0.0.1", HTTP_PORT); + OutputStream os = client.getOutputStream(); + int index = 0; + String content = ""; + String request = MessageFormat.format(REQUEST2, "POST", index, "If-Modified-Since", dateFormat.format(new Date()), content.getBytes().length, content); + os.write(request.getBytes()); + os.flush(); + + String document = read(client); + // Should return code 200 OK + // assertTrue(document.indexOf("posted item=" + index) != -1); + assertTrue(document.indexOf("HTTP/1.1 200 OK") != -1); + // Should return code 304 Not Modified. + // assertTrue(document.indexOf("HTTP/1.1 304") != -1); + } + + /** + * Test invoking a conditional method implementation using the HTTP binding. + * + * @throws Exception + */ + public void testConditionalPostIfModifiedPositive() throws Exception { + Socket client = new Socket("127.0.0.1", HTTP_PORT); + OutputStream os = client.getOutputStream(); + int index = 1; + String content = ""; + String request = MessageFormat.format(REQUEST2, "POST", index, "If-Modified-Since", dateFormat.format(new Date(0)), content.getBytes().length, content); + os.write(request.getBytes()); + os.flush(); + + String document = read(client); + // Should return item + // assertTrue(document.indexOf("posted item=" + index) != -1); + // Should return code 304 Not Modified. + assertTrue(document.indexOf("HTTP/1.1 304") != -1); + } + + /** + * Test invoking a conditional method implementation using the HTTP binding. + * + * @throws Exception + */ + public void testConditionalPostIfUnmodifiedNegative() throws Exception { + Socket client = new Socket("127.0.0.1", HTTP_PORT); + OutputStream os = client.getOutputStream(); + int index = 1; + String content = ""; + String request = MessageFormat.format(REQUEST2, "POST", index, "If-Unmodified-Since", dateFormat.format(new Date()), content.getBytes().length, content); + os.write(request.getBytes()); + os.flush(); + + String document = read(client); + // Should return code 200 OK + assertTrue(document.indexOf("HTTP/1.1 200 OK") != -1); + // Should return code 304 Not Modified. + // assertTrue(document.indexOf("HTTP/1.1 304") != -1); + } + + /** + * Test invoking a conditional method implementation using the HTTP binding. + * + * @throws Exception + */ + public void testConditionalPostIfUnmodifiedPositive() throws Exception { + Socket client = new Socket("127.0.0.1", HTTP_PORT); + OutputStream os = client.getOutputStream(); + int index = 0; + String content = ""; + String request = MessageFormat.format(REQUEST2, "POST", index, "If-Unmodified-Since", dateFormat.format(new Date(0)), content.getBytes().length, content); + os.write(request.getBytes()); + os.flush(); + + String document = read(client); + // Should return item + // assertTrue(document.indexOf("posted item=" + index) != -1); + // Should return code 412 PreconditionFailed. + assertTrue(document.indexOf("HTTP/1.1 412") != -1); + } + + /** + * Test invoking a conditional method implementation using the HTTP binding. + * + * @throws Exception + */ + public void testConditionalPostIfMatchNegative() throws Exception { + Socket client = new Socket("127.0.0.1", HTTP_PORT); + OutputStream os = client.getOutputStream(); + int index = 1; + String content = ""; + String request = MessageFormat.format(REQUEST2, "POST", index, "If-Match", "eTagMatch", content.getBytes().length, content); + os.write(request.getBytes()); + os.flush(); + + String document = read(client); + // Should return code 200 OK. + assertTrue(document.indexOf("HTTP/1.1 200 OK") != -1); + // Should return code 412 precondition failed. + // assertTrue(document.indexOf("HTTP/1.1 412") != -1); + } + + /** + * Test invoking a conditional method implementation using the HTTP binding. + * + * @throws Exception + */ + public void testConditionalPostIfMatchPositive() throws Exception { + Socket client = new Socket("127.0.0.1", HTTP_PORT); + OutputStream os = client.getOutputStream(); + int index = 0; + String content = ""; + String request = MessageFormat.format(REQUEST2, "POST", index, "If-Match", "eTagNoneMatch", content.getBytes().length, content); + os.write(request.getBytes()); + os.flush(); + + String document = read(client); + // Should return item + // assertTrue(document.indexOf("posted item=" + index) != -1); + // Should return code 412 PreconditionFailed. + assertTrue(document.indexOf("HTTP/1.1 412") != -1); + } + + /** + * Test invoking a conditional method implementation using the HTTP binding. + * + * @throws Exception + */ + public void testConditionalPostIfNoneMatchNegative() throws Exception { + Socket client = new Socket("127.0.0.1", HTTP_PORT); + OutputStream os = client.getOutputStream(); + int index = 1; + String content = ""; + String request = MessageFormat.format(REQUEST2, "POST", index, "If-None-Match", "eTagNoneMatch", content.getBytes().length, content); + os.write(request.getBytes()); + os.flush(); + + String document = read(client); + // Should return code 200 OK + assertTrue(document.indexOf("HTTP/1.1 200 OK") != -1); + // Should return code 412 precondition failed. + // assertTrue(document.indexOf("HTTP/1.1 412") != -1); + } + + /** + * Test invoking a conditional method implementation using the HTTP binding. + * + * @throws Exception + */ + public void testConditionalPostIfNoneMatchPositive() throws Exception { + Socket client = new Socket("127.0.0.1", HTTP_PORT); + OutputStream os = client.getOutputStream(); + int index = 0; + String content = ""; + String request = MessageFormat.format(REQUEST2, "POST", index, "If-None-Match", "eTagMatch", content.getBytes().length, content); + os.write(request.getBytes()); + os.flush(); + + String document = read(client); + // Should return item + // assertTrue(document.indexOf("posted item=" + index) != -1); + // Should return code 412 PreconditionFailed. + assertTrue(document.indexOf("HTTP/1.1 412") != -1); + } + + /** + * Test invoking a POJO get method implementation using the HTTP binding. + * + * @throws Exception + */ + public void testPut() throws Exception { + Socket client = new Socket("127.0.0.1", HTTP_PORT); + OutputStream os = client.getOutputStream(); + int index = 0; + String content = ""; + String request = MessageFormat.format(REQUEST1, "PUT", index, content.getBytes().length, content); + os.write(request.getBytes()); + os.flush(); + + String document = read(client); + assertTrue(document.indexOf("updated item=" + index) != -1); + } + + /** + * Test invoking a conditional method implementation using the HTTP binding. + * + * @throws Exception + */ + public void testConditionalPutIfModifiedNegative() throws Exception { + Socket client = new Socket("127.0.0.1", HTTP_PORT); + OutputStream os = client.getOutputStream(); + int index = 0; + String content = ""; + String request = MessageFormat.format(REQUEST2, "PUT", index, "If-Modified-Since", dateFormat.format(new Date(0)), content.getBytes().length, content); + os.write(request.getBytes()); + os.flush(); + + String document = read(client); + // Should return item + assertTrue(document.indexOf("updated item=" + index) != -1); + // Should return code 304 Not Modified. + // assertTrue(document.indexOf("HTTP/1.1 304") != -1); + } + + /** + * Test invoking a conditional method implementation using the HTTP binding. + * + * @throws Exception + */ + public void testConditionalPutIfModifiedPositive() throws Exception { + Socket client = new Socket("127.0.0.1", HTTP_PORT); + OutputStream os = client.getOutputStream(); + int index = 1; + String content = ""; + String request = MessageFormat.format(REQUEST2, "PUT", index, "If-Modified-Since", dateFormat.format(new Date(0)), content.getBytes().length, content); + os.write(request.getBytes()); + os.flush(); + + String document = read(client); + // Should return item + // assertTrue(document.indexOf("updated item=" + index) != -1); + // Should return code 304 Not Modified. + assertTrue(document.indexOf("HTTP/1.1 304") != -1); + } + + /** + * Test invoking a conditional method implementation using the HTTP binding. + * + * @throws Exception + */ + public void testConditionalPutIfUnmodifiedNegative() throws Exception { + Socket client = new Socket("127.0.0.1", HTTP_PORT); + OutputStream os = client.getOutputStream(); + int index = 1; + String content = ""; + String request = MessageFormat.format(REQUEST2, "PUT", index, "If-Unmodified-Since", dateFormat.format(new Date()), content.getBytes().length, content); + os.write(request.getBytes()); + os.flush(); + + String document = read(client); + // Should return item + assertTrue(document.indexOf("updated item=" + index) != -1); + // Should return code 304 Not Modified. + // assertTrue(document.indexOf("HTTP/1.1 304") != -1); + } + + /** + * Test invoking a conditional method implementation using the HTTP binding. + * + * @throws Exception + */ + public void testConditionalPutIfUnmodifiedPositive() throws Exception { + Socket client = new Socket("127.0.0.1", HTTP_PORT); + OutputStream os = client.getOutputStream(); + int index = 0; + String content = ""; + String request = MessageFormat.format(REQUEST2, "PUT", index, "If-Unmodified-Since", dateFormat.format(new Date(0)), content.getBytes().length, content); + os.write(request.getBytes()); + os.flush(); + + String document = read(client); + // Should return item + // assertTrue(document.indexOf("updated item=" + index) != -1); + // Should return code 412 PreconditionFailed. + assertTrue(document.indexOf("HTTP/1.1 412") != -1); + } + + /** + * Test invoking a conditional method implementation using the HTTP binding. + * + * @throws Exception + */ + public void testConditionalPutIfMatchNegative() throws Exception { + Socket client = new Socket("127.0.0.1", HTTP_PORT); + OutputStream os = client.getOutputStream(); + int index = 1; + String content = ""; + String request = MessageFormat.format(REQUEST2, "PUT", index, "If-Match", "eTagXXX", content.getBytes().length, content); + os.write(request.getBytes()); + os.flush(); + + String document = read(client); + // Should return item + // assertTrue(document.indexOf("updated item=" + index) != -1); + // Should return code 412 precondition failed. + assertTrue(document.indexOf("HTTP/1.1 412") != -1); + } + + /** + * Test invoking a conditional method implementation using the HTTP binding. + * + * @throws Exception + */ + public void testConditionalPutIfMatchPositive() throws Exception { + Socket client = new Socket("127.0.0.1", HTTP_PORT); + OutputStream os = client.getOutputStream(); + int index = 0; + String content = ""; + String request = MessageFormat.format(REQUEST2, "PUT", index, "If-Match", "eTagXXX", content.getBytes().length, content); + os.write(request.getBytes()); + os.flush(); + + String document = read(client); + // Should return item + assertTrue(document.indexOf("updated item=" + index) != -1); + // Should return code 412 PreconditionFailed. + // assertTrue(document.indexOf("HTTP/1.1 412") != -1); + } + + /** + * Test invoking a conditional method implementation using the HTTP binding. + * + * @throws Exception + */ + public void testConditionalPutIfNoneMatchNegative() throws Exception { + Socket client = new Socket("127.0.0.1", HTTP_PORT); + OutputStream os = client.getOutputStream(); + int index = 1; + String content = ""; + String request = MessageFormat.format(REQUEST2, "PUT", index, "If-None-Match", "eTagXXX", content.getBytes().length, content); + os.write(request.getBytes()); + os.flush(); + + String document = read(client); + // Should return item + assertTrue(document.indexOf("updated item=" + index) != -1); + // Should return code 412 precondition failed. + // assertTrue(document.indexOf("HTTP/1.1 412") != -1); + } + + /** + * Test invoking a conditional method implementation using the HTTP binding. + * + * @throws Exception + */ + public void testConditionalPutIfNoneMatchPositive() throws Exception { + Socket client = new Socket("127.0.0.1", HTTP_PORT); + OutputStream os = client.getOutputStream(); + int index = 0; + String content = ""; + String request = MessageFormat.format(REQUEST2, "PUT", index, "If-None-Match", "eTagXXX", content.getBytes().length, content); + os.write(request.getBytes()); + os.flush(); + + String document = read(client); + // Should return item + // assertTrue(document.indexOf("updated item=" + index) != -1); + // Should return code 412 PreconditionFailed. + assertTrue(document.indexOf("HTTP/1.1 412") != -1); + } + + /** + * Read response stream from the given socket. + * + * @param socket + * @return + * @throws IOException + */ + private static String read(Socket socket) throws IOException { + BufferedReader reader = null; + try { + reader = new BufferedReader(new InputStreamReader(socket.getInputStream())); + StringBuffer sb = new StringBuffer(); + String str; + while ((str = reader.readLine()) != null) { + sb.append(str); + } + return sb.toString(); + } finally { + if (reader != null) { + reader.close(); + } + } + } } diff --git a/branches/sca-equinox/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/HTTPBindingTestCase.java b/branches/sca-equinox/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/HTTPBindingTestCase.java index e5cad080a6..601483be8a 100644 --- a/branches/sca-equinox/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/HTTPBindingTestCase.java +++ b/branches/sca-equinox/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/HTTPBindingTestCase.java @@ -25,9 +25,12 @@ import java.io.OutputStream; import java.net.Socket; import java.text.MessageFormat; -import junit.framework.TestCase; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; -import org.apache.tuscany.sca.host.embedded.SCADomain; +import junit.framework.TestCase; /** * HTTP binding unit tests. @@ -65,16 +68,19 @@ public class HTTPBindingTestCase extends TestCase { private static final int HTTP_PORT = 8085; - private SCADomain scaDomain; + private Node node; @Override protected void setUp() throws Exception { - scaDomain = SCADomain.newInstance("test.composite"); + String contribution = ContributionLocationHelper.getContributionLocation(HTTPBindingCacheTestCase.class); + node = NodeFactory.newInstance().createNode("test.composite", new Contribution("test", contribution)); + node.start(); } @Override protected void tearDown() throws Exception { - scaDomain.close(); + node.stop(); + node.destroy(); } /** diff --git a/branches/sca-equinox/modules/binding-jms-runtime/pom.xml b/branches/sca-equinox/modules/binding-jms-runtime/pom.xml index d3db03d1df..75224861a5 100644 --- a/branches/sca-equinox/modules/binding-jms-runtime/pom.xml +++ b/branches/sca-equinox/modules/binding-jms-runtime/pom.xml @@ -100,7 +100,7 @@ <dependency> <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-host-embedded</artifactId> + <artifactId>tuscany-node-impl</artifactId> <version>1.4-SNAPSHOT</version> <scope>test</scope> </dependency> diff --git a/branches/sca-equinox/modules/binding-jsonrpc-runtime/pom.xml b/branches/sca-equinox/modules/binding-jsonrpc-runtime/pom.xml index 8ec5e52a0f..ee73b43bd5 100644 --- a/branches/sca-equinox/modules/binding-jsonrpc-runtime/pom.xml +++ b/branches/sca-equinox/modules/binding-jsonrpc-runtime/pom.xml @@ -103,14 +103,13 @@ </dependency> - <!-- Test Dependencies --> <dependency> <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-host-embedded</artifactId> + <artifactId>tuscany-node-impl</artifactId> <version>1.4-SNAPSHOT</version> <scope>test</scope> </dependency> - + <dependency> <groupId>org.apache.tuscany.sca</groupId> <artifactId>tuscany-implementation-java-runtime</artifactId> diff --git a/branches/sca-equinox/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCDataTypeTestCase.java b/branches/sca-equinox/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCDataTypeTestCase.java index 6d156fcdf5..47ce8f4433 100644 --- a/branches/sca-equinox/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCDataTypeTestCase.java +++ b/branches/sca-equinox/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCDataTypeTestCase.java @@ -22,11 +22,13 @@ import java.io.ByteArrayInputStream; import junit.framework.Assert; -import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.json.JSONObject; import org.junit.After; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import com.meterware.httpunit.PostMethodWebRequest; @@ -39,155 +41,140 @@ import com.meterware.httpunit.WebResponse; */ public class JSONRPCDataTypeTestCase { - private static final String SERVICE_PATH = "/EchoService"; - private static final String SERVICE_URL = "http://localhost:8085/SCADomain" + SERVICE_PATH; - private SCADomain domain; + private static final String SERVICE_PATH = "/EchoService"; + private static final String SERVICE_URL = "http://localhost:8085/SCADomain" + SERVICE_PATH; + private Node node; - @Before - public void setUp() throws Exception { - domain = SCADomain.newInstance("JSONRPCBinding.composite"); - } + @Before + public void setUp() throws Exception { + String contribution = ContributionLocationHelper.getContributionLocation(getClass()); + node = NodeFactory.newInstance().createNode("JSONRPCBinding.composite", new Contribution("test", contribution)); + node.start(); + } - @After - public void tearDown() throws Exception { - domain.close(); - } + @After + public void tearDown() throws Exception { + node.stop(); + node.destroy(); + } - @Test - public void testInt() throws Exception { - JSONObject jsonRequest = new JSONObject( - "{ \"method\": \"echoInt\", \"params\": [12345], \"id\": 4}"); + @Test + public void testInt() throws Exception { + JSONObject jsonRequest = new JSONObject("{ \"method\": \"echoInt\", \"params\": [12345], \"id\": 4}"); - WebConversation wc = new WebConversation(); - WebRequest request = new PostMethodWebRequest(SERVICE_URL, - new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")), "application/json"); - WebResponse response = wc.getResource(request); + WebConversation wc = new WebConversation(); + WebRequest request = new PostMethodWebRequest(SERVICE_URL, new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")), "application/json"); + WebResponse response = wc.getResource(request); - Assert.assertEquals(200, response.getResponseCode()); + Assert.assertEquals(200, response.getResponseCode()); - JSONObject jsonResp = new JSONObject(response.getText()); + JSONObject jsonResp = new JSONObject(response.getText()); - Assert.assertEquals(12345, jsonResp.getInt("result")); - } + Assert.assertEquals(12345, jsonResp.getInt("result")); + } - @Test - public void testBoolean() throws Exception { - JSONObject jsonRequest = new JSONObject( - "{ \"method\": \"echoBoolean\", \"params\": [true], \"id\": 5}"); - - WebConversation wc = new WebConversation(); - WebRequest request = new PostMethodWebRequest(SERVICE_URL, - new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")), "application/json"); - WebResponse response = wc.getResource(request); + @Test + public void testBoolean() throws Exception { + JSONObject jsonRequest = new JSONObject("{ \"method\": \"echoBoolean\", \"params\": [true], \"id\": 5}"); - Assert.assertEquals(200, response.getResponseCode()); + WebConversation wc = new WebConversation(); + WebRequest request = new PostMethodWebRequest(SERVICE_URL, new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")), "application/json"); + WebResponse response = wc.getResource(request); - JSONObject jsonResp = new JSONObject(response.getText()); + Assert.assertEquals(200, response.getResponseCode()); - Assert.assertEquals(true, jsonResp.getBoolean("result")); - } + JSONObject jsonResp = new JSONObject(response.getText()); - @Test - public void testMap() throws Exception { - JSONObject jsonRequest = new JSONObject( - "{ \"method\": \"echoMap\", \"params\": [ {\"javaClass\": \"java.util.HashMap\", \"map\": { \"Binding\": \"JSON-RPC\"}}], \"id\": 6}"); + Assert.assertEquals(true, jsonResp.getBoolean("result")); + } - WebConversation wc = new WebConversation(); - WebRequest request = new PostMethodWebRequest(SERVICE_URL, - new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")), "application/json"); - WebResponse response = wc.getResource(request); + @Test + public void testMap() throws Exception { + JSONObject jsonRequest = new JSONObject("{ \"method\": \"echoMap\", \"params\": [ {\"javaClass\": \"java.util.HashMap\", \"map\": { \"Binding\": \"JSON-RPC\"}}], \"id\": 6}"); - Assert.assertEquals(200, response.getResponseCode()); + WebConversation wc = new WebConversation(); + WebRequest request = new PostMethodWebRequest(SERVICE_URL, new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")), "application/json"); + WebResponse response = wc.getResource(request); - JSONObject jsonResp = new JSONObject(response.getText()); + Assert.assertEquals(200, response.getResponseCode()); - Assert.assertEquals("JSON-RPC", jsonResp.getJSONObject("result").getJSONObject("map").getString("Binding")); - } - - @Test - public void testBean() throws Exception { - JSONObject jsonRequest = new JSONObject( - "{ \"method\": \"echoBean\", \"params\": [ {\"javaClass\": \"bean.TestBean\", \"testString\": \"JSON-RPC\", \"testInt\":1234}], \"id\": 7}"); + JSONObject jsonResp = new JSONObject(response.getText()); - WebConversation wc = new WebConversation(); - WebRequest request = new PostMethodWebRequest(SERVICE_URL, - new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")), "application/json"); - WebResponse response = wc.getResource(request); + Assert.assertEquals("JSON-RPC", jsonResp.getJSONObject("result").getJSONObject("map").getString("Binding")); + } - Assert.assertEquals(200, response.getResponseCode()); + @Test + public void testBean() throws Exception { + JSONObject jsonRequest = new JSONObject("{ \"method\": \"echoBean\", \"params\": [ {\"javaClass\": \"bean.TestBean\", \"testString\": \"JSON-RPC\", \"testInt\":1234}], \"id\": 7}"); - JSONObject jsonResp = new JSONObject(response.getText()); + WebConversation wc = new WebConversation(); + WebRequest request = new PostMethodWebRequest(SERVICE_URL, new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")), "application/json"); + WebResponse response = wc.getResource(request); - Assert.assertEquals("JSON-RPC", jsonResp.getJSONObject("result").getString("testString")); - } + Assert.assertEquals(200, response.getResponseCode()); - @Test - public void testList() throws Exception { - JSONObject jsonRequest = new JSONObject( - "{ \"method\": \"echoList\", \"params\": [ {\"javaClass\": \"java.util.ArrayList\", \"list\": [0,1,2,3,4]}], \"id\": 8}"); + JSONObject jsonResp = new JSONObject(response.getText()); - WebConversation wc = new WebConversation(); - WebRequest request = new PostMethodWebRequest(SERVICE_URL, - new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")), "application/json"); - WebResponse response = wc.getResource(request); + Assert.assertEquals("JSON-RPC", jsonResp.getJSONObject("result").getString("testString")); + } - Assert.assertEquals(200, response.getResponseCode()); + @Test + public void testList() throws Exception { + JSONObject jsonRequest = new JSONObject("{ \"method\": \"echoList\", \"params\": [ {\"javaClass\": \"java.util.ArrayList\", \"list\": [0,1,2,3,4]}], \"id\": 8}"); - JSONObject jsonResp = new JSONObject(response.getText()); + WebConversation wc = new WebConversation(); + WebRequest request = new PostMethodWebRequest(SERVICE_URL, new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")), "application/json"); + WebResponse response = wc.getResource(request); - Assert.assertEquals(0, jsonResp.getJSONObject("result").getJSONArray("list").get(0)); - } - - @Test - public void testArrayString() throws Exception { - JSONObject jsonRequest = new JSONObject( - "{\"params\":[[\"1\",\"2\"]],\"method\":\"echoArrayString\",\"id\":9}"); + Assert.assertEquals(200, response.getResponseCode()); - WebConversation wc = new WebConversation(); - WebRequest request = new PostMethodWebRequest(SERVICE_URL, - new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")), "application/json"); - WebResponse response = wc.getResource(request); + JSONObject jsonResp = new JSONObject(response.getText()); - Assert.assertEquals(200, response.getResponseCode()); + Assert.assertEquals(0, jsonResp.getJSONObject("result").getJSONArray("list").get(0)); + } - JSONObject jsonResp = new JSONObject(response.getText()); + @Test + public void testArrayString() throws Exception { + JSONObject jsonRequest = new JSONObject("{\"params\":[[\"1\",\"2\"]],\"method\":\"echoArrayString\",\"id\":9}"); - Assert.assertEquals(1, jsonResp.getJSONArray("result").getInt(0)); - } + WebConversation wc = new WebConversation(); + WebRequest request = new PostMethodWebRequest(SERVICE_URL, new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")), "application/json"); + WebResponse response = wc.getResource(request); - - @Test - public void testArrayInt() throws Exception { - JSONObject jsonRequest = new JSONObject( - "{\"params\":[[1,2]],\"method\":\"echoArrayInt\",\"id\":10}"); + Assert.assertEquals(200, response.getResponseCode()); - WebConversation wc = new WebConversation(); - WebRequest request = new PostMethodWebRequest(SERVICE_URL, - new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")), "application/json"); - WebResponse response = wc.getResource(request); + JSONObject jsonResp = new JSONObject(response.getText()); - Assert.assertEquals(200, response.getResponseCode()); + Assert.assertEquals(1, jsonResp.getJSONArray("result").getInt(0)); + } - JSONObject jsonResp = new JSONObject(response.getText()); + @Test + public void testArrayInt() throws Exception { + JSONObject jsonRequest = new JSONObject("{\"params\":[[1,2]],\"method\":\"echoArrayInt\",\"id\":10}"); - Assert.assertEquals(1, jsonResp.getJSONArray("result").getInt(0)); - } + WebConversation wc = new WebConversation(); + WebRequest request = new PostMethodWebRequest(SERVICE_URL, new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")), "application/json"); + WebResponse response = wc.getResource(request); - - @Test - public void testSet() throws Exception { - JSONObject jsonRequest = new JSONObject( - "{ \"method\": \"echoSet\", \"params\": [ {\"javaClass\": \"java.util.HashSet\", \"set\": {\"1\": \"red\", \"2\": \"blue\"}}],\"id\": 11}"); + Assert.assertEquals(200, response.getResponseCode()); - WebConversation wc = new WebConversation(); - WebRequest request = new PostMethodWebRequest(SERVICE_URL, - new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")), "application/json"); - WebResponse response = wc.getResource(request); + JSONObject jsonResp = new JSONObject(response.getText()); - Assert.assertEquals(200, response.getResponseCode()); + Assert.assertEquals(1, jsonResp.getJSONArray("result").getInt(0)); + } - JSONObject jsonResp = new JSONObject(response.getText()); + @Test + public void testSet() throws Exception { + JSONObject jsonRequest = new JSONObject("{ \"method\": \"echoSet\", \"params\": [ {\"javaClass\": \"java.util.HashSet\", \"set\": {\"1\": \"red\", \"2\": \"blue\"}}],\"id\": 11}"); - Assert.assertEquals("red", jsonResp.getJSONObject("result").getJSONObject("set").getString("red")); - } -}
\ No newline at end of file + WebConversation wc = new WebConversation(); + WebRequest request = new PostMethodWebRequest(SERVICE_URL, new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")), "application/json"); + WebResponse response = wc.getResource(request); + + Assert.assertEquals(200, response.getResponseCode()); + + JSONObject jsonResp = new JSONObject(response.getText()); + + Assert.assertEquals("red", jsonResp.getJSONObject("result").getJSONObject("set").getString("red")); + } +} diff --git a/branches/sca-equinox/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCExceptionTestCase.java b/branches/sca-equinox/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCExceptionTestCase.java index 52518e1bbc..0619831c06 100644 --- a/branches/sca-equinox/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCExceptionTestCase.java +++ b/branches/sca-equinox/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCExceptionTestCase.java @@ -22,7 +22,10 @@ import java.io.ByteArrayInputStream; import junit.framework.Assert; -import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.json.JSONObject; import org.junit.After; import org.junit.Before; @@ -42,16 +45,19 @@ public class JSONRPCExceptionTestCase{ private static final String SERVICE_URL = "http://localhost:8085/SCADomain" + SERVICE_PATH; - private SCADomain domain; + private Node node; @Before public void setUp() throws Exception { - domain = SCADomain.newInstance("JSONRPCBinding.composite"); + String contribution = ContributionLocationHelper.getContributionLocation(getClass()); + node = NodeFactory.newInstance().createNode("JSONRPCBinding.composite", new Contribution("test", contribution)); + node.start(); } @After public void tearDown() throws Exception { - domain.close(); + node.stop(); + node.destroy(); } @Test diff --git a/branches/sca-equinox/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCServiceTestCase.java b/branches/sca-equinox/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCServiceTestCase.java index 67d3eda6b2..ed73766202 100644 --- a/branches/sca-equinox/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCServiceTestCase.java +++ b/branches/sca-equinox/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCServiceTestCase.java @@ -22,7 +22,10 @@ import java.io.ByteArrayInputStream; import junit.framework.Assert; -import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.json.JSONObject; import org.junit.After; import org.junit.Before; @@ -42,16 +45,19 @@ public class JSONRPCServiceTestCase{ private static final String SERVICE_URL = "http://localhost:8085/SCADomain" + SERVICE_PATH; - private SCADomain domain; + private Node node; @Before public void setUp() throws Exception { - domain = SCADomain.newInstance("JSONRPCBinding.composite"); + String contribution = ContributionLocationHelper.getContributionLocation(getClass()); + node = NodeFactory.newInstance().createNode("JSONRPCBinding.composite", new Contribution("test", contribution)); + node.start(); } @After public void tearDown() throws Exception { - domain.close(); + node.stop(); + node.destroy(); } @Test diff --git a/branches/sca-equinox/modules/binding-rmi-runtime/pom.xml b/branches/sca-equinox/modules/binding-rmi-runtime/pom.xml index f999bb22d8..d0ee8050d9 100644 --- a/branches/sca-equinox/modules/binding-rmi-runtime/pom.xml +++ b/branches/sca-equinox/modules/binding-rmi-runtime/pom.xml @@ -63,7 +63,7 @@ <dependency> <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-host-embedded</artifactId> + <artifactId>tuscany-node-impl</artifactId> <version>1.4-SNAPSHOT</version> <scope>test</scope> </dependency> diff --git a/branches/sca-equinox/modules/binding-rmi-runtime/src/test/java/org/apache/tuscany/sca/binding/rmi/BindingTestCase.java b/branches/sca-equinox/modules/binding-rmi-runtime/src/test/java/org/apache/tuscany/sca/binding/rmi/BindingTestCase.java index c7838e284b..c62e3a6b8b 100644 --- a/branches/sca-equinox/modules/binding-rmi-runtime/src/test/java/org/apache/tuscany/sca/binding/rmi/BindingTestCase.java +++ b/branches/sca-equinox/modules/binding-rmi-runtime/src/test/java/org/apache/tuscany/sca/binding/rmi/BindingTestCase.java @@ -22,7 +22,10 @@ import helloworld.HelloException; import helloworld.HelloWorldRmiService; import junit.framework.Assert; -import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -34,7 +37,7 @@ import org.junit.Test; */ public class BindingTestCase { private static HelloWorldRmiService helloWorldRmiService; - private static SCADomain domain; + private static Node node; @Test public void testRmiService() { @@ -60,8 +63,10 @@ public class BindingTestCase { @BeforeClass public static void init() throws Exception { try { - domain = SCADomain.newInstance("RMIBindingTest.composite"); - helloWorldRmiService = domain.getService(HelloWorldRmiService.class, "HelloWorldRmiServiceComponent"); + String contribution = ContributionLocationHelper.getContributionLocation(BindingTestCase.class); + node = NodeFactory.newInstance().createNode("RMIBindingTest.composite", new Contribution("test", contribution)); + node.start(); + helloWorldRmiService = node.getService(HelloWorldRmiService.class, "HelloWorldRmiServiceComponent"); } catch (Exception e) { e.printStackTrace(); } @@ -69,7 +74,8 @@ public class BindingTestCase { @AfterClass public static void destroy() throws Exception { - domain.close(); + node.stop(); + node.destroy(); } } diff --git a/branches/sca-equinox/modules/binding-rss-rome/pom.xml b/branches/sca-equinox/modules/binding-rss-rome/pom.xml index 3fa097cfb4..ac467c8d65 100644 --- a/branches/sca-equinox/modules/binding-rss-rome/pom.xml +++ b/branches/sca-equinox/modules/binding-rss-rome/pom.xml @@ -106,7 +106,7 @@ <dependency> <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-host-embedded</artifactId> + <artifactId>tuscany-node-impl</artifactId> <version>1.4-SNAPSHOT</version> <scope>test</scope> </dependency> diff --git a/branches/sca-equinox/modules/binding-rss-rome/src/test/java/org/apache/tuscany/sca/binding/rss/Consumer.java b/branches/sca-equinox/modules/binding-rss-rome/src/test/java/org/apache/tuscany/sca/binding/rss/Consumer.java index 19370285f5..489631ae3b 100644 --- a/branches/sca-equinox/modules/binding-rss-rome/src/test/java/org/apache/tuscany/sca/binding/rss/Consumer.java +++ b/branches/sca-equinox/modules/binding-rss-rome/src/test/java/org/apache/tuscany/sca/binding/rss/Consumer.java @@ -19,17 +19,23 @@ package org.apache.tuscany.sca.binding.rss; -import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; public class Consumer { public static void main(String[] args) throws Exception { - SCADomain scaDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/feed/Consumer.composite"); + String contribution = ContributionLocationHelper.getContributionLocation(Consumer.class); + Node node = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/feed/Consumer.composite", new Contribution("test", contribution)); + node.start(); - CustomerClient testService = scaDomain.getService(CustomerClient.class, "CustomerClient"); + CustomerClient testService = node.getService(CustomerClient.class, "CustomerClient"); testService.testCustomerCollection(); - scaDomain.close(); + node.stop(); + node.destroy(); } } diff --git a/branches/sca-equinox/modules/binding-rss-rome/src/test/java/org/apache/tuscany/sca/binding/rss/Provider.java b/branches/sca-equinox/modules/binding-rss-rome/src/test/java/org/apache/tuscany/sca/binding/rss/Provider.java index ae7b72834e..42d64ef957 100644 --- a/branches/sca-equinox/modules/binding-rss-rome/src/test/java/org/apache/tuscany/sca/binding/rss/Provider.java +++ b/branches/sca-equinox/modules/binding-rss-rome/src/test/java/org/apache/tuscany/sca/binding/rss/Provider.java @@ -21,13 +21,18 @@ package org.apache.tuscany.sca.binding.rss; import java.io.IOException; -import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; public class Provider { public static void main(String[] args) { - SCADomain scaDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/feed/Provider.composite"); + String contribution = ContributionLocationHelper.getContributionLocation(Consumer.class); + Node node = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/feed/Provider.composite", new Contribution("test", contribution)); + node.start(); System.out.println("Provider.composite ready..."); try { @@ -36,6 +41,7 @@ public class Provider { e.printStackTrace(); } - scaDomain.close(); + node.stop(); + node.destroy(); } } diff --git a/branches/sca-equinox/modules/binding-rss/pom.xml b/branches/sca-equinox/modules/binding-rss/pom.xml index cd51de1088..2ae3c24401 100644 --- a/branches/sca-equinox/modules/binding-rss/pom.xml +++ b/branches/sca-equinox/modules/binding-rss/pom.xml @@ -63,7 +63,7 @@ <dependency> <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-host-embedded</artifactId> + <artifactId>tuscany-node-impl</artifactId> <version>1.4-SNAPSHOT</version> <scope>test</scope> </dependency> diff --git a/branches/sca-equinox/modules/binding-sca-axis2/pom.xml b/branches/sca-equinox/modules/binding-sca-axis2/pom.xml index 807a4add70..76e5114a19 100644 --- a/branches/sca-equinox/modules/binding-sca-axis2/pom.xml +++ b/branches/sca-equinox/modules/binding-sca-axis2/pom.xml @@ -59,9 +59,9 @@ <dependency>
<groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-host-embedded</artifactId>
+ <artifactId>tuscany-node-impl</artifactId>
<version>1.4-SNAPSHOT</version>
- <scope>test</scope>
+ <scope>test</scope>
</dependency>
<dependency>
diff --git a/branches/sca-equinox/modules/binding-ws-axis2/pom.xml b/branches/sca-equinox/modules/binding-ws-axis2/pom.xml index ae806d756e..d9253b9cbe 100644 --- a/branches/sca-equinox/modules/binding-ws-axis2/pom.xml +++ b/branches/sca-equinox/modules/binding-ws-axis2/pom.xml @@ -277,7 +277,7 @@ <dependency> <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-host-embedded</artifactId> + <artifactId>tuscany-node-impl</artifactId> <version>1.4-SNAPSHOT</version> <scope>test</scope> </dependency> diff --git a/branches/sca-equinox/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/launcher/DomainManagerLauncherBootstrap.java b/branches/sca-equinox/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/launcher/DomainManagerLauncherBootstrap.java index f96e19ed72..87fd41a74f 100644 --- a/branches/sca-equinox/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/launcher/DomainManagerLauncherBootstrap.java +++ b/branches/sca-equinox/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/launcher/DomainManagerLauncherBootstrap.java @@ -20,9 +20,12 @@ package org.apache.tuscany.sca.domain.manager.launcher; import org.apache.tuscany.sca.domain.manager.impl.DomainManagerConfiguration; -import org.apache.tuscany.sca.node.SCAClient; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; +import org.osoa.sca.CallableReference; +import org.osoa.sca.ServiceReference; /** * Bootstrap class for the SCA domain manager. @@ -30,15 +33,15 @@ import org.apache.tuscany.sca.node.SCANodeFactory; * @version $Rev$ $Date$ */ public class DomainManagerLauncherBootstrap { - private SCANode node; + private Node node; /** * A node wrappering an instance of a domain manager. */ - public static class NodeFacade implements SCANode { + public static class NodeFacade implements Node { private ClassLoader threadContextClassLoader; private ClassLoader runtimeClassLoader; - private SCANode node; + private Node node; private String rootDirectory; private NodeFacade(String rootDirectory) { @@ -51,12 +54,13 @@ public class DomainManagerLauncherBootstrap { boolean started = false; try { Thread.currentThread().setContextClassLoader(runtimeClassLoader); - SCANodeFactory factory = SCANodeFactory.newInstance(); - node = factory.createSCANodeFromClassLoader("DomainManager.composite", getClass().getClassLoader()); + NodeFactory factory = NodeFactory.newInstance(); + String contribution = ContributionLocationHelper.getContributionLocation(getClass()); + node = factory.createNode("DomainManager.composite", new Contribution("domain-manager", contribution)); node.start(); // Set the domain manager's root directory - DomainManagerConfiguration domainManagerConfiguration = ((SCAClient) node).getService(DomainManagerConfiguration.class, "DomainManagerConfigurationComponent"); + DomainManagerConfiguration domainManagerConfiguration = node.getService(DomainManagerConfiguration.class, "DomainManagerConfigurationComponent"); domainManagerConfiguration.setRootDirectory(rootDirectory); started = true; @@ -75,6 +79,28 @@ public class DomainManagerLauncherBootstrap { Thread.currentThread().setContextClassLoader(threadContextClassLoader); } } + + public void destroy() { + try { + Thread.currentThread().setContextClassLoader(runtimeClassLoader); + node.destroy(); + } finally { + Thread.currentThread().setContextClassLoader(threadContextClassLoader); + } + } + + public <B, R extends CallableReference<B>> R cast(B target) throws IllegalArgumentException { + throw new UnsupportedOperationException(); + } + + public <B> B getService(Class<B> businessInterface, String serviceName) { + throw new UnsupportedOperationException(); + } + + public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String serviceName) { + throw new UnsupportedOperationException(); + } + } /** @@ -88,7 +114,7 @@ public class DomainManagerLauncherBootstrap { * Returns the node representing the domain manager. * @return */ - public SCANode getNode() { + public Node getNode() { return node; } diff --git a/branches/sca-equinox/modules/host-embedded/LICENSE b/branches/sca-equinox/modules/host-embedded/LICENSE deleted file mode 100644 index 8aa906c321..0000000000 --- a/branches/sca-equinox/modules/host-embedded/LICENSE +++ /dev/null @@ -1,205 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed 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. - - - diff --git a/branches/sca-equinox/modules/host-embedded/META-INF/README b/branches/sca-equinox/modules/host-embedded/META-INF/README deleted file mode 100644 index 009570154d..0000000000 --- a/branches/sca-equinox/modules/host-embedded/META-INF/README +++ /dev/null @@ -1 +0,0 @@ -This directory contains a generated MANIFEST.MF file. diff --git a/branches/sca-equinox/modules/host-embedded/NOTICE b/branches/sca-equinox/modules/host-embedded/NOTICE deleted file mode 100644 index fdfa0e9faa..0000000000 --- a/branches/sca-equinox/modules/host-embedded/NOTICE +++ /dev/null @@ -1,6 +0,0 @@ -${pom.name} -Copyright (c) 2005 - 2008 The Apache Software Foundation - -This product includes software developed by -The Apache Software Foundation (http://www.apache.org/). - diff --git a/branches/sca-equinox/modules/host-embedded/pom.xml b/branches/sca-equinox/modules/host-embedded/pom.xml deleted file mode 100644 index 92fd8cc016..0000000000 --- a/branches/sca-equinox/modules/host-embedded/pom.xml +++ /dev/null @@ -1,132 +0,0 @@ -<?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. ---> -<project> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-modules</artifactId> - <version>1.4-SNAPSHOT</version> - <relativePath>../pom.xml</relativePath> - </parent> - <artifactId>tuscany-host-embedded</artifactId> - <name>Apache Tuscany SCA Embedded Host</name> - - <dependencies> - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-node-impl</artifactId> - <version>1.4-SNAPSHOT</version> - </dependency> - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-extensibility</artifactId> - <version>1.4-SNAPSHOT</version> - </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-core</artifactId> - <version>1.4-SNAPSHOT</version> - </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-definitions</artifactId> - <version>1.4-SNAPSHOT</version> - </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-definitions-xml</artifactId> - <version>1.4-SNAPSHOT</version> - </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-assembly-xml</artifactId> - <version>1.4-SNAPSHOT</version> - </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-binding-sca</artifactId> - <version>1.4-SNAPSHOT</version> - </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-binding-sca-xml</artifactId> - <version>1.4-SNAPSHOT</version> - </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-contribution-impl</artifactId> - <version>1.4-SNAPSHOT</version> - </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-policy-xml</artifactId> - <version>1.4-SNAPSHOT</version> - </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-core-databinding</artifactId> - <version>1.4-SNAPSHOT</version> - </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-assembly-xsd</artifactId> - <version>1.4-SNAPSHOT</version> - <scope>runtime</scope> - </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-endpoint</artifactId> - <version>1.4-SNAPSHOT</version> - <scope>runtime</scope> - </dependency> - - - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - - <configuration> - <instructions> - <Bundle-Version>${tuscany.version}</Bundle-Version> - <Bundle-SymbolicName>org.apache.tuscany.sca.host.embedded</Bundle-SymbolicName> - <Bundle-Description>${pom.name}</Bundle-Description> - <Export-Package>org.apache.tuscany.sca.host.embedded*</Export-Package> - </instructions> - </configuration> - </plugin> - </plugins> - </build> - -</project> diff --git a/branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/SCADomain.java b/branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/SCADomain.java deleted file mode 100644 index aaa4c6ee95..0000000000 --- a/branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/SCADomain.java +++ /dev/null @@ -1,229 +0,0 @@ -/* - * 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.host.embedded; - -import java.lang.reflect.Constructor; - -import org.apache.tuscany.sca.extensibility.ServiceDeclaration; -import org.apache.tuscany.sca.extensibility.ServiceDiscovery; -import org.apache.tuscany.sca.host.embedded.impl.DefaultSCADomain; -import org.apache.tuscany.sca.host.embedded.management.ComponentManager; -import org.osoa.sca.CallableReference; -import org.osoa.sca.ServiceReference; -import org.osoa.sca.ServiceRuntimeException; - -/** - * A handle to an SCA domain. - * - * @version $Rev$ $Date$ - */ -public abstract class SCADomain { - - static final String LOCAL_DOMAIN_URI = "http://localhost"; - - /** - * Static variable to hold the most recent instance of SCADomain - */ - // TODO: Temporary support for SCADomain.connect() API - protected static SCADomain theDomain; - - - /** - * Returns a new instance of a local SCA domain. - * - * @return - */ - public static SCADomain newInstance() { - return createNewInstance(LOCAL_DOMAIN_URI, null); - } - - /** - * Returns a new instance of a local SCA domain. The specified deployable - * composite will be included in the SCA domain. - * - * @param composite the deployable composite to include in the SCA domain. - * @return - */ - public static SCADomain newInstance(String composite) { - return createNewInstance(LOCAL_DOMAIN_URI, "/", composite); - } - - /** - * Returns a new instance of a local SCA domain. The specified deployable - * composites will be included in the SCA domain. - * - * @param domainURI the URI of the SCA domain - * @param contributionLocation the location of an SCA contribution - * @param composites the deployable composites to include in the SCA domain. - * @return - */ - public static SCADomain newInstance(String domainURI, String contributionLocation, String... composites) { - return createNewInstance(domainURI, contributionLocation, composites); - } - - /** - * Removes the specified local SCA Domain instance - * - * @param domainInstance the instance to be removed - */ - // FIXME: Adding this as temporary support for the "connect" API - public static void removeInstance(SCADomain domainInstance) { - theDomain = null; - } - - /** - * Returns an SCADomain representing a remote SCA domain. - * - * @param domainURI the URI of the SCA domain - * @return - */ - // FIXME : this is a temporary implementation to get the capability working - public static SCADomain connect(String domainURI) { - return theDomain; - } - - /** - * Close the SCA domain. - */ - public void close() { - // TODO: temporary to support initial SCADomain.connect capability - SCADomain.removeInstance(this); - } - - /** - * Returns the URI of the SCA Domain. - * - * @return the URI of the SCA Domain - */ - public abstract String getURI(); - - /** - * Cast a type-safe reference to a CallableReference. Converts a type-safe - * reference to an equivalent CallableReference; if the target refers to a - * service then a ServiceReference will be returned, if the target refers to - * a callback then a CallableReference will be returned. - * - * @param target a reference proxy provided by the SCA runtime - * @param <B> the Java type of the business interface for the reference - * @param <R> the type of reference to be returned - * @return a CallableReference equivalent for the proxy - * @throws IllegalArgumentException if the supplied instance is not a - * reference supplied by the SCA runtime - */ - public abstract <B, R extends CallableReference<B>> R cast(B target) throws IllegalArgumentException; - - /** - * Returns a proxy for a service provided by a component in the SCA domain. - * - * @param businessInterface the interface that will be used to invoke the - * service - * @param serviceName the name of the service - * @param <B> the Java type of the business interface for the service - * @return an object that implements the business interface - */ - public abstract <B> B getService(Class<B> businessInterface, String serviceName); - - /** - * Returns a ServiceReference for a service provided by a component in the - * SCA domain. - * - * @param businessInterface the interface that will be used to invoke the - * service - * @param serviceName the name of the service - * @param <B> the Java type of the business interface for the service - * @return a ServiceReference for the designated service - */ - public abstract <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String serviceName); - - /** - * Returns an SCADomain instance. If the system property - * "org.apache.tuscany.sca.host.embedded.SCADomain" is set, its value is used as - * the name of the implementation class. Otherwise, if the resource - * "META-INF/services/org.apache.tuscany.sca.host.embedded.SCADomain" can be - * loaded from the supplied ClassLoader. Otherwise, it will use - * "org.apache.tuscany.sca.host.embedded.impl.DefaultSCADomain" as the default. - * The named class is loaded from the supplied ClassLoader. - * - * @param classLoader - * @param domainURI - * @param contributionLocation - * @param composites - * @return - */ - static SCADomain createNewInstance(String domainURI, String contributionLocation, String... composites) { - - SCADomain domain = null; - - try { - // Determine the runtime and application ClassLoader - final ClassLoader runtimeClassLoader = SCADomain.class.getClassLoader(); - final ClassLoader applicationClassLoader = Thread.currentThread().getContextClassLoader(); - - ServiceDeclaration implDeclaration = ServiceDiscovery.getInstance().getFirstServiceDeclaration(SCADomain.class.getName()); - - if (implDeclaration == null) { - - // Create a default SCA domain implementation - domain = - new DefaultSCADomain(runtimeClassLoader, applicationClassLoader, domainURI, contributionLocation, - composites); - } else { - - // Create an instance of the discovered SCA domain implementation - Constructor<?> constructor = null; - try { - Class<?> implClass = implDeclaration.loadClass(); - constructor = - implClass.getConstructor(ClassLoader.class, - ClassLoader.class, - String.class, - String.class, - String[].class); - } catch (NoSuchMethodException e) { - } - if (constructor != null) { - domain = - (SCADomain)constructor.newInstance(runtimeClassLoader, - applicationClassLoader, - domainURI, - contributionLocation, - composites); - } else { - - Class<?> implClass = implDeclaration.loadClass(); - constructor = implClass.getConstructor(ClassLoader.class, String.class); - domain = (SCADomain)constructor.newInstance(runtimeClassLoader, domainURI); - } - } - - // FIXME: temporary support for connect() API - theDomain = domain; - - return domain; - - } catch (Exception e) { - throw new ServiceRuntimeException(e); - } - } - - public ComponentManager getComponentManager() { - return null; - } - -} diff --git a/branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/SCADomainBean.java b/branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/SCADomainBean.java deleted file mode 100644 index c9bfe499c6..0000000000 --- a/branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/SCADomainBean.java +++ /dev/null @@ -1,125 +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.host.embedded; - -import org.apache.tuscany.sca.host.embedded.management.ComponentManager; -import org.osoa.sca.CallableReference; -import org.osoa.sca.ServiceReference; - -/** - * - * @version $Rev$ $Date$ - */ -public class SCADomainBean extends SCADomain { - - private SCADomain instance; - - private String uri = LOCAL_DOMAIN_URI; - private String location = "/"; - private String[] composites; - - /** - * Constructs a new SCA domain - */ - public SCADomainBean() { - } - - @Override - public String getURI() { - return uri; - } - - public void setURI(String uri) { - this.uri = uri; - } - - public void setContributionLocation(String contributionLocation) { - this.location = contributionLocation; - } - - public String getContributionLocation() { - return location; - } - - public void setDeployableComposite(String composite) { - setDeployableComposites(composite); - } - - public void setDeployableComposites(String... composites) { - this.composites = composites; - } - - public String[] getDeployableComposites() { - return composites; - } - - @SuppressWarnings("unchecked") - @Override - public <B, R extends CallableReference<B>> R cast(B target) throws IllegalArgumentException { - if (instance == null) { - instance = SCADomain.createNewInstance(uri, location, composites); - } - Object result = instance.cast(target); - return (R) result; - } - - @Override - public void close() { - if (instance == null) { - instance = SCADomain.createNewInstance(uri, location, composites); - } - instance.close(); - instance = null; - } - - @Override - public <B> B getService(Class<B> businessInterface, String serviceName) { - if (instance == null) { - instance = SCADomain.createNewInstance(uri, location, composites); - } - return instance.getService(businessInterface, serviceName); - } - - @Override - public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String referenceName) { - if (instance == null) { - instance = SCADomain.createNewInstance(uri, location, composites); - } - return instance.getServiceReference(businessInterface, referenceName); - } - - @Override - protected void finalize() throws Throwable { - - // Make sure that the SCA domain is closed - if (instance != null) { - instance.close(); - instance = null; - } - } - - @Override - public ComponentManager getComponentManager() { - if (instance == null) { - instance = SCADomain.createNewInstance(uri, location, composites); - } - return instance.getComponentManager(); - } -} diff --git a/branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/SCATestCaseRunner.java b/branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/SCATestCaseRunner.java deleted file mode 100644 index 7c893a5c9e..0000000000 --- a/branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/SCATestCaseRunner.java +++ /dev/null @@ -1,291 +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.host.embedded; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; -import java.net.URL; -import java.net.URLClassLoader; -import java.security.AccessController; -import java.security.PrivilegedAction; - -/** - * A helper class that can be used to run an SCA JUnit test case. The test case will run in an isolated class loader. - * - * @version $Rev$ $Date$ - */ -public class SCATestCaseRunner { - - private ClassLoader classLoader; - private Class<?> testSuiteClass; - private Object testSuite; - private Class<?> testResultClass; - private Class<?> testCaseClass; - private Object testCase; - - private Class<?> beforeAnnotation; - private Class<?> beforeClassAnnotation; - private Class<?> afterAnnotation; - private Class<?> afterClassAnnotation; - private Class<?> junit4AdapterClass; - private Class<?> junit3TestCaseClass; - - /** - * Constructs a new TestCase runner. - * - * @param testClass - */ - public SCATestCaseRunner(Class testClass) { - try { - ClassLoader tccl = Thread.currentThread().getContextClassLoader(); - classLoader = testClass.getClassLoader(); - if (classLoader instanceof URLClassLoader) { - URL[] urls = ((URLClassLoader)classLoader).getURLs(); - classLoader = new URLClassLoader(urls, classLoader.getParent()); - } else if (classLoader == tccl || classLoader.getParent() == tccl) { - classLoader = new URLClassLoader(new URL[0], classLoader); - } else { - classLoader = tccl; - } - - try { - // Thread.currentThread().setContextClassLoader(classLoader); - // Allow privileged access to set class loader. Requires RuntimePermission - // setContextClassLoader in security policy. - final ClassLoader finalClassLoader = classLoader; - AccessController.doPrivileged(new PrivilegedAction<Object>() { - public Object run() { - Thread.currentThread().setContextClassLoader(finalClassLoader); - return null; - } - }); - - testCaseClass = Class.forName(testClass.getName(), true, classLoader); - testCase = testCaseClass.newInstance(); - ClassLoader testClassLoader = testCaseClass.getClassLoader(); - - junit3TestCaseClass = Class.forName("junit.framework.TestCase", true, testClassLoader); - - testSuiteClass = Class.forName("junit.framework.TestSuite", true, testClassLoader); - Constructor testSuiteConstructor = testSuiteClass.getConstructor(Class.class); - testSuite = testSuiteConstructor.newInstance(testCaseClass); - - testResultClass = Class.forName("junit.framework.TestResult", true, testClassLoader); - - try { - beforeAnnotation = Class.forName("org.junit.Before", true, testClassLoader); - afterAnnotation = Class.forName("org.junit.After", true, testClassLoader); - beforeClassAnnotation = Class.forName("org.junit.BeforeClass", true, testClassLoader); - afterClassAnnotation = Class.forName("org.junit.AfterClass", true, testClassLoader); - junit4AdapterClass = Class.forName("junit.framework.JUnit4TestAdapter", true, testClassLoader); - } catch (Exception e) { - // Unexpected - throw new AssertionError(e); - } - } catch (Throwable e) { - e.printStackTrace(); - } finally { - // Thread.currentThread().setContextClassLoader(tccl); - // Allow privileged access to set class loader. Requires RuntimePermission - // setContextClassLoader in security policy. - final ClassLoader finaltccl = tccl; - AccessController.doPrivileged(new PrivilegedAction<Object>() { - public Object run() { - Thread.currentThread().setContextClassLoader(finaltccl); - return null; - } - }); - } - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - /** - * Run the test case - */ - public void run() { - ClassLoader tccl = Thread.currentThread().getContextClassLoader(); - try { - // Thread.currentThread().setContextClassLoader(classLoader); - // Allow privileged access to set class loader. Requires RuntimePermission - // setContextClassLoader in security policy. - final ClassLoader finalClassLoader = classLoader; - AccessController.doPrivileged(new PrivilegedAction<Object>() { - public Object run() { - Thread.currentThread().setContextClassLoader(finalClassLoader); - return null; - } - }); - - if (junit3TestCaseClass.isAssignableFrom(testCaseClass)) { - Object testResult = testResultClass.newInstance(); - Method runMethod = testSuiteClass.getMethod("run", testResultClass); - runMethod.invoke(testSuite, testResult); - } else { - Object junit4Adapter = junit4AdapterClass.getConstructor(Class.class).newInstance(testCaseClass); - Object testResult = testResultClass.newInstance(); - Method runMethod = junit4AdapterClass.getMethod("run", testResultClass); - runMethod.invoke(junit4Adapter, testResult); - } - } catch (Exception e) { - throw new RuntimeException(e); - } finally { - // Thread.currentThread().setContextClassLoader(tccl); - // Allow privileged access to set class loader. Requires RuntimePermission - // setContextClassLoader in security policy. - final ClassLoader finaltccl = tccl; - AccessController.doPrivileged(new PrivilegedAction<Object>() { - public Object run() { - Thread.currentThread().setContextClassLoader(finaltccl); - return null; - } - }); - } - } - - /** - * Invoke the setUp method - */ - public void setUp() { - execute("setUp"); - } - - /** - * Invoke the before methods - */ - public void before() { - execute(beforeAnnotation); - } - - /** - * Invoke the beforeClass methods - */ - public void beforeClass() { - execute(beforeClassAnnotation); - } - - /** - * Invoke the tearDown method - */ - public void tearDown() { - execute("tearDown"); - } - - /** - * Invoke the after methods - */ - public void after() { - execute(afterAnnotation); - } - - /** - * Invoke the afterClass methods - */ - public void afterClass() { - execute(afterClassAnnotation); - } - - /** - * Invoke the specified test method. - */ - public void run(String methodName) { - execute(methodName); - } - - /** - * Invoke the methods annotated with the specified annotation. - */ - private void execute(Class<?> annotationClass) { - if (annotationClass == null) { - throw new RuntimeException(new NoSuchMethodException()); - } - ClassLoader tccl = Thread.currentThread().getContextClassLoader(); - try { - // Thread.currentThread().setContextClassLoader(classLoader); - // Allow privileged access to set class loader. Requires RuntimePermission - // setContextClassLoader in security policy. - final ClassLoader finalClassLoader = classLoader; - AccessController.doPrivileged(new PrivilegedAction<Object>() { - public Object run() { - Thread.currentThread().setContextClassLoader(finalClassLoader); - return null; - } - }); - - for (Method method : testCaseClass.getDeclaredMethods()) { - for (Annotation annotation : method.getAnnotations()) { - if (annotation.annotationType() == annotationClass) { - method.invoke(testCase); - } - } - } - } catch (Exception e) { - throw new RuntimeException(e); - } finally { - // Thread.currentThread().setContextClassLoader(tccl); - // Allow privileged access to set class loader. Requires RuntimePermission - // setContextClassLoader in security policy. - final ClassLoader finaltccl = tccl; - AccessController.doPrivileged(new PrivilegedAction<Object>() { - public Object run() { - Thread.currentThread().setContextClassLoader(finaltccl); - return null; - } - }); - } - } - - /** - * Invoke the specified method - */ - private void execute(String methodName) { - ClassLoader tccl = Thread.currentThread().getContextClassLoader(); - try { - // Thread.currentThread().setContextClassLoader(classLoader); - // Allow privileged access to set class loader. Requires RuntimePermission - // setContextClassLoader in security policy. - final ClassLoader finalClassLoader = classLoader; - AccessController.doPrivileged(new PrivilegedAction<Object>() { - public Object run() { - Thread.currentThread().setContextClassLoader(finalClassLoader); - return null; - } - }); - Method setUpMethod = testCaseClass.getDeclaredMethod(methodName); - setUpMethod.setAccessible(true); - setUpMethod.invoke(testCase); - } catch (Exception e) { - throw new RuntimeException(e); - } finally { - // Thread.currentThread().setContextClassLoader(tccl); - // Allow privileged access to set class loader. Requires RuntimePermission - // setContextClassLoader in security policy. - final ClassLoader finaltccl = tccl; - AccessController.doPrivileged(new PrivilegedAction<Object>() { - public Object run() { - Thread.currentThread().setContextClassLoader(finaltccl); - return null; - } - }); - } - } - -} diff --git a/branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ComponentManagerImpl.java b/branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ComponentManagerImpl.java deleted file mode 100644 index 187f32f405..0000000000 --- a/branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ComponentManagerImpl.java +++ /dev/null @@ -1,120 +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.host.embedded.impl; - -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.concurrent.CopyOnWriteArrayList; - -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.core.assembly.ActivationException; -import org.apache.tuscany.sca.core.assembly.RuntimeComponentImpl; -import org.apache.tuscany.sca.host.embedded.management.ComponentListener; -import org.apache.tuscany.sca.host.embedded.management.ComponentManager; - -/** - * Implementation of the ComponentManager. - * - * @version $Rev$ $Date$ - */ -public class ComponentManagerImpl implements ComponentManager { - - protected List<ComponentListener> listeners = new CopyOnWriteArrayList<ComponentListener>(); - protected EmbeddedSCADomain domain; - - public ComponentManagerImpl(EmbeddedSCADomain domain) { - this.domain = domain; - } - - public void addComponentListener(ComponentListener listener) { - this.listeners.add(listener); - } - - public void removeComponentListener(ComponentListener listener) { - this.listeners.remove(listener); - } - - public Set<String> getComponentNames() { - Set<String> names = new HashSet<String>(); - for (Composite composite: domain.getDomainComposite().getIncludes()) { - for (Component component: composite.getComponents()) { - names.add(component.getName()); - } - } - return names; - } - - public Component getComponent(String componentName) { - for (Composite composite: domain.getDomainComposite().getIncludes()) { - for (Component component: composite.getComponents()) { - if (component.getName().equals(componentName)) { - return component; - } - } - } - return null; - } - - public void startComponent(String componentName) throws ActivationException { - Component component = getComponent(componentName); - if (component == null) { - throw new IllegalArgumentException("no component: " + componentName); - } - domain.getCompositeActivator().start(component); - notifyComponentStarted(componentName); - } - - public void stopComponent(String componentName) throws ActivationException { - Component component = getComponent(componentName); - if (component == null) { - throw new IllegalArgumentException("no component: " + componentName); - } - domain.getCompositeActivator().stop(component); - notifyComponentStopped(componentName); - } - - public void notifyComponentStarted(String componentName) { - for (ComponentListener listener : listeners) { - try { - listener.componentStarted(componentName); - } catch (Exception e) { - e.printStackTrace(); // TODO: log - } - } - } - - public void notifyComponentStopped(String componentName) { - for (ComponentListener listener : listeners) { - try { - listener.componentStopped(componentName); - } catch (Exception e) { - e.printStackTrace(); // TODO: log - } - } - } - - public boolean isComponentStarted(String componentName) { - RuntimeComponentImpl runtimeComponent = (RuntimeComponentImpl)getComponent(componentName); - return runtimeComponent.isStarted(); - } - -} diff --git a/branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/DefaultSCADomain.java b/branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/DefaultSCADomain.java deleted file mode 100644 index cb1011a5dc..0000000000 --- a/branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/DefaultSCADomain.java +++ /dev/null @@ -1,340 +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.host.embedded.impl; - -import java.net.URL; -import java.net.URLConnection; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.CopyOnWriteArrayList; - -import javax.xml.XMLConstants; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.xml.Constants; -import org.apache.tuscany.sca.core.assembly.ActivationException; -import org.apache.tuscany.sca.core.assembly.CompositeActivator; -import org.apache.tuscany.sca.core.assembly.RuntimeComponentImpl; -import org.apache.tuscany.sca.host.embedded.SCADomain; -import org.apache.tuscany.sca.host.embedded.management.ComponentListener; -import org.apache.tuscany.sca.host.embedded.management.ComponentManager; -import org.apache.tuscany.sca.node.SCAClient; -import org.apache.tuscany.sca.node.SCAContribution; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; -import org.apache.tuscany.sca.node.impl.NodeImpl; -import org.apache.tuscany.sca.node.impl.NodeUtil; -import org.osoa.sca.CallableReference; -import org.osoa.sca.ServiceReference; - -/** - * A default SCA domain facade implementation. - * - * @version $Rev$ $Date$ - */ -public class DefaultSCADomain extends SCADomain { - - private String uri; - private String[] composites; - // private Composite domainComposite; - // private List<Contribution> contributions; - private Map<String, Component> components; - private ComponentManager componentManager; - // private ClassLoader runtimeClassLoader; - private ClassLoader applicationClassLoader; - private String domainURI; - private List<String> contributionURLs; - - private CompositeActivator compositeActivator; - private SCANode node; - private SCAClient client; - - /** - * Constructs a new domain facade. - * - * @param domainURI - * @param contributionLocation - * @param composites - */ - public DefaultSCADomain(ClassLoader runtimeClassLoader, - ClassLoader applicationClassLoader, - String domainURI, - String contributionLocation, - String... composites) { - this.uri = domainURI; - this.composites = composites; - // this.runtimeClassLoader = runtimeClassLoader; - this.applicationClassLoader = applicationClassLoader; - this.domainURI = domainURI; - this.contributionURLs = new ArrayList<String>(); - if (contributionLocation != null && !"/".equals(contributionLocation)) { - this.contributionURLs.add(contributionLocation); - } - this.composites = composites; - - init(); - - this.componentManager = new DefaultSCADomainComponentManager(this); - - } - - /** - * A hack to create an aggregated composite - * @param classLoader - * @param composites - * @return - */ - private String createDeploymentComposite(ClassLoader classLoader, String composites[]) { - try { - StringBuffer xml = - new StringBuffer("<sca:composite xmlns:sca=\"http://www.osoa.org/xmlns/sca/1.0\"") - .append(" targetNamespace=\"http://tempuri.org\" name=\"aggregated\">\n"); - XMLInputFactory factory = XMLInputFactory.newInstance(); - for (int i = 0; i < composites.length; i++) { - URL url = classLoader.getResource(composites[i]); - if (url == null) { - continue; - } - String location = NodeUtil.getContributionURL(url, composites[i]).toString(); - if (!contributionURLs.contains(location)) { - contributionURLs.add(location); - } - URLConnection connection = url.openConnection(); - connection.setUseCaches(false); - XMLStreamReader reader = factory.createXMLStreamReader(connection.getInputStream()); - reader.nextTag(); - - assert Constants.COMPOSITE_QNAME.equals(reader.getName()); - String ns = reader.getAttributeValue(null, "targetNamespace"); - if (ns == null) { - ns = XMLConstants.NULL_NS_URI; - } - String name = reader.getAttributeValue(null, "name"); - reader.close(); - if (XMLConstants.NULL_NS_URI.equals(ns)) { - xml.append("<sca:include name=\"").append(name).append("\"/>\n"); - } else { - xml.append("<sca:include xmlns:ns").append(i).append("=\"").append(ns).append("\""); - xml.append(" name=\"").append("ns").append(i).append(":").append(name).append("\"/>\n"); - } - } - xml.append("</sca:composite>"); - // System.out.println(xml.toString()); - return xml.toString(); - } catch (Exception e) { - throw new IllegalArgumentException(e); - } - } - - public void init() { - SCANodeFactory factory = SCANodeFactory.newInstance(); - - List<SCAContribution> contributions = new ArrayList<SCAContribution>(); - - if (composites != null && composites.length > 1) { - // Create an aggregated composite that includes all the composites as Node API only takes one composite - String content = createDeploymentComposite(applicationClassLoader, composites); - // Create SCA contributions - for (String location : contributionURLs) { - contributions.add(new SCAContribution(location, location)); - } - node = - factory.createSCANode("http://tempuri.org/aggregated", content, contributions - .toArray(new SCAContribution[contributions.size()])); - } else { - for (String location : contributionURLs) { - contributions.add(new SCAContribution(location, location)); - } - String composite = (composites != null && composites.length >= 1) ? composites[0] : null; - if (!contributions.isEmpty()) { - node = - factory.createSCANode(composite, contributions.toArray(new SCAContribution[contributions.size()])); - } else { - node = factory.createSCANodeFromClassLoader(composite, applicationClassLoader); - } - } - client = (SCAClient)node; - compositeActivator = ((NodeImpl)node).getCompositeActivator(); - components = new HashMap<String, Component>(); - - node.start(); - - getComponents(compositeActivator.getDomainComposite()); - } - - private void getComponents(Composite composite) { - for (Component c : composite.getComponents()) { - components.put(c.getName(), c); - } - for (Composite cp : composite.getIncludes()) { - getComponents(cp); - } - } - - @Override - public void close() { - super.close(); - node.stop(); - - } - - @Override - @SuppressWarnings("unchecked") - public <B, R extends CallableReference<B>> R cast(B target) throws IllegalArgumentException { - return (R)client.cast(target); - } - - @Override - public <B> B getService(Class<B> businessInterface, String serviceName) { - return client.getService(businessInterface, serviceName); - } - - @Override - public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String name) { - return client.getServiceReference(businessInterface, name); - } - - @Override - public String getURI() { - return uri; - } - - @Override - public ComponentManager getComponentManager() { - return componentManager; - } - - public Set<String> getComponentNames() { - return components.keySet(); - /* - Set<String> componentNames = new HashSet<String>(); - for (Contribution contribution : contributions) { - for (Artifact artifact : contribution.getArtifacts()) { - if (artifact.getModel() instanceof Composite) { - for (Component component : ((Composite)artifact.getModel()).getComponents()) { - componentNames.add(component.getName()); - } - } - } - } - return componentNames; - */ - } - - public Component getComponent(String componentName) { - return components.get(componentName); - /* - for (Contribution contribution : contributions) { - for (Artifact artifact : contribution.getArtifacts()) { - if (artifact.getModel() instanceof Composite) { - for (Component component : ((Composite)artifact.getModel()).getComponents()) { - if (component.getName().equals(componentName)) { - return component; - } - } - } - } - } - return null; - */ - } - - public void startComponent(String componentName) throws ActivationException { - Component component = getComponent(componentName); - if (component == null) { - throw new IllegalArgumentException("no component: " + componentName); - } - compositeActivator.start(component); - } - - public void stopComponent(String componentName) throws ActivationException { - Component component = getComponent(componentName); - if (component == null) { - throw new IllegalArgumentException("no component: " + componentName); - } - compositeActivator.stop(component); - } -} - -class DefaultSCADomainComponentManager implements ComponentManager { - - protected DefaultSCADomain scaDomain; - protected List<ComponentListener> listeners = new CopyOnWriteArrayList<ComponentListener>(); - - public DefaultSCADomainComponentManager(DefaultSCADomain scaDomain) { - this.scaDomain = scaDomain; - } - - public void addComponentListener(ComponentListener listener) { - this.listeners.add(listener); - } - - public void removeComponentListener(ComponentListener listener) { - this.listeners.remove(listener); - } - - public Set<String> getComponentNames() { - return scaDomain.getComponentNames(); - } - - public Component getComponent(String componentName) { - return scaDomain.getComponent(componentName); - } - - public void startComponent(String componentName) throws ActivationException { - scaDomain.startComponent(componentName); - } - - public void stopComponent(String componentName) throws ActivationException { - scaDomain.stopComponent(componentName); - } - - public void notifyComponentStarted(String componentName) { - for (ComponentListener listener : listeners) { - try { - listener.componentStarted(componentName); - } catch (Exception e) { - e.printStackTrace(); // TODO: log - } - } - } - - public void notifyComponentStopped(String componentName) { - for (ComponentListener listener : listeners) { - try { - listener.componentStopped(componentName); - } catch (Exception e) { - e.printStackTrace(); // TODO: log - } - } - } - - public boolean isComponentStarted(String componentName) { - RuntimeComponentImpl runtimeComponent = (RuntimeComponentImpl)getComponent(componentName); - return runtimeComponent.isStarted(); - } - -} diff --git a/branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/EmbeddedSCADomain.java b/branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/EmbeddedSCADomain.java deleted file mode 100644 index b1e4b13833..0000000000 --- a/branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/EmbeddedSCADomain.java +++ /dev/null @@ -1,235 +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.host.embedded.impl; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.CompositeService; -import org.apache.tuscany.sca.assembly.SCABinding; -import org.apache.tuscany.sca.assembly.SCABindingFactory; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException; -import org.apache.tuscany.sca.assembly.xml.Constants; -import org.apache.tuscany.sca.contribution.service.ContributionService; -import org.apache.tuscany.sca.core.FactoryExtensionPoint; -import org.apache.tuscany.sca.core.assembly.ActivationException; -import org.apache.tuscany.sca.core.assembly.CompositeActivator; -import org.apache.tuscany.sca.core.context.ServiceReferenceImpl; -import org.apache.tuscany.sca.host.embedded.SCADomain; -import org.apache.tuscany.sca.host.embedded.management.ComponentManager; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; -import org.apache.tuscany.sca.node.impl.RuntimeBootStrapper; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentContext; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; -import org.osoa.sca.CallableReference; -import org.osoa.sca.ServiceReference; -import org.osoa.sca.ServiceRuntimeException; - -/** - * An SCA domain facade implementation. - * - * @version $Rev$ $Date$ - */ -public class EmbeddedSCADomain extends SCADomain { - - private String uri; - private Composite domainComposite; - private RuntimeBootStrapper runtime; - private ComponentManagerImpl componentManager = new ComponentManagerImpl(this); - - /** - * Constructs a new domain facade. - * - * @param runtimeClassLoader - * @param domainURI - */ - public EmbeddedSCADomain(ClassLoader runtimeClassLoader, - String domainURI) { - this.uri = domainURI; - - // Create a runtime - runtime = new RuntimeBootStrapper(runtimeClassLoader); - } - - public void start() throws ActivationException { - - // Start the runtime - runtime.start(); - - // Create an in-memory domain level composite - AssemblyFactory assemblyFactory = runtime.getAssemblyFactory(); - domainComposite = assemblyFactory.createComposite(); - domainComposite.setName(new QName(Constants.SCA10_NS, "domain")); - domainComposite.setURI(uri); - - getCompositeActivator().setDomainComposite(domainComposite); - - } - - public void stop() throws ActivationException { - - // Stop the runtime - runtime.stop(); - - // Cleanup - domainComposite = null; - } - - public void buildComposite(Composite composite) throws CompositeBuilderException { - runtime.buildComposite(composite); - } - - public ContributionService getContributionService() { - return runtime.getContributionService(); - } - - public CompositeBuilder getCompositeBuilder() { - return runtime.getCompositeBuilder(); - } - - public CompositeActivator getCompositeActivator() { - return runtime.getCompositeActivator(); - } - - public Composite getDomainComposite() { - return domainComposite; - } - - @Override - public ComponentManager getComponentManager() { - return componentManager; - } - - @Override - public void close() { - super.close(); - } - - @Override - public <B, R extends CallableReference<B>> R cast(B target) throws IllegalArgumentException { - return (R)runtime.getProxyFactory().cast(target); - } - - @Override - public <B> B getService(Class<B> businessInterface, String serviceName) { - ServiceReference<B> serviceReference = getServiceReference(businessInterface, serviceName); - if (serviceReference == null) { - throw new ServiceRuntimeException("Service not found: " + serviceName); - } - return serviceReference.getService(); - } - - private <B> ServiceReference<B> createServiceReference(Class<B> businessInterface, String targetURI) { - try { - AssemblyFactory assemblyFactory = runtime.getAssemblyFactory(); - Composite composite = assemblyFactory.createComposite(); - composite.setName(new QName(Constants.SCA10_TUSCANY_NS, "default")); - RuntimeComponent component = (RuntimeComponent)assemblyFactory.createComponent(); - component.setName("default"); - component.setURI("default"); - runtime.getCompositeActivator().configureComponentContext(component); - composite.getComponents().add(component); - RuntimeComponentReference reference = (RuntimeComponentReference)assemblyFactory.createComponentReference(); - reference.setName("default"); - FactoryExtensionPoint factories = - runtime.getExtensionPointRegistry().getExtensionPoint(FactoryExtensionPoint.class); - JavaInterfaceFactory javaInterfaceFactory = factories.getFactory(JavaInterfaceFactory.class); - InterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract(); - interfaceContract.setInterface(javaInterfaceFactory.createJavaInterface(businessInterface)); - reference.setInterfaceContract(interfaceContract); - component.getReferences().add(reference); - reference.setComponent(component); - SCABindingFactory scaBindingFactory = factories.getFactory(SCABindingFactory.class); - SCABinding binding = scaBindingFactory.createSCABinding(); - binding.setURI(targetURI); - reference.getBindings().add(binding); - return new ServiceReferenceImpl<B>(businessInterface, component, reference, binding, runtime - .getProxyFactory(), runtime.getCompositeActivator()); - } catch (Exception e) { - throw new ServiceRuntimeException(e); - } - } - @Override - public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String name) { - - // Extract the component name - String componentName; - String serviceName; - int i = name.indexOf('/'); - if (i != -1) { - componentName = name.substring(0, i); - serviceName = name.substring(i + 1); - - } else { - componentName = name; - serviceName = null; - } - - // Lookup the component in the domain - Component component = componentManager.getComponent(componentName); - if (component == null) { - // The component is not local in the partition, try to create a remote service ref - return createServiceReference(businessInterface, name); - } - RuntimeComponentContext componentContext = null; - - // If the component is a composite, then we need to find the - // non-composite component that provides the requested service - if (component.getImplementation() instanceof Composite) { - for (ComponentService componentService : component.getServices()) { - if (serviceName == null || serviceName.equals(componentService.getName())) { - CompositeService compositeService = (CompositeService)componentService.getService(); - if (compositeService != null) { - if (serviceName != null) { - serviceName = "$promoted$" + component.getName() + "$slash$" + serviceName; - } - componentContext = - ((RuntimeComponent)compositeService.getPromotedComponent()).getComponentContext(); - return componentContext.createSelfReference(businessInterface, compositeService - .getPromotedService()); - } - break; - } - } - // No matching service is found - throw new ServiceRuntimeException("Composite service not found: " + name); - } else { - componentContext = ((RuntimeComponent)component).getComponentContext(); - if (serviceName != null) { - return componentContext.createSelfReference(businessInterface, serviceName); - } else { - return componentContext.createSelfReference(businessInterface); - } - } - - } - - @Override - public String getURI() { - return uri; - } - -} diff --git a/branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/HotUpdatableSCADomain.java b/branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/HotUpdatableSCADomain.java deleted file mode 100644 index d59f1544e5..0000000000 --- a/branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/HotUpdatableSCADomain.java +++ /dev/null @@ -1,389 +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.host.embedded.impl; - -import java.io.File; -import java.io.FilenameFilter; -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URISyntaxException; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.logging.Logger; - -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException; -import org.apache.tuscany.sca.contribution.Contribution; -import org.apache.tuscany.sca.contribution.service.ContributionService; -import org.apache.tuscany.sca.contribution.service.util.FileHelper; -import org.apache.tuscany.sca.core.assembly.ActivationException; -import org.apache.tuscany.sca.host.embedded.SCADomain; -import org.apache.tuscany.sca.host.embedded.management.ComponentManager; -import org.osoa.sca.CallableReference; -import org.osoa.sca.ServiceReference; -import org.osoa.sca.ServiceRuntimeException; - -/** - * An SCADomain that starts a Tuscany runtime supporting multiple - * SCA contribution jars. All contribution jars found in a repository - * directory will be contributed to the SCA domain. Any changes to the - * contributions in that repository will be automatically detected and - * the SCADomain updated accordingly. - * - * TODO: find how to properly add/remove contributions and start/activate the SCADomain - * TODO: support contributions that are folders as well as jar's - * TODO: needs to restart the entire SCADomain when a contribution changes - * as the domain classpath includes all the contribution jar's, would - * be nice to find a way to avoid this - * TODO: hot update requires copying contribution jars to a temp location - * to avoid the classpath lock preventing updating the contribution - * jars, would be nice to find a way to avoid that - * - * @version $Rev$ $Date$ - */ -public class HotUpdatableSCADomain extends SCADomain { - private static final Logger logger = Logger.getLogger(HotUpdatableSCADomain.class.getName()); - protected String domainURI; - protected File contributionRepository; - - protected EmbeddedSCADomain scaDomain; - - protected boolean hotUpdateActive; - protected Thread hotUpdateThread; - protected int hotUpdateInterval; // milliseconds, 0 = hotupdate disabled - - protected HashMap<URL, Long> existingContributions; // value is last modified time - protected ClassLoader originalCCL; - - protected static final String REPOSITORY_FOLDER = "sca-contributions"; - - public HotUpdatableSCADomain(String domainURI, File contributionRepository, int hotupdateInterval) { - this.domainURI = domainURI; - this.contributionRepository = contributionRepository; - this.hotUpdateInterval = hotupdateInterval; - this.originalCCL = Thread.currentThread().getContextClassLoader(); - start(); - } - - protected void start() { - try { - initEmbeddedSCADomain(); - activateHotUpdate(); - for (URL url : existingContributions.keySet()) { - File f = new File(url.toURI()); - logger.info("added contribution: " + f.getName()); - } - } catch (ActivationException e) { - throw new ServiceRuntimeException(e); - } catch (URISyntaxException e) { - throw new ServiceRuntimeException(e); - } - } - - @Override - public void close() { - try { - hotUpdateActive = false; - scaDomain.stop(); - } catch (ActivationException e) { - throw new ServiceRuntimeException(e); - } - Thread.currentThread().setContextClassLoader(originalCCL); - super.close(); - } - - - protected SCADomain initEmbeddedSCADomain() throws ActivationException { - - URL[] contributionJars = getContributionJarURLs(contributionRepository); - - this.existingContributions = getLastModified(contributionJars); - - if (hotUpdateInterval > 0) { - contributionJars = copyContributionsToTemp(contributionJars); - } - - // Using the CCL as the parent exposes Tuscany to the contributions, want to do this? - URLClassLoader cl = new URLClassLoader(contributionJars, originalCCL); - Thread.currentThread().setContextClassLoader(cl); - - scaDomain = new EmbeddedSCADomain(cl, domainURI); - - scaDomain.start(); - - initContributions(scaDomain, cl, contributionJars); - - return scaDomain; - } - - protected URL[] getContributionJarURLs(File repositoryDir) { - - String[] jars = repositoryDir.list(new FilenameFilter() { - public boolean accept(File dir, String name) { - return name.endsWith(".jar"); - }}); - - List<URL> contributionJars = new ArrayList<URL>(); - if (jars != null) { - for (String jar : jars) { - try { - contributionJars.add(new File(repositoryDir, jar).toURL()); - } catch (MalformedURLException e) { - throw new RuntimeException(e); - } - } - } - - return contributionJars.toArray(new URL[contributionJars.size()]); - } - - /** - * TODO: No idea what the 'correct' way to add/contribute and activate/start things to an scaDomain is - * but this seems to work. Doesn't seem to start <service>s or <reference>s which are outside of - * a <component> so something is missing/wrong. Also this doesn't seem to be picking up composites - * located in META-INF/deployables or specified in the sca-deployables.xml. Maybe the EmbeddedSCADomain - * and ContributionService APIs should make all this easier? - */ - protected void initContributions(EmbeddedSCADomain scaDomain, ClassLoader cl, URL[] contributionJars) { - Contribution contribution = null; - ContributionService contributionService = scaDomain.getContributionService(); - for (URL jar : contributionJars) { - InputStream is = null; - try { - is = jar.openStream(); - contribution = contributionService.contribute(jar.toString(), jar, is); - } catch (Exception e) { - System.err.println("exception adding contribution: " + jar); - e.printStackTrace(); - } - if (is != null) { - try { - is.close(); - } catch (IOException e) { - // ignore - } - } - } - - if (contribution != null ) { - try { - - for (Composite composite : contribution.getDeployables()) { - scaDomain.getDomainComposite().getIncludes().add(composite); - scaDomain.getCompositeBuilder().build(composite); - scaDomain.getCompositeActivator().activate(composite); - } - - for (Composite composite : contribution.getDeployables()) { - scaDomain.getCompositeActivator().start(composite); - } - - } catch (ActivationException e) { - throw new RuntimeException(e); - } catch (CompositeBuilderException e) { - throw new RuntimeException(e); - } - } - - } - - /** - * Copies Files to a temp location returning the URLs of the new temp files. - * For hot update to work need to be able to delete/update the contribution jar's - * but as they're in the classpath the URLClassLoader has an open lock on the jar's - * so you can't update them. This solution copies each contribution to a temp - * location for use on the classpath, nicer would be a ClassLoder impl that doesn't - * lock the jar's. - */ - protected URL[] copyContributionsToTemp(URL[] contributionJars) { - try { - - URL[] newURLs = new URL[contributionJars.length]; - File tempDir = new File(System.getProperty("java.io.tmpdir")); - for (int i=0; i<contributionJars.length; i++) { - File fin = new File(contributionJars[i].toURI()); - File fout = File.createTempFile("tuscany", fin.getName(), tempDir); - fout.deleteOnExit(); - FileHelper.copyFile(fin, fout); - fout.setLastModified(System.currentTimeMillis()); - newURLs[i] = fout.toURL(); - } - return newURLs; - - } catch (IOException e) { - throw new RuntimeException(e); - } catch (URISyntaxException e) { - throw new RuntimeException(e); - } - } - - /** - * Returns the last modified times of the files pointed to by the URLs - */ - protected HashMap<URL, Long> getLastModified(URL[] contrabutions) { - try { - - HashMap<URL, Long> contributionLastUpdates = new HashMap<URL, Long>(); - for (URL url: contrabutions) { - File f = new File(url.toURI()); - contributionLastUpdates.put(url, new Long(f.lastModified())); - } - return contributionLastUpdates; - - } catch (URISyntaxException e) { - throw new RuntimeException(e); - } - } - - protected void activateHotUpdate() { - if (hotUpdateInterval == 0) { - return; // hotUpdateInterval of 0 disables hotupdate - } - - Runnable runable = new Runnable() { - public void run() { - logger.info("Tuscany contribution hotupdate running"); - while (hotUpdateActive) { - try { - Thread.sleep(hotUpdateInterval); - } catch (InterruptedException e) { - } - if (hotUpdateActive) { - checkForUpdates(); - } - } - logger.info("Tuscany contribution hotupdate stopped"); - } - }; - hotUpdateThread = new Thread(runable, "TuscanyHotUpdate"); - hotUpdateActive = true; - hotUpdateThread.start(); - } - - - /** - * Checks if any of the contributions have been updated and if so restarts the SCADomain - * TODO: Ideally just the altered contribution would be restarted but thats not possible - * as the ClassLoader used by the SCADomain includes the old contribution so need - * to restart the entire domain to use a new ClassLoader. Should there be separate - * ClassLoader per contribution? But then have all the issues with sharing classes - * across contributions. - */ - protected void checkForUpdates() { - URL[] currentContributions = getContributionJarURLs(contributionRepository); - - if (areContributionsAltered(currentContributions)) { - try { - scaDomain.stop(); - } catch (Exception e) { - e.printStackTrace(); - } - try { - initEmbeddedSCADomain(); - } catch (Exception e) { - e.printStackTrace(); - } - } - } - - protected boolean areContributionsAltered(URL[] currentContrabutions) { - try { - - List addedContributions = getAddedContributions(currentContrabutions); - List removedContributions = getRemovedContributions(currentContrabutions); - List updatedContributions = getUpdatedContributions(currentContrabutions); - - return (addedContributions.size() > 0 || removedContributions.size() > 0 || updatedContributions.size() > 0); - - } catch (URISyntaxException e) { - throw new RuntimeException(e); - } - } - - protected List<URL> getUpdatedContributions(URL[] currentContrabutions) throws URISyntaxException { - List<URL> urls = new ArrayList<URL>(); - for (URL url : currentContrabutions) { - if (existingContributions.containsKey(url)) { - File curentFile = new File(url.toURI()); - if (curentFile.lastModified() != existingContributions.get(url)) { - urls.add(url); - logger.info("updated contribution: " + curentFile.getName()); - } - } - } - return urls; - } - - protected List getRemovedContributions(URL[] currentContrabutions) throws URISyntaxException { - List<URL> currentUrls = Arrays.asList(currentContrabutions); - List<URL> urls = new ArrayList<URL>(); - for (URL url : existingContributions.keySet()) { - if (!currentUrls.contains(url)) { - urls.add(url); - } - } - for (URL url : urls) { - logger.info("removed contributions: " + new File(url.toURI()).getName()); - } - return urls; - } - - protected List getAddedContributions(URL[] currentContrabutions) throws URISyntaxException { - List<URL> urls = new ArrayList<URL>(); - for (URL url : currentContrabutions) { - if (!existingContributions.containsKey(url)) { - urls.add(url); - logger.info("added contribution: " + new File(url.toURI()).getName()); - } - } - return urls; - } - - @Override - public <B, R extends CallableReference<B>> R cast(B target) throws IllegalArgumentException { - throw new UnsupportedOperationException("not implemented"); - } - - @Override - public <B> B getService(Class<B> businessInterface, String serviceName) { - return scaDomain.getService(businessInterface, serviceName); - } - - @Override - public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String referenceName) { - return scaDomain.getServiceReference(businessInterface, referenceName); - } - - @Override - public String getURI() { - return domainURI; - } - - @Override - public ComponentManager getComponentManager(){ - return scaDomain.getComponentManager(); - } - -} diff --git a/branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntime.java b/branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntime.java deleted file mode 100644 index 51b22ffdb0..0000000000 --- a/branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntime.java +++ /dev/null @@ -1,385 +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.host.embedded.impl; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.transform.TransformerFactory; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.EndpointFactory; -import org.apache.tuscany.sca.assembly.SCABindingFactory; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException; -import org.apache.tuscany.sca.contribution.ContributionFactory; -import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.contribution.service.ContributionService; -import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.core.FactoryExtensionPoint; -import org.apache.tuscany.sca.core.ModuleActivator; -import org.apache.tuscany.sca.core.UtilityExtensionPoint; -import org.apache.tuscany.sca.core.assembly.ActivationException; -import org.apache.tuscany.sca.core.assembly.CompositeActivator; -import org.apache.tuscany.sca.core.assembly.RuntimeAssemblyFactory; -import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory; -import org.apache.tuscany.sca.core.invocation.ProxyFactory; -import org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint; -import org.apache.tuscany.sca.core.scope.ScopeRegistry; -import org.apache.tuscany.sca.definitions.SCADefinitions; -import org.apache.tuscany.sca.definitions.impl.SCADefinitionsImpl; -import org.apache.tuscany.sca.definitions.util.SCADefinitionsUtil; -import org.apache.tuscany.sca.extensibility.ServiceDeclaration; -import org.apache.tuscany.sca.extensibility.ServiceDiscovery; -import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; -import org.apache.tuscany.sca.invocation.MessageFactory; -import org.apache.tuscany.sca.monitor.DefaultMonitorFactory; -import org.apache.tuscany.sca.monitor.Monitor; -import org.apache.tuscany.sca.monitor.MonitorFactory; -import org.apache.tuscany.sca.policy.DefaultIntentAttachPointTypeFactory; -import org.apache.tuscany.sca.policy.DefaultPolicyFactory; -import org.apache.tuscany.sca.policy.Intent; -import org.apache.tuscany.sca.policy.IntentAttachPointType; -import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory; -import org.apache.tuscany.sca.policy.PolicyFactory; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.provider.SCADefinitionsProvider; -import org.apache.tuscany.sca.provider.SCADefinitionsProviderExtensionPoint; -import org.apache.tuscany.sca.work.WorkScheduler; - -/** - * - * @version $Rev$ $Date$ - */ -public class ReallySmallRuntime { - private static final Logger logger = Logger.getLogger(ReallySmallRuntime.class.getName()); - private List<ModuleActivator> modules; - private ExtensionPointRegistry registry; - - private ClassLoader classLoader; - private AssemblyFactory assemblyFactory; - private ContributionService contributionService; - private CompositeActivator compositeActivator; - private CompositeBuilder compositeBuilder; - // private DomainBuilder domainBuilder; - private WorkScheduler workScheduler; - private ScopeRegistry scopeRegistry; - private ProxyFactory proxyFactory; - private List<SCADefinitions> policyDefinitions; - private ModelResolver policyDefinitionsResolver; - private Monitor monitor; - - public ReallySmallRuntime(ClassLoader classLoader) { - this.classLoader = classLoader; - } - - public void start() throws ActivationException { - long start = System.currentTimeMillis(); - - // Create our extension point registry - registry = new DefaultExtensionPointRegistry(); - UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class); - - // Get work scheduler - workScheduler = utilities.getUtility(WorkScheduler.class); - - // Create an interface contract mapper - InterfaceContractMapper mapper = utilities.getUtility(InterfaceContractMapper.class); - - // Get factory extension point - FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class); - - // Get Message factory - MessageFactory messageFactory = factories.getFactory(MessageFactory.class); - - // Get proxy factory - ProxyFactoryExtensionPoint proxyFactories = registry.getExtensionPoint(ProxyFactoryExtensionPoint.class); - proxyFactory = new ExtensibleProxyFactory(proxyFactories); - - // Create model factories - assemblyFactory = new RuntimeAssemblyFactory(); - factories.addFactory(assemblyFactory); - PolicyFactory policyFactory = new DefaultPolicyFactory(); - factories.addFactory(policyFactory); - - // Load the runtime modules - modules = loadModules(registry); - - // Start the runtime modules - startModules(registry, modules); - - SCABindingFactory scaBindingFactory = factories.getFactory(SCABindingFactory.class); - IntentAttachPointTypeFactory intentAttachPointTypeFactory = new DefaultIntentAttachPointTypeFactory(); - factories.addFactory(intentAttachPointTypeFactory); - ContributionFactory contributionFactory = factories.getFactory(ContributionFactory.class); - - // Create a monitor - MonitorFactory monitorFactory = utilities.getUtility(MonitorFactory.class); - - if (monitorFactory != null){ - monitor = monitorFactory.createMonitor(); - } else { - monitorFactory = new DefaultMonitorFactory(); - monitor = monitorFactory.createMonitor(); - utilities.addUtility(monitorFactory); - //logger.fine("No MonitorFactory is found on the classpath."); - } - - // Create a contribution service - policyDefinitions = new ArrayList<SCADefinitions>(); - policyDefinitionsResolver = new DefaultModelResolver(); - contributionService = ReallySmallRuntimeBuilder.createContributionService(classLoader, - registry, - contributionFactory, - assemblyFactory, - policyFactory, - mapper, - policyDefinitions, - policyDefinitionsResolver, - monitor); - - // Create the ScopeRegistry - scopeRegistry = ReallySmallRuntimeBuilder.createScopeRegistry(registry); - - // Create a composite activator - compositeActivator = ReallySmallRuntimeBuilder.createCompositeActivator(registry, - assemblyFactory, - messageFactory, - scaBindingFactory, - mapper, - proxyFactory, - scopeRegistry, - workScheduler); - - // Load the definitions.xml - loadSCADefinitions(); - - if (logger.isLoggable(Level.FINE)) { - long end = System.currentTimeMillis(); - logger.fine("The tuscany runtime is started in " + (end - start) + " ms."); - } - } - - public void stop() throws ActivationException { - long start = System.currentTimeMillis(); - - // Stop the runtime modules - stopModules(registry, modules); - - // Stop and destroy the work manager - workScheduler.destroy(); - - // Cleanup - modules = null; - registry = null; - assemblyFactory = null; - contributionService = null; - compositeActivator = null; - workScheduler = null; - scopeRegistry = null; - - if (logger.isLoggable(Level.FINE)) { - long end = System.currentTimeMillis(); - logger.fine("The tuscany runtime is stopped in " + (end - start) + " ms."); - } - } - - public void buildComposite(Composite composite) throws CompositeBuilderException { - //Get factory extension point - FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class); - SCABindingFactory scaBindingFactory = factories.getFactory(SCABindingFactory.class); - IntentAttachPointTypeFactory intentAttachPointTypeFactory = factories.getFactory(IntentAttachPointTypeFactory.class); - EndpointFactory endpointFactory = factories.getFactory(EndpointFactory.class); - UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class); - InterfaceContractMapper mapper = utilities.getUtility(InterfaceContractMapper.class); - DocumentBuilderFactory documentBuilderFactory = factories.getFactory(DocumentBuilderFactory.class); - TransformerFactory transformerFactory = factories.getFactory(TransformerFactory.class); - - //Create a composite builder - SCADefinitions aggregatedDefinitions = new SCADefinitionsImpl(); - for ( SCADefinitions definition : ((List<SCADefinitions>)policyDefinitions) ) { - SCADefinitionsUtil.aggregateSCADefinitions(definition, aggregatedDefinitions); - } - compositeBuilder = ReallySmallRuntimeBuilder.createCompositeBuilder(monitor, - assemblyFactory, - scaBindingFactory, - endpointFactory, - intentAttachPointTypeFactory, - documentBuilderFactory, - transformerFactory, - mapper, - aggregatedDefinitions); - compositeBuilder.build(composite); - - } - - public ContributionService getContributionService() { - return contributionService; - } - - public CompositeActivator getCompositeActivator() { - return compositeActivator; - } - - public CompositeBuilder getCompositeBuilder() { - return compositeBuilder; - } - - public AssemblyFactory getAssemblyFactory() { - return assemblyFactory; - } - - private void loadSCADefinitions() throws ActivationException { - try { - URLArtifactProcessorExtensionPoint documentProcessors = registry.getExtensionPoint(URLArtifactProcessorExtensionPoint.class); - URLArtifactProcessor<SCADefinitions> definitionsProcessor = documentProcessors.getProcessor(SCADefinitions.class); - SCADefinitionsProviderExtensionPoint scaDefnProviders = registry.getExtensionPoint(SCADefinitionsProviderExtensionPoint.class); - - SCADefinitions systemSCADefinitions = new SCADefinitionsImpl(); - SCADefinitions aSCADefn = null; - for ( SCADefinitionsProvider aProvider : scaDefnProviders.getSCADefinitionsProviders() ) { - aSCADefn = aProvider.getSCADefinition(); - SCADefinitionsUtil.aggregateSCADefinitions(aSCADefn, systemSCADefinitions); - } - - policyDefinitions.add(systemSCADefinitions); - - //we cannot expect that providers will add the intents and policysets into the resolver - //so we do this here explicitly - for ( Intent intent : systemSCADefinitions.getPolicyIntents() ) { - policyDefinitionsResolver.addModel(intent); - } - - for ( PolicySet policySet : systemSCADefinitions.getPolicySets() ) { - policyDefinitionsResolver.addModel(policySet); - } - - for ( IntentAttachPointType attachPoinType : systemSCADefinitions.getBindingTypes() ) { - policyDefinitionsResolver.addModel(attachPoinType); - } - - for ( IntentAttachPointType attachPoinType : systemSCADefinitions.getImplementationTypes() ) { - policyDefinitionsResolver.addModel(attachPoinType); - } - - //now that all system sca definitions have been read, lets resolve them right away - definitionsProcessor.resolve(systemSCADefinitions, - policyDefinitionsResolver); - } catch ( Exception e ) { - throw new ActivationException(e); - } - } - - @SuppressWarnings("unchecked") - private List<ModuleActivator> loadModules(ExtensionPointRegistry registry) throws ActivationException { - - // Load and instantiate the modules found on the classpath (or any registered ClassLoaders) - modules = new ArrayList<ModuleActivator>(); - try { - Set<ServiceDeclaration> moduleActivators = - ServiceDiscovery.getInstance().getServiceDeclarations(ModuleActivator.class.getName()); - Set<String> moduleClasses = new HashSet<String>(); - for (ServiceDeclaration moduleDeclarator : moduleActivators) { - if (moduleClasses.contains(moduleDeclarator.getClassName())) { - continue; - } - moduleClasses.add(moduleDeclarator.getClassName()); - Class<?> moduleClass = moduleDeclarator.loadClass(); - ModuleActivator module = (ModuleActivator)moduleClass.newInstance(); - modules.add(module); - } - } catch (IOException e) { - throw new ActivationException(e); - } catch (ClassNotFoundException e) { - throw new ActivationException(e); - } catch (InstantiationException e) { - throw new ActivationException(e); - } catch (IllegalAccessException e) { - throw new ActivationException(e); - } - - return modules; - } - - private void startModules(ExtensionPointRegistry registry, List<ModuleActivator> modules) - throws ActivationException { - boolean debug = logger.isLoggable(Level.FINE); - // Start all the extension modules - for (ModuleActivator module : modules) { - long start = 0L; - if (debug) { - logger.fine(module.getClass().getName() + " is starting."); - start = System.currentTimeMillis(); - } - try { - module.start(registry); - if (debug) { - long end = System.currentTimeMillis(); - logger.fine(module.getClass().getName() + " is started in " + (end - start) + " ms."); - } - } catch (Throwable e) { - logger.log(Level.WARNING, "Exception starting module " + module.getClass().getName() + " :" + e.getMessage()); - logger.log(Level.FINE, "Exception starting module " + module.getClass().getName(), e); - } - } - } - - private void stopModules(final ExtensionPointRegistry registry, List<ModuleActivator> modules) { - boolean debug = logger.isLoggable(Level.FINE); - for (ModuleActivator module : modules) { - long start = 0L; - if (debug) { - logger.fine(module.getClass().getName() + " is stopping."); - start = System.currentTimeMillis(); - } - module.stop(registry); - if (debug) { - long end = System.currentTimeMillis(); - logger.fine(module.getClass().getName() + " is stopped in " + (end - start) + " ms."); - } - } - } - - /** - * @return the proxyFactory - */ - public ProxyFactory getProxyFactory() { - return proxyFactory; - } - - /** - * @return the registry - */ - public ExtensionPointRegistry getExtensionPointRegistry() { - return registry; - } - -} diff --git a/branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntimeBuilder.java b/branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntimeBuilder.java deleted file mode 100644 index 9b1ab420c9..0000000000 --- a/branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntimeBuilder.java +++ /dev/null @@ -1,275 +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.host.embedded.impl; - -import java.io.IOException; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.util.List; - -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.transform.TransformerFactory; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.EndpointFactory; -import org.apache.tuscany.sca.assembly.SCABindingFactory; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; -import org.apache.tuscany.sca.assembly.builder.impl.CompositeBuilderImpl; -import org.apache.tuscany.sca.assembly.xml.CompositeDocumentProcessor; -import org.apache.tuscany.sca.context.ContextFactoryExtensionPoint; -import org.apache.tuscany.sca.context.RequestContextFactory; -import org.apache.tuscany.sca.contribution.ContributionFactory; -import org.apache.tuscany.sca.contribution.processor.DefaultValidatingXMLInputFactory; -import org.apache.tuscany.sca.contribution.processor.DefaultValidationSchemaExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.ExtensiblePackageProcessor; -import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.PackageProcessor; -import org.apache.tuscany.sca.contribution.processor.PackageProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.ValidationSchemaExtensionPoint; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint; -import org.apache.tuscany.sca.contribution.service.ContributionListenerExtensionPoint; -import org.apache.tuscany.sca.contribution.service.ContributionRepository; -import org.apache.tuscany.sca.contribution.service.ContributionService; -import org.apache.tuscany.sca.contribution.service.ExtensibleContributionListener; -import org.apache.tuscany.sca.contribution.service.TypeDescriber; -import org.apache.tuscany.sca.contribution.service.impl.ContributionRepositoryImpl; -import org.apache.tuscany.sca.contribution.service.impl.ContributionServiceImpl; -import org.apache.tuscany.sca.contribution.service.impl.PackageTypeDescriberImpl; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.core.FactoryExtensionPoint; -import org.apache.tuscany.sca.core.UtilityExtensionPoint; -import org.apache.tuscany.sca.core.assembly.ActivationException; -import org.apache.tuscany.sca.core.assembly.CompositeActivator; -import org.apache.tuscany.sca.core.assembly.CompositeActivatorImpl; -import org.apache.tuscany.sca.core.conversation.ConversationManager; -import org.apache.tuscany.sca.core.invocation.ExtensibleWireProcessor; -import org.apache.tuscany.sca.core.invocation.ProxyFactory; -import org.apache.tuscany.sca.core.scope.CompositeScopeContainerFactory; -import org.apache.tuscany.sca.core.scope.ConversationalScopeContainerFactory; -import org.apache.tuscany.sca.core.scope.RequestScopeContainerFactory; -import org.apache.tuscany.sca.core.scope.ScopeContainerFactory; -import org.apache.tuscany.sca.core.scope.ScopeRegistry; -import org.apache.tuscany.sca.core.scope.ScopeRegistryImpl; -import org.apache.tuscany.sca.core.scope.StatelessScopeContainerFactory; -import org.apache.tuscany.sca.definitions.SCADefinitions; -import org.apache.tuscany.sca.endpointresolver.EndpointResolverFactoryExtensionPoint; -import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; -import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; -import org.apache.tuscany.sca.invocation.MessageFactory; -import org.apache.tuscany.sca.monitor.Monitor; -import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory; -import org.apache.tuscany.sca.policy.PolicyFactory; -import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint; -import org.apache.tuscany.sca.runtime.RuntimeWireProcessor; -import org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint; -import org.apache.tuscany.sca.work.WorkScheduler; - -/** - * - * @version $Rev$ $Date$ - */ -public class ReallySmallRuntimeBuilder { - - // private static final Logger logger = Logger.getLogger(ReallySmallRuntimeBuilder.class.getName()); - - public static CompositeActivator createCompositeActivator(ExtensionPointRegistry registry, - AssemblyFactory assemblyFactory, - MessageFactory messageFactory, - SCABindingFactory scaBindingFactory, - InterfaceContractMapper mapper, - ProxyFactory proxyFactory, - ScopeRegistry scopeRegistry, - WorkScheduler workScheduler) { - - // Create a wire post processor extension point - RuntimeWireProcessorExtensionPoint wireProcessors = - registry.getExtensionPoint(RuntimeWireProcessorExtensionPoint.class); - RuntimeWireProcessor wireProcessor = new ExtensibleWireProcessor(wireProcessors); - - // Retrieve the processors extension point - StAXArtifactProcessorExtensionPoint processors = - registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); - - // Create a provider factory extension point - ProviderFactoryExtensionPoint providerFactories = - registry.getExtensionPoint(ProviderFactoryExtensionPoint.class); - - // Create a endpoint resolver factory extension point - EndpointResolverFactoryExtensionPoint endpointResolverFactories = - registry.getExtensionPoint(EndpointResolverFactoryExtensionPoint.class); - - JavaInterfaceFactory javaInterfaceFactory = - registry.getExtensionPoint(FactoryExtensionPoint.class).getFactory(JavaInterfaceFactory.class); - RequestContextFactory requestContextFactory = - registry.getExtensionPoint(ContextFactoryExtensionPoint.class).getFactory(RequestContextFactory.class); - - UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class); - ConversationManager conversationManager = utilities.getUtility(ConversationManager.class); - - // Create the composite activator - CompositeActivator compositeActivator = - new CompositeActivatorImpl(assemblyFactory, messageFactory, javaInterfaceFactory, scaBindingFactory, - mapper, scopeRegistry, workScheduler, wireProcessor, requestContextFactory, - proxyFactory, providerFactories, endpointResolverFactories, processors, conversationManager); - - return compositeActivator; - } - - public static CompositeBuilder createCompositeBuilder(Monitor monitor, - AssemblyFactory assemblyFactory, - SCABindingFactory scaBindingFactory, - EndpointFactory endpointFactory, - IntentAttachPointTypeFactory intentAttachPointTypeFactory, - DocumentBuilderFactory documentBuilderFactory, - TransformerFactory transformerFactory, - InterfaceContractMapper interfaceContractMapper, - SCADefinitions policyDefinitions) { - - - return new CompositeBuilderImpl(assemblyFactory, - endpointFactory, - scaBindingFactory, - intentAttachPointTypeFactory, - documentBuilderFactory, - transformerFactory, - interfaceContractMapper, - policyDefinitions, - monitor); - } - - - /** - * Create the contribution service used by this domain. - * - * @throws ActivationException - */ - public static ContributionService createContributionService(ClassLoader classLoader, - ExtensionPointRegistry registry, - ContributionFactory contributionFactory, - AssemblyFactory assemblyFactory, - PolicyFactory policyFactory, - InterfaceContractMapper mapper, - List<SCADefinitions> policyDefinitions, - ModelResolver policyDefinitionResolver, - Monitor monitor) - throws ActivationException { - - // Get the model factory extension point - FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class); - - // Create a new XML input factory - // Allow privileged access to factory. Requires RuntimePermission in security policy file. - XMLInputFactory inputFactory = AccessController.doPrivileged(new PrivilegedAction<XMLInputFactory>() { - public XMLInputFactory run() { - return XMLInputFactory.newInstance(); - } - }); - modelFactories.addFactory(inputFactory); - - // Create a validation XML schema extension point - ValidationSchemaExtensionPoint schemas = new DefaultValidationSchemaExtensionPoint(); - - // Create a validating XML input factory - XMLInputFactory validatingInputFactory = new DefaultValidatingXMLInputFactory(inputFactory, schemas, monitor); - modelFactories.addFactory(validatingInputFactory); - - // Create StAX artifact processor extension point - StAXArtifactProcessorExtensionPoint staxProcessors = - registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); - - // Create and register StAX processors for SCA assembly XML - // Allow privileged access to factory. Requires RuntimePermission in security policy file. - XMLOutputFactory outputFactory = AccessController.doPrivileged(new PrivilegedAction<XMLOutputFactory>() { - public XMLOutputFactory run() { - return XMLOutputFactory.newInstance(); - } - }); - ExtensibleStAXArtifactProcessor staxProcessor = - new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory, monitor); - - // Create URL artifact processor extension point - URLArtifactProcessorExtensionPoint documentProcessors = - registry.getExtensionPoint(URLArtifactProcessorExtensionPoint.class); - - // Create and register document processors for SCA assembly XML - documentProcessors.getProcessor(Composite.class); - DocumentBuilderFactory documentBuilderFactory = AccessController.doPrivileged(new PrivilegedAction<DocumentBuilderFactory>() { - public DocumentBuilderFactory run() { - return DocumentBuilderFactory.newInstance(); - } - }); - documentProcessors.addArtifactProcessor(new CompositeDocumentProcessor(staxProcessor, validatingInputFactory, documentBuilderFactory, policyDefinitions, monitor)); - - // Create Model Resolver extension point - ModelResolverExtensionPoint modelResolvers = registry.getExtensionPoint(ModelResolverExtensionPoint.class); - - // Create contribution package processor extension point - TypeDescriber describer = new PackageTypeDescriberImpl(); - PackageProcessor packageProcessor = - new ExtensiblePackageProcessor(registry.getExtensionPoint(PackageProcessorExtensionPoint.class), describer, monitor); - - // Create contribution listener - ExtensibleContributionListener contributionListener = - new ExtensibleContributionListener(registry.getExtensionPoint(ContributionListenerExtensionPoint.class)); - - // Create a contribution repository - ContributionRepository repository; - try { - repository = new ContributionRepositoryImpl("target", inputFactory, monitor); - } catch (IOException e) { - throw new ActivationException(e); - } - - ExtensibleURLArtifactProcessor documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors, monitor); - - // Create the contribution service - ContributionService contributionService = - new ContributionServiceImpl(repository, packageProcessor, documentProcessor, staxProcessor, - contributionListener, policyDefinitionResolver, modelResolvers, modelFactories, - assemblyFactory, contributionFactory, inputFactory, policyDefinitions, monitor); - return contributionService; - } - - public static ScopeRegistry createScopeRegistry(ExtensionPointRegistry registry) { - ScopeRegistry scopeRegistry = new ScopeRegistryImpl(); - ScopeContainerFactory[] factories = - new ScopeContainerFactory[] {new CompositeScopeContainerFactory(), new StatelessScopeContainerFactory(), - new RequestScopeContainerFactory(), - new ConversationalScopeContainerFactory(null), - // new HttpSessionScopeContainer(monitor) - }; - for (ScopeContainerFactory f : factories) { - scopeRegistry.register(f); - } - - //FIXME Pass the scope container differently as it's not an extension point - registry.addExtensionPoint(scopeRegistry); - - return scopeRegistry; - } - -} diff --git a/branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/ComponentListener.java b/branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/ComponentListener.java deleted file mode 100644 index 5f38c0c063..0000000000 --- a/branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/ComponentListener.java +++ /dev/null @@ -1,34 +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.host.embedded.management; - -import java.util.EventListener; - -/** - * Component Listener interface. - * - * @version $Rev$ $Date$ - */ -public interface ComponentListener extends EventListener { - - void componentStarted(String componentName); - void componentStopped(String componentName); - -} diff --git a/branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/ComponentManager.java b/branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/ComponentManager.java deleted file mode 100644 index 4acb270810..0000000000 --- a/branches/sca-equinox/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/ComponentManager.java +++ /dev/null @@ -1,48 +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.host.embedded.management; - -import java.util.Set; - -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.core.assembly.ActivationException; - -/** - * Component Manager interface. - * - * @version $Rev$ $Date$ - */ -public interface ComponentManager { - - Set<String> getComponentNames(); - - Component getComponent(String componentName); - - boolean isComponentStarted(String componentName); - - void startComponent(String componentName) throws ActivationException; - - void stopComponent(String componentName) throws ActivationException; - - void addComponentListener(ComponentListener listener); - - void removeComponentListener(ComponentListener listener); - -} diff --git a/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/SCADomainBeanTestCase.java b/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/SCADomainBeanTestCase.java deleted file mode 100644 index 9252b114a1..0000000000 --- a/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/SCADomainBeanTestCase.java +++ /dev/null @@ -1,57 +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.host.embedded; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.host.embedded.test.extension.TestService; -import org.osoa.sca.ServiceReference; - - - -/** - * Test creation of an SCADomainBean and invocation of a service. - * - * @version $Rev$ $Date$ - */ -public class SCADomainBeanTestCase extends TestCase { - - private SCADomainBean domain; - - @Override - protected void setUp() throws Exception { - domain = new SCADomainBean(); - domain.setDeployableComposites("test.composite"); - } - - public void testInvoke() throws Exception { - ServiceReference<TestService> serviceReference = domain.getServiceReference(TestService.class, "TestServiceComponent"); - assertNotNull(serviceReference); - TestService service = serviceReference.getService(); - String result = service.ping("Bob"); - assertEquals("Hello Bob", result); - } - - @Override - protected void tearDown() throws Exception { - domain.close(); - } - -} diff --git a/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/SCADomainTestCase.java b/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/SCADomainTestCase.java deleted file mode 100644 index c52c16d8e1..0000000000 --- a/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/SCADomainTestCase.java +++ /dev/null @@ -1,56 +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.host.embedded; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.host.embedded.test.extension.TestService; -import org.osoa.sca.ServiceReference; - - - -/** - * Test SCADomain.newInstance and invocation of a service. - * - * @version $Rev$ $Date$ - */ -public class SCADomainTestCase extends TestCase { - - private SCADomain domain; - - @Override - protected void setUp() throws Exception { - domain = SCADomain.newInstance("test.composite"); - } - - public void testInvoke() throws Exception { - ServiceReference<TestService> serviceReference = domain.getServiceReference(TestService.class, "TestServiceComponent"); - assertNotNull(serviceReference); - TestService service = serviceReference.getService(); - String result = service.ping("Bob"); - assertEquals("Hello Bob", result); - } - - @Override - protected void tearDown() throws Exception { - domain.close(); - } - -} diff --git a/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/impl/DefaultSCADomainTestCase.java b/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/impl/DefaultSCADomainTestCase.java deleted file mode 100644 index fd5398c8e6..0000000000 --- a/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/impl/DefaultSCADomainTestCase.java +++ /dev/null @@ -1,63 +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.host.embedded.impl; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.host.embedded.management.ComponentManager; -import org.apache.tuscany.sca.host.embedded.test.extension.TestService; - - -/** - * Test creation of DefaultSCADomain. - * - * @version $Rev$ $Date$ - */ -public class DefaultSCADomainTestCase extends TestCase { - private DefaultSCADomain domain; - - @Override - protected void setUp() throws Exception { - domain = new DefaultSCADomain(getClass().getClassLoader(), getClass().getClassLoader(), - "http://localhost", "./target/test-classes", "test.composite"); - } - - public void testStart() throws Exception { - TestService service = domain.getService(TestService.class, "TestServiceComponent"); - assertNotNull(service); - } - - public void testComponentManager() throws Exception { - ComponentManager componentManager = domain.getComponentManager(); - assertEquals(1, componentManager.getComponentNames().size()); - assertEquals("TestServiceComponent", componentManager.getComponentNames().iterator().next()); - assertNotNull(componentManager.getComponent("TestServiceComponent")); - - assertTrue(componentManager.isComponentStarted("TestServiceComponent")); - componentManager.stopComponent("TestServiceComponent"); - assertFalse(componentManager.isComponentStarted("TestServiceComponent")); - } - - @Override - protected void tearDown() throws Exception { - domain.close(); - } - -} diff --git a/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/impl/EmbeddedSCADomainTestCase.java b/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/impl/EmbeddedSCADomainTestCase.java deleted file mode 100644 index 2a59635a19..0000000000 --- a/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/impl/EmbeddedSCADomainTestCase.java +++ /dev/null @@ -1,189 +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.host.embedded.impl; - -import java.net.URL; - -import javax.xml.namespace.QName; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.contribution.Contribution; -import org.apache.tuscany.sca.contribution.service.ContributionService; -import org.apache.tuscany.sca.host.embedded.management.ComponentListener; -import org.apache.tuscany.sca.host.embedded.management.ComponentManager; -import org.apache.tuscany.sca.host.embedded.test.extension.TestService; - -/** - * Test creation of an EmbeddedSCADomain and invocation of a service. - * - * @version $Rev$ $Date$ - */ -public class EmbeddedSCADomainTestCase extends TestCase { - private EmbeddedSCADomain domain; - - @Override - protected void setUp() throws Exception { - - // Create a test embedded SCA domain - domain = new EmbeddedSCADomain(getClass().getClassLoader(), "http://localhost"); - } - - public void testDomain() throws Exception { - // Start the domain - domain.start(); - - // Determine my class loader and my test SCA contribution location - ClassLoader myClassLoader = getClass().getClassLoader(); - String url = myClassLoader.getResource("test.txt").toString(); - url = url.substring(0, url.length()-8); - - // Contribute the SCA contribution - TestModelResolver myResolver = new TestModelResolver(myClassLoader); - ContributionService contributionService = domain.getContributionService(); - Contribution contribution = contributionService.contribute("http://test/contribution", new URL(url), myResolver, false); - assertNotNull(contribution); - - // Decide which SCA composite I want to deploy - Composite myComposite = myResolver.getComposite(new QName("http://test", "test")); - - // Add the deployable composite to the domain - domain.getDomainComposite().getIncludes().add(myComposite); - - - domain.buildComposite(myComposite); - - // Start the composite - domain.getCompositeActivator().activate(myComposite); - domain.getCompositeActivator().start(myComposite); - - // At this point the domain contains my contribution, my composite and - // it's started, my application code can start using it - - // Get the TestServiceComponent service - TestService service = domain.getService(TestService.class, "TestServiceComponent"); - - // Invoke the service - String result = service.ping("Bob"); - assertEquals("Hello Bob", result); - - // Stop my composite - domain.getCompositeActivator().stop(myComposite); - domain.getCompositeActivator().deactivate(myComposite); - - // Remove my composite - domain.getDomainComposite().getIncludes().remove(myComposite); - - // Remove my contribution - contributionService.remove("http://test/contribution"); - - // Stop the domain - domain.stop(); - } - - public void testComponentManager() throws Exception { - // Start the domain - domain.start(); - - // Determine my class loader and my test SCA contribution location - ClassLoader myClassLoader = getClass().getClassLoader(); - String url = myClassLoader.getResource("test.txt").toString(); - url = url.substring(0, url.length()-8); - - // Contribute the SCA contribution - TestModelResolver myResolver = new TestModelResolver(myClassLoader); - ContributionService contributionService = domain.getContributionService(); - Contribution contribution = contributionService.contribute("http://test/contribution", new URL(url), myResolver, false); - assertNotNull(contribution); - - // Decide which SCA composite I want to deploy - Composite myComposite = myResolver.getComposite(new QName("http://test", "test")); - - // Add the deployable composite to the domain - domain.getDomainComposite().getIncludes().add(myComposite); - - domain.buildComposite(myComposite); - - // Start the composite - domain.getCompositeActivator().activate(myComposite); - domain.getCompositeActivator().start(myComposite); - - // At this point the domain contains my contribution, my composite and - // it's started, my application code can start using it - - ComponentManager componentManager = domain.getComponentManager(); - assertEquals(1, componentManager.getComponentNames().size()); - assertEquals("TestServiceComponent", componentManager.getComponentNames().iterator().next()); - - Component component = componentManager.getComponent("TestServiceComponent"); - assertNotNull(component); - assertEquals("TestServiceComponent", component.getName()); - - MyComponentListener cl = new MyComponentListener(); - componentManager.addComponentListener(cl); - - assertTrue(componentManager.isComponentStarted("TestServiceComponent")); - - assertFalse(cl.stopCalled); - componentManager.stopComponent("TestServiceComponent"); - assertTrue(cl.stopCalled); - assertFalse(componentManager.isComponentStarted("TestServiceComponent")); - - assertFalse(cl.startCalled); - componentManager.startComponent("TestServiceComponent"); - assertTrue(cl.startCalled); - assertTrue(componentManager.isComponentStarted("TestServiceComponent")); - - // Stop my composite - domain.getCompositeActivator().stop(myComposite); - domain.getCompositeActivator().deactivate(myComposite); - - // Remove my composite - domain.getDomainComposite().getIncludes().remove(myComposite); - - // Remove my contribution - contributionService.remove("http://test/contribution"); - - // Stop the domain - domain.stop(); - } - - class MyComponentListener implements ComponentListener { - boolean startCalled; - boolean stopCalled; - - public void componentStarted(String componentName) { - startCalled = true; - } - - public void componentStopped(String componentName) { - stopCalled = true; - } - - } - - @Override - protected void tearDown() throws Exception { - domain.close(); - } - -} diff --git a/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/impl/TestModelResolver.java b/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/impl/TestModelResolver.java deleted file mode 100644 index 1cfe5ed5d8..0000000000 --- a/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/impl/TestModelResolver.java +++ /dev/null @@ -1,104 +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.host.embedded.impl; - -import java.lang.ref.WeakReference; -import java.util.HashMap; -import java.util.Map; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.contribution.resolver.ClassReference; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; - - -/** - * A test model resolver, based on a map. - * - * @version $Rev$ $Date$ - */ -public class TestModelResolver implements ModelResolver { - private static final long serialVersionUID = -7826976465762296634L; - - private Map<Object, Object> map = new HashMap<Object, Object>(); - private WeakReference<ClassLoader> classLoader; - - private Map<QName, Composite> composites = new HashMap<QName, Composite>(); - - public TestModelResolver(ClassLoader classLoader) { - this.classLoader = new WeakReference<ClassLoader>(classLoader); - } - - public <T> T resolveModel(Class<T> modelClass, T unresolved) { - Object resolved = map.get(unresolved); - if (resolved != null) { - - // Return the resolved object - return modelClass.cast(resolved); - - } else if (unresolved instanceof ClassReference) { - - // Load a class on demand - ClassReference classReference = (ClassReference)unresolved; - Class<?> clazz; - try { - clazz = Class.forName(classReference.getClassName(), true, classLoader.get()); - } catch (ClassNotFoundException e) { - - // Return the unresolved object - return unresolved; - } - - // Store a new ClassReference wrapping the loaded class - resolved = new ClassReference(clazz); - map.put(resolved, resolved); - - // Return the resolved ClassReference - return modelClass.cast(resolved); - - } else { - - // Return the unresolved object - return unresolved; - } - } - - public void addModel(Object resolved) { - map.put(resolved, resolved); - if (resolved instanceof Composite) { - Composite composite = (Composite)resolved; - composites.put(composite.getName(), composite); - } - } - - public Object removeModel(Object resolved) { - if (resolved instanceof Composite) { - Composite composite = (Composite)resolved; - composites.remove(composite.getName()); - } - return map.remove(resolved); - } - - public Composite getComposite(QName qname) { - return composites.get(qname); - } - -} diff --git a/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/DefaultTestImplementationFactory.java b/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/DefaultTestImplementationFactory.java deleted file mode 100644 index 86e0cb6a8a..0000000000 --- a/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/DefaultTestImplementationFactory.java +++ /dev/null @@ -1,47 +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.host.embedded.test.extension; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.host.embedded.test.extension.impl.TestImplementationImpl; -import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; - - -/** - * Default factory for the test implementation model. - * - * @version $Rev$ $Date$ - */ -public class DefaultTestImplementationFactory implements TestImplementationFactory { - - private AssemblyFactory assemblyFactory; - private JavaInterfaceFactory javaFactory; - - public DefaultTestImplementationFactory(AssemblyFactory assemblyFactory, - JavaInterfaceFactory javaFactory) { - this.assemblyFactory = assemblyFactory; - this.javaFactory = javaFactory; - } - - public TestImplementation createTestImplementation() { - return new TestImplementationImpl(assemblyFactory, javaFactory); - } - -} diff --git a/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/TestImplementation.java b/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/TestImplementation.java deleted file mode 100644 index d9f1228307..0000000000 --- a/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/TestImplementation.java +++ /dev/null @@ -1,44 +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.host.embedded.test.extension; - -import org.apache.tuscany.sca.assembly.Implementation; - -/** - * The model representing a test implementation in an SCA assembly model. - * - * @version $Rev$ $Date$ - */ -public interface TestImplementation extends Implementation { - - /** - * Returns the greeting string that can be configured on test implementations. - * - * @return the greeting string that can be configured on test implementations - */ - String getGreeting(); - - /** - * Sets the greeting string that can be configured on test implementations. - * - * @param greeting the greeting string that can be configured on test implementations - */ - void setGreeting(String greeting); - -} diff --git a/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/TestService.java b/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/TestService.java deleted file mode 100644 index 4adec91151..0000000000 --- a/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/TestService.java +++ /dev/null @@ -1,30 +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.host.embedded.test.extension; - -/** - * Service interface for test component implementations. - * - * @version $Rev$ $Date$ - */ -public interface TestService { - - String ping(String name); - -} diff --git a/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/impl/TestImplementationImpl.java b/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/impl/TestImplementationImpl.java deleted file mode 100644 index 083b01167f..0000000000 --- a/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/impl/TestImplementationImpl.java +++ /dev/null @@ -1,117 +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.host.embedded.test.extension.impl; - -import java.util.Collections; -import java.util.List; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.ConstrainingType; -import org.apache.tuscany.sca.assembly.Property; -import org.apache.tuscany.sca.assembly.Reference; -import org.apache.tuscany.sca.assembly.Service; -import org.apache.tuscany.sca.host.embedded.test.extension.TestService; -import org.apache.tuscany.sca.host.embedded.test.extension.TestImplementation; -import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException; -import org.apache.tuscany.sca.interfacedef.java.JavaInterface; -import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract; -import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; - - -/** - * The model representing a test implementation in an SCA assembly model. - * - * @version $Rev$ $Date$ - */ -public class TestImplementationImpl implements TestImplementation { - - private Service testService; - private String greeting; - - /** - * Constructs a new test implementation. - */ - public TestImplementationImpl(AssemblyFactory assemblyFactory, - JavaInterfaceFactory javaFactory) { - - // Test implementations always provide a single service exposing - // the TestService interface, and have no references and properties - testService = assemblyFactory.createService(); - testService.setName("Test"); - JavaInterface javaInterface; - try { - javaInterface = javaFactory.createJavaInterface(TestService.class); - } catch (InvalidInterfaceException e) { - throw new IllegalArgumentException(e); - } - JavaInterfaceContract interfaceContract = javaFactory.createJavaInterfaceContract(); - interfaceContract.setInterface(javaInterface); - testService.setInterfaceContract(interfaceContract); - } - - public String getGreeting() { - return greeting; - } - - public void setGreeting(String greeting) { - this.greeting = greeting; - } - - public ConstrainingType getConstrainingType() { - // The test implementation does not support constrainingTypes - return null; - } - - public List<Property> getProperties() { - // The test implementation does not support properties - return Collections.emptyList(); - } - - public List<Service> getServices() { - // The test implementation provides a single fixed Test service - return Collections.singletonList(testService); - } - - public List<Reference> getReferences() { - // The test implementation does not support properties - return Collections.emptyList(); - } - - public String getURI() { - // The test implementation does not have a URI - return null; - } - - public void setConstrainingType(ConstrainingType constrainingType) { - // The test implementation does not support constrainingTypes - } - - public void setURI(String uri) { - // The test implementation does not have a URI - } - - public boolean isUnresolved() { - // The test implementation is always resolved - return false; - } - - public void setUnresolved(boolean unresolved) { - // The test implementation is always resolved - } -} diff --git a/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/impl/TestImplementationProcessor.java b/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/impl/TestImplementationProcessor.java deleted file mode 100644 index 73feffad50..0000000000 --- a/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/impl/TestImplementationProcessor.java +++ /dev/null @@ -1,96 +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.host.embedded.test.extension.impl; - -import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; - -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.contribution.service.ContributionReadException; -import org.apache.tuscany.sca.contribution.service.ContributionResolveException; -import org.apache.tuscany.sca.contribution.service.ContributionWriteException; -import org.apache.tuscany.sca.host.embedded.test.extension.TestImplementation; -import org.apache.tuscany.sca.host.embedded.test.extension.TestImplementationFactory; - - - -/** - * Implements a StAX artifact processor for test implementations. - * - * @version $Rev$ $Date$ - */ -public class TestImplementationProcessor implements StAXArtifactProcessor<TestImplementation> { - private static final QName IMPLEMENTATION_TEST = new QName("http://test/extension", "implementation.test"); - - private TestImplementationFactory testFactory; - - public TestImplementationProcessor(TestImplementationFactory testFactory) { - this.testFactory = testFactory; - } - - public QName getArtifactType() { - // Returns the QName of the XML element processed by this processor - return IMPLEMENTATION_TEST; - } - - public Class<TestImplementation> getModelType() { - // Returns the type of model processed by this processor - return TestImplementation.class; - } - - public TestImplementation read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { - - // Read an <implementation.test> element - - // Read the message attribute. - String message = reader.getAttributeValue(null, "greeting"); - - // Create and initialize the test implementation model - TestImplementation implementation = testFactory.createTestImplementation(); - implementation.setGreeting(message); - - // Skip to end element - while (reader.hasNext()) { - if (reader.next() == END_ELEMENT && IMPLEMENTATION_TEST.equals(reader.getName())) { - break; - } - } - - return implementation; - } - - public void resolve(TestImplementation impl, ModelResolver resolver) throws ContributionResolveException { - } - - public void write(TestImplementation implementation, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException { - - writer.writeStartElement(IMPLEMENTATION_TEST.getNamespaceURI(), IMPLEMENTATION_TEST.getLocalPart()); - - if (implementation.getGreeting() != null) { - writer.writeAttribute("greeting", implementation.getGreeting()); - } - - writer.writeEndElement(); - } -} diff --git a/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/module/TestModuleActivator.java b/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/module/TestModuleActivator.java deleted file mode 100644 index e89df5a555..0000000000 --- a/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/module/TestModuleActivator.java +++ /dev/null @@ -1,65 +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.host.embedded.test.extension.module; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.core.FactoryExtensionPoint; -import org.apache.tuscany.sca.core.ModuleActivator; -import org.apache.tuscany.sca.host.embedded.test.extension.DefaultTestImplementationFactory; -import org.apache.tuscany.sca.host.embedded.test.extension.TestImplementationFactory; -import org.apache.tuscany.sca.host.embedded.test.extension.impl.TestImplementationProcessor; -import org.apache.tuscany.sca.host.embedded.test.extension.provider.TestImplementationProviderFactory; -import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; -import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint; - - - -/** - * Implements a module activator for the test implementation extension module. - * - * @version $Rev$ $Date$ - */ -public class TestModuleActivator implements ModuleActivator { - - public void start(ExtensionPointRegistry registry) { - - // Create the test implementation factory - FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class); - AssemblyFactory assemblyFactory = modelFactories.getFactory(AssemblyFactory.class); - JavaInterfaceFactory javaFactory = modelFactories.getFactory(JavaInterfaceFactory.class); - TestImplementationFactory testFactory = new DefaultTestImplementationFactory(assemblyFactory, javaFactory); - modelFactories.addFactory(testFactory); - - // Add the test implementation extension to the StAXArtifactProcessor - // extension point - StAXArtifactProcessorExtensionPoint processors = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); - TestImplementationProcessor implementationArtifactProcessor = new TestImplementationProcessor(testFactory); - processors.addArtifactProcessor(implementationArtifactProcessor); - - // Add the test provider factory to the ProviderFactory extension point - ProviderFactoryExtensionPoint providerFactories = registry.getExtensionPoint(ProviderFactoryExtensionPoint.class); - providerFactories.addProviderFactory(new TestImplementationProviderFactory()); - } - - public void stop(ExtensionPointRegistry registry) { - } -} diff --git a/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/provider/TestImplementationProvider.java b/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/provider/TestImplementationProvider.java deleted file mode 100644 index 1d27e08fee..0000000000 --- a/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/provider/TestImplementationProvider.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.host.embedded.test.extension.provider; - -import org.apache.tuscany.sca.host.embedded.test.extension.TestImplementation; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.provider.ImplementationProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; - - -/** - * Implementation provider for test implementations. - * - * @version $Rev$ $Date$ - */ -public class TestImplementationProvider implements ImplementationProvider { - - private RuntimeComponent component; - private TestImplementation implementation; - - /** - * Constructs a new test implementation provider. - */ - public TestImplementationProvider(RuntimeComponent component, TestImplementation implementation) { - this.component = component; - this.implementation = implementation; - } - - public Invoker createInvoker(RuntimeComponentService service, Operation operation) { - TestInvoker invoker = new TestInvoker(operation, implementation.getGreeting()); - return invoker; - } - - public boolean supportsOneWayInvocation() { - return false; - } - - public void start() { - System.out.println("Starting " + component.getName()); - } - - public void stop() { - System.out.println("Stopping " + component.getName()); - } - -} diff --git a/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/provider/TestImplementationProviderFactory.java b/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/provider/TestImplementationProviderFactory.java deleted file mode 100644 index 15d3618fdd..0000000000 --- a/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/provider/TestImplementationProviderFactory.java +++ /dev/null @@ -1,47 +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.host.embedded.test.extension.provider; - -import org.apache.tuscany.sca.host.embedded.test.extension.TestImplementation; -import org.apache.tuscany.sca.provider.ImplementationProvider; -import org.apache.tuscany.sca.provider.ImplementationProviderFactory; -import org.apache.tuscany.sca.runtime.RuntimeComponent; - - -/** - * The model representing a test implementation in an SCA assembly model. - * - * @version $Rev$ $Date$ - */ -public class TestImplementationProviderFactory implements ImplementationProviderFactory<TestImplementation> { - - /** - * Constructs a new test implementation provider factory. - */ - public TestImplementationProviderFactory() { - } - - public ImplementationProvider createImplementationProvider(RuntimeComponent component, TestImplementation implementation) { - return new TestImplementationProvider(component, implementation); - } - - public Class<TestImplementation> getModelType() { - return TestImplementation.class; - } -} diff --git a/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/provider/TestInvoker.java b/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/provider/TestInvoker.java deleted file mode 100644 index d49179dec0..0000000000 --- a/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/provider/TestInvoker.java +++ /dev/null @@ -1,52 +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.host.embedded.test.extension.provider; - -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.invocation.Message; - - -/** - * Implements an invoker for test component implementations. - * - * The target invoker is responsible for handling operation invocations. - * - * @version $Rev$ $Date$ - */ -public class TestInvoker implements Invoker { - private Operation operation; - private String greeting; - - public TestInvoker(Operation operation, String greeting) { - this.operation = operation; - this.greeting = greeting; - } - - public Message invoke(Message msg) { - Object[] args = msg.getBody(); - if (operation.getName().equals("ping")) { - msg.setBody(greeting + " " + args[0]); - } else { - msg.setFaultBody(new Exception("Operation " + operation.getName() + " is not supported")); - } - return msg; - } -} diff --git a/branches/sca-equinox/modules/host-embedded/src/test/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator b/branches/sca-equinox/modules/host-embedded/src/test/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator deleted file mode 100644 index 7e2e11e4cc..0000000000 --- a/branches/sca-equinox/modules/host-embedded/src/test/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator +++ /dev/null @@ -1,18 +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.
-# Implementation class for the ExtensionActivator
-org.apache.tuscany.sca.host.embedded.test.extension.module.TestModuleActivator
diff --git a/branches/sca-equinox/modules/host-embedded/src/test/resources/test.composite b/branches/sca-equinox/modules/host-embedded/src/test/resources/test.composite deleted file mode 100644 index bd7c5fab79..0000000000 --- a/branches/sca-equinox/modules/host-embedded/src/test/resources/test.composite +++ /dev/null @@ -1,30 +0,0 @@ -<?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. ---> -<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" - targetNamespace="http://test" - xmlns:se="http://test" - xmlns:e="http://test/extension" - name="test"> - - <component name="TestServiceComponent"> - <e:implementation.test greeting="Hello" /> - </component> - -</composite> diff --git a/branches/sca-equinox/modules/host-embedded/src/test/resources/test.txt b/branches/sca-equinox/modules/host-embedded/src/test/resources/test.txt deleted file mode 100644 index 287f9b1f65..0000000000 --- a/branches/sca-equinox/modules/host-embedded/src/test/resources/test.txt +++ /dev/null @@ -1,16 +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.
\ No newline at end of file diff --git a/branches/sca-equinox/modules/host-webapp/pom.xml b/branches/sca-equinox/modules/host-webapp/pom.xml index 7ef183ddeb..40eb79e2c2 100644 --- a/branches/sca-equinox/modules/host-webapp/pom.xml +++ b/branches/sca-equinox/modules/host-webapp/pom.xml @@ -44,8 +44,9 @@ <dependency> <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-host-embedded</artifactId> - <version>1.4-SNAPSHOT</version> + <artifactId>tuscany-node-impl</artifactId> + <version>1.4-SNAPSHOT</version> + <scope>test</scope> </dependency> <dependency> diff --git a/branches/sca-equinox/modules/implementation-bpel-ode/pom.xml b/branches/sca-equinox/modules/implementation-bpel-ode/pom.xml index bd829fc33f..d774e1265b 100644 --- a/branches/sca-equinox/modules/implementation-bpel-ode/pom.xml +++ b/branches/sca-equinox/modules/implementation-bpel-ode/pom.xml @@ -78,11 +78,11 @@ <artifactId>tuscany-implementation-java-runtime</artifactId>
<version>1.4-SNAPSHOT</version>
</dependency>
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-host-embedded</artifactId>
- <version>1.4-SNAPSHOT</version>
- </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>1.4-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-interface-wsdl</artifactId>
diff --git a/branches/sca-equinox/modules/implementation-ejb/pom.xml b/branches/sca-equinox/modules/implementation-ejb/pom.xml index 31da4af3c2..d671743942 100644 --- a/branches/sca-equinox/modules/implementation-ejb/pom.xml +++ b/branches/sca-equinox/modules/implementation-ejb/pom.xml @@ -45,9 +45,9 @@ <dependency> <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-host-embedded</artifactId> + <artifactId>tuscany-node-impl</artifactId> <version>1.4-SNAPSHOT</version> - <scope>test</scope> + <scope>test</scope> </dependency> <dependency> diff --git a/branches/sca-equinox/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/launcher/NodeImplementationDaemonBootstrap.java b/branches/sca-equinox/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/launcher/NodeImplementationDaemonBootstrap.java index 8de2a3a3f9..48abc21520 100644 --- a/branches/sca-equinox/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/launcher/NodeImplementationDaemonBootstrap.java +++ b/branches/sca-equinox/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/launcher/NodeImplementationDaemonBootstrap.java @@ -19,8 +19,12 @@ package org.apache.tuscany.sca.implementation.node.launcher; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; +import org.osoa.sca.CallableReference; +import org.osoa.sca.ServiceReference; /** * Bootstrap class for the SCA node daemon. @@ -28,15 +32,15 @@ import org.apache.tuscany.sca.node.SCANodeFactory; * @version $Rev$ $Date$ */ public class NodeImplementationDaemonBootstrap { - private SCANode node; + private Node node; /** * A node wrappering an instance of a node daemon. */ - public static class NodeFacade implements SCANode { + public static class NodeFacade implements Node { private ClassLoader threadContextClassLoader; private ClassLoader runtimeClassLoader; - private SCANode daemon; + private Node daemon; private NodeFacade() { runtimeClassLoader = Thread.currentThread().getContextClassLoader(); @@ -47,8 +51,9 @@ public class NodeImplementationDaemonBootstrap { boolean started = false; try { Thread.currentThread().setContextClassLoader(runtimeClassLoader); - SCANodeFactory factory = SCANodeFactory.newInstance(); - daemon = factory.createSCANodeFromClassLoader("NodeDaemon.composite", threadContextClassLoader); + NodeFactory factory = NodeFactory.newInstance(); + String contribution = ContributionLocationHelper.getContributionLocation(getClass()); + daemon = factory.createNode("NodeDaemon.composite", new Contribution("node-runtime", contribution)); started = true; } finally { if (!started) { @@ -65,6 +70,27 @@ public class NodeImplementationDaemonBootstrap { Thread.currentThread().setContextClassLoader(threadContextClassLoader); } } + + public void destroy() { + try { + Thread.currentThread().setContextClassLoader(runtimeClassLoader); + daemon.destroy(); + } finally { + Thread.currentThread().setContextClassLoader(threadContextClassLoader); + } + } + + public <B, R extends CallableReference<B>> R cast(B target) throws IllegalArgumentException { + throw new UnsupportedOperationException(); + } + + public <B> B getService(Class<B> businessInterface, String serviceName) { + throw new UnsupportedOperationException(); + } + + public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String serviceName) { + throw new UnsupportedOperationException(); + } } /** @@ -78,7 +104,7 @@ public class NodeImplementationDaemonBootstrap { * Returns the node representing the daemon. * @return */ - public SCANode getNode() { + public Node getNode() { return node; } diff --git a/branches/sca-equinox/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/launcher/NodeImplementationLauncherBootstrap.java b/branches/sca-equinox/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/launcher/NodeImplementationLauncherBootstrap.java index 0264574fb9..8552c3434d 100644 --- a/branches/sca-equinox/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/launcher/NodeImplementationLauncherBootstrap.java +++ b/branches/sca-equinox/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/launcher/NodeImplementationLauncherBootstrap.java @@ -19,10 +19,10 @@ package org.apache.tuscany.sca.implementation.node.launcher; -import org.apache.tuscany.sca.node.SCAClient; -import org.apache.tuscany.sca.node.SCAContribution; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Client; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.osoa.sca.CallableReference; import org.osoa.sca.ServiceReference; @@ -33,17 +33,17 @@ import org.osoa.sca.ServiceReference; */ public class NodeImplementationLauncherBootstrap { - private SCANode node; + private Node node; /** * A node facade. */ - public static class NodeFacade implements SCANode, SCAClient { + public static class NodeFacade implements Node, Client { private ClassLoader threadContextClassLoader; private ClassLoader runtimeClassLoader; - private SCANode delegate; + private Node delegate; - private NodeFacade(SCANode delegate) { + private NodeFacade(Node delegate) { runtimeClassLoader = Thread.currentThread().getContextClassLoader(); this.delegate = delegate; } @@ -71,16 +71,25 @@ public class NodeImplementationLauncherBootstrap { } } + public void destroy() { + try { + Thread.currentThread().setContextClassLoader(runtimeClassLoader); + delegate.destroy(); + } finally { + Thread.currentThread().setContextClassLoader(threadContextClassLoader); + } + } + public <B, R extends CallableReference<B>> R cast(B target) throws IllegalArgumentException { - return (R)((SCAClient)delegate).cast(target); + return (R)((Client)delegate).cast(target); } public <B> B getService(Class<B> businessInterface, String serviceName) { - return (B)((SCAClient)delegate).getService(businessInterface, serviceName); + return (B)((Client)delegate).getService(businessInterface, serviceName); } public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String referenceName) { - return (ServiceReference<B>)((SCAClient)delegate).getServiceReference(businessInterface, referenceName); + return (ServiceReference<B>)((Client)delegate).getServiceReference(businessInterface, referenceName); } } @@ -90,19 +99,8 @@ public class NodeImplementationLauncherBootstrap { * @param configurationURI */ public NodeImplementationLauncherBootstrap(String configurationURI) throws Exception { - SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); - node = new NodeFacade(nodeFactory.createSCANodeFromURL(configurationURI)); - } - - /** - * Bootstrap a new SCA node. - * - * @param configurationURI - * @param contributionClassLoader - */ - public NodeImplementationLauncherBootstrap(String compositeURI, ClassLoader contributionClassLoader) throws Exception { - SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); - node = new NodeFacade(nodeFactory.createSCANodeFromClassLoader(compositeURI, contributionClassLoader)); + NodeFactory nodeFactory = NodeFactory.newInstance(); + node = new NodeFacade(nodeFactory.createNode(configurationURI)); } /** @@ -113,12 +111,12 @@ public class NodeImplementationLauncherBootstrap { * @param locations */ public NodeImplementationLauncherBootstrap(String compositeURI, String[] uris, String[] locations) throws Exception { - SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); - SCAContribution[] contributions = new SCAContribution[uris.length]; + NodeFactory nodeFactory = NodeFactory.newInstance(); + Contribution[] contributions = new Contribution[uris.length]; for (int i = 0; i < uris.length; i++) { - contributions[i] = new SCAContribution(uris[i], locations[i]); + contributions[i] = new Contribution(uris[i], locations[i]); } - node = new NodeFacade(nodeFactory.createSCANode(compositeURI, contributions)); + node = new NodeFacade(nodeFactory.createNode(compositeURI, contributions)); } /** @@ -129,12 +127,12 @@ public class NodeImplementationLauncherBootstrap { * @param locations */ public NodeImplementationLauncherBootstrap(String compositeURI, String compositeContent, String[] uris, String[] locations) throws Exception { - SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); - SCAContribution[] contributions = new SCAContribution[uris.length]; + NodeFactory nodeFactory = NodeFactory.newInstance(); + Contribution[] contributions = new Contribution[uris.length]; for (int i = 0; i < uris.length; i++) { - contributions[i] = new SCAContribution(uris[i], locations[i]); + contributions[i] = new Contribution(uris[i], locations[i]); } - node = new NodeFacade(nodeFactory.createSCANode(compositeURI, compositeContent, contributions)); + node = new NodeFacade(nodeFactory.createNode(compositeURI, compositeContent, contributions)); } /** @@ -142,7 +140,7 @@ public class NodeImplementationLauncherBootstrap { * * @return */ - public SCANode getNode() { + public Node getNode() { return node; } diff --git a/branches/sca-equinox/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/webapp/NodeWebAppServletHost.java b/branches/sca-equinox/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/webapp/NodeWebAppServletHost.java index 5a50f87d4c..43c91ac9af 100644 --- a/branches/sca-equinox/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/webapp/NodeWebAppServletHost.java +++ b/branches/sca-equinox/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/webapp/NodeWebAppServletHost.java @@ -47,9 +47,9 @@ import org.apache.tuscany.sca.host.http.ServletHost; import org.apache.tuscany.sca.host.http.ServletHostExtensionPoint; import org.apache.tuscany.sca.host.http.ServletMappingException; import org.apache.tuscany.sca.implementation.node.launcher.NodeImplementationLauncherUtil; -import org.apache.tuscany.sca.node.SCAClient; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Client; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; /** * ServletHost implementation for use in a Webapp Node environment. @@ -62,7 +62,7 @@ public class NodeWebAppServletHost implements ServletHost, Filter { private static final NodeWebAppServletHost servletHost = new NodeWebAppServletHost(); private Map<String, Servlet> servlets = new HashMap<String, Servlet>(); - private SCANode node; + private Node node; private String contextPath = "/"; private int defaultPort = 8080; @@ -112,8 +112,8 @@ public class NodeWebAppServletHost implements ServletHost, Filter { String nodeConfiguration = NodeImplementationLauncherUtil.nodeConfigurationURI(nodeName); // Create the SCA node - SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); - node = nodeFactory.createSCANodeFromURL(nodeConfiguration); + NodeFactory nodeFactory = NodeFactory.newInstance(); + node = nodeFactory.createNode(nodeConfiguration); // Register the Servlet host ServletHostExtensionPoint servletHosts = servletHosts(node); @@ -121,7 +121,7 @@ public class NodeWebAppServletHost implements ServletHost, Filter { servletHosts.addServletHost(servletHost); // Save the node in the Servlet context - servletContext.setAttribute(SCAClient.class.getName(), node); + servletContext.setAttribute(Client.class.getName(), node); // Start the node node.start(); @@ -350,7 +350,7 @@ public class NodeWebAppServletHost implements ServletHost, Filter { * * @return */ - private static ServletHostExtensionPoint servletHosts(SCANode node) { + private static ServletHostExtensionPoint servletHosts(Node node) { //FIXME Need a clean way to get the extension point registry // from the node ExtensionPointRegistry registry; diff --git a/branches/sca-equinox/modules/implementation-node-runtime/src/test/java/org/apache/tuscany/sca/implementation/node/NodeImplementationTestCase.java b/branches/sca-equinox/modules/implementation-node-runtime/src/test/java/org/apache/tuscany/sca/implementation/node/NodeImplementationTestCase.java index 73475f49fe..8e016054c4 100644 --- a/branches/sca-equinox/modules/implementation-node-runtime/src/test/java/org/apache/tuscany/sca/implementation/node/NodeImplementationTestCase.java +++ b/branches/sca-equinox/modules/implementation-node-runtime/src/test/java/org/apache/tuscany/sca/implementation/node/NodeImplementationTestCase.java @@ -20,8 +20,10 @@ package org.apache.tuscany.sca.implementation.node; import junit.framework.TestCase; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; /** * Test case for node component implementations. @@ -30,11 +32,13 @@ import org.apache.tuscany.sca.node.SCANodeFactory; */ public class NodeImplementationTestCase extends TestCase { - private SCANode node; + private Node node; @Override protected void setUp() throws Exception { - node = SCANodeFactory.newInstance().createSCANodeFromClassLoader("TestNode.composite", null); + String contribution = ContributionLocationHelper.getContributionLocation(getClass()); + node = NodeFactory.newInstance().createNode("TestNode.composite", new Contribution("test", contribution)); + node.start(); } @Override diff --git a/branches/sca-equinox/modules/implementation-resource-runtime/pom.xml b/branches/sca-equinox/modules/implementation-resource-runtime/pom.xml index 33270149b5..d4145c5e8b 100644 --- a/branches/sca-equinox/modules/implementation-resource-runtime/pom.xml +++ b/branches/sca-equinox/modules/implementation-resource-runtime/pom.xml @@ -50,7 +50,7 @@ <dependency> <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-host-embedded</artifactId> + <artifactId>tuscany-node-impl</artifactId> <version>1.4-SNAPSHOT</version> <scope>test</scope> </dependency> diff --git a/branches/sca-equinox/modules/implementation-resource-runtime/src/test/java/org/apache/tuscany/sca/implementation/resource/ResourceImplementationTestCase.java b/branches/sca-equinox/modules/implementation-resource-runtime/src/test/java/org/apache/tuscany/sca/implementation/resource/ResourceImplementationTestCase.java index 03f10e78e8..9b3c959753 100644 --- a/branches/sca-equinox/modules/implementation-resource-runtime/src/test/java/org/apache/tuscany/sca/implementation/resource/ResourceImplementationTestCase.java +++ b/branches/sca-equinox/modules/implementation-resource-runtime/src/test/java/org/apache/tuscany/sca/implementation/resource/ResourceImplementationTestCase.java @@ -25,27 +25,33 @@ import java.io.InputStreamReader; import junit.framework.TestCase; -import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; /** * @version $Rev$ $Date$ */ public class ResourceImplementationTestCase extends TestCase { - private SCADomain scaDomain; + private Node node; @Override protected void setUp() throws Exception { - scaDomain = SCADomain.newInstance("resource.composite"); + String contribution = ContributionLocationHelper.getContributionLocation(getClass()); + node = NodeFactory.newInstance().createNode("resource.composite", new Contribution("test", contribution)); + node.start(); } @Override protected void tearDown() throws Exception { - scaDomain.close(); + node.stop(); + node.destroy(); } public void testResource() throws Exception { - Resource resource = scaDomain.getService(Resource.class, "ResourceServiceComponent"); + Resource resource = node.getService(Resource.class, "ResourceServiceComponent"); InputStream is = resource.get("test.html"); String document = read(is); assertTrue(document.indexOf("<body><p>hello</body>") != -1); diff --git a/branches/sca-equinox/modules/implementation-script-runtime/pom.xml b/branches/sca-equinox/modules/implementation-script-runtime/pom.xml index 5e5c78ced4..d590ebb4c4 100644 --- a/branches/sca-equinox/modules/implementation-script-runtime/pom.xml +++ b/branches/sca-equinox/modules/implementation-script-runtime/pom.xml @@ -121,7 +121,7 @@ <dependency>
<groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-host-embedded</artifactId>
+ <artifactId>tuscany-node-impl</artifactId>
<version>1.4-SNAPSHOT</version>
<scope>test</scope>
</dependency>
diff --git a/branches/sca-equinox/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/AbstractSCATestCase.java b/branches/sca-equinox/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/AbstractSCATestCase.java index fc87f92ef1..f098885741 100644 --- a/branches/sca-equinox/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/AbstractSCATestCase.java +++ b/branches/sca-equinox/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/AbstractSCATestCase.java @@ -21,7 +21,10 @@ package org.apache.tuscany.sca.implementation.script.itests; import junit.framework.TestCase; -import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; /** * @@ -29,21 +32,24 @@ import org.apache.tuscany.sca.host.embedded.SCADomain; */ public abstract class AbstractSCATestCase<T> extends TestCase { - protected SCADomain domain; + protected Node node; protected T service; @Override @SuppressWarnings("unchecked") protected void setUp() throws Exception { - domain = SCADomain.newInstance(getCompositeName()); - service = (T) domain.getService(getServiceClass(), "ClientComponent"); + String contribution = ContributionLocationHelper.getContributionLocation(getClass()); + node = NodeFactory.newInstance().createNode(getCompositeName(), new Contribution("test", contribution)); + node.start(); + service = (T) node.getService(getServiceClass(), "ClientComponent"); } protected abstract Class getServiceClass(); @Override protected void tearDown() throws Exception { - domain.close(); + node.stop(); + node.destroy(); } protected String getCompositeName() { diff --git a/branches/sca-equinox/modules/implementation-spring/pom.xml b/branches/sca-equinox/modules/implementation-spring/pom.xml index 284244c761..4b2b516eea 100644 --- a/branches/sca-equinox/modules/implementation-spring/pom.xml +++ b/branches/sca-equinox/modules/implementation-spring/pom.xml @@ -79,10 +79,11 @@ <dependency> <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-host-embedded</artifactId> + <artifactId>tuscany-node-impl</artifactId> <version>1.4-SNAPSHOT</version> + <scope>test</scope> </dependency> - + <!-- Spring dependencies... --> <dependency> <groupId>org.springframework</groupId> diff --git a/branches/sca-equinox/modules/implementation-spring/src/test/java/org/apache/tuscany/sca/implementation/spring/itests/AbstractSCATestCase.java b/branches/sca-equinox/modules/implementation-spring/src/test/java/org/apache/tuscany/sca/implementation/spring/itests/AbstractSCATestCase.java index 6b2d114756..d782384ce6 100644 --- a/branches/sca-equinox/modules/implementation-spring/src/test/java/org/apache/tuscany/sca/implementation/spring/itests/AbstractSCATestCase.java +++ b/branches/sca-equinox/modules/implementation-spring/src/test/java/org/apache/tuscany/sca/implementation/spring/itests/AbstractSCATestCase.java @@ -21,7 +21,10 @@ package org.apache.tuscany.sca.implementation.spring.itests; import junit.framework.TestCase; -import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; /** * @@ -29,20 +32,23 @@ import org.apache.tuscany.sca.host.embedded.SCADomain; */ public abstract class AbstractSCATestCase<T> extends TestCase { - protected SCADomain domain; + protected Node node; protected T service; @Override protected void setUp() throws Exception { - domain = SCADomain.newInstance(getCompositeName()); - service = (T)domain.getService(getServiceClass(), "ClientComponent"); + String contribution = ContributionLocationHelper.getContributionLocation(getClass()); + node = NodeFactory.newInstance().createNode(getCompositeName(), new Contribution("test", contribution)); + node.start(); + service = (T)node.getService(getServiceClass(), "ClientComponent"); } protected abstract Class getServiceClass(); @Override protected void tearDown() throws Exception { - domain.close(); + node.stop(); + node.destroy(); } protected String getCompositeName() { diff --git a/branches/sca-equinox/modules/implementation-widget-runtime/pom.xml b/branches/sca-equinox/modules/implementation-widget-runtime/pom.xml index 43ae9aa3ef..3902dfae58 100644 --- a/branches/sca-equinox/modules/implementation-widget-runtime/pom.xml +++ b/branches/sca-equinox/modules/implementation-widget-runtime/pom.xml @@ -78,11 +78,11 @@ <!-- Test dependencies --> <dependency> <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-host-embedded</artifactId> + <artifactId>tuscany-node-impl</artifactId> <version>1.4-SNAPSHOT</version> <scope>test</scope> </dependency> - + <dependency> <groupId>org.apache.tuscany.sca</groupId> <artifactId>tuscany-host-jetty</artifactId> diff --git a/branches/sca-equinox/modules/implementation-widget-runtime/src/test/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationTestCase.java b/branches/sca-equinox/modules/implementation-widget-runtime/src/test/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationTestCase.java index 3b5c6f89b2..3d559c20d5 100644 --- a/branches/sca-equinox/modules/implementation-widget-runtime/src/test/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationTestCase.java +++ b/branches/sca-equinox/modules/implementation-widget-runtime/src/test/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationTestCase.java @@ -22,23 +22,29 @@ import java.net.Socket; import junit.framework.TestCase; -import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; /** * @version $Rev$ $Date$ */ public class WidgetImplementationTestCase extends TestCase { - private SCADomain scaDomain; + private Node node; @Override protected void setUp() throws Exception { - scaDomain = SCADomain.newInstance("widget.composite"); + String contribution = ContributionLocationHelper.getContributionLocation(getClass()); + node = NodeFactory.newInstance().createNode("widget.composite", new Contribution("test", contribution)); + node.start(); } @Override protected void tearDown() throws Exception { - scaDomain.close(); + node.stop(); + node.destroy(); } public void testPing() throws Exception { diff --git a/branches/sca-equinox/modules/implementation-xquery/pom.xml b/branches/sca-equinox/modules/implementation-xquery/pom.xml index 10a35783e7..0f6a5b66a7 100644 --- a/branches/sca-equinox/modules/implementation-xquery/pom.xml +++ b/branches/sca-equinox/modules/implementation-xquery/pom.xml @@ -69,7 +69,7 @@ <dependency> <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-host-embedded</artifactId> + <artifactId>tuscany-node-impl</artifactId> <version>1.4-SNAPSHOT</version> <scope>test</scope> </dependency> diff --git a/branches/sca-equinox/modules/node-api/src/main/java/org/apache/tuscany/sca/node/SCAClient.java b/branches/sca-equinox/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Client.java index f390e8881e..8ca5262eff 100644 --- a/branches/sca-equinox/modules/node-api/src/main/java/org/apache/tuscany/sca/node/SCAClient.java +++ b/branches/sca-equinox/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Client.java @@ -28,7 +28,7 @@ import org.osoa.sca.ServiceReference; * * @version $Rev$ $Date$ */ -public interface SCAClient { +public interface Client { /** * Cast a type-safe reference to a CallahbleReference. Converts a type-safe diff --git a/branches/sca-equinox/modules/node-api/src/main/java/org/apache/tuscany/sca/node/SCAContribution.java b/branches/sca-equinox/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Contribution.java index de7f352122..f69e18dc63 100644 --- a/branches/sca-equinox/modules/node-api/src/main/java/org/apache/tuscany/sca/node/SCAContribution.java +++ b/branches/sca-equinox/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Contribution.java @@ -21,7 +21,7 @@ package org.apache.tuscany.sca.node; /** * Represents an SCA contribution uri + location. */ -public final class SCAContribution { +public final class Contribution { private String uri; private String location; @@ -31,7 +31,7 @@ public final class SCAContribution { * @param uri The URI that uniquely identifies the contribution in the SCA domain * @param location The URL of the contribution archive */ - public SCAContribution(String uri, String location) { + public Contribution(String uri, String location) { this.uri = uri; this.location = location; } diff --git a/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/TestImplementationFactory.java b/branches/sca-equinox/modules/node-api/src/main/java/org/apache/tuscany/sca/node/ContributionLocationHelper.java index 9200d850bb..74ebe556bc 100644 --- a/branches/sca-equinox/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/TestImplementationFactory.java +++ b/branches/sca-equinox/modules/node-api/src/main/java/org/apache/tuscany/sca/node/ContributionLocationHelper.java @@ -17,21 +17,33 @@ * under the License. */ -package org.apache.tuscany.sca.host.embedded.test.extension; +package org.apache.tuscany.sca.node; +import java.net.URL; +import java.security.AccessController; +import java.security.PrivilegedAction; /** - * A factory for the test implementation model. + * ContributionLocationHelper * - * @version $Rev$ $Date$ + * @version $Rev: $ $Date: $ */ -public interface TestImplementationFactory { +public class ContributionLocationHelper { /** - * Creates a new test implementation. + * Returns the location of the SCA contribution containing the given class. * + * @param anchorClass * @return */ - TestImplementation createTestImplementation(); + public static String getContributionLocation(final Class<?> anchorClass) { + URL url = AccessController.doPrivileged(new PrivilegedAction<URL>() { + public URL run() { + return anchorClass.getProtectionDomain().getCodeSource().getLocation(); + } + }); + String uri = url.toString(); + return uri; + } } diff --git a/branches/sca-equinox/modules/node-api/src/main/java/org/apache/tuscany/sca/node/SCANode.java b/branches/sca-equinox/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Node.java index fea749a57c..3f4998bcc9 100644 --- a/branches/sca-equinox/modules/node-api/src/main/java/org/apache/tuscany/sca/node/SCANode.java +++ b/branches/sca-equinox/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Node.java @@ -27,7 +27,7 @@ package org.apache.tuscany.sca.node; * * @version $Rev$ $Date$ */ -public interface SCANode { +public interface Node extends Client { /** * Start the composite loaded in the node. @@ -38,5 +38,10 @@ public interface SCANode { * Stop the composite loaded in the node. */ void stop(); + + /** + * Destroy the node. + */ + void destroy(); } diff --git a/branches/sca-equinox/modules/node-api/src/main/java/org/apache/tuscany/sca/node/SCANodeFactory.java b/branches/sca-equinox/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java index bca649dbae..a9f75fc8be 100644 --- a/branches/sca-equinox/modules/node-api/src/main/java/org/apache/tuscany/sca/node/SCANodeFactory.java +++ b/branches/sca-equinox/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java @@ -31,9 +31,9 @@ import org.osoa.sca.ServiceRuntimeException; * * @version $Rev$ $Date$ */ -public abstract class SCANodeFactory { +public abstract class NodeFactory { - public static class NodeProxy implements SCANode, SCAClient { + public static class NodeProxy implements Node, Client { private Object node; private NodeProxy(Object node) { @@ -95,6 +95,14 @@ public abstract class SCANodeFactory { } } + public void destroy() { + try { + node.getClass().getMethod("destroy").invoke(node); + } catch (Throwable e) { + handleException(e); + } + } + private static void handleException(Throwable ex) { if (ex instanceof InvocationTargetException) { ex = ((InvocationTargetException)ex).getTargetException(); @@ -116,8 +124,8 @@ public abstract class SCANodeFactory { * * @return a new SCA node factory */ - public static SCANodeFactory newInstance() { - SCANodeFactory scaNodeFactory = null; + public static NodeFactory newInstance() { + NodeFactory scaNodeFactory = null; try { // final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); @@ -125,10 +133,10 @@ public abstract class SCANodeFactory { try { Class<?> discoveryClass = Class.forName("org.apache.tuscany.sca.extensibility.ServiceDiscovery"); Object instance = discoveryClass.getMethod("getInstance").invoke(null); - Object factoryDeclaration = discoveryClass.getMethod("getFirstServiceDeclaration", String.class).invoke(instance, SCANodeFactory.class.getName()); + Object factoryDeclaration = discoveryClass.getMethod("getFirstServiceDeclaration", String.class).invoke(instance, NodeFactory.class.getName()); if (factoryDeclaration != null) { Class<?> factoryImplClass = (Class<?>)factoryDeclaration.getClass().getMethod("loadClass").invoke(factoryDeclaration); - scaNodeFactory = (SCANodeFactory)factoryImplClass.newInstance(); + scaNodeFactory = (NodeFactory)factoryImplClass.newInstance(); return scaNodeFactory; } } catch (ClassNotFoundException e) { @@ -139,7 +147,7 @@ public abstract class SCANodeFactory { String className = "org.apache.tuscany.sca.node.impl.NodeFactoryImpl"; Class<?> cls = Class.forName(className); - scaNodeFactory = (SCANodeFactory)cls.newInstance(); + scaNodeFactory = (NodeFactory)cls.newInstance(); return scaNodeFactory; } catch (Exception e) { @@ -155,7 +163,7 @@ public abstract class SCANodeFactory { * * @return a new SCA node. */ - public abstract SCANode createSCANodeFromURL(String configurationURL); + public abstract Node createNode(String configurationURL); /** * Creates a new SCA node. @@ -167,7 +175,7 @@ public abstract class SCANodeFactory { * * @return a new SCA node. */ - public abstract SCANode createSCANode(String compositeURI, SCAContribution... contributions); + public abstract Node createNode(String compositeURI, Contribution... contributions); /** * Creates a new SCA node. @@ -177,8 +185,8 @@ public abstract class SCANodeFactory { * @param contributions the URI of the contributions that provides the composites and related artifacts * @return a new SCA node. */ - public abstract SCANode createSCANode(String compositeURI, + public abstract Node createNode(String compositeURI, String compositeContent, - SCAContribution... contributions); + Contribution... contributions); } diff --git a/branches/sca-equinox/modules/node-impl/pom.xml b/branches/sca-equinox/modules/node-impl/pom.xml index f932c9abc4..4239a1ee03 100644 --- a/branches/sca-equinox/modules/node-impl/pom.xml +++ b/branches/sca-equinox/modules/node-impl/pom.xml @@ -76,6 +76,12 @@ <dependency> <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-workspace</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> <artifactId>tuscany-definitions-xml</artifactId> <version>1.4-SNAPSHOT</version> <scope>runtime</scope> diff --git a/branches/sca-equinox/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java b/branches/sca-equinox/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java index 946c6b06e0..62758e8332 100644 --- a/branches/sca-equinox/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java +++ b/branches/sca-equinox/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java @@ -19,31 +19,31 @@ package org.apache.tuscany.sca.node.impl; -import org.apache.tuscany.sca.node.SCAContribution; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; /** * Default implementation of an SCA node factory. * * @version $Rev$ $Date$ */ -public class NodeFactoryImpl extends SCANodeFactory { +public class NodeFactoryImpl extends NodeFactory { public NodeFactoryImpl() { } @Override - public SCANode createSCANodeFromURL(String configurationURI) { + public Node createNode(String configurationURI) { return new NodeImpl(configurationURI); } @Override - public SCANode createSCANode(String compositeURI, SCAContribution... contributions) { + public Node createNode(String compositeURI, Contribution... contributions) { return new NodeImpl(compositeURI, contributions); } @Override - public SCANode createSCANode(String compositeURI, String compositeContent, SCAContribution... contributions) { + public Node createNode(String compositeURI, String compositeContent, Contribution... contributions) { return new NodeImpl(compositeURI, compositeContent, contributions); } diff --git a/branches/sca-equinox/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java b/branches/sca-equinox/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java index e53f478864..fb22d2ea5d 100644 --- a/branches/sca-equinox/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java +++ b/branches/sca-equinox/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java @@ -22,15 +22,13 @@ package org.apache.tuscany.sca.node.impl; import static java.lang.System.currentTimeMillis; import static org.apache.tuscany.sca.node.impl.NodeUtil.contribution; import static org.apache.tuscany.sca.node.impl.NodeUtil.createURI; -import static org.apache.tuscany.sca.node.impl.NodeUtil.loadModules; -import static org.apache.tuscany.sca.node.impl.NodeUtil.startModules; -import static org.apache.tuscany.sca.node.impl.NodeUtil.stopModules; import java.io.ByteArrayInputStream; import java.io.File; import java.io.InputStream; import java.net.URI; import java.net.URL; +import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -77,9 +75,8 @@ import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.MonitorFactory; import org.apache.tuscany.sca.monitor.Problem; import org.apache.tuscany.sca.monitor.Problem.Severity; -import org.apache.tuscany.sca.node.SCAClient; -import org.apache.tuscany.sca.node.SCAContribution; -import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.Client; +import org.apache.tuscany.sca.node.Node; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentContext; import org.apache.tuscany.sca.work.WorkScheduler; @@ -96,7 +93,7 @@ import org.osoa.sca.ServiceRuntimeException; * * @version $Rev$ $Date$ */ -public class NodeImpl implements SCANode, SCAClient { +public class NodeImpl implements Node, Client { private static final Logger logger = Logger.getLogger(NodeImpl.class.getName()); @@ -120,7 +117,7 @@ public class NodeImpl implements SCANode, SCAClient { private StAXArtifactProcessorExtensionPoint xmlProcessors; private StAXArtifactProcessor<Composite> compositeProcessor; private ProxyFactory proxyFactory; - private List<ModuleActivator> modules; + private List<ModuleActivator> moduleActivators = new ArrayList<ModuleActivator>(); private CompositeActivator compositeActivator; private WorkScheduler workScheduler; @@ -170,7 +167,7 @@ public class NodeImpl implements SCANode, SCAClient { * @param compositeURI * @param contributions */ - NodeImpl(String compositeURI, SCAContribution[] contributions) { + NodeImpl(String compositeURI, org.apache.tuscany.sca.node.Contribution[] contributions) { configurationName = compositeURI; logger.log(Level.INFO, "Creating node: " + configurationName); @@ -190,7 +187,7 @@ public class NodeImpl implements SCANode, SCAClient { } // Create contribution models - for (SCAContribution c : contributions) { + for (org.apache.tuscany.sca.node.Contribution c : contributions) { Contribution contribution = contribution(contributionFactory, c); configuration.getContributions().add(contribution); } @@ -210,7 +207,7 @@ public class NodeImpl implements SCANode, SCAClient { * @param compositeContent * @param contributions */ - NodeImpl(String compositeURI, String compositeContent, SCAContribution[] contributions) { + NodeImpl(String compositeURI, String compositeContent, org.apache.tuscany.sca.node.Contribution[] contributions) { configurationName = compositeURI; logger.log(Level.INFO, "Creating node: " + configurationName); @@ -238,7 +235,7 @@ public class NodeImpl implements SCANode, SCAClient { configuration.setComposite(composite); // Create contribution models - for (SCAContribution c : contributions) { + for (org.apache.tuscany.sca.node.Contribution c : contributions) { Contribution contribution = contribution(contributionFactory, c); configuration.getContributions().add(contribution); } @@ -263,9 +260,10 @@ public class NodeImpl implements SCANode, SCAClient { monitor = monitorFactory.createMonitor(); // Initialize the Tuscany module activators - ModuleActivatorExtensionPoint moduleActivators = extensionPoints.getExtensionPoint(ModuleActivatorExtensionPoint.class); - for (ModuleActivator activator: moduleActivators.getModuleActivators()) { - activator.start(extensionPoints); + ModuleActivatorExtensionPoint activators = extensionPoints.getExtensionPoint(ModuleActivatorExtensionPoint.class); + for (ModuleActivator moduleActivator: activators.getModuleActivators()) { + moduleActivator.start(extensionPoints); + moduleActivators.add(moduleActivator); } // Get XML input/output factories @@ -302,17 +300,6 @@ public class NodeImpl implements SCANode, SCAClient { // Initialize runtime - // Load the runtime modules - try { - modules = loadModules(extensionPoints); - - // Start the runtime modules - startModules(extensionPoints, modules); - - } catch (ActivationException e) { - throw new IllegalStateException(e); - } - // Get proxy factory ProxyFactoryExtensionPoint proxyFactories = extensionPoints.getExtensionPoint(ProxyFactoryExtensionPoint.class); proxyFactory = new ExtensibleProxyFactory(proxyFactories); @@ -458,8 +445,13 @@ public class NodeImpl implements SCANode, SCAClient { throw new IllegalStateException(e); } + } + + public void destroy() { // Stop the runtime modules - stopModules(extensionPoints, modules); + for (ModuleActivator moduleActivator: moduleActivators) { + moduleActivator.stop(extensionPoints); + } // Stop and destroy the work manager workScheduler.destroy(); diff --git a/branches/sca-equinox/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeUtil.java b/branches/sca-equinox/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeUtil.java index 0aaee432a8..2a4d6c7e69 100644 --- a/branches/sca-equinox/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeUtil.java +++ b/branches/sca-equinox/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeUtil.java @@ -33,16 +33,8 @@ import org.apache.tuscany.sca.contribution.ContributionFactory; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.core.ModuleActivator; import org.apache.tuscany.sca.core.assembly.ActivationException; -import org.apache.tuscany.sca.core.scope.CompositeScopeContainerFactory; -import org.apache.tuscany.sca.core.scope.ConversationalScopeContainerFactory; -import org.apache.tuscany.sca.core.scope.RequestScopeContainerFactory; -import org.apache.tuscany.sca.core.scope.ScopeContainerFactory; -import org.apache.tuscany.sca.core.scope.ScopeRegistry; -import org.apache.tuscany.sca.core.scope.ScopeRegistryImpl; -import org.apache.tuscany.sca.core.scope.StatelessScopeContainerFactory; import org.apache.tuscany.sca.extensibility.ServiceDeclaration; import org.apache.tuscany.sca.extensibility.ServiceDiscovery; -import org.apache.tuscany.sca.node.SCAContribution; /** * NodeUtil @@ -52,7 +44,7 @@ import org.apache.tuscany.sca.node.SCAContribution; public class NodeUtil { private static final Logger logger = Logger.getLogger(NodeImpl.class.getName()); - static Contribution contribution(ContributionFactory contributionFactory, SCAContribution c) { + static Contribution contribution(ContributionFactory contributionFactory, org.apache.tuscany.sca.node.Contribution c) { Contribution contribution = contributionFactory.createContribution(); contribution.setURI(c.getURI()); contribution.setLocation(c.getLocation()); @@ -72,76 +64,6 @@ public class NodeUtil { return URI.create(uri); } - static List<ModuleActivator> loadModules(ExtensionPointRegistry registry) throws ActivationException { - - // Load and instantiate the modules found on the classpath (or any registered ClassLoaders) - List<ModuleActivator> modules = new ArrayList<ModuleActivator>(); - try { - Set<ServiceDeclaration> moduleActivators = ServiceDiscovery.getInstance().getServiceDeclarations(ModuleActivator.class.getName()); - Set<String> moduleClasses = new HashSet<String>(); - for (ServiceDeclaration moduleDeclarator : moduleActivators) { - if (moduleClasses.contains(moduleDeclarator.getClassName())) { - continue; - } - moduleClasses.add(moduleDeclarator.getClassName()); - Class<?> moduleClass = moduleDeclarator.loadClass(); - ModuleActivator module = (ModuleActivator)moduleClass.newInstance(); - modules.add(module); - } - } catch (IOException e) { - throw new ActivationException(e); - } catch (ClassNotFoundException e) { - throw new ActivationException(e); - } catch (InstantiationException e) { - throw new ActivationException(e); - } catch (IllegalAccessException e) { - throw new ActivationException(e); - } - - return modules; - } - - static void startModules(ExtensionPointRegistry registry, List<ModuleActivator> modules) throws ActivationException { - boolean debug = logger.isLoggable(Level.FINE); - - // Start all the extension modules - for (ModuleActivator module : modules) { - long start = 0L; - if (debug) { - logger.fine(module.getClass().getName() + " is starting."); - start = System.currentTimeMillis(); - } - try { - module.start(registry); - if (debug) { - long end = System.currentTimeMillis(); - logger.fine(module.getClass().getName() + " is started in " + (end - start) + " ms."); - } - } catch (Throwable e) { - logger.log(Level.WARNING, "Exception starting module " + module.getClass().getName() - + " :" - + e.getMessage()); - logger.log(Level.FINE, "Exception starting module " + module.getClass().getName(), e); - } - } - } - - static void stopModules(final ExtensionPointRegistry registry, List<ModuleActivator> modules) { - boolean debug = logger.isLoggable(Level.FINE); - for (ModuleActivator module : modules) { - long start = 0L; - if (debug) { - logger.fine(module.getClass().getName() + " is stopping."); - start = System.currentTimeMillis(); - } - module.stop(registry); - if (debug) { - long end = System.currentTimeMillis(); - logger.fine(module.getClass().getName() + " is stopped in " + (end - start) + " ms."); - } - } - } - // private void loadSCADefinitions() throws ActivationException { // try { // URLArtifactProcessorExtensionPoint documentProcessors = diff --git a/branches/sca-equinox/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.java b/branches/sca-equinox/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.java index e91f399a57..bd760d613d 100644 --- a/branches/sca-equinox/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.java +++ b/branches/sca-equinox/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.java @@ -25,10 +25,10 @@ import java.io.File; import junit.framework.Assert; -import org.apache.tuscany.sca.node.SCAClient; -import org.apache.tuscany.sca.node.SCAContribution; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Client; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.junit.Test; /** @@ -47,25 +47,25 @@ public class NodeImplTestCase { @Test public void testNodeWithCompositeContent() { - SCANodeFactory factory = new NodeFactoryImpl(); - SCAContribution contribution = new SCAContribution("c1", new File("target/test-classes").toURI().toString()); + NodeFactory factory = new NodeFactoryImpl(); + Contribution contribution = new Contribution("c1", new File("target/test-classes").toURI().toString()); String compositeURI = "HelloWorld.composite"; - SCANode node = factory.createSCANode(compositeURI, composite, contribution); + Node node = factory.createNode(compositeURI, composite, contribution); testNode(node); } @Test public void testNodeWithRelativeCompositeURI() { - SCANodeFactory factory = new NodeFactoryImpl(); - SCAContribution contribution = new SCAContribution("c1", new File("target/test-classes").toURI().toString()); + NodeFactory factory = new NodeFactoryImpl(); + Contribution contribution = new Contribution("c1", new File("target/test-classes").toURI().toString()); String compositeURI = "HelloWorld.composite"; - SCANode node = factory.createSCANode(compositeURI, contribution); + Node node = factory.createNode(compositeURI, contribution); testNode(node); } - private void testNode(SCANode node) { + private void testNode(Node node) { node.start(); - HelloWorld hw = ((SCAClient)node).getService(HelloWorld.class, "HelloWorld"); + HelloWorld hw = node.getService(HelloWorld.class, "HelloWorld"); Assert.assertEquals("Hello, Node", hw.hello("Node")); node.stop(); } diff --git a/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.java b/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.java index 614c34b01e..68d1fa05e7 100644 --- a/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.java +++ b/branches/sca-equinox/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.java @@ -64,7 +64,7 @@ public class NodeLauncher { * @return a new SCA node. * @throws LauncherException */ - public <T> T createNodeFromURL(String configurationURL) throws LauncherException { + public <T> T createNode(String configurationURL) throws LauncherException { return (T)node(configurationURL, null, null, null, bundleContext); } @@ -113,7 +113,7 @@ public class NodeLauncher { // Create a node from a configuration URI String configurationURI = args[0]; logger.info("SCA Node configuration: " + configurationURI); - node = launcher.createNodeFromURL(configurationURI); + node = launcher.createNode(configurationURI); } else { // Create a node from a composite URI and a contribution location @@ -157,7 +157,7 @@ public class NodeLauncher { // Stop the node if (node != null) { - stopNode(node); + destroyNode(node); } if (equinox != null) { equinox.stop(); @@ -178,9 +178,10 @@ public class NodeLauncher { * @param node * @throws Exception */ - private static void stopNode(Object node) throws Exception { + private static void destroyNode(Object node) throws Exception { try { node.getClass().getMethod("stop").invoke(node); + node.getClass().getMethod("destroy").invoke(node); logger.info("SCA Node is now stopped."); } catch (Exception e) { logger.log(Level.SEVERE, "SCA Node could not be stopped", e); @@ -200,7 +201,7 @@ public class NodeLauncher { public void run() { try { - stopNode(node); + destroyNode(node); } catch (Exception e) { // Ignore } diff --git a/branches/sca-equinox/modules/node-launcher-equinox/src/test/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherTestCase.java b/branches/sca-equinox/modules/node-launcher-equinox/src/test/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherTestCase.java index b109b690c5..6186b1799a 100644 --- a/branches/sca-equinox/modules/node-launcher-equinox/src/test/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherTestCase.java +++ b/branches/sca-equinox/modules/node-launcher-equinox/src/test/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherTestCase.java @@ -19,7 +19,7 @@ package org.apache.tuscany.sca.node.equinox.launcher; -import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.Node; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Ignore; @@ -51,7 +51,7 @@ public class NodeLauncherTestCase { @Test public void testLaunch() throws Exception { String location = ContributionLocationHelper.getContributionLocation(getClass()); - SCANode node = launcher.createNode("HelloWorld.composite", new Contribution("test", location)); + Node node = launcher.createNode("HelloWorld.composite", new Contribution("test", location)); node.start(); node.stop(); } diff --git a/branches/sca-equinox/modules/node-manager/pom.xml b/branches/sca-equinox/modules/node-manager/pom.xml index b5c1e085f4..dc84c6fe2e 100644 --- a/branches/sca-equinox/modules/node-manager/pom.xml +++ b/branches/sca-equinox/modules/node-manager/pom.xml @@ -56,12 +56,6 @@ <dependency> <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-host-embedded</artifactId> - <version>1.4-SNAPSHOT</version> - </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> <artifactId>tuscany-data-api</artifactId> <version>1.4-SNAPSHOT</version> </dependency> diff --git a/branches/sca-equinox/modules/pom.xml b/branches/sca-equinox/modules/pom.xml index 57f379ef45..bcf0682459 100644 --- a/branches/sca-equinox/modules/pom.xml +++ b/branches/sca-equinox/modules/pom.xml @@ -105,7 +105,6 @@ <!-- <module>host-ejb</module> --> - <module>host-embedded</module> <module>host-http</module> <module>host-jetty</module> <!-- @@ -125,7 +124,6 @@ <module>interface-wsdl-xml</module> <module>implementation-bpel</module> <module>implementation-bpel-ode</module> - <module>implementation-bpel-jbpm</module> <module>implementation-ejb</module> <module>implementation-java</module> <module>implementation-java-xml</module> diff --git a/branches/sca-equinox/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeA.java b/branches/sca-equinox/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeA.java index 3ff6c8969a..306ce68327 100644 --- a/branches/sca-equinox/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeA.java +++ b/branches/sca-equinox/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeA.java @@ -19,8 +19,8 @@ package node; -import org.apache.tuscany.sca.node.SCAClient; -import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.Client; +import org.apache.tuscany.sca.node.Node; import org.apache.tuscany.sca.node.launcher.NodeLauncher; import org.osoa.sca.ServiceRuntimeException; @@ -29,7 +29,7 @@ import calculator.CalculatorService; public class LaunchCalculatorNodeA { public static void main(String[] args) throws Exception { - SCANode node = null; + Node node = null; try { NodeLauncher nodeLauncher = NodeLauncher.newInstance(); @@ -38,7 +38,7 @@ public class LaunchCalculatorNodeA { node.start(); // get a reference to the calculator component - SCAClient client = (SCAClient)node; + Client client = (Client)node; CalculatorService calculatorService = client.getService(CalculatorService.class, "CalculatorServiceComponentA"); diff --git a/branches/sca-equinox/samples/calculator-distributed/src/test/java/calculator/CalculatorDistributedTestCase.java b/branches/sca-equinox/samples/calculator-distributed/src/test/java/calculator/CalculatorDistributedTestCase.java index 2a6f3af002..cd6e934854 100644 --- a/branches/sca-equinox/samples/calculator-distributed/src/test/java/calculator/CalculatorDistributedTestCase.java +++ b/branches/sca-equinox/samples/calculator-distributed/src/test/java/calculator/CalculatorDistributedTestCase.java @@ -21,9 +21,9 @@ package calculator; import junit.framework.Assert;
-import org.apache.tuscany.sca.node.SCAClient;
-import org.apache.tuscany.sca.node.SCANode;
-import org.apache.tuscany.sca.node.SCANodeFactory;
+import org.apache.tuscany.sca.node.Client;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
import org.apache.tuscany.sca.node.launcher.DomainManagerLauncher;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -35,10 +35,10 @@ import org.junit.Test; */
public class CalculatorDistributedTestCase {
- private static SCANode manager;
- private static SCANode nodeA;
- private static SCANode nodeB;
- private static SCANode nodeC;
+ private static Node manager;
+ private static Node nodeA;
+ private static Node nodeB;
+ private static Node nodeC;
private static CalculatorService calculatorService;
@@ -53,16 +53,16 @@ public class CalculatorDistributedTestCase { manager = managerLauncher.createDomainManager();
manager.start();
- SCANodeFactory nodeFactory = SCANodeFactory.newInstance();
- nodeC = nodeFactory.createSCANodeFromURL("http://localhost:9990/node-config/NodeC");
- nodeB = nodeFactory.createSCANodeFromURL("http://localhost:9990/node-config/NodeB");
- nodeA = nodeFactory.createSCANodeFromURL("http://localhost:9990/node-config/NodeA");
+ NodeFactory nodeFactory = NodeFactory.newInstance();
+ nodeC = nodeFactory.createNode("http://localhost:9990/node-config/NodeC");
+ nodeB = nodeFactory.createNode("http://localhost:9990/node-config/NodeB");
+ nodeA = nodeFactory.createNode("http://localhost:9990/node-config/NodeA");
nodeC.start();
nodeB.start();
nodeA.start();
- SCAClient client = (SCAClient)nodeA;
+ Client client = (Client)nodeA;
calculatorService =
client.getService(CalculatorService.class, "CalculatorServiceComponentA");
diff --git a/branches/sca-equinox/samples/calculator-equinox/src/test/java/calculator/CalculatorTestCase.java b/branches/sca-equinox/samples/calculator-equinox/src/test/java/calculator/CalculatorTestCase.java index 83c0e7c9ff..28d83fac4a 100644 --- a/branches/sca-equinox/samples/calculator-equinox/src/test/java/calculator/CalculatorTestCase.java +++ b/branches/sca-equinox/samples/calculator-equinox/src/test/java/calculator/CalculatorTestCase.java @@ -20,7 +20,7 @@ package calculator; import junit.framework.TestCase; -import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.Node; import org.apache.tuscany.sca.node.equinox.launcher.Contribution; import org.apache.tuscany.sca.node.equinox.launcher.ContributionLocationHelper; import org.apache.tuscany.sca.node.equinox.launcher.NodeLauncher; @@ -35,7 +35,7 @@ import org.osoa.sca.annotations.Scope; public class CalculatorTestCase extends TestCase { private NodeLauncher launcher; - private SCANode node; + private Node node; @Override protected void setUp() throws Exception { @@ -48,8 +48,11 @@ public class CalculatorTestCase extends TestCase { @Override protected void tearDown() throws Exception { - if (launcher != null) { + if (node != null) { node.stop(); + node.destroy(); + } + if (launcher != null) { launcher.destroy(); } } diff --git a/branches/sca-equinox/samples/calculator-lean/src/test/java/calculator/CalculatorTestCase.java b/branches/sca-equinox/samples/calculator-lean/src/test/java/calculator/CalculatorTestCase.java index a007a28f21..f965e710d5 100644 --- a/branches/sca-equinox/samples/calculator-lean/src/test/java/calculator/CalculatorTestCase.java +++ b/branches/sca-equinox/samples/calculator-lean/src/test/java/calculator/CalculatorTestCase.java @@ -20,8 +20,10 @@ package calculator; import junit.framework.TestCase; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.osoa.sca.annotations.EagerInit; import org.osoa.sca.annotations.Reference; import org.osoa.sca.annotations.Scope; @@ -33,7 +35,7 @@ import org.osoa.sca.annotations.Scope; public class CalculatorTestCase extends TestCase { private static CalculatorService calculatorService; - private SCANode node; + private Node node; @Reference public void setCalculatorService(CalculatorService calculatorService) { @@ -42,14 +44,16 @@ public class CalculatorTestCase extends TestCase { @Override protected void setUp() throws Exception { - SCANodeFactory factory = SCANodeFactory.newInstance(); - node = factory.createSCANodeFromClassLoader("CalculatorTest.composite", getClass().getClassLoader()); + NodeFactory factory = NodeFactory.newInstance(); + String contribution = ContributionLocationHelper.getContributionLocation(CalculatorClient.class); + node = factory.createNode("CalculatorTest.composite", new Contribution("calculator", contribution)); node.start(); } @Override protected void tearDown() throws Exception { node.stop(); + node.destroy(); } public void testCalculator() throws Exception { diff --git a/branches/sca-equinox/samples/calculator-rcp/src/main/java/calculator/rcp/Activator.java b/branches/sca-equinox/samples/calculator-rcp/src/main/java/calculator/rcp/Activator.java index c3122cca7c..4fd7b8520d 100644 --- a/branches/sca-equinox/samples/calculator-rcp/src/main/java/calculator/rcp/Activator.java +++ b/branches/sca-equinox/samples/calculator-rcp/src/main/java/calculator/rcp/Activator.java @@ -18,7 +18,7 @@ */ package calculator.rcp; -import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.Node; import org.apache.tuscany.sca.node.equinox.launcher.Contribution; import org.apache.tuscany.sca.node.equinox.launcher.ContributionLocationHelper; import org.apache.tuscany.sca.node.equinox.launcher.NodeLauncher; @@ -38,7 +38,7 @@ public class Activator extends AbstractUIPlugin { private static Activator plugin; private NodeLauncher launcher; - private SCANode node; + private Node node; public Activator() { } @@ -58,6 +58,7 @@ public class Activator extends AbstractUIPlugin { super.stop(context); if (node != null) { node.stop(); + node.destroy(); } if (launcher != null) { launcher.destroy(); diff --git a/branches/sca-equinox/samples/calculator/src/main/java/calculator/CalculatorClient.java b/branches/sca-equinox/samples/calculator/src/main/java/calculator/CalculatorClient.java index 3b2966e96d..3f0bcd15c9 100644 --- a/branches/sca-equinox/samples/calculator/src/main/java/calculator/CalculatorClient.java +++ b/branches/sca-equinox/samples/calculator/src/main/java/calculator/CalculatorClient.java @@ -19,9 +19,11 @@ package calculator; -import org.apache.tuscany.sca.node.SCAClient; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Client; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; /** * This client program shows how to create an SCA runtime, start it, @@ -30,11 +32,12 @@ import org.apache.tuscany.sca.node.SCANodeFactory; public class CalculatorClient { public static void main(String[] args) throws Exception { - SCANodeFactory factory = SCANodeFactory.newInstance(); - SCANode node = factory.createSCANodeFromClassLoader("Calculator.composite", CalculatorClient.class.getClassLoader()); + NodeFactory factory = NodeFactory.newInstance(); + String contribution = ContributionLocationHelper.getContributionLocation(CalculatorClient.class); + Node node = factory.createNode("Calculator.composite", new Contribution("calculator", contribution)); node.start(); - CalculatorService calculatorService = ((SCAClient)node).getService(CalculatorService.class, "CalculatorServiceComponent"); + CalculatorService calculatorService = ((Client)node).getService(CalculatorService.class, "CalculatorServiceComponent"); // Calculate System.out.println("3 + 2=" + calculatorService.add(3, 2)); @@ -43,6 +46,7 @@ public class CalculatorClient { System.out.println("3 / 2=" + calculatorService.divide(3, 2)); node.stop(); + node.destroy(); } } diff --git a/branches/sca-equinox/samples/calculator/src/test/java/calculator/CalculatorTestCase.java b/branches/sca-equinox/samples/calculator/src/test/java/calculator/CalculatorTestCase.java index 1b7476534a..1a880d2656 100644 --- a/branches/sca-equinox/samples/calculator/src/test/java/calculator/CalculatorTestCase.java +++ b/branches/sca-equinox/samples/calculator/src/test/java/calculator/CalculatorTestCase.java @@ -20,9 +20,11 @@ package calculator; import junit.framework.TestCase; -import org.apache.tuscany.sca.node.SCAClient; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Client; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; /** * This shows how to test the Calculator service component. @@ -30,20 +32,22 @@ import org.apache.tuscany.sca.node.SCANodeFactory; public class CalculatorTestCase extends TestCase { private CalculatorService calculatorService; - private SCANode node; + private Node node; @Override protected void setUp() throws Exception { - SCANodeFactory factory = SCANodeFactory.newInstance(); - node = factory.createSCANodeFromClassLoader("Calculator.composite", getClass().getClassLoader()); + NodeFactory factory = NodeFactory.newInstance(); + String contribution = ContributionLocationHelper.getContributionLocation(CalculatorClient.class); + node = factory.createNode("Calculator.composite", new Contribution("calculator", contribution)); node.start(); - calculatorService = ((SCAClient)node).getService(CalculatorService.class, "CalculatorServiceComponent"); + calculatorService = ((Client)node).getService(CalculatorService.class, "CalculatorServiceComponent"); } @Override protected void tearDown() throws Exception { node.stop(); + node.destroy(); } public void testCalculator() throws Exception { diff --git a/branches/sca-equinox/samples/callback-ws-client/src/main/java/myapp/MyClientImpl.java b/branches/sca-equinox/samples/callback-ws-client/src/main/java/myapp/MyClientImpl.java index ece769236c..1ac33872b7 100644 --- a/branches/sca-equinox/samples/callback-ws-client/src/main/java/myapp/MyClientImpl.java +++ b/branches/sca-equinox/samples/callback-ws-client/src/main/java/myapp/MyClientImpl.java @@ -21,9 +21,9 @@ package myapp; import myserver.MyService;
import myserver.MyServiceCallback;
-import org.apache.tuscany.sca.node.SCAClient;
-import org.apache.tuscany.sca.node.SCANode;
-import org.apache.tuscany.sca.node.SCANodeFactory;
+import org.apache.tuscany.sca.node.Client;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
import org.osoa.sca.annotations.Reference;
import org.osoa.sca.annotations.Scope;
import org.osoa.sca.annotations.Service;
@@ -49,15 +49,15 @@ public class MyClientImpl implements MyClient, MyServiceCallback { }
public static void main(String[] args) throws Exception {
- SCANode node = SCANodeFactory.newInstance().createSCANodeFromClassLoader("myapp.composite", MyClientImpl.class.getClassLoader());
+ Node node = NodeFactory.newInstance().createSCANodeFromClassLoader("myapp.composite", MyClientImpl.class.getClassLoader());
node.start();
run(node);
System.out.println("Closing the domain");
node.stop();
}
- public static void run(SCANode node) throws InterruptedException {
- MyClient myClient = ((SCAClient)node).getService(MyClient.class, "MyClientComponent");
+ public static void run(Node node) throws InterruptedException {
+ MyClient myClient = ((Client)node).getService(MyClient.class, "MyClientComponent");
myClient.aClientMethod();
Thread.sleep(5000); // don't exit before callback arrives
}
diff --git a/branches/sca-equinox/samples/callback-ws-client/src/test/java/myapp/CallbackClientTestCase.java b/branches/sca-equinox/samples/callback-ws-client/src/test/java/myapp/CallbackClientTestCase.java index fb2f6952c4..af343c637c 100644 --- a/branches/sca-equinox/samples/callback-ws-client/src/test/java/myapp/CallbackClientTestCase.java +++ b/branches/sca-equinox/samples/callback-ws-client/src/test/java/myapp/CallbackClientTestCase.java @@ -18,8 +18,8 @@ */
package myapp;
-import org.apache.tuscany.sca.node.SCANode;
-import org.apache.tuscany.sca.node.SCANodeFactory;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -29,12 +29,12 @@ import org.junit.Test; */
public class CallbackClientTestCase {
- private SCANode node;
+ private Node node;
@Before
public void startServer() throws Exception {
try {
- node = SCANodeFactory.newInstance().createSCANodeFromClassLoader(null, getClass().getClassLoader());
+ node = NodeFactory.newInstance().createSCANodeFromClassLoader(null, getClass().getClassLoader());
node.start();
} catch (Exception ex) {
System.out.println(ex.toString());
diff --git a/branches/sca-equinox/samples/callback-ws-service/src/main/java/myserver/CallbackServer.java b/branches/sca-equinox/samples/callback-ws-service/src/main/java/myserver/CallbackServer.java index 75ef05bc48..da3844dbf3 100644 --- a/branches/sca-equinox/samples/callback-ws-service/src/main/java/myserver/CallbackServer.java +++ b/branches/sca-equinox/samples/callback-ws-service/src/main/java/myserver/CallbackServer.java @@ -20,8 +20,8 @@ package myserver; import java.io.IOException;
-import org.apache.tuscany.sca.node.SCANode;
-import org.apache.tuscany.sca.node.SCANodeFactory;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
/**
* This server program shows how to create and start an SCA runtime that
@@ -31,7 +31,7 @@ public class CallbackServer { public static void main(String[] args) throws Exception {
- SCANode node = SCANodeFactory.newInstance().createSCANodeFromClassLoader("callbackws.composite", null);
+ Node node = NodeFactory.newInstance().createSCANodeFromClassLoader("callbackws.composite", null);
node.start();
try {
diff --git a/branches/sca-equinox/samples/callback-ws-service/src/test/java/myserver/CallbackServerTestCase.java b/branches/sca-equinox/samples/callback-ws-service/src/test/java/myserver/CallbackServerTestCase.java index e87667cc3e..1b17e10556 100644 --- a/branches/sca-equinox/samples/callback-ws-service/src/test/java/myserver/CallbackServerTestCase.java +++ b/branches/sca-equinox/samples/callback-ws-service/src/test/java/myserver/CallbackServerTestCase.java @@ -21,8 +21,8 @@ package myserver; import java.io.IOException;
import java.net.Socket;
-import org.apache.tuscany.sca.node.SCANode;
-import org.apache.tuscany.sca.node.SCANodeFactory;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -32,11 +32,11 @@ import org.junit.Test; */
public class CallbackServerTestCase {
- private SCANode node;
+ private Node node;
@Before
public void startServer() throws Exception {
- node = SCANodeFactory.newInstance().createSCANodeFromClassLoader("callbackws.composite", null);
+ node = NodeFactory.newInstance().createSCANodeFromClassLoader("callbackws.composite", null);
node.start();
}
diff --git a/branches/sca-equinox/samples/domain-management/src/main/java/manager/DistributeAndRunComponents.java b/branches/sca-equinox/samples/domain-management/src/main/java/manager/DistributeAndRunComponents.java index 8d33f55228..9446d38bb7 100644 --- a/branches/sca-equinox/samples/domain-management/src/main/java/manager/DistributeAndRunComponents.java +++ b/branches/sca-equinox/samples/domain-management/src/main/java/manager/DistributeAndRunComponents.java @@ -68,7 +68,7 @@ import org.apache.tuscany.sca.implementation.node.NodeImplementation; import org.apache.tuscany.sca.implementation.node.NodeImplementationFactory; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.MonitorFactory; -import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.Node; import org.apache.tuscany.sca.node.launcher.NodeLauncher; import org.apache.tuscany.sca.workspace.Workspace; import org.apache.tuscany.sca.workspace.WorkspaceFactory; @@ -251,7 +251,7 @@ public class DistributeAndRunComponents { System.out.println(print(domainComposite)); // Now start our SCA nodes - List<SCANode> runtimeNodes = new ArrayList<SCANode>(); + List<Node> runtimeNodes = new ArrayList<Node>(); NodeLauncher launcher = NodeLauncher.newInstance(); for (Component node: cloudComposite.getComponents()) { @@ -277,7 +277,7 @@ public class DistributeAndRunComponents { Contribution dependency = dependencies.get(c); contributions[c] = new org.apache.tuscany.sca.node.launcher.Contribution(dependency.getURI(), dependency.getLocation()); } - SCANode runtimeNode = launcher.createNode("http://sample/" + node.getName(), print(runnable), contributions); + Node runtimeNode = launcher.createNode("http://sample/" + node.getName(), print(runnable), contributions); // Start the node runtimeNode.start(); @@ -287,7 +287,7 @@ public class DistributeAndRunComponents { System.out.println("Nodes are running, press enter to stop..."); System.in.read(); - for (SCANode runtimeNode: runtimeNodes) { + for (Node runtimeNode: runtimeNodes) { runtimeNode.stop(); } } diff --git a/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/client/BigBankClient.java b/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/client/BigBankClient.java index f7b940f873..fe3b198a7b 100644 --- a/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/client/BigBankClient.java +++ b/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/client/BigBankClient.java @@ -19,9 +19,9 @@ package bigbank.client; -import org.apache.tuscany.sca.node.SCAClient; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Client; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import bigbank.account.AccountService; @@ -32,11 +32,11 @@ import bigbank.account.AccountService; public class BigBankClient { public static void main(String[] args) throws Exception { - SCANodeFactory factory = SCANodeFactory.newInstance(); - SCANode node = factory.createSCANodeFromClassLoader("BigBank.composite", BigBankClient.class.getClassLoader()); + NodeFactory factory = NodeFactory.newInstance(); + Node node = factory.createSCANodeFromClassLoader("BigBank.composite", BigBankClient.class.getClassLoader()); node.start(); - AccountService accountService = ((SCAClient)node).getService(AccountService.class, "AccountServiceComponent"); + AccountService accountService = ((Client)node).getService(AccountService.class, "AccountServiceComponent"); System.out.println("Account summary: " + accountService.getAccountReport("Customer_01") ); diff --git a/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/server/BigBankServer.java b/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/server/BigBankServer.java index 241347e417..82103612f7 100644 --- a/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/server/BigBankServer.java +++ b/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/server/BigBankServer.java @@ -19,8 +19,8 @@ package bigbank.server; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; /** * This client program shows how to create an SCA runtime, start it, @@ -36,8 +36,8 @@ public class BigBankServer { System.out.println("Starting the Sample SCA Spring BigBank server..."); - SCANodeFactory factory = SCANodeFactory.newInstance(); - SCANode node = factory.createSCANodeFromClassLoader("BigBank.composite", BigBankServer.class.getClassLoader()); + NodeFactory factory = NodeFactory.newInstance(); + Node node = factory.createSCANodeFromClassLoader("BigBank.composite", BigBankServer.class.getClassLoader()); node.start(); if (timeout < 0) { diff --git a/branches/sca-equinox/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/server/CalculatorServer.java b/branches/sca-equinox/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/server/CalculatorServer.java index b0737899dc..7167edc672 100644 --- a/branches/sca-equinox/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/server/CalculatorServer.java +++ b/branches/sca-equinox/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/server/CalculatorServer.java @@ -19,8 +19,8 @@ package bigbank.calculator.server; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; public class CalculatorServer { @@ -28,8 +28,8 @@ public class CalculatorServer { System.out.println("Starting the Sample SCA Calculator..."); - SCANodeFactory factory = SCANodeFactory.newInstance(); - SCANode node = factory.createSCANodeFromClassLoader("Calculator.composite", CalculatorServer.class.getClassLoader()); + NodeFactory factory = NodeFactory.newInstance(); + Node node = factory.createSCANodeFromClassLoader("Calculator.composite", CalculatorServer.class.getClassLoader()); node.start(); System.out.println("Press Enter to Exit..."); diff --git a/branches/sca-equinox/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/checking/server/CheckingAccountServer.java b/branches/sca-equinox/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/checking/server/CheckingAccountServer.java index 2e367cf32b..b6c6d3897d 100644 --- a/branches/sca-equinox/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/checking/server/CheckingAccountServer.java +++ b/branches/sca-equinox/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/checking/server/CheckingAccountServer.java @@ -21,8 +21,8 @@ package bigbank.account.checking.server; import java.io.IOException; import org.apache.activemq.broker.BrokerService; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; /** * This server program shows how to create an SCA runtime, and start it which @@ -39,8 +39,8 @@ public class CheckingAccountServer { jmsBroker.addConnector("tcp://localhost:61619"); jmsBroker.start(); - SCANodeFactory factory = SCANodeFactory.newInstance(); - SCANode node = factory.createSCANodeFromClassLoader("CheckingsAccount.composite", CheckingAccountServer.class.getClassLoader()); + NodeFactory factory = NodeFactory.newInstance(); + Node node = factory.createSCANodeFromClassLoader("CheckingsAccount.composite", CheckingAccountServer.class.getClassLoader()); node.start(); System.out.println("CheckingsAccount server started (press enter to shutdown)"); diff --git a/branches/sca-equinox/samples/spring-bigbank-stockquote/src/main/java/bigbank/stockquote/server/StockQuoteServer.java b/branches/sca-equinox/samples/spring-bigbank-stockquote/src/main/java/bigbank/stockquote/server/StockQuoteServer.java index b9abb53eb4..1fe6b2d516 100644 --- a/branches/sca-equinox/samples/spring-bigbank-stockquote/src/main/java/bigbank/stockquote/server/StockQuoteServer.java +++ b/branches/sca-equinox/samples/spring-bigbank-stockquote/src/main/java/bigbank/stockquote/server/StockQuoteServer.java @@ -18,8 +18,8 @@ */ package bigbank.stockquote.server; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.springframework.context.ApplicationContext; /** @@ -32,8 +32,8 @@ public class StockQuoteServer { System.out.println("Starting the Sample SCA StockQuote Service..."); - SCANodeFactory factory = SCANodeFactory.newInstance(); - SCANode node = factory.createSCANodeFromClassLoader("StockQuote.composite", StockQuoteServer.class.getClassLoader()); + NodeFactory factory = NodeFactory.newInstance(); + Node node = factory.createSCANodeFromClassLoader("StockQuote.composite", StockQuoteServer.class.getClassLoader()); node.start(); // Method 1: To access the Spring Application Context instance diff --git a/branches/sca-equinox/tutorials/store/store-client/launch/LaunchStoreClientNode.java b/branches/sca-equinox/tutorials/store/store-client/launch/LaunchStoreClientNode.java index d1a9dfb36c..5cb8ae90f9 100644 --- a/branches/sca-equinox/tutorials/store/store-client/launch/LaunchStoreClientNode.java +++ b/branches/sca-equinox/tutorials/store/store-client/launch/LaunchStoreClientNode.java @@ -19,8 +19,8 @@ package launch; -import org.apache.tuscany.sca.node.SCAClient; -import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.Client; +import org.apache.tuscany.sca.node.Node; import org.apache.tuscany.sca.node.launcher.NodeLauncher; import client.Shopper; @@ -29,9 +29,9 @@ public class LaunchStoreClientNode { public static void main(String[] args) throws Exception { NodeLauncher nodeLauncher = NodeLauncher.newInstance(); - SCANode storeClientNode = nodeLauncher.createNodeFromURL("http://localhost:9990/node-config/StoreClientNode"); + Node storeClientNode = nodeLauncher.createNodeFromURL("http://localhost:9990/node-config/StoreClientNode"); storeClientNode.start(); - SCAClient client = (SCAClient)storeClientNode; + Client client = (Client)storeClientNode; Shopper shopper = client.getService(Shopper.class, "StoreClient"); diff --git a/branches/sca-equinox/vtest/java-api/annotations/destroy/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/destroy/DestroyAnnotationTestCase.java b/branches/sca-equinox/vtest/java-api/annotations/destroy/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/destroy/DestroyAnnotationTestCase.java index f3b2f28200..dba8072271 100644 --- a/branches/sca-equinox/vtest/java-api/annotations/destroy/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/destroy/DestroyAnnotationTestCase.java +++ b/branches/sca-equinox/vtest/java-api/annotations/destroy/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/destroy/DestroyAnnotationTestCase.java @@ -23,10 +23,10 @@ import java.io.File; import junit.framework.Assert; -import org.apache.tuscany.sca.node.SCAClient; -import org.apache.tuscany.sca.node.SCAContribution; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Client; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.junit.Test; import org.osoa.sca.ServiceRuntimeException; @@ -47,12 +47,12 @@ public class DestroyAnnotationTestCase { */ @Test public void atDestroyProper() throws Exception { - SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); - SCANode node = nodeFactory.createSCANode(new File("src/main/resources/proper/AService.composite").toURL().toString(), - new SCAContribution("TestContribution", + NodeFactory nodeFactory = NodeFactory.newInstance(); + Node node = nodeFactory.createNode(new File("src/main/resources/proper/AService.composite").toURL().toString(), + new Contribution("TestContribution", new File("src/main/resources/proper").toURL().toString())); node.start(); - AService aService = ((SCAClient)node).getService(AService.class, "AComponent"); + AService aService = ((Client)node).getService(AService.class, "AComponent"); Assert.assertEquals("Hello Pandu", aService.getGreetings("Pandu")); node.stop(); } @@ -69,10 +69,10 @@ public class DestroyAnnotationTestCase { */ @Test public void atDestroyProtectedMethod() throws Exception { - SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); + NodeFactory nodeFactory = NodeFactory.newInstance(); try { - SCANode node = nodeFactory.createSCANode(new File("src/main/resources/err1/AServiceErr1.composite").toURL().toString(), - new SCAContribution("TestContribution", + Node node = nodeFactory.createNode(new File("src/main/resources/err1/AServiceErr1.composite").toURL().toString(), + new Contribution("TestContribution", new File("src/main/resources/err1").toURL().toString())); Assert.fail(); node.stop(); @@ -94,10 +94,10 @@ public class DestroyAnnotationTestCase { */ @Test public void atDestroyPrivateMethod() throws Exception { - SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); + NodeFactory nodeFactory = NodeFactory.newInstance(); try { - SCANode node = nodeFactory.createSCANode(new File("src/main/resources/err2/AServiceErr2.composite").toURL().toString(), - new SCAContribution("TestContribution", + Node node = nodeFactory.createNode(new File("src/main/resources/err2/AServiceErr2.composite").toURL().toString(), + new Contribution("TestContribution", new File("src/main/resources/err2").toURL().toString())); Assert.fail(); node.stop(); @@ -119,10 +119,10 @@ public class DestroyAnnotationTestCase { */ @Test public void atDestroyNonVoidReturnType() throws Exception { - SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); + NodeFactory nodeFactory = NodeFactory.newInstance(); try { - SCANode node = nodeFactory.createSCANode(new File("src/main/resources/err3/AServiceErr3.composite").toURL().toString(), - new SCAContribution("TestContribution", + Node node = nodeFactory.createNode(new File("src/main/resources/err3/AServiceErr3.composite").toURL().toString(), + new Contribution("TestContribution", new File("src/main/resources/err3").toURL().toString())); Assert.fail(); node.stop(); @@ -144,10 +144,10 @@ public class DestroyAnnotationTestCase { */ @Test public void atDestroyMethodWithArgs() throws Exception { - SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); + NodeFactory nodeFactory = NodeFactory.newInstance(); try { - SCANode node = nodeFactory.createSCANode(new File("src/main/resources/err4/AServiceErr4.composite").toURL().toString(), - new SCAContribution("TestContribution", + Node node = nodeFactory.createNode(new File("src/main/resources/err4/AServiceErr4.composite").toURL().toString(), + new Contribution("TestContribution", new File("src/main/resources/err4").toURL().toString())); Assert.fail(); node.stop(); diff --git a/branches/sca-equinox/vtest/java-api/annotations/init/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/init/InitAnnotationTestCase.java b/branches/sca-equinox/vtest/java-api/annotations/init/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/init/InitAnnotationTestCase.java index 0dbccd8611..32af7c2cbd 100644 --- a/branches/sca-equinox/vtest/java-api/annotations/init/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/init/InitAnnotationTestCase.java +++ b/branches/sca-equinox/vtest/java-api/annotations/init/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/init/InitAnnotationTestCase.java @@ -23,10 +23,10 @@ import java.io.File; import junit.framework.Assert; -import org.apache.tuscany.sca.node.SCAClient; -import org.apache.tuscany.sca.node.SCAContribution; -import org.apache.tuscany.sca.node.SCANode; -import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.Client; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; import org.junit.Test; import org.osoa.sca.ServiceRuntimeException; @@ -50,12 +50,12 @@ public class InitAnnotationTestCase { */ @Test public void atInitProper() throws Exception { - SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); - SCANode node = nodeFactory.createSCANode(new File("src/main/resources/proper/AService.composite").toURL().toString(), - new SCAContribution("TestContribution", + NodeFactory nodeFactory = NodeFactory.newInstance(); + Node node = nodeFactory.createNode(new File("src/main/resources/proper/AService.composite").toURL().toString(), + new Contribution("TestContribution", new File("src/main/resources/proper").toURL().toString())); node.start(); - AService aService = ((SCAClient)node).getService(AService.class, "AComponent"); + AService aService = ((Client)node).getService(AService.class, "AComponent"); Assert.assertTrue(aService.isInitProper()); Assert.assertEquals("Hello Pandu", aService.getGreetings("Pandu")); node.stop(); @@ -74,10 +74,10 @@ public class InitAnnotationTestCase { */ @Test public void atInitProtectedMethod() throws Exception { - SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); + NodeFactory nodeFactory = NodeFactory.newInstance(); try { - SCANode node = nodeFactory.createSCANode(new File("src/main/resources/err1/AServiceErr1.composite").toURL().toString(), - new SCAContribution("TestContribution", + Node node = nodeFactory.createNode(new File("src/main/resources/err1/AServiceErr1.composite").toURL().toString(), + new Contribution("TestContribution", new File("src/main/resources/err1").toURL().toString())); Assert.fail(); node.stop(); @@ -100,10 +100,10 @@ public class InitAnnotationTestCase { */ @Test public void atInitPrivateMethod() throws Exception { - SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); + NodeFactory nodeFactory = NodeFactory.newInstance(); try { - SCANode node = nodeFactory.createSCANode(new File("src/main/resources/err2/AServiceErr2.composite").toURL().toString(), - new SCAContribution("TestContribution", + Node node = nodeFactory.createNode(new File("src/main/resources/err2/AServiceErr2.composite").toURL().toString(), + new Contribution("TestContribution", new File("src/main/resources/err2").toURL().toString())); Assert.fail(); node.stop(); @@ -126,10 +126,10 @@ public class InitAnnotationTestCase { */ @Test public void atInitNonVoidReturnType() throws Exception { - SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); + NodeFactory nodeFactory = NodeFactory.newInstance(); try { - SCANode node = nodeFactory.createSCANode(new File("src/main/resources/err3/HelloWorldErr3.composite").toURL().toString(), - new SCAContribution("TestContribution", + Node node = nodeFactory.createNode(new File("src/main/resources/err3/HelloWorldErr3.composite").toURL().toString(), + new Contribution("TestContribution", new File("src/main/resources/err3").toURL().toString())); Assert.fail(); node.stop(); @@ -152,10 +152,10 @@ public class InitAnnotationTestCase { */ @Test public void atInitMethodWithArgs() throws Exception { - SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); + NodeFactory nodeFactory = NodeFactory.newInstance(); try { - SCANode node = nodeFactory.createSCANode(new File("src/main/resources/err4/HelloWorldErr4.composite").toURL().toString(), - new SCAContribution("TestContribution", + Node node = nodeFactory.createNode(new File("src/main/resources/err4/HelloWorldErr4.composite").toURL().toString(), + new Contribution("TestContribution", new File("src/main/resources/err4").toURL().toString())); Assert.fail(); node.stop(); |