diff --git a/yoko-core/src/test/java-testify/org/apache/yoko/orb/PortableServer/TestServantActivatorServer.java b/yoko-core/src/test/java-testify/org/apache/yoko/orb/PortableServer/TestServantActivatorServer.java new file mode 100644 index 000000000..299ca3e95 --- /dev/null +++ b/yoko-core/src/test/java-testify/org/apache/yoko/orb/PortableServer/TestServantActivatorServer.java @@ -0,0 +1,120 @@ +/* + * Copyright 2023 IBM Corporation and others. + * + * Licensed 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. + * + * SPDX-License-Identifier: Apache-2.0 + */ +package org.apache.yoko.orb.PortableServer; + +import org.junit.jupiter.api.Test; +import org.omg.CORBA.LocalObject; +import org.omg.CORBA.OBJECT_NOT_EXIST; +import org.omg.CORBA.ORB; +import org.omg.PortableServer.ForwardRequest; +import org.omg.PortableServer.POA; +import org.omg.PortableServer.POAManager; +import org.omg.PortableServer.POAPackage.ObjectAlreadyActive; +import org.omg.PortableServer.POAPackage.ServantAlreadyActive; +import org.omg.PortableServer.POAPackage.WrongPolicy; +import org.omg.PortableServer.Servant; +import org.omg.PortableServer.ServantActivator; +import test.poa.TestDSIRef_impl; +import test.poa.TestHelper; +import test.poa.Test_impl; +import testify.bus.Bus; +import testify.iiop.annotation.ConfigureServer; + +import static org.apache.yoko.orb.PortableServer.PolicyValue.PERSISTENT; +import static org.apache.yoko.orb.PortableServer.PolicyValue.USER_ID; +import static org.apache.yoko.orb.PortableServer.PolicyValue.create_POA; +import static org.junit.Assert.assertThrows; + +@ConfigureServer +public class TestServantActivatorServer { + + @ConfigureServer.BeforeServer + public static void setup(ORB orb, POA root, Bus bus) throws Exception { + POAManager rootMgr = root.the_POAManager(); + POA poa = create_POA("persistent", root, rootMgr, PERSISTENT, USER_ID, PolicyValue.USE_SERVANT_MANAGER); + TestActivator_impl activatorImpl = new TestActivator_impl(orb); + poa.set_servant_manager(activatorImpl); + + // Create three references, two good and one bad + bus.put("test1", orb.object_to_string(poa.create_reference_with_id("test1".getBytes(), "IDL:Test:1.0"))); + bus.put("testDSI", orb.object_to_string(poa.create_reference_with_id("testDSI".getBytes(), "IDL:Test:1.0"))); + bus.put("testNotExist", orb.object_to_string(poa.create_reference_with_id("testNotExist".getBytes(), "IDL:Test:1.0"))); + + //TODO: Find a way to test this after the ORB is shutdown +// assertTrue(activatorImpl.etherealize_called()); + } + + @Test + void test1(ORB orb, Bus bus) { TestHelper.narrow(orb.string_to_object(bus.get("test1"))).aMethod(); } + + @Test + void testDSI(ORB orb, Bus bus) { TestHelper.narrow(orb.string_to_object(bus.get("testDSI"))).aMethod(); } + + @Test + void testNotExist(ORB orb, Bus bus) { + assertThrows(OBJECT_NOT_EXIST.class, + () -> TestHelper.narrow(orb.string_to_object(bus.get("testNotExist"))).aMethod()); + } + + final static class TestActivator_impl extends LocalObject implements ServantActivator{ + private final ORB orb; + private boolean etherealizeCalled = false; + + TestActivator_impl(ORB orb) { + this.orb = orb; + } + + public org.omg.PortableServer.Servant incarnate(byte[] oid, POA poa) throws ForwardRequest { + String oidString = new String(oid); + + // If the user is requesting the object "test" then oblige + org.omg.PortableServer.Servant servant = null; + if (oidString.equals("test1")) + servant = new Test_impl(orb, "test1", false); + else if (oidString.equals("testDSI")) + servant = new TestDSIRef_impl(orb, "", false); + + if (servant != null) { + // Verify that POA allows activator to explicitly activate a servant + try { + poa.activate_object_with_id(oid, servant); + } catch (ObjectAlreadyActive | WrongPolicy | ServantAlreadyActive ex) { + throw new RuntimeException(); + } + return servant; + } + // Fail if not test1 or testDSI objects + throw new OBJECT_NOT_EXIST(); + } + + public void etherealize(byte[] oid, POA poa, Servant servant, boolean cleanup, boolean remaining) { + if (remaining) return; + etherealizeCalled = true; + // Etherealize is called when the orb -> shutdown() + // method is called. The ORB shutdown calls + // destroy(true, true) on each POAManagers. The + // cleanup flag should be set to true here. + if (!cleanup) throw new RuntimeException(); + if (new String(oid).equals("test")) servant = null; + } + + public boolean etherealize_called() { + return etherealizeCalled; + } + } +} diff --git a/yoko-core/src/test/java-testify/org/apache/yoko/orb/PortableServer/TestServantLocatorServer.java b/yoko-core/src/test/java-testify/org/apache/yoko/orb/PortableServer/TestServantLocatorServer.java new file mode 100644 index 000000000..b167cfd69 --- /dev/null +++ b/yoko-core/src/test/java-testify/org/apache/yoko/orb/PortableServer/TestServantLocatorServer.java @@ -0,0 +1,123 @@ +/* + * Copyright 2023 IBM Corporation and others. + * + * Licensed 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. + * + * SPDX-License-Identifier: Apache-2.0 + */ +package org.apache.yoko.orb.PortableServer; + +import org.junit.jupiter.api.Test; +import org.omg.CORBA.LocalObject; +import org.omg.CORBA.NO_PERMISSION; +import org.omg.CORBA.OBJECT_NOT_EXIST; +import org.omg.CORBA.ORB; +import org.omg.PortableServer.POA; +import org.omg.PortableServer.POAManager; +import org.omg.PortableServer.Servant; +import org.omg.PortableServer.ServantLocator; +import org.omg.PortableServer.ServantLocatorPackage.CookieHolder; +import test.poa.TestDSIRef_impl; +import test.poa.TestHelper; +import test.poa.Test_impl; +import testify.bus.Bus; +import testify.iiop.annotation.ConfigureServer; + +import static org.apache.yoko.orb.PortableServer.PolicyValue.NON_RETAIN; +import static org.apache.yoko.orb.PortableServer.PolicyValue.NO_IMPLICIT_ACTIVATION; +import static org.apache.yoko.orb.PortableServer.PolicyValue.PERSISTENT; +import static org.apache.yoko.orb.PortableServer.PolicyValue.USER_ID; +import static org.apache.yoko.orb.PortableServer.PolicyValue.USE_SERVANT_MANAGER; +import static org.apache.yoko.orb.PortableServer.PolicyValue.create_POA; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +@ConfigureServer +public class TestServantLocatorServer { + + @ConfigureServer.BeforeServer + public static void setup(ORB orb, POA root, Bus bus) throws Exception { + POAManager rootMgr = root.the_POAManager(); + POA persistentPOA = create_POA("persistent", root, rootMgr, PERSISTENT, USER_ID, USE_SERVANT_MANAGER, NON_RETAIN, NO_IMPLICIT_ACTIVATION); + ServantLocator locator = new TestLocator_impl(orb); + persistentPOA.set_servant_manager(locator); + + bus.put("test1", orb.object_to_string(persistentPOA.create_reference_with_id("test1".getBytes(), "IDL:Test:1.0"))); + bus.put("testDSI", orb.object_to_string(persistentPOA.create_reference_with_id("testDSI".getBytes(), "IDL:Test:1.0"))); + bus.put("testEx", orb.object_to_string(persistentPOA.create_reference_with_id("testEx".getBytes(), "IDL:Test:1.0"))); + bus.put("testBad", orb.object_to_string(persistentPOA.create_reference_with_id("testBad".getBytes(), "IDL:Test:1.0"))); + } + + @Test + void test1(ORB orb, Bus bus) { TestHelper.narrow(orb.string_to_object(bus.get("test1"))).aMethod(); } + + @Test + void testDSI(ORB orb, Bus bus) { TestHelper.narrow(orb.string_to_object(bus.get("testDSI"))).aMethod(); } + + @Test + void testNoPermissionError(ORB orb, Bus bus) { + assertThrows(NO_PERMISSION.class, + () -> TestHelper.narrow(orb.string_to_object(bus.get("testEx"))).aMethod()); + } + + @Test + void testObjectNotExistError(ORB orb, Bus bus) { + assertThrows(OBJECT_NOT_EXIST.class, + () -> TestHelper.narrow(orb.string_to_object(bus.get("testBad"))).aMethod()); + } + + public final static class TestLocator_impl extends LocalObject implements ServantLocator { + Test_impl testImpl; + TestDSIRef_impl testDSI; + + TestLocator_impl(ORB orb) { + testImpl = new Test_impl(orb, "test1", false); + testDSI = new TestDSIRef_impl(orb, "", false); + } + + public org.omg.PortableServer.Servant preinvoke(byte[] oid, POA poa, String operation, CookieHolder the_cookie) { + String oidString = new String(oid); + + // If the user is requesting the object "test", "testDSI" or "testEx", then oblige + if (oidString.equals("test1")) { + the_cookie.value = oidString; + return testImpl; + } + + if (oidString.equals("testDSI")) { + the_cookie.value = oidString; + return testDSI; + } + + // Use testImpl as the servant for testEx. We'll raise an exception in postinvoke(). + if (oidString.equals("testEx")) { + the_cookie.value = oidString; + return testImpl; + } + + // XXX test ForwardRequest - Fail + throw new OBJECT_NOT_EXIST(); + } + + public void postinvoke(byte[] oid, POA poa, String operation, Object the_cookie, Servant the_servant) { + // Check the cookie + String oidString = new String(oid); + assertEquals(oidString, (String) the_cookie); + + if (oidString.equals("testEx") && !operation.equals("_locate")) { + // The client must receive this exception as the result of an invocation on "testEx" + throw new org.omg.CORBA.NO_PERMISSION(); + } + } + } +} diff --git a/yoko-core/src/test/java/org/apache/yoko/PoaTest.java b/yoko-core/src/test/java/org/apache/yoko/PoaTest.java index 784e8575a..476c1d940 100644 --- a/yoko-core/src/test/java/org/apache/yoko/PoaTest.java +++ b/yoko-core/src/test/java/org/apache/yoko/PoaTest.java @@ -29,8 +29,6 @@ import test.poa.TestMultipleOrbsThreadedServer; import test.poa.TestPOAManagerClient; import test.poa.TestPOAManagerServer; -import test.poa.TestServantActivatorServer; -import test.poa.TestServantLocatorServer; public class PoaTest extends AbstractOrbTestBase { @@ -39,14 +37,6 @@ public void setUp() throws Exception { setWaitForFile("Test.ref"); } - public void testServantActivatorServer() throws Exception { - runServerClientTest(TestServantActivatorServer.class, TestClient.class); - } - - public void testServantLocatorServer() throws Exception { - runServerClientTest(TestServantLocatorServer.class, TestClient.class); - } - public void testLocationForwardServer() throws Exception { runServerClientTest(TestLocationForwardServerMain.class, TestLocationForwardClient.class); } diff --git a/yoko-core/src/test/java/test/poa/TestServantActivatorServer.java b/yoko-core/src/test/java/test/poa/TestServantActivatorServer.java deleted file mode 100644 index 8dbfb0723..000000000 --- a/yoko-core/src/test/java/test/poa/TestServantActivatorServer.java +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright 2015 IBM Corporation and others. - * - * Licensed 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. - * - * SPDX-License-Identifier: Apache-2.0 - */ -package test.poa; - -import static org.junit.Assert.assertTrue; - -import org.omg.CORBA.*; -import org.omg.PortableServer.*; -import org.omg.PortableServer.POAPackage.*; -import org.omg.PortableServer.POAManagerPackage.*; - -import java.io.*; -import java.util.Properties; - -public final class TestServantActivatorServer extends test.common.TestBase { - final static class TestActivator_impl extends ServantActivatorPOA { - private ORB orb_; - - private boolean etherealizeCalled_ = false; - - TestActivator_impl(ORB orb) { - orb_ = orb; - } - - public Servant incarnate(byte[] oid, POA poa) throws ForwardRequest { - String oidString = new String(oid); - - // - // If the user is requesting the object "test" then oblige - // - Servant servant = null; - if (oidString.equals("test")) - servant = new Test_impl(orb_, "test", false); - else if (oidString.equals("testDSI")) - servant = new TestDSIRef_impl(orb_, "", false); - if (servant != null) { - // - // Verify that POA allows activator to explicitly activate - // a servant - // - try { - poa.activate_object_with_id(oid, servant); - } catch (ObjectAlreadyActive ex) { - throw new RuntimeException(); - } catch (WrongPolicy ex) { - throw new RuntimeException(); - } catch (ServantAlreadyActive ex) { - throw new RuntimeException(); - } - return servant; - } - - // - // Fail - // - throw new org.omg.CORBA.OBJECT_NOT_EXIST(); - } - - public void etherealize(byte[] oid, POA poa, Servant servant, - boolean cleanup, boolean remaining) { - if (!remaining) { - etherealizeCalled_ = true; - - // - // Etherealize is called when the orb -> shutdown() - // method is called. The ORB shutdown calls - // destroy(true, true) on each POAManagers. The - // cleanup flag should be set to true here. - // - if (!cleanup) - throw new RuntimeException(); - - String oidString = new String(oid); - - // - // If the user is requesting the object "test" then oblige. - // - if (oidString.equals("test")) - servant = null; - else if (oidString.equals("testDSI")) - ; // Do nothing here - } - } - - public boolean etherealize_called() { - return etherealizeCalled_; - } - } - - public static void main(String args[]) { - java.util.Properties props = new Properties(); - props.putAll(System.getProperties()); - props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB"); - props.put("org.omg.CORBA.ORBSingletonClass", - "org.apache.yoko.orb.CORBA.ORBSingleton"); - - ORB orb = null; - - try { - // - // Create ORB - // - orb = ORB.init(args, props); - - POA root = TestUtil.GetRootPOA(orb); - POAManager manager = root.the_POAManager(); - - Policy[] policies = new Policy[3]; - policies[0] = root - .create_lifespan_policy(org.omg.PortableServer.LifespanPolicyValue.PERSISTENT); - policies[1] = root - .create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.USER_ID); - policies[2] = root - .create_request_processing_policy(org.omg.PortableServer.RequestProcessingPolicyValue.USE_SERVANT_MANAGER); - - POA persistentPOA = null; - try { - persistentPOA = root - .create_POA("persistent", manager, policies); - } catch (AdapterAlreadyExists ex) { - throw new RuntimeException(); - } catch (InvalidPolicy ex) { - throw new RuntimeException(); - } - - TestActivator_impl activatorImpl = new TestActivator_impl(orb); - ServantActivator activator = activatorImpl._this(orb); - - try { - persistentPOA.set_servant_manager(activator); - } catch (WrongPolicy ex) { - throw new RuntimeException(); - } - - // - // Create three references, two good and one bad - // - byte[] oid1 = ("test").getBytes(); - byte[] oid2 = ("testDSI").getBytes(); - byte[] oid3 = ("test2").getBytes(); - org.omg.CORBA.Object reference1 = persistentPOA - .create_reference_with_id(oid1, "IDL:Test:1.0"); - org.omg.CORBA.Object reference2 = persistentPOA - .create_reference_with_id(oid2, "IDL:Test:1.0"); - org.omg.CORBA.Object reference3 = persistentPOA - .create_reference_with_id(oid3, "IDL:Test:1.0"); - - // - // Create server - // - TestInfo[] info = new TestInfo[3]; - info[0] = new TestInfo(); - info[1] = new TestInfo(); - info[2] = new TestInfo(); - info[0].obj = TestHelper.narrow(reference1); - info[0].except_id = ""; - info[1].obj = TestHelper.narrow(reference2); - info[1].except_id = ""; - info[2].obj = TestHelper.narrow(reference3); - info[2].except_id = "IDL:omg.org/CORBA/OBJECT_NOT_EXIST:1.0"; - TestServer_impl serverImpl = new TestServer_impl(orb, info); - TestServer server = serverImpl._this(orb); - - // - // Save reference - // - String refFile = "Test.ref"; - try { - FileOutputStream file = new FileOutputStream(refFile); - PrintWriter out = new PrintWriter(file); - out.println(orb.object_to_string(server)); - out.flush(); - file.close(); - } catch (IOException ex) { - System.err.println("Can't write to `" + ex.getMessage() + "'"); - System.exit(1); - } - - // - // Run implementation - // - try { - manager.activate(); - } catch (AdapterInactive ex) { - throw new RuntimeException(); - } - orb.run(); - - assertTrue(activatorImpl.etherealize_called()); - - File file = new File(refFile); - file.delete(); - } catch (SystemException ex) { - ex.printStackTrace(); - System.exit(1); - } - - if (orb != null) { - try { - orb.destroy(); - } catch (SystemException ex) { - ex.printStackTrace(); - System.exit(1); - } - } - - System.exit(0); - } -} diff --git a/yoko-core/src/test/java/test/poa/TestServantLocatorServer.java b/yoko-core/src/test/java/test/poa/TestServantLocatorServer.java deleted file mode 100644 index 572556118..000000000 --- a/yoko-core/src/test/java/test/poa/TestServantLocatorServer.java +++ /dev/null @@ -1,227 +0,0 @@ -/* - * Copyright 2015 IBM Corporation and others. - * - * Licensed 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. - * - * SPDX-License-Identifier: Apache-2.0 - */ -package test.poa; - -import static org.junit.Assert.assertTrue; - -import org.omg.CORBA.*; -import org.omg.PortableServer.*; -import org.omg.PortableServer.POAPackage.*; -import org.omg.PortableServer.POAManagerPackage.*; -import org.omg.PortableServer.ServantLocatorPackage.*; - -import java.io.*; -import java.util.Properties; - -public final class TestServantLocatorServer extends test.common.TestBase { - final static class TestLocator_impl extends ServantLocatorPOA { - private ORB orb_; - - Test_impl test_; - - TestDSIRef_impl testDSI_; - - TestLocator_impl(ORB orb) { - orb_ = orb; - test_ = new Test_impl(orb_, "test", false); - testDSI_ = new TestDSIRef_impl(orb_, "", false); - } - - public Servant preinvoke(byte[] oid, POA poa, String operation, - CookieHolder the_cookie) throws ForwardRequest { - String oidString = new String(oid); - - // - // If the user is requesting the object "test", "testDSI" or - // "testEx", then oblige - // - if (oidString.equals("test")) { - the_cookie.value = oidString; - return test_; - } - - if (oidString.equals("testDSI")) { - the_cookie.value = oidString; - return testDSI_; - } - - // - // Use test_ as the servant for testEx. We'll raise an - // exception in postinvoke(). - // - if (oidString.equals("testEx")) { - the_cookie.value = oidString; - return test_; - } - - // - // XXX test ForwardRequest - // - - // - // Fail - // - throw new OBJECT_NOT_EXIST(); - } - - public void postinvoke(byte[] oid, POA poa, String operation, - java.lang.Object the_cookie, Servant the_servant) { - // - // Check the cookie - // - String oidString = new String(oid); - assertTrue(oidString.equals((String) the_cookie)); - - if (oidString.equals("testEx") && !operation.equals("_locate")) { - // - // The client must receive this exception as the result - // of an invocation on "testEx" - // - throw new org.omg.CORBA.NO_PERMISSION(); - } - } - } - - public static void main(String[] args) { - java.util.Properties props = new Properties(); - props.putAll(System.getProperties()); - props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB"); - props.put("org.omg.CORBA.ORBSingletonClass", - "org.apache.yoko.orb.CORBA.ORBSingleton"); - - ORB orb = null; - - try { - // - // Create ORB - // - orb = ORB.init(args, props); - - POA root = TestUtil.GetRootPOA(orb); - POAManager manager = root.the_POAManager(); - - Policy[] policies = new Policy[5]; - policies[0] = root - .create_lifespan_policy(org.omg.PortableServer.LifespanPolicyValue.PERSISTENT); - policies[1] = root - .create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.USER_ID); - policies[2] = root - .create_request_processing_policy(org.omg.PortableServer.RequestProcessingPolicyValue.USE_SERVANT_MANAGER); - policies[3] = root - .create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.NON_RETAIN); - policies[4] = root - .create_implicit_activation_policy(org.omg.PortableServer.ImplicitActivationPolicyValue.NO_IMPLICIT_ACTIVATION); - - POA persistentPOA = null; - try { - persistentPOA = root - .create_POA("persistent", manager, policies); - } catch (AdapterAlreadyExists ex) { - throw new RuntimeException(); - } catch (InvalidPolicy ex) { - throw new RuntimeException(); - } - - TestLocator_impl locatorImpl = new TestLocator_impl(orb); - ServantLocator locator = locatorImpl._this(orb); - - try { - persistentPOA.set_servant_manager(locator); - } catch (WrongPolicy ex) { - throw new RuntimeException(); - } - - // - // Create four references, three good and one bad - // - byte[] oid1 = ("test").getBytes(); - byte[] oid2 = ("testDSI").getBytes(); - byte[] oid3 = ("testEx").getBytes(); - byte[] oid4 = ("testBad").getBytes(); - org.omg.CORBA.Object reference1 = persistentPOA - .create_reference_with_id(oid1, "IDL:Test:1.0"); - org.omg.CORBA.Object reference2 = persistentPOA - .create_reference_with_id(oid2, "IDL:Test:1.0"); - org.omg.CORBA.Object reference3 = persistentPOA - .create_reference_with_id(oid3, "IDL:Test:1.0"); - org.omg.CORBA.Object reference4 = persistentPOA - .create_reference_with_id(oid4, "IDL:Test:1.0"); - - // - // Create server - // - TestInfo[] info = new TestInfo[4]; - info[0] = new TestInfo(); - info[1] = new TestInfo(); - info[2] = new TestInfo(); - info[3] = new TestInfo(); - info[0].obj = TestHelper.narrow(reference1); - info[0].except_id = ""; - info[1].obj = TestHelper.narrow(reference2); - info[1].except_id = ""; - info[2].obj = TestHelper.narrow(reference3); - info[2].except_id = "IDL:omg.org/CORBA/NO_PERMISSION:1.0"; - info[3].obj = TestHelper.narrow(reference4); - info[3].except_id = "IDL:omg.org/CORBA/OBJECT_NOT_EXIST:1.0"; - TestServer_impl serverImpl = new TestServer_impl(orb, info); - TestServer server = serverImpl._this(orb); - - // - // Save reference - // - String refFile = "Test.ref"; - try { - FileOutputStream file = new FileOutputStream(refFile); - PrintWriter out = new PrintWriter(file); - out.println(orb.object_to_string(server)); - out.flush(); - file.close(); - } catch (IOException ex) { - System.err.println("Can't write to `" + ex.getMessage() + "'"); - System.exit(1); - } - - // - // Run implementation - // - try { - manager.activate(); - } catch (AdapterInactive ex) { - throw new RuntimeException(); - } - orb.run(); - - File file = new File(refFile); - file.delete(); - } catch (SystemException ex) { - ex.printStackTrace(); - System.exit(1); - } - - if (orb != null) { - try { - orb.destroy(); - } catch (SystemException ex) { - ex.printStackTrace(); - System.exit(1); - } - } - - System.exit(0); - } -}