Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added some Unit Tests to increase code coverage #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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