### Question:
ClassHelper { public static List<Class<?>> loadClasses(final String packageToScan, final ClassValidator cv) { return loadClasses(packageToScan, CLASSFILE_FILTER, cv); }  static List<Class<?>> loadClasses(final String packageToScan, final ClassValidator cv); static List<Class<?>> loadClasses(final String packageToScan, final FilenameFilter ff,
      final ClassValidator cv); static Class<?> getFieldType(Field field); static Object getFieldValue(final Object instance, final Field field); static void setFieldValue(final Object instance, final Field field, final Object value);  }### Answer:
@Test public void loadSingleEntity() throws ODataException { String packageToScan = ClassHelperTest.class.getPackage().getName(); List<Class<?>> loadedClasses = ClassHelper.loadClasses(packageToScan, annotatedTestEntityInnerClasses); Assert.assertEquals(1, loadedClasses.size()); Assert.assertEquals(SimpleEntity.class.getName(), loadedClasses.get(0).getName()); }
@Test(expected = ClassFormatError.class) public void loadFromSpaceDir() throws Exception { URL currentPath = Thread.currentThread().getContextClassLoader().getResource("."); File folder = new File(currentPath.toURI().getSchemeSpecificPart(), "space space/package"); folder.mkdirs(); File classFile = new File(folder, "Invalid.class"); classFile.createNewFile(); String packageToScan = "space space.package"; List<Class<?>> loadedClasses = ClassHelper.loadClasses(packageToScan, annotatedTestEntityInnerClasses); Assert.assertEquals(1, loadedClasses.size()); Assert.assertEquals(SimpleEntity.class.getName(), loadedClasses.get(0).getName()); }
@Test(expected = ClassFormatError.class) public void loadFromDirWithUnsafeName() throws Exception { URL currentPath = Thread.currentThread().getContextClassLoader().getResource("."); File folder = new File(currentPath.toURI().getSchemeSpecificPart(), "space space/package (123)/"); folder.mkdirs(); File classFile = new File(folder, "Invalid.class"); classFile.createNewFile(); String packageToScan = "space space.package"; List<Class<?>> loadedClasses = ClassHelper.loadClasses(packageToScan, annotatedTestEntityInnerClasses); Assert.assertEquals(1, loadedClasses.size()); Assert.assertEquals(SimpleEntity.class.getName(), loadedClasses.get(0).getName()); }
@Test public void loadSingleEntityFromJar() throws ODataException { String packageToScan = AnnotatedEntity.class.getPackage().getName(); List<Class<?>> loadedClasses = ClassHelper.loadClasses(packageToScan, annotatedEntityClasses); Assert.assertEquals(1, loadedClasses.size()); Assert.assertEquals(AnnotatedEntity.class.getName(), loadedClasses.get(0).getName()); }