Merge branch 'master' into BAEL-4828
This commit is contained in:
commit
b1dbbdda46
|
@ -38,8 +38,6 @@
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
|
||||||
<akka.http.version>10.0.11</akka.http.version>
|
<akka.http.version>10.0.11</akka.http.version>
|
||||||
<akka.stream.version>2.5.11</akka.stream.version>
|
<akka.stream.version>2.5.11</akka.stream.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
|
@ -91,8 +91,6 @@
|
||||||
<commons-collections4.version>4.3</commons-collections4.version>
|
<commons-collections4.version>4.3</commons-collections4.version>
|
||||||
<guava.version>28.0-jre</guava.version>
|
<guava.version>28.0-jre</guava.version>
|
||||||
<retrofit.version>2.6.0</retrofit.version>
|
<retrofit.version>2.6.0</retrofit.version>
|
||||||
<jmh-core.version>1.19</jmh-core.version>
|
|
||||||
<jmh-generator.version>1.19</jmh-generator.version>
|
|
||||||
<commons.lang3.version>3.8.1</commons.lang3.version>
|
<commons.lang3.version>3.8.1</commons.lang3.version>
|
||||||
<JUnitParams.version>1.1.0</JUnitParams.version>
|
<JUnitParams.version>1.1.0</JUnitParams.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
|
@ -13,22 +13,22 @@ public class KadaneAlgorithm {
|
||||||
int start = 0;
|
int start = 0;
|
||||||
int end = 0;
|
int end = 0;
|
||||||
|
|
||||||
int maxSoFar = 0, maxEndingHere = 0;
|
int maxSoFar = arr[0], maxEndingHere = arr[0];
|
||||||
|
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
|
|
||||||
if (arr[i] > maxEndingHere + arr[i]) {
|
if (arr[i] > maxEndingHere + arr[i]) {
|
||||||
start = i;
|
start = i;
|
||||||
maxEndingHere = arr[i];
|
maxEndingHere = arr[i];
|
||||||
} else
|
} else {
|
||||||
maxEndingHere = maxEndingHere + arr[i];
|
maxEndingHere = maxEndingHere + arr[i];
|
||||||
|
}
|
||||||
|
|
||||||
if (maxSoFar < maxEndingHere) {
|
if (maxSoFar < maxEndingHere) {
|
||||||
maxSoFar = maxEndingHere;
|
maxSoFar = maxEndingHere;
|
||||||
end = i;
|
end = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logger.info("Found Maximum Subarray between {} and {}", start, end);
|
logger.info("Found Maximum Subarray between {} and {}", Math.min(start, end), end);
|
||||||
return maxSoFar;
|
return maxSoFar;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,4 +16,15 @@ class KadaneAlgorithmUnitTest {
|
||||||
//then
|
//then
|
||||||
assertEquals(6, maxSum);
|
assertEquals(6, maxSum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void givenArrayWithAllNegativeNumbersWhenMaximumSubarrayThenReturnsExpectedResult() {
|
||||||
|
//given
|
||||||
|
int[] arr = new int[] { -8, -7, -5, -4, -3, -1, -2 };
|
||||||
|
//when
|
||||||
|
KadaneAlgorithm algorithm = new KadaneAlgorithm();
|
||||||
|
int maxSum = algorithm.maxSubArraySum(arr);
|
||||||
|
//then
|
||||||
|
assertEquals(-1, maxSum);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -13,7 +13,7 @@ import java.util.Objects;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
public class AvroSerealizerDeSerealizerUnitTest {
|
public class AvroSerealizerDeSerealizerIntegrationTest {
|
||||||
|
|
||||||
AvroSerealizer serealizer;
|
AvroSerealizer serealizer;
|
||||||
AvroDeSerealizer deSerealizer;
|
AvroDeSerealizer deSerealizer;
|
|
@ -17,7 +17,7 @@ import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
|
||||||
@RunWith(MonoMeecrowave.Runner.class)
|
@RunWith(MonoMeecrowave.Runner.class)
|
||||||
public class ArticleEndpointsUnitTest {
|
public class ArticleEndpointsIntegrationTest {
|
||||||
|
|
||||||
@ConfigurationInject
|
@ConfigurationInject
|
||||||
private Meecrowave.Builder config;
|
private Meecrowave.Builder config;
|
|
@ -100,7 +100,6 @@
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>1.8</java.version>
|
|
||||||
<spring.version>2.2.1.RELEASE</spring.version>
|
<spring.version>2.2.1.RELEASE</spring.version>
|
||||||
<awssdk.version>2.10.27</awssdk.version>
|
<awssdk.version>2.10.27</awssdk.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
|
@ -115,7 +115,6 @@
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<version>${surefire.plugin.version}</version>
|
|
||||||
<configuration>
|
<configuration>
|
||||||
<useFile>false</useFile>
|
<useFile>false</useFile>
|
||||||
<includes>
|
<includes>
|
||||||
|
@ -186,7 +185,6 @@
|
||||||
<logback.version>1.2.3</logback.version>
|
<logback.version>1.2.3</logback.version>
|
||||||
<groovy.version>2.5.7</groovy.version>
|
<groovy.version>2.5.7</groovy.version>
|
||||||
<assembly.plugin.version>3.1.0</assembly.plugin.version>
|
<assembly.plugin.version>3.1.0</assembly.plugin.version>
|
||||||
<surefire.plugin.version>2.20.1</surefire.plugin.version>
|
|
||||||
<compiler.plugin.version>3.8.0</compiler.plugin.version>
|
<compiler.plugin.version>3.8.0</compiler.plugin.version>
|
||||||
<groovy.compiler.version>3.3.0-01</groovy.compiler.version>
|
<groovy.compiler.version>3.3.0-01</groovy.compiler.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
|
@ -101,7 +101,6 @@
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<version>${surefire.plugin.version}</version>
|
|
||||||
<configuration>
|
<configuration>
|
||||||
<useFile>false</useFile>
|
<useFile>false</useFile>
|
||||||
<includes>
|
<includes>
|
||||||
|
@ -128,7 +127,6 @@
|
||||||
<hsqldb.version>2.4.0</hsqldb.version>
|
<hsqldb.version>2.4.0</hsqldb.version>
|
||||||
<spock-core.version>1.1-groovy-2.4</spock-core.version>
|
<spock-core.version>1.1-groovy-2.4</spock-core.version>
|
||||||
<gmavenplus-plugin.version>1.6</gmavenplus-plugin.version>
|
<gmavenplus-plugin.version>1.6</gmavenplus-plugin.version>
|
||||||
<surefire.plugin.version>2.20.1</surefire.plugin.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -32,12 +32,12 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
<artifactId>jmh-core</artifactId>
|
<artifactId>jmh-core</artifactId>
|
||||||
<version>${jmh.version}</version>
|
<version>${jmh-core.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
<artifactId>jmh-generator-annprocess</artifactId>
|
<artifactId>jmh-generator-annprocess</artifactId>
|
||||||
<version>${jmh.version}</version>
|
<version>${jmh-generator.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -105,7 +105,6 @@
|
||||||
<guava.version>27.1-jre</guava.version>
|
<guava.version>27.1-jre</guava.version>
|
||||||
<assertj.version>3.11.1</assertj.version>
|
<assertj.version>3.11.1</assertj.version>
|
||||||
<uberjar.name>benchmarks</uberjar.name>
|
<uberjar.name>benchmarks</uberjar.name>
|
||||||
<jmh.version>1.22</jmh.version>
|
|
||||||
<eclipse.collections.version>10.0.0</eclipse.collections.version>
|
<eclipse.collections.version>10.0.0</eclipse.collections.version>
|
||||||
<shade.plugin.version>3.2.4</shade.plugin.version>
|
<shade.plugin.version>3.2.4</shade.plugin.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
|
@ -17,16 +17,18 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
<artifactId>jmh-core</artifactId>
|
<artifactId>jmh-core</artifactId>
|
||||||
<version>${jmh.version}</version>
|
<version>${jmh-core.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
<artifactId>jmh-generator-annprocess</artifactId>
|
<artifactId>jmh-generator-annprocess</artifactId>
|
||||||
<version>${jmh.version}</version>
|
<version>${jmh-generator.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.assertj</groupId>
|
||||||
|
<artifactId>assertj-core</artifactId>
|
||||||
|
<version>3.19.0</version>
|
||||||
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<properties>
|
|
||||||
<jmh.version>1.19</jmh.version>
|
|
||||||
</properties>
|
|
||||||
</project>
|
</project>
|
|
@ -2,7 +2,6 @@ package com.baeldung.genericarrays;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
package com.baeldung.genericarrays;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.function.IntFunction;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import static java.util.Collections.singletonList;
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||||
|
|
||||||
|
public class StreamToArrayUnitTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenAStream_thenCanGetArrayOfObject() {
|
||||||
|
Object[] strings = Stream.of("A", "AAA", "B", "AAB", "C")
|
||||||
|
.filter(string -> string.startsWith("A"))
|
||||||
|
.toArray();
|
||||||
|
|
||||||
|
assertThat(strings).containsExactly("A", "AAA", "AAB");
|
||||||
|
assertThat(strings).isNotInstanceOf(String[].class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenAStream_thenCanGetArrayOfString() {
|
||||||
|
String[] strings = Stream.of("A", "AAA", "B", "AAB", "C")
|
||||||
|
.filter(string -> string.startsWith("A"))
|
||||||
|
.toArray(String[]::new);
|
||||||
|
|
||||||
|
assertThat(strings).containsExactly("A", "AAA", "AAB");
|
||||||
|
assertThat(strings).isInstanceOf(String[].class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Test
|
||||||
|
public void givenAStream_whenConvertToOptional_thenCanGetArrayOfOptional() {
|
||||||
|
Stream<Optional<String>> stream = Stream.of("A", "AAA", "B", "AAB", "C")
|
||||||
|
.filter(string -> string.startsWith("A"))
|
||||||
|
.map(Optional::of);
|
||||||
|
Optional<String>[] strings = stream
|
||||||
|
.toArray(Optional[]::new);
|
||||||
|
|
||||||
|
assertThat(strings).containsExactly(Optional.of("A"),
|
||||||
|
Optional.of("AAA"),
|
||||||
|
Optional.of("AAB"));
|
||||||
|
assertThat(strings).isInstanceOf(Optional[].class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenAStream_whenConvertToOptional_thenCanGetArrayOfOptionalWithHelper() {
|
||||||
|
Optional<String>[] strings = Stream.of("A", "AAA", "B", "AAB", "C")
|
||||||
|
.filter(string -> string.startsWith("A"))
|
||||||
|
.map(Optional::of)
|
||||||
|
.toArray(genericArray(Optional[]::new));
|
||||||
|
|
||||||
|
assertThat(strings).containsExactly(Optional.of("A"),
|
||||||
|
Optional.of("AAA"),
|
||||||
|
Optional.of("AAB"));
|
||||||
|
assertThat(strings).isInstanceOf(Optional[].class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenInvalidUseOfGenericArray_thenIllegalCast() {
|
||||||
|
assertThatThrownBy(() -> {
|
||||||
|
ArrayList<String>[] lists = Stream.of(singletonList("A"))
|
||||||
|
.toArray(genericArray(List[]::new));
|
||||||
|
}).isInstanceOf(ClassCastException.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private static <T, R extends T> IntFunction<R[]> genericArray(IntFunction<T[]> arrayCreator) {
|
||||||
|
return size -> (R[])arrayCreator.apply(size);
|
||||||
|
}
|
||||||
|
}
|
|
@ -24,12 +24,12 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
<artifactId>jmh-core</artifactId>
|
<artifactId>jmh-core</artifactId>
|
||||||
<version>${jmh.version}</version>
|
<version>${jmh-core.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
<artifactId>jmh-generator-annprocess</artifactId>
|
<artifactId>jmh-generator-annprocess</artifactId>
|
||||||
<version>${jmh.version}</version>
|
<version>${jmh-generator.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -68,7 +68,6 @@
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<shade.plugin.version>3.2.0</shade.plugin.version>
|
<shade.plugin.version>3.2.0</shade.plugin.version>
|
||||||
<jmh.version>1.19</jmh.version>
|
|
||||||
<assertj-core.version>3.10.0</assertj-core.version>
|
<assertj-core.version>3.10.0</assertj-core.version>
|
||||||
</properties>
|
</properties>
|
||||||
</project>
|
</project>
|
|
@ -31,12 +31,12 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
<artifactId>jmh-core</artifactId>
|
<artifactId>jmh-core</artifactId>
|
||||||
<version>${jmh.version}</version>
|
<version>${jmh-core.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
<artifactId>jmh-generator-annprocess</artifactId>
|
<artifactId>jmh-generator-annprocess</artifactId>
|
||||||
<version>${jmh.version}</version>
|
<version>${jmh-generator.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Testing -->
|
<!-- Testing -->
|
||||||
|
@ -77,7 +77,6 @@
|
||||||
<properties>
|
<properties>
|
||||||
<shade.plugin.version>3.2.0</shade.plugin.version>
|
<shade.plugin.version>3.2.0</shade.plugin.version>
|
||||||
<guava.version>28.2-jre</guava.version>
|
<guava.version>28.2-jre</guava.version>
|
||||||
<jmh.version>1.19</jmh.version>
|
|
||||||
<assertj-core.version>3.10.0</assertj-core.version>
|
<assertj-core.version>3.10.0</assertj-core.version>
|
||||||
</properties>
|
</properties>
|
||||||
</project>
|
</project>
|
|
@ -25,17 +25,16 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
<artifactId>jmh-core</artifactId>
|
<artifactId>jmh-core</artifactId>
|
||||||
<version>${openjdk.jmh.version}</version>
|
<version>${jmh-core.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
<artifactId>jmh-generator-annprocess</artifactId>
|
<artifactId>jmh-generator-annprocess</artifactId>
|
||||||
<version>${openjdk.jmh.version}</version>
|
<version>${jmh-generator.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<openjdk.jmh.version>1.19</openjdk.jmh.version>
|
|
||||||
<assertj.version>3.11.1</assertj.version>
|
<assertj.version>3.11.1</assertj.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
<artifactId>jmh-core</artifactId>
|
<artifactId>jmh-core</artifactId>
|
||||||
<version>${openjdk.jmh.version}</version>
|
<version>${jmh-core.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.assertj</groupId>
|
<groupId>org.assertj</groupId>
|
||||||
|
@ -40,7 +40,6 @@
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<openjdk.jmh.version>1.19</openjdk.jmh.version>
|
|
||||||
<assertj.version>3.11.1</assertj.version>
|
<assertj.version>3.11.1</assertj.version>
|
||||||
<jol-core.version>0.10</jol-core.version>
|
<jol-core.version>0.10</jol-core.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
|
@ -58,7 +58,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
<artifactId>jmh-generator-annprocess</artifactId>
|
<artifactId>jmh-generator-annprocess</artifactId>
|
||||||
<version>${jmh-core.version}</version>
|
<version>${jmh-generator.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
@ -25,17 +25,16 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
<artifactId>jmh-core</artifactId>
|
<artifactId>jmh-core</artifactId>
|
||||||
<version>${openjdk.jmh.version}</version>
|
<version>${jmh-core.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
<artifactId>jmh-generator-annprocess</artifactId>
|
<artifactId>jmh-generator-annprocess</artifactId>
|
||||||
<version>${openjdk.jmh.version}</version>
|
<version>${jmh-generator.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<openjdk.jmh.version>1.19</openjdk.jmh.version>
|
|
||||||
<assertj.version>3.11.1</assertj.version>
|
<assertj.version>3.11.1</assertj.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
<artifactId>jmh-generator-annprocess</artifactId>
|
<artifactId>jmh-generator-annprocess</artifactId>
|
||||||
<version>${jmh-generator-annprocess.version}</version>
|
<version>${jmh-generator.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -51,8 +51,6 @@
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<jmh-core.version>1.19</jmh-core.version>
|
|
||||||
<jmh-generator-annprocess.version>1.19</jmh-generator-annprocess.version>
|
|
||||||
<assertj.version>3.6.1</assertj.version>
|
<assertj.version>3.6.1</assertj.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
|
|
@ -23,12 +23,12 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
<artifactId>jmh-core</artifactId>
|
<artifactId>jmh-core</artifactId>
|
||||||
<version>${jmh.version}</version>
|
<version>${jmh-core.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
<artifactId>jmh-generator-annprocess</artifactId>
|
<artifactId>jmh-generator-annprocess</artifactId>
|
||||||
<version>${jmh.version}</version>
|
<version>${jmh-generator.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.assertj</groupId>
|
<groupId>org.assertj</groupId>
|
||||||
|
@ -39,7 +39,6 @@
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<jmh.version>1.21</jmh.version>
|
|
||||||
<guava.version>28.2-jre</guava.version>
|
<guava.version>28.2-jre</guava.version>
|
||||||
<!-- testing -->
|
<!-- testing -->
|
||||||
<assertj.version>3.6.1</assertj.version>
|
<assertj.version>3.6.1</assertj.version>
|
||||||
|
|
|
@ -65,8 +65,6 @@
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<jmh-core.version>1.19</jmh-core.version>
|
|
||||||
<jmh-generator.version>1.19</jmh-generator.version>
|
|
||||||
<assertj.version>3.12.2</assertj.version>
|
<assertj.version>3.12.2</assertj.version>
|
||||||
<commons.beanutils.version>1.9.4</commons.beanutils.version>
|
<commons.beanutils.version>1.9.4</commons.beanutils.version>
|
||||||
<guava.version>29.0-jre</guava.version>
|
<guava.version>29.0-jre</guava.version>
|
||||||
|
|
|
@ -20,12 +20,12 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
<artifactId>jmh-core</artifactId>
|
<artifactId>jmh-core</artifactId>
|
||||||
<version>${jmh.version}</version>
|
<version>${jmh-core.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
<artifactId>jmh-generator-annprocess</artifactId>
|
<artifactId>jmh-generator-annprocess</artifactId>
|
||||||
<version>${jmh.version}</version>
|
<version>${jmh-generator.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@ -40,8 +40,4 @@
|
||||||
</resources>
|
</resources>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<properties>
|
|
||||||
<jmh.version>1.28</jmh.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -58,7 +58,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
<artifactId>jmh-generator-annprocess</artifactId>
|
<artifactId>jmh-generator-annprocess</artifactId>
|
||||||
<version>${jmh.version}</version>
|
<version>${jmh-generator.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@ -83,7 +83,6 @@
|
||||||
<nd4j.version>1.0.0-beta4</nd4j.version>
|
<nd4j.version>1.0.0-beta4</nd4j.version>
|
||||||
<colt.version>1.2.0</colt.version>
|
<colt.version>1.2.0</colt.version>
|
||||||
<la4j.version>0.6.0</la4j.version>
|
<la4j.version>0.6.0</la4j.version>
|
||||||
<jmh.version>1.19</jmh.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -13,3 +13,4 @@ This module contains articles about types in Java
|
||||||
- [A Guide to Java Enums](https://www.baeldung.com/a-guide-to-java-enums)
|
- [A Guide to Java Enums](https://www.baeldung.com/a-guide-to-java-enums)
|
||||||
- [Determine if an Object is of Primitive Type](https://www.baeldung.com/java-object-primitive-type)
|
- [Determine if an Object is of Primitive Type](https://www.baeldung.com/java-object-primitive-type)
|
||||||
- [Extending Enums in Java](https://www.baeldung.com/java-extending-enums)
|
- [Extending Enums in Java](https://www.baeldung.com/java-extending-enums)
|
||||||
|
- [Java Class File Naming Conventions](https://www.baeldung.com/java-class-file-naming)
|
||||||
|
|
|
@ -47,6 +47,7 @@ public class Outer {
|
||||||
// Anonymous Inner class extending a class
|
// Anonymous Inner class extending a class
|
||||||
public String greet() {
|
public String greet() {
|
||||||
Outer anonymous = new Outer() {
|
Outer anonymous = new Outer() {
|
||||||
|
@Override
|
||||||
public String greet() {
|
public String greet() {
|
||||||
return "Running Anonymous Class...";
|
return "Running Anonymous Class...";
|
||||||
}
|
}
|
||||||
|
@ -58,6 +59,7 @@ public class Outer {
|
||||||
public String greet(String name) {
|
public String greet(String name) {
|
||||||
|
|
||||||
HelloWorld helloWorld = new HelloWorld() {
|
HelloWorld helloWorld = new HelloWorld() {
|
||||||
|
@Override
|
||||||
public String greet(String name) {
|
public String greet(String name) {
|
||||||
return "Welcome to " + name;
|
return "Welcome to " + name;
|
||||||
}
|
}
|
||||||
|
@ -70,6 +72,7 @@ public class Outer {
|
||||||
public String greetSomeone(String name) {
|
public String greetSomeone(String name) {
|
||||||
|
|
||||||
HelloSomeone helloSomeOne = new HelloSomeone() {
|
HelloSomeone helloSomeOne = new HelloSomeone() {
|
||||||
|
@Override
|
||||||
public String greet(String name) {
|
public String greet(String name) {
|
||||||
return "Hello " + name;
|
return "Hello " + name;
|
||||||
}
|
}
|
||||||
|
@ -94,7 +97,8 @@ interface HelloWorld {
|
||||||
public String greet(String name);
|
public String greet(String name);
|
||||||
|
|
||||||
// Nested class within an interface
|
// Nested class within an interface
|
||||||
class InnerClass {
|
class InnerClass implements HelloWorld {
|
||||||
|
@Override
|
||||||
public String greet(String name) {
|
public String greet(String name) {
|
||||||
return "Inner class within an interface";
|
return "Inner class within an interface";
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,5 +14,4 @@ This module contains articles about networking in Java
|
||||||
- [Handling java.net.ConnectException](https://www.baeldung.com/java-net-connectexception)
|
- [Handling java.net.ConnectException](https://www.baeldung.com/java-net-connectexception)
|
||||||
- [Getting MAC addresses in Java](https://www.baeldung.com/java-mac-address)
|
- [Getting MAC addresses in Java](https://www.baeldung.com/java-mac-address)
|
||||||
- [Sending Emails with Attachments in Java](https://www.baeldung.com/java-send-emails-attachments)
|
- [Sending Emails with Attachments in Java](https://www.baeldung.com/java-send-emails-attachments)
|
||||||
- [Finding a Free Port in Java](https://www.baeldung.com/java-free-port)
|
|
||||||
- [[<-- Prev]](/core-java-modules/core-java-networking)
|
- [[<-- Prev]](/core-java-modules/core-java-networking)
|
||||||
|
|
|
@ -4,5 +4,5 @@ This module contains articles about networking in Java
|
||||||
|
|
||||||
### Relevant Articles
|
### Relevant Articles
|
||||||
|
|
||||||
- TODO: add link once live
|
- [Finding a Free Port in Java](https://www.baeldung.com/java-free-port)
|
||||||
- [[<-- Prev]](/core-java-modules/core-java-networking-2)
|
- [[<-- Prev]](/core-java-modules/core-java-networking-2)
|
||||||
|
|
|
@ -67,8 +67,6 @@
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<hibernate.core.version>5.4.0.Final</hibernate.core.version>
|
<hibernate.core.version>5.4.0.Final</hibernate.core.version>
|
||||||
<jmh-core.version>1.19</jmh-core.version>
|
|
||||||
<jmh-generator.version>1.19</jmh-generator.version>
|
|
||||||
<guava.version>27.1-jre</guava.version>
|
<guava.version>27.1-jre</guava.version>
|
||||||
<assertj.version>3.10.0</assertj.version>
|
<assertj.version>3.10.0</assertj.version>
|
||||||
<rest-assured.version>3.1.1</rest-assured.version>
|
<rest-assured.version>3.1.1</rest-assured.version>
|
||||||
|
|
|
@ -0,0 +1,92 @@
|
||||||
|
package com.baeldung.cipher;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Assertions;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import javax.crypto.Cipher;
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.security.KeyPair;
|
||||||
|
import java.security.KeyPairGenerator;
|
||||||
|
import java.security.PrivateKey;
|
||||||
|
import java.security.PublicKey;
|
||||||
|
|
||||||
|
public class RsaUnitTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenRsaKeyPair_whenEncryptAndDecryptString_thenCompareResults() throws Exception {
|
||||||
|
KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA");
|
||||||
|
generator.initialize(2048);
|
||||||
|
KeyPair pair = generator.generateKeyPair();
|
||||||
|
PrivateKey privateKey = pair.getPrivate();
|
||||||
|
PublicKey publicKey = pair.getPublic();
|
||||||
|
|
||||||
|
String secretMessage = "Baeldung secret message";
|
||||||
|
Cipher encryptCipher = Cipher.getInstance("RSA");
|
||||||
|
encryptCipher.init(Cipher.ENCRYPT_MODE, publicKey);
|
||||||
|
byte[] secretMessageBytes = secretMessage.getBytes(StandardCharsets.UTF_8);
|
||||||
|
byte[] encryptedMessageBytes = encryptCipher.doFinal(secretMessageBytes);
|
||||||
|
|
||||||
|
Cipher decryptCipher = Cipher.getInstance("RSA");
|
||||||
|
decryptCipher.init(Cipher.DECRYPT_MODE, privateKey);
|
||||||
|
byte[] decryptedMessageBytes = decryptCipher.doFinal(encryptedMessageBytes);
|
||||||
|
String decryptedMessage = new String(decryptedMessageBytes, StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
Assertions.assertEquals(secretMessage, decryptedMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenRsaKeyPair_whenEncryptAndDecryptFile_thenCompareResults() throws Exception {
|
||||||
|
KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA");
|
||||||
|
generator.initialize(2048);
|
||||||
|
KeyPair pair = generator.generateKeyPair();
|
||||||
|
PrivateKey privateKey = pair.getPrivate();
|
||||||
|
PublicKey publicKey = pair.getPublic();
|
||||||
|
|
||||||
|
String originalContent = "some secret message";
|
||||||
|
Path tempFile = Files.createTempFile("temp", "txt");
|
||||||
|
writeString(tempFile, originalContent);
|
||||||
|
|
||||||
|
byte[] fileBytes = Files.readAllBytes(tempFile);
|
||||||
|
Cipher encryptCipher = Cipher.getInstance("RSA");
|
||||||
|
encryptCipher.init(Cipher.ENCRYPT_MODE, publicKey);
|
||||||
|
byte[] encryptedFileBytes = encryptCipher.doFinal(fileBytes);
|
||||||
|
try (FileOutputStream stream = new FileOutputStream(tempFile.toFile())) {
|
||||||
|
stream.write(encryptedFileBytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
encryptedFileBytes = Files.readAllBytes(tempFile);
|
||||||
|
Cipher decryptCipher = Cipher.getInstance("RSA");
|
||||||
|
decryptCipher.init(Cipher.DECRYPT_MODE, privateKey);
|
||||||
|
byte[] decryptedFileBytes = decryptCipher.doFinal(encryptedFileBytes);
|
||||||
|
try (FileOutputStream stream = new FileOutputStream(tempFile.toFile())) {
|
||||||
|
stream.write(decryptedFileBytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
String fileContent = readString(tempFile);
|
||||||
|
|
||||||
|
Assertions.assertEquals(originalContent, fileContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeString(Path path, String content) throws Exception {
|
||||||
|
try (BufferedWriter writer = Files.newBufferedWriter(path)) {
|
||||||
|
writer.write(content);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String readString(Path path) throws Exception {
|
||||||
|
StringBuilder resultStringBuilder = new StringBuilder();
|
||||||
|
try (BufferedReader br = new BufferedReader(new FileReader(path.toFile()))) {
|
||||||
|
String line;
|
||||||
|
while ((line = br.readLine()) != null) {
|
||||||
|
resultStringBuilder.append(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resultStringBuilder.toString();
|
||||||
|
}
|
||||||
|
}
|
|
@ -47,7 +47,6 @@
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
<maven.compiler.source>1.9</maven.compiler.source>
|
<maven.compiler.source>1.9</maven.compiler.source>
|
||||||
<maven.compiler.target>1.9</maven.compiler.target>
|
<maven.compiler.target>1.9</maven.compiler.target>
|
||||||
<assertj.version>3.11.1</assertj.version>
|
<assertj.version>3.11.1</assertj.version>
|
||||||
|
|
|
@ -10,4 +10,5 @@ This module contains articles about the Stream API in Java.
|
||||||
- [Debugging Java 8 Streams with IntelliJ](https://www.baeldung.com/intellij-debugging-java-streams)
|
- [Debugging Java 8 Streams with IntelliJ](https://www.baeldung.com/intellij-debugging-java-streams)
|
||||||
- [Add BigDecimals using the Stream API](https://www.baeldung.com/java-stream-add-bigdecimals)
|
- [Add BigDecimals using the Stream API](https://www.baeldung.com/java-stream-add-bigdecimals)
|
||||||
- [Should We Close a Java Stream?](https://www.baeldung.com/java-stream-close)
|
- [Should We Close a Java Stream?](https://www.baeldung.com/java-stream-close)
|
||||||
|
- [Returning Stream vs. Collection](https://www.baeldung.com/java-return-stream-collection)
|
||||||
- More articles: [[<-- prev>]](/../core-java-streams-2)
|
- More articles: [[<-- prev>]](/../core-java-streams-2)
|
||||||
|
|
|
@ -49,8 +49,6 @@
|
||||||
<properties>
|
<properties>
|
||||||
<!-- testing -->
|
<!-- testing -->
|
||||||
<assertj.version>3.6.1</assertj.version>
|
<assertj.version>3.6.1</assertj.version>
|
||||||
<!-- plugins -->
|
|
||||||
<maven-surefire-plugin.version>2.22.1</maven-surefire-plugin.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -0,0 +1,95 @@
|
||||||
|
package com.baeldung.streams.streamvscollection;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.SortedSet;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
public class StreamVsCollectionExample {
|
||||||
|
|
||||||
|
static ArrayList<String> userNameSource = new ArrayList<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
userNameSource.add("john");
|
||||||
|
userNameSource.add("smith");
|
||||||
|
userNameSource.add("tom");
|
||||||
|
userNameSource.add("rob");
|
||||||
|
userNameSource.add("charlie");
|
||||||
|
userNameSource.add("alfred");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Stream<String> userNames() {
|
||||||
|
return userNameSource.stream();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<String> userNameList() {
|
||||||
|
return userNames().collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Set<String> userNameSet() {
|
||||||
|
return userNames().collect(Collectors.toSet());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map<String, String> userNameMap() {
|
||||||
|
return userNames().collect(Collectors.toMap(u1 -> u1.toString(), u1 -> u1.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Stream<String> filterUserNames() {
|
||||||
|
return userNames().filter(i -> i.length() >= 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Stream<String> sortUserNames() {
|
||||||
|
return userNames().sorted();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Stream<String> limitUserNames() {
|
||||||
|
return userNames().limit(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Stream<String> sortFilterLimitUserNames() {
|
||||||
|
return filterUserNames().sorted().limit(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void printStream(Stream<String> stream) {
|
||||||
|
stream.forEach(System.out::println);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void modifyList() {
|
||||||
|
userNameSource.remove(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map<String, String> modifyMap() {
|
||||||
|
Map<String, String> userNameMap = userNameMap();
|
||||||
|
userNameMap.put("bob", "bob");
|
||||||
|
userNameMap.remove("alfred");
|
||||||
|
|
||||||
|
return userNameMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void tryStreamTraversal() {
|
||||||
|
Stream<String> userNameStream = userNames();
|
||||||
|
userNameStream.forEach(System.out::println);
|
||||||
|
|
||||||
|
try {
|
||||||
|
userNameStream.forEach(System.out::println);
|
||||||
|
} catch(IllegalStateException e) {
|
||||||
|
System.out.println("stream has already been operated upon or closed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
System.out.println(userNameMap());
|
||||||
|
System.out.println(modifyMap());
|
||||||
|
tryStreamTraversal();
|
||||||
|
|
||||||
|
Set<String> set = userNames().collect(Collectors.toCollection(TreeSet::new));
|
||||||
|
set.forEach(val -> System.out.println(val));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -34,7 +34,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
<artifactId>jmh-generator-annprocess</artifactId>
|
<artifactId>jmh-generator-annprocess</artifactId>
|
||||||
<version>${jmh-core.version}</version>
|
<version>${jmh-generator.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.assertj</groupId>
|
<groupId>org.assertj</groupId>
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
<artifactId>jmh-generator-annprocess</artifactId>
|
<artifactId>jmh-generator-annprocess</artifactId>
|
||||||
<version>${jmh-core.version}</version>
|
<version>${jmh-generator.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.vdurmont</groupId>
|
<groupId>com.vdurmont</groupId>
|
||||||
|
|
|
@ -59,7 +59,6 @@
|
||||||
<compiler.plugin.version>3.8.0</compiler.plugin.version>
|
<compiler.plugin.version>3.8.0</compiler.plugin.version>
|
||||||
<source.version>1.9</source.version>
|
<source.version>1.9</source.version>
|
||||||
<target.version>1.9</target.version>
|
<target.version>1.9</target.version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
<assertj-core.version>3.12.2</assertj-core.version>
|
<assertj-core.version>3.12.2</assertj-core.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
|
|
@ -100,6 +100,7 @@
|
||||||
|
|
||||||
<module>core-java-networking</module>
|
<module>core-java-networking</module>
|
||||||
<module>core-java-networking-2</module>
|
<module>core-java-networking-2</module>
|
||||||
|
<module>core-java-networking-3</module>
|
||||||
<module>core-java-nio</module>
|
<module>core-java-nio</module>
|
||||||
<module>core-java-nio-2</module>
|
<module>core-java-nio-2</module>
|
||||||
|
|
||||||
|
@ -148,18 +149,6 @@
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
<build>
|
|
||||||
<pluginManagement>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
|
||||||
<version>${maven-surefire-plugin.version}</version>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</pluginManagement>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
|
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
|
||||||
<junit-jupiter.version>5.6.2</junit-jupiter.version>
|
<junit-jupiter.version>5.6.2</junit-jupiter.version>
|
||||||
|
|
|
@ -45,7 +45,6 @@
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
<maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
|
<maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
|
||||||
<pmdVersion>6.0.1</pmdVersion>
|
<pmdVersion>6.0.1</pmdVersion>
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
|
|
|
@ -148,30 +148,28 @@ public class BinaryTree {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void traverseInOrderWithoutRecursion() {
|
public void traverseInOrderWithoutRecursion() {
|
||||||
Stack<Node> stack = new Stack<Node>();
|
Stack<Node> stack = new Stack<>();
|
||||||
Node current = root;
|
Node current = root;
|
||||||
stack.push(root);
|
|
||||||
while(! stack.isEmpty()) {
|
while (current != null || !stack.isEmpty()) {
|
||||||
while(current.left != null) {
|
while (current != null) {
|
||||||
|
stack.push(current);
|
||||||
current = current.left;
|
current = current.left;
|
||||||
stack.push(current);
|
|
||||||
}
|
|
||||||
current = stack.pop();
|
|
||||||
visit(current.value);
|
|
||||||
if(current.right != null) {
|
|
||||||
current = current.right;
|
|
||||||
stack.push(current);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Node top = stack.pop();
|
||||||
|
visit(top.value);
|
||||||
|
current = top.right;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void traversePreOrderWithoutRecursion() {
|
public void traversePreOrderWithoutRecursion() {
|
||||||
Stack<Node> stack = new Stack<Node>();
|
Stack<Node> stack = new Stack<>();
|
||||||
Node current = root;
|
Node current = root;
|
||||||
stack.push(root);
|
stack.push(root);
|
||||||
while(! stack.isEmpty()) {
|
|
||||||
|
while (current != null && !stack.isEmpty()) {
|
||||||
current = stack.pop();
|
current = stack.pop();
|
||||||
visit(current.value);
|
visit(current.value);
|
||||||
|
|
||||||
|
@ -184,12 +182,12 @@ public class BinaryTree {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void traversePostOrderWithoutRecursion() {
|
public void traversePostOrderWithoutRecursion() {
|
||||||
Stack<Node> stack = new Stack<Node>();
|
Stack<Node> stack = new Stack<>();
|
||||||
Node prev = root;
|
Node prev = root;
|
||||||
Node current = root;
|
Node current = root;
|
||||||
stack.push(root);
|
stack.push(root);
|
||||||
|
|
||||||
while (!stack.isEmpty()) {
|
while (current != null && !stack.isEmpty()) {
|
||||||
current = stack.peek();
|
current = stack.peek();
|
||||||
boolean hasChild = (current.left != null || current.right != null);
|
boolean hasChild = (current.left != null || current.right != null);
|
||||||
boolean isPrevLastChild = (prev == current.right || (prev == current.left && current.right == null));
|
boolean isPrevLastChild = (prev == current.right || (prev == current.left && current.right == null));
|
||||||
|
|
|
@ -13,7 +13,7 @@ public class BinaryTreeUnitTest {
|
||||||
|
|
||||||
BinaryTree bt = createBinaryTree();
|
BinaryTree bt = createBinaryTree();
|
||||||
|
|
||||||
assertTrue(!bt.isEmpty());
|
assertFalse(bt.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -72,6 +72,7 @@ public class BinaryTreeUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void it_deletes_the_root() {
|
public void it_deletes_the_root() {
|
||||||
|
|
||||||
int value = 12;
|
int value = 12;
|
||||||
BinaryTree bt = new BinaryTree();
|
BinaryTree bt = new BinaryTree();
|
||||||
bt.add(value);
|
bt.add(value);
|
||||||
|
@ -91,6 +92,14 @@ public class BinaryTreeUnitTest {
|
||||||
bt.traverseInOrderWithoutRecursion();
|
bt.traverseInOrderWithoutRecursion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenAnEmptyBinaryTree_WhenTraversingInOrderWithoutRecursion_ThenNoException() {
|
||||||
|
|
||||||
|
BinaryTree empty = new BinaryTree();
|
||||||
|
|
||||||
|
empty.traverseInOrderWithoutRecursion();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenABinaryTree_WhenTraversingPreOrder_ThenPrintValues() {
|
public void givenABinaryTree_WhenTraversingPreOrder_ThenPrintValues() {
|
||||||
|
|
||||||
|
@ -101,6 +110,14 @@ public class BinaryTreeUnitTest {
|
||||||
bt.traversePreOrderWithoutRecursion();
|
bt.traversePreOrderWithoutRecursion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenAnEmptyBinaryTree_WhenTraversingPreOrderWithoutRecursion_ThenNoException() {
|
||||||
|
|
||||||
|
BinaryTree empty = new BinaryTree();
|
||||||
|
|
||||||
|
empty.traversePreOrderWithoutRecursion();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenABinaryTree_WhenTraversingPostOrder_ThenPrintValues() {
|
public void givenABinaryTree_WhenTraversingPostOrder_ThenPrintValues() {
|
||||||
|
|
||||||
|
@ -111,6 +128,14 @@ public class BinaryTreeUnitTest {
|
||||||
bt.traversePostOrderWithoutRecursion();
|
bt.traversePostOrderWithoutRecursion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenAnEmptyBinaryTree_WhenTraversingPostOrderWithoutRecursion_ThenNoException() {
|
||||||
|
|
||||||
|
BinaryTree empty = new BinaryTree();
|
||||||
|
|
||||||
|
empty.traversePostOrderWithoutRecursion();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenABinaryTree_WhenTraversingLevelOrder_ThenPrintValues() {
|
public void givenABinaryTree_WhenTraversingLevelOrder_ThenPrintValues() {
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<version>2.16</version>
|
|
||||||
<configuration>
|
<configuration>
|
||||||
<enableAssertions>true</enableAssertions>
|
<enableAssertions>true</enableAssertions>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
|
@ -66,7 +66,6 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<version>${maven-surefire-plugin.version}</version>
|
|
||||||
<configuration>
|
<configuration>
|
||||||
<forkCount>0</forkCount>
|
<forkCount>0</forkCount>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
@ -75,13 +74,10 @@
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
|
|
||||||
<source.version>9</source.version>
|
<source.version>9</source.version>
|
||||||
<target.version>9</target.version>
|
<target.version>9</target.version>
|
||||||
|
|
||||||
<compiler.plugin.version>3.8.1</compiler.plugin.version>
|
<compiler.plugin.version>3.8.1</compiler.plugin.version>
|
||||||
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
|
|
||||||
|
|
||||||
<appmodules.version>1.0</appmodules.version>
|
<appmodules.version>1.0</appmodules.version>
|
||||||
|
|
||||||
|
|
|
@ -99,15 +99,6 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<joda-money.version>1.0.1</joda-money.version>
|
<joda-money.version>1.0.1</joda-money.version>
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,6 @@
|
||||||
<!-- Skip normal test execution, we use gwt:test instead -->
|
<!-- Skip normal test execution, we use gwt:test instead -->
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<version>${surefire.plugin.version}</version>
|
|
||||||
<configuration>
|
<configuration>
|
||||||
<skip>true</skip>
|
<skip>true</skip>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
@ -113,12 +112,8 @@
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
|
|
||||||
<!-- Don't let your Mac use a crazy non-standard encoding -->
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
|
||||||
<gwt.version>2.8.2</gwt.version>
|
<gwt.version>2.8.2</gwt.version>
|
||||||
<gwt.plugin.version>1.0-rc-8</gwt.plugin.version>
|
<gwt.plugin.version>1.0-rc-8</gwt.plugin.version>
|
||||||
<surefire.plugin.version>2.17</surefire.plugin.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -66,14 +66,6 @@
|
||||||
<filtering>true</filtering>
|
<filtering>true</filtering>
|
||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
|
||||||
<version>2.22.2</version>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|
|
@ -38,14 +38,6 @@
|
||||||
<filtering>true</filtering>
|
<filtering>true</filtering>
|
||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
|
||||||
<version>2.22.2</version>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|
|
@ -37,14 +37,6 @@
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<finalName>guava-collections-set</finalName>
|
<finalName>guava-collections-set</finalName>
|
||||||
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
|
||||||
<version>2.22.2</version>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|
|
@ -71,14 +71,6 @@
|
||||||
<filtering>true</filtering>
|
<filtering>true</filtering>
|
||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
|
||||||
<version>2.22.2</version>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|
|
@ -40,14 +40,6 @@
|
||||||
<filtering>true</filtering>
|
<filtering>true</filtering>
|
||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
|
||||||
<version>2.22.2</version>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -52,14 +52,6 @@
|
||||||
<filtering>true</filtering>
|
<filtering>true</filtering>
|
||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
|
||||||
<version>2.22.2</version>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|
|
@ -46,17 +46,8 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
|
||||||
<version>2.22.2</version>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
|
||||||
<junit-jupiter.version>5.6.2</junit-jupiter.version>
|
<junit-jupiter.version>5.6.2</junit-jupiter.version>
|
||||||
<guava.version>29.0-jre</guava.version>
|
<guava.version>29.0-jre</guava.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
|
@ -50,16 +50,6 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
|
||||||
<version>2.22.2</version>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<junit-jupiter.version>5.6.2</junit-jupiter.version>
|
<junit-jupiter.version>5.6.2</junit-jupiter.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
|
@ -51,14 +51,6 @@
|
||||||
<filtering>true</filtering>
|
<filtering>true</filtering>
|
||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
|
||||||
<version>2.22.2</version>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|
|
@ -1,24 +1,25 @@
|
||||||
package com.baeldung.rmi;
|
package com.baeldung.rmi;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import org.junit.Before;
|
||||||
import static org.junit.Assert.fail;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.rmi.NotBoundException;
|
import java.rmi.NotBoundException;
|
||||||
import java.rmi.RemoteException;
|
import java.rmi.RemoteException;
|
||||||
import java.rmi.registry.LocateRegistry;
|
import java.rmi.registry.LocateRegistry;
|
||||||
import java.rmi.registry.Registry;
|
import java.rmi.registry.Registry;
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
import static org.junit.Assert.assertEquals;
|
||||||
import org.junit.Test;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
public class JavaRMIIntegrationTest {
|
public class JavaRMIIntegrationTest {
|
||||||
|
|
||||||
@BeforeClass
|
private MessengerServiceImpl messengerService;
|
||||||
public static void whenRunServer_thenServerStarts() {
|
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void init() {
|
||||||
try {
|
try {
|
||||||
MessengerServiceImpl server = new MessengerServiceImpl();
|
messengerService = new MessengerServiceImpl();
|
||||||
server.createStubAndBind();
|
messengerService.createStubAndBind();
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
fail("Exception Occurred: " + e);
|
fail("Exception Occurred: " + e);
|
||||||
}
|
}
|
||||||
|
@ -26,7 +27,6 @@ public class JavaRMIIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenClientSendsMessageToServer_thenServerSendsResponseMessage() {
|
public void whenClientSendsMessageToServer_thenServerSendsResponseMessage() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Registry registry = LocateRegistry.getRegistry();
|
Registry registry = LocateRegistry.getRegistry();
|
||||||
MessengerService server = (MessengerService) registry.lookup("MessengerService");
|
MessengerService server = (MessengerService) registry.lookup("MessengerService");
|
||||||
|
@ -36,7 +36,7 @@ public class JavaRMIIntegrationTest {
|
||||||
assertEquals(responseMessage, expectedMessage);
|
assertEquals(responseMessage, expectedMessage);
|
||||||
} catch (RemoteException | NotBoundException e) {
|
} catch (RemoteException | NotBoundException e) {
|
||||||
fail("Exception Occurred: " + e);
|
fail("Exception Occurred: " + e);
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -523,7 +523,6 @@
|
||||||
<jersey.version>2.25</jersey.version>
|
<jersey.version>2.25</jersey.version>
|
||||||
<arquillian-glassfish.version>1.0.0.Final</arquillian-glassfish.version>
|
<arquillian-glassfish.version>1.0.0.Final</arquillian-glassfish.version>
|
||||||
<org.springframework.security.version>4.2.3.RELEASE</org.springframework.security.version>
|
<org.springframework.security.version>4.2.3.RELEASE</org.springframework.security.version>
|
||||||
<maven-surefire-plugin.version>2.21.0</maven-surefire-plugin.version>
|
|
||||||
<taglibs.standard.version>1.1.2</taglibs.standard.version>
|
<taglibs.standard.version>1.1.2</taglibs.standard.version>
|
||||||
<com.sun.faces.jsf.version>2.2.14</com.sun.faces.jsf.version>
|
<com.sun.faces.jsf.version>2.2.14</com.sun.faces.jsf.version>
|
||||||
<httpclient.version>4.5</httpclient.version>
|
<httpclient.version>4.5</httpclient.version>
|
||||||
|
|
|
@ -12,7 +12,7 @@ import javax.batch.runtime.StepExecution;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
class CustomCheckPointUnitTest {
|
class CustomCheckPointIntegrationTest {
|
||||||
@Test
|
@Test
|
||||||
public void givenChunk_whenCustomCheckPoint_thenCommitCountIsThree() throws Exception {
|
public void givenChunk_whenCustomCheckPoint_thenCommitCountIsThree() throws Exception {
|
||||||
JobOperator jobOperator = BatchRuntime.getJobOperator();
|
JobOperator jobOperator = BatchRuntime.getJobOperator();
|
|
@ -16,7 +16,7 @@ import javax.batch.runtime.StepExecution;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
class JobSequenceUnitTest {
|
class JobSequenceIntegrationTest {
|
||||||
@Test
|
@Test
|
||||||
public void givenTwoSteps_thenBatch_CompleteWithSuccess() throws Exception {
|
public void givenTwoSteps_thenBatch_CompleteWithSuccess() throws Exception {
|
||||||
JobOperator jobOperator = BatchRuntime.getJobOperator();
|
JobOperator jobOperator = BatchRuntime.getJobOperator();
|
|
@ -11,7 +11,7 @@ import javax.batch.runtime.JobExecution;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
class SimpleBatchLetUnitTest {
|
class SimpleBatchLetIntegrationTest {
|
||||||
@Test
|
@Test
|
||||||
public void givenBatchLet_thenBatch_CompleteWithSuccess() throws Exception {
|
public void givenBatchLet_thenBatch_CompleteWithSuccess() throws Exception {
|
||||||
JobOperator jobOperator = BatchRuntime.getJobOperator();
|
JobOperator jobOperator = BatchRuntime.getJobOperator();
|
|
@ -16,7 +16,7 @@ import javax.batch.runtime.StepExecution;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
class SimpleChunkUnitTest {
|
class SimpleChunkIntegrationTest {
|
||||||
@Test
|
@Test
|
||||||
public void givenChunk_thenBatch_CompletesWithSucess() throws Exception {
|
public void givenChunk_thenBatch_CompletesWithSucess() throws Exception {
|
||||||
JobOperator jobOperator = BatchRuntime.getJobOperator();
|
JobOperator jobOperator = BatchRuntime.getJobOperator();
|
|
@ -13,7 +13,7 @@ import javax.batch.runtime.StepExecution;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
class SimpleErrorChunkUnitTest {
|
class SimpleErrorChunkIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenChunkError_thenBatch_CompletesWithFailed() throws Exception {
|
public void givenChunkError_thenBatch_CompletesWithFailed() throws Exception {
|
|
@ -1099,8 +1099,6 @@
|
||||||
<scala.version>2.12.6</scala.version>
|
<scala.version>2.12.6</scala.version>
|
||||||
<node.version>v10.15.0</node.version>
|
<node.version>v10.15.0</node.version>
|
||||||
<npm.version>6.4.1</npm.version>
|
<npm.version>6.4.1</npm.version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
|
||||||
<project.testresult.directory>${project.build.directory}/test-results</project.testresult.directory>
|
<project.testresult.directory>${project.build.directory}/test-results</project.testresult.directory>
|
||||||
<maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>
|
<maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>
|
||||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||||
|
|
|
@ -1020,8 +1020,6 @@
|
||||||
<scala.version>2.12.6</scala.version>
|
<scala.version>2.12.6</scala.version>
|
||||||
<node.version>v8.12.0</node.version>
|
<node.version>v8.12.0</node.version>
|
||||||
<npm.version>6.4.1</npm.version>
|
<npm.version>6.4.1</npm.version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
|
||||||
<project.testresult.directory>${project.build.directory}/test-results</project.testresult.directory>
|
<project.testresult.directory>${project.build.directory}/test-results</project.testresult.directory>
|
||||||
<maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>
|
<maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>
|
||||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||||
|
|
|
@ -840,8 +840,6 @@
|
||||||
<scala.version>2.12.6</scala.version>
|
<scala.version>2.12.6</scala.version>
|
||||||
<node.version>v8.12.0</node.version>
|
<node.version>v8.12.0</node.version>
|
||||||
<npm.version>6.4.1</npm.version>
|
<npm.version>6.4.1</npm.version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
|
||||||
<project.testresult.directory>${project.build.directory}/test-results</project.testresult.directory>
|
<project.testresult.directory>${project.build.directory}/test-results</project.testresult.directory>
|
||||||
<maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>
|
<maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>
|
||||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||||
|
|
|
@ -842,8 +842,6 @@
|
||||||
<scala.version>2.12.6</scala.version>
|
<scala.version>2.12.6</scala.version>
|
||||||
<node.version>v8.12.0</node.version>
|
<node.version>v8.12.0</node.version>
|
||||||
<npm.version>6.4.1</npm.version>
|
<npm.version>6.4.1</npm.version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
|
||||||
<project.testresult.directory>${project.build.directory}/test-results</project.testresult.directory>
|
<project.testresult.directory>${project.build.directory}/test-results</project.testresult.directory>
|
||||||
<maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>
|
<maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>
|
||||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||||
|
|
|
@ -19,12 +19,12 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
<artifactId>jmh-core</artifactId>
|
<artifactId>jmh-core</artifactId>
|
||||||
<version>${openjdk.jmh.version}</version>
|
<version>${jmh-core.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
<artifactId>jmh-generator-annprocess</artifactId>
|
<artifactId>jmh-generator-annprocess</artifactId>
|
||||||
<version>${openjdk.jmh.version}</version>
|
<version>${jmh-generator.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjdk.jol</groupId>
|
<groupId>org.openjdk.jol</groupId>
|
||||||
|
@ -76,7 +76,6 @@
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<openjdk.jmh.version>1.19</openjdk.jmh.version>
|
|
||||||
<maven-jar-plugin.version>3.0.2</maven-jar-plugin.version>
|
<maven-jar-plugin.version>3.0.2</maven-jar-plugin.version>
|
||||||
<jol-core.version>0.10</jol-core.version>
|
<jol-core.version>0.10</jol-core.version>
|
||||||
<maven-assembly-plugin.version>3.2.0</maven-assembly-plugin.version>
|
<maven-assembly-plugin.version>3.2.0</maven-assembly-plugin.version>
|
||||||
|
|
|
@ -11,3 +11,7 @@ An easy way to check that everything is working as expected is issuing any *kube
|
||||||
$ kubectl get nodes
|
$ kubectl get nodes
|
||||||
```
|
```
|
||||||
If you get a valid response, then you're good to go.
|
If you get a valid response, then you're good to go.
|
||||||
|
|
||||||
|
### Relevant Articles:
|
||||||
|
|
||||||
|
- [Paging and Async Calls with the Kubernetes API](https://www.baeldung.com/java-kubernetes-paging-async)
|
||||||
|
|
|
@ -55,12 +55,12 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.bytebuddy</groupId>
|
<groupId>net.bytebuddy</groupId>
|
||||||
<artifactId>byte-buddy</artifactId>
|
<artifactId>byte-buddy</artifactId>
|
||||||
<version>${bytebuddy.version}</version>
|
<version>${byte-buddy.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.bytebuddy</groupId>
|
<groupId>net.bytebuddy</groupId>
|
||||||
<artifactId>byte-buddy-agent</artifactId>
|
<artifactId>byte-buddy-agent</artifactId>
|
||||||
<version>${bytebuddy.version}</version>
|
<version>${byte-buddy.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--Java Docker API Client -->
|
<!--Java Docker API Client -->
|
||||||
|
@ -115,7 +115,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
<artifactId>jmh-core</artifactId>
|
<artifactId>jmh-core</artifactId>
|
||||||
<version>${jmh.version}</version>
|
<version>${jmh-core.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@ -127,14 +127,12 @@
|
||||||
<scala.version>2.11</scala.version>
|
<scala.version>2.11</scala.version>
|
||||||
<typesafe-akka.version>2.5.11</typesafe-akka.version>
|
<typesafe-akka.version>2.5.11</typesafe-akka.version>
|
||||||
<streamex.version>0.6.5</streamex.version>
|
<streamex.version>0.6.5</streamex.version>
|
||||||
<bytebuddy.version>1.7.1</bytebuddy.version>
|
|
||||||
<docker.version>3.0.14</docker.version>
|
<docker.version>3.0.14</docker.version>
|
||||||
<caffeine.version>2.5.5</caffeine.version>
|
<caffeine.version>2.5.5</caffeine.version>
|
||||||
<findbugs.version>3.0.2</findbugs.version>
|
<findbugs.version>3.0.2</findbugs.version>
|
||||||
<fugue.version>4.5.1</fugue.version>
|
<fugue.version>4.5.1</fugue.version>
|
||||||
<jnats.version>1.0</jnats.version>
|
<jnats.version>1.0</jnats.version>
|
||||||
<jctools.version>2.1.2</jctools.version>
|
<jctools.version>2.1.2</jctools.version>
|
||||||
<jmh.version>1.19</jmh.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -26,13 +26,13 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
<artifactId>jmh-core</artifactId>
|
<artifactId>jmh-core</artifactId>
|
||||||
<version>${jmh.version}</version>
|
<version>${jmh-core.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
<artifactId>jmh-generator-annprocess</artifactId>
|
<artifactId>jmh-generator-annprocess</artifactId>
|
||||||
<version>${jmh.version}</version>
|
<version>${jmh-generator.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- Eclipse Collections -->
|
<!-- Eclipse Collections -->
|
||||||
|
@ -46,10 +46,11 @@
|
||||||
<properties>
|
<properties>
|
||||||
<fastutil.version>8.2.2</fastutil.version>
|
<fastutil.version>8.2.2</fastutil.version>
|
||||||
<junit.version>4.12</junit.version>
|
<junit.version>4.12</junit.version>
|
||||||
<jmh.version>1.19</jmh.version>
|
|
||||||
<eclipse-collections.version>10.0.0</eclipse-collections.version>
|
<eclipse-collections.version>10.0.0</eclipse-collections.version>
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
|
<jmh-core.version>1.28</jmh-core.version>
|
||||||
|
<jmh-generator.version>1.28</jmh-generator.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -202,7 +202,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
<artifactId>jmh-core</artifactId>
|
<artifactId>jmh-core</artifactId>
|
||||||
<version>${jmh.version}</version>
|
<version>${jmh-core.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
|
@ -395,7 +395,6 @@
|
||||||
<spring-mock-mvc.version>3.0.3</spring-mock-mvc.version>
|
<spring-mock-mvc.version>3.0.3</spring-mock-mvc.version>
|
||||||
<quartz.version>2.3.0</quartz.version>
|
<quartz.version>2.3.0</quartz.version>
|
||||||
<jool.version>0.9.12</jool.version>
|
<jool.version>0.9.12</jool.version>
|
||||||
<jmh.version>1.19</jmh.version>
|
|
||||||
<maven-jar-plugin.version>3.0.2</maven-jar-plugin.version>
|
<maven-jar-plugin.version>3.0.2</maven-jar-plugin.version>
|
||||||
<commons-net.version>3.6</commons-net.version>
|
<commons-net.version>3.6</commons-net.version>
|
||||||
<commonsio.version>2.6</commonsio.version>
|
<commonsio.version>2.6</commonsio.version>
|
||||||
|
|
|
@ -95,14 +95,6 @@
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</pluginManagement>
|
</pluginManagement>
|
||||||
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
|
||||||
<version>2.22.2</version>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|
|
@ -14,23 +14,13 @@
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
|
<module>flogger</module>
|
||||||
<module>log4j</module>
|
<module>log4j</module>
|
||||||
<module>log4j2</module>
|
<module>log4j2</module>
|
||||||
<module>logback</module>
|
<module>logback</module>
|
||||||
<module>log-mdc</module>
|
<module>log-mdc</module>
|
||||||
<module>flogger</module>
|
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
|
||||||
<version>2.22.2</version>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<junit-jupiter.version>5.6.2</junit-jupiter.version>
|
<junit-jupiter.version>5.6.2</junit-jupiter.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
|
@ -20,14 +20,15 @@
|
||||||
<module>maven-integration-test</module>
|
<module>maven-integration-test</module>
|
||||||
<module>maven-multi-source</module>
|
<module>maven-multi-source</module>
|
||||||
<module>maven-plugins</module>
|
<module>maven-plugins</module>
|
||||||
<module>maven-unused-dependencies</module>
|
|
||||||
<module>maven-war-plugin</module>
|
|
||||||
<module>maven-profiles</module>
|
<module>maven-profiles</module>
|
||||||
<module>maven-properties</module>
|
<module>maven-properties</module>
|
||||||
<module>versions-maven-plugin</module>
|
<!-- <module>maven-proxy</module> --> <!-- Not a maven project -->
|
||||||
<module>version-collision</module>
|
<module>maven-unused-dependencies</module>
|
||||||
|
<module>maven-war-plugin</module>
|
||||||
<module>optional-dependencies</module>
|
<module>optional-dependencies</module>
|
||||||
|
<module>version-collision</module>
|
||||||
<module>version-overriding-plugins</module>
|
<module>version-overriding-plugins</module>
|
||||||
|
<module>versions-maven-plugin</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -32,18 +32,17 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
<artifactId>jmh-core</artifactId>
|
<artifactId>jmh-core</artifactId>
|
||||||
<version>${jmh.version}</version>
|
<version>${jmh-core.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
<artifactId>jmh-generator-annprocess</artifactId>
|
<artifactId>jmh-generator-annprocess</artifactId>
|
||||||
<version>${jmh.version}</version>
|
<version>${jmh-generator.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<guava.version>29.0-jre</guava.version>
|
<guava.version>29.0-jre</guava.version>
|
||||||
<jmh.version>1.19</jmh.version>
|
|
||||||
<modelmapper.version>2.3.7</modelmapper.version>
|
<modelmapper.version>2.3.7</modelmapper.version>
|
||||||
<hamcrest.version>2.2</hamcrest.version>
|
<hamcrest.version>2.2</hamcrest.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
|
@ -15,10 +15,6 @@
|
||||||
<relativePath>../../parent-boot-2</relativePath>
|
<relativePath>../../parent-boot-2</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<properties>
|
|
||||||
<java.version>1.8</java.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.h2database</groupId>
|
<groupId>com.h2database</groupId>
|
||||||
|
|
|
@ -38,8 +38,8 @@ public class UsingOptional {
|
||||||
.flatMap(list -> list.stream().findFirst());
|
.flatMap(list -> list.stream().findFirst());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Optional<List> getOptionalList() {
|
private Optional<List<String>> getOptionalList() {
|
||||||
return Optional.ofNullable(getList());
|
return Optional.of(getList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private String doSomething(boolean processed) {
|
private String doSomething(boolean processed) {
|
||||||
|
|
|
@ -19,22 +19,22 @@ class UsingOptionalUnitTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenArgIsFalse_thenReturnEmptyResponse() {
|
void whenArgIsFalse_thenReturnEmptyResponse() {
|
||||||
Optional<Object> result = dataObject.process(false);
|
Optional<Object> result = dataObject.process(false);
|
||||||
|
|
||||||
assertFalse(result.isPresent());
|
assertFalse(result.isPresent());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenArgIsTrue_thenReturnValidResponse() {
|
void whenArgIsTrue_thenReturnValidResponse() {
|
||||||
Optional<Object> result = dataObject.process(true);
|
Optional<Object> result = dataObject.process(true);
|
||||||
|
|
||||||
assertTrue(result.isPresent());
|
assertTrue(result.isPresent());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenArgIsFalse_thenChainResponseAndThrowException() {
|
void whenArgIsFalse_thenChainResponseAndThrowException() {
|
||||||
assertThrows(Exception.class, () -> dataObject.process(false).orElseThrow(() -> new Exception()));
|
assertThrows(Exception.class, () -> dataObject.process(false).orElseThrow(Exception::new));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test()
|
@Test()
|
||||||
|
@ -51,7 +51,4 @@ class UsingOptionalUnitTest {
|
||||||
void whenOptionalListFirst_returnsEmptyOptional() {
|
void whenOptionalListFirst_returnsEmptyOptional() {
|
||||||
assertFalse(dataObject.optionalListFirst().isPresent());
|
assertFalse(dataObject.optionalListFirst().isPresent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -15,10 +15,6 @@
|
||||||
<relativePath>../../parent-boot-2</relativePath>
|
<relativePath>../../parent-boot-2</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<properties>
|
|
||||||
<java.version>1.8</java.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
|
|
@ -42,12 +42,12 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
<artifactId>jmh-core</artifactId>
|
<artifactId>jmh-core</artifactId>
|
||||||
<version>${jmh.version}</version>
|
<version>${jmh-core.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
<artifactId>jmh-generator-annprocess</artifactId>
|
<artifactId>jmh-generator-annprocess</artifactId>
|
||||||
<version>${jmh.version}</version>
|
<version>${jmh-generator.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@ -67,7 +67,7 @@
|
||||||
<path>
|
<path>
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
<artifactId>jmh-generator-annprocess</artifactId>
|
<artifactId>jmh-generator-annprocess</artifactId>
|
||||||
<version>${jmh.version}</version>
|
<version>${jmh-generator.version}</version>
|
||||||
</path>
|
</path>
|
||||||
<path>
|
<path>
|
||||||
<groupId>org.mapstruct</groupId>
|
<groupId>org.mapstruct</groupId>
|
||||||
|
@ -147,19 +147,11 @@
|
||||||
<artifactId>maven-source-plugin</artifactId>
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
<version>${source.plugin.version}</version>
|
<version>${source.plugin.version}</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
|
||||||
<version>${surefire.plugin.version}</version>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</pluginManagement>
|
</pluginManagement>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<!--
|
|
||||||
JMH version to use with this project.
|
|
||||||
-->
|
|
||||||
<jmh.version>1.23</jmh.version>
|
|
||||||
<orika.version>1.5.4</orika.version>
|
<orika.version>1.5.4</orika.version>
|
||||||
<dozer.version>6.5.0</dozer.version>
|
<dozer.version>6.5.0</dozer.version>
|
||||||
<mapstruct.version>1.3.1.Final</mapstruct.version>
|
<mapstruct.version>1.3.1.Final</mapstruct.version>
|
||||||
|
@ -185,7 +177,6 @@
|
||||||
<resources.plugin.version>3.1.0</resources.plugin.version>
|
<resources.plugin.version>3.1.0</resources.plugin.version>
|
||||||
<site.plugin.version>3.9.1</site.plugin.version>
|
<site.plugin.version>3.9.1</site.plugin.version>
|
||||||
<source.plugin.version>3.2.1</source.plugin.version>
|
<source.plugin.version>3.2.1</source.plugin.version>
|
||||||
<surefire.plugin.version>2.17</surefire.plugin.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.testcontainers</groupId>
|
<groupId>org.testcontainers</groupId>
|
||||||
<artifactId>testcontainers</artifactId>
|
<artifactId>testcontainers</artifactId>
|
||||||
<version>1.14.3</version>
|
<version>${testcontainers.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<org.apache.bookkeeper.version>4.10.0</org.apache.bookkeeper.version>
|
<org.apache.bookkeeper.version>4.10.0</org.apache.bookkeeper.version>
|
||||||
|
<testcontainers.version>1.14.3</testcontainers.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,3 +2,4 @@
|
||||||
|
|
||||||
- [Getting Database URL From JDBC Connection Object](https://www.baeldung.com/jdbc-get-url-from-connection)
|
- [Getting Database URL From JDBC Connection Object](https://www.baeldung.com/jdbc-get-url-from-connection)
|
||||||
- [JDBC URL Format For Different Databases](https://www.baeldung.com/java-jdbc-url-format)
|
- [JDBC URL Format For Different Databases](https://www.baeldung.com/java-jdbc-url-format)
|
||||||
|
- [How to Check if a Database Table Exists with JDBC](https://www.baeldung.com/jdbc-check-table-exists)
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.baeldung.tableexists;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
class DatabaseConfig {
|
||||||
|
static Connection connect() throws ClassNotFoundException, SQLException {
|
||||||
|
Class.forName("org.h2.Driver");
|
||||||
|
String url = "jdbc:h2:mem:testdb";
|
||||||
|
return DriverManager.getConnection(url, "user", "password");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void createTables(Connection connection) throws SQLException {
|
||||||
|
connection.createStatement().executeUpdate("create table EMPLOYEE (id int primary key auto_increment, name VARCHAR(255))");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dropTables(Connection connection) throws SQLException {
|
||||||
|
connection.createStatement().executeUpdate("drop table EMPLOYEE");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.baeldung.tableexists;
|
||||||
|
|
||||||
|
import java.sql.*;
|
||||||
|
|
||||||
|
class TableChecker {
|
||||||
|
static void printAllTables(Connection connection, String tableName) throws SQLException {
|
||||||
|
DatabaseMetaData databaseMetaData = connection.getMetaData();
|
||||||
|
ResultSet resultSet = databaseMetaData.getTables(null, null, tableName, new String[] {"TABLE"});
|
||||||
|
|
||||||
|
while (resultSet.next()) {
|
||||||
|
String name = resultSet.getString("TABLE_NAME");
|
||||||
|
String schema = resultSet.getString("TABLE_SCHEM");
|
||||||
|
System.out.println(name + " on schema " + schema);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean tableExists(Connection connection, String tableName) throws SQLException {
|
||||||
|
DatabaseMetaData meta = connection.getMetaData();
|
||||||
|
ResultSet resultSet = meta.getTables(null, null, tableName, new String[] {"TABLE"});
|
||||||
|
|
||||||
|
return resultSet.next();
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean tableExistsSQL(Connection connection, String tableName) throws SQLException {
|
||||||
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT count(*) " +
|
||||||
|
"FROM information_schema.tables " +
|
||||||
|
"WHERE table_name = ?" +
|
||||||
|
"LIMIT 1;");
|
||||||
|
preparedStatement.setString(1, tableName);
|
||||||
|
|
||||||
|
ResultSet resultSet = preparedStatement.executeQuery();
|
||||||
|
resultSet.next();
|
||||||
|
return resultSet.getInt(1) != 0;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,70 @@
|
||||||
|
package com.baeldung.tableexists;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
class TableCheckerUnitTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void givenCreatedTable_shouldFindTable() throws SQLException, ClassNotFoundException {
|
||||||
|
// given
|
||||||
|
Connection connection = DatabaseConfig.connect();
|
||||||
|
DatabaseConfig.createTables(connection);
|
||||||
|
|
||||||
|
// when
|
||||||
|
boolean tableExists = TableChecker.tableExists(connection, "EMPLOYEE");
|
||||||
|
|
||||||
|
// then
|
||||||
|
TableChecker.printAllTables(connection, null);
|
||||||
|
assertTrue(tableExists);
|
||||||
|
|
||||||
|
DatabaseConfig.dropTables(connection);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void givenCreatedTable_shouldFindTableWithSQL() throws SQLException, ClassNotFoundException {
|
||||||
|
// given
|
||||||
|
Connection connection = DatabaseConfig.connect();
|
||||||
|
DatabaseConfig.createTables(connection);
|
||||||
|
|
||||||
|
// when
|
||||||
|
boolean tableExists = TableChecker.tableExistsSQL(connection, "EMPLOYEE");
|
||||||
|
|
||||||
|
// then
|
||||||
|
TableChecker.printAllTables(connection, null);
|
||||||
|
assertTrue(tableExists);
|
||||||
|
|
||||||
|
DatabaseConfig.dropTables(connection);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void givenNoTable_shouldNotFindTable() throws SQLException, ClassNotFoundException {
|
||||||
|
// given
|
||||||
|
Connection connection = DatabaseConfig.connect();
|
||||||
|
|
||||||
|
// when
|
||||||
|
boolean tableExists = TableChecker.tableExists(connection, "EMPLOYEE");
|
||||||
|
|
||||||
|
// then
|
||||||
|
TableChecker.printAllTables(connection, null);
|
||||||
|
assertFalse(tableExists);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void givenNoTable_shouldNotFindTableWithSQL() throws SQLException, ClassNotFoundException {
|
||||||
|
// given
|
||||||
|
Connection connection = DatabaseConfig.connect();
|
||||||
|
|
||||||
|
// when
|
||||||
|
boolean tableExists = TableChecker.tableExistsSQL(connection, "EMPLOYEE");
|
||||||
|
|
||||||
|
// then
|
||||||
|
TableChecker.printAllTables(connection, null);
|
||||||
|
assertFalse(tableExists);
|
||||||
|
}
|
||||||
|
}
|
|
@ -79,7 +79,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
<artifactId>jmh-generator-annprocess</artifactId>
|
<artifactId>jmh-generator-annprocess</artifactId>
|
||||||
<version>${openjdk-jmh.version}</version>
|
<version>${jmh-generator.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.postgresql</groupId>
|
<groupId>org.postgresql</groupId>
|
||||||
|
@ -94,7 +94,6 @@
|
||||||
<postgresql.version>42.2.11</postgresql.version>
|
<postgresql.version>42.2.11</postgresql.version>
|
||||||
<mariaDB4j.version>2.2.3</mariaDB4j.version>
|
<mariaDB4j.version>2.2.3</mariaDB4j.version>
|
||||||
<assertj-core.version>3.8.0</assertj-core.version>
|
<assertj-core.version>3.8.0</assertj-core.version>
|
||||||
<openjdk-jmh.version>1.21</openjdk-jmh.version>
|
|
||||||
<spring-boot.version>2.1.7.RELEASE</spring-boot.version>
|
<spring-boot.version>2.1.7.RELEASE</spring-boot.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
|
|
@ -175,7 +175,6 @@
|
||||||
<log4jdbc.version>2.0.0</log4jdbc.version>
|
<log4jdbc.version>2.0.0</log4jdbc.version>
|
||||||
<logback.version>1.2.3</logback.version>
|
<logback.version>1.2.3</logback.version>
|
||||||
<maven-jar-plugin.version>3.0.2</maven-jar-plugin.version>
|
<maven-jar-plugin.version>3.0.2</maven-jar-plugin.version>
|
||||||
<maven.surefire.version>2.22.2</maven.surefire.version>
|
|
||||||
<maven.compiler.version>3.8.1</maven.compiler.version>
|
<maven.compiler.version>3.8.1</maven.compiler.version>
|
||||||
<maven.version>3.8.1</maven.version>
|
<maven.version>3.8.1</maven.version>
|
||||||
<mysql.version>8.0.19</mysql.version>
|
<mysql.version>8.0.19</mysql.version>
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
<artifactId>jmh-generator-annprocess</artifactId>
|
<artifactId>jmh-generator-annprocess</artifactId>
|
||||||
<version>${openjdk-jmh.version}</version>
|
<version>${jmh-generator.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@ -61,7 +61,6 @@
|
||||||
<mysql.version>6.0.6</mysql.version>
|
<mysql.version>6.0.6</mysql.version>
|
||||||
<mariaDB4j.version>2.2.3</mariaDB4j.version>
|
<mariaDB4j.version>2.2.3</mariaDB4j.version>
|
||||||
<assertj-core.version>3.8.0</assertj-core.version>
|
<assertj-core.version>3.8.0</assertj-core.version>
|
||||||
<openjdk-jmh.version>1.21</openjdk-jmh.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -59,7 +59,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
<artifactId>jmh-generator-annprocess</artifactId>
|
<artifactId>jmh-generator-annprocess</artifactId>
|
||||||
<version>${openjdk-jmh.version}</version>
|
<version>${jmh-generator.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@ -68,7 +68,6 @@
|
||||||
<mysql.version>6.0.6</mysql.version>
|
<mysql.version>6.0.6</mysql.version>
|
||||||
<mariaDB4j.version>2.2.3</mariaDB4j.version>
|
<mariaDB4j.version>2.2.3</mariaDB4j.version>
|
||||||
<assertj-core.version>3.8.0</assertj-core.version>
|
<assertj-core.version>3.8.0</assertj-core.version>
|
||||||
<openjdk-jmh.version>1.21</openjdk-jmh.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -30,17 +30,17 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>mysql</groupId>
|
<groupId>mysql</groupId>
|
||||||
<artifactId>mysql-connector-java</artifactId>
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
<version>8.0.21</version>
|
<version>${mysql.version}</version>
|
||||||
</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.11.3</version>
|
<version>${jackson.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
<artifactId>jackson-datatype-hibernate5</artifactId>
|
<artifactId>jackson-datatype-hibernate5</artifactId>
|
||||||
<version>2.9.8</version>
|
<version>${jackson.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--Compile time JPA API -->
|
<!--Compile time JPA API -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -87,6 +87,7 @@
|
||||||
<hibernate.version>5.4.14.Final</hibernate.version>
|
<hibernate.version>5.4.14.Final</hibernate.version>
|
||||||
<eclipselink.version>2.7.4</eclipselink.version>
|
<eclipselink.version>2.7.4</eclipselink.version>
|
||||||
<postgres.version>42.2.5</postgres.version>
|
<postgres.version>42.2.5</postgres.version>
|
||||||
|
<mysql.version>8.0.21</mysql.version>
|
||||||
<javax.persistence-api.version>2.2</javax.persistence-api.version>
|
<javax.persistence-api.version>2.2</javax.persistence-api.version>
|
||||||
<assertj.version>3.11.1</assertj.version>
|
<assertj.version>3.11.1</assertj.version>
|
||||||
<maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version>
|
<maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version>
|
||||||
|
|
|
@ -9,6 +9,7 @@ import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.service.ServiceRegistry;
|
import org.hibernate.service.ServiceRegistry;
|
||||||
|
|
||||||
public class HibernateConfig {
|
public class HibernateConfig {
|
||||||
|
|
||||||
private static SessionFactory sessionFactory;
|
private static SessionFactory sessionFactory;
|
||||||
|
|
||||||
public static SessionFactory getSessionFactory() {
|
public static SessionFactory getSessionFactory() {
|
||||||
|
@ -16,12 +17,12 @@ public class HibernateConfig {
|
||||||
Configuration configuration = new Configuration();
|
Configuration configuration = new Configuration();
|
||||||
|
|
||||||
Properties settings = new Properties();
|
Properties settings = new Properties();
|
||||||
settings.put(Environment.DRIVER, "com.mysql.cj.jdbc.Driver");
|
settings.put(Environment.DRIVER, "org.h2.Driver");
|
||||||
settings.put(Environment.URL, "jdbc:mysql://localhost:3306/app_db?useSSL=false");
|
settings.put(Environment.URL, "jdbc:h2:mem:test");
|
||||||
settings.put(Environment.USER, "root");
|
settings.put(Environment.USER, "sa");
|
||||||
settings.put(Environment.PASS, "password");
|
settings.put(Environment.PASS, "");
|
||||||
settings.put(Environment.DIALECT, "org.hibernate.dialect.MySQL5Dialect");
|
settings.put(Environment.DIALECT, "org.hibernate.dialect.H2Dialect");
|
||||||
settings.put(Environment.CURRENT_SESSION_CONTEXT_CLASS, "thread");
|
settings.put(Environment.HBM2DDL_AUTO, "create-drop");
|
||||||
configuration.setProperties(settings);
|
configuration.setProperties(settings);
|
||||||
|
|
||||||
configuration.addAnnotatedClass(User.class);
|
configuration.addAnnotatedClass(User.class);
|
||||||
|
|
|
@ -1,18 +1,24 @@
|
||||||
package com.baeldung.ignorable.fields;
|
package com.baeldung.ignorable.fields;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.MapperFeature;
|
import com.fasterxml.jackson.databind.MapperFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module;
|
import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.ObjectInputStream;
|
||||||
|
import java.io.ObjectOutputStream;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
|
||||||
public class TransientFieldUnitTest {
|
public class TransientFieldUnitTest {
|
||||||
|
|
||||||
|
@ -34,20 +40,22 @@ public class TransientFieldUnitTest {
|
||||||
@Test
|
@Test
|
||||||
public void givenFieldWithTransientAnnotation_whenSerializingObject_thenFieldSerialized() throws IOException, ClassNotFoundException {
|
public void givenFieldWithTransientAnnotation_whenSerializingObject_thenFieldSerialized() throws IOException, ClassNotFoundException {
|
||||||
|
|
||||||
FileOutputStream fout = new FileOutputStream("test.obj");
|
try (FileOutputStream fout = new FileOutputStream("test.obj")) {
|
||||||
ObjectOutputStream out = new ObjectOutputStream(fout);
|
ObjectOutputStream out = new ObjectOutputStream(fout);
|
||||||
out.writeObject(user);
|
out.writeObject(user);
|
||||||
out.flush();
|
out.flush();
|
||||||
out.close();
|
}
|
||||||
|
|
||||||
FileInputStream fin = new FileInputStream("test.obj");
|
try (FileInputStream fin = new FileInputStream("test.obj")) {
|
||||||
ObjectInputStream in = new ObjectInputStream(fin);
|
ObjectInputStream in = new ObjectInputStream(fin);
|
||||||
User savedUser = (User) in.readObject();
|
User savedUser = (User) in.readObject();
|
||||||
in.close();
|
|
||||||
|
|
||||||
assertEquals(user.getCurrentDevice(), savedUser.getCurrentDevice());
|
assertEquals(user.getCurrentDevice(), savedUser.getCurrentDevice());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Files.deleteIfExists(Paths.get("test.obj"));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenFieldWithTransientAnnotation_whenSerializingToJSON_thenFieldSerialized() throws JsonProcessingException {
|
public void givenFieldWithTransientAnnotation_whenSerializingToJSON_thenFieldSerialized() throws JsonProcessingException {
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
|
@ -19,28 +19,34 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jooq</groupId>
|
<groupId>org.jooq</groupId>
|
||||||
<artifactId>jooq</artifactId>
|
<artifactId>jooq</artifactId>
|
||||||
<version>3.13.4</version>
|
<version>${jooq.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jooq</groupId>
|
<groupId>org.jooq</groupId>
|
||||||
<artifactId>jooq-meta</artifactId>
|
<artifactId>jooq-meta</artifactId>
|
||||||
<version>3.13.4</version>
|
<version>${jooq.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jooq</groupId>
|
<groupId>org.jooq</groupId>
|
||||||
<artifactId>jooq-codegen</artifactId>
|
<artifactId>jooq-codegen</artifactId>
|
||||||
<version>3.13.4</version>
|
<version>${jooq.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.postgresql</groupId>
|
<groupId>org.postgresql</groupId>
|
||||||
<artifactId>postgresql</artifactId>
|
<artifactId>postgresql</artifactId>
|
||||||
<version>42.2.16</version>
|
<version>${postgresql.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.h2database</groupId>
|
<groupId>com.h2database</groupId>
|
||||||
<artifactId>h2</artifactId>
|
<artifactId>h2</artifactId>
|
||||||
<version>1.4.200</version>
|
<version>${h2.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<jooq.version>3.13.4</jooq.version>
|
||||||
|
<postgresql.version>42.2.16</postgresql.version>
|
||||||
|
<h2.version>1.4.200</h2.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
<module>java-jdbi</module>
|
<module>java-jdbi</module>
|
||||||
<module>java-jpa</module> <!-- long running -->
|
<module>java-jpa</module> <!-- long running -->
|
||||||
<module>java-jpa-2</module> <!-- long running -->
|
<module>java-jpa-2</module> <!-- long running -->
|
||||||
|
<module>java-jpa-3</module>
|
||||||
<module>java-mongodb</module> <!-- long running -->
|
<module>java-mongodb</module> <!-- long running -->
|
||||||
<module>jnosql</module> <!-- long running -->
|
<module>jnosql</module> <!-- long running -->
|
||||||
<module>jooq</module>
|
<module>jooq</module>
|
||||||
|
|
|
@ -47,7 +47,6 @@
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
<maven.release.version>11</maven.release.version>
|
<maven.release.version>11</maven.release.version>
|
||||||
<sirix-core.version>0.9.3</sirix-core.version>
|
<sirix-core.version>0.9.3</sirix-core.version>
|
||||||
<compiler.plugin.version>3.8.0</compiler.plugin.version>
|
<compiler.plugin.version>3.8.0</compiler.plugin.version>
|
||||||
|
|
|
@ -24,7 +24,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@SpringBootTest(classes = {SpringBootJdbiApplication.class, JdbiConfiguration.class})
|
@SpringBootTest(classes = {SpringBootJdbiApplication.class, JdbiConfiguration.class})
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class SpringBootJdbiApplicationUnitTest {
|
public class SpringBootJdbiApplicationIntegrationTest {
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
|
@ -20,7 +20,7 @@ import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
@AutoConfigureMockMvc
|
@AutoConfigureMockMvc
|
||||||
public class CustomerControllerUnitTest {
|
public class CustomerControllerIntegrationTest {
|
||||||
|
|
||||||
private static MediaType MEDIA_TYPE_JSON;
|
private static MediaType MEDIA_TYPE_JSON;
|
||||||
|
|
|
@ -14,9 +14,7 @@
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>1.8</java.version>
|
|
||||||
<cosmodb.version>2.3.0</cosmodb.version>
|
<cosmodb.version>2.3.0</cosmodb.version>
|
||||||
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
|
@ -61,7 +61,7 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>com.mysema.maven</groupId>
|
<groupId>com.mysema.maven</groupId>
|
||||||
<artifactId>maven-apt-plugin</artifactId>
|
<artifactId>maven-apt-plugin</artifactId>
|
||||||
<version>1.0</version>
|
<version>${maven-apt-plugin.version}</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>generate-sources</phase>
|
<phase>generate-sources</phase>
|
||||||
|
@ -88,6 +88,7 @@
|
||||||
<start-class>com.baeldung.springdatageode.app.ClientCacheApp</start-class>
|
<start-class>com.baeldung.springdatageode.app.ClientCacheApp</start-class>
|
||||||
<spring-geode-starter-version>1.1.1.RELEASE</spring-geode-starter-version>
|
<spring-geode-starter-version>1.1.1.RELEASE</spring-geode-starter-version>
|
||||||
<spring.boot.starter.version>2.1.9.RELEASE</spring.boot.starter.version>
|
<spring.boot.starter.version>2.1.9.RELEASE</spring.boot.starter.version>
|
||||||
|
<maven-apt-plugin.version>1.0</maven-apt-plugin.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -78,7 +78,7 @@
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.8.1</version>
|
<version>${maven-compiler-plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
|
@ -86,7 +86,7 @@
|
||||||
<path>
|
<path>
|
||||||
<groupId>org.mapstruct</groupId>
|
<groupId>org.mapstruct</groupId>
|
||||||
<artifactId>mapstruct-processor</artifactId>
|
<artifactId>mapstruct-processor</artifactId>
|
||||||
<version>1.3.1.Final</version>
|
<version>${mapstruct.version}</version>
|
||||||
</path>
|
</path>
|
||||||
</annotationProcessorPaths>
|
</annotationProcessorPaths>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
@ -98,7 +98,6 @@
|
||||||
<mapstruct.version>1.3.1.Final</mapstruct.version>
|
<mapstruct.version>1.3.1.Final</mapstruct.version>
|
||||||
<guava.version>21.0</guava.version>
|
<guava.version>21.0</guava.version>
|
||||||
<testcontainers.version>1.12.2</testcontainers.version>
|
<testcontainers.version>1.12.2</testcontainers.version>
|
||||||
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configuration>
|
||||||
|
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder>
|
||||||
|
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
|
||||||
|
</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<root level="INFO">
|
||||||
|
<appender-ref ref="STDOUT" />
|
||||||
|
</root>
|
||||||
|
</configuration>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue