updated libraries

updated to JUNIT5
This commit is contained in:
Joern Muehlencord
2019-07-12 15:07:13 +02:00
parent 3ae4dba8fe
commit 24dc927ab7
57 changed files with 1196 additions and 1083 deletions

View File

@ -17,10 +17,10 @@ package de.muehlencord.shared.account.web;
import de.muehlencord.shared.account.business.account.boundary.AccountPermissions; import de.muehlencord.shared.account.business.account.boundary.AccountPermissions;
import de.muehlencord.shared.account.business.account.entity.AccountException; import de.muehlencord.shared.account.business.account.entity.AccountException;
import de.muehlencord.shared.account.business.instance.boundary.ApplicationPermissions;
import de.muehlencord.shared.account.business.application.control.ApplicationPermissionControl; import de.muehlencord.shared.account.business.application.control.ApplicationPermissionControl;
import de.muehlencord.shared.account.business.application.control.ApplicationRoleControl; import de.muehlencord.shared.account.business.application.control.ApplicationRoleControl;
import de.muehlencord.shared.account.business.application.entity.ApplicationEntity; import de.muehlencord.shared.account.business.application.entity.ApplicationEntity;
import de.muehlencord.shared.account.business.instance.boundary.ApplicationPermissions;
import java.util.Arrays; import java.util.Arrays;
import javax.enterprise.context.ApplicationScoped; import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.context.Initialized; import javax.enterprise.context.Initialized;

View File

@ -1,9 +1,9 @@
package de.muehlencord.shared.account.web.presentation; package de.muehlencord.shared.account.web.presentation;
import de.muehlencord.shared.account.business.instance.control.ApplicationController;
import de.muehlencord.shared.account.business.application.entity.ApplicationEntity; import de.muehlencord.shared.account.business.application.entity.ApplicationEntity;
import de.muehlencord.shared.account.business.config.boundary.ConfigService; import de.muehlencord.shared.account.business.config.boundary.ConfigService;
import de.muehlencord.shared.account.business.config.entity.ConfigException; import de.muehlencord.shared.account.business.config.entity.ConfigException;
import de.muehlencord.shared.account.business.instance.control.ApplicationController;
import javax.enterprise.context.ApplicationScoped; import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;

View File

@ -1,7 +1,10 @@
package de.muehlencord.shared.account.web.presentation; package de.muehlencord.shared.account.web.presentation;
import de.muehlencord.shared.account.business.application.control.ApplicationRoleControl;
import de.muehlencord.shared.account.business.application.entity.ApplicationEntity;
import de.muehlencord.shared.account.business.application.entity.ApplicationRoleEntity;
import de.muehlencord.shared.account.util.AccountPU;
import java.io.Serializable; import java.io.Serializable;
import javax.faces.application.FacesMessage; import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent; import javax.faces.component.UIComponent;
import javax.faces.component.UIInput; import javax.faces.component.UIInput;
@ -12,11 +15,6 @@ import javax.faces.validator.ValidatorException;
import javax.inject.Inject; import javax.inject.Inject;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import de.muehlencord.shared.account.business.application.control.ApplicationRoleControl;
import de.muehlencord.shared.account.business.application.entity.ApplicationEntity;
import de.muehlencord.shared.account.business.application.entity.ApplicationRoleEntity;
import de.muehlencord.shared.account.util.AccountPU;
/** /**
* *
* @author Joern Muehlencord <joern at muehlencord.de> * @author Joern Muehlencord <joern at muehlencord.de>

View File

@ -1,7 +1,8 @@
package de.muehlencord.shared.account.web.presentation; package de.muehlencord.shared.account.web.presentation;
import de.muehlencord.shared.account.business.application.control.ApplicationControl;
import de.muehlencord.shared.account.business.application.entity.ApplicationEntity;
import java.io.Serializable; import java.io.Serializable;
import javax.faces.application.FacesMessage; import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent; import javax.faces.component.UIComponent;
import javax.faces.component.UIInput; import javax.faces.component.UIInput;
@ -10,13 +11,9 @@ import javax.faces.validator.FacesValidator;
import javax.faces.validator.Validator; import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException; import javax.faces.validator.ValidatorException;
import javax.inject.Inject; import javax.inject.Inject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import de.muehlencord.shared.account.business.application.control.ApplicationControl;
import de.muehlencord.shared.account.business.application.entity.ApplicationEntity;
/** /**
* *
* @author Joern Muehlencord <joern at muehlencord.de> * @author Joern Muehlencord <joern at muehlencord.de>

View File

@ -1,8 +1,8 @@
package de.muehlencord.shared.account.web.presentation; package de.muehlencord.shared.account.web.presentation;
import de.muehlencord.shared.account.business.application.entity.ApplicationPermissionEntity;
import de.muehlencord.shared.account.business.application.control.ApplicationPermissionControl; import de.muehlencord.shared.account.business.application.control.ApplicationPermissionControl;
import de.muehlencord.shared.account.business.application.entity.ApplicationEntity; import de.muehlencord.shared.account.business.application.entity.ApplicationEntity;
import de.muehlencord.shared.account.business.application.entity.ApplicationPermissionEntity;
import de.muehlencord.shared.account.util.AccountPU; import de.muehlencord.shared.account.util.AccountPU;
import java.io.Serializable; import java.io.Serializable;
import javax.faces.application.FacesMessage; import javax.faces.application.FacesMessage;

View File

@ -54,8 +54,8 @@
<type>jar</type> <type>jar</type>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>junit</artifactId> <artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -63,6 +63,11 @@
<artifactId>mockito-core</artifactId> <artifactId>mockito-core</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId> <artifactId>slf4j-log4j12</artifactId>

View File

@ -163,8 +163,9 @@ public class ApiKeyService implements Serializable {
@Transactional @Transactional
@Lock(LockType.WRITE) @Lock(LockType.WRITE)
public ApiKeyObject createNewApiKey(String userName, short expirationInMinutes) throws ApiKeyException { public ApiKeyObject createNewApiKey(String userName, short expirationInMinutes) throws ApiKeyException {
if ((password == null || issuer == null) || (userName == null)) { if (password == null || issuer == null || userName == null) {
LOGGER.error("password, issuer or username not set in, please validate configuration"); String hint = "password, issuer or username not set in, please validate configuration";
throw new ApiKeyException(hint);
} }
Date now = DateUtil.getCurrentTimeInUTC(); Date now = DateUtil.getCurrentTimeInUTC();
ZonedDateTime issuedOn = ZonedDateTime.ofInstant(now.toInstant(), ZoneId.of("UTC")); ZonedDateTime issuedOn = ZonedDateTime.ofInstant(now.toInstant(), ZoneId.of("UTC"));

View File

@ -15,7 +15,6 @@
*/ */
package de.muehlencord.shared.account.business.config.boundary; package de.muehlencord.shared.account.business.config.boundary;
import de.muehlencord.shared.db.ControllerException;
import de.muehlencord.shared.account.business.account.entity.Account; import de.muehlencord.shared.account.business.account.entity.Account;
import de.muehlencord.shared.account.business.account.entity.AccountEntity; import de.muehlencord.shared.account.business.account.entity.AccountEntity;
import de.muehlencord.shared.account.business.application.entity.ApplicationEntity; import de.muehlencord.shared.account.business.application.entity.ApplicationEntity;
@ -23,6 +22,7 @@ import de.muehlencord.shared.account.business.config.entity.ConfigEntity;
import de.muehlencord.shared.account.business.config.entity.ConfigEntityPK; import de.muehlencord.shared.account.business.config.entity.ConfigEntityPK;
import de.muehlencord.shared.account.business.config.entity.ConfigException; import de.muehlencord.shared.account.business.config.entity.ConfigException;
import de.muehlencord.shared.account.util.AccountPU; import de.muehlencord.shared.account.util.AccountPU;
import de.muehlencord.shared.db.ControllerException;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@ -37,6 +37,7 @@ import javax.inject.Inject;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.persistence.Query; import javax.persistence.Query;
import javax.transaction.Transactional; import javax.transaction.Transactional;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -121,7 +122,7 @@ public class ConfigService implements Serializable {
// if config value is not found null has been returned // if config value is not found null has been returned
// in this case the value to return is the defaultValue // in this case the value to return is the defaultValue
if (configValue == null) { if (StringUtils.isEmpty(configValue)) {
configValue = defaultValue; configValue = defaultValue;
} }

View File

@ -15,10 +15,10 @@
*/ */
package de.muehlencord.shared.account.business.instance.boundary; package de.muehlencord.shared.account.business.instance.boundary;
import de.muehlencord.shared.db.ControllerException;
import de.muehlencord.shared.account.business.application.entity.ApplicationEntity; import de.muehlencord.shared.account.business.application.entity.ApplicationEntity;
import de.muehlencord.shared.account.business.config.boundary.ConfigService; import de.muehlencord.shared.account.business.config.boundary.ConfigService;
import de.muehlencord.shared.account.business.config.entity.ConfigException; import de.muehlencord.shared.account.business.config.entity.ConfigException;
import de.muehlencord.shared.db.ControllerException;
import javax.annotation.PreDestroy; import javax.annotation.PreDestroy;
import javax.enterprise.context.ApplicationScoped; import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.context.Initialized; import javax.enterprise.context.Initialized;

View File

@ -25,13 +25,12 @@ import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
import javax.faces.view.ViewScoped; import javax.faces.view.ViewScoped;
import javax.inject.Named; import javax.inject.Named;
import javax.servlet.ServletRequest; import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse; import javax.servlet.ServletResponse;
import org.apache.shiro.subject.Subject;
import org.apache.shiro.SecurityUtils; import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationException; import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.UsernamePasswordToken; import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.apache.shiro.web.util.WebUtils; import org.apache.shiro.web.util.WebUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;

View File

@ -15,9 +15,13 @@
*/ */
package de.muehlencord.shared.account.shiro.filter; package de.muehlencord.shared.account.shiro.filter;
import de.muehlencord.shared.account.business.account.boundary.ApiKeyService;
import de.muehlencord.shared.account.business.account.entity.JWTObject;
import de.muehlencord.shared.account.shiro.token.JWTAuthenticationToken;
import de.muehlencord.shared.account.util.AccountSecurityException;
import de.muehlencord.shared.jeeutil.restexfw.APIException;
import java.io.IOException; import java.io.IOException;
import java.io.StringReader; import java.io.StringReader;
import javax.json.Json; import javax.json.Json;
import javax.json.JsonObject; import javax.json.JsonObject;
import javax.json.JsonReader; import javax.json.JsonReader;
@ -29,7 +33,6 @@ import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse; import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.shiro.authc.AuthenticationToken; import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.UsernamePasswordToken; import org.apache.shiro.authc.UsernamePasswordToken;
@ -37,12 +40,6 @@ import org.apache.shiro.web.filter.authc.AuthenticatingFilter;
import org.apache.shiro.web.util.WebUtils; import org.apache.shiro.web.util.WebUtils;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import de.muehlencord.shared.account.business.account.boundary.ApiKeyService;
import de.muehlencord.shared.account.business.account.entity.JWTObject;
import de.muehlencord.shared.account.shiro.token.JWTAuthenticationToken;
import de.muehlencord.shared.account.util.AccountSecurityException;
import de.muehlencord.shared.jeeutil.restexfw.APIException;
/** /**
* *
* @author Joern Muehlencord <joern at muehlencord.de> * @author Joern Muehlencord <joern at muehlencord.de>

View File

@ -1,21 +1,98 @@
package de.muehlencord.shared.account.business.account.boundary; package de.muehlencord.shared.account.business.account.boundary;
import org.junit.Test; import de.muehlencord.shared.account.business.account.control.AccountControl;
import de.muehlencord.shared.account.business.account.entity.AccountEntity;
import de.muehlencord.shared.account.business.application.entity.ApplicationRoleEntity;
import de.muehlencord.shared.account.business.config.boundary.ConfigService;
import de.muehlencord.shared.account.business.config.entity.ConfigException;
import de.muehlencord.shared.account.dao.ApiKeyObject;
import de.muehlencord.shared.db.ControllerException;
import java.util.ArrayList;
import javax.persistence.EntityManager;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.fail;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.stubbing.Answer;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/** /**
* *
* @author Joern Muehlencord <joern at muehlencord.de> * @author Joern Muehlencord <joern at muehlencord.de>
*/ */
@ExtendWith(MockitoExtension.class)
public class ApiKeyServiceTest { public class ApiKeyServiceTest {
private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(ApiKeyServiceTest.class); private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(ApiKeyServiceTest.class);
ApiKeyService apiKeyService;
@BeforeEach
public void setup() {
apiKeyService = new ApiKeyService();
apiKeyService.configService = mock(ConfigService.class);
try {
when(apiKeyService.configService.getConfigValue(anyString(), anyString(), anyBoolean())).thenReturn("120");
when(apiKeyService.configService.getConfigValue(anyString())).thenAnswer(new Answer<String>() {
@Override
public String answer(InvocationOnMock invocation) throws Throwable {
Object[] args = invocation.getArguments();
String configKey = args[0].toString();
switch (configKey) {
case "rest.password":
return "secret";
case "rest.issuer":
return "ApiKeyServiceTest";
default:
return "unknown";
}
}
});
} catch (ConfigException | ControllerException ex) {
LOGGER.error(ex.getMessage());
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Detailed stacktrace", new Object[]{ex});
}
fail("An exception occured");
}
apiKeyService.accountControl = mock(AccountControl.class);
when(apiKeyService.accountControl.getAccountEntity(anyString(), anyBoolean())).thenAnswer(new Answer<AccountEntity>() {
@Override
public AccountEntity answer(InvocationOnMock iom) throws Throwable {
Object[] args = iom.getArguments();
String userName = args[0].toString();
boolean loadRoles = (boolean) args[1];
AccountEntity account = new AccountEntity();
account.setUsername(userName);
account.setFirstname("FirstName");
account.setLastname("LastName");
if (loadRoles) {
account.setApplicationRoleList(new ArrayList<>());
ApplicationRoleEntity exampleRoleEntity = new ApplicationRoleEntity();
exampleRoleEntity.setRoleName("Example Role");
account.getApplicationRoleList().add(exampleRoleEntity);
}
return account;
}
});
apiKeyService.em = mock (EntityManager.class);
apiKeyService.init();
}
@Test @Test
public void testCreateApiKey() { public void testCreateApiKey() {
try { try {
ApiKeyService apiKeyService = new ApiKeyService(); ApiKeyObject apiKeyObject = apiKeyService.createNewApiKey("web", (short) 120);
apiKeyService.createNewApiKey("web", (short) 120); assertNotNull(apiKeyObject);
LOGGER.info("authToken: "+apiKeyObject.getAuthToken());
} catch (ApiKeyException ex) { } catch (ApiKeyException ex) {
LOGGER.error(ex.getMessage()); LOGGER.error(ex.getMessage());
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {

View File

@ -22,20 +22,20 @@ import de.muehlencord.shared.account.business.config.entity.ConfigEntity;
import de.muehlencord.shared.account.business.config.entity.ConfigEntityPK; import de.muehlencord.shared.account.business.config.entity.ConfigEntityPK;
import java.util.UUID; import java.util.UUID;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import org.junit.Test; import org.junit.jupiter.api.BeforeEach;
import org.junit.Before; import org.junit.jupiter.api.Disabled;
import org.junit.Ignore; import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith; import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks; import org.mockito.InjectMocks;
import org.mockito.Mock; import org.mockito.Mock;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import org.mockito.runners.MockitoJUnitRunner; import org.mockito.junit.jupiter.MockitoExtension;
/** /**
* *
* @author joern.muehlencord * @author joern.muehlencord
*/ */
@RunWith(MockitoJUnitRunner.class) @ExtendWith(MockitoExtension.class)
public class ConfigServiceTest { public class ConfigServiceTest {
@InjectMocks @InjectMocks
@ -44,7 +44,7 @@ public class ConfigServiceTest {
@Mock @Mock
private EntityManager entityManagerMock; private EntityManager entityManagerMock;
@Before @BeforeEach
public void init() { public void init() {
ApplicationEntity application = new ApplicationEntity(); ApplicationEntity application = new ApplicationEntity();
application.setId(UUID.randomUUID()); application.setId(UUID.randomUUID());
@ -63,7 +63,7 @@ public class ConfigServiceTest {
} }
@Test @Test
@Ignore @Disabled
// TODO move to account test // TODO move to account test
public void testGetMaxFailedLogins() { public void testGetMaxFailedLogins() {
// configService.init(); // configService.init();

View File

@ -19,10 +19,12 @@ import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationException; import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.UsernamePasswordToken; import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.config.IniSecurityManagerFactory; import org.apache.shiro.config.IniSecurityManagerFactory;
import org.apache.shiro.subject.Subject;
import org.junit.Test;
import org.apache.shiro.mgt.SecurityManager; import org.apache.shiro.mgt.SecurityManager;
import static org.junit.Assume.assumeNotNull; import org.apache.shiro.subject.Subject;
import org.junit.jupiter.api.Assertions;
import static org.junit.jupiter.api.Assumptions.assumeFalse;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
/** /**
* *
@ -32,27 +34,32 @@ public class UserNameActiveDirectoryRealmTest {
@Test @Test
public void testUsernameLogin() { public void testUsernameLogin() {
String userName = "user.name"; String userName = "root";
String password = "secret"; String password = "secret";
testLogin(userName, password); testLogin(userName, password);
} }
@Test @Test
@Disabled
public void testEmailaddressLogin() { public void testEmailaddressLogin() {
String userName = "user.name@domain.com"; String userName = "user.name@domain.com";
String password = "secret"; String password = "secret";
testLogin(userName, password); Assertions.assertThrows(AuthenticationException.class, () -> {
testLogin(userName, password);
});
} }
@Test(expected=AuthenticationException.class) @Test
public void testWrongUserNamePassword() { public void testWrongUserNamePassword() {
String userName = "test123"; String userName = "test123";
String password = "secret"; String password = "secret";
testLogin(userName, password); Assertions.assertThrows(AuthenticationException.class, () -> {
testLogin(userName, password);
});
} }
private void testLogin(String userName, String password) throws AuthenticationException { private void testLogin(String userName, String password) throws AuthenticationException {
assumeNotNull(UserNameActiveDirectoryRealmTest.class.getResource("/shiro.ini")); assumeFalse(UserNameActiveDirectoryRealmTest.class.getResource("/shiro.ini") == null);
IniSecurityManagerFactory factory = new IniSecurityManagerFactory("classpath:shiro.ini"); IniSecurityManagerFactory factory = new IniSecurityManagerFactory("classpath:shiro.ini");
SecurityManager securityManager = factory.getInstance(); SecurityManager securityManager = factory.getInstance();

View File

@ -15,7 +15,7 @@
*/ */
package de.muehlencord.shared.account.util; package de.muehlencord.shared.account.util;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** /**
* *

View File

@ -0,0 +1,25 @@
# =============================================================================
# Tutorial INI configuration
#
# Usernames/passwords are based on the classic Mel Brooks' film "Spaceballs" :)
# =============================================================================
# -----------------------------------------------------------------------------
# Users and their (optional) assigned roles
# username = password, role1, role2, ..., roleN
# -----------------------------------------------------------------------------
[users]
root = secret, admin
guest = guest, guest
presidentskroob = 12345, president
darkhelmet = ludicrousspeed, darklord, schwartz
lonestarr = vespa, goodguy, schwartz
# -----------------------------------------------------------------------------
# Roles with assigned permissions
# roleName = perm1, perm2, ..., permN
# -----------------------------------------------------------------------------
[roles]
admin = *
schwartz = lightsaber:*
goodguy = winnebago:drive:eagle5

View File

@ -19,8 +19,8 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>junit</artifactId> <artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>

View File

@ -25,9 +25,8 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>junit</artifactId> <artifactId>junit-jupiter-engine</artifactId>
<type>jar</type>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -5,8 +5,8 @@
package de.muehlencord.shared.network; package de.muehlencord.shared.network;
import static de.muehlencord.shared.network.CidrTool.rangeToCidrList; import static de.muehlencord.shared.network.CidrTool.rangeToCidrList;
import org.junit.Ignore; import org.junit.jupiter.api.Disabled;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** /**
* *
@ -18,7 +18,7 @@ public class CidrToolTest {
} }
@Test @Test
@Ignore @Disabled
public void testCidrConversion() { public void testCidrConversion() {
System.out.println (rangeToCidrList("213.55.64.0", "213.55.127.255")); System.out.println (rangeToCidrList("213.55.64.0", "213.55.127.255"));
} }

View File

@ -3,9 +3,9 @@ package de.muehlencord.shared.network;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import org.apache.commons.net.util.SubnetUtils; import org.apache.commons.net.util.SubnetUtils;
import static org.junit.Assert.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import org.junit.Ignore; import org.junit.jupiter.api.Disabled;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** /**
* *
@ -17,7 +17,7 @@ public class NetworkScannerTest {
} }
@Test @Test
@Ignore // takes very long @Disabled // takes very long
public void testScan() throws UnknownHostException { public void testScan() throws UnknownHostException {
String ipAddress = InetAddress.getLocalHost().getHostAddress(); String ipAddress = InetAddress.getLocalHost().getHostAddress();
SubnetUtils utils = new SubnetUtils(ipAddress, "255.255.255.0"); SubnetUtils utils = new SubnetUtils(ipAddress, "255.255.255.0");

View File

@ -1,8 +1,8 @@
package de.muehlencord.shared.network; package de.muehlencord.shared.network;
import java.util.List; import java.util.List;
import org.junit.Ignore; import org.junit.jupiter.api.Disabled;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** /**
* *
@ -14,7 +14,7 @@ public class PortScannerTest {
} }
@Test @Test
@Ignore // takes very long @Disabled // takes very long
public void testMain() { public void testMain() {
PortScanner portScanner = new PortScanner(); PortScanner portScanner = new PortScanner();
List<PortInformation> resultList = portScanner.scan("127.0.0.1"); List<PortInformation> resultList = portScanner.scan("127.0.0.1");

View File

@ -1,7 +1,7 @@
package de.muehlencord.shared.network; package de.muehlencord.shared.network;
import static de.muehlencord.shared.network.CidrTool.rangeToCidrList; import static de.muehlencord.shared.network.CidrTool.rangeToCidrList;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** /**
* *

View File

@ -7,10 +7,11 @@ import java.net.URL;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Properties; import java.util.Properties;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.Before; import static org.junit.jupiter.api.Assertions.fail;
import org.junit.Ignore; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -27,8 +28,8 @@ public class FTPConnectionTest {
/** true, if init is complete to execute test */ /** true, if init is complete to execute test */
boolean initDone = false; boolean initDone = false;
@Before @BeforeEach
public void initClass() { public void setup() {
System.out.println("\n[FTPConnectionTest]"); System.out.println("\n[FTPConnectionTest]");
URL testConfigURL = FTPConnectionTest.class.getResource("/test.properties"); URL testConfigURL = FTPConnectionTest.class.getResource("/test.properties");
FileInputStream fin = null; FileInputStream fin = null;
@ -80,7 +81,7 @@ public class FTPConnectionTest {
} }
@Test @Test
@Ignore @Disabled
public void testList() throws FTPConnectionException { public void testList() throws FTPConnectionException {
System.out.println("list"); System.out.println("list");
String dir = ""; String dir = "";
@ -92,7 +93,7 @@ public class FTPConnectionTest {
} }
@Test @Test
@Ignore @Disabled
public void testListDirsOnly() throws FTPConnectionException { public void testListDirsOnly() throws FTPConnectionException {
System.out.println("listDirsOnly"); System.out.println("listDirsOnly");
String dir = ""; String dir = "";
@ -104,7 +105,7 @@ public class FTPConnectionTest {
} }
@Test @Test
@Ignore @Disabled
public void testListFilesOnly() throws FTPConnectionException { public void testListFilesOnly() throws FTPConnectionException {
System.out.println("listFilesOnly"); System.out.println("listFilesOnly");
String dir = ""; String dir = "";
@ -116,7 +117,7 @@ public class FTPConnectionTest {
} }
@Test @Test
@Ignore @Disabled
public void testListLinksOnly() throws FTPConnectionException { public void testListLinksOnly() throws FTPConnectionException {
System.out.println("listLinksOnly"); System.out.println("listLinksOnly");
String dir = ""; String dir = "";
@ -128,7 +129,7 @@ public class FTPConnectionTest {
} }
@Test @Test
@Ignore @Disabled
public void testUploadFile() throws FTPConnectionException { public void testUploadFile() throws FTPConnectionException {
System.out.println("uploadFile"); System.out.println("uploadFile");
String localFilename = ""; String localFilename = "";
@ -138,7 +139,7 @@ public class FTPConnectionTest {
} }
@Test @Test
@Ignore @Disabled
public void testRename() throws FTPConnectionException { public void testRename() throws FTPConnectionException {
System.out.println("rename"); System.out.println("rename");
String remoteOldName = ""; String remoteOldName = "";

View File

@ -9,8 +9,9 @@ import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.junit.Ignore; import org.junit.jupiter.api.Assertions;
import org.junit.Test; import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
/** /**
* *
@ -19,7 +20,7 @@ import org.junit.Test;
public class HttpLayerTest extends BaseTest { public class HttpLayerTest extends BaseTest {
@Test @Test
@Ignore @Disabled
public void testPostByMap() throws Exception { public void testPostByMap() throws Exception {
System.out.println("testPostByMap"); System.out.println("testPostByMap");
Map<String, String[]> map = new HashMap<>(); Map<String, String[]> map = new HashMap<>();
@ -32,7 +33,7 @@ public class HttpLayerTest extends BaseTest {
} }
@Test @Test
@Ignore @Disabled
public void testPostByMapList() throws Exception { public void testPostByMapList() throws Exception {
System.out.println("testPostByMapList"); System.out.println("testPostByMapList");
List<Map<String, String[]>> list = new LinkedList<>(); List<Map<String, String[]>> list = new LinkedList<>();
@ -45,41 +46,43 @@ public class HttpLayerTest extends BaseTest {
map.put("url", urlValue); map.put("url", urlValue);
list.add(map); list.add(map);
HttpLayer httpLayer = new HttpLayer("http://localhost:8080/HttpPostListener/HttpPostListener"); HttpLayer httpLayer = new HttpLayer("http://localhost:8080/HttpPostListener/HttpPostListener");
httpLayer.post(list); httpLayer.post(list);
} }
@Test @Test
@Ignore @Disabled
public void testByValue() throws Exception { public void testByValue() throws Exception {
System.out.println("testByValue"); System.out.println("testByValue");
HttpLayer httpLayer = new HttpLayer( HttpLayer httpLayer = new HttpLayer("http://localhost:8080/HttpPostListener/HttpPostListener");
"http://localhost:8080/HttpPostListener/HttpPostListener");
httpLayer.post("message", "Hello World by single parameter"); httpLayer.post("message", "Hello World by single parameter");
} }
@Test(expected = MessageNotSendException.class) @Test
public void testWithUnknownURL() throws MessageNotSendException { public void testWithUnknownURL() throws MessageNotSendException {
System.out.println("testWithUnknownURL"); System.out.println("testWithUnknownURL");
HttpLayer httpLayer = new HttpLayer( HttpLayer httpLayer = new HttpLayer("http://localhost/thisURLDoesNotExist");
"http://localhost/thisURLDoesNotExist"); Assertions.assertThrows(MessageNotSendException.class, () -> {
httpLayer.post("message", "Hello World by single parameter"); httpLayer.post("message", "Hello World by single parameter");
});
} }
@Test(expected = MessageNotSendException.class) @Test
public void testInvalidURL() throws MessageNotSendException { public void testInvalidURL() throws MessageNotSendException {
System.out.println("testInvalidURL"); System.out.println("testInvalidURL");
HttpLayer httpLayer = new HttpLayer("joern@muehlencord.de"); HttpLayer httpLayer = new HttpLayer("joern@muehlencord.de");
httpLayer.post("message", "Hello World by single parameter"); Assertions.assertThrows(MessageNotSendException.class, () -> {
httpLayer.post("message", "Hello World by single parameter");
});
} }
@Test(expected = MessageNotSendException.class) @Test
public void testUnsupportedURL() throws MessageNotSendException { public void testUnsupportedURL() throws MessageNotSendException {
System.out.println("testUnsupportedURL"); System.out.println("testUnsupportedURL");
HttpLayer httpLayer = new HttpLayer("ftp://localhost"); HttpLayer httpLayer = new HttpLayer("ftp://localhost");
httpLayer.post("message", "Hello World by single parameter"); Assertions.assertThrows(MessageNotSendException.class, () -> {
httpLayer.post("message", "Hello World by single parameter");
});
} }
} }

View File

@ -6,11 +6,11 @@ import de.muehlencord.shared.network.mail.imap.ImapMailReader;
import java.io.File; import java.io.File;
import java.net.URL; import java.net.URL;
import java.util.List; import java.util.List;
import static org.junit.Assert.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Ignore; import org.junit.jupiter.api.Disabled;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** /**
* *
@ -18,13 +18,13 @@ import org.junit.Test;
*/ */
public class MailMessageUtilsTest extends BaseTest { public class MailMessageUtilsTest extends BaseTest {
@Before @BeforeEach
public void setup() { public void setup() {
System.out.println ("\n[MailMessageUtilsTest]"); System.out.println ("\n[MailMessageUtilsTest]");
} }
@Test @Test
@Ignore // depends on environment @Disabled // depends on environment
public void testGetInstance() throws Exception { public void testGetInstance() throws Exception {
System.out.println("testGetInstance"); System.out.println("testGetInstance");
URL testConfigURL = MailMessageUtilsTest.class.getResource("/test.properties"); URL testConfigURL = MailMessageUtilsTest.class.getResource("/test.properties");

View File

@ -1,8 +1,3 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package de.muehlencord.shared.network.mail; package de.muehlencord.shared.network.mail;
import java.io.File; import java.io.File;
@ -23,8 +18,8 @@ import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart; import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage; import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart; import javax.mail.internet.MimeMultipart;
import org.junit.Assume; import static org.junit.jupiter.api.Assumptions.assumeFalse;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -42,8 +37,8 @@ public class TestSendMail {
@Test @Test
public void testSendEmail() throws AddressException, MessagingException, IOException { public void testSendEmail() throws AddressException, MessagingException, IOException {
Assume.assumeFalse(RECEIVER == null); assumeFalse(RECEIVER == null);
Assume.assumeFalse(PASSWORD == null); assumeFalse(PASSWORD == null);
Properties props = new Properties(); Properties props = new Properties();
props.put("mail.smtp.host", "jomu.timelord.de"); props.put("mail.smtp.host", "jomu.timelord.de");

View File

@ -6,9 +6,9 @@ import de.muehlencord.shared.network.mail.MailReaderConfiguration;
import de.muehlencord.shared.network.mail.MailReaderConnectionException; import de.muehlencord.shared.network.mail.MailReaderConnectionException;
import de.muehlencord.shared.network.mail.MailReaderException; import de.muehlencord.shared.network.mail.MailReaderException;
import java.util.List; import java.util.List;
import static org.junit.Assert.fail; import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.Assume.assumeNotNull; import static org.junit.jupiter.api.Assumptions.assumeFalse;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -33,12 +33,12 @@ public class ExchangeMailReaderTest {
String emailaddress = null; String emailaddress = null;
// disable tests if not all values are set // disable tests if not all values are set
assumeNotNull(smtpHost); assumeFalse(smtpHost == null);
assumeNotNull(folder); assumeFalse(folder == null);
assumeNotNull(testFolder); assumeFalse(testFolder == null);
assumeNotNull(userName); assumeFalse(userName == null);
assumeNotNull(emailaddress); assumeFalse(emailaddress == null);
assumeNotNull(password); assumeFalse(password == null);
MailReaderConfiguration config = new MailReaderConfiguration(smtpHost, imapHost, userName, password, emailaddress); MailReaderConfiguration config = new MailReaderConfiguration(smtpHost, imapHost, userName, password, emailaddress);
MailReader instance = new ExchangeMailReader(config); MailReader instance = new ExchangeMailReader(config);

View File

@ -1,7 +1,3 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package de.muehlencord.shared.network.mail.imap; package de.muehlencord.shared.network.mail.imap;
import de.muehlencord.shared.network.BaseTest; import de.muehlencord.shared.network.BaseTest;
@ -10,10 +6,10 @@ import de.muehlencord.shared.network.mail.MailReaderConfiguration;
import de.muehlencord.shared.network.mail.MailReaderConnectionException; import de.muehlencord.shared.network.mail.MailReaderConnectionException;
import de.muehlencord.shared.network.mail.MailReaderException; import de.muehlencord.shared.network.mail.MailReaderException;
import java.util.List; import java.util.List;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.Ignore; import org.junit.jupiter.api.Disabled;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** /**
* *
@ -28,7 +24,7 @@ public class ImapMailReaderTest extends BaseTest {
* @throws Exception if the tests fails * @throws Exception if the tests fails
*/ */
@Test @Test
@Ignore // depends on environment @Disabled // depends on environment
public void testConnect() throws Exception { public void testConnect() throws Exception {
System.out.println("connect"); System.out.println("connect");
String meta = "meta.muehlencord.intra"; String meta = "meta.muehlencord.intra";
@ -40,7 +36,7 @@ public class ImapMailReaderTest extends BaseTest {
} }
@Test @Test
@Ignore // depends on environment @Disabled // depends on environment
public void testGetFolder() throws Exception { public void testGetFolder() throws Exception {
System.out.println("getFolder"); System.out.println("getFolder");
String meta = "meta.muehlencord.intra"; String meta = "meta.muehlencord.intra";
@ -54,7 +50,7 @@ public class ImapMailReaderTest extends BaseTest {
} }
@Test @Test
@Ignore // depends on environment @Disabled // depends on environment
public void testGetMessageCount() throws MailReaderConnectionException, MailReaderException { public void testGetMessageCount() throws MailReaderConnectionException, MailReaderException {
System.out.println("testGetMessageCount"); System.out.println("testGetMessageCount");
String meta = "meta.muehlencord.intra"; String meta = "meta.muehlencord.intra";
@ -67,7 +63,7 @@ public class ImapMailReaderTest extends BaseTest {
} }
@Test @Test
@Ignore // depends on environment @Disabled // depends on environment
public void testGetSubFolder() throws MailReaderConnectionException, MailReaderException { public void testGetSubFolder() throws MailReaderConnectionException, MailReaderException {
System.out.println("getSubFolder"); System.out.println("getSubFolder");
String meta = "meta.muehlencord.intra"; String meta = "meta.muehlencord.intra";

View File

@ -2,9 +2,9 @@ package de.muehlencord.shared.network.whois;
import de.muehlencord.shared.network.BaseTest; import de.muehlencord.shared.network.BaseTest;
import java.io.IOException; import java.io.IOException;
import org.junit.Test; import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.Assert.*; import org.junit.jupiter.api.Disabled;
import org.junit.Ignore; import org.junit.jupiter.api.Test;
/** /**
* *
@ -14,7 +14,7 @@ public class ArinWhoisParserTest extends BaseTest {
@Test @Test
@Ignore @Disabled
public void testParseArinIp() throws IOException, WhoisException { public void testParseArinIp() throws IOException, WhoisException {
String whoisInformation = this.readContentFromFile("204.232.209.184.txt"); String whoisInformation = this.readContentFromFile("204.232.209.184.txt");
ArinWhoisParser parser = new ArinWhoisParser(); ArinWhoisParser parser = new ArinWhoisParser();
@ -28,7 +28,7 @@ public class ArinWhoisParserTest extends BaseTest {
} }
@Test @Test
@Ignore @Disabled
public void testParseArinDoubleIp() throws IOException, WhoisException { public void testParseArinDoubleIp() throws IOException, WhoisException {
String whoisInformation = this.readContentFromFile("108.166.92.167.txt"); String whoisInformation = this.readContentFromFile("108.166.92.167.txt");
ArinWhoisParser parser = new ArinWhoisParser(); ArinWhoisParser parser = new ArinWhoisParser();
@ -42,7 +42,7 @@ public class ArinWhoisParserTest extends BaseTest {
} }
@Test @Test
@Ignore // FIXME test broken @Disabled // FIXME test broken
public void testParseArinUnknown() throws IOException, WhoisException { public void testParseArinUnknown() throws IOException, WhoisException {
String whoisInformation = this.readContentFromFile("74.95.241.217.txt"); String whoisInformation = this.readContentFromFile("74.95.241.217.txt");
ArinWhoisParser parser = new ArinWhoisParser(); ArinWhoisParser parser = new ArinWhoisParser();

View File

@ -1,12 +1,12 @@
package de.muehlencord.shared.network.whois; package de.muehlencord.shared.network.whois;
import de.muehlencord.shared.network.BaseTest; import de.muehlencord.shared.network.BaseTest;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.Assert.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.Ignore; import org.junit.jupiter.api.Disabled;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** /**
* *
@ -14,56 +14,55 @@ import org.junit.Test;
*/ */
public class WhoisTest extends BaseTest { public class WhoisTest extends BaseTest {
@Test @Test
@Ignore @Disabled
public void testDenicWhoIs() throws WhoisException { public void testDenicWhoIs() throws WhoisException {
Whois whoIsClient = new Whois(); Whois whoIsClient = new Whois();
// Denic answers "status: connect" only // Denic answers "status: connect" only
whoIsClient.execute ("whois.denic.de", "-T dn,ace muehlencord.de"); whoIsClient.execute("whois.denic.de", "-T dn,ace muehlencord.de");
} }
@Test @Test
@Ignore @Disabled
public void testInternic() throws WhoisException { public void testInternic() throws WhoisException {
Whois whoIsClient = new Whois(); Whois whoIsClient = new Whois();
whoIsClient.execute ("whois.1api.net", "egameladder.com"); whoIsClient.execute("whois.1api.net", "egameladder.com");
} }
@Test @Test
@Ignore @Disabled
// TODO 184.173.67.10 whois with referal // TODO 184.173.67.10 whois with referal
public void testArin() throws WhoisException { public void testArin() throws WhoisException {
Whois whoIsClient = new Whois(); Whois whoIsClient = new Whois();
// WhoisInformation whoisInformation = whoIsClient.execute ("whois.arin.net", "204.232.209.184"); // WhoisInformation whoisInformation = whoIsClient.execute ("whois.arin.net", "204.232.209.184");
WhoisInformation whoisInformation = whoIsClient.execute ("whois.arin.net", "74.95.241.217"); WhoisInformation whoisInformation = whoIsClient.execute("whois.arin.net", "74.95.241.217");
assertNotNull (whoisInformation); assertNotNull(whoisInformation);
whoisInformation.validate(); whoisInformation.validate();
assertEquals ("Country", "US", whoisInformation.getNetworkInformation().getCountry()); assertEquals("Country", "US", whoisInformation.getNetworkInformation().getCountry());
System.out.println ("Network: "+whoisInformation.getNetwork()); System.out.println("Network: " + whoisInformation.getNetwork());
assertTrue ("Network", whoisInformation.getNetwork().contains("74.95.224.0/19")); assertTrue(whoisInformation.getNetwork().contains("74.95.224.0/19"), "Network");
} }
@Test @Test
@Ignore @Disabled
public void testApnic() throws WhoisException { public void testApnic() throws WhoisException {
Whois whoIsClient = new Whois(); Whois whoIsClient = new Whois();
whoIsClient.execute ("whois.apnic.net", "60.247.69.45"); whoIsClient.execute("whois.apnic.net", "60.247.69.45");
} }
@Test @Test
@Ignore @Disabled
public void testLacnic() throws WhoisException { public void testLacnic() throws WhoisException {
Whois whoIsClient = new Whois(); Whois whoIsClient = new Whois();
WhoisInformation whoisInformation = whoIsClient.execute ("whois.lacnic.net", "200.29.132.82"); WhoisInformation whoisInformation = whoIsClient.execute("whois.lacnic.net", "200.29.132.82");
assertNotNull (whoisInformation); assertNotNull(whoisInformation);
assertEquals ("Country", "CL", whoisInformation.getNetworkInformation().getCountry()); assertEquals("Country", "CL", whoisInformation.getNetworkInformation().getCountry());
assertTrue ("Network", whoisInformation.getNetwork().contains("200.29.132.80/29")); assertTrue(whoisInformation.getNetwork().contains("200.29.132.80/29"), "Network");
} }
@Test @Test
@Ignore @Disabled
public void testUnkown() throws WhoisException { public void testUnkown() throws WhoisException {
Whois whoIsClient = new Whois(); Whois whoIsClient = new Whois();
// whoIsClient.execute("whois.arin.net", "174.139.180.10"); // whoIsClient.execute("whois.arin.net", "174.139.180.10");
// whoIsClient.execute("whois.twnic.net", "60.250.38.39"); // whoIsClient.execute("whois.twnic.net", "60.250.38.39");
@ -76,27 +75,26 @@ public class WhoisTest extends BaseTest {
} }
@Test @Test
@Ignore @Disabled
public void testGeneric() throws WhoisException { public void testGeneric() throws WhoisException {
Whois whoIsClient = new Whois(); Whois whoIsClient = new Whois();
WhoisInformation info = whoIsClient.execute( "85.185.91.5"); WhoisInformation info = whoIsClient.execute("85.185.91.5");
assertNotNull (info); assertNotNull(info);
assertNotNull (info.getNetwork()); assertNotNull(info.getNetwork());
assertFalse (info.getNetwork().isEmpty()); assertFalse(info.getNetwork().isEmpty());
System.out.println (info.getNetwork().toString()); System.out.println(info.getNetwork().toString());
System.out.println (info.getRootNetwork().toString()); System.out.println(info.getRootNetwork().toString());
System.out.println (info.getNetworkInformation().getDescription()); System.out.println(info.getNetworkInformation().getDescription());
} }
@Test @Test
@Ignore @Disabled
public void testStepWise() throws WhoisException { public void testStepWise() throws WhoisException {
Whois whoIsClient = new Whois(); Whois whoIsClient = new Whois();
// whoIsClient.execute ("whois.ripe.net", "88.198.181.181"); // whoIsClient.execute ("whois.ripe.net", "88.198.181.181");
WhoisInformation whoisInformation = whoIsClient.execute ("212.204.60.1"); WhoisInformation whoisInformation = whoIsClient.execute("212.204.60.1");
assertTrue ("network", whoisInformation.getNetwork().contains("212.204.60.0/24")); assertTrue(whoisInformation.getNetwork().contains("212.204.60.0/24"), "network");
// whoIsClient.execute ("whois.ripe.net", "212.204.60.0"); // whoIsClient.execute ("whois.ripe.net", "212.204.60.0");
// whoIsClient.execute ("whois.ripe.net", "212.0.0.0/8"); // whoIsClient.execute ("whois.ripe.net", "212.0.0.0/8");
} }

View File

@ -17,8 +17,8 @@
<artifactId>freemarker</artifactId> <artifactId>freemarker</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>junit</artifactId> <artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -2,12 +2,12 @@ package de.muehlencord.shared.pdf;
import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer; import com.google.gson.JsonDeserializer;
import java.lang.reflect.Type;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParseException; import com.google.gson.JsonParseException;
import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer; import com.google.gson.JsonSerializer;
import java.lang.reflect.Type;
/** /**
* *

View File

@ -7,7 +7,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedDeque;
import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.font.PDFont; import org.apache.pdfbox.pdmodel.font.PDFont;
import org.apache.pdfbox.pdmodel.font.PDType1Font; import org.apache.pdfbox.pdmodel.font.PDType1Font;

View File

@ -1,7 +1,8 @@
package de.muehlencord.shared.pdf; package de.muehlencord.shared.pdf;
import org.junit.Test; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.assertFalse;
import org.junit.jupiter.api.Test;
/** /**
* *
@ -11,25 +12,24 @@ public class DefaultTableRowTest {
@Test @Test
public void testFromJson() { public void testFromJson() {
String jsonString = "{\n" + String jsonString = "{\n"
" \"type\": \"de.muehlencord.shared.pdf.DefaultTableRow\",\n" + + " \"type\": \"de.muehlencord.shared.pdf.DefaultTableRow\",\n"
" \"data\": {\n" + + " \"data\": {\n"
" \"row\": [\n" + + " \"row\": [\n"
" {\n" + + " {\n"
" \"text\": \"Rechnungs-Nr.:\"\n" + + " \"text\": \"Rechnungs-Nr.:\"\n"
" },\n" + + " },\n"
" {\n" + + " {\n"
" \"text\": \"${invoiceNumber}\"\n" + + " \"text\": \"${invoiceNumber}\"\n"
" }\n" + + " }\n"
" ],\n" + + " ],\n"
" \"isList\": false\n" + + " \"isList\": false\n"
" }\n" + + " }\n"
" }"; + " }";
TableRow tableRow = GsonUtil.getInstance().fromJson(jsonString, TableRow.class); TableRow tableRow = GsonUtil.getInstance().fromJson(jsonString, TableRow.class);
assertNotNull ("tableRowObject", tableRow); assertFalse(tableRow == null, "tableRowObject");
assertEquals ("column count", 2, tableRow.getColumnCount()); assertEquals(2, tableRow.getColumnCount(), "column count");
assertFalse ("isList", tableRow.isList()); assertFalse(tableRow.isList(), "isList");
} }
} }

View File

@ -1,7 +1,7 @@
package de.muehlencord.shared.pdf; package de.muehlencord.shared.pdf;
import org.junit.Test; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.*; import org.junit.jupiter.api.Test;
/** /**
* *

View File

@ -4,7 +4,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** /**
* *

View File

@ -2,7 +2,7 @@ package de.muehlencord.shared.pdf;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** /**
* *

View File

@ -1,7 +1,8 @@
package de.muehlencord.shared.pdf; package de.muehlencord.shared.pdf;
import org.junit.Test; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.assertFalse;
import org.junit.jupiter.api.Test;
/** /**
* *
@ -19,8 +20,8 @@ public class TextTest {
+ "}"; + "}";
TextElement text = GsonUtil.getInstance().fromJson(jsonString, TextElement.class); TextElement text = GsonUtil.getInstance().fromJson(jsonString, TextElement.class);
assertNotNull ("text object", text); assertFalse(text == null, "text object");
assertEquals ("text value", "Rechnungs-Nr.:", text.getText()); assertEquals("Rechnungs-Nr.:", text.getText(), "text value");
} }

View File

@ -14,7 +14,7 @@ import java.io.IOException;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** /**
* *

View File

@ -25,14 +25,15 @@ import java.net.URL;
import java.util.Date; import java.util.Date;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.junit.FixMethodOrder; import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
/** /**
* *
* @author jomu * @author jomu
*/ */
@FixMethodOrder @TestMethodOrder(OrderAnnotation.class)
public class PDFDocumentTest { public class PDFDocumentTest {
private String jsonString = null; private String jsonString = null;

View File

@ -1,11 +1,12 @@
package de.muehlencord.shared.pdf.util; package de.muehlencord.shared.pdf.util;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import org.junit.Ignore; import org.junit.jupiter.api.Disabled;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** /**
* *
@ -32,7 +33,7 @@ public class ImageUtilTest {
} }
@Test @Test
@Ignore @Disabled
public void testFromFile() throws IOException { public void testFromFile() throws IOException {
System.out.println ("testFromFile"); System.out.println ("testFromFile");
BufferedImage img = ImageIO.read(new File ("c:/temp/dn_logo_smartteller_transparent.png")); BufferedImage img = ImageIO.read(new File ("c:/temp/dn_logo_smartteller_transparent.png"));

84
pom.xml
View File

@ -73,40 +73,10 @@
<artifactId>filter</artifactId> <artifactId>filter</artifactId>
<version>1.1-SNAPSHOT</version> <version>1.1-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version> <!-- TODO needs update to v5 -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.3.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.3.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.3.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.23.0</version>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>commons-codec</groupId> <groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId> <artifactId>commons-codec</artifactId>
<version>1.11</version> <version>1.12</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>commons-net</groupId> <groupId>commons-net</groupId>
@ -116,7 +86,7 @@
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId> <artifactId>commons-lang3</artifactId>
<version>3.8.1</version> <version>3.9</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>commons-io</groupId> <groupId>commons-io</groupId>
@ -157,24 +127,24 @@
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId> <artifactId>jackson-annotations</artifactId>
<version>2.9.8</version> <version>2.9.9</version>
<type>jar</type> <type>jar</type>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId> <artifactId>jackson-databind</artifactId>
<version>2.9.8</version> <version>2.9.9.1</version>
<type>jar</type> <type>jar</type>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.shiro</groupId> <groupId>org.apache.shiro</groupId>
<artifactId>shiro-core</artifactId> <artifactId>shiro-core</artifactId>
<version>1.4.0</version> <version>1.4.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.shiro</groupId> <groupId>org.apache.shiro</groupId>
<artifactId>shiro-web</artifactId> <artifactId>shiro-web</artifactId>
<version>1.4.0</version> <version>1.4.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>javax</groupId> <groupId>javax</groupId>
@ -259,6 +229,38 @@
<artifactId>prime-jwt</artifactId> <artifactId>prime-jwt</artifactId>
<version>1.3.1</version> <version>1.3.1</version>
</dependency> </dependency>
<!-- Testing -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.5.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.5.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.5.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.28.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>2.23.0</version>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
@ -296,6 +298,12 @@
<artifactId>maven-release-plugin</artifactId> <artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version> <version>2.5.3</version>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
</plugins> </plugins>
</pluginManagement> </pluginManagement>
<plugins> <plugins>
@ -310,6 +318,10 @@
<tagNameFormat>v@{project.version}</tagNameFormat> <tagNameFormat>v@{project.version}</tagNameFormat>
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
</plugins> </plugins>
</build> </build>

View File

@ -21,8 +21,9 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>junit</artifactId> <artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>commons-codec</groupId> <groupId>commons-codec</groupId>

View File

@ -15,8 +15,9 @@ package de.muehlencord.shared.security;
import static de.muehlencord.shared.security.Luhn.computeCheckDigit; import static de.muehlencord.shared.security.Luhn.computeCheckDigit;
import static de.muehlencord.shared.security.Luhn.validateNumber; import static de.muehlencord.shared.security.Luhn.validateNumber;
import org.junit.Test; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
/** /**
* *

View File

@ -2,8 +2,11 @@ package de.muehlencord.shared.security;
import static de.muehlencord.shared.security.OldPasswordUtil.getScryptHash; import static de.muehlencord.shared.security.OldPasswordUtil.getScryptHash;
import static de.muehlencord.shared.security.OldPasswordUtil.validateScryptHash; import static de.muehlencord.shared.security.OldPasswordUtil.validateScryptHash;
import org.junit.Test; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNotSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
/** /**
* *
@ -11,114 +14,111 @@ import static org.junit.Assert.*;
*/ */
public class OldPasswordUtilTest { public class OldPasswordUtilTest {
/** /**
* Test of createSaltString method, of class PasswordUtil. * Test of createSaltString method, of class PasswordUtil.
*/ */
@Test @Test
public void createSaltString() throws Exception { public void createSaltString() throws Exception {
System.out.println("createSaltString"); System.out.println("createSaltString");
int saltLength = 40; int saltLength = 40;
String result = OldPasswordUtil.createSaltString(saltLength); String result = OldPasswordUtil.createSaltString(saltLength);
assertNotNull(result); assertNotNull(result);
} }
/** /**
* Test of getMD5Password method, of class PasswordUtil. * Test of getMD5Password method, of class PasswordUtil.
*/ */
@Test @Test
public void getMD5Password() throws Exception { public void getMD5Password() throws Exception {
System.out.println("getMD5Password"); System.out.println("getMD5Password");
String plainTextPassword = ""; String plainTextPassword = "";
int saltLength = 40; int saltLength = 40;
String[] result1 = OldPasswordUtil.getMD5Password(plainTextPassword, saltLength); String[] result1 = OldPasswordUtil.getMD5Password(plainTextPassword, saltLength);
String password1 = result1[0]; String password1 = result1[0];
String salt1 = result1[1]; String salt1 = result1[1];
assertNotNull(result1); assertNotNull(result1);
assertNotNull(password1); assertNotNull(password1);
assertNotNull(salt1); assertNotNull(salt1);
String[] result2 = OldPasswordUtil.getMD5Password(plainTextPassword, saltLength); String[] result2 = OldPasswordUtil.getMD5Password(plainTextPassword, saltLength);
String password2 = result2[0]; String password2 = result2[0];
String salt2 = result2[1]; String salt2 = result2[1];
assertNotNull(result2); assertNotNull(result2);
assertNotNull(password2); assertNotNull(password2);
assertNotNull(salt2); assertNotNull(salt2);
assertNotSame(result1, result2); assertNotSame(result1, result2);
assertNotSame(password1, password2); assertNotSame(password1, password2);
assertNotSame(salt1, salt2); assertNotSame(salt1, salt2);
} }
/**
* Test of checkPassword method, of class PasswordUtil.
*/
@Test
public void checkPassword() throws Exception {
System.out.println("checkPassword");
String plainTextPassword = "welcome";
String plainTextPassword2 = "this is not the correct password";
String[] data = OldPasswordUtil.getMD5Password(plainTextPassword, 40);
String cryptedPassword = data[0];
String salt = data[1];
String salt2 = OldPasswordUtil.createSaltString(40);
String salt3 = OldPasswordUtil.createSaltString(10);
/** boolean expResult = true;
* Test of checkPassword method, of class PasswordUtil. boolean result = OldPasswordUtil.checkPassword(plainTextPassword, cryptedPassword, salt);
*/ assertTrue(expResult == result);
@Test
public void checkPassword() throws Exception {
System.out.println("checkPassword");
String plainTextPassword = "welcome";
String plainTextPassword2 = "this is not the correct password";
String[] data = OldPasswordUtil.getMD5Password(plainTextPassword, 40); expResult = false;
String cryptedPassword = data[0]; result = OldPasswordUtil.checkPassword(plainTextPassword2, cryptedPassword, salt);
String salt = data[1]; assertTrue(expResult == result);
String salt2 = OldPasswordUtil.createSaltString(40); expResult = false;
String salt3 = OldPasswordUtil.createSaltString(10); result = OldPasswordUtil.checkPassword(plainTextPassword, cryptedPassword, salt2);
assertTrue(expResult == result);
boolean expResult = true; expResult = false;
boolean result = OldPasswordUtil.checkPassword(plainTextPassword, cryptedPassword, salt); result = OldPasswordUtil.checkPassword(plainTextPassword, cryptedPassword, salt3);
assertEquals(expResult, result); assertTrue(expResult == result);
}
expResult = false;
result = OldPasswordUtil.checkPassword(plainTextPassword2, cryptedPassword, salt);
assertEquals(expResult, result);
expResult = false;
result = OldPasswordUtil.checkPassword(plainTextPassword, cryptedPassword, salt2);
assertEquals(expResult, result);
expResult = false;
result = OldPasswordUtil.checkPassword(plainTextPassword, cryptedPassword, salt3);
assertEquals(expResult, result);
}
@Test @Test
public void getRandomString() throws SecurityException { public void getRandomString() throws SecurityException {
System.out.println ("getRandomString"); System.out.println("getRandomString");
String randomString = OldPasswordUtil.getRandomString("test-", 32); String randomString = OldPasswordUtil.getRandomString("test-", 32);
System.out.println(randomString); System.out.println(randomString);
assertNotNull(randomString); assertNotNull(randomString);
assertTrue("string must start with prefix", randomString.startsWith("test")); assertTrue(randomString.startsWith("test"), "string must start with prefix");
assertEquals("string length check", 32, randomString.length()); assertTrue(32 == randomString.length(), "string length check");
String randomString2 = OldPasswordUtil.getRandomString("test-", 32); String randomString2 = OldPasswordUtil.getRandomString("test-", 32);
System.out.println(randomString2); System.out.println(randomString2);
assertNotNull(randomString2); assertNotNull(randomString2);
assertTrue("string must start with prefix", randomString2.startsWith("test")); assertTrue(randomString2.startsWith("test"), "string must start with prefix");
assertEquals("string length check", 32, randomString2.length()); assertTrue(32 == randomString2.length(), "string length check");
assertNotSame(randomString, randomString2); assertNotSame(randomString, randomString2);
} }
@Test @Test
public void getRandomStringBlankPrefix() throws SecurityException { public void getRandomStringBlankPrefix() throws SecurityException {
System.out.println ("getRandomStringBlankPrefix"); System.out.println("getRandomStringBlankPrefix");
String randomString = OldPasswordUtil.getRandomString("", 32); String randomString = OldPasswordUtil.getRandomString("", 32);
System.out.println(randomString); System.out.println(randomString);
assertNotNull(randomString); assertNotNull(randomString);
assertEquals("string length check", 32, randomString.length()); assertTrue(32 == randomString.length(), "string length check");
} }
@Test @Test
public void getRandomStringNullPrefix() throws SecurityException { public void getRandomStringNullPrefix() throws SecurityException {
System.out.println ("getRandomStringNullPrefix"); System.out.println("getRandomStringNullPrefix");
String randomString = OldPasswordUtil.getRandomString(null, 32); String randomString = OldPasswordUtil.getRandomString(null, 32);
System.out.println(randomString); System.out.println(randomString);
assertNotNull(randomString); assertNotNull(randomString);
assertEquals("string length check", 32, randomString.length()); assertTrue(32 == randomString.length(), "string length check");
} }
/** /**
@ -128,15 +128,15 @@ public class OldPasswordUtilTest {
public void testGetScryptHash() { public void testGetScryptHash() {
String hash1 = getScryptHash("secret"); String hash1 = getScryptHash("secret");
String hash2 = getScryptHash("secret"); String hash2 = getScryptHash("secret");
System.out.println (hash1); System.out.println(hash1);
System.out.println (hash2); System.out.println(hash2);
assertNotNull (hash1); assertNotNull(hash1);
assertNotNull (hash2); assertNotNull(hash2);
// even if password is the same, the has must not be the same due to correct usage of salts // even if password is the same, the has must not be the same due to correct usage of salts
assertFalse (hash1.equals (hash2)); assertFalse(hash1.equals(hash2));
assertTrue (hash1.length() == 79); assertTrue(hash1.length() == 79);
assertTrue (hash2.length() == 79); assertTrue(hash2.length() == 79);
} }
/** /**
@ -146,9 +146,9 @@ public class OldPasswordUtilTest {
public void testValidateScryptHash() { public void testValidateScryptHash() {
String hash1 = getScryptHash("secret"); String hash1 = getScryptHash("secret");
String hash2 = getScryptHash("secret"); String hash2 = getScryptHash("secret");
assertTrue ("hash must match if correct password is given",validateScryptHash("secret", hash1)); assertTrue(validateScryptHash("secret", hash1), "hash must match if correct password is given");
assertTrue ("hash must match if correct password is given", validateScryptHash("secret", hash2)); assertTrue(validateScryptHash("secret", hash2), "hash must match if correct password is given");
assertFalse ("hash must not match if wrong password is given", validateScryptHash("secret2", hash1)); assertFalse(validateScryptHash("secret2", hash1), "hash must not match if wrong password is given");
} }
} }

View File

@ -1,12 +1,11 @@
package de.muehlencord.shared.security; package de.muehlencord.shared.security;
import de.muehlencord.shared.security.PasswordUtil;
import java.security.SecureRandom; import java.security.SecureRandom;
import org.bouncycastle.util.encoders.Base64; import org.bouncycastle.util.encoders.Base64;
import static org.junit.Assert.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.Test; import org.junit.jupiter.api.BeforeAll;
import org.junit.BeforeClass; import org.junit.jupiter.api.Test;
/** /**
* *
@ -18,7 +17,7 @@ public class PasswordUtilTest {
private static String systemSalt64Coded; private static String systemSalt64Coded;
private static byte[] systemSaltBytes; private static byte[] systemSaltBytes;
@BeforeClass @BeforeAll
public static void init() { public static void init() {
secureRandom = new SecureRandom(); secureRandom = new SecureRandom();

View File

@ -15,7 +15,7 @@ public class NtlmAuthenticatorTest extends BaseTest {
@Test @Test
@Ignore // Depends on available sharepoint currently @Disabled // Depends on available sharepoint currently
public void testAuthentication() throws MalformedURLException, NoSuchAlgorithmException, KeyManagementException { public void testAuthentication() throws MalformedURLException, NoSuchAlgorithmException, KeyManagementException {
SPSite instance = new SPSite(getContext()); SPSite instance = new SPSite(getContext());
// instance.getRootWeb(); // instance.getRootWeb();

View File

@ -14,7 +14,7 @@ public class SharepointConfigTest {
} }
@Test @Test
@Ignore // Depends on available sharepoint currently @Disabled // Depends on available sharepoint currently
public void testLoadFromFile() throws Exception { public void testLoadFromFile() throws Exception {
SharepointConfig c = new SharepointConfig(); SharepointConfig c = new SharepointConfig();
c.loadFromFile(); c.loadFromFile();

View File

@ -23,7 +23,7 @@ import org.xml.sax.SAXException;
public class SPListTest extends BaseTest { public class SPListTest extends BaseTest {
@Test @Test
@Ignore // Depends on available sharepoint currently @Disabled // Depends on available sharepoint currently
public void testFromXML() throws Exception { public void testFromXML() throws Exception {
String xmlString = readFileContentFromTest("lists/testlist.xml", "UTF-8"); String xmlString = readFileContentFromTest("lists/testlist.xml", "UTF-8");
SPList list = new SPList(getContext(), "{924883B9-41B7-430C-8206-151786A67319}"); SPList list = new SPList(getContext(), "{924883B9-41B7-430C-8206-151786A67319}");
@ -32,7 +32,7 @@ public class SPListTest extends BaseTest {
} }
@Test @Test
@Ignore // Depends on available sharepoint currently @Disabled // Depends on available sharepoint currently
public void addListItemByTitle() throws NoSuchAlgorithmException, KeyManagementException, JAXBException, SAXException, ParserConfigurationException, public void addListItemByTitle() throws NoSuchAlgorithmException, KeyManagementException, JAXBException, SAXException, ParserConfigurationException,
IOException { IOException {
@ -58,7 +58,7 @@ public class SPListTest extends BaseTest {
} }
@Test @Test
@Ignore // Depends on available sharepoint currently @Disabled // Depends on available sharepoint currently
public void addListItemBigList() throws NoSuchAlgorithmException, KeyManagementException, JAXBException, SAXException, ParserConfigurationException, public void addListItemBigList() throws NoSuchAlgorithmException, KeyManagementException, JAXBException, SAXException, ParserConfigurationException,
IOException { IOException {
@ -93,7 +93,7 @@ public class SPListTest extends BaseTest {
} }
@Test @Test
@Ignore // Depends on available sharepoint currently @Disabled // Depends on available sharepoint currently
public void testGetListItems() throws Exception { public void testGetListItems() throws Exception {
SPLists instance = new SPLists(getContext()); SPLists instance = new SPLists(getContext());
SPList list = instance.getSpListByTitle("Questionnaire_Countries"); SPList list = instance.getSpListByTitle("Questionnaire_Countries");
@ -111,7 +111,7 @@ public class SPListTest extends BaseTest {
} }
@Test @Test
@Ignore // Depends on available sharepoint currently @Disabled // Depends on available sharepoint currently
public void testGetListItemsQuery() throws Exception { public void testGetListItemsQuery() throws Exception {
SPLists instance = new SPLists(getContext()); SPLists instance = new SPLists(getContext());
SPList list = instance.getSpListByTitle("Questionnaire_Countries"); SPList list = instance.getSpListByTitle("Questionnaire_Countries");
@ -135,7 +135,7 @@ public class SPListTest extends BaseTest {
} }
@Test @Test
@Ignore // Depends on available sharepoint currently @Disabled // Depends on available sharepoint currently
public void testGetLookupValueMap() throws Exception { public void testGetLookupValueMap() throws Exception {
SPLists instance = new SPLists(getContext()); SPLists instance = new SPLists(getContext());
SPList list = instance.getSpListByTitle("Questionnaire_Countries"); SPList list = instance.getSpListByTitle("Questionnaire_Countries");
@ -145,7 +145,7 @@ public class SPListTest extends BaseTest {
} }
@Test @Test
@Ignore // Depends on available sharepoint currently @Disabled // Depends on available sharepoint currently
public void testGetColumnNameByDisplayName() throws Exception { public void testGetColumnNameByDisplayName() throws Exception {
SPLists instance = new SPLists(getContext()); SPLists instance = new SPLists(getContext());
SPList list = instance.getSpListByTitle("Questionnaire"); SPList list = instance.getSpListByTitle("Questionnaire");
@ -153,7 +153,7 @@ public class SPListTest extends BaseTest {
} }
@Test @Test
@Ignore // Depends on available sharepoint currently @Disabled // Depends on available sharepoint currently
public void testGetItemCount() throws Exception { public void testGetItemCount() throws Exception {
SPLists instance = new SPLists(getContext()); SPLists instance = new SPLists(getContext());
SPList list = instance.getSpListByTitle("Questionnaire"); SPList list = instance.getSpListByTitle("Questionnaire");

View File

@ -18,7 +18,7 @@ public class SPListsTest extends BaseTest {
@Test @Test
@Ignore // Depends on available sharepoint currently @Disabled // Depends on available sharepoint currently
public void testFromXML() throws IOException, JAXBException, SAXException { public void testFromXML() throws IOException, JAXBException, SAXException {
String xmlString = readFileContentFromTest("lists/testlists.xml", "UTF-8"); String xmlString = readFileContentFromTest("lists/testlists.xml", "UTF-8");
SPLists lists = new SPLists(getContext()); SPLists lists = new SPLists(getContext());
@ -27,7 +27,7 @@ public class SPListsTest extends BaseTest {
} }
@Test @Test
@Ignore // Depends on available sharepoint currently @Disabled // Depends on available sharepoint currently
public void testGetListName() throws Exception { public void testGetListName() throws Exception {
SPLists instance = new SPLists(getContext()); SPLists instance = new SPLists(getContext());
String listName = instance.getListNameByTitle("Questionnaire"); String listName = instance.getListNameByTitle("Questionnaire");

View File

@ -18,7 +18,7 @@ public class SPUserGroupTest extends BaseTest {
private final static Logger LOGGER = LoggerFactory.getLogger(SPUserGroupTest.class.getName()); private final static Logger LOGGER = LoggerFactory.getLogger(SPUserGroupTest.class.getName());
@Test @Test
@Ignore @Disabled
public void testFromXML() throws Exception { public void testFromXML() throws Exception {
String xmlString = readFileContentFromTest("usergroups/user.xml", "UTF-8"); String xmlString = readFileContentFromTest("usergroups/user.xml", "UTF-8");
SPUser user = new SPUser(getContext()); SPUser user = new SPUser(getContext());
@ -27,7 +27,7 @@ public class SPUserGroupTest extends BaseTest {
} }
@Test @Test
@Ignore // Depends on available sharepoint currently @Disabled // Depends on available sharepoint currently
public void testGetUserInfo() throws Exception { public void testGetUserInfo() throws Exception {
SPUserGroup ug = new SPUserGroup(getContext()); SPUserGroup ug = new SPUserGroup(getContext());
String userId = ug.getUserId("wincor-nixdorf\\joern.muehlencord"); String userId = ug.getUserId("wincor-nixdorf\\joern.muehlencord");
@ -35,14 +35,14 @@ public class SPUserGroupTest extends BaseTest {
} }
@Test @Test
@Ignore // Depends on available sharepoint currently @Disabled // Depends on available sharepoint currently
public void testAddUserToGroup() throws Exception { public void testAddUserToGroup() throws Exception {
SPUserGroup ug = new SPUserGroup(getContext()); SPUserGroup ug = new SPUserGroup(getContext());
ug.addUserToGroup("wincor-nixdorf\\joern.muehlencord", "Test Group"); ug.addUserToGroup("wincor-nixdorf\\joern.muehlencord", "Test Group");
} }
@Test @Test
@Ignore // Depends on available sharepoint currently @Disabled // Depends on available sharepoint currently
public void testIsUserMemberOfGroup() throws Exception { public void testIsUserMemberOfGroup() throws Exception {
SPUserGroup ug = new SPUserGroup(getContext()); SPUserGroup ug = new SPUserGroup(getContext());
boolean result = ug.isUserMemberOfGroup("wincor-nixdorf\\joern.muehlencord", "HQ All Members"); boolean result = ug.isUserMemberOfGroup("wincor-nixdorf\\joern.muehlencord", "HQ All Members");
@ -50,7 +50,7 @@ public class SPUserGroupTest extends BaseTest {
} }
@Test @Test
@Ignore // Depends on available sharepoint currently @Disabled // Depends on available sharepoint currently
public void getUserLoginNameFromEmail() throws Exception { public void getUserLoginNameFromEmail() throws Exception {
SPUserGroup ug = new SPUserGroup(getContext()); SPUserGroup ug = new SPUserGroup(getContext());
SPUser user = ug.getUserFromEmail("joern.muehlencord@wincor-nixdorf.com"); SPUser user = ug.getUserFromEmail("joern.muehlencord@wincor-nixdorf.com");
@ -58,7 +58,7 @@ public class SPUserGroupTest extends BaseTest {
} }
@Test @Test
@Ignore // Depends on available sharepoint currently @Disabled // Depends on available sharepoint currently
public void getUserFromEmail() throws Exception { public void getUserFromEmail() throws Exception {
SPUserGroup ug = new SPUserGroup(getContext()); SPUserGroup ug = new SPUserGroup(getContext());
String user1Email = "nicole.cravo@wincor-nixdorf.com"; String user1Email = "nicole.cravo@wincor-nixdorf.com";

View File

@ -22,8 +22,8 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>junit</artifactId> <artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -2,8 +2,6 @@ package de.muehlencord.shared.util;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.text.ParseException; import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;

View File

@ -7,8 +7,9 @@ package de.muehlencord.shared.util;
import static de.muehlencord.shared.util.OSUtil.getOperationSystem; import static de.muehlencord.shared.util.OSUtil.getOperationSystem;
import static java.lang.System.getProperties; import static java.lang.System.getProperties;
import org.junit.Test; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.fail;
import org.junit.jupiter.api.Test;
/** /**
* *

View File

@ -6,8 +6,8 @@
package de.muehlencord.shared.util; package de.muehlencord.shared.util;
import org.junit.Test; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.Assert.*; import org.junit.jupiter.api.Test;
/** /**
* *

View File

@ -3,8 +3,8 @@ package de.muehlencord.shared.util;
import static de.muehlencord.shared.util.StringUtil.getValueBetweenKeywords; import static de.muehlencord.shared.util.StringUtil.getValueBetweenKeywords;
import java.io.IOException; import java.io.IOException;
import java.text.ParseException; import java.text.ParseException;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** /**
* Basic StringUtilTests * Basic StringUtilTests
@ -18,6 +18,6 @@ public class StringUtilTest extends DefaultTest {
String content = readContentFromFile("test.txt"); String content = readContentFromFile("test.txt");
String ipAddress = getValueBetweenKeywords(content, "The IP", "has just"); String ipAddress = getValueBetweenKeywords(content, "The IP", "has just");
assertEquals("ipAddress", "222.184.230.118", ipAddress); assertEquals("222.184.230.118", ipAddress, "ipAddress");
} }
} }

View File

@ -7,8 +7,8 @@ import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import org.junit.Ignore; import org.junit.jupiter.api.Disabled;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** /**
* *
@ -22,7 +22,7 @@ public class FileUtilTest {
* @throws URISyntaxException if the testfile specification is wrong * @throws URISyntaxException if the testfile specification is wrong
*/ */
@Test @Test
@Ignore @Disabled
public void testGetFilesFromDirecotry() throws FileHandlingException, URISyntaxException { public void testGetFilesFromDirecotry() throws FileHandlingException, URISyntaxException {
System.out.println("testGetFilesFromDirectory"); System.out.println("testGetFilesFromDirectory");