Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,53 @@ private void executeTestMethodUnderClassLoader(final ClassLoader cl, final Strin
}
}

public void testGetClassTakingStringThrowsClassNotFoundException() {
try {
ClassLoaderUtil.getClass("[]");
fail("Expecting exception: ClassNotFoundException");
} catch(ClassNotFoundException e) {
}
}



public void testGetClassTakingStringThrowsRuntimeException() throws ClassNotFoundException {
try {
ClassLoaderUtil.getClass(null);
fail("Expecting exception: RuntimeException");
} catch(RuntimeException e) {
assertEquals(ClassLoaderUtil.class.getName(), e.getStackTrace()[0].getClassName());
}
}



public void testGetClassTakingString() throws ClassNotFoundException {
Class clasz = ClassLoaderUtil.getClass("char");

assertEquals(1041, clasz.getModifiers());
assertFalse(clasz.isArray());

assertFalse(clasz.isAnnotation());
assertEquals("char", clasz.toString());

assertFalse(clasz.isInterface());
assertTrue(clasz.isPrimitive());

assertFalse(clasz.isEnum());
assertFalse(clasz.isSynthetic());
}


public void testGetClassTaking2ArgumentsThrowsClassNotFoundException() {
try {
ClassLoaderUtil.getClass(ClassLoader.getSystemClassLoader(), "/B`j\\*xtz.Eb!s");
fail("Expecting exception: ClassNotFoundException");
} catch(ClassNotFoundException e) {
}
}


/**
* A simple class loader which delegates all class loading to its parent
* with two exceptions. First, attempts to load the class
Expand Down