From f44c07576a61f6f4915ea8fd2aa5af9fee71745f Mon Sep 17 00:00:00 2001 From: rfeng Date: Fri, 5 Dec 2008 00:48:31 +0000 Subject: Convert, clean and bring up a set of itests git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@723537 13f79535-47bb-0310-9956-ffa450edef68 --- .../references/AutoWiredReferenceTestCase.java | 37 ++++++++++++++-------- .../itest/references/InnerReferenceTestCase.java | 29 ++++++++++------- .../references/ManualWiredReferenceTestCase.java | 27 +++++++++------- 3 files changed, 57 insertions(+), 36 deletions(-) (limited to 'java/sca/itest/references/src/test') 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() { -- cgit v1.2.3