diff options
Diffstat (limited to 'sca-java-1.x/branches/sca-java-1.0.1/itest/osgi-implementation/src/test')
28 files changed, 1561 insertions, 0 deletions
diff --git a/sca-java-1.x/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/callback/Callback1TestCase.java b/sca-java-1.x/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/callback/Callback1TestCase.java new file mode 100644 index 0000000000..54b9b00bc8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0.1/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/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/callback/Callback2TestCase.java b/sca-java-1.x/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/callback/Callback2TestCase.java new file mode 100644 index 0000000000..b26bfbd98d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0.1/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/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/callback/Callback3TestCase.java b/sca-java-1.x/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/callback/Callback3TestCase.java new file mode 100644 index 0000000000..667df7aa12 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0.1/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/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/callback/CallbackTestCase.java b/sca-java-1.x/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/callback/CallbackTestCase.java new file mode 100644 index 0000000000..a95437f8c1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0.1/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/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/conversation/ConversationTestCase.java b/sca-java-1.x/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/conversation/ConversationTestCase.java new file mode 100644 index 0000000000..c5d94df93d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0.1/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/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/helloworld/passbyref/PassByRefTestCase.java b/sca-java-1.x/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/helloworld/passbyref/PassByRefTestCase.java new file mode 100644 index 0000000000..d340923938 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0.1/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/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/helloworld/ws/HelloWorldTestCase.java b/sca-java-1.x/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/helloworld/ws/HelloWorldTestCase.java new file mode 100644 index 0000000000..49afb3d8e8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0.1/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/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/supplychain/SupplyChainTestCase.java b/sca-java-1.x/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/supplychain/SupplyChainTestCase.java new file mode 100644 index 0000000000..a858c18a90 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0.1/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/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/supplychain/VersionedSupplyChainTestCase.java b/sca-java-1.x/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/supplychain/VersionedSupplyChainTestCase.java new file mode 100644 index 0000000000..bff919bd4a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0.1/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(1000); + } + + 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/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/supplychain/factory/DSFactoryTestCase.java b/sca-java-1.x/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/supplychain/factory/DSFactoryTestCase.java new file mode 100644 index 0000000000..8e939b1a83 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0.1/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/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/supplychain/factory/FactoryTestCase.java b/sca-java-1.x/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/supplychain/factory/FactoryTestCase.java new file mode 100644 index 0000000000..e319076882 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/supplychain/factory/FactoryTestCase.java @@ -0,0 +1,52 @@ +/* + * 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 { + + 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(); + assertFalse(customer.hasOutstandingOrders()); + + customer.purchaseGames(); + assertFalse(customer.hasOutstandingOrders()); + + Thread.sleep(1000); + System.out.println("Test complete"); + + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/supplychain/interfaces/DSInterfacesTestCase.java b/sca-java-1.x/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/supplychain/interfaces/DSInterfacesTestCase.java new file mode 100644 index 0000000000..5376687b61 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0.1/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/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/supplychain/interfaces/InterfacesTestCase.java b/sca-java-1.x/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/supplychain/interfaces/InterfacesTestCase.java new file mode 100644 index 0000000000..6d8dc1021e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0.1/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/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/supplychain/properties/DSProperties2TestCase.java b/sca-java-1.x/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/supplychain/properties/DSProperties2TestCase.java new file mode 100644 index 0000000000..e037ae9675 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0.1/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/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/supplychain/properties/DSPropertiesTestCase.java b/sca-java-1.x/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/supplychain/properties/DSPropertiesTestCase.java new file mode 100644 index 0000000000..eecf67913d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0.1/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/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/supplychain/properties/Properties2TestCase.java b/sca-java-1.x/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/supplychain/properties/Properties2TestCase.java new file mode 100644 index 0000000000..203bf5123c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0.1/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/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/supplychain/properties/PropertiesTestCase.java b/sca-java-1.x/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/supplychain/properties/PropertiesTestCase.java new file mode 100644 index 0000000000..429b1f10ef --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0.1/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/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/supplychain/services/DSServicesTestCase.java b/sca-java-1.x/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/supplychain/services/DSServicesTestCase.java new file mode 100644 index 0000000000..dbc980f8c4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0.1/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/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/supplychain/services/ServicesTestCase.java b/sca-java-1.x/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/supplychain/services/ServicesTestCase.java new file mode 100644 index 0000000000..e39295a402 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0.1/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/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/supplychain/version/DSVersionTestCase.java b/sca-java-1.x/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/supplychain/version/DSVersionTestCase.java new file mode 100644 index 0000000000..c2f6bff4f5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0.1/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/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/supplychain/version/VersionTestCase.java b/sca-java-1.x/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/supplychain/version/VersionTestCase.java new file mode 100644 index 0000000000..17ba7a2f14 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0.1/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/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/supplychain/wiring/DSWiring1TestCase.java b/sca-java-1.x/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/supplychain/wiring/DSWiring1TestCase.java new file mode 100644 index 0000000000..8c33720018 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0.1/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/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/supplychain/wiring/DSWiring2TestCase.java b/sca-java-1.x/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/supplychain/wiring/DSWiring2TestCase.java new file mode 100644 index 0000000000..0c6edd6691 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0.1/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/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/supplychain/wiring/Wiring1TestCase.java b/sca-java-1.x/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/supplychain/wiring/Wiring1TestCase.java new file mode 100644 index 0000000000..0b48ac90ba --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0.1/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/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/supplychain/wiring/Wiring2TestCase.java b/sca-java-1.x/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/supplychain/wiring/Wiring2TestCase.java new file mode 100644 index 0000000000..c84741f34f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0.1/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/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/test/OSGiTestCase.java b/sca-java-1.x/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/test/OSGiTestCase.java new file mode 100644 index 0000000000..5a9b2a8b1d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0.1/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/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/util/OSGiTestUtil.java b/sca-java-1.x/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/java/util/OSGiTestUtil.java new file mode 100644 index 0000000000..7b95c12038 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0.1/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/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/resources/osgi/felix/felix.config.properties b/sca-java-1.x/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/resources/osgi/felix/felix.config.properties new file mode 100644 index 0000000000..524454171f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0.1/itest/osgi-implementation/src/test/resources/osgi/felix/felix.config.properties @@ -0,0 +1,44 @@ +# +# 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 + + +felix.auto.start.1= \ + "file://${FELIX_DIR}/org.apache.felix.shell/1.0.0/org.apache.felix.shell-1.0.0.jar" \ + "file://${FELIX_DIR}/org.apache.felix.shell.tui/1.0.0/org.apache.felix.shell.tui-1.0.0.jar" \ + "file://${FELIX_DIR}/org.apache.felix.bundlerepository/1.0.0/org.apache.felix.bundlerepository-1.0.0.jar" \ + "file://${FELIX_DIR}/org.apache.felix.scr/0.9.0-SNAPSHOT/org.apache.felix.scr-0.9.0-SNAPSHOT.jar" \ + "file://${FELIX_DIR}/org.apache.felix.log/0.9.0-incubator-SNAPSHOT/org.apache.felix.log-0.9.0-incubator-SNAPSHOT.jar" \ + "file://${FELIX_DIR}/org.apache.felix.configadmin/0.9.0-SNAPSHOT/org.apache.felix.configadmin-0.9.0-SNAPSHOT.jar" + + +felix.startlevel.framework=1 +felix.startlevel.bundle=1 + +# +# Bundle config properties. +# +org.osgi.service.http.port=8085 +obr.shell.telnet=on |