Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Merge branch 'unknown_exception_handling' into 'ibm-trunk'
Unknown exception info propagation See merge request !44
- Loading branch information
Showing
14 changed files
with
565 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,86 @@ | ||
package org.apache.yoko; | ||
|
||
import java.rmi.RemoteException; | ||
import java.util.Properties; | ||
|
||
import javax.rmi.PortableRemoteObject; | ||
|
||
import org.junit.AfterClass; | ||
import org.junit.BeforeClass; | ||
import org.junit.Ignore; | ||
import org.junit.Test; | ||
import org.omg.CORBA.ORB; | ||
import org.omg.PortableServer.POA; | ||
import org.omg.PortableServer.POAHelper; | ||
|
||
import test.rmi.exceptionhandling.MyAppException; | ||
import test.rmi.exceptionhandling.MyClientRequestInterceptor; | ||
import test.rmi.exceptionhandling.MyRuntimeException; | ||
import test.rmi.exceptionhandling.MyServerRequestInterceptor; | ||
import test.rmi.exceptionhandling.Thrower; | ||
import test.rmi.exceptionhandling.ThrowerImpl; | ||
import test.rmi.exceptionhandling._ThrowerImpl_Tie; | ||
|
||
@SuppressWarnings("serial") | ||
public class RMIExceptionHandlingTest { | ||
private static ORB serverOrb; | ||
private static ORB clientOrb; | ||
private static String ior; | ||
|
||
private static ORB initOrb(Properties props, String... args) { | ||
return ORB.init(args, props); | ||
} | ||
|
||
@BeforeClass | ||
public static void createServerORB() throws Exception { | ||
serverOrb = initOrb(new Properties() {{ | ||
put("org.omg.PortableInterceptor.ORBInitializerClass." + MyClientRequestInterceptor.class.getName(),""); | ||
put("org.omg.PortableInterceptor.ORBInitializerClass." + MyServerRequestInterceptor.class.getName(),""); | ||
}}); | ||
POA poa = POAHelper.narrow(serverOrb.resolve_initial_references("RootPOA")); | ||
poa.the_POAManager().activate(); | ||
|
||
_ThrowerImpl_Tie tie = new _ThrowerImpl_Tie(); | ||
tie.setTarget(new ThrowerImpl()); | ||
|
||
poa.activate_object(tie); | ||
ior = serverOrb.object_to_string(tie.thisObject()); | ||
System.out.println(ior); | ||
} | ||
|
||
@BeforeClass | ||
public static void createClientORB() { | ||
clientOrb = initOrb(new Properties() {{ | ||
put("org.omg.PortableInterceptor.ORBInitializerClass." + MyClientRequestInterceptor.class.getName(),""); | ||
}}); | ||
} | ||
|
||
@AfterClass | ||
public static void shutdownServerORB() { | ||
serverOrb.shutdown(true); | ||
serverOrb.destroy(); | ||
ior = null; | ||
} | ||
|
||
@AfterClass | ||
public static void shutdownClientORB() { | ||
clientOrb.shutdown(true); | ||
clientOrb.destroy(); | ||
} | ||
|
||
@Test(expected=MyRuntimeException.class) | ||
public void testRuntimeException() throws RemoteException { | ||
getThrower(clientOrb).throwRuntimeException(); | ||
} | ||
|
||
@Test(expected=MyAppException.class) | ||
public void testAppException() throws RemoteException, MyAppException { | ||
getThrower(clientOrb).throwAppException(); | ||
} | ||
|
||
private Thrower getThrower(ORB orb) { | ||
Object o = orb.string_to_object(ior); | ||
Thrower thrower = (Thrower) PortableRemoteObject.narrow(o, Thrower.class); | ||
return thrower; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,3 @@ | ||
package test.rmi.exceptionhandling; | ||
|
||
public class MyAppException extends Exception {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,64 @@ | ||
package test.rmi.exceptionhandling; | ||
|
||
import org.omg.CORBA.LocalObject; | ||
import org.omg.PortableInterceptor.ClientRequestInfo; | ||
import org.omg.PortableInterceptor.ClientRequestInterceptor; | ||
import org.omg.PortableInterceptor.ForwardRequest; | ||
import org.omg.PortableInterceptor.ORBInitInfo; | ||
import org.omg.PortableInterceptor.ORBInitializer; | ||
import org.omg.PortableInterceptor.ORBInitInfoPackage.DuplicateName; | ||
|
||
public class MyClientRequestInterceptor extends LocalObject implements ClientRequestInterceptor, ORBInitializer { | ||
|
||
@Override | ||
public void receive_exception(ClientRequestInfo arg0) throws ForwardRequest { | ||
System.out.printf("%08x: ", Thread.currentThread().getId()); | ||
System.out.println("receive_exception(" + arg0.operation() + ")"); | ||
} | ||
|
||
@Override | ||
public void receive_other(ClientRequestInfo arg0) throws ForwardRequest { | ||
System.out.printf("%08x: ", Thread.currentThread().getId()); | ||
System.out.println("receive_other(" + arg0.operation() + ")"); | ||
} | ||
|
||
@Override | ||
public void receive_reply(ClientRequestInfo arg0) { | ||
System.out.printf("%08x: ", Thread.currentThread().getId()); | ||
System.out.println("receive_reply(" + arg0.operation() + ")"); | ||
} | ||
|
||
@Override | ||
public void send_poll(ClientRequestInfo arg0) { | ||
System.out.printf("%08x: ", Thread.currentThread().getId()); | ||
System.out.println("send_poll(" + arg0.operation() + ")"); | ||
} | ||
|
||
@Override | ||
public void send_request(ClientRequestInfo arg0) throws ForwardRequest { | ||
System.out.printf("%08x: ", Thread.currentThread().getId()); | ||
System.out.println("send_request(" + arg0.operation() + ")"); | ||
} | ||
|
||
@Override | ||
public void destroy() { | ||
} | ||
|
||
@Override | ||
public String name() { | ||
return this.getClass().getName(); | ||
} | ||
|
||
@Override | ||
public void post_init(ORBInitInfo arg0) { | ||
try { | ||
arg0.add_client_request_interceptor(this); | ||
} catch (DuplicateName e) { | ||
throw new Error(e); | ||
} | ||
} | ||
|
||
@Override | ||
public void pre_init(ORBInitInfo arg0) { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,3 @@ | ||
package test.rmi.exceptionhandling; | ||
|
||
public class MyRuntimeException extends RuntimeException {} |
Oops, something went wrong.