protected static Class<?> loadClass( Resource root, String className ) { try { return Class.forName( className ); } catch (ClassNotFoundException e) { throw new CannotLoadClassException( root, className, e ); } }
public CannotLoadClassException( Resource root, String className, ClassNotFoundException e ) { super( root, makeMessage( root, className ), e ); this.className = className; }
private static String makeMessage( Resource root, String className ) { return "the class '" + className + "' required by the object " + nice( root ) + " could not be loaded" ; }
public void testReasonerClassThrowsIfClassNotFound() { String description = "x rdf:type ja:ReasonerFactory; x ja:reasonerClass java:noSuchClass"; Resource root = resourceInModel( description ); try { ASSEMBLER.open( root ); fail( "should trap missing class noSuchClass" ); } catch (CannotLoadClassException e) { assertEquals( "noSuchClass", e.getClassName() ); } }
public void testReasonerClassThrowsIfClassNotFound() { String description = "x rdf:type ja:ReasonerFactory; x ja:reasonerClass java:noSuchClass"; Resource root = resourceInModel( description ); try { ASSEMBLER.open( root ); fail( "should trap missing class noSuchClass" ); } catch (CannotLoadClassException e) { assertEquals( "noSuchClass", e.getClassName() ); } }
public CannotLoadClassException( Resource root, String className, ClassNotFoundException e ) { super( root, makeMessage( root, className ), e ); this.className = className; }
protected static Class<?> loadClass( Resource root, String className ) { try { return Class.forName( className ); } catch (ClassNotFoundException e) { throw new CannotLoadClassException( root, className, e ); } }
private static String makeMessage( Resource root, String className ) { return "the class '" + className + "' required by the object " + nice( root ) + " could not be loaded" ; }