From 33cf44b2ca09724ab08769b887750f8b3807fc9e Mon Sep 17 00:00:00 2001 From: wjaniszewski Date: Tue, 12 Aug 2008 15:17:26 +0000 Subject: Added Transient Name Server JSE Corba host. Adjusted existing bindings and integration tests and removed 'provideNameServer' flag from binding.corba configuration git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@685180 13f79535-47bb-0310-9956-ffa450edef68 --- java/sca/itest/corba/pom.xml | 9 +++- .../sca/test/corba/ScenarioFiveTestCase.java | 7 ++- .../sca/test/corba/ScenarioFourTestCase.java | 15 +++++- .../sca/test/corba/ScenarioOneTestCase.java | 2 + .../sca/test/corba/ScenarioThreeTestCase.java | 2 + .../sca/test/corba/ScenarioTwoTestCase.java | 2 + .../tuscany/sca/test/corba/TestCorbaHost.java | 55 ++++++++++++++++++++++ .../test/corba/TestCorbaHostModuleActivator.java | 40 ++++++++++++++++ .../org.apache.tuscany.sca.core.ModuleActivator | 18 +++++++ 9 files changed, 143 insertions(+), 7 deletions(-) create mode 100644 java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/TestCorbaHost.java create mode 100644 java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/TestCorbaHostModuleActivator.java create mode 100644 java/sca/itest/corba/src/test/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator (limited to 'java/sca/itest/corba') diff --git a/java/sca/itest/corba/pom.xml b/java/sca/itest/corba/pom.xml index 3a8d45907f..82e89fe444 100644 --- a/java/sca/itest/corba/pom.xml +++ b/java/sca/itest/corba/pom.xml @@ -53,9 +53,16 @@ org.apache.tuscany.sca tuscany-host-corba-jse 1.4-SNAPSHOT - runtime + test + + org.apache.tuscany.sca + tuscany-host-corba-jse-tns + 1.4-SNAPSHOT + test + + org.apache.tuscany.sca tuscany-binding-sca diff --git a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioFiveTestCase.java b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioFiveTestCase.java index 2704186386..95f1c28b3e 100644 --- a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioFiveTestCase.java +++ b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioFiveTestCase.java @@ -21,21 +21,20 @@ package org.apache.tuscany.sca.test.corba; import static org.junit.Assert.fail; +import org.apache.tuscany.sca.host.corba.jse.tns.TnsDefaultCorbaHost; import org.apache.tuscany.sca.host.embedded.SCADomain; import org.apache.tuscany.sca.test.corba.types.ScenarioFive; import org.apache.tuscany.sca.test.corba.types.ScenarioFiveComponent; import org.junit.Test; /** - * Tests usage of "provideNameServer" attribute in + * Tests usage of TNS JSE Corba host */ public class ScenarioFiveTestCase { - /** - * Tests binding with provided name server - */ @Test public void test_providedNameServer() { + TestCorbaHost.setCorbaHost(new TnsDefaultCorbaHost()); try { // just make sure we can obtain and use the reference with success SCADomain domain = SCADomain.newInstance("ScenarioFive.composite"); diff --git a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioFourTestCase.java b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioFourTestCase.java index 63bb05ca4c..90a97eb3cd 100644 --- a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioFourTestCase.java +++ b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioFourTestCase.java @@ -23,6 +23,9 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import junit.framework.Assert; +import org.apache.tuscany.sca.host.corba.jse.DefaultCorbaHost; +import org.apache.tuscany.sca.host.corba.naming.TransientNameServer; +import org.apache.tuscany.sca.host.corba.naming.TransientNameService; import org.apache.tuscany.sca.host.embedded.SCADomain; import org.apache.tuscany.sca.test.corba.scenariofour.ScenarioFourFactory; import org.apache.tuscany.sca.test.corba.scenariofour.ScenarioFourSdo; @@ -43,13 +46,21 @@ public class ScenarioFourTestCase { private static SCADomain domain; private static ScenarioFourComponent scenarioFourComponent; private static ScenarioFour scenarioFour; - + private static TransientNameServer server; + private static final int ORB_INITIAL_PORT = 5080; + /** * Initial configuration */ @BeforeClass public static void setUp() { + TestCorbaHost.setCorbaHost(new DefaultCorbaHost()); try { + server = new TransientNameServer("localhost", ORB_INITIAL_PORT, TransientNameService.DEFAULT_SERVICE_NAME); + Thread t = server.start(); + if (t == null) { + Assert.fail("The naming server cannot be started"); + } // obtain domain domain = SCADomain.newInstance("ScenarioFour.composite"); scenarioFourComponent = domain.getService(ScenarioFourComponent.class, "ScenarioFour"); @@ -64,7 +75,7 @@ public class ScenarioFourTestCase { */ @AfterClass public static void tearDown() { - // do nothing + server.stop(); } /** diff --git a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioOneTestCase.java b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioOneTestCase.java index a447c00c5c..4bad2a2ccb 100644 --- a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioOneTestCase.java +++ b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioOneTestCase.java @@ -23,6 +23,7 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import junit.framework.Assert; +import org.apache.tuscany.sca.host.corba.jse.DefaultCorbaHost; import org.apache.tuscany.sca.host.corba.naming.TransientNameServer; import org.apache.tuscany.sca.host.corba.naming.TransientNameService; import org.apache.tuscany.sca.host.embedded.SCADomain; @@ -75,6 +76,7 @@ public class ScenarioOneTestCase { */ @BeforeClass public static void setUp() { + TestCorbaHost.setCorbaHost(new DefaultCorbaHost()); try { try { server = diff --git a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioThreeTestCase.java b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioThreeTestCase.java index eb0ac60ef1..903d9d76c2 100644 --- a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioThreeTestCase.java +++ b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioThreeTestCase.java @@ -23,6 +23,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; import junit.framework.Assert; +import org.apache.tuscany.sca.host.corba.jse.DefaultCorbaHost; import org.apache.tuscany.sca.host.corba.naming.TransientNameServer; import org.apache.tuscany.sca.host.corba.naming.TransientNameService; import org.apache.tuscany.sca.host.embedded.SCADomain; @@ -48,6 +49,7 @@ public class ScenarioThreeTestCase { */ @BeforeClass public static void setUp() { + TestCorbaHost.setCorbaHost(new DefaultCorbaHost()); try { try { server = diff --git a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioTwoTestCase.java b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioTwoTestCase.java index 6d59e50566..369393e496 100644 --- a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioTwoTestCase.java +++ b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioTwoTestCase.java @@ -23,6 +23,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; import junit.framework.Assert; +import org.apache.tuscany.sca.host.corba.jse.DefaultCorbaHost; import org.apache.tuscany.sca.host.corba.naming.TransientNameServer; import org.apache.tuscany.sca.host.corba.naming.TransientNameService; import org.apache.tuscany.sca.host.embedded.SCADomain; @@ -61,6 +62,7 @@ public class ScenarioTwoTestCase { */ @BeforeClass public static void setUp() { + TestCorbaHost.setCorbaHost(new DefaultCorbaHost()); try { try { server = diff --git a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/TestCorbaHost.java b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/TestCorbaHost.java new file mode 100644 index 0000000000..c50b93d03d --- /dev/null +++ b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/TestCorbaHost.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 org.apache.tuscany.sca.test.corba; + +import org.apache.tuscany.sca.host.corba.CorbaHost; +import org.apache.tuscany.sca.host.corba.CorbaHostException; +import org.apache.tuscany.sca.host.corba.jse.DefaultCorbaHost; +import org.omg.CORBA.Object; + +/** + * Mock Corba host which proxies to configured Corba host + */ +public class TestCorbaHost implements CorbaHost { + + private static CorbaHost corbaHost = new DefaultCorbaHost(); + + /** + * Configures environment to use given Corba host + * + * @param corbaHost Corba host to use + */ + public static void setCorbaHost(CorbaHost corbaHost) { + TestCorbaHost.corbaHost = corbaHost; + } + + public Object lookup(String arg0) throws CorbaHostException { + return TestCorbaHost.corbaHost.lookup(arg0); + } + + public void registerServant(String arg0, Object arg1) throws CorbaHostException { + TestCorbaHost.corbaHost.registerServant(arg0, arg1); + } + + public void unregisterServant(String arg0) throws CorbaHostException { + TestCorbaHost.corbaHost.unregisterServant(arg0); + } + +} diff --git a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/TestCorbaHostModuleActivator.java b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/TestCorbaHostModuleActivator.java new file mode 100644 index 0000000000..3856d1b617 --- /dev/null +++ b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/TestCorbaHostModuleActivator.java @@ -0,0 +1,40 @@ +/* + * 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 org.apache.tuscany.sca.test.corba; + +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.ModuleActivator; +import org.apache.tuscany.sca.host.corba.CorbaHostExtensionPoint; + +/** + * Registers TestCorbaHost as a Corba host extension. + */ +public class TestCorbaHostModuleActivator implements ModuleActivator { + + public void start(ExtensionPointRegistry extensionPointRegistry) { + CorbaHostExtensionPoint chep = extensionPointRegistry.getExtensionPoint(CorbaHostExtensionPoint.class); + chep.getCorbaHosts().add(0, new TestCorbaHost()); + } + + public void stop(ExtensionPointRegistry extensionPointRegistry) { + + } + +} diff --git a/java/sca/itest/corba/src/test/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator b/java/sca/itest/corba/src/test/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator new file mode 100644 index 0000000000..3e77527d73 --- /dev/null +++ b/java/sca/itest/corba/src/test/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator @@ -0,0 +1,18 @@ +# 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. + +org.apache.tuscany.sca.test.corba.TestCorbaHostModuleActivator -- cgit v1.2.3