### Question:
JarUtils { public static File getJarFileOfClass (Class<?> cls) { if (cls == null) { throw new NullPointerException("class cannot be null."); } String classResource = cls.getName().replace('.', '/') + ".class"; URL location = cls.getResource('/' + cls.getName().replace('.', '/') + ".class"); String jarPath = location.getPath(); return pathToFile(jarPath, classResource); } protected  JarUtils(); static File getJarFileOfClass(Class<?> cls); static String getJarPath(Class<?> cls);  }### Answer:
@Test (expected = NullPointerException.class) public void testGetNullJarFile () { JarUtils.getJarFileOfClass(null); }
@Test public void testGetJarFile () { File file = JarUtils.getJarFileOfClass(String.class); System.out.println("jar file: " + file.getAbsolutePath()); assertNotNull(file); assertEquals(true, file.getAbsolutePath().endsWith("jar")); }