/** Throw a <code>NotExpectedTypeException</code> if <code>c</code> isn't a subclass of <code>ReasonerFactory</code>. */ private static void mustBeReasonerFactory( Resource root, Class<?> c ) { if (!ReasonerFactory.class.isAssignableFrom( c )) throw new NotExpectedTypeException( root, ReasonerFactory.class, c ); }
public void testReasonerClassThrowsIfClassNotFactory() { String description = "x rdf:type ja:ReasonerFactory; x ja:reasonerClass java:java.util.ArrayList"; Resource root = resourceInModel( description ); try { ASSEMBLER.open( root ); fail( "should trap non-ReasonerFactory ArrayList" ); } catch (NotExpectedTypeException e) { assertEquals( root, e.getRoot() ); assertEquals( ReasonerFactory.class, e.getExpectedType() ); assertEquals( ArrayList.class, e.getActualType() ); } }
public void testReasonerClassThrowsIfClassNotFactory() { String description = "x rdf:type ja:ReasonerFactory; x ja:reasonerClass java:java.util.ArrayList"; Resource root = resourceInModel( description ); try { ASSEMBLER.open( root ); fail( "should trap non-ReasonerFactory ArrayList" ); } catch (NotExpectedTypeException e) { assertEquals( root, e.getRoot() ); assertEquals( ReasonerFactory.class, e.getExpectedType() ); assertEquals( ArrayList.class, e.getActualType() ); } }
/** Throw a <code>NotExpectedTypeException</code> if <code>c</code> isn't a subclass of <code>ReasonerFactory</code>. */ private static void mustBeReasonerFactory( Resource root, Class<?> c ) { if (!ReasonerFactory.class.isAssignableFrom( c )) throw new NotExpectedTypeException( root, ReasonerFactory.class, c ); }
public static String getIpAddress(Object proxy) throws IllegalArgumentException, RemoteException, NotExpectedTypeException { InvocationHandler h = Proxy.getInvocationHandler(proxy); if (h instanceof RemoteObjectInvocationHandler) { RemoteRef remoteRef = ((RemoteObjectInvocationHandler) h).getRef(); if (remoteRef instanceof UnicastRef) { Endpoint ep = ((UnicastRef) remoteRef).getLiveRef().getChannel().getEndpoint(); if (ep instanceof TCPEndpoint) { return ((TCPEndpoint) ep).getHost(); } throw new NotExpectedTypeException(ep.getClass().getSimpleName(), "TCPEndpoint"); } throw new NotExpectedTypeException(remoteRef.getClass().getSimpleName(), "UnicastRef"); } throw new NotExpectedTypeException(h.getClass().getSimpleName(), "RemoteObjectInvocationHandler"); }