From a40e527938d76ba71f211da7e327adb50384ba69 Mon Sep 17 00:00:00 2001 From: lresende Date: Wed, 11 Nov 2009 23:26:33 +0000 Subject: Moving 1.x tags git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835157 13f79535-47bb-0310-9956-ffa450edef68 --- .../test/java/helloworld/HelloWorldTestCase.java | 55 +++++++++ .../test/java/helloworld/PassByRefTestCase.java | 135 +++++++++++++++++++++ .../test/java/supplychain/SupplyChainTestCase.java | 79 ++++++++++++ .../supplychain/VersionedSupplyChainTestCase.java | 81 +++++++++++++ .../supplychain/factory/DSFactoryTestCase.java | 32 +++++ .../java/supplychain/factory/FactoryTestCase.java | 52 ++++++++ .../interfaces/DSInterfacesTestCase.java | 32 +++++ .../supplychain/interfaces/InterfacesTestCase.java | 32 +++++ .../properties/DSProperties2TestCase.java | 31 +++++ .../properties/DSPropertiesTestCase.java | 31 +++++ .../properties/Properties2TestCase.java | 83 +++++++++++++ .../supplychain/properties/PropertiesTestCase.java | 73 +++++++++++ .../supplychain/services/DSServicesTestCase.java | 32 +++++ .../supplychain/services/ServicesTestCase.java | 32 +++++ .../supplychain/version/DSVersionTestCase.java | 33 +++++ .../java/supplychain/version/VersionTestCase.java | 33 +++++ .../java/supplychain/wiring/DSWiring1TestCase.java | 33 +++++ .../java/supplychain/wiring/DSWiring2TestCase.java | 33 +++++ .../java/supplychain/wiring/Wiring1TestCase.java | 32 +++++ .../java/supplychain/wiring/Wiring2TestCase.java | 32 +++++ .../src/test/java/util/OSGiTestUtil.java | 71 +++++++++++ 21 files changed, 1047 insertions(+) create mode 100644 sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/helloworld/HelloWorldTestCase.java create mode 100644 sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/helloworld/PassByRefTestCase.java create mode 100644 sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/SupplyChainTestCase.java create mode 100644 sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/VersionedSupplyChainTestCase.java create mode 100644 sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/factory/DSFactoryTestCase.java create mode 100644 sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/factory/FactoryTestCase.java create mode 100644 sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/interfaces/DSInterfacesTestCase.java create mode 100644 sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/interfaces/InterfacesTestCase.java create mode 100644 sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/properties/DSProperties2TestCase.java create mode 100644 sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/properties/DSPropertiesTestCase.java create mode 100644 sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/properties/Properties2TestCase.java create mode 100644 sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/properties/PropertiesTestCase.java create mode 100644 sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/services/DSServicesTestCase.java create mode 100644 sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/services/ServicesTestCase.java create mode 100644 sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/version/DSVersionTestCase.java create mode 100644 sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/version/VersionTestCase.java create mode 100644 sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/wiring/DSWiring1TestCase.java create mode 100644 sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/wiring/DSWiring2TestCase.java create mode 100644 sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/wiring/Wiring1TestCase.java create mode 100644 sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/wiring/Wiring2TestCase.java create mode 100644 sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/util/OSGiTestUtil.java (limited to 'sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java') diff --git a/sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/helloworld/HelloWorldTestCase.java b/sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/helloworld/HelloWorldTestCase.java new file mode 100644 index 0000000000..ab08fd1982 --- /dev/null +++ b/sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/helloworld/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; + +import helloworld.HelloWorld; +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +import util.OSGiTestUtil; + + +public class HelloWorldTestCase extends TestCase { + + private SCADomain scaDomain; + private HelloWorld helloWorld; + + protected void setUp() throws Exception { + OSGiTestUtil.setUpOSGiTestRutime(); + + scaDomain = SCADomain.newInstance("sca/ws-helloworld.composite"); + 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/tags/0.99-incubating/itest/osgi-implementation/src/test/java/helloworld/PassByRefTestCase.java b/sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/helloworld/PassByRefTestCase.java new file mode 100644 index 0000000000..454fc6a7f8 --- /dev/null +++ b/sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/helloworld/PassByRefTestCase.java @@ -0,0 +1,135 @@ +/* + * 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; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +import util.OSGiTestUtil; + + +public class PassByRefTestCase extends TestCase { + + private SCADomain scaDomain; + private Greetings greetingsJava; + private Greetings greetingsOSGi; + private String[] origNames = {"world"}; + private String[] names; + + protected void setUp() throws Exception { + OSGiTestUtil.setUpOSGiTestRutime(); + + scaDomain = SCADomain.newInstance("sca/passbyref-test.composite"); + 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); + } + + protected void tearDown() throws Exception { + scaDomain.close(); + OSGiTestUtil.shutdownOSGiRuntime(); + } + + 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/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/SupplyChainTestCase.java b/sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/SupplyChainTestCase.java new file mode 100644 index 0000000000..b41c00bd0b --- /dev/null +++ b/sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/SupplyChainTestCase.java @@ -0,0 +1,79 @@ +/* + * 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 junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + + +import supplychain.customer.Customer; +import util.OSGiTestUtil; + +/** + * Test case for supplychain - it is invoked with different composite files to test + * various scenarios. + */ +public abstract class SupplyChainTestCase extends TestCase { + + private String compositeName; + private SCADomain scaDomain; + public Customer customer; + + public SupplyChainTestCase(String compositeName) { + super(); + this.compositeName = compositeName; + } + + protected void setUp() throws Exception { + + OSGiTestUtil.setUpOSGiTestRutime(); + + scaDomain = SCADomain.newInstance(compositeName); + customer = scaDomain.getService(Customer.class, "CustomerComponent"); + } + + protected void tearDown() throws Exception { + scaDomain.close(); + + OSGiTestUtil.shutdownOSGiRuntime(); + } + + + 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/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/VersionedSupplyChainTestCase.java b/sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/VersionedSupplyChainTestCase.java new file mode 100644 index 0000000000..d569cd7189 --- /dev/null +++ b/sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/VersionedSupplyChainTestCase.java @@ -0,0 +1,81 @@ +/* + * 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 junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +import supplychain.customer.Customer; +import util.OSGiTestUtil; + +/** + * OSGi test program - common code for versioned bundles + */ +public abstract class VersionedSupplyChainTestCase extends TestCase { + + private String compositeName; + private SCADomain scaDomain; + private Customer customer1; + private Customer customer2; + + + public VersionedSupplyChainTestCase(String compositeName) { + super(); + this.compositeName = compositeName; + } + + protected void setUp() throws Exception { + + OSGiTestUtil.setUpOSGiTestRutime(); + + scaDomain = SCADomain.newInstance(compositeName); + customer1 = scaDomain.getService(Customer.class, "CustomerComponent1"); + customer2 = scaDomain.getService(Customer.class, "CustomerComponent2"); + } + + protected void tearDown() throws Exception { + scaDomain.close(); + + OSGiTestUtil.shutdownOSGiRuntime(); + } + + 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/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/factory/DSFactoryTestCase.java b/sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/factory/DSFactoryTestCase.java new file mode 100644 index 0000000000..eba07d7d93 --- /dev/null +++ b/sca-java-1.x/tags/0.99-incubating/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("sca/factory-ds-test.composite"); + } + + +} diff --git a/sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/factory/FactoryTestCase.java b/sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/factory/FactoryTestCase.java new file mode 100644 index 0000000000..2f367a2f64 --- /dev/null +++ b/sca-java-1.x/tags/0.99-incubating/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("sca/factory-test.composite"); + } + + protected FactoryTestCase(String compositeName) { + super(compositeName); + } + + + @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/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/interfaces/DSInterfacesTestCase.java b/sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/interfaces/DSInterfacesTestCase.java new file mode 100644 index 0000000000..64610bfff8 --- /dev/null +++ b/sca-java-1.x/tags/0.99-incubating/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("sca/interfaces-ds-test.composite"); + } + +} diff --git a/sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/interfaces/InterfacesTestCase.java b/sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/interfaces/InterfacesTestCase.java new file mode 100644 index 0000000000..7b7d4f1e04 --- /dev/null +++ b/sca-java-1.x/tags/0.99-incubating/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("sca/interfaces-test.composite"); + } + +} diff --git a/sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/properties/DSProperties2TestCase.java b/sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/properties/DSProperties2TestCase.java new file mode 100644 index 0000000000..20dab1ec66 --- /dev/null +++ b/sca-java-1.x/tags/0.99-incubating/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("sca/properties2-ds-test.composite"); + } + +} diff --git a/sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/properties/DSPropertiesTestCase.java b/sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/properties/DSPropertiesTestCase.java new file mode 100644 index 0000000000..5de9035ace --- /dev/null +++ b/sca-java-1.x/tags/0.99-incubating/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("sca/properties-ds-test.composite"); + } + +} diff --git a/sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/properties/Properties2TestCase.java b/sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/properties/Properties2TestCase.java new file mode 100644 index 0000000000..51d37a4519 --- /dev/null +++ b/sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/properties/Properties2TestCase.java @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package supplychain.properties; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +import stockquote.StockQuote; +import util.OSGiTestUtil; + +/** + * OSGi test program - procedural with business properties + */ +public class Properties2TestCase extends TestCase { + + + private SCADomain scaDomain; + private StockQuote stockQuoteServiceUSD; + private StockQuote stockQuoteServiceEURO; + private String compositeName; + + public Properties2TestCase() { + super(); + compositeName = "sca/properties2-test.composite"; + } + + protected Properties2TestCase(String compositeName) { + super(); + this.compositeName = compositeName; + } + + protected void setUp() throws Exception { + + OSGiTestUtil.setUpOSGiTestRutime(); + + scaDomain = SCADomain.newInstance(compositeName); + stockQuoteServiceUSD = scaDomain.getService(StockQuote.class, "USDStockQuoteComponent"); + stockQuoteServiceEURO = scaDomain.getService(StockQuote.class, "EUROStockQuoteComponent"); + } + + protected void tearDown() throws Exception { + scaDomain.close(); + OSGiTestUtil.shutdownOSGiRuntime(); + } + + 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/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/properties/PropertiesTestCase.java b/sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/properties/PropertiesTestCase.java new file mode 100644 index 0000000000..23e1624be1 --- /dev/null +++ b/sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/properties/PropertiesTestCase.java @@ -0,0 +1,73 @@ +/* + * 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 junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +import stockquote.StockQuote; +import util.OSGiTestUtil; + +/** + * OSGi test program - procedural with business properties + */ +public class PropertiesTestCase extends TestCase { + + + private SCADomain scaDomain; + private StockQuote stockQuoteService; + private String compositeName; + + public PropertiesTestCase() { + super(); + compositeName = "sca/properties-test.composite"; + } + + protected PropertiesTestCase(String compositeName) { + super(); + this.compositeName = compositeName; + } + + protected void setUp() throws Exception { + + OSGiTestUtil.setUpOSGiTestRutime(); + + scaDomain = SCADomain.newInstance(compositeName); + stockQuoteService = scaDomain.getService(StockQuote.class, "StockQuoteComponent"); + } + + protected void tearDown() throws Exception { + scaDomain.close(); + OSGiTestUtil.shutdownOSGiRuntime(); + } + + 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/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/services/DSServicesTestCase.java b/sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/services/DSServicesTestCase.java new file mode 100644 index 0000000000..069a5e538d --- /dev/null +++ b/sca-java-1.x/tags/0.99-incubating/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("sca/services-ds-test.composite"); + } + +} diff --git a/sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/services/ServicesTestCase.java b/sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/services/ServicesTestCase.java new file mode 100644 index 0000000000..5ec9f51c71 --- /dev/null +++ b/sca-java-1.x/tags/0.99-incubating/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("sca/services-test.composite"); + } + +} diff --git a/sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/version/DSVersionTestCase.java b/sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/version/DSVersionTestCase.java new file mode 100644 index 0000000000..3226362335 --- /dev/null +++ b/sca-java-1.x/tags/0.99-incubating/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("sca/version-ds-test.composite"); + } + + +} diff --git a/sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/version/VersionTestCase.java b/sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/version/VersionTestCase.java new file mode 100644 index 0000000000..3153399820 --- /dev/null +++ b/sca-java-1.x/tags/0.99-incubating/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("sca/version-test.composite"); + } + + +} diff --git a/sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/wiring/DSWiring1TestCase.java b/sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/wiring/DSWiring1TestCase.java new file mode 100644 index 0000000000..8c50bf89aa --- /dev/null +++ b/sca-java-1.x/tags/0.99-incubating/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("sca/wiring-ds-test1.composite"); + } + + +} diff --git a/sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/wiring/DSWiring2TestCase.java b/sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/wiring/DSWiring2TestCase.java new file mode 100644 index 0000000000..46d41710c6 --- /dev/null +++ b/sca-java-1.x/tags/0.99-incubating/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("sca/wiring-ds-test2.composite"); + } + + +} diff --git a/sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/wiring/Wiring1TestCase.java b/sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/wiring/Wiring1TestCase.java new file mode 100644 index 0000000000..00c6d69678 --- /dev/null +++ b/sca-java-1.x/tags/0.99-incubating/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("sca/wiring-test1.composite"); + } + +} diff --git a/sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/wiring/Wiring2TestCase.java b/sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/supplychain/wiring/Wiring2TestCase.java new file mode 100644 index 0000000000..b7f0ad79d8 --- /dev/null +++ b/sca-java-1.x/tags/0.99-incubating/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("sca/wiring-test2.composite"); + } + +} diff --git a/sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/util/OSGiTestUtil.java b/sca-java-1.x/tags/0.99-incubating/itest/osgi-implementation/src/test/java/util/OSGiTestUtil.java new file mode 100644 index 0000000000..ad13e72866 --- /dev/null +++ b/sca-java-1.x/tags/0.99-incubating/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.implementation.osgi.runtime.OSGiRuntime; + + +/** + * OSGi Test Utils + */ +public class OSGiTestUtil { + + public static void setUpOSGiTestRutime() throws Exception { + + setUpFelixTestRutime(); + } + + + private static void setUpFelixTestRutime() 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.getRuntime().shutdown(); + + } catch (Exception e) { + // Ignore + } + } + +} -- cgit v1.2.3