Group testing modules (#3014)
* move security content from spring-security-rest-full * swagger update * move query language to new module * rename spring-security-rest-full to spring-rest-full * group persistence modules * group testing modules * try fix conflict
This commit is contained in:
committed by
GitHub
parent
b383d83bf4
commit
776a01429e
@@ -1,41 +0,0 @@
|
||||
package com.baeldung.junit5.mockito;
|
||||
|
||||
public class User {
|
||||
|
||||
private Integer id;
|
||||
private String name;
|
||||
private int age;
|
||||
|
||||
public User() {
|
||||
}
|
||||
|
||||
public User(String name, int age) {
|
||||
this.name = name;
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public int getAge() {
|
||||
return age;
|
||||
}
|
||||
public void setAge(int age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "User [id=" + id + ", name=" + name + ", age=" + age + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.baeldung.junit5.mockito.repository;
|
||||
|
||||
import com.baeldung.junit5.mockito.User;
|
||||
|
||||
public interface MailClient {
|
||||
|
||||
void sendUserRegistrationMail(User user);
|
||||
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.baeldung.junit5.mockito.repository;
|
||||
|
||||
public interface SettingRepository {
|
||||
|
||||
int getUserMinAge();
|
||||
|
||||
int getUserNameMinLength();
|
||||
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package com.baeldung.junit5.mockito.repository;
|
||||
|
||||
import com.baeldung.junit5.mockito.User;
|
||||
|
||||
public interface UserRepository {
|
||||
|
||||
User insert(User user);
|
||||
boolean isUsernameAlreadyExists(String userName);
|
||||
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package com.baeldung.junit5.mockito.service;
|
||||
|
||||
import com.baeldung.junit5.mockito.User;
|
||||
import com.baeldung.junit5.mockito.repository.MailClient;
|
||||
import com.baeldung.junit5.mockito.repository.SettingRepository;
|
||||
import com.baeldung.junit5.mockito.repository.UserRepository;
|
||||
|
||||
public class DefaultUserService implements UserService {
|
||||
|
||||
private UserRepository userRepository;
|
||||
private SettingRepository settingRepository;
|
||||
private MailClient mailClient;
|
||||
|
||||
public DefaultUserService(UserRepository userRepository, SettingRepository settingRepository, MailClient mailClient) {
|
||||
this.userRepository = userRepository;
|
||||
this.settingRepository = settingRepository;
|
||||
this.mailClient = mailClient;
|
||||
}
|
||||
|
||||
@Override
|
||||
public User register(User user) {
|
||||
validate(user);
|
||||
User insertedUser = userRepository.insert(user);
|
||||
mailClient.sendUserRegistrationMail(insertedUser);
|
||||
return insertedUser;
|
||||
}
|
||||
|
||||
private void validate(User user) {
|
||||
if(user.getName() == null) {
|
||||
throw new RuntimeException(Errors.USER_NAME_REQUIRED);
|
||||
}
|
||||
|
||||
if(user.getName().length() < settingRepository.getUserNameMinLength()) {
|
||||
throw new RuntimeException(Errors.USER_NAME_SHORT);
|
||||
}
|
||||
|
||||
if(user.getAge() < settingRepository.getUserMinAge()) {
|
||||
throw new RuntimeException(Errors.USER_AGE_YOUNG);
|
||||
}
|
||||
|
||||
if(userRepository.isUsernameAlreadyExists(user.getName())) {
|
||||
throw new RuntimeException(Errors.USER_NAME_DUPLICATE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package com.baeldung.junit5.mockito.service;
|
||||
|
||||
public class Errors {
|
||||
|
||||
public static final String USER_NAME_REQUIRED = "user.name.required";
|
||||
public static final String USER_NAME_SHORT = "user.name.short";
|
||||
public static final String USER_AGE_YOUNG = "user.age.young";
|
||||
public static final String USER_NAME_DUPLICATE = "user.name.duplicate";
|
||||
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.baeldung.junit5.mockito.service;
|
||||
|
||||
import com.baeldung.junit5.mockito.User;
|
||||
|
||||
public interface UserService {
|
||||
|
||||
User register(User user);
|
||||
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.baeldung;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class AssertionUnitTest {
|
||||
|
||||
@Test
|
||||
public void testConvertToDoubleThrowException() {
|
||||
String age = "eighteen";
|
||||
assertThrows(NumberFormatException.class, () -> {
|
||||
convertToInt(age);
|
||||
});
|
||||
|
||||
assertThrows(NumberFormatException.class, () -> {
|
||||
convertToInt(age);
|
||||
});
|
||||
}
|
||||
|
||||
private static Integer convertToInt(String str) {
|
||||
if (str == null) {
|
||||
return null;
|
||||
}
|
||||
return Integer.valueOf(str);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.baeldung;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assumptions.assumeFalse;
|
||||
import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
||||
import static org.junit.jupiter.api.Assumptions.assumingThat;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class AssumptionUnitTest {
|
||||
|
||||
@Test
|
||||
void trueAssumption() {
|
||||
assumeTrue(5 > 1);
|
||||
assertEquals(5 + 2, 7);
|
||||
}
|
||||
|
||||
@Test
|
||||
void falseAssumption() {
|
||||
assumeFalse(5 < 1);
|
||||
assertEquals(5 + 2, 7);
|
||||
}
|
||||
|
||||
@Test
|
||||
void assumptionThat() {
|
||||
String someString = "Just a string";
|
||||
assumingThat(someString.equals("Just a string"), () -> assertEquals(2 + 2, 4));
|
||||
}
|
||||
}
|
||||
@@ -1,126 +0,0 @@
|
||||
package com.baeldung;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.IntStream;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.junit.jupiter.api.DynamicTest;
|
||||
import org.junit.jupiter.api.TestFactory;
|
||||
import org.junit.jupiter.api.function.ThrowingConsumer;
|
||||
|
||||
import com.baeldung.helpers.Employee;
|
||||
import com.baeldung.helpers.EmployeeDao;
|
||||
|
||||
public class DynamicTestsExample {
|
||||
|
||||
@TestFactory
|
||||
Collection<DynamicTest> dynamicTestsWithCollection() {
|
||||
return Arrays.asList(DynamicTest.dynamicTest("Add test", () -> assertEquals(2, Math.addExact(1, 1))), DynamicTest.dynamicTest("Multiply Test", () -> assertEquals(4, Math.multiplyExact(2, 2))));
|
||||
}
|
||||
|
||||
@TestFactory
|
||||
Iterable<DynamicTest> dynamicTestsWithIterable() {
|
||||
return Arrays.asList(DynamicTest.dynamicTest("Add test", () -> assertEquals(2, Math.addExact(1, 1))), DynamicTest.dynamicTest("Multiply Test", () -> assertEquals(4, Math.multiplyExact(2, 2))));
|
||||
}
|
||||
|
||||
@TestFactory
|
||||
Iterator<DynamicTest> dynamicTestsWithIterator() {
|
||||
return Arrays.asList(DynamicTest.dynamicTest("Add test", () -> assertEquals(2, Math.addExact(1, 1))), DynamicTest.dynamicTest("Multiply Test", () -> assertEquals(4, Math.multiplyExact(2, 2))))
|
||||
.iterator();
|
||||
}
|
||||
|
||||
@TestFactory
|
||||
Stream<DynamicTest> dynamicTestsFromIntStream() {
|
||||
return IntStream.iterate(0, n -> n + 2)
|
||||
.limit(10)
|
||||
.mapToObj(n -> DynamicTest.dynamicTest("test" + n, () -> assertTrue(n % 2 == 0)));
|
||||
}
|
||||
|
||||
@TestFactory
|
||||
Stream<DynamicTest> dynamicTestsFromStream() {
|
||||
|
||||
// sample input and output
|
||||
List<String> inputList = Arrays.asList("www.somedomain.com", "www.anotherdomain.com", "www.yetanotherdomain.com");
|
||||
List<String> outputList = Arrays.asList("154.174.10.56", "211.152.104.132", "178.144.120.156");
|
||||
|
||||
// input generator that generates inputs using inputList
|
||||
Iterator<String> inputGenerator = inputList.iterator();
|
||||
|
||||
// a display name generator that creates a different name based on the input
|
||||
Function<String, String> displayNameGenerator = (input) -> "Resolving: " + input;
|
||||
|
||||
// the test executor, which actually has the logic of how to execute the test case
|
||||
DomainNameResolver resolver = new DomainNameResolver();
|
||||
ThrowingConsumer<String> testExecutor = (input) -> {
|
||||
int id = inputList.indexOf(input);
|
||||
assertEquals(outputList.get(id), resolver.resolveDomain(input));
|
||||
};
|
||||
|
||||
// combine everything and return a Stream of DynamicTest
|
||||
return DynamicTest.stream(inputGenerator, displayNameGenerator, testExecutor);
|
||||
}
|
||||
|
||||
@TestFactory
|
||||
Stream<DynamicTest> dynamicTestsFromStreamInJava8() {
|
||||
|
||||
DomainNameResolver resolver = new DomainNameResolver();
|
||||
|
||||
List<String> inputList = Arrays.asList("www.somedomain.com", "www.anotherdomain.com", "www.yetanotherdomain.com");
|
||||
List<String> outputList = Arrays.asList("154.174.10.56", "211.152.104.132", "178.144.120.156");
|
||||
|
||||
return inputList.stream()
|
||||
.map(dom -> DynamicTest.dynamicTest("Resolving: " + dom, () -> {
|
||||
int id = inputList.indexOf(dom);
|
||||
assertEquals(outputList.get(id), resolver.resolveDomain(dom));
|
||||
}));
|
||||
|
||||
}
|
||||
|
||||
@TestFactory
|
||||
Stream<DynamicTest> dynamicTestsForEmployeeWorkflows() {
|
||||
List<Employee> inputList = Arrays.asList(new Employee(1, "Fred"), new Employee(2), new Employee(3, "John"));
|
||||
|
||||
EmployeeDao dao = new EmployeeDao();
|
||||
Stream<DynamicTest> saveEmployeeStream = inputList.stream()
|
||||
.map(emp -> DynamicTest.dynamicTest("saveEmployee: " + emp.toString(), () -> {
|
||||
Employee returned = dao.save(emp.getId());
|
||||
assertEquals(returned.getId(), emp.getId());
|
||||
}));
|
||||
|
||||
Stream<DynamicTest> saveEmployeeWithFirstNameStream = inputList.stream()
|
||||
.filter(emp -> !emp.getFirstName()
|
||||
.isEmpty())
|
||||
.map(emp -> DynamicTest.dynamicTest("saveEmployeeWithName" + emp.toString(), () -> {
|
||||
Employee returned = dao.save(emp.getId(), emp.getFirstName());
|
||||
assertEquals(returned.getId(), emp.getId());
|
||||
assertEquals(returned.getFirstName(), emp.getFirstName());
|
||||
}));
|
||||
|
||||
return Stream.concat(saveEmployeeStream, saveEmployeeWithFirstNameStream);
|
||||
}
|
||||
|
||||
class DomainNameResolver {
|
||||
|
||||
private Map<String, String> ipByDomainName = new HashMap<>();
|
||||
|
||||
DomainNameResolver() {
|
||||
this.ipByDomainName.put("www.somedomain.com", "154.174.10.56");
|
||||
this.ipByDomainName.put("www.anotherdomain.com", "211.152.104.132");
|
||||
this.ipByDomainName.put("www.yetanotherdomain.com", "178.144.120.156");
|
||||
}
|
||||
|
||||
public String resolveDomain(String domainName) {
|
||||
return ipByDomainName.get(domainName);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
package com.baeldung;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import com.baeldung.extensions.EmployeeDaoParameterResolver;
|
||||
import com.baeldung.extensions.EmployeeDatabaseSetupExtension;
|
||||
import com.baeldung.extensions.EnvironmentExtension;
|
||||
import com.baeldung.extensions.IgnoreFileNotFoundExceptionExtension;
|
||||
import com.baeldung.extensions.LoggingExtension;
|
||||
import com.baeldung.helpers.Employee;
|
||||
import com.baeldung.helpers.EmployeeJdbcDao;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@ExtendWith({ EnvironmentExtension.class, EmployeeDatabaseSetupExtension.class, EmployeeDaoParameterResolver.class })
|
||||
@ExtendWith(LoggingExtension.class)
|
||||
@ExtendWith(IgnoreFileNotFoundExceptionExtension.class)
|
||||
public class EmployeesTest {
|
||||
|
||||
private EmployeeJdbcDao employeeDao;
|
||||
|
||||
private Logger logger;
|
||||
|
||||
public EmployeesTest(EmployeeJdbcDao employeeDao) {
|
||||
this.employeeDao = employeeDao;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenAddEmployee_thenGetEmployee() throws SQLException {
|
||||
Employee emp = new Employee(1, "john");
|
||||
employeeDao.add(emp);
|
||||
assertEquals(1, employeeDao.findAll()
|
||||
.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGetEmployees_thenEmptyList() throws SQLException {
|
||||
assertEquals(0, employeeDao.findAll()
|
||||
.size());
|
||||
}
|
||||
|
||||
public void setLogger(Logger logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.baeldung;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class ExceptionUnitTest {
|
||||
|
||||
@Test
|
||||
void shouldThrowException() {
|
||||
Throwable exception = assertThrows(UnsupportedOperationException.class, () -> {
|
||||
throw new UnsupportedOperationException("Not supported");
|
||||
});
|
||||
assertEquals(exception.getMessage(), "Not supported");
|
||||
}
|
||||
|
||||
@Test
|
||||
void assertThrowsException() {
|
||||
String str = null;
|
||||
assertThrows(IllegalArgumentException.class, () -> {
|
||||
Integer.valueOf(str);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package com.baeldung;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class FirstUnitTest {
|
||||
|
||||
@Test
|
||||
void lambdaExpressions() {
|
||||
List<Integer> numbers = Arrays.asList(1, 2, 3);
|
||||
assertTrue(numbers.stream()
|
||||
.mapToInt(i -> i)
|
||||
.sum() > 5, "Sum should be greater than 5");
|
||||
}
|
||||
|
||||
@Disabled("test to show MultipleFailuresError")
|
||||
@Test
|
||||
void groupAssertions() {
|
||||
int[] numbers = { 0, 1, 2, 3, 4 };
|
||||
assertAll("numbers", () -> assertEquals(numbers[0], 1), () -> assertEquals(numbers[3], 3), () -> assertEquals(numbers[4], 1));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
void disabledTest() {
|
||||
assertTrue(false);
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
package com.baeldung;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
//@RunWith(JUnitPlatform.class)
|
||||
public class JUnit5NewFeaturesUnitTest {
|
||||
|
||||
private static final Logger log = Logger.getLogger(JUnit5NewFeaturesUnitTest.class.getName());
|
||||
|
||||
@BeforeAll
|
||||
static void setup() {
|
||||
log.info("@BeforeAll - executes once before all test methods in this class");
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
void init() {
|
||||
log.info("@BeforeEach - executes before each test method in this class");
|
||||
}
|
||||
|
||||
@DisplayName("Single test successful")
|
||||
@Test
|
||||
void testSingleSuccessTest() {
|
||||
log.info("Success");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled("Not implemented yet.")
|
||||
void testShowSomething() {
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void tearDown() {
|
||||
log.info("@AfterEach - executed after each test method.");
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
static void done() {
|
||||
log.info("@AfterAll - executed after all test methods.");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package com.baeldung;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.junit.jupiter.api.DynamicTest;
|
||||
import org.junit.jupiter.api.TestFactory;
|
||||
|
||||
public class LiveTest {
|
||||
|
||||
private List<String> in = new ArrayList<>(Arrays.asList("Hello", "Yes", "No"));
|
||||
private List<String> out = new ArrayList<>(Arrays.asList("Cześć", "Tak", "Nie"));
|
||||
|
||||
@TestFactory
|
||||
public Stream<DynamicTest> translateDynamicTestsFromStream() {
|
||||
|
||||
return in.stream()
|
||||
.map(word -> DynamicTest.dynamicTest("Test translate " + word, () -> {
|
||||
int id = in.indexOf(word);
|
||||
assertEquals(out.get(id), translate(word));
|
||||
}));
|
||||
}
|
||||
|
||||
private String translate(String word) {
|
||||
if ("Hello".equalsIgnoreCase(word)) {
|
||||
return "Cześć";
|
||||
} else if ("Yes".equalsIgnoreCase(word)) {
|
||||
return "Tak";
|
||||
} else if ("No".equalsIgnoreCase(word)) {
|
||||
return "Nie";
|
||||
}
|
||||
return "Error";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
package com.baeldung;
|
||||
|
||||
import java.util.EmptyStackException;
|
||||
import java.util.Stack;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class NestedUnitTest {
|
||||
Stack<Object> stack;
|
||||
boolean isRun = false;
|
||||
|
||||
@Test
|
||||
@DisplayName("is instantiated with new Stack()")
|
||||
void isInstantiatedWithNew() {
|
||||
new Stack<Object>();
|
||||
}
|
||||
|
||||
@Nested
|
||||
@DisplayName("when new")
|
||||
class WhenNew {
|
||||
|
||||
@BeforeEach
|
||||
void init() {
|
||||
stack = new Stack<Object>();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("is empty")
|
||||
void isEmpty() {
|
||||
Assertions.assertTrue(stack.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("throws EmptyStackException when popped")
|
||||
void throwsExceptionWhenPopped() {
|
||||
Assertions.assertThrows(EmptyStackException.class, () -> stack.pop());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("throws EmptyStackException when peeked")
|
||||
void throwsExceptionWhenPeeked() {
|
||||
Assertions.assertThrows(EmptyStackException.class, () -> stack.peek());
|
||||
}
|
||||
|
||||
@Nested
|
||||
@DisplayName("after pushing an element")
|
||||
class AfterPushing {
|
||||
|
||||
String anElement = "an element";
|
||||
|
||||
@BeforeEach
|
||||
void init() {
|
||||
stack.push(anElement);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("it is no longer empty")
|
||||
void isEmpty() {
|
||||
Assertions.assertFalse(stack.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("returns the element when popped and is empty")
|
||||
void returnElementWhenPopped() {
|
||||
Assertions.assertEquals(anElement, stack.pop());
|
||||
Assertions.assertTrue(stack.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("returns the element when peeked but remains not empty")
|
||||
void returnElementWhenPeeked() {
|
||||
Assertions.assertEquals(anElement, stack.peek());
|
||||
Assertions.assertFalse(stack.isEmpty());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
package com.baeldung;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.RepeatedTest;
|
||||
import org.junit.jupiter.api.RepetitionInfo;
|
||||
import org.junit.jupiter.api.TestInfo;
|
||||
|
||||
public class RepeatedTestExample {
|
||||
|
||||
@BeforeEach
|
||||
void beforeEachTest() {
|
||||
System.out.println("Before Each Test");
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void afterEachTest() {
|
||||
System.out.println("After Each Test");
|
||||
System.out.println("=====================");
|
||||
}
|
||||
|
||||
@RepeatedTest(3)
|
||||
void repeatedTest(TestInfo testInfo) {
|
||||
System.out.println("Executing repeated test");
|
||||
assertEquals(2, Math.addExact(1, 1), "1 + 1 should equal 2");
|
||||
}
|
||||
|
||||
@RepeatedTest(value = 3, name = RepeatedTest.LONG_DISPLAY_NAME)
|
||||
void repeatedTestWithLongName() {
|
||||
System.out.println("Executing repeated test with long name");
|
||||
assertEquals(2, Math.addExact(1, 1), "1 + 1 should equal 2");
|
||||
}
|
||||
|
||||
@RepeatedTest(value = 3, name = RepeatedTest.SHORT_DISPLAY_NAME)
|
||||
void repeatedTestWithShortName() {
|
||||
System.out.println("Executing repeated test with long name");
|
||||
assertEquals(2, Math.addExact(1, 1), "1 + 1 should equal 2");
|
||||
}
|
||||
|
||||
@RepeatedTest(value = 3, name = "Custom name {currentRepetition}/{totalRepetitions}")
|
||||
void repeatedTestWithCustomDisplayName() {
|
||||
assertEquals(2, Math.addExact(1, 1), "1 + 1 should equal 2");
|
||||
}
|
||||
|
||||
@RepeatedTest(3)
|
||||
void repeatedTestWithRepetitionInfo(RepetitionInfo repetitionInfo) {
|
||||
System.out.println("Repetition #" + repetitionInfo.getCurrentRepetition());
|
||||
assertEquals(3, repetitionInfo.getTotalRepetitions());
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.baeldung;
|
||||
|
||||
public final class StringUtils {
|
||||
|
||||
public static Double convertToDouble(String str) {
|
||||
if (str == null) {
|
||||
return null;
|
||||
}
|
||||
return Double.valueOf(str);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.baeldung;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@Tag("Test case")
|
||||
public class TaggedUnitTest {
|
||||
|
||||
@Test
|
||||
@Tag("Method")
|
||||
void testMethod() {
|
||||
assertEquals(2 + 2, 4);
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package com.baeldung;
|
||||
|
||||
import org.junit.platform.launcher.LauncherDiscoveryRequest;
|
||||
import org.junit.platform.launcher.TestExecutionListener;
|
||||
import org.junit.platform.launcher.TestPlan;
|
||||
import org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder;
|
||||
import org.junit.platform.launcher.core.LauncherFactory;
|
||||
import org.junit.platform.launcher.listeners.SummaryGeneratingListener;
|
||||
|
||||
import static org.junit.platform.engine.discovery.DiscoverySelectors.selectClass;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import org.junit.platform.launcher.Launcher;
|
||||
|
||||
public class TestLauncher {
|
||||
public static void main(String[] args) {
|
||||
|
||||
//@formatter:off
|
||||
LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request()
|
||||
.selectors(selectClass("com.baeldung.EmployeesTest"))
|
||||
.configurationParameter("junit.conditions.deactivate", "com.baeldung.extensions.*")
|
||||
.configurationParameter("junit.extensions.autodetection.enabled", "true")
|
||||
.build();
|
||||
|
||||
//@formatter:on
|
||||
|
||||
TestPlan plan = LauncherFactory.create()
|
||||
.discover(request);
|
||||
Launcher launcher = LauncherFactory.create();
|
||||
SummaryGeneratingListener summaryGeneratingListener = new SummaryGeneratingListener();
|
||||
launcher.execute(request, new TestExecutionListener[] { summaryGeneratingListener });
|
||||
launcher.execute(request);
|
||||
|
||||
summaryGeneratingListener.getSummary()
|
||||
.printTo(new PrintWriter(System.out));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.baeldung.extensions;
|
||||
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.junit.jupiter.api.extension.ParameterContext;
|
||||
import org.junit.jupiter.api.extension.ParameterResolutionException;
|
||||
import org.junit.jupiter.api.extension.ParameterResolver;
|
||||
|
||||
import com.baeldung.helpers.EmployeeJdbcDao;
|
||||
import com.baeldung.helpers.JdbcConnectionUtil;
|
||||
|
||||
public class EmployeeDaoParameterResolver implements ParameterResolver {
|
||||
|
||||
@Override
|
||||
public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
|
||||
return parameterContext.getParameter()
|
||||
.getType()
|
||||
.equals(EmployeeJdbcDao.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
|
||||
return new EmployeeJdbcDao(JdbcConnectionUtil.getConnection());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package com.baeldung.extensions;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Savepoint;
|
||||
|
||||
import org.junit.jupiter.api.extension.AfterAllCallback;
|
||||
import org.junit.jupiter.api.extension.AfterEachCallback;
|
||||
import org.junit.jupiter.api.extension.BeforeAllCallback;
|
||||
import org.junit.jupiter.api.extension.BeforeEachCallback;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
|
||||
import com.baeldung.helpers.EmployeeJdbcDao;
|
||||
import com.baeldung.helpers.JdbcConnectionUtil;
|
||||
|
||||
public class EmployeeDatabaseSetupExtension implements BeforeAllCallback, AfterAllCallback, BeforeEachCallback, AfterEachCallback {
|
||||
|
||||
private Connection con = JdbcConnectionUtil.getConnection();
|
||||
private EmployeeJdbcDao employeeDao = new EmployeeJdbcDao(con);
|
||||
private Savepoint savepoint;
|
||||
|
||||
@Override
|
||||
public void afterAll(ExtensionContext context) throws SQLException {
|
||||
if (con != null) {
|
||||
con.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeAll(ExtensionContext context) throws SQLException {
|
||||
employeeDao.createTable();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterEach(ExtensionContext context) throws SQLException {
|
||||
con.rollback(savepoint);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeEach(ExtensionContext context) throws SQLException {
|
||||
con.setAutoCommit(false);
|
||||
savepoint = con.setSavepoint("before");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.baeldung.extensions;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.junit.jupiter.api.extension.ConditionEvaluationResult;
|
||||
import org.junit.jupiter.api.extension.ExecutionCondition;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
|
||||
public class EnvironmentExtension implements ExecutionCondition {
|
||||
|
||||
@Override
|
||||
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
|
||||
Properties props = new Properties();
|
||||
|
||||
try {
|
||||
props.load(EnvironmentExtension.class.getResourceAsStream("application.properties"));
|
||||
String env = props.getProperty("env");
|
||||
if ("qa".equalsIgnoreCase(env)) {
|
||||
return ConditionEvaluationResult.disabled("Test disabled on QA environment");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return ConditionEvaluationResult.enabled("Test enabled on QA environment");
|
||||
}
|
||||
}
|
||||
-23
@@ -1,23 +0,0 @@
|
||||
package com.baeldung.extensions;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.junit.jupiter.api.extension.TestExecutionExceptionHandler;
|
||||
|
||||
public class IgnoreFileNotFoundExceptionExtension implements TestExecutionExceptionHandler {
|
||||
|
||||
Logger logger = LogManager.getLogger(IgnoreFileNotFoundExceptionExtension.class);
|
||||
|
||||
@Override
|
||||
public void handleTestExecutionException(ExtensionContext context, Throwable throwable) throws Throwable {
|
||||
|
||||
if (throwable instanceof FileNotFoundException) {
|
||||
logger.error("File not found:" + throwable.getMessage());
|
||||
return;
|
||||
}
|
||||
throw throwable;
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.baeldung.extensions;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.junit.jupiter.api.extension.TestInstancePostProcessor;
|
||||
|
||||
public class LoggingExtension implements TestInstancePostProcessor {
|
||||
|
||||
@Override
|
||||
public void postProcessTestInstance(Object testInstance, ExtensionContext context) throws Exception {
|
||||
Logger logger = LogManager.getLogger(testInstance.getClass());
|
||||
testInstance.getClass()
|
||||
.getMethod("setLogger", Logger.class)
|
||||
.invoke(testInstance, logger);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package com.baeldung.helpers;
|
||||
|
||||
public class Employee {
|
||||
|
||||
private long id;
|
||||
private String firstName;
|
||||
|
||||
public Employee(long id) {
|
||||
this.id = id;
|
||||
this.firstName = "";
|
||||
}
|
||||
|
||||
public Employee(long id, String firstName) {
|
||||
this.id = id;
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Employee [id=" + id + ", firstName=" + firstName + "]";
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.baeldung.helpers;
|
||||
|
||||
public class EmployeeDao {
|
||||
|
||||
public Employee save(long id) {
|
||||
return new Employee(id);
|
||||
}
|
||||
|
||||
public Employee save(long id, String firstName) {
|
||||
return new Employee(id, firstName);
|
||||
}
|
||||
|
||||
public Employee update(Employee employee) {
|
||||
return employee;
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package com.baeldung.helpers;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class EmployeeJdbcDao {
|
||||
|
||||
private Connection con;
|
||||
|
||||
public EmployeeJdbcDao(Connection con) {
|
||||
this.con = con;
|
||||
}
|
||||
|
||||
public void createTable() throws SQLException {
|
||||
String createQuery = "CREATE TABLE employees(id long primary key, firstName varchar(50))";
|
||||
PreparedStatement pstmt = con.prepareStatement(createQuery);
|
||||
|
||||
pstmt.execute();
|
||||
}
|
||||
|
||||
public void add(Employee emp) throws SQLException {
|
||||
String insertQuery = "INSERT INTO employees(id, firstName) VALUES(?,?)";
|
||||
PreparedStatement pstmt = con.prepareStatement(insertQuery);
|
||||
pstmt.setLong(1, emp.getId());
|
||||
pstmt.setString(2, emp.getFirstName());
|
||||
|
||||
pstmt.executeUpdate();
|
||||
|
||||
}
|
||||
|
||||
public List<Employee> findAll() throws SQLException {
|
||||
List<Employee> employees = new ArrayList<>();
|
||||
String query = "SELECT * FROM employees";
|
||||
PreparedStatement pstmt = con.prepareStatement(query);
|
||||
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
while (rs.next()) {
|
||||
Employee emp = new Employee(rs.getLong("id"), rs.getString("firstName"));
|
||||
employees.add(emp);
|
||||
}
|
||||
|
||||
return employees;
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package com.baeldung.helpers;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Properties;
|
||||
|
||||
public class JdbcConnectionUtil {
|
||||
|
||||
private static Connection con;
|
||||
|
||||
public static Connection getConnection() {
|
||||
if (con == null) {
|
||||
try {
|
||||
Properties props = new Properties();
|
||||
props.load(JdbcConnectionUtil.class.getResourceAsStream("jdbc.properties"));
|
||||
Class.forName(props.getProperty("jdbc.driver"));
|
||||
con = DriverManager.getConnection(props.getProperty("jdbc.url"), props.getProperty("jdbc.user"), props.getProperty("jdbc.password"));
|
||||
return con;
|
||||
} catch (IOException exc) {
|
||||
exc.printStackTrace();
|
||||
} catch (ClassNotFoundException exc) {
|
||||
exc.printStackTrace();
|
||||
} catch (SQLException exc) {
|
||||
exc.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return con;
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015-2016 the original author or authors.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials are
|
||||
* made available under the terms of the Eclipse Public License v1.0 which
|
||||
* accompanies this distribution and is available at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
|
||||
package com.baeldung.junit5.mockito;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import java.lang.reflect.Parameter;
|
||||
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext.Namespace;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext.Store;
|
||||
import org.junit.jupiter.api.extension.ParameterContext;
|
||||
import org.junit.jupiter.api.extension.ParameterResolver;
|
||||
import org.junit.jupiter.api.extension.TestInstancePostProcessor;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.mockito.Mock;
|
||||
|
||||
/**
|
||||
* {@code MockitoExtension} showcases the {@link TestInstancePostProcessor}
|
||||
* and {@link ParameterResolver} extension APIs of JUnit 5 by providing
|
||||
* dependency injection support at the field level and at the method parameter
|
||||
* level via Mockito 2.x's {@link Mock @Mock} annotation.
|
||||
*
|
||||
* @since 5.0
|
||||
*/
|
||||
public class MockitoExtension implements TestInstancePostProcessor, ParameterResolver {
|
||||
|
||||
@Override
|
||||
public void postProcessTestInstance(Object testInstance, ExtensionContext context) {
|
||||
MockitoAnnotations.initMocks(testInstance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) {
|
||||
return parameterContext.getParameter().isAnnotationPresent(Mock.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) {
|
||||
return getMock(parameterContext.getParameter(), extensionContext);
|
||||
}
|
||||
|
||||
private Object getMock(Parameter parameter, ExtensionContext extensionContext) {
|
||||
Class<?> mockType = parameter.getType();
|
||||
Store mocks = extensionContext.getStore(Namespace.create(MockitoExtension.class, mockType));
|
||||
String mockName = getMockName(parameter);
|
||||
|
||||
if (mockName != null) {
|
||||
return mocks.getOrComputeIfAbsent(mockName, key -> mock(mockType, mockName));
|
||||
}
|
||||
else {
|
||||
return mocks.getOrComputeIfAbsent(mockType.getCanonicalName(), key -> mock(mockType));
|
||||
}
|
||||
}
|
||||
|
||||
private String getMockName(Parameter parameter) {
|
||||
String explicitMockName = parameter.getAnnotation(Mock.class).name().trim();
|
||||
if (!explicitMockName.isEmpty()) {
|
||||
return explicitMockName;
|
||||
}
|
||||
else if (parameter.isNamePresent()) {
|
||||
return parameter.getName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,122 +0,0 @@
|
||||
package com.baeldung.junit5.mockito;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.platform.runner.JUnitPlatform;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import com.baeldung.junit5.mockito.repository.MailClient;
|
||||
import com.baeldung.junit5.mockito.repository.SettingRepository;
|
||||
import com.baeldung.junit5.mockito.repository.UserRepository;
|
||||
import com.baeldung.junit5.mockito.service.DefaultUserService;
|
||||
import com.baeldung.junit5.mockito.service.Errors;
|
||||
import com.baeldung.junit5.mockito.service.UserService;
|
||||
|
||||
@RunWith(JUnitPlatform.class)
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class UserServiceUnitTest {
|
||||
|
||||
UserService userService;
|
||||
@Mock UserRepository userRepository;
|
||||
|
||||
User user;
|
||||
|
||||
@BeforeEach
|
||||
void init(@Mock SettingRepository settingRepository, @Mock MailClient mailClient) {
|
||||
userService = new DefaultUserService(userRepository, settingRepository, mailClient);
|
||||
when(settingRepository.getUserMinAge()).thenReturn(10);
|
||||
when(settingRepository.getUserNameMinLength()).thenReturn(4);
|
||||
when(userRepository.isUsernameAlreadyExists(any(String.class))).thenReturn(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenValidUser_whenSaveUser_thenSucceed(@Mock MailClient mailClient) {
|
||||
// Given
|
||||
user = new User("Jerry", 12);
|
||||
when(userRepository.insert(any(User.class))).then(new Answer<User>() {
|
||||
int sequence = 1;
|
||||
|
||||
@Override
|
||||
public User answer(InvocationOnMock invocation) throws Throwable {
|
||||
User user = (User) invocation.getArgument(0);
|
||||
user.setId(sequence++);
|
||||
return user;
|
||||
}
|
||||
});
|
||||
|
||||
// When
|
||||
User insertedUser = userService.register(user);
|
||||
|
||||
// Then
|
||||
verify(userRepository).insert(user);
|
||||
Assertions.assertNotNull(user.getId());
|
||||
verify(mailClient).sendUserRegistrationMail(insertedUser);
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenShortName_whenSaveUser_thenGiveShortUsernameError() {
|
||||
// Given
|
||||
user = new User("tom", 12);
|
||||
|
||||
// When
|
||||
try {
|
||||
userService.register(user);
|
||||
fail("Should give an error");
|
||||
} catch(Exception ex) {
|
||||
assertEquals(ex.getMessage(), Errors.USER_NAME_SHORT);
|
||||
}
|
||||
|
||||
// Then
|
||||
verify(userRepository, never()).insert(user);
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenSmallAge_whenSaveUser_thenGiveYoungUserError() {
|
||||
// Given
|
||||
user = new User("jerry", 3);
|
||||
|
||||
// When
|
||||
try {
|
||||
userService.register(user);
|
||||
fail("Should give an error");
|
||||
} catch(Exception ex) {
|
||||
assertEquals(ex.getMessage(), Errors.USER_AGE_YOUNG);
|
||||
}
|
||||
|
||||
// Then
|
||||
verify(userRepository, never()).insert(user);
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenUserWithExistingName_whenSaveUser_thenGiveUsernameAlreadyExistsError() {
|
||||
// Given
|
||||
user = new User("jerry", 12);
|
||||
Mockito.reset(userRepository);
|
||||
when(userRepository.isUsernameAlreadyExists(any(String.class))).thenReturn(true);
|
||||
|
||||
// When
|
||||
try {
|
||||
userService.register(user);
|
||||
fail("Should give an error");
|
||||
} catch(Exception ex) {
|
||||
assertEquals(ex.getMessage(), Errors.USER_NAME_DUPLICATE);
|
||||
}
|
||||
|
||||
// Then
|
||||
verify(userRepository, never()).insert(user);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package com.baeldung.migration.junit4;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
|
||||
import com.baeldung.migration.junit4.categories.Annotations;
|
||||
import com.baeldung.migration.junit4.categories.JUnit4Tests;
|
||||
|
||||
@Category(value = { Annotations.class, JUnit4Tests.class })
|
||||
public class AnnotationTestExampleTest {
|
||||
@Test(expected = Exception.class)
|
||||
public void shouldRaiseAnException() throws Exception {
|
||||
throw new Exception("This is my expected exception");
|
||||
}
|
||||
|
||||
@Test(timeout = 1)
|
||||
@Ignore
|
||||
public void shouldFailBecauseTimeout() throws InterruptedException {
|
||||
Thread.sleep(10);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.baeldung.migration.junit4;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
public class AssertionsExampleTest {
|
||||
@Test
|
||||
@Ignore
|
||||
public void shouldFailBecauseTheNumbersAreNotEqualld() {
|
||||
assertEquals("Numbers are not equal!", 2, 3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldAssertAllTheGroup() {
|
||||
List<Integer> list = Arrays.asList(1, 2, 3);
|
||||
assertEquals("List is not incremental", list.get(0)
|
||||
.intValue(), 1);
|
||||
assertEquals("List is not incremental", list.get(1)
|
||||
.intValue(), 2);
|
||||
assertEquals("List is not incremental", list.get(2)
|
||||
.intValue(), 3);
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.baeldung.migration.junit4;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.baeldung.migration.junit4.rules.TraceUnitTestRule;
|
||||
|
||||
public class RuleExampleTest {
|
||||
|
||||
@Rule
|
||||
public final TraceUnitTestRule traceRuleTests = new TraceUnitTestRule();
|
||||
|
||||
@Test
|
||||
public void whenTracingTests() {
|
||||
System.out.println("This is my test");
|
||||
/*...*/
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package com.baeldung.migration.junit4.categories;
|
||||
|
||||
public interface Annotations {
|
||||
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package com.baeldung.migration.junit4.categories;
|
||||
|
||||
public interface JUnit4Tests {
|
||||
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.baeldung.migration.junit4.rules;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.rules.TestRule;
|
||||
import org.junit.runner.Description;
|
||||
import org.junit.runners.model.MultipleFailureException;
|
||||
import org.junit.runners.model.Statement;
|
||||
|
||||
public class TraceUnitTestRule implements TestRule {
|
||||
|
||||
@Override
|
||||
public Statement apply(Statement base, Description description) {
|
||||
|
||||
return new Statement() {
|
||||
@Override
|
||||
public void evaluate() throws Throwable {
|
||||
List<Throwable> errors = new ArrayList<Throwable>();
|
||||
|
||||
System.out.println("Starting test ... " + description.getMethodName());
|
||||
try {
|
||||
base.evaluate();
|
||||
} catch (Throwable e) {
|
||||
errors.add(e);
|
||||
} finally {
|
||||
System.out.println("... test finished. " + description.getMethodName());
|
||||
}
|
||||
|
||||
MultipleFailureException.assertEmpty(errors);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.baeldung.migration.junit5;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.platform.runner.JUnitPlatform;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@Tag("annotations")
|
||||
@Tag("junit5")
|
||||
@RunWith(JUnitPlatform.class)
|
||||
public class AnnotationTestExampleTest {
|
||||
@Test
|
||||
public void shouldRaiseAnException() throws Exception {
|
||||
Assertions.assertThrows(Exception.class, () -> {
|
||||
throw new Exception("This is my expected exception");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void shouldFailBecauseTimeout() throws InterruptedException {
|
||||
Assertions.assertTimeout(Duration.ofMillis(1), () -> Thread.sleep(10));
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.baeldung.migration.junit5;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.platform.runner.JUnitPlatform;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@RunWith(JUnitPlatform.class)
|
||||
public class AssertionsExampleTest {
|
||||
@Test
|
||||
@Disabled
|
||||
public void shouldFailBecauseTheNumbersAreNotEqual() {
|
||||
Assertions.assertEquals(2, 3, "Numbers are not equal!");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void shouldFailBecauseItsNotTrue_overloading() {
|
||||
Assertions.assertTrue(() -> {
|
||||
return false;
|
||||
}, () -> "It's not true!");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldAssertAllTheGroup() {
|
||||
List<Integer> list = Arrays.asList(1, 2, 3);
|
||||
|
||||
Assertions.assertAll("List is not incremental", () -> Assertions.assertEquals(list.get(0)
|
||||
.intValue(), 1), () -> Assertions.assertEquals(
|
||||
list.get(1)
|
||||
.intValue(),
|
||||
2),
|
||||
() -> Assertions.assertEquals(list.get(2)
|
||||
.intValue(), 3));
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.baeldung.migration.junit5;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.platform.runner.JUnitPlatform;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import com.baeldung.migration.junit5.extensions.TraceUnitExtension;
|
||||
|
||||
@RunWith(JUnitPlatform.class)
|
||||
@ExtendWith(TraceUnitExtension.class)
|
||||
public class RuleExampleTest {
|
||||
|
||||
@Test
|
||||
public void whenTracingTests() {
|
||||
System.out.println("This is my test");
|
||||
/*...*/
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.baeldung.migration.junit5.extensions;
|
||||
|
||||
import org.junit.jupiter.api.extension.AfterEachCallback;
|
||||
import org.junit.jupiter.api.extension.BeforeEachCallback;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
|
||||
public class TraceUnitExtension implements AfterEachCallback, BeforeEachCallback {
|
||||
|
||||
@Override
|
||||
public void beforeEach(ExtensionContext context) throws Exception {
|
||||
System.out.println("Starting test ... " + context.getDisplayName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterEach(ExtensionContext context) throws Exception {
|
||||
System.out.println("... test finished. " + context.getDisplayName());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
package com.baeldung.param;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.junit.jupiter.api.extension.ParameterContext;
|
||||
import org.junit.jupiter.api.extension.ParameterResolutionException;
|
||||
import org.junit.jupiter.api.extension.ParameterResolver;
|
||||
|
||||
public class InvalidPersonParameterResolver implements ParameterResolver {
|
||||
|
||||
/**
|
||||
* The "bad" (invalid) data for testing purposes has to go somewhere, right?
|
||||
*/
|
||||
public static Person[] INVALID_PERSONS = { new Person().setId(1L)
|
||||
.setLastName("Ad_ams")
|
||||
.setFirstName("Jill,"),
|
||||
new Person().setId(2L)
|
||||
.setLastName(",Baker")
|
||||
.setFirstName(""),
|
||||
new Person().setId(3L)
|
||||
.setLastName(null)
|
||||
.setFirstName(null),
|
||||
new Person().setId(4L)
|
||||
.setLastName("Daniel&")
|
||||
.setFirstName("{Joseph}"),
|
||||
new Person().setId(5L)
|
||||
.setLastName("")
|
||||
.setFirstName("English, Jane"),
|
||||
new Person()/* .setId(6L).setLastName("Fontana").setFirstName("Enrique") */,
|
||||
// TODO: ADD MORE DATA HERE
|
||||
};
|
||||
|
||||
@Override
|
||||
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
|
||||
Object ret = null;
|
||||
//
|
||||
// Return a random, valid Person object if Person.class is the type of Parameter
|
||||
/// to be resolved. Otherwise return null.
|
||||
if (parameterContext.getParameter()
|
||||
.getType() == Person.class) {
|
||||
ret = INVALID_PERSONS[new Random().nextInt(INVALID_PERSONS.length)];
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
|
||||
boolean ret = false;
|
||||
//
|
||||
// If the Parameter.type == Person.class, then we support it, otherwise, get outta here!
|
||||
if (parameterContext.getParameter()
|
||||
.getType() == Person.class) {
|
||||
ret = true;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package com.baeldung.param;
|
||||
|
||||
/**
|
||||
* Very simple Person entity.
|
||||
* Use the Fluent-style interface to set properties.
|
||||
*
|
||||
* @author J Steven Perry
|
||||
*
|
||||
*/
|
||||
public class Person {
|
||||
|
||||
private Long id;
|
||||
private String lastName;
|
||||
private String firstName;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Person setId(Long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public Person setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public Person setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,132 +0,0 @@
|
||||
package com.baeldung.param;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Somewhat contrived validation class to illustrate unit test
|
||||
* concepts.
|
||||
*
|
||||
* @author J Steven Perry
|
||||
*
|
||||
*/
|
||||
public class PersonValidator {
|
||||
|
||||
/**
|
||||
* Contrived checked exception to illustrate one possible
|
||||
* way to handle validation errors (via a checked exception).
|
||||
*
|
||||
* @author J Steven Perry
|
||||
*
|
||||
*/
|
||||
public static class ValidationException extends Exception {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -134518049431883102L;
|
||||
|
||||
// Probably should implement some more constructors, but don't want
|
||||
/// to tarnish the lesson...
|
||||
|
||||
/**
|
||||
* The one and only way to create this checked exception.
|
||||
*
|
||||
* @param message
|
||||
* The message accompanying the exception. Should be meaningful.
|
||||
*/
|
||||
public ValidationException(String message) {
|
||||
super(message);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static final String[] ILLEGAL_NAME_CHARACTERS = { ",", "_", "{", "}", "!" };
|
||||
|
||||
/**
|
||||
* Validate the first name of the specified Person object.
|
||||
*
|
||||
* @param person
|
||||
* The Person object to validate.
|
||||
*
|
||||
* @return - returns true if the specified Person is valid
|
||||
*
|
||||
* @throws ValidationException
|
||||
* - this Exception is thrown if any kind of validation error occurs.
|
||||
*/
|
||||
public static boolean validateFirstName(Person person) throws ValidationException {
|
||||
boolean ret = true;
|
||||
// The validation rules go here.
|
||||
// Naive: use simple ifs
|
||||
if (person == null) {
|
||||
throw new ValidationException("Person is null (not allowed)!");
|
||||
}
|
||||
if (person.getFirstName() == null) {
|
||||
throw new ValidationException("Person FirstName is null (not allowed)!");
|
||||
}
|
||||
if (person.getFirstName()
|
||||
.isEmpty()) {
|
||||
throw new ValidationException("Person FirstName is an empty String (not allowed)!");
|
||||
}
|
||||
if (!isStringValid(person.getFirstName(), ILLEGAL_NAME_CHARACTERS)) {
|
||||
throw new ValidationException("Person FirstName (" + person.getFirstName() + ") may not contain any of the following characters: " + Arrays.toString(ILLEGAL_NAME_CHARACTERS) + "!");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the last name of the specified Person object. Looks the same as first
|
||||
* name? Look closer. Just kidding. It's the same. But real world code can (and will) diverge.
|
||||
*
|
||||
* @param person
|
||||
* The Person object to validate.
|
||||
*
|
||||
* @return - returns true if the specified Person is valid
|
||||
*
|
||||
* @throws ValidationException
|
||||
* - this Exception is thrown if any kind of validation error occurs.
|
||||
*/
|
||||
public static boolean validateLastName(Person person) throws ValidationException {
|
||||
boolean ret = true;
|
||||
// The validation rules go here.
|
||||
// Naive: use simple ifs
|
||||
if (person == null) {
|
||||
throw new ValidationException("Person is null (not allowed)!");
|
||||
}
|
||||
if (person.getFirstName() == null) {
|
||||
throw new ValidationException("Person FirstName is null (not allowed)!");
|
||||
}
|
||||
if (person.getFirstName()
|
||||
.isEmpty()) {
|
||||
throw new ValidationException("Person FirstName is an empty String (not allowed)!");
|
||||
}
|
||||
if (!isStringValid(person.getFirstName(), ILLEGAL_NAME_CHARACTERS)) {
|
||||
throw new ValidationException("Person LastName (" + person.getLastName() + ") may not contain any of the following characters: " + Arrays.toString(ILLEGAL_NAME_CHARACTERS) + "!");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the specified name. If it contains any of the illegalCharacters,
|
||||
* this method returns false (indicating the name is illegal). Otherwise it returns true.
|
||||
*
|
||||
* @param candidate
|
||||
* The candidate String to validate
|
||||
*
|
||||
* @param illegalCharacters
|
||||
* The characters the String is not allowed to have
|
||||
*
|
||||
* @return - boolean - true if the name is valid, false otherwise.
|
||||
*/
|
||||
private static boolean isStringValid(String candidate, String[] illegalCharacters) {
|
||||
boolean ret = true;
|
||||
for (String illegalChar : illegalCharacters) {
|
||||
if (candidate.contains(illegalChar)) {
|
||||
ret = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
package com.baeldung.param;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.RepeatedTest;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.platform.runner.JUnitPlatform;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@RunWith(JUnitPlatform.class)
|
||||
@DisplayName("Testing PersonValidator")
|
||||
public class PersonValidatorTest {
|
||||
|
||||
/**
|
||||
* Nested class, uses ExtendWith
|
||||
* {@link com.baeldung.param.ValidPersonParameterResolver ValidPersonParameterResolver}
|
||||
* to feed Test methods with "good" data.
|
||||
*/
|
||||
@Nested
|
||||
@DisplayName("When using Valid data")
|
||||
@ExtendWith(ValidPersonParameterResolver.class)
|
||||
public class ValidData {
|
||||
|
||||
/**
|
||||
* Repeat the test ten times, that way we have a good shot at
|
||||
* running all of the data through at least once.
|
||||
*
|
||||
* @param person
|
||||
* A valid Person object to validate.
|
||||
*/
|
||||
@RepeatedTest(value = 10)
|
||||
@DisplayName("All first names are valid")
|
||||
public void validateFirstName(Person person) {
|
||||
try {
|
||||
assertTrue(PersonValidator.validateFirstName(person));
|
||||
} catch (PersonValidator.ValidationException e) {
|
||||
fail("Exception not expected: " + e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Repeat the test ten times, that way we have a good shot at
|
||||
* running all of the data through at least once.
|
||||
*
|
||||
* @param person
|
||||
* A valid Person object to validate.
|
||||
*/
|
||||
@RepeatedTest(value = 10)
|
||||
@DisplayName("All last names are valid")
|
||||
public void validateLastName(Person person) {
|
||||
try {
|
||||
assertTrue(PersonValidator.validateLastName(person));
|
||||
} catch (PersonValidator.ValidationException e) {
|
||||
fail("Exception not expected: " + e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Nested class, uses ExtendWith
|
||||
* {@link com.baeldung.param.InvalidPersonParameterResolver InvalidPersonParameterResolver}
|
||||
* to feed Test methods with "bad" data.
|
||||
*/
|
||||
@Nested
|
||||
@DisplayName("When using Invalid data")
|
||||
@ExtendWith(InvalidPersonParameterResolver.class)
|
||||
public class InvalidData {
|
||||
|
||||
/**
|
||||
* Repeat the test ten times, that way we have a good shot at
|
||||
* running all of the data through at least once.
|
||||
*
|
||||
* @param person
|
||||
* An invalid Person object to validate.
|
||||
*/
|
||||
@RepeatedTest(value = 10)
|
||||
@DisplayName("All first names are invalid")
|
||||
public void validateFirstName(Person person) {
|
||||
assertThrows(PersonValidator.ValidationException.class, () -> PersonValidator.validateFirstName(person));
|
||||
}
|
||||
|
||||
/**
|
||||
* Repeat the test ten times, that way we have a good shot at
|
||||
* running all of the data through at least once.
|
||||
*
|
||||
* @param person
|
||||
* An invalid Person object to validate.
|
||||
*/
|
||||
@RepeatedTest(value = 10)
|
||||
@DisplayName("All first names are invalid")
|
||||
public void validateLastName(Person person) {
|
||||
assertThrows(PersonValidator.ValidationException.class, () -> PersonValidator.validateLastName(person));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
package com.baeldung.param;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.junit.jupiter.api.extension.ParameterContext;
|
||||
import org.junit.jupiter.api.extension.ParameterResolutionException;
|
||||
import org.junit.jupiter.api.extension.ParameterResolver;
|
||||
|
||||
public class ValidPersonParameterResolver implements ParameterResolver {
|
||||
|
||||
/**
|
||||
* The "good" (valid) data for testing purposes has to go somewhere, right?
|
||||
*/
|
||||
public static Person[] VALID_PERSONS = { new Person().setId(1L)
|
||||
.setLastName("Adams")
|
||||
.setFirstName("Jill"),
|
||||
new Person().setId(2L)
|
||||
.setLastName("Baker")
|
||||
.setFirstName("James"),
|
||||
new Person().setId(3L)
|
||||
.setLastName("Carter")
|
||||
.setFirstName("Samanta"),
|
||||
new Person().setId(4L)
|
||||
.setLastName("Daniels")
|
||||
.setFirstName("Joseph"),
|
||||
new Person().setId(5L)
|
||||
.setLastName("English")
|
||||
.setFirstName("Jane"),
|
||||
new Person().setId(6L)
|
||||
.setLastName("Fontana")
|
||||
.setFirstName("Enrique"),
|
||||
// TODO: ADD MORE DATA HERE
|
||||
};
|
||||
|
||||
@Override
|
||||
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
|
||||
Object ret = null;
|
||||
//
|
||||
// Return a random, valid Person object if Person.class is the type of Parameter
|
||||
/// to be resolved. Otherwise return null.
|
||||
if (parameterContext.getParameter()
|
||||
.getType() == Person.class) {
|
||||
ret = VALID_PERSONS[new Random().nextInt(VALID_PERSONS.length)];
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
|
||||
boolean ret = false;
|
||||
//
|
||||
// If the Parameter.type == Person.class, then we support it, otherwise, get outta here!
|
||||
if (parameterContext.getParameter()
|
||||
.getType() == Person.class) {
|
||||
ret = true;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.baeldung.suites;
|
||||
|
||||
import org.junit.platform.runner.JUnitPlatform;
|
||||
import org.junit.platform.suite.api.SelectPackages;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@RunWith(JUnitPlatform.class)
|
||||
@SelectPackages("com.baeldung")
|
||||
// @SelectClasses({AssertionTest.class, AssumptionTest.class, ExceptionTest.class})
|
||||
public class AllTests {
|
||||
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
com.baeldung.extensions.EmployeeDaoParameterResolver
|
||||
@@ -1 +0,0 @@
|
||||
env=dev
|
||||
@@ -1,5 +0,0 @@
|
||||
#h2 db
|
||||
jdbc.driver=org.h2.Driver
|
||||
jdbc.url=jdbc:h2:mem:myDb;DB_CLOSE_DELAY=-1
|
||||
jdbc.user=sa
|
||||
jdbc.password=
|
||||
Reference in New Issue
Block a user