fix unit test

Signed-off-by: Michael Hirsch <michael.hirsch@bosch-si.com>
This commit is contained in:
Michael Hirsch
2016-08-03 09:24:28 +02:00
parent 2ba9fd135d
commit 2965c93083

View File

@@ -47,6 +47,8 @@ public class RepositoryManagementMethodPreAuthorizeAnnotatedTest {
throws ClassNotFoundException, URISyntaxException, IOException { throws ClassNotFoundException, URISyntaxException, IOException {
final List<Class<?>> findInterfacesInPackage = findInterfacesInPackage(getClass().getPackage(), final List<Class<?>> findInterfacesInPackage = findInterfacesInPackage(getClass().getPackage(),
Pattern.compile(".*Management")); Pattern.compile(".*Management"));
assertThat(findInterfacesInPackage).isNotEmpty();
for (final Class<?> interfaceToCheck : findInterfacesInPackage) { for (final Class<?> interfaceToCheck : findInterfacesInPackage) {
assertDeclaredMethodsContainsPreAuthorizeAnnotaions(interfaceToCheck); assertDeclaredMethodsContainsPreAuthorizeAnnotaions(interfaceToCheck);
} }
@@ -92,7 +94,9 @@ public class RepositoryManagementMethodPreAuthorizeAnnotatedTest {
final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
final Enumeration<URL> resources = classLoader.getResources(p.getName().replace(".", "/")); final Enumeration<URL> resources = classLoader.getResources(p.getName().replace(".", "/"));
while (resources.hasMoreElements()) { while (resources.hasMoreElements()) {
final File packageDirectory = new File(new URI(resources.nextElement().toString()).getPath()); final String uriPath = new URI(resources.nextElement().toString()).getPath();
if (uriPath != null) {
final File packageDirectory = new File(uriPath);
final File[] filesInPackage = packageDirectory.listFiles(); final File[] filesInPackage = packageDirectory.listFiles();
for (final File classFile : filesInPackage) { for (final File classFile : filesInPackage) {
final String classNameWithExtension = classFile.getName(); final String classNameWithExtension = classFile.getName();
@@ -100,7 +104,8 @@ public class RepositoryManagementMethodPreAuthorizeAnnotatedTest {
if (indexOfExtension > 0) { if (indexOfExtension > 0) {
final String classNameWithoutExtension = classNameWithExtension.substring(0, indexOfExtension); final String classNameWithoutExtension = classNameWithExtension.substring(0, indexOfExtension);
if (includeFilter.matcher(classNameWithoutExtension).matches()) { if (includeFilter.matcher(classNameWithoutExtension).matches()) {
final Class<?> classInPackage = Class.forName(p.getName() + "." + classNameWithoutExtension); final Class<?> classInPackage = Class
.forName(p.getName() + "." + classNameWithoutExtension);
if (classInPackage.isInterface()) { if (classInPackage.isInterface()) {
interfacesToReturn.add(classInPackage); interfacesToReturn.add(classInPackage);
} }
@@ -108,6 +113,7 @@ public class RepositoryManagementMethodPreAuthorizeAnnotatedTest {
} }
} }
} }
}
return interfacesToReturn; return interfacesToReturn;
} }