test classes
diff --git a/pom.xml b/pom.xml
index c0237ee..4876e67 100644
--- a/pom.xml
+++ b/pom.xml
@@ -149,7 +149,7 @@
<exclude>**/*APITest.java</exclude>
</excludes>
<includes>
- <include>de.ids_mannheim.korap.**/*.java</include>
+ <include>de/ids_mannheim/korap/**/*.java</include>
</includes>
</configuration>
</plugin>
diff --git a/src/main/java/de/ids_mannheim/korap/handlers/EntityDao.java b/src/main/java/de/ids_mannheim/korap/handlers/EntityDao.java
index c5bf551..497b23c 100644
--- a/src/main/java/de/ids_mannheim/korap/handlers/EntityDao.java
+++ b/src/main/java/de/ids_mannheim/korap/handlers/EntityDao.java
@@ -53,7 +53,6 @@
user = this.jdbcTemplate.queryForObject(sql, namedParameters,
new RowMapperFactory.UserMapper());
}catch (EmptyResultDataAccessException ae) {
- ae.printStackTrace();
jlog.error("No user found for name '{}'", username);
throw new EmptyResultException(username);
}catch (DataAccessException e) {
diff --git a/src/main/java/de/ids_mannheim/korap/security/auth/KustvaktAuthenticationManager.java b/src/main/java/de/ids_mannheim/korap/security/auth/KustvaktAuthenticationManager.java
index 70b190b..680f67d 100644
--- a/src/main/java/de/ids_mannheim/korap/security/auth/KustvaktAuthenticationManager.java
+++ b/src/main/java/de/ids_mannheim/korap/security/auth/KustvaktAuthenticationManager.java
@@ -502,6 +502,7 @@
UserdataFactory.getDaoInstance(UserDetails.class).store(details);
UserdataFactory.getDaoInstance(UserSettings.class).store(settings);
}catch (KustvaktException e) {
+ e.printStackTrace();
throw new WrappedException(e, StatusCodes.CREATE_ACCOUNT_FAILED,
user.toString());
}
diff --git a/src/test/java/de/ids_mannheim/korap/config/TestHelper.java b/src/test/java/de/ids_mannheim/korap/config/TestHelper.java
index 2a685a8..cc180f3 100644
--- a/src/test/java/de/ids_mannheim/korap/config/TestHelper.java
+++ b/src/test/java/de/ids_mannheim/korap/config/TestHelper.java
@@ -47,6 +47,7 @@
.createUserAccount(m, false);
}catch (KustvaktException e) {
// do nothing
+ e.printStackTrace();
Assert.assertNull("Test user could not be set up", true);
return false;
}
@@ -54,17 +55,17 @@
return r;
}
- public static boolean setupSimpleAccount() {
+ public static boolean setupSimpleAccount(String username, String password) {
boolean r = BeanConfiguration.hasContext();
if (r && BeanConfiguration.getBeans().getUserDBHandler().size() == 0) {
EntityHandlerIface dao = BeanConfiguration.getBeans()
.getUserDBHandler();
Map m = new HashMap<>();
- m.put(Attributes.USERNAME, credentials[0]);
+ m.put(Attributes.USERNAME, username);
try {
String hash = BeanConfiguration.getBeans().getEncryption()
- .produceSecureHash(credentials[1]);
+ .produceSecureHash(password);
m.put(Attributes.PASSWORD, hash);
}catch (NoSuchAlgorithmException | UnsupportedEncodingException | KustvaktException e) {
@@ -96,19 +97,25 @@
throw new RuntimeException("User could not be retrieved!");
}
- public static boolean dropUser() {
- boolean r = BeanConfiguration.hasContext();
- if (r) {
- EntityHandlerIface dao = BeanConfiguration.getBeans()
- .getUserDBHandler();
- try {
- User us = dao.getAccount(credentials[0]);
- dao.deleteAccount(us.getId());
- }catch (KustvaktException e) {
- // do nothing
- }
+ public static boolean dropUser(String... usernames) {
+ if (usernames == null || usernames.length == 0)
+ usernames = new String[] { credentials[0] };
+ if (BeanConfiguration.hasContext()) {
+ for (String name : usernames)
+ remove(name);
}
- return r;
+ return BeanConfiguration.hasContext();
+ }
+
+ private static void remove(String username) {
+ EntityHandlerIface dao = BeanConfiguration.getBeans()
+ .getUserDBHandler();
+ try {
+ User us = dao.getAccount(username);
+ dao.deleteAccount(us.getId());
+ }catch (KustvaktException e) {
+ // do nothing
+ }
}
public static void drop() {