Package org.omg.PortableServer

Examples of org.omg.PortableServer.POA


  }

  void uTestReferenceToId(ORB orb, POA root)
  {
    org.omg.CORBA.Object obj;
    POA poa;
    byte[] id1;
    byte[] id2;
    byte[] tmpid;
    Policy[] policies;

    POAManager manager = root.the_POAManager();

    //
    // Create POA
    //
    policies = new Policy[ 3 ];
    policies [ 0 ] =
      root.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.RETAIN);
    policies [ 1 ] =
      root.create_lifespan_policy(org.omg.PortableServer.LifespanPolicyValue.TRANSIENT);
    policies [ 2 ] =
      root.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.USER_ID);
    try
      {
        poa = root.create_POA("poa", manager, policies);
      }
    catch (AdapterAlreadyExists ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (InvalidPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }

    id1 = ("test1").getBytes();
    id2 = ("test2").getBytes();

    //
    // Test: reference_to_id
    //
    obj = poa.create_reference_with_id(id1, "IDL:Test:1.0");
    try
      {
        tmpid = poa.reference_to_id(obj);
      }
    catch (WrongAdapter ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    TEST(TestUtil.Compare(tmpid, id1));
    obj = poa.create_reference_with_id(id2, "IDL:Test:1.0");
    try
      {
        tmpid = poa.reference_to_id(obj);
      }
    catch (WrongAdapter ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    TEST(TestUtil.Compare(tmpid, id2));

    //
    // Test: WrongAdapter exception
    //
    try
      {
        obj = poa.create_reference_with_id(id1, "IDL:Test:1.0");
        root.reference_to_id(obj);
        TEST(false); // reference_to_id should not have succeeded
      }
    catch (WrongAdapter ex)
      {
        // expected
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }

    poa.destroy(true, true);
  }
View Full Code Here


        String s = r.exchangeNodeObject(NodeObject.create1()).toString();
        harness.check(s, NodeObject.create2().toString(), "Graph");

        // Instantiate another RMI_test here.
        POA rootPOA = POAHelper.narrow(client_orb.resolve_initial_references("RootPOA"));

        rootPOA.the_POAManager().activate();

        RMI_testImpl impl = new RMI_testImpl();
        impl.ego = "Local client object";

        NodeObject n = new NodeObject("x");

        Tie tie = Util.getTie(impl);

        org.omg.CORBA.Object l_object = rootPOA.servant_to_reference((Servant) tie);

        RMI_test l_r = (RMI_test) PortableRemoteObject.narrow(l_object,
          RMI_test.class);

        n.z_anotherTest = l_r;
View Full Code Here

        }.start();

        // Wait for 500 ms for the sever to start.
        Thread.sleep(500);

        POA rootPOA = POAHelper.narrow(server_orb.resolve_initial_references("RootPOA"));

        rootPOA.the_POAManager().activate();

        RMI_testImpl impl = new RMI_testImpl();
        impl.ego = "Server side object";
        Tie tie = Util.getTie(impl);

        org.omg.CORBA.Object object = rootPOA.servant_to_reference((Servant) tie);

        String ior = server_orb.object_to_string(object);

        return ior;
      }
View Full Code Here

    //
    // Create ORB
    //
    orb = ORB.init(new String[ 0 ], props);

    POA root = TestUtil.GetRootPOA(orb);

    //
    // Run the tests using the root POA
    //
    runtests(orb, root);

    //
    // Create a child POA and run the tests again using the
    // child as the root
    //
    Policy[] policies = new Policy[ 0 ];
    POAManager manager = root.the_POAManager();
    POA child = null;
    try
      {
        child = root.create_POA("child", manager, policies);
      }
    catch (AdapterAlreadyExists ex)
View Full Code Here

            }
            TEST(servant == this);
    */
    if (defaultServant_)
      {
        POA poa = null;
        try
          {
            poa = current.get_POA();
          }
        catch (org.omg.PortableServer.CurrentPackage.NoContext ex)
          {
            throw new RuntimeException();
          }

        byte[] servantId = null;
        try
          {
            servantId = poa.servant_to_id(this);
          }
        catch (ServantNotActive ex)
          {
            throw new RuntimeException();
          }
View Full Code Here

    if (obj == null)
      {
        System.err.println("Error: `RootPOA' is a nil object reference");
      }

    POA root = null;
    try
      {
        root = POAHelper.narrow(obj);
      }
    catch (BAD_PARAM ex)
View Full Code Here

  }

  private void run(ORB orb, POA root)
  {
    org.omg.CORBA.Object obj;
    POA system;
    POA nonretain;
    POA multiple;
    POA ether;
    byte[] id1;
    byte[] id2;
    byte[] id3;
    Policy[] policies;
    Test_impl servant1;
    Test_impl servant2;
    Servant tmpserv;

    POAManager manager = root.the_POAManager();

    try
      {
        manager.activate();
      }
    catch (org.omg.PortableServer.POAManagerPackage.AdapterInactive ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }

    //
    // Create POAs
    //
    policies = new Policy[ 3 ];
    policies [ 0 ] =
      root.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.SYSTEM_ID);
    policies [ 1 ] =
      root.create_id_uniqueness_policy(org.omg.PortableServer.IdUniquenessPolicyValue.UNIQUE_ID);
    policies [ 2 ] =
      root.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.RETAIN);
    try
      {
        system = root.create_POA("system_id", manager, policies);
      }
    catch (AdapterAlreadyExists ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (InvalidPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }

    policies = new Policy[ 5 ];
    policies [ 0 ] =
      root.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.USER_ID);
    policies [ 1 ] =
      root.create_id_uniqueness_policy(org.omg.PortableServer.IdUniquenessPolicyValue.MULTIPLE_ID);
    policies [ 2 ] =
      root.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.NON_RETAIN);
    policies [ 3 ] =
      root.create_request_processing_policy(org.omg.PortableServer.RequestProcessingPolicyValue.USE_DEFAULT_SERVANT);
    policies [ 4 ] =
      root.create_implicit_activation_policy(org.omg.PortableServer.ImplicitActivationPolicyValue.NO_IMPLICIT_ACTIVATION);
    try
      {
        nonretain = root.create_POA("nonretain", manager, policies);
      }
    catch (AdapterAlreadyExists ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (InvalidPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }

    policies = new Policy[ 3 ];
    policies [ 0 ] =
      root.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.SYSTEM_ID);
    policies [ 1 ] =
      root.create_id_uniqueness_policy(org.omg.PortableServer.IdUniquenessPolicyValue.MULTIPLE_ID);
    policies [ 2 ] =
      root.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.RETAIN);
    try
      {
        multiple = root.create_POA("multiple_id", manager, policies);
      }
    catch (AdapterAlreadyExists ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (InvalidPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }

    policies = new Policy[ 3 ];
    policies [ 0 ] =
      root.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.SYSTEM_ID);
    policies [ 1 ] =
      root.create_id_uniqueness_policy(org.omg.PortableServer.IdUniquenessPolicyValue.MULTIPLE_ID);
    policies [ 2 ] =
      root.create_request_processing_policy(org.omg.PortableServer.RequestProcessingPolicyValue.USE_SERVANT_MANAGER);
    try
      {
        ether = root.create_POA("ether", manager, policies);
      }
    catch (AdapterAlreadyExists ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (InvalidPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }

    TestActivator_impl activatorImpl = new TestActivator_impl();
    ServantActivator activator = activatorImpl._this(orb);

    //
    // Start tests
    //
    try
      {
        ether.set_servant_manager(activator);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }

    servant1 = new Test_impl(orb, "obj1", false);
    servant2 = new Test_impl(orb, "obj2", false);

    //
    // Test: activate_object w/ SYSTEM_ID POA
    //
    try
      {
        id1 = system.activate_object(servant1);
        id2 = system.activate_object(servant2);
      }
    catch (ServantAlreadyActive ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    TEST(!TestUtil.Compare(id1, id2));
    try
      {
        tmpserv = system.id_to_servant(id1);
      }
    catch (ObjectNotActive ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }

    TEST(tmpserv == servant1);
    try
      {
        tmpserv = system.id_to_servant(id2);
      }
    catch (ObjectNotActive ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    TEST(tmpserv == servant2);

    //
    // Test: ServantAlreadyActive exception
    //
    try
      {
        system.activate_object(servant1);
        TEST(false); // activate_object should not have succeeded
      }
    catch (ServantAlreadyActive ex)
      {
        // expected
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }

    try
      {
        system.activate_object(servant2);
        TEST(false); // activate_object should not have succeeded
      }
    catch (ServantAlreadyActive ex)
      {
        // expected
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }

    //
    // Test: deactivate_object
    //
    try
      {
        system.deactivate_object(id2);
        system.deactivate_object(id1);
      }
    catch (ObjectNotActive ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }

    //
    // Test: ObjectNotActive exception
    //
    try
      {
        system.deactivate_object(id1);
        TEST(false); // deactivate_object should not have succeeded
      }
    catch (ObjectNotActive ex)
      {
        // expected
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }

    try
      {
        system.deactivate_object(id2);
        TEST(false); // deactivate_object should not have succeeded
      }
    catch (ObjectNotActive ex)
      {
        // expected
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }

    //
    // Test: WrongPolicy exception
    //
    try
      {
        nonretain.activate_object(servant1);
        TEST(false); // activate_object should not have succeeded
      }
    catch (WrongPolicy ex)
      {
        // expected
      }
    catch (ServantAlreadyActive ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }

    try
      {
        byte[] id = ("XXX").getBytes();
        nonretain.activate_object_with_id(id, servant1);
        TEST(false); // activate_object_with_id should not have succeeded
      }
    catch (WrongPolicy ex)
      {
        // expected
      }
    catch (ServantAlreadyActive ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (ObjectAlreadyActive ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }

    try
      {
        byte[] id = ("XXX").getBytes();
        nonretain.deactivate_object(id);
        TEST(false); // deactivate_object should not have succeeded
      }
    catch (ObjectNotActive ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (WrongPolicy ex)
      {
        // expected
      }

    //
    // Test: activate_object w/ MULTIPLE_ID POA
    //
    try
      {
        id1 = multiple.activate_object(servant1);
        id2 = multiple.activate_object(servant1);
      }
    catch (ServantAlreadyActive ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    TEST(!TestUtil.Compare(id1, id2));
    try
      {
        tmpserv = multiple.id_to_servant(id1);
      }
    catch (ObjectNotActive ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    TEST(tmpserv == servant1);
    try
      {
        tmpserv = multiple.id_to_servant(id2);
      }
    catch (ObjectNotActive ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    TEST(tmpserv == servant1);

    //
    // Test: confirm servant1 is no longer active
    //
    try
      {
        multiple.deactivate_object(id1);
        multiple.deactivate_object(id2);
      }
    catch (ObjectNotActive ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }

    try
      {
        multiple.id_to_servant(id1);
      }
    catch (ObjectNotActive ex)
      {
        // expected
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }

    try
      {
        multiple.id_to_servant(id2);
      }
    catch (ObjectNotActive ex)
      {
        // expected
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }

    //
    // Test: confirm ServantActivator::etherealize is invoked on
    // deactivate
    //
    try
      {
        id1 = ether.activate_object(servant1);
        id2 = ether.activate_object(servant1);
        id3 = ether.activate_object(servant2);
      }
    catch (ServantAlreadyActive ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    activatorImpl.expect(id1, ether, servant1, true);
    try
      {
        ether.deactivate_object(id1);
      }
    catch (ObjectNotActive ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    TEST(activatorImpl.isValid(), regression_note);
    activatorImpl.expect(id2, ether, servant1, false);
    try
      {
        ether.deactivate_object(id2);
      }
    catch (ObjectNotActive ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    TEST(activatorImpl.isValid(), regression_note);
    activatorImpl.expect(id3, ether, servant2, false);
    try
      {
        ether.deactivate_object(id3);
      }
    catch (ObjectNotActive ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    TEST(activatorImpl.isValid(), "Regression in 1.5");

    system.destroy(true, true);
    nonretain.destroy(true, true);
    multiple.destroy(true, true);
    ether.destroy(true, true);

    //
    // Since activatorImpl is a stack-based servant, we need to deactivate
    // it before it goes out of scope
    //
View Full Code Here

    ORB orb = null;

    orb = ORB.init(new String[ 0 ], props);

    POA root = TestUtil.GetRootPOA(orb);

    run(orb, root);

    if (orb != null)
      {
View Full Code Here

  implements Testlet
{
  void uTestCreateReference(ORB orb, POA root)
  {
    org.omg.CORBA.Object obj;
    POA user;
    POA system;
    byte[] id1;
    byte[] id2;
    byte[] tmpid;
    Policy[] policies;

    POAManager manager = root.the_POAManager();

    policies = new Policy[ 1 ];
    policies [ 0 ] =
      root.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.USER_ID);
    try
      {
        user = root.create_POA("user_id", manager, policies);
      }
    catch (AdapterAlreadyExists ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (InvalidPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }

    policies = new Policy[ 1 ];
    policies [ 0 ] =
      root.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.SYSTEM_ID);
    try
      {
        system = root.create_POA("system_id", manager, policies);
      }
    catch (AdapterAlreadyExists ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (InvalidPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }

    //
    // Test: create_reference with wrong POA policies
    //
    try
      {
        obj = user.create_reference("IDL:Test:1.0");
        TEST(false); // create_reference should not have succeeded
      }
    catch (WrongPolicy ex)
      {
        // expected
      }

    //
    // Test: create_reference - should get a new ID for each invocation
    //       on POA w/ SYSTEM_ID policy
    //
    try
      {
        obj = system.create_reference("IDL:Test:1.0");
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    TEST(obj != null);
    try
      {
        id1 = system.reference_to_id(obj);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (WrongAdapter ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    try
      {
        obj = system.create_reference("IDL:Test:1.0");
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    TEST(obj != null);
    try
      {
        id2 = system.reference_to_id(obj);
      }
    catch (WrongAdapter ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    TEST(!TestUtil.Compare(id1, id2));

    //
    // Test: create_reference_with_id using a system-generated ID
    //
    try
      {
        obj = system.create_reference_with_id(id1, "IDL:Test:1.0");
      }
    catch (BAD_PARAM ex)
      {
        TEST(false); // create_reference_with_id should have succeeded
      }

    id1 = ("id1").getBytes();

    //
    // Test: create_reference_with_id
    //
    obj = user.create_reference_with_id(id1, "IDL:Test:1.0");
    TEST(obj != null);
    try
      {
        tmpid = user.reference_to_id(obj);
      }
    catch (WrongAdapter ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    TEST(TestUtil.Compare(id1, tmpid));
    id2 = ("id2").getBytes();
    obj = user.create_reference_with_id(id2, "IDL:Test:1.0");
    TEST(obj != null);
    try
      {
        tmpid = user.reference_to_id(obj);
      }
    catch (WrongAdapter ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    TEST(TestUtil.Compare(id2, tmpid));

    user.destroy(true, true);
    system.destroy(true, true);
  }
View Full Code Here

  }

  void uTestServantToId(ORB orb, POA root)
  {
    org.omg.CORBA.Object obj;
    POA unique;
    POA implicit;
    POA multiple;
    byte[] id1;
    byte[] id2;
    byte[] tmpid;
    Policy[] policies;
    Test_impl servant1;
    Test_impl servant2;

    POAManager manager = root.the_POAManager();

    //
    // Create POA w/ UNIQUE_ID, NO_IMPLICIT_ACTIVATION
    //
    policies = new Policy[ 4 ];
    policies [ 0 ] =
      root.create_id_uniqueness_policy(org.omg.PortableServer.IdUniquenessPolicyValue.UNIQUE_ID);
    policies [ 1 ] =
      root.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.USER_ID);
    policies [ 2 ] =
      root.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.RETAIN);
    policies [ 3 ] =
      root.create_implicit_activation_policy(org.omg.PortableServer.ImplicitActivationPolicyValue.NO_IMPLICIT_ACTIVATION);
    try
      {
        unique = root.create_POA("unique_id", manager, policies);
      }
    catch (AdapterAlreadyExists ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (InvalidPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }

    //
    // Create POA w/ UNIQUE_ID, IMPLICIT_ACTIVATION
    //
    policies = new Policy[ 3 ];
    policies [ 0 ] =
      root.create_id_uniqueness_policy(org.omg.PortableServer.IdUniquenessPolicyValue.UNIQUE_ID);
    policies [ 1 ] =
      root.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.RETAIN);
    policies [ 2 ] =
      root.create_implicit_activation_policy(org.omg.PortableServer.ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION);
    try
      {
        implicit = root.create_POA("implicit", manager, policies);
      }
    catch (AdapterAlreadyExists ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (InvalidPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }

    //
    // Create POA w/ MULTIPLE_ID, IMPLICIT_ACTIVATION
    //
    policies = new Policy[ 3 ];
    policies [ 0 ] =
      root.create_id_uniqueness_policy(org.omg.PortableServer.IdUniquenessPolicyValue.MULTIPLE_ID);
    policies [ 1 ] =
      root.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.RETAIN);
    policies [ 2 ] =
      root.create_implicit_activation_policy(org.omg.PortableServer.ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION);
    try
      {
        multiple = root.create_POA("multiple", manager, policies);
      }
    catch (AdapterAlreadyExists ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (InvalidPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }

    servant1 = new Test_impl(orb, "test1", false);
    servant2 = new Test_impl(orb, "test2", false);

    //
    // Test: ServantNotActive exception
    //
    try
      {
        unique.servant_to_id(servant1);
        TEST(false); // servant_to_id should not have succeeded
      }
    catch (ServantNotActive ex)
      {
        // expected
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }

    id1 = ("test1").getBytes();
    try
      {
        unique.activate_object_with_id(id1, servant1);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (ServantAlreadyActive ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (ObjectAlreadyActive ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }

    //
    // Test: servant_to_id (UNIQUE_ID policy)
    //
    try
      {
        tmpid = unique.servant_to_id(servant1);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (ServantNotActive ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    TEST(TestUtil.Compare(id1, tmpid));

    //
    // Test: servant_to_id (IMPLICIT_ACTIVATION) - servant1 should
    //       be automatically activated
    //
    try
      {
        id1 = implicit.servant_to_id(servant1);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (ServantNotActive ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }

    //
    // Test: Now that servant1 is activated, and since we have UNIQUE_ID,
    //       we should get the same ID back
    //
    try
      {
        tmpid = implicit.servant_to_id(servant1);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (ServantNotActive ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    TEST(TestUtil.Compare(id1, tmpid));

    //
    // Test: Implicitly activating servant2 should produce a new ID
    //
    try
      {
        id2 = implicit.servant_to_id(servant2);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (ServantNotActive ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    TEST(!TestUtil.Compare(id1, id2));

    //
    // Test: servant_to_id (IMPLICIT_ACTIVATION, MULTIPLE_ID) - servant1
    //       should be automatically activated
    //
    try
      {
        id1 = multiple.servant_to_id(servant1);
      }
    catch (WrongPolicy ex)
      {
        ex.printStackTrace();
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (ServantNotActive ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }

    //
    // Test: Since we have MULTIPLE_ID, we should get a new ID
    //
    try
      {
        tmpid = multiple.servant_to_id(servant1);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (ServantNotActive ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    TEST(!TestUtil.Compare(id1, tmpid));

    unique.destroy(true, true);
    implicit.destroy(true, true);
    multiple.destroy(true, true);
  }
View Full Code Here

TOP

Related Classes of org.omg.PortableServer.POA

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.