Skip to content
Permalink
Browse files
test Resolver class
  • Loading branch information
joe-chacko committed Feb 19, 2015
1 parent 7bdc1c1 commit fae005bc71b24a70b6cacc40eb8da3895c06b5ed
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 14 deletions.
@@ -122,12 +122,12 @@ void run() throws Exception {
testReadOnly();
testBoundReferences();
testIterators();
testObjectFactory();
testObjectFactories();
break;
case INTEGRAL:
testBoundReferences();
testIterators();
testObjectFactory();
testObjectFactories();
break;
case STANDALONE:
testBoundReferences();
@@ -218,6 +218,11 @@ private void testReadOnly() throws Exception {
}
}

public void testObjectFactories() throws CannotProceed, InvalidName {
Util.assertFactoryIsBound(rootNamingContext, Server.RESOLVABLE_TEST);
Util.assertFactoryIsBound(rootNamingContext, Server.RESOLVER_TEST);
}

@Override
public void close() throws Exception {
try {
@@ -231,8 +236,4 @@ public void close() throws Exception {
}
}
}

public void testObjectFactory() throws CannotProceed, InvalidName {
Util.assertFactoryIsBound(rootNamingContext, Server.FACTORY_TEST1);
}
}
@@ -13,7 +13,7 @@ public static void main(String args[]) throws Exception {
props.put("org.omg.CORBA.ORBSingletonClass", "org.apache.yoko.orb.CORBA.ORBSingleton");

try (Client client = new Client(READ_ONLY, refFile, props, "-ORBInitRef", "NameService=" + Util.NS_LOC )) {
client.testObjectFactory();
client.testObjectFactories();
client.run();
}
}
@@ -30,7 +30,8 @@
import java.util.Properties;

import org.apache.yoko.orb.spi.naming.Resolvable;
import org.omg.CORBA.ORB;
import org.apache.yoko.orb.spi.naming.Resolver;
import org.omg.CORBA.*;
import org.omg.CosNaming.NameComponent;
import org.omg.CosNaming.NamingContext;
import org.omg.CosNaming.NamingContextExt;
@@ -50,14 +51,16 @@ final class Server extends test.common.TestBase implements AutoCloseable {
private static final NameComponent TEST2 = new NameComponent("Test2", "");
private static final NameComponent TEST3 = new NameComponent("Test3", "");

public static final NameComponent FACTORY_TEST1 = new NameComponent("FactoryTest1", "");
public static final NameComponent RESOLVABLE_TEST = new NameComponent("ResolvableTest", "");
public static final NameComponent RESOLVER_TEST = new NameComponent("ResolverTest", "");

final String refFile;
final ORB orb;
final POA rootPoa;
final NamingContextExt rootNamingContext;
final Test test1, test2, test3;
final Resolvable objectFactory1;
final Resolvable resolvable;
final Resolver resolver;

public Server(String refFile, Properties props, String... args) throws Exception {
this.refFile = refFile;
@@ -78,8 +81,15 @@ public Server(String refFile, Properties props, String... args) throws Exception
test1 = TestHelper.narrow(new Test_impl(rootPoa, "Test1")._this_object(orb));
test2 = TestHelper.narrow(new Test_impl(rootPoa, "Test2")._this_object(orb));
test3 = TestHelper.narrow(new Test_impl(rootPoa, "Test3")._this_object(orb));

objectFactory1 = new TestFactory_impl (rootPoa, orb, FACTORY_TEST1.id);

// two ways to provide a Resolvable - both should be treated identically
resolvable = new TestFactory_impl (rootPoa, orb, RESOLVABLE_TEST.id);
resolver = new Resolver(){
@Override
public org.omg.CORBA.Object resolve() {
return resolvable.resolve();
}
};

System.out.println("created references");
} catch (Throwable t) {
@@ -154,8 +164,10 @@ void run() throws Exception {
}

public void bindObjectFactories() throws NotFound, CannotProceed, InvalidName, AlreadyBound {
rootNamingContext.bind(new NameComponent[]{FACTORY_TEST1}, objectFactory1);
Util.assertFactoryIsBound(rootNamingContext, FACTORY_TEST1);
rootNamingContext.bind(new NameComponent[]{RESOLVABLE_TEST}, resolvable);
Util.assertFactoryIsBound(rootNamingContext, RESOLVABLE_TEST);
rootNamingContext.bind(new NameComponent[]{RESOLVER_TEST}, resolver);
Util.assertFactoryIsBound(rootNamingContext, RESOLVER_TEST);
}

@Override

0 comments on commit fae005b

Please sign in to comment.