diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-13 01:42:27 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-13 01:42:27 +0000 |
commit | 3c7c4a749baafcf375f4785a7668d3a25c9063e3 (patch) | |
tree | a66b8b031c5dc6c7744f44b44b6bcd371bd0b8df /sca-java-1.x/trunk/itest/osgi-implementation/src/test | |
parent | eb03ff672236cddf65533f39b83ddd5e2984a2bb (diff) |
Moving 1.x trunk
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835700 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-1.x/trunk/itest/osgi-implementation/src/test')
29 files changed, 1677 insertions, 0 deletions
diff --git a/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/callback/Callback1TestCase.java b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/callback/Callback1TestCase.java new file mode 100644 index 0000000000..54b9b00bc8 --- /dev/null +++ b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/callback/Callback1TestCase.java @@ -0,0 +1,30 @@ +/* + * 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 callback; + + +public class Callback1TestCase extends CallbackTestCase { + + public Callback1TestCase() { + super("callback-test1.composite"); + } + + +} diff --git a/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/callback/Callback2TestCase.java b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/callback/Callback2TestCase.java new file mode 100644 index 0000000000..b26bfbd98d --- /dev/null +++ b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/callback/Callback2TestCase.java @@ -0,0 +1,29 @@ +/* + * 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 callback; + + +public class Callback2TestCase extends CallbackTestCase { + + public Callback2TestCase() { + super("callback-test2.composite"); + } + +} diff --git a/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/callback/Callback3TestCase.java b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/callback/Callback3TestCase.java new file mode 100644 index 0000000000..667df7aa12 --- /dev/null +++ b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/callback/Callback3TestCase.java @@ -0,0 +1,29 @@ +/* + * 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 callback; + + +public class Callback3TestCase extends CallbackTestCase { + + public Callback3TestCase() { + super("callback-test3.composite"); + } + +} diff --git a/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/callback/CallbackTestCase.java b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/callback/CallbackTestCase.java new file mode 100644 index 0000000000..a95437f8c1 --- /dev/null +++ b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/callback/CallbackTestCase.java @@ -0,0 +1,50 @@ +/* + * 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 callback; + + +import callback.client.CallbackClient; + +import test.OSGiTestCase; + +public abstract class CallbackTestCase extends OSGiTestCase { + + private CallbackClient aCallbackClient; + + protected String compositeName; + + + public CallbackTestCase(String compositeName) { + super(compositeName, "callback"); + } + + + + protected void setUp() throws Exception { + super.setUp(); + aCallbackClient = scaDomain.getService(CallbackClient.class, "CallbackClient"); + } + + + public void test() throws Exception { + aCallbackClient.run(); + } + +} diff --git a/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/conversation/ConversationTestCase.java b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/conversation/ConversationTestCase.java new file mode 100644 index 0000000000..c5d94df93d --- /dev/null +++ b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/conversation/ConversationTestCase.java @@ -0,0 +1,325 @@ +/* + * 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 conversation; + +import junit.framework.Assert; + +import org.junit.Before; +import org.junit.Test; + +import conversation.client.ConversationalClient; + +import test.OSGiTestCase; + +public class ConversationTestCase extends OSGiTestCase { + + private ConversationalClient conversationalStatelessClientStatelessService; + private ConversationalClient conversationalStatelessClientStatefulService; + private ConversationalClient conversationalStatefulClientStatelessService; + private ConversationalClient conversationalStatefulClientStatefulService; + + public ConversationTestCase() { + super("conversation-test.composite", "conversation"); + } + + @Before + public void setUp() throws Exception { + + try { + + super.setUp(); + + conversationalStatelessClientStatelessService = scaDomain.getService(ConversationalClient.class, + "ConversationalStatelessClientStatelessService/ConversationalClient"); + + conversationalStatelessClientStatefulService = scaDomain.getService(ConversationalClient.class, + "ConversationalStatelessClientStatefulService/ConversationalClient"); + + conversationalStatefulClientStatelessService = scaDomain.getService(ConversationalClient.class, + "ConversationalStatefulClientStatelessService/ConversationalClient"); + + conversationalStatefulClientStatefulService = scaDomain.getService(ConversationalClient.class, + "ConversationalStatefulClientStatefulService/ConversationalClient"); + + + + } catch (Exception e) { + e.printStackTrace(); + + throw e; + } + + } + + + // stateless client stateful service tests + // ======================================= + @Test + public void testStatelessStatefulConversationFromInjectedReference() { + int count = conversationalStatelessClientStatefulService.runConversationFromInjectedReference(); + Assert.assertEquals(2, count); + } + + @Test + public void testStatelessStatefulConversationFromServiceReference() { + int count = conversationalStatelessClientStatefulService.runConversationFromServiceReference(); + Assert.assertEquals(2, count); + } + + @Test + public void testStatelessStatefulConversationWithUserDefinedConversationId() { + int count = conversationalStatelessClientStatefulService.runConversationWithUserDefinedConversationId(); + Assert.assertEquals(2, count); + } + + @Test + public void testStatelessStatefulConversationCheckUserDefinedConversationId() { + String conversationId = conversationalStatelessClientStatefulService.runConversationCheckUserDefinedConversationId(); + Assert.assertEquals("MyConversation2", conversationId); + } + + @Test + public void testStatelessStatefulConversationCheckingScope() { + conversationalStatelessClientStatefulService.runConversationCheckingScope(); + + Assert.assertEquals("init,initializeCount,incrementCount,retrieveCount,endConversation,destroy,init,", + conversationalStatelessClientStatefulService.getServiceCalls()); + } + + @Test + public void testStatelessStatefulConversationWithCallback() { + int count = conversationalStatelessClientStatefulService.runConversationWithCallback(); + Assert.assertEquals(0, count); + + Assert.assertEquals("init,runConversationWithCallback,init,initializeCount,destroy,init,incrementCount,destroy,init,retrieveCount,destroy,init,endConversation,destroy,destroy,init,", + conversationalStatelessClientStatefulService.getCalls()); + } + + /////@Test + public void _testStatelessStatefulConversationHavingPassedReference() { + int count = conversationalStatelessClientStatefulService.runConversationHavingPassedReference(); + Assert.assertEquals(3, count); + } + + @Test + public void testStatelessStatefulConversationBusinessException() { + String message = conversationalStatelessClientStatefulService.runConversationBusinessException(); + Assert.assertEquals("Business Exception", message); + } + + @Test + public void testStatelessStatefulConversationBusinessExceptionCallback() { + String message = conversationalStatelessClientStatefulService.runConversationBusinessExceptionCallback(); + Assert.assertEquals("Business Exception", message); + } + + @Test + public void testStatelessStatefulConversationCallingEndedConversation() { + int count = conversationalStatelessClientStatefulService.runConversationCallingEndedConversation(); + Assert.assertEquals(0, count); + } + + @Test + public void testStatelessStatefulConversationCallingEndedConversationCallback() { + int count = conversationalStatelessClientStatefulService.runConversationCallingEndedConversationCallback(); + Assert.assertEquals(0, count); + } + + // stateless client stateless service tests + // ======================================== + @Test + public void testStatelessStatelessConversationFromInjectedReference() { + int count = conversationalStatelessClientStatelessService.runConversationFromInjectedReference(); + Assert.assertEquals(2, count); + } + + @Test + public void testStatelessStatelessConversationFromServiceReference() { + int count = conversationalStatelessClientStatelessService.runConversationFromServiceReference(); + Assert.assertEquals(2, count); + } + + @Test + public void testStatelessStatelessConversationWithUserDefinedConversationId() { + int count = conversationalStatelessClientStatelessService.runConversationWithUserDefinedConversationId(); + Assert.assertEquals(2, count); + } + @Test + public void testStatelessStatelessConversationCheckUserDefinedConversationId() { + String conversationId = conversationalStatelessClientStatelessService.runConversationCheckUserDefinedConversationId(); + Assert.assertEquals("MyConversation2", conversationId); + } + + @Test + public void testStatelessStatelessConversationCheckingScope() { + conversationalStatelessClientStatelessService.runConversationCheckingScope(); + Assert.assertEquals("init,initializeCount,destroy,init,incrementCount,destroy,init,retrieveCount,destroy,init,endConversation,destroy,init,", + conversationalStatelessClientStatelessService.getServiceCalls()); + } + + @Test + public void testStatelessStatelessConversationWithCallback() { + int count = conversationalStatelessClientStatelessService.runConversationWithCallback(); + Assert.assertEquals(0, count); + + Assert.assertEquals("init,runConversationWithCallback,init,initializeCount,destroy,init,incrementCount,destroy,init,retrieveCount,destroy,init,endConversation,destroy,destroy,init,", + conversationalStatelessClientStatelessService.getCalls()); + } + /////@Test + public void _testStatelessStatelessConversationHavingPassedReference() { + int count = conversationalStatelessClientStatelessService.runConversationHavingPassedReference(); + Assert.assertEquals(3, count); + } + + @Test + public void testStatelessStatelessConversationCallingEndedConversation() { + int count = conversationalStatelessClientStatelessService.runConversationCallingEndedConversation(); + Assert.assertEquals(-999, count); + } + + @Test + public void testStatelessStatelessConversationCallingEndedConversationCallback() { + int count = conversationalStatelessClientStatelessService.runConversationCallingEndedConversationCallback(); + Assert.assertEquals(0, count); + } + + // stateful client stateful service tests + // ====================================== + @Test + public void testStatefulStatefulConversationFromInjectedReference() { + int count = conversationalStatefulClientStatefulService.runConversationFromInjectedReference(); + Assert.assertEquals(2, count); + } + + @Test + public void testStatefulStatefulConversationFromServiceReference() { + int count = conversationalStatefulClientStatefulService.runConversationFromServiceReference(); + Assert.assertEquals(2, count); + } + + @Test + public void testStatefulStatefulConversationWithUserDefinedConversationId() { + int count = conversationalStatefulClientStatefulService.runConversationWithUserDefinedConversationId(); + Assert.assertEquals(2, count); + } + + @Test + public void testStatefulStatefulConversationCheckUserDefinedConversationId() { + String conversationId = conversationalStatefulClientStatefulService.runConversationCheckUserDefinedConversationId(); + Assert.assertEquals("MyConversation2", conversationId); + } + + @Test + public void testStatefulStatefulConversationCheckingScope() { + conversationalStatefulClientStatefulService.runConversationCheckingScope(); + Assert.assertEquals("init,initializeCount,incrementCount,retrieveCount,endConversation,destroy,init,", + conversationalStatefulClientStatefulService.getServiceCalls()); + } + + @Test + public void testStatefulStatefulConversationWithCallback() { + int count = conversationalStatefulClientStatefulService.runConversationWithCallback(); + //System.out.println("Calls: " + conversationalStatefulClientStatefulService.getCalls()); + Assert.assertEquals(4, count); + + Assert.assertEquals("init,runConversationWithCallback,initializeCount,incrementCount,retrieveCount,endConversation,destroy,init,", + conversationalStatefulClientStatefulService.getCalls()); + } + + /////@Test + public void _testStatefulStatefulConversationHavingPassedReference() { + int count = conversationalStatefulClientStatefulService.runConversationHavingPassedReference(); + Assert.assertEquals(3, count); + } + + @Test + public void testStatefulStatefulConversationCallingEndedConversation() { + int count = conversationalStatefulClientStatefulService.runConversationCallingEndedConversation(); + Assert.assertEquals(0, count); + } + + @Test + public void testStatefulStatefulConversationCallingEndedConversationCallback() { + int count = conversationalStatefulClientStatefulService.runConversationCallingEndedConversationCallback(); + Assert.assertEquals(0, count); + } + + // stateful client stateless service tests + // ======================================= + @Test + public void testStatefulStatelessConversationFromInjectedReference() { + int count = conversationalStatefulClientStatelessService.runConversationFromInjectedReference(); + Assert.assertEquals(2, count); + } + + @Test + public void testStatefulStatelessConversationFromServiceReference() { + int count = conversationalStatefulClientStatelessService.runConversationFromServiceReference(); + Assert.assertEquals(2, count); + } + + @Test + public void testStatefulStatelessConversationWithUserDefinedConversationId() { + int count = conversationalStatefulClientStatelessService.runConversationWithUserDefinedConversationId(); + Assert.assertEquals(2, count); + } + + @Test + public void testStatefulStatelessConversationCheckUserDefinedConversationId() { + String conversationId = conversationalStatefulClientStatelessService.runConversationCheckUserDefinedConversationId(); + Assert.assertEquals("MyConversation2", conversationId); + } + + @Test + public void testStatefulStatelessConversationCheckingScope() { + conversationalStatefulClientStatelessService.runConversationCheckingScope(); + + Assert.assertEquals("init,initializeCount,destroy,init,incrementCount,destroy,init,retrieveCount,destroy,init,endConversation,destroy,init,", + conversationalStatefulClientStatelessService.getServiceCalls()); + } + + @Test + public void testStatefulStatelessConversationWithCallback() { + int count = conversationalStatefulClientStatelessService.runConversationWithCallback(); + Assert.assertEquals(4, count); + + Assert.assertEquals("init,runConversationWithCallback,initializeCount,incrementCount,retrieveCount,endConversation,destroy,init,", + conversationalStatefulClientStatelessService.getCalls()); + } + + /////@Test + public void _testStatefulStatelessConversationHavingPassedReference() { + int count = conversationalStatefulClientStatelessService.runConversationHavingPassedReference(); + Assert.assertEquals(3, count); + } + + @Test + public void testStatefulStatelessConversationCallingEndedConversation() { + int count = conversationalStatefulClientStatelessService.runConversationCallingEndedConversation(); + Assert.assertEquals(-999, count); + } + + @Test + public void testStatefulStatelessConversationCallingEndedConversationCallback() { + int count = conversationalStatefulClientStatelessService.runConversationCallingEndedConversationCallback(); + Assert.assertEquals(0, count); + } + +} diff --git a/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/helloworld/passbyref/PassByRefTestCase.java b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/helloworld/passbyref/PassByRefTestCase.java new file mode 100644 index 0000000000..d340923938 --- /dev/null +++ b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/helloworld/passbyref/PassByRefTestCase.java @@ -0,0 +1,130 @@ +/* + * 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 helloworld.passbyref; + +import helloworld.Greetings; +import test.OSGiTestCase; + + +public class PassByRefTestCase extends OSGiTestCase { + + private Greetings greetingsJava; + private Greetings greetingsOSGi; + private String[] origNames = {"world"}; + private String[] names; + + public PassByRefTestCase() { + super("passbyref-test.composite", "passbyref"); + } + + protected void setUp() throws Exception { + + super.setUp(); + greetingsJava = scaDomain.getService(Greetings.class, "JavaGreetingsComponent"); + greetingsOSGi = scaDomain.getService(Greetings.class, "OSGiGreetingsComponent"); + + names = new String[origNames.length]; + System.arraycopy(origNames, 0, names, 0, names.length); + } + + + public void test() throws Exception { + + javaOSGiPassByValue(); + osgiJavaPassByValue(); + javaOSGiPassByRef(); + osgiJavaPassByRef(); + + } + + + public void javaOSGiPassByValue() throws Exception { + + String[] greetings = greetingsJava.getGreetingsFromJava(names); + for (int i = 0; i < origNames.length; i++) { + assertEquals(origNames[i], names[i]); + } + for (int i = 0; i < origNames.length; i++) { + + System.out.println(greetings[i]); + + assertEquals(greetings[i], + "Hello " + origNames[i] + "(From Java)(From OSGi)"); + } + + } + + public void osgiJavaPassByValue() throws Exception { + String[] names = { + "world" + }; + String[] greetings = greetingsOSGi.getGreetingsFromOSGi(names); + + for (int i = 0; i < origNames.length; i++) { + assertEquals(origNames[i], names[i]); + } + for (int i = 0; i < origNames.length; i++) { + + System.out.println(greetings[i]); + + assertEquals(greetings[i], + "Hello " + origNames[i] + "(From OSGi)(From Java)"); + } + + + + } + + public void javaOSGiPassByRef() throws Exception { + String[] names = { + "world" + }; + String[] greetings = greetingsJava.getModifiedGreetingsFromJava(names); + for (int i = 0; i < origNames.length; i++) { + assertEquals("Hello " + origNames[i] + "(From Java)(From OSGi)", names[i]); + } + for (int i = 0; i < origNames.length; i++) { + + System.out.println(greetings[i]); + + assertEquals(greetings[i], + "Hello " + origNames[i] + "(From Java)(From OSGi)"); + } + } + + public void osgiJavaPassByRef() throws Exception { + String[] names = { + "world" + }; + String[] greetings = greetingsOSGi.getModifiedGreetingsFromOSGi(names); + for (int i = 0; i < origNames.length; i++) { + assertEquals("Hello " + origNames[i] + "(From OSGi)(From Java)", names[i]); + } + for (int i = 0; i < origNames.length; i++) { + + System.out.println(greetings[i]); + + assertEquals(greetings[i], + "Hello " + origNames[i] + "(From OSGi)(From Java)"); + } + } + + +} diff --git a/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/helloworld/sdo/SdoTestCase.java b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/helloworld/sdo/SdoTestCase.java new file mode 100644 index 0000000000..c1f11d0b6e --- /dev/null +++ b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/helloworld/sdo/SdoTestCase.java @@ -0,0 +1,95 @@ +/* + * 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 helloworld.sdo; + +import helloworld.sdo.client.HelloWorldClient; + +import java.io.File; +import java.net.URL; + +import junit.framework.TestCase; + +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.impl.EmbeddedSCADomain; + +import util.OSGiTestUtil; + + +public class SdoTestCase extends TestCase { + + + private EmbeddedSCADomain scaDomain; + + + protected void setUp() throws Exception { + + OSGiTestUtil.setUpOSGiTestRuntime(); + + scaDomain = new EmbeddedSCADomain(this.getClass().getClassLoader(), "http://localhost"); + scaDomain.start(); + ContributionService contributionService = scaDomain.getContributionService(); + + URL serviceURL = new File("./target/classes/sdo/ds/HelloWorldService.jar").toURI().toURL(); + URL clientURL = new File("./target/classes/sdo/ds/HelloWorldClient.jar").toURI().toURL(); + + Contribution serviceContribution = contributionService.contribute("HelloWorldService", serviceURL, true); + Contribution clientContribution = contributionService.contribute("HelloWorldClient", clientURL, true); + + for (Composite deployable : serviceContribution.getDeployables()) { + scaDomain.getDomainComposite().getIncludes().add(deployable); + scaDomain.buildComposite(deployable); + } + for (Composite deployable : clientContribution.getDeployables()) { + scaDomain.getDomainComposite().getIncludes().add(deployable); + scaDomain.buildComposite(deployable); + } + for (Composite deployable : clientContribution.getDeployables() ) { + scaDomain.getCompositeActivator().activate(deployable); + scaDomain.getCompositeActivator().start(deployable); + } + } + + protected void tearDown() throws Exception { + scaDomain.close(); + + OSGiTestUtil.shutdownOSGiRuntime(); + } + + + public void testJavaToOSGi() throws Exception { + + HelloWorldClient helloWorldClient = scaDomain.getService(HelloWorldClient.class, "JavaHelloWorldClientComponent"); + String greetings = helloWorldClient.getGreetings("Apache", "Tuscany"); + System.out.println(greetings); + assertEquals("Hello Apache Tuscany", greetings); + } + + public void testOSGiToJava() throws Exception { + + HelloWorldClient helloWorldClient = scaDomain.getService(HelloWorldClient.class, "OSGiHelloWorldClientComponent"); + String greetings = helloWorldClient.getGreetings("Apache", "Tuscany"); + System.out.println(greetings); + assertEquals("Hello Apache Tuscany", greetings); + } + + +} diff --git a/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/helloworld/ws/HelloWorldTestCase.java b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/helloworld/ws/HelloWorldTestCase.java new file mode 100644 index 0000000000..49afb3d8e8 --- /dev/null +++ b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/helloworld/ws/HelloWorldTestCase.java @@ -0,0 +1,55 @@ +/* + * 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 helloworld.ws; + +import helloworld.HelloWorld; + + +import test.OSGiTestCase; +import util.OSGiTestUtil; + + +public class HelloWorldTestCase extends OSGiTestCase { + + private HelloWorld helloWorld; + + public HelloWorldTestCase() { + super("ws-helloworld.composite", "ws"); + } + + protected void setUp() throws Exception { + super.setUp(); + helloWorld = scaDomain.getService(HelloWorld.class, "HelloWorldComponent"); + } + + protected void tearDown() throws Exception { + scaDomain.close(); + OSGiTestUtil.shutdownOSGiRuntime(); + } + + + public void testHelloWorld() throws Exception { + String greetings = helloWorld.getGreetings("petra"); + System.out.println(greetings); + assertEquals("Hello petra", greetings); + } + + +} diff --git a/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/SupplyChainTestCase.java b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/SupplyChainTestCase.java new file mode 100644 index 0000000000..a858c18a90 --- /dev/null +++ b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/SupplyChainTestCase.java @@ -0,0 +1,63 @@ +/* + * 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 supplychain; + +import supplychain.customer.Customer; +import test.OSGiTestCase; + +/** + * Test case for supplychain - it is invoked with different composite files to test + * various scenarios. + */ +public abstract class SupplyChainTestCase extends OSGiTestCase { + + public Customer customer; + + + public SupplyChainTestCase(String compositeName, String contributionLocation) { + super(compositeName, contributionLocation); + } + + protected void setUp() throws Exception { + + super.setUp(); + customer = scaDomain.getService(Customer.class, "CustomerComponent"); + } + + public void test() throws Exception { + + System.out.println("Main thread " + Thread.currentThread()); + customer.purchaseBooks(); + customer.purchaseGames(); + long timeout = 5000L; + while (timeout > 0) { + if (customer.hasOutstandingOrders()) { + Thread.sleep(100); + timeout -= 100; + } else + break; + } + assertFalse(customer.hasOutstandingOrders()); + + System.out.println("Test complete"); + + } + + +} diff --git a/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/VersionedSupplyChainTestCase.java b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/VersionedSupplyChainTestCase.java new file mode 100644 index 0000000000..a9941aebcd --- /dev/null +++ b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/VersionedSupplyChainTestCase.java @@ -0,0 +1,71 @@ +/* + * 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 supplychain; + +import supplychain.customer.Customer; +import test.OSGiTestCase; + +/** + * OSGi test program - common code for versioned bundles + */ +public abstract class VersionedSupplyChainTestCase extends OSGiTestCase { + + private Customer customer1; + private Customer customer2; + + + public VersionedSupplyChainTestCase(String compositeName, String contributionLocation) { + super(compositeName, contributionLocation); + } + + protected void setUp() throws Exception { + + super.setUp(); + customer1 = scaDomain.getService(Customer.class, "CustomerComponent1"); + customer2 = scaDomain.getService(Customer.class, "CustomerComponent2"); + } + + protected void tearDown() throws Exception { + super.tearDown(); + Thread.sleep(2000); + } + + public void test() throws Exception { + + System.out.println("Main thread " + Thread.currentThread()); + customer1.purchaseBooks(); + customer2.purchaseGames(); + long timeout = 5000L; + while (timeout > 0) { + if (customer1.hasOutstandingOrders()) { + Thread.sleep(100); + timeout -= 100; + } else if (customer2.hasOutstandingOrders()) { + Thread.sleep(100); + timeout -= 100; + } else + break; + } + assertFalse(customer1.hasOutstandingOrders()); + assertFalse(customer2.hasOutstandingOrders()); + + System.out.println("Test complete"); + + } +} diff --git a/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/factory/DSFactoryTestCase.java b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/factory/DSFactoryTestCase.java new file mode 100644 index 0000000000..8e939b1a83 --- /dev/null +++ b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/factory/DSFactoryTestCase.java @@ -0,0 +1,32 @@ +/* + * 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 supplychain.factory; + + +/** + * OSGi test program - declarative with scopes other than composites which use OSGi service factories + */ +public class DSFactoryTestCase extends FactoryTestCase { + + public DSFactoryTestCase() { + super("factory-ds-test.composite", "factory/ds"); + } + + +} diff --git a/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/factory/FactoryTestCase.java b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/factory/FactoryTestCase.java new file mode 100644 index 0000000000..39d90bb75c --- /dev/null +++ b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/factory/FactoryTestCase.java @@ -0,0 +1,72 @@ +/* + * 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 supplychain.factory; + +import supplychain.SupplyChainTestCase; + +/** + * OSGi test program - declarative with scopes other than composites which use OSGi service factories + */ +public class FactoryTestCase extends SupplyChainTestCase { + /** + * This constant defines the time period (in milliseconds) for which we are prepared to wait for + * the @OneWay notifyShipment() callback to run. + */ + private static final long MAX_WAIT_TIME_FOR_CALLBACK = 10000; + + public FactoryTestCase() { + super("factory-test.composite", "factory"); + } + + protected FactoryTestCase(String compositeName, String contributionLocation) { + super(compositeName, contributionLocation); + } + + + @Override + public void test() throws Exception { + + System.out.println("Main thread " + Thread.currentThread()); + customer.purchaseBooks(); + waitForOrderShipmentNotification(); // TUSCANY-2198 notifyShipment() callback is @OneWay + assertFalse(customer.hasOutstandingOrders()); + + customer.purchaseGames(); + waitForOrderShipmentNotification(); // TUSCANY-2198 notifyShipment() callback is @OneWay + assertFalse(customer.hasOutstandingOrders()); + + Thread.sleep(2000); + System.out.println("Test complete"); + + } + + /** + * Since the notifyShipment() callback on the Customer is @OneWay, we need to allow + * some time for it to complete as it is runs asynchronously. + * + * This is for TUSCANY-2198 + */ + private void waitForOrderShipmentNotification() throws InterruptedException { + long startTime = System.currentTimeMillis(); + while (customer.hasOutstandingOrders() + && System.currentTimeMillis() - startTime < MAX_WAIT_TIME_FOR_CALLBACK) { + Thread.sleep(100); + } + } +} diff --git a/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/interfaces/DSInterfacesTestCase.java b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/interfaces/DSInterfacesTestCase.java new file mode 100644 index 0000000000..5376687b61 --- /dev/null +++ b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/interfaces/DSInterfacesTestCase.java @@ -0,0 +1,32 @@ +/* + * 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 supplychain.interfaces; + +import supplychain.SupplyChainTestCase; + +/** + * OSGi test program - declarative with components exposing multiple services with multiple interfaces + */ +public class DSInterfacesTestCase extends SupplyChainTestCase { + + public DSInterfacesTestCase() { + super("interfaces-ds-test.composite", "interfaces/ds"); + } + +} diff --git a/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/interfaces/InterfacesTestCase.java b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/interfaces/InterfacesTestCase.java new file mode 100644 index 0000000000..6d8dc1021e --- /dev/null +++ b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/interfaces/InterfacesTestCase.java @@ -0,0 +1,32 @@ +/* + * 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 supplychain.interfaces; + +import supplychain.SupplyChainTestCase; + +/** + * OSGi test program - procedural with components exposing multiple services with multiple interfaces + */ +public class InterfacesTestCase extends SupplyChainTestCase { + + public InterfacesTestCase() { + super("interfaces-test.composite", "interfaces"); + } + +} diff --git a/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/properties/DSProperties2TestCase.java b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/properties/DSProperties2TestCase.java new file mode 100644 index 0000000000..e037ae9675 --- /dev/null +++ b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/properties/DSProperties2TestCase.java @@ -0,0 +1,31 @@ +/* + * 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 supplychain.properties; + + +/** + * OSGi test program - declarative with business properties + */ +public class DSProperties2TestCase extends Properties2TestCase { + + public DSProperties2TestCase() { + super("properties2-ds-test.composite", "properties/ds"); + } + +} diff --git a/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/properties/DSPropertiesTestCase.java b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/properties/DSPropertiesTestCase.java new file mode 100644 index 0000000000..eecf67913d --- /dev/null +++ b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/properties/DSPropertiesTestCase.java @@ -0,0 +1,31 @@ +/* + * 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 supplychain.properties; + + +/** + * OSGi test program - declarative with business properties + */ +public class DSPropertiesTestCase extends PropertiesTestCase { + + public DSPropertiesTestCase() { + super("properties-ds-test.composite", "properties/ds"); + } + +} diff --git a/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/properties/Properties2TestCase.java b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/properties/Properties2TestCase.java new file mode 100644 index 0000000000..203bf5123c --- /dev/null +++ b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/properties/Properties2TestCase.java @@ -0,0 +1,69 @@ +/* + * 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 supplychain.properties; + + +import stockquote.StockQuote; +import test.OSGiTestCase; + +/** + * OSGi test program - procedural with business properties + */ +public class Properties2TestCase extends OSGiTestCase { + + + private StockQuote stockQuoteServiceUSD; + private StockQuote stockQuoteServiceEURO; + + public Properties2TestCase() { + super("properties2-test.composite", "properties"); + } + + protected Properties2TestCase(String compositeName, String contributionLocation) { + super(compositeName, contributionLocation); + } + + protected void setUp() throws Exception { + + super.setUp(); + stockQuoteServiceUSD = scaDomain.getService(StockQuote.class, "USDStockQuoteComponent"); + stockQuoteServiceEURO = scaDomain.getService(StockQuote.class, "EUROStockQuoteComponent"); + } + + public void test() throws Exception { + + double stockQuote = stockQuoteServiceUSD.getQuote("IBM"); + + double expectedValue = 52.81 * 2.0; + + System.out.println("IBM: $" + stockQuote); + + assertTrue(stockQuote > expectedValue - 0.1 && stockQuote < expectedValue + 0.1); + + double stockQuote2 = stockQuoteServiceEURO.getQuote("IBM"); + + double expectedValue2 = 52.81 * 1.48; + + System.out.println("IBM: Euro " + stockQuote2); + + assertTrue(stockQuote2 > expectedValue2 - 0.1 && stockQuote2 < expectedValue2 + 0.1); + + } + +} diff --git a/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/properties/PropertiesTestCase.java b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/properties/PropertiesTestCase.java new file mode 100644 index 0000000000..429b1f10ef --- /dev/null +++ b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/properties/PropertiesTestCase.java @@ -0,0 +1,58 @@ +/* + * 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 supplychain.properties; + +import stockquote.StockQuote; +import test.OSGiTestCase; + +/** + * OSGi test program - procedural with business properties + */ +public class PropertiesTestCase extends OSGiTestCase { + + + private StockQuote stockQuoteService; + + public PropertiesTestCase() { + super("properties-test.composite", "properties"); + } + + protected PropertiesTestCase(String compositeName, String contributionLocation) { + super(compositeName, contributionLocation); + } + + protected void setUp() throws Exception { + super.setUp(); + stockQuoteService = scaDomain.getService(StockQuote.class, "StockQuoteComponent"); + } + + + public void test() throws Exception { + + double stockQuote = stockQuoteService.getQuote("IBM"); + + double expectedValue = 52.81 * 2.0; + + System.out.println("IBM: " + stockQuote); + + assertTrue(stockQuote > expectedValue - 0.1 && stockQuote < expectedValue + 0.1); + + } + +} diff --git a/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/services/DSServicesTestCase.java b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/services/DSServicesTestCase.java new file mode 100644 index 0000000000..dbc980f8c4 --- /dev/null +++ b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/services/DSServicesTestCase.java @@ -0,0 +1,32 @@ +/* + * 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 supplychain.services; + +import supplychain.SupplyChainTestCase; + +/** + * OSGi test program - declarative with components exposing multiple services + */ +public class DSServicesTestCase extends SupplyChainTestCase { + + public DSServicesTestCase() { + super("services-ds-test.composite", "services/ds"); + } + +} diff --git a/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/services/ServicesTestCase.java b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/services/ServicesTestCase.java new file mode 100644 index 0000000000..e39295a402 --- /dev/null +++ b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/services/ServicesTestCase.java @@ -0,0 +1,32 @@ +/* + * 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 supplychain.services; + +import supplychain.SupplyChainTestCase; + +/** + * OSGi test program - procedural with components exposing multiple services + */ +public class ServicesTestCase extends SupplyChainTestCase { + + public ServicesTestCase() { + super("services-test.composite", "services"); + } + +} diff --git a/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/version/DSVersionTestCase.java b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/version/DSVersionTestCase.java new file mode 100644 index 0000000000..c2f6bff4f5 --- /dev/null +++ b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/version/DSVersionTestCase.java @@ -0,0 +1,33 @@ +/* + * 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 supplychain.version; + +import supplychain.VersionedSupplyChainTestCase; + +/** + * OSGi test program - declarative with versioning + */ +public class DSVersionTestCase extends VersionedSupplyChainTestCase { + + public DSVersionTestCase() { + super("version-ds-test.composite", "version/ds"); + } + + +} diff --git a/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/version/VersionTestCase.java b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/version/VersionTestCase.java new file mode 100644 index 0000000000..17ba7a2f14 --- /dev/null +++ b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/version/VersionTestCase.java @@ -0,0 +1,33 @@ +/* + * 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 supplychain.version; + +import supplychain.VersionedSupplyChainTestCase; + +/** + * OSGi test program - procedural with versioning + */ +public class VersionTestCase extends VersionedSupplyChainTestCase { + + public VersionTestCase() { + super("version-test.composite", "version"); + } + + +} diff --git a/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/wiring/DSWiring1TestCase.java b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/wiring/DSWiring1TestCase.java new file mode 100644 index 0000000000..8c33720018 --- /dev/null +++ b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/wiring/DSWiring1TestCase.java @@ -0,0 +1,33 @@ +/* + * 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 supplychain.wiring; + +import supplychain.SupplyChainTestCase; + +/** + * OSGi test program - declarative with SCA wiring + */ +public class DSWiring1TestCase extends SupplyChainTestCase { + + public DSWiring1TestCase() { + super("wiring-ds-test1.composite", "wiring/ds"); + } + + +} diff --git a/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/wiring/DSWiring2TestCase.java b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/wiring/DSWiring2TestCase.java new file mode 100644 index 0000000000..0c6edd6691 --- /dev/null +++ b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/wiring/DSWiring2TestCase.java @@ -0,0 +1,33 @@ +/* + * 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 supplychain.wiring; + +import supplychain.SupplyChainTestCase; + +/** + * OSGi test program - declarative with SCA wiring + */ +public class DSWiring2TestCase extends SupplyChainTestCase { + + public DSWiring2TestCase() { + super("wiring-ds-test2.composite", "wiring/ds"); + } + + +} diff --git a/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/wiring/Wiring1TestCase.java b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/wiring/Wiring1TestCase.java new file mode 100644 index 0000000000..0b48ac90ba --- /dev/null +++ b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/wiring/Wiring1TestCase.java @@ -0,0 +1,32 @@ +/* + * 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 supplychain.wiring; + +import supplychain.SupplyChainTestCase; + +/** + * OSGi test program - procedural with SCA wiring + */ +public class Wiring1TestCase extends SupplyChainTestCase { + + public Wiring1TestCase() { + super("wiring-test1.composite", "wiring"); + } + +} diff --git a/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/wiring/Wiring2TestCase.java b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/wiring/Wiring2TestCase.java new file mode 100644 index 0000000000..c84741f34f --- /dev/null +++ b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/supplychain/wiring/Wiring2TestCase.java @@ -0,0 +1,32 @@ +/* + * 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 supplychain.wiring; + +import supplychain.SupplyChainTestCase; + +/** + * OSGi test program - procedural with SCA wiring + */ +public class Wiring2TestCase extends SupplyChainTestCase { + + public Wiring2TestCase() { + super("wiring-test2.composite", "wiring"); + } + +} diff --git a/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/test/OSGiTestCase.java b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/test/OSGiTestCase.java new file mode 100644 index 0000000000..5a9b2a8b1d --- /dev/null +++ b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/test/OSGiTestCase.java @@ -0,0 +1,67 @@ +/* + * 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 test; + +import java.io.File; +import java.net.MalformedURLException; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +import util.OSGiTestUtil; + +/** + * Test case setup base code - it is invoked with different composite files to test + * various scenarios. + */ +public abstract class OSGiTestCase extends TestCase { + + private String compositeName; + private String contributionLocation; + public SCADomain scaDomain; + + public OSGiTestCase(String compositeName, String contributionLocation) { + super(); + this.compositeName = compositeName; + this.contributionLocation = contributionLocation; + try { + if (contributionLocation != null) { + File f = new File("target/classes/" + contributionLocation); + this.contributionLocation = f.toURL().toString(); + } + } catch (MalformedURLException e) { + e.printStackTrace(); + } + } + + protected void setUp() throws Exception { + + OSGiTestUtil.setUpOSGiTestRuntime(); + + scaDomain = SCADomain.newInstance("http://localhost", contributionLocation, compositeName); + } + + protected void tearDown() throws Exception { + scaDomain.close(); + + OSGiTestUtil.shutdownOSGiRuntime(); + } + +} diff --git a/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/util/OSGiTestUtil.java b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/util/OSGiTestUtil.java new file mode 100644 index 0000000000..7b95c12038 --- /dev/null +++ b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/java/util/OSGiTestUtil.java @@ -0,0 +1,71 @@ +/* + * 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 util; + +import org.apache.tuscany.sca.osgi.runtime.OSGiRuntime; + + +/** + * OSGi Test Utils + */ +public class OSGiTestUtil { + + public static void setUpOSGiTestRuntime() throws Exception { + + setUpFelixTestRuntime(); + } + + + private static void setUpFelixTestRuntime() throws Exception { + + String felixConfigFileName = "file:target/test-classes/osgi/felix/felix.config.properties"; + + System.setProperty("felix.config.properties", felixConfigFileName); + + try { + + ClassLoader cl = OSGiTestUtil.class.getClassLoader(); + + Class felixMainClass = cl.loadClass("org.apache.felix.main.Main"); + if (felixMainClass != null) { + String felixDir = felixMainClass.getProtectionDomain().getCodeSource().getLocation().getPath(); + int index = 0; + if ((index = felixDir.indexOf("/org.apache.felix.main")) >= 0) { + felixDir = felixDir.substring(0, index); + System.setProperty("FELIX_DIR", felixDir); + } + } + + } catch (Exception e) { + // Ignore + } + + + } + + public static void shutdownOSGiRuntime() { + try { + OSGiRuntime.stop(); + + } catch (Exception e) { + // Ignore + } + } + +} diff --git a/sca-java-1.x/trunk/itest/osgi-implementation/src/test/resources/osgi/felix/felix.config.properties b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/resources/osgi/felix/felix.config.properties new file mode 100644 index 0000000000..8399991503 --- /dev/null +++ b/sca-java-1.x/trunk/itest/osgi-implementation/src/test/resources/osgi/felix/felix.config.properties @@ -0,0 +1,45 @@ +# +# 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. +# +# +# Framework config properties. +# +org.osgi.framework.system.packages=org.osgi.framework; version=1.3.0, \ + org.osgi.service.packageadmin; version=1.2.0, \ + org.osgi.service.startlevel; version=1.0.0, \ + org.osgi.service.url; version=1.0.0 \ + org.osgi.util.tracker; version=1.3.2 + + +felix.auto.start.1= \ + "file://${FELIX_DIR}/org.apache.felix.scr/1.0.2/org.apache.felix.scr-1.0.2.jar" \ + "file://${FELIX_DIR}/org.apache.felix.configadmin/1.0.1/org.apache.felix.configadmin-1.0.1.jar" + + +# "file://${FELIX_DIR}/org.apache.felix.shell/1.0.1/org.apache.felix.shell-1.0.1.jar" \ +# "file://${FELIX_DIR}/org.apache.felix.shell.tui/1.0.1/org.apache.felix.shell.tui-1.0.1.jar" \ +# "file://${FELIX_DIR}/org.apache.felix.bundlerepository/1.0.3/org.apache.felix.bundlerepository-1.0.3.jar" \ + +felix.startlevel.framework=1 +felix.startlevel.bundle=1 + +# +# Bundle config properties. +# +org.osgi.service.http.port=8080 +obr.shell.telnet=on |