From 3a569a2f00bf172cddfd567149774ee808a2a242 Mon Sep 17 00:00:00 2001 From: nash Date: Wed, 30 Mar 2011 19:50:51 +0000 Subject: Create branch for 1.6.2 git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1087059 13f79535-47bb-0310-9956-ffa450edef68 --- .../CallableReferenceConversationalTestCase.java | 109 ++++++++++++++++ .../CallableReferenceRemoteTestCase.java | 145 +++++++++++++++++++++ .../CallableReferenceReturnTestCase.java | 48 +++++++ .../callableref/CallableReferenceTestCase.java | 83 ++++++++++++ 4 files changed, 385 insertions(+) create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceConversationalTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceRemoteTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceReturnTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceTestCase.java (limited to 'sca-java-1.x/branches/sca-java-1.6.2/itest/callablereferences/src/test/java/org') diff --git a/sca-java-1.x/branches/sca-java-1.6.2/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceConversationalTestCase.java b/sca-java-1.x/branches/sca-java-1.6.2/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceConversationalTestCase.java new file mode 100644 index 0000000000..a9cbb5d0a1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceConversationalTestCase.java @@ -0,0 +1,109 @@ +/* + * 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.itest.callableref; + +import junit.framework.Assert; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.itest.callablerefconversational.ConversationalService; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.osoa.sca.ServiceReference; + +/** + * Simple test case that creates a ServiceReference to a Conversational Component + * using ComponentContext.createSelfReference() + *

+ * This test case is for TUSCANY-2208 + * + * @version $Date$ $Revision$ + */ +public class CallableReferenceConversationalTestCase { + private static SCADomain domain; + private static ConversationalService acomponent; + + @BeforeClass + public static void init() throws Exception { + domain = SCADomain.newInstance("CallableReferenceConversationalTest.composite"); + Assert.assertNotNull(domain); + acomponent = domain.getService(ConversationalService.class, "ConversationalComponent"); + } + + @AfterClass + public static void destroy() throws Exception { + if (domain != null) { + domain.close(); + } + } + + /** + * This is a dummy test so that this Unit Test has a test so it will build. + * Once TUSCANY-2208 is fixed, this dummy test method can be removed + */ + @Test + public void dummyTestRemoveWhenTuscany2208IsFixed() { + } + + /** + * Tests creating Self References and validate them with Conversation IDs + */ + // Disabled until TUSCANY-2208 is fixed + // @Test + public void testCreateSelfRefUsingConvID() { + Assert.assertNotNull(acomponent); + + final Object origConvID = acomponent.getConversationID(); + Assert.assertNotNull(origConvID); + final ServiceReference ref = acomponent.createSelfRef(); + Assert.assertNotNull(ref); + + final ConversationalService resolvedRef = ref.getService(); + Assert.assertNotNull(resolvedRef); + final Object newConvID = resolvedRef.getConversationID(); + Assert.assertNotNull(newConvID); + + Assert.assertEquals(origConvID, newConvID); + } + + /** + * Tests creating Self References and validate them with user specified data + */ + // Disabled until TUSCANY-2208 is fixed + // @Test + public void testCreateSelfRefUsingUserData() { + Assert.assertNotNull(acomponent); + + final String origUserData = acomponent.getUserData(); + Assert.assertEquals(ConversationalService.DEFAULT_USER_DATA, origUserData); + + final String userData = "Some new user data set at " + System.currentTimeMillis(); + acomponent.setUserData(userData); + + final ServiceReference ref = acomponent.createSelfRef(); + Assert.assertNotNull(ref); + + final ConversationalService resolvedRef = ref.getService(); + Assert.assertNotNull(resolvedRef); + final String newUserData = resolvedRef.getUserData(); + Assert.assertNotNull(newUserData); + + Assert.assertEquals(userData, newUserData); + } +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceRemoteTestCase.java b/sca-java-1.x/branches/sca-java-1.6.2/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceRemoteTestCase.java new file mode 100644 index 0000000000..ba9020811c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceRemoteTestCase.java @@ -0,0 +1,145 @@ +/* + * 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.itest.callableref; + + +import static junit.framework.Assert.assertEquals; + +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.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + + +/** + * Runs a distributed domain in a single VM by using and in memory + * implementation of the distributed domain + */ +public class CallableReferenceRemoteTestCase { + + private static SCANode nodeA; + private static SCANode nodeB; + + private static AComponent acomponent; + + @BeforeClass + public static void init() throws Exception { + + try { + + 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", + new File("src/main/resources/nodeA").toURL().toString())); + + + nodeB = nodeFactory.createSCANode(new File("src/main/resources/nodeB/CompositeB.composite").toURL().toString(), + new SCAContribution("TestContribution", + new File("src/main/resources/nodeB").toURL().toString())); + + + nodeA.start(); + nodeB.start(); + + acomponent = ((SCAClient)nodeA).getService(AComponent.class, "AComponent/AComponent"); + + } catch (Throwable ex) { + System.out.println(ex.toString()); + // Print detailed cause information. + ex.printStackTrace(); + StringBuffer sb = new StringBuffer(); + Throwable cause = ex.getCause(); + while ( cause != null ) { + sb.append( " " ); + System.out.println( sb.toString() + "Cause: " + cause ); + if (cause instanceof java.lang.reflect.InvocationTargetException) + System.out.println( sb.toString() + "Target Exception: " + ((java.lang.reflect.InvocationTargetException)cause).getTargetException() ); + cause = cause.getCause(); + } + } + } + + @AfterClass + public static void destroy() throws Exception { + // stop the nodes and hence the domains they contain + nodeA.stop(); + nodeB.stop(); + } + + //@Test + public void testKeepServerRunning1() throws Exception { + System.out.println("press enter to continue"); + System.in.read(); + } + + @Test + public void testBReference() { + assertEquals("BComponent", acomponent.fooB()); + } + + @Test + public void testBCast() { + assertEquals("BComponent", acomponent.fooB1()); + } + + @Test + public void testCReference() { + assertEquals("CComponent", acomponent.fooC()); + } + + @Test + public void testCServiceReference() { + assertEquals("CComponent", acomponent.fooC1()); + } + + @Test + public void testDReferenceString() { + assertEquals("DAComponent", acomponent.fooStringD()); + } + + @Test + public void testDReference() { + assertEquals("DAComponent", acomponent.fooD()); + } + + + @Test + public void testBCReference() { + assertEquals("BCComponent", acomponent.fooBC()); + } + + @Test + public void testRequiredFalseReference() { + try { + acomponent.invokeDReference(); + } catch (Exception e) { + Assert.assertTrue(true); + } + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceReturnTestCase.java b/sca-java-1.x/branches/sca-java-1.6.2/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceReturnTestCase.java new file mode 100644 index 0000000000..f2d8fe5d64 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceReturnTestCase.java @@ -0,0 +1,48 @@ +/* + * 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.itest.callableref; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.itest.callablerefreturn.Alpha; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +public class CallableReferenceReturnTestCase { + private static SCADomain domain; + private static Alpha alpha; + + @BeforeClass + public static void init() throws Exception { + domain = SCADomain.newInstance("CallableReferenceReturnTest.composite"); + alpha = domain.getService(Alpha.class, "Alpha"); + } + + @AfterClass + public static void destroy() throws Exception { + domain.close(); + } + + @Test + public void testCallableReferenceReturn() { + Assert.assertTrue(alpha.run()); + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceTestCase.java b/sca-java-1.x/branches/sca-java-1.6.2/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceTestCase.java new file mode 100644 index 0000000000..d785a6a397 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceTestCase.java @@ -0,0 +1,83 @@ +/* + * 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.itest.callableref; + +import static junit.framework.Assert.assertEquals; +import junit.framework.Assert; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +public class CallableReferenceTestCase { + private static SCADomain domain; + private static AComponent acomponent; + + @BeforeClass + public static void init() throws Exception { + domain = SCADomain.newInstance("CallableReferenceTest.composite"); + acomponent = domain.getService(AComponent.class, "AComponent"); + } + + @AfterClass + public static void destroy() throws Exception { + domain.close(); + } + + @Test + public void testBReference() { + assertEquals("BComponent", acomponent.fooB()); + } + + @Test + public void testBCast() { + assertEquals("BComponent", acomponent.fooB1()); + } + + @Test + public void testCReference() { + assertEquals("CComponent", acomponent.fooC()); + } + + @Test + public void testCServiceReference() { + assertEquals("CComponent", acomponent.fooC1()); + } + + @Test + public void testDReference() { + assertEquals("DAComponent", acomponent.fooD()); + } + + @Test + public void testBCReference() { + assertEquals("BCComponent", acomponent.fooBC()); + } + + @Test + public void testRequiredFalseReference() { + try { + acomponent.invokeDReference(); + } catch (Exception e) { + Assert.assertTrue(true); + } + } + +} -- cgit v1.2.3