diff options
Diffstat (limited to 'java/sca/itest/references/src')
5 files changed, 62 insertions, 43 deletions
diff --git a/java/sca/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/AComponentImpl.java b/java/sca/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/AComponentImpl.java index 647fff0159..ab275ece52 100644 --- a/java/sca/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/AComponentImpl.java +++ b/java/sca/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/AComponentImpl.java @@ -37,11 +37,10 @@ public class AComponentImpl implements AComponent { @Reference(name = "dReferences") public Collection<DComponent> dReferences; - + @Reference(name = "dReferenceArray") public DComponent[] dReferenceArray; - @Reference(name = "dServiceReferences") public List<ServiceReference<DComponent>> dServiceReferences; @@ -93,8 +92,8 @@ public class AComponentImpl implements AComponent { str.deleteCharAt(str.length() - 1); } return str.toString(); - } - + } + public String fooMultipleD() { StringBuffer str = new StringBuffer(); for (DComponent d : dReferences) { @@ -106,7 +105,7 @@ public class AComponentImpl implements AComponent { } return str.toString(); } - + public String fooMultipleDServiceRef() { StringBuffer str = new StringBuffer(); for (ServiceReference<DComponent> d : dServiceReferences) { diff --git a/java/sca/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/DComponent.java b/java/sca/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/DComponent.java index 2618ec7095..80617bdec2 100644 --- a/java/sca/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/DComponent.java +++ b/java/sca/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/DComponent.java @@ -18,10 +18,9 @@ */ package org.apache.tuscany.sca.itest.references; -import org.osoa.sca.annotations.Remotable; - public interface DComponent { String dFoo(); + String getComponentName(); } diff --git a/java/sca/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/AutoWiredReferenceTestCase.java b/java/sca/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/AutoWiredReferenceTestCase.java index bfd542e2f2..1034bda02d 100644 --- a/java/sca/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/AutoWiredReferenceTestCase.java +++ b/java/sca/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/AutoWiredReferenceTestCase.java @@ -18,29 +18,40 @@ */ package org.apache.tuscany.sca.itest.references; -import static junit.framework.Assert.assertEquals; -import junit.framework.Assert; +import static org.junit.Assert.assertEquals; -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.Assert; import org.junit.BeforeClass; import org.junit.Test; public class AutoWiredReferenceTestCase { - private static SCADomain domain; + private static Node node; private static AComponent acomponent; private static AComponent acomponentAutowire; @BeforeClass public static void init() throws Exception { - domain = SCADomain.newInstance("AutoWiredReferencesTest.composite"); - acomponent = domain.getService(AComponent.class, "AComponent"); - acomponentAutowire = domain.getService(AComponent.class, "AComponentAutowire"); + try { + String location = ContributionLocationHelper.getContributionLocation("AutoWiredReferencesTest.composite"); + node = + NodeFactory.newInstance().createNode("AutoWiredReferencesTest.composite", + new Contribution("c1", location)); + node.start(); + acomponent = node.getService(AComponent.class, "AComponent"); + acomponentAutowire = node.getService(AComponent.class, "AComponentAutowire"); + } catch (Throwable e) { + e.printStackTrace(); + } } @AfterClass public static void destroy() throws Exception { - domain.close(); + node.stop(); } @Test @@ -67,19 +78,19 @@ public class AutoWiredReferenceTestCase { public void testD2Reference() { assertEquals("DComponent", acomponent.fooD2()); } - + @Test public void testMultiDReferenceArray() { String components = acomponent.fooMultipleDArray(); Assert.assertTrue(components.contains("DComponent1")); - } - + } + @Test public void testMultiDServiceReference() { String components = acomponent.fooMultipleDServiceRef(); Assert.assertTrue(components.contains("DComponent")); Assert.assertTrue(components.contains("DComponent1")); - } + } @Test public void testRequiredFalseReference() { @@ -89,7 +100,7 @@ public class AutoWiredReferenceTestCase { Assert.assertTrue(true); } } - + @Test public void testTargetPrecendence() { try { diff --git a/java/sca/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/InnerReferenceTestCase.java b/java/sca/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/InnerReferenceTestCase.java index 1d8284f0fd..db2e3f175d 100644 --- a/java/sca/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/InnerReferenceTestCase.java +++ b/java/sca/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/InnerReferenceTestCase.java @@ -18,27 +18,32 @@ */ package org.apache.tuscany.sca.itest.references; -import static junit.framework.Assert.assertEquals; -import junit.framework.Assert; +import static org.junit.Assert.assertEquals; -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.Assert; import org.junit.BeforeClass; import org.junit.Test; public class InnerReferenceTestCase { - private static SCADomain domain; + private static Node node; private static AComponent acomponent; @BeforeClass public static void init() throws Exception { - domain = SCADomain.newInstance("InnerReferencesTest.composite"); - acomponent = domain.getService(AComponent.class, "AComponent"); + String location = ContributionLocationHelper.getContributionLocation("InnerReferencesTest.composite"); + node = NodeFactory.newInstance().createNode("InnerReferencesTest.composite", new Contribution("c1", location)); + node.start(); + acomponent = node.getService(AComponent.class, "AComponent"); } @AfterClass public static void destroy() throws Exception { - domain.close(); + node.stop(); } @Test @@ -65,26 +70,26 @@ public class InnerReferenceTestCase { public void testD2Reference() { assertEquals("DComponent", acomponent.fooD2()); } - + @Test public void testMultiDReference() { String components = acomponent.fooMultipleD(); Assert.assertTrue(components.contains("DComponent")); Assert.assertTrue(components.contains("DComponent1")); } - + @Test public void testMultiDReferenceArray() { String components = acomponent.fooMultipleDArray(); Assert.assertTrue(components.equals("DComponent1")); - } - + } + @Test public void testMultiDServiceReference() { String components = acomponent.fooMultipleDServiceRef(); Assert.assertTrue(components.contains("DComponent")); Assert.assertTrue(components.contains("DComponent1")); - } + } @Test(expected = NullPointerException.class) public void testRequiredFalseReference() { diff --git a/java/sca/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/ManualWiredReferenceTestCase.java b/java/sca/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/ManualWiredReferenceTestCase.java index 4b3a745a19..6349e4f827 100644 --- a/java/sca/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/ManualWiredReferenceTestCase.java +++ b/java/sca/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/ManualWiredReferenceTestCase.java @@ -18,28 +18,33 @@ */ package org.apache.tuscany.sca.itest.references; -import static junit.framework.Assert.assertEquals; -import junit.framework.Assert; +import static org.junit.Assert.assertEquals; -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.Assert; import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.Test; public class ManualWiredReferenceTestCase { - private static SCADomain domain; + private static Node node; private static AComponent acomponent; @BeforeClass public static void init() throws Exception { - domain = SCADomain.newInstance("ManualWiredReferencesTest.composite"); - acomponent = domain.getService(AComponent.class, "AComponent"); + String location = ContributionLocationHelper.getContributionLocation("ManualWiredReferencesTest.composite"); + node = NodeFactory.newInstance().createNode("ManualWiredReferencesTest.composite", new Contribution("c1", location)); + node.start(); + acomponent = node.getService(AComponent.class, "AComponent"); } @AfterClass public static void destroy() throws Exception { - domain.close(); + node.stop(); } @Test @@ -67,19 +72,19 @@ public class ManualWiredReferenceTestCase { public void testD2Reference() { assertEquals("DComponent", acomponent.fooD2()); } - + @Test public void testMultiDReferenceArray() { String components = acomponent.fooMultipleDArray(); Assert.assertTrue(components.contains("DComponent1")); - } - + } + @Test public void testMultiDServiceReference() { String components = acomponent.fooMultipleDServiceRef(); Assert.assertTrue(components.contains("DComponent")); Assert.assertTrue(components.contains("DComponent1")); - } + } @Test public void testRequiredFalseReference() { |