Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
7c4cbc0968
@ -64,7 +64,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
<artifactId>cobertura-maven-plugin</artifactId>
|
<artifactId>cobertura-maven-plugin</artifactId>
|
||||||
<version>2.7</version>
|
<version>${cobertura.plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<instrumentation>
|
<instrumentation>
|
||||||
<ignores>
|
<ignores>
|
||||||
@ -85,6 +85,7 @@
|
|||||||
<commons-codec.version>1.11</commons-codec.version>
|
<commons-codec.version>1.11</commons-codec.version>
|
||||||
<guava.version>27.0.1-jre</guava.version>
|
<guava.version>27.0.1-jre</guava.version>
|
||||||
<combinatoricslib3.version>3.3.0</combinatoricslib3.version>
|
<combinatoricslib3.version>3.3.0</combinatoricslib3.version>
|
||||||
|
<cobertura.plugin.version>2.7</cobertura.plugin.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
@ -46,13 +46,13 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-lang3</artifactId>
|
<artifactId>commons-lang3</artifactId>
|
||||||
<version>3.8.1</version>
|
<version>${commons.lang3.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>pl.pragmatists</groupId>
|
<groupId>pl.pragmatists</groupId>
|
||||||
<artifactId>JUnitParams</artifactId>
|
<artifactId>JUnitParams</artifactId>
|
||||||
<version>1.1.0</version>
|
<version>${JUnitParams.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -91,6 +91,8 @@
|
|||||||
<retrofit.version>2.6.0</retrofit.version>
|
<retrofit.version>2.6.0</retrofit.version>
|
||||||
<jmh-core.version>1.19</jmh-core.version>
|
<jmh-core.version>1.19</jmh-core.version>
|
||||||
<jmh-generator.version>1.19</jmh-generator.version>
|
<jmh-generator.version>1.19</jmh-generator.version>
|
||||||
|
<commons.lang3.version>3.8.1</commons.lang3.version>
|
||||||
|
<JUnitParams.version>1.1.0</JUnitParams.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
@ -37,7 +37,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.guava</groupId>
|
<groupId>com.google.guava</groupId>
|
||||||
<artifactId>guava</artifactId>
|
<artifactId>guava</artifactId>
|
||||||
<version>28.1-jre</version>
|
<version>${guava.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -65,6 +65,7 @@
|
|||||||
<org.assertj.core.version>3.9.0</org.assertj.core.version>
|
<org.assertj.core.version>3.9.0</org.assertj.core.version>
|
||||||
<commons-codec.version>1.11</commons-codec.version>
|
<commons-codec.version>1.11</commons-codec.version>
|
||||||
<commons-math3.version>3.6.1</commons-math3.version>
|
<commons-math3.version>3.6.1</commons-math3.version>
|
||||||
|
<guava.version>28.1-jre</guava.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
4
algorithms-sorting-2/.gitignore
vendored
Normal file
4
algorithms-sorting-2/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
/target/
|
||||||
|
.settings/
|
||||||
|
.classpath
|
||||||
|
.project
|
64
algorithms-sorting-2/pom.xml
Normal file
64
algorithms-sorting-2/pom.xml
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>algorithms-sorting-2</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<name>algorithms-sorting-2</name>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>com.baeldung</groupId>
|
||||||
|
<artifactId>parent-modules</artifactId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-math3</artifactId>
|
||||||
|
<version>${commons-math3.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-codec</groupId>
|
||||||
|
<artifactId>commons-codec</artifactId>
|
||||||
|
<version>${commons-codec.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>${lombok.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
<artifactId>junit-jupiter-api</artifactId>
|
||||||
|
<version>${junit-jupiter-api.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.assertj</groupId>
|
||||||
|
<artifactId>assertj-core</artifactId>
|
||||||
|
<version>${org.assertj.core.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<pluginManagement>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
|
<version>${exec-maven-plugin.version}</version>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</pluginManagement>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<commons-math3.version>3.6.1</commons-math3.version>
|
||||||
|
<org.assertj.core.version>3.9.0</org.assertj.core.version>
|
||||||
|
<commons-codec.version>1.11</commons-codec.version>
|
||||||
|
<junit-jupiter-api.version>5.3.1</junit-jupiter-api.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
</project>
|
@ -0,0 +1,66 @@
|
|||||||
|
package com.baeldung.algorithms.quicksort;
|
||||||
|
|
||||||
|
import static com.baeldung.algorithms.quicksort.SortingUtils.swap;
|
||||||
|
|
||||||
|
public class BentleyMcIlroyPartioning {
|
||||||
|
|
||||||
|
public static Partition partition(int input[], int begin, int end) {
|
||||||
|
int left = begin, right = end;
|
||||||
|
int leftEqualKeysCount = 0, rightEqualKeysCount = 0;
|
||||||
|
|
||||||
|
int partitioningValue = input[end];
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
while (input[left] < partitioningValue)
|
||||||
|
left++;
|
||||||
|
|
||||||
|
while (input[right] > partitioningValue) {
|
||||||
|
if (right == begin)
|
||||||
|
break;
|
||||||
|
right--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (left == right && input[left] == partitioningValue) {
|
||||||
|
swap(input, begin + leftEqualKeysCount, left);
|
||||||
|
leftEqualKeysCount++;
|
||||||
|
left++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (left >= right) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
swap(input, left, right);
|
||||||
|
|
||||||
|
if (input[left] == partitioningValue) {
|
||||||
|
swap(input, begin + leftEqualKeysCount, left);
|
||||||
|
leftEqualKeysCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (input[right] == partitioningValue) {
|
||||||
|
swap(input, right, end - rightEqualKeysCount);
|
||||||
|
rightEqualKeysCount++;
|
||||||
|
}
|
||||||
|
left++; right--;
|
||||||
|
}
|
||||||
|
right = left - 1;
|
||||||
|
for (int k = begin; k < begin + leftEqualKeysCount; k++, right--) {
|
||||||
|
if (right >= begin + leftEqualKeysCount)
|
||||||
|
swap(input, k, right);
|
||||||
|
}
|
||||||
|
for (int k = end; k > end - rightEqualKeysCount; k--, left++) {
|
||||||
|
if (left <= end - rightEqualKeysCount)
|
||||||
|
swap(input, left, k);
|
||||||
|
}
|
||||||
|
return new Partition(right + 1, left - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void quicksort(int input[], int begin, int end) {
|
||||||
|
if (end <= begin)
|
||||||
|
return;
|
||||||
|
Partition middlePartition = partition(input, begin, end);
|
||||||
|
quicksort(input, begin, middlePartition.getLeft() - 1);
|
||||||
|
quicksort(input, middlePartition.getRight() + 1, end);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
package com.baeldung.algorithms.quicksort;
|
||||||
|
|
||||||
|
import static com.baeldung.algorithms.quicksort.SortingUtils.compare;
|
||||||
|
import static com.baeldung.algorithms.quicksort.SortingUtils.swap;
|
||||||
|
|
||||||
|
public class DutchNationalFlagPartioning {
|
||||||
|
|
||||||
|
public static Partition partition(int[] a, int begin, int end) {
|
||||||
|
int lt = begin, current = begin, gt = end;
|
||||||
|
int partitioningValue = a[begin];
|
||||||
|
|
||||||
|
while (current <= gt) {
|
||||||
|
int compareCurrent = compare(a[current], partitioningValue);
|
||||||
|
switch (compareCurrent) {
|
||||||
|
case -1:
|
||||||
|
swap(a, current++, lt++);
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
|
current++;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
swap(a, current, gt--);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new Partition(lt, gt);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void quicksort(int[] input, int begin, int end) {
|
||||||
|
if (end <= begin)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Partition middlePartition = partition(input, begin, end);
|
||||||
|
|
||||||
|
quicksort(input, begin, middlePartition.getLeft() - 1);
|
||||||
|
quicksort(input, middlePartition.getRight() + 1, end);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
package com.baeldung.algorithms.quicksort;
|
||||||
|
|
||||||
|
public class Partition {
|
||||||
|
private int left;
|
||||||
|
private int right;
|
||||||
|
|
||||||
|
public Partition(int left, int right) {
|
||||||
|
super();
|
||||||
|
this.left = left;
|
||||||
|
this.right = right;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLeft() {
|
||||||
|
return left;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLeft(int left) {
|
||||||
|
this.left = left;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRight() {
|
||||||
|
return right;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRight(int right) {
|
||||||
|
this.right = right;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package com.baeldung.algorithms.quicksort;
|
||||||
|
|
||||||
|
public class SortingUtils {
|
||||||
|
|
||||||
|
public static void swap(int[] array, int position1, int position2) {
|
||||||
|
if (position1 != position2) {
|
||||||
|
int temp = array[position1];
|
||||||
|
array[position1] = array[position2];
|
||||||
|
array[position2] = temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int compare(int num1, int num2) {
|
||||||
|
if (num1 > num2)
|
||||||
|
return 1;
|
||||||
|
else if (num1 < num2)
|
||||||
|
return -1;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void printArray(int[] array) {
|
||||||
|
if (array == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (int e : array) {
|
||||||
|
System.out.print(e + " ");
|
||||||
|
}
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
13
algorithms-sorting-2/src/main/resources/logback.xml
Normal file
13
algorithms-sorting-2/src/main/resources/logback.xml
Normal file
@ -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>
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.baeldung.algorithms.quicksort;
|
||||||
|
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class BentleyMcilroyPartitioningUnitTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void given_IntegerArray_whenSortedWithBentleyMcilroyPartitioning_thenGetSortedArray() {
|
||||||
|
int[] actual = {3, 2, 2, 2, 3, 7, 7, 3, 2, 2, 7, 3, 3};
|
||||||
|
int[] expected = {2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 7, 7, 7};
|
||||||
|
BentleyMcIlroyPartioning.quicksort(actual, 0, actual.length - 1);
|
||||||
|
Assert.assertArrayEquals(expected, actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.baeldung.algorithms.quicksort;
|
||||||
|
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class DNFThreeWayQuickSortUnitTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenIntegerArray_whenSortedWithThreeWayQuickSort_thenGetSortedArray() {
|
||||||
|
int[] actual = {3, 5, 5, 5, 3, 7, 7, 3, 5, 5, 7, 3, 3};
|
||||||
|
int[] expected = {3, 3, 3, 3, 3, 5, 5, 5, 5, 5, 7, 7, 7};
|
||||||
|
DutchNationalFlagPartioning.quicksort(actual, 0, actual.length - 1);
|
||||||
|
Assert.assertArrayEquals(expected, actual);
|
||||||
|
}
|
||||||
|
}
|
@ -18,19 +18,19 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.ws.rs</groupId>
|
<groupId>javax.ws.rs</groupId>
|
||||||
<artifactId>javax.ws.rs-api</artifactId>
|
<artifactId>javax.ws.rs-api</artifactId>
|
||||||
<version>2.1</version>
|
<version>${rs-api.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.enterprise</groupId>
|
<groupId>javax.enterprise</groupId>
|
||||||
<artifactId>cdi-api</artifactId>
|
<artifactId>cdi-api</artifactId>
|
||||||
<version>2.0</version>
|
<version>${cdi-api.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.json.bind</groupId>
|
<groupId>javax.json.bind</groupId>
|
||||||
<artifactId>javax.json.bind-api</artifactId>
|
<artifactId>javax.json.bind-api</artifactId>
|
||||||
<version>1.0</version>
|
<version>${bind-api.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@ -80,6 +80,9 @@
|
|||||||
<liberty-maven-plugin.version>2.4.2</liberty-maven-plugin.version>
|
<liberty-maven-plugin.version>2.4.2</liberty-maven-plugin.version>
|
||||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||||
<openliberty-version>18.0.0.2</openliberty-version>
|
<openliberty-version>18.0.0.2</openliberty-version>
|
||||||
|
<rs-api.version>2.1</rs-api.version>
|
||||||
|
<cdi-api.version>2.0</cdi-api.version>
|
||||||
|
<bind-api.version>1.0</bind-api.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -17,11 +17,12 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.rocketmq</groupId>
|
<groupId>org.apache.rocketmq</groupId>
|
||||||
<artifactId>rocketmq-spring-boot-starter</artifactId>
|
<artifactId>rocketmq-spring-boot-starter</artifactId>
|
||||||
<version>2.0.4</version>
|
<version>${rocketmq.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<geode.core>1.6.0</geode.core>
|
<geode.core>1.6.0</geode.core>
|
||||||
|
<rocketmq.version>2.0.4</rocketmq.version>
|
||||||
</properties>
|
</properties>
|
||||||
</project>
|
</project>
|
||||||
|
@ -81,10 +81,10 @@ of testing facilities designed for use with TestNG (http://testng.org/), so it's
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>2.3.2</version>
|
<version>${compiler.plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.8</source>
|
<source>${source.version}</source>
|
||||||
<target>1.8</target>
|
<target>${target.version}</target>
|
||||||
<optimize>true</optimize>
|
<optimize>true</optimize>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
@ -92,7 +92,7 @@ of testing facilities designed for use with TestNG (http://testng.org/), so it's
|
|||||||
<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.7.2</version>
|
<version>${compiler.surefire.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<systemPropertyVariables>
|
<systemPropertyVariables>
|
||||||
<tapestry.execution-mode>Qa</tapestry.execution-mode>
|
<tapestry.execution-mode>Qa</tapestry.execution-mode>
|
||||||
@ -104,7 +104,7 @@ of testing facilities designed for use with TestNG (http://testng.org/), so it's
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.mortbay.jetty</groupId>
|
<groupId>org.mortbay.jetty</groupId>
|
||||||
<artifactId>maven-jetty-plugin</artifactId>
|
<artifactId>maven-jetty-plugin</artifactId>
|
||||||
<version>6.1.16</version>
|
<version>${compiler.jetty.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<!-- Log to the console. -->
|
<!-- Log to the console. -->
|
||||||
<requestLog implementation="org.mortbay.jetty.NCSARequestLog">
|
<requestLog implementation="org.mortbay.jetty.NCSARequestLog">
|
||||||
@ -140,6 +140,11 @@ of testing facilities designed for use with TestNG (http://testng.org/), so it's
|
|||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
<compiler.jetty.version>6.1.16</compiler.jetty.version>
|
||||||
|
<compiler.surefire.version>2.7.2</compiler.surefire.version>
|
||||||
|
<compiler.plugin.version>2.3.2</compiler.plugin.version>
|
||||||
|
<source.version>1.8</source.version>
|
||||||
|
<target.version>1.8</target.version>
|
||||||
<tapestry-release-version>5.4.5</tapestry-release-version>
|
<tapestry-release-version>5.4.5</tapestry-release-version>
|
||||||
<servlet-api-release-version>2.5</servlet-api-release-version>
|
<servlet-api-release-version>2.5</servlet-api-release-version>
|
||||||
<testng-release-version>6.8.21</testng-release-version>
|
<testng-release-version>6.8.21</testng-release-version>
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
|
<spring.version>2.2.1.RELEASE</spring.version>
|
||||||
|
<awssdk.version>2.10.27</awssdk.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
@ -26,7 +28,7 @@
|
|||||||
<!-- Import dependency management from Spring Boot -->
|
<!-- Import dependency management from Spring Boot -->
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-dependencies</artifactId>
|
<artifactId>spring-boot-dependencies</artifactId>
|
||||||
<version>2.2.1.RELEASE</version>
|
<version>${spring.version}</version>
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
@ -34,7 +36,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>software.amazon.awssdk</groupId>
|
<groupId>software.amazon.awssdk</groupId>
|
||||||
<artifactId>bom</artifactId>
|
<artifactId>bom</artifactId>
|
||||||
<version>2.10.27</version>
|
<version>${awssdk.version}</version>
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
@ -124,7 +124,7 @@
|
|||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-assembly-plugin</artifactId>
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
<version>3.1.0</version>
|
<version>${assembly.plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<finalName>${project.build.finalName}</finalName>
|
<finalName>${project.build.finalName}</finalName>
|
||||||
<appendAssemblyId>false</appendAssemblyId>
|
<appendAssemblyId>false</appendAssemblyId>
|
||||||
@ -161,6 +161,7 @@
|
|||||||
<assertj-core.version>3.11.1</assertj-core.version>
|
<assertj-core.version>3.11.1</assertj-core.version>
|
||||||
<maven-failsafe-plugin.version>3.0.0-M3</maven-failsafe-plugin.version>
|
<maven-failsafe-plugin.version>3.0.0-M3</maven-failsafe-plugin.version>
|
||||||
<process-exec-maven-plugin.version>0.7</process-exec-maven-plugin.version>
|
<process-exec-maven-plugin.version>0.7</process-exec-maven-plugin.version>
|
||||||
|
<assembly.plugin.version>3.1.0</assembly.plugin.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -62,12 +62,12 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.codehaus.groovy</groupId>
|
<groupId>org.codehaus.groovy</groupId>
|
||||||
<artifactId>groovy-eclipse-compiler</artifactId>
|
<artifactId>groovy-eclipse-compiler</artifactId>
|
||||||
<version>3.3.0-01</version>
|
<version>${groovy.compiler.version}</version>
|
||||||
<extensions>true</extensions>
|
<extensions>true</extensions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.8.0</version>
|
<version>${compiler.plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<compilerId>groovy-eclipse-compiler</compilerId>
|
<compilerId>groovy-eclipse-compiler</compilerId>
|
||||||
<source>${java.version}</source>
|
<source>${java.version}</source>
|
||||||
@ -113,7 +113,7 @@
|
|||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<version>2.20.1</version>
|
<version>${surefire.plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<useFile>false</useFile>
|
<useFile>false</useFile>
|
||||||
<includes>
|
<includes>
|
||||||
@ -126,7 +126,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-assembly-plugin</artifactId>
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
<version>3.1.0</version>
|
<version>${assembly.plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<!-- get all project dependencies -->
|
<!-- get all project dependencies -->
|
||||||
<descriptorRefs>
|
<descriptorRefs>
|
||||||
@ -183,6 +183,10 @@
|
|||||||
<groovy-wslite.version>1.1.3</groovy-wslite.version>
|
<groovy-wslite.version>1.1.3</groovy-wslite.version>
|
||||||
<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>
|
||||||
|
<surefire.plugin.version>2.20.1</surefire.plugin.version>
|
||||||
|
<compiler.plugin.version>3.8.0</compiler.plugin.version>
|
||||||
|
<groovy.compiler.version>3.3.0-01</groovy.compiler.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -99,7 +99,7 @@
|
|||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<version>2.20.1</version>
|
<version>${surefire.plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<useFile>false</useFile>
|
<useFile>false</useFile>
|
||||||
<includes>
|
<includes>
|
||||||
@ -126,6 +126,7 @@
|
|||||||
<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>
|
||||||
|
@ -42,12 +42,12 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.collections</groupId>
|
<groupId>org.eclipse.collections</groupId>
|
||||||
<artifactId>eclipse-collections</artifactId>
|
<artifactId>eclipse-collections</artifactId>
|
||||||
<version>10.0.0</version>
|
<version>${eclipse.collections.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.collections</groupId>
|
<groupId>org.eclipse.collections</groupId>
|
||||||
<artifactId>eclipse-collections-api</artifactId>
|
<artifactId>eclipse-collections-api</artifactId>
|
||||||
<version>10.0.0</version>
|
<version>${eclipse.collections.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
@ -108,6 +108,7 @@
|
|||||||
<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>
|
<jmh.version>1.22</jmh.version>
|
||||||
|
<eclipse.collections.version>10.0.0</eclipse.collections.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
<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>3.0.0-M3</version>
|
<version>${surefire.plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<argLine>--enable-preview</argLine>
|
<argLine>--enable-preview</argLine>
|
||||||
</configuration>
|
</configuration>
|
||||||
@ -53,6 +53,7 @@
|
|||||||
<maven.compiler.source.version>13</maven.compiler.source.version>
|
<maven.compiler.source.version>13</maven.compiler.source.version>
|
||||||
<maven.compiler.target.version>13</maven.compiler.target.version>
|
<maven.compiler.target.version>13</maven.compiler.target.version>
|
||||||
<assertj.version>3.6.1</assertj.version>
|
<assertj.version>3.6.1</assertj.version>
|
||||||
|
<surefire.plugin.version>3.0.0-M3</surefire.plugin.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
@ -0,0 +1,27 @@
|
|||||||
|
package com.baeldung.newfeatures;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class SwitchExpressionsWithYieldUnitTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@SuppressWarnings("preview")
|
||||||
|
public void whenSwitchingOnOperationSquareMe_thenWillReturnSquare() {
|
||||||
|
var me = 4;
|
||||||
|
var operation = "squareMe";
|
||||||
|
var result = switch (operation) {
|
||||||
|
case "doubleMe" -> {
|
||||||
|
yield me * 2;
|
||||||
|
}
|
||||||
|
case "squareMe" -> {
|
||||||
|
yield me * me;
|
||||||
|
}
|
||||||
|
default -> me;
|
||||||
|
};
|
||||||
|
|
||||||
|
assertEquals(16, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
package com.baeldung.newfeatures;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class TextBlocksUnitTest {
|
||||||
|
|
||||||
|
private static final String JSON_STRING = "{\r\n" + "\"name\" : \"Baeldung\",\r\n" + "\"website\" : \"https://www.%s.com/\"\r\n" + "}";
|
||||||
|
|
||||||
|
@SuppressWarnings("preview")
|
||||||
|
private static final String TEXT_BLOCK_JSON = """
|
||||||
|
{
|
||||||
|
"name" : "Baeldung",
|
||||||
|
"website" : "https://www.%s.com/"
|
||||||
|
}
|
||||||
|
""";
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenTextBlocks_thenStringOperationsWork() {
|
||||||
|
|
||||||
|
assertThat(TEXT_BLOCK_JSON.contains("Baeldung")).isTrue();
|
||||||
|
assertThat(TEXT_BLOCK_JSON.indexOf("www")).isGreaterThan(0);
|
||||||
|
assertThat(TEXT_BLOCK_JSON.length()).isGreaterThan(0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("removal")
|
||||||
|
@Test
|
||||||
|
public void whenTextBlocks_thenFormattedWorksAsFormat() {
|
||||||
|
assertThat(TEXT_BLOCK_JSON.formatted("baeldung")
|
||||||
|
.contains("www.baeldung.com")).isTrue();
|
||||||
|
|
||||||
|
assertThat(String.format(JSON_STRING, "baeldung")
|
||||||
|
.contains("www.baeldung.com")).isTrue();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -36,7 +36,7 @@
|
|||||||
<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>3.0.0-M3</version>
|
<version>${surefire.plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<argLine>--enable-preview</argLine>
|
<argLine>--enable-preview</argLine>
|
||||||
</configuration>
|
</configuration>
|
||||||
@ -47,6 +47,7 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source.version>14</maven.compiler.source.version>
|
<maven.compiler.source.version>14</maven.compiler.source.version>
|
||||||
<maven.compiler.target.version>14</maven.compiler.target.version>
|
<maven.compiler.target.version>14</maven.compiler.target.version>
|
||||||
|
<surefire.plugin.version>3.0.0-M3</surefire.plugin.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
@ -51,7 +51,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
<version>3.2.0</version>
|
<version>${shade.plugin.version}</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>package</phase>
|
<phase>package</phase>
|
||||||
@ -79,6 +79,7 @@
|
|||||||
<commons-lang3.version>3.9</commons-lang3.version>
|
<commons-lang3.version>3.9</commons-lang3.version>
|
||||||
<!-- testing -->
|
<!-- testing -->
|
||||||
<assertj-core.version>3.10.0</assertj-core.version>
|
<assertj-core.version>3.10.0</assertj-core.version>
|
||||||
|
<shade.plugin.version>3.2.0</shade.plugin.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -183,8 +183,8 @@
|
|||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
<version>${maven-javadoc-plugin.version}</version>
|
<version>${maven-javadoc-plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.8</source>
|
<source>${source.version}</source>
|
||||||
<target>1.8</target>
|
<target>${target.version}</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
@ -373,6 +373,8 @@
|
|||||||
<maven-shade-plugin.version>3.1.1</maven-shade-plugin.version>
|
<maven-shade-plugin.version>3.1.1</maven-shade-plugin.version>
|
||||||
<spring-boot-maven-plugin.version>2.0.3.RELEASE</spring-boot-maven-plugin.version>
|
<spring-boot-maven-plugin.version>2.0.3.RELEASE</spring-boot-maven-plugin.version>
|
||||||
<exec-maven-plugin.version>1.6.0</exec-maven-plugin.version>
|
<exec-maven-plugin.version>1.6.0</exec-maven-plugin.version>
|
||||||
|
<source.version>1.8</source.version>
|
||||||
|
<target.version>1.8</target.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -23,6 +23,37 @@
|
|||||||
<version>${assertj.version}</version>
|
<version>${assertj.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.jcabi</groupId>
|
||||||
|
<artifactId>jcabi-aspects</artifactId>
|
||||||
|
<version>${jcabi-aspects.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.aspectj</groupId>
|
||||||
|
<artifactId>aspectjrt</artifactId>
|
||||||
|
<version>${aspectjrt.version}</version>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.guava</groupId>
|
||||||
|
<artifactId>guava</artifactId>
|
||||||
|
<version>${guava.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.cactoos</groupId>
|
||||||
|
<artifactId>cactoos</artifactId>
|
||||||
|
<version>${cactoos.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ea.async</groupId>
|
||||||
|
<artifactId>ea-async</artifactId>
|
||||||
|
<version>${ea-async.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@ -36,6 +67,30 @@
|
|||||||
<target>${maven.compiler.target}</target>
|
<target>${maven.compiler.target}</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.jcabi</groupId>
|
||||||
|
<artifactId>jcabi-maven-plugin</artifactId>
|
||||||
|
<version>${jcabi-maven-plugin.version}</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>ajc</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.aspectj</groupId>
|
||||||
|
<artifactId>aspectjtools</artifactId>
|
||||||
|
<version>${aspectjtools.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.aspectj</groupId>
|
||||||
|
<artifactId>aspectjweaver</artifactId>
|
||||||
|
<version>${aspectjweaver.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
<resources>
|
<resources>
|
||||||
<resource>
|
<resource>
|
||||||
@ -49,6 +104,14 @@
|
|||||||
<assertj.version>3.14.0</assertj.version>
|
<assertj.version>3.14.0</assertj.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>
|
||||||
|
<jcabi-aspects.version>0.22.6</jcabi-aspects.version>
|
||||||
|
<aspectjrt.version>1.9.5</aspectjrt.version>
|
||||||
|
<guava.version>28.2-jre</guava.version>
|
||||||
|
<cactoos.version>0.43</cactoos.version>
|
||||||
|
<ea-async.version>1.2.3</ea-async.version>
|
||||||
|
<jcabi-maven-plugin.version>0.14.1</jcabi-maven-plugin.version>
|
||||||
|
<aspectjtools.version>1.9.1</aspectjtools.version>
|
||||||
|
<aspectjweaver.version>1.9.1</aspectjweaver.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -0,0 +1,57 @@
|
|||||||
|
package com.baeldung.async;
|
||||||
|
|
||||||
|
import static com.ea.async.Async.await;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
|
import com.ea.async.Async;
|
||||||
|
|
||||||
|
public class EAAsyncExample {
|
||||||
|
|
||||||
|
static {
|
||||||
|
Async.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
usingCompletableFuture();
|
||||||
|
usingAsyncAwait();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void usingCompletableFuture() throws InterruptedException, ExecutionException, Exception {
|
||||||
|
CompletableFuture<Void> completableFuture = hello()
|
||||||
|
.thenComposeAsync(hello -> mergeWorld(hello))
|
||||||
|
.thenAcceptAsync(helloWorld -> print(helloWorld))
|
||||||
|
.exceptionally( throwable -> {
|
||||||
|
System.out.println(throwable.getCause());
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
completableFuture.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CompletableFuture<String> hello() {
|
||||||
|
CompletableFuture<String> completableFuture = CompletableFuture.supplyAsync(() -> "Hello");
|
||||||
|
return completableFuture;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CompletableFuture<String> mergeWorld(String s) {
|
||||||
|
CompletableFuture<String> completableFuture = CompletableFuture.supplyAsync(() -> {
|
||||||
|
return s + " World!";
|
||||||
|
});
|
||||||
|
return completableFuture;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void print(String str) {
|
||||||
|
CompletableFuture.runAsync(() -> System.out.println(str));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void usingAsyncAwait() {
|
||||||
|
try {
|
||||||
|
String hello = await(hello());
|
||||||
|
String helloWorld = await(mergeWorld(hello));
|
||||||
|
await(CompletableFuture.runAsync(() -> print(helloWorld)));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,183 @@
|
|||||||
|
package com.baeldung.async;
|
||||||
|
|
||||||
|
import static com.ea.async.Async.await;
|
||||||
|
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
|
import com.google.common.util.concurrent.AsyncCallable;
|
||||||
|
import com.google.common.util.concurrent.Callables;
|
||||||
|
import com.google.common.util.concurrent.Futures;
|
||||||
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||||
|
import com.google.common.util.concurrent.MoreExecutors;
|
||||||
|
import com.jcabi.aspects.Async;
|
||||||
|
import com.jcabi.aspects.Loggable;
|
||||||
|
|
||||||
|
public class JavaAsync {
|
||||||
|
|
||||||
|
static {
|
||||||
|
com.ea.async.Async.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final ExecutorService threadpool = Executors.newCachedThreadPool();
|
||||||
|
|
||||||
|
public static void main (String[] args) throws InterruptedException, ExecutionException {
|
||||||
|
int number = 20;
|
||||||
|
|
||||||
|
//Thread Example
|
||||||
|
factorialUsingThread(number).start();
|
||||||
|
|
||||||
|
//FutureTask Example
|
||||||
|
Future<Long> futureTask = factorialUsingFutureTask(number);
|
||||||
|
System.out.println("Factorial of " + number + " is: " + futureTask.get());
|
||||||
|
|
||||||
|
// CompletableFuture Example
|
||||||
|
Future<Long> completableFuture = factorialUsingCompletableFuture(number);
|
||||||
|
System.out.println("Factorial of " + number + " is: " + completableFuture.get());
|
||||||
|
|
||||||
|
// EA Async example
|
||||||
|
System.out.println("Factorial of " + number + " is: " + factorialUsingEAAsync(number));
|
||||||
|
|
||||||
|
// cactoos async example
|
||||||
|
Future<Long> asyncFuture = factorialUsingCactoos(number);
|
||||||
|
System.out.println("Factorial of " + number + " is: " + asyncFuture.get());
|
||||||
|
|
||||||
|
// Guava example
|
||||||
|
ListenableFuture<Long> guavaFuture = factorialUsingGuavaServiceSubmit(number);
|
||||||
|
System.out.println("Factorial of " + number + " is: " + guavaFuture.get());
|
||||||
|
|
||||||
|
ListenableFuture<Long> guavaFutures = factorialUsingGuavaFutures(number);
|
||||||
|
System.out.println("Factorial of " + number + " is: " + guavaFutures.get());
|
||||||
|
|
||||||
|
// @async jcabi-aspect example
|
||||||
|
Future<Long> aspectFuture = factorialUsingJcabiAspect(number);
|
||||||
|
System.out.println("Factorial of " + number + " is: " + aspectFuture.get());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds factorial of a number
|
||||||
|
* @param number
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static long factorial(int number) {
|
||||||
|
long result = 1;
|
||||||
|
for(int i=number;i>0;i--) {
|
||||||
|
result *= i;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds factorial of a number using Thread
|
||||||
|
* @param number
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Loggable
|
||||||
|
public static Thread factorialUsingThread(int number) {
|
||||||
|
Thread newThread = new Thread(() -> {
|
||||||
|
System.out.println("Factorial of " + number + " is: " + factorial(number));
|
||||||
|
});
|
||||||
|
|
||||||
|
return newThread;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds factorial of a number using FutureTask
|
||||||
|
* @param number
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Loggable
|
||||||
|
public static Future<Long> factorialUsingFutureTask(int number) {
|
||||||
|
Future<Long> futureTask = threadpool.submit(() -> factorial(number));
|
||||||
|
|
||||||
|
while (!futureTask.isDone()) {
|
||||||
|
System.out.println("FutureTask is not finished yet...");
|
||||||
|
}
|
||||||
|
|
||||||
|
return futureTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds factorial of a number using CompletableFuture
|
||||||
|
* @param number
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Loggable
|
||||||
|
public static Future<Long> factorialUsingCompletableFuture(int number) {
|
||||||
|
CompletableFuture<Long> completableFuture = CompletableFuture.supplyAsync(() -> factorial(number));
|
||||||
|
return completableFuture;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds factorial of a number using EA Async
|
||||||
|
* @param number
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Loggable
|
||||||
|
public static long factorialUsingEAAsync(int number) {
|
||||||
|
CompletableFuture<Long> completableFuture = CompletableFuture.supplyAsync(() -> factorial(number));
|
||||||
|
long result = await(completableFuture);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds factorial of a number using Async of Cactoos
|
||||||
|
* @param number
|
||||||
|
* @return
|
||||||
|
* @throws InterruptedException
|
||||||
|
* @throws ExecutionException
|
||||||
|
*/
|
||||||
|
@Loggable
|
||||||
|
public static Future<Long> factorialUsingCactoos(int number) throws InterruptedException, ExecutionException {
|
||||||
|
org.cactoos.func.Async<Integer, Long> asyncFunction = new org.cactoos.func.Async<Integer, Long>(input -> factorial(input));
|
||||||
|
Future<Long> asyncFuture = asyncFunction.apply(number);
|
||||||
|
return asyncFuture;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds factorial of a number using Guava's ListeningExecutorService.submit()
|
||||||
|
* @param number
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Loggable
|
||||||
|
public static ListenableFuture<Long> factorialUsingGuavaServiceSubmit(int number) {
|
||||||
|
ListeningExecutorService service = MoreExecutors.listeningDecorator(threadpool);
|
||||||
|
ListenableFuture<Long> factorialFuture = (ListenableFuture<Long>) service.submit(()-> factorial(number));
|
||||||
|
return factorialFuture;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds factorial of a number using Guava's Futures.submitAsync()
|
||||||
|
* @param number
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Loggable
|
||||||
|
public static ListenableFuture<Long> factorialUsingGuavaFutures(int number) {
|
||||||
|
ListeningExecutorService service = MoreExecutors.listeningDecorator(threadpool);
|
||||||
|
AsyncCallable<Long> asyncCallable = Callables.asAsyncCallable(new Callable<Long>() {
|
||||||
|
public Long call() {
|
||||||
|
return factorial(number);
|
||||||
|
}
|
||||||
|
}, service);
|
||||||
|
return Futures.submitAsync(asyncCallable, service);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds factorial of a number using @Async of jcabi-aspects
|
||||||
|
* @param number
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Async
|
||||||
|
@Loggable
|
||||||
|
public static Future<Long> factorialUsingJcabiAspect(int number) {
|
||||||
|
Future<Long> factorialFuture = CompletableFuture.supplyAsync(() -> factorial(number));
|
||||||
|
return factorialFuture;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -207,8 +207,8 @@
|
|||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
<version>${maven-javadoc-plugin.version}</version>
|
<version>${maven-javadoc-plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.8</source>
|
<source>${source.version}</source>
|
||||||
<target>1.8</target>
|
<target>${target.version}</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
@ -397,6 +397,8 @@
|
|||||||
<maven-shade-plugin.version>3.1.1</maven-shade-plugin.version>
|
<maven-shade-plugin.version>3.1.1</maven-shade-plugin.version>
|
||||||
<spring-boot-maven-plugin.version>2.0.3.RELEASE</spring-boot-maven-plugin.version>
|
<spring-boot-maven-plugin.version>2.0.3.RELEASE</spring-boot-maven-plugin.version>
|
||||||
<exec-maven-plugin.version>1.6.0</exec-maven-plugin.version>
|
<exec-maven-plugin.version>1.6.0</exec-maven-plugin.version>
|
||||||
|
<source.version>1.8</source.version>
|
||||||
|
<target.version>1.8</target.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -19,34 +19,34 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.junit.jupiter</groupId>
|
<groupId>org.junit.jupiter</groupId>
|
||||||
<artifactId>junit-jupiter</artifactId>
|
<artifactId>junit-jupiter</artifactId>
|
||||||
<version>5.5.1</version>
|
<version>${jupiter.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-core</artifactId>
|
<artifactId>spring-core</artifactId>
|
||||||
<version>5.0.9.RELEASE</version>
|
<version>${spring.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-context</artifactId>
|
<artifactId>spring-context</artifactId>
|
||||||
<version>5.0.9.RELEASE</version>
|
<version>${spring.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-jdbc</artifactId>
|
<artifactId>spring-jdbc</artifactId>
|
||||||
<version>5.0.9.RELEASE</version>
|
<version>${spring.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-test</artifactId>
|
<artifactId>spring-test</artifactId>
|
||||||
<version>5.0.9.RELEASE</version>
|
<version>${spring.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.h2database</groupId>
|
<groupId>com.h2database</groupId>
|
||||||
<artifactId>h2</artifactId>
|
<artifactId>h2</artifactId>
|
||||||
<version>1.4.199</version>
|
<version>${h2.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
@ -56,11 +56,19 @@
|
|||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.8</source>
|
<source>${source.version}</source>
|
||||||
<target>1.8</target>
|
<target>${target.version}</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<spring.version>5.0.9.RELEASE</spring.version>
|
||||||
|
<h2.version>1.4.199</h2.version>
|
||||||
|
<jupiter.version>5.5.1</jupiter.version>
|
||||||
|
<source.version>1.8</source.version>
|
||||||
|
<target.version>1.8</target.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.baeldung.servicemodule</groupId>
|
<groupId>com.baeldung.servicemodule</groupId>
|
||||||
<artifactId>servicemodule</artifactId>
|
<artifactId>servicemodule</artifactId>
|
||||||
<version>1.0</version>
|
<version>${servicemodule.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
@ -29,4 +29,8 @@
|
|||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<servicemodule.version>1.0</servicemodule.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -19,10 +19,10 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.8.0</version>
|
<version>${compiler.plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>11</source>
|
<source>${source.version}</source>
|
||||||
<target>11</target>
|
<target>${target.version}</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
@ -31,6 +31,9 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<compiler.plugin.version>3.8.0</compiler.plugin.version>
|
||||||
|
<source.version>11</source.version>
|
||||||
|
<target.version>11</target.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
@ -17,12 +17,12 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.baeldung.servicemodule</groupId>
|
<groupId>com.baeldung.servicemodule</groupId>
|
||||||
<artifactId>servicemodule</artifactId>
|
<artifactId>servicemodule</artifactId>
|
||||||
<version>1.0</version>
|
<version>${servicemodule.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.baeldung.providermodule</groupId>
|
<groupId>com.baeldung.providermodule</groupId>
|
||||||
<artifactId>providermodule</artifactId>
|
<artifactId>providermodule</artifactId>
|
||||||
<version>1.0</version>
|
<version>${providermodule.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
@ -34,5 +34,10 @@
|
|||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<servicemodule.version>1.0</servicemodule.version>
|
||||||
|
<providermodule.version>1.0</providermodule.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
@ -20,14 +20,20 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.8.0</version>
|
<version>${compiler.plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>11</source>
|
<source>${source.version}</source>
|
||||||
<target>11</target>
|
<target>${target.version}</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</pluginManagement>
|
</pluginManagement>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<compiler.plugin.version>3.8.0</compiler.plugin.version>
|
||||||
|
<source.version>11</source.version>
|
||||||
|
<target.version>11</target.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
@ -17,7 +17,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.baeldung.servicemodule</groupId>
|
<groupId>com.baeldung.servicemodule</groupId>
|
||||||
<artifactId>servicemodule</artifactId>
|
<artifactId>servicemodule</artifactId>
|
||||||
<version>1.0</version>
|
<version>${servicemodule.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
@ -30,4 +30,9 @@
|
|||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<servicemodule.version>1.0</servicemodule.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
|
||||||
</project>
|
</project>
|
@ -18,7 +18,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-beanutils</groupId>
|
<groupId>commons-beanutils</groupId>
|
||||||
<artifactId>commons-beanutils</artifactId>
|
<artifactId>commons-beanutils</artifactId>
|
||||||
<version>1.9.4</version>
|
<version>${commons.beanutils.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjdk.jmh</groupId>
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
@ -57,6 +57,7 @@
|
|||||||
<jmh-core.version>1.19</jmh-core.version>
|
<jmh-core.version>1.19</jmh-core.version>
|
||||||
<jmh-generator.version>1.19</jmh-generator.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>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -37,8 +37,8 @@
|
|||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>${maven-compiler-plugin.version}</version>
|
<version>${maven-compiler-plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.8</source>
|
<source>${source.version}</source>
|
||||||
<target>1.8</target>
|
<target>${target.version}</target>
|
||||||
<compilerArgument>-parameters</compilerArgument>
|
<compilerArgument>-parameters</compilerArgument>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
@ -48,5 +48,7 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<maven-compiler-plugin.version>3.8.0</maven-compiler-plugin.version>
|
<maven-compiler-plugin.version>3.8.0</maven-compiler-plugin.version>
|
||||||
<assertj-core.version>3.10.0</assertj-core.version>
|
<assertj-core.version>3.10.0</assertj-core.version>
|
||||||
|
<source.version>1.8</source.version>
|
||||||
|
<target.version>1.8</target.version>
|
||||||
</properties>
|
</properties>
|
||||||
</project>
|
</project>
|
@ -0,0 +1,7 @@
|
|||||||
|
package com.baeldung.reflection.exception.invocationtarget;
|
||||||
|
|
||||||
|
public class InvocationTargetExample {
|
||||||
|
public int divideByZeroExample() {
|
||||||
|
return 1 / 0;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package com.baeldung.reflection.exception.invocationtarget;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
public class InvocationTargetUnitTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenCallingMethodThrowsException_thenAssertCauseOfInvocationTargetException() throws Exception {
|
||||||
|
|
||||||
|
InvocationTargetExample targetExample = new InvocationTargetExample();
|
||||||
|
Method method = InvocationTargetExample.class.getMethod("divideByZeroExample");
|
||||||
|
|
||||||
|
Exception exception = assertThrows(InvocationTargetException.class, () -> method.invoke(targetExample));
|
||||||
|
|
||||||
|
assertEquals(ArithmeticException.class, exception.getCause().getClass());
|
||||||
|
}
|
||||||
|
}
|
@ -25,7 +25,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.guava</groupId>
|
<groupId>com.google.guava</groupId>
|
||||||
<artifactId>guava</artifactId>
|
<artifactId>guava</artifactId>
|
||||||
<version>28.1-jre</version>
|
<version>${guava.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -62,7 +62,7 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<commons-lang3.version>3.8.1</commons-lang3.version>
|
<commons-lang3.version>3.8.1</commons-lang3.version>
|
||||||
<assertj.version>3.6.1</assertj.version>
|
<assertj.version>3.6.1</assertj.version>
|
||||||
<guava.version>27.0.1-jre</guava.version>
|
<guava.version>28.1-jre</guava.version>
|
||||||
<junit-jupiter-api.version>5.3.1</junit-jupiter-api.version>
|
<junit-jupiter-api.version>5.3.1</junit-jupiter-api.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
@ -0,0 +1,63 @@
|
|||||||
|
package com.baeldung.regex.matcher;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
public class MatcherUnitTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenFindFourDigitWorks_thenCorrect() {
|
||||||
|
Pattern stringPattern = Pattern.compile("\\d\\d\\d\\d");
|
||||||
|
Matcher m = stringPattern.matcher("goodbye 2019 and welcome 2020");
|
||||||
|
|
||||||
|
assertTrue(m.find());
|
||||||
|
assertEquals(8, m.start());
|
||||||
|
assertEquals("2019", m.group());
|
||||||
|
assertEquals(12, m.end());
|
||||||
|
|
||||||
|
assertTrue(m.find());
|
||||||
|
assertEquals(25, m.start());
|
||||||
|
assertEquals("2020", m.group());
|
||||||
|
assertEquals(29, m.end());
|
||||||
|
|
||||||
|
assertFalse(m.find());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenStartIndex_whenFindFourDigitWorks_thenCorrect() {
|
||||||
|
Pattern stringPattern = Pattern.compile("\\d\\d\\d\\d");
|
||||||
|
Matcher m = stringPattern.matcher("goodbye 2019 and welcome 2020");
|
||||||
|
|
||||||
|
assertTrue(m.find(20));
|
||||||
|
assertEquals(25, m.start());
|
||||||
|
assertEquals("2020", m.group());
|
||||||
|
assertEquals(29, m.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenMatchFourDigitWorks_thenFail() {
|
||||||
|
Pattern stringPattern = Pattern.compile("\\d\\d\\d\\d");
|
||||||
|
Matcher m = stringPattern.matcher("goodbye 2019 and welcome 2020");
|
||||||
|
assertFalse(m.matches());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenMatchFourDigitWorks_thenCorrect() {
|
||||||
|
Pattern stringPattern = Pattern.compile("\\d\\d\\d\\d");
|
||||||
|
Matcher m = stringPattern.matcher("2019");
|
||||||
|
|
||||||
|
assertTrue(m.matches());
|
||||||
|
assertEquals(0, m.start());
|
||||||
|
assertEquals("2019", m.group());
|
||||||
|
assertEquals(4, m.end());
|
||||||
|
|
||||||
|
assertTrue(m.matches());// matches will always return the same return
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -207,8 +207,8 @@
|
|||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
<version>${maven-javadoc-plugin.version}</version>
|
<version>${maven-javadoc-plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.8</source>
|
<source>${source.version}</source>
|
||||||
<target>1.8</target>
|
<target>${target.version}</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
@ -397,6 +397,8 @@
|
|||||||
<maven-shade-plugin.version>3.1.1</maven-shade-plugin.version>
|
<maven-shade-plugin.version>3.1.1</maven-shade-plugin.version>
|
||||||
<spring-boot-maven-plugin.version>2.0.3.RELEASE</spring-boot-maven-plugin.version>
|
<spring-boot-maven-plugin.version>2.0.3.RELEASE</spring-boot-maven-plugin.version>
|
||||||
<exec-maven-plugin.version>1.6.0</exec-maven-plugin.version>
|
<exec-maven-plugin.version>1.6.0</exec-maven-plugin.version>
|
||||||
|
<source.version>1.8</source.version>
|
||||||
|
<target.version>1.8</target.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -17,17 +17,17 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.baeldung.entitymodule</groupId>
|
<groupId>com.baeldung.entitymodule</groupId>
|
||||||
<artifactId>entitymodule</artifactId>
|
<artifactId>entitymodule</artifactId>
|
||||||
<version>1.0</version>
|
<version>${entitymodule.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.baeldung.daomodule</groupId>
|
<groupId>com.baeldung.daomodule</groupId>
|
||||||
<artifactId>daomodule</artifactId>
|
<artifactId>daomodule</artifactId>
|
||||||
<version>1.0</version>
|
<version>${daomodule.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.baeldung.userdaomodule</groupId>
|
<groupId>com.baeldung.userdaomodule</groupId>
|
||||||
<artifactId>userdaomodule</artifactId>
|
<artifactId>userdaomodule</artifactId>
|
||||||
<version>1.0</version>
|
<version>${userdaomodule.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
@ -43,6 +43,9 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>9</maven.compiler.source>
|
<maven.compiler.source>9</maven.compiler.source>
|
||||||
<maven.compiler.target>9</maven.compiler.target>
|
<maven.compiler.target>9</maven.compiler.target>
|
||||||
|
<entitymodule.version>1.0</entitymodule.version>
|
||||||
|
<daomodule.version>1.0</daomodule.version>
|
||||||
|
<userdaomodule.version>1.0</userdaomodule.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
@ -45,10 +45,10 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.8.0</version>
|
<version>${compiler.plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.9</source>
|
<source>${source.version}</source>
|
||||||
<target>1.9</target>
|
<target>${target.version}</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
@ -56,6 +56,9 @@
|
|||||||
</build>
|
</build>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
<compiler.plugin.version>3.8.0</compiler.plugin.version>
|
||||||
|
<source.version>1.9</source.version>
|
||||||
|
<target.version>1.9</target.version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<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>
|
||||||
|
@ -17,12 +17,12 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.baeldung.entitymodule</groupId>
|
<groupId>com.baeldung.entitymodule</groupId>
|
||||||
<artifactId>entitymodule</artifactId>
|
<artifactId>entitymodule</artifactId>
|
||||||
<version>1.0</version>
|
<version>${entitymodule.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.baeldung.daomodule</groupId>
|
<groupId>com.baeldung.daomodule</groupId>
|
||||||
<artifactId>daomodule</artifactId>
|
<artifactId>daomodule</artifactId>
|
||||||
<version>1.0</version>
|
<version>${daomodule.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
@ -38,6 +38,8 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>9</maven.compiler.source>
|
<maven.compiler.source>9</maven.compiler.source>
|
||||||
<maven.compiler.target>9</maven.compiler.target>
|
<maven.compiler.target>9</maven.compiler.target>
|
||||||
|
<entitymodule.version>1.0</entitymodule.version>
|
||||||
|
<daomodule.version>1.0</daomodule.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
@ -29,16 +29,16 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.8.0</version>
|
<version>${compiler.plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.8</source>
|
<source>${source.version}</source>
|
||||||
<target>1.8</target>
|
<target>${target.version}</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-dependency-plugin</artifactId>
|
<artifactId>maven-dependency-plugin</artifactId>
|
||||||
<version>3.1.1</version>
|
<version>${dependency.plugin.version}</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>copy-dependencies</id>
|
<id>copy-dependencies</id>
|
||||||
@ -69,5 +69,12 @@
|
|||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<dependency.plugin.version>3.1.1</dependency.plugin.version>
|
||||||
|
<compiler.plugin.version>3.8.0</compiler.plugin.version>
|
||||||
|
<source.version>1.8</source.version>
|
||||||
|
<target.version>1.8</target.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -0,0 +1,54 @@
|
|||||||
|
package com.baeldung.sequeces
|
||||||
|
|
||||||
|
import org.junit.Test
|
||||||
|
import kotlin.test.assertEquals
|
||||||
|
import java.time.Instant
|
||||||
|
|
||||||
|
class SequencesTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun shouldBuildSequenceWhenUsingFromElements() {
|
||||||
|
val seqOfElements = sequenceOf("first" ,"second", "third")
|
||||||
|
.toList()
|
||||||
|
assertEquals(3, seqOfElements.count())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun shouldBuildSequenceWhenUsingFromFunction() {
|
||||||
|
val seqFromFunction = generateSequence(Instant.now()) {it.plusSeconds(1)}
|
||||||
|
.take(3)
|
||||||
|
.toList()
|
||||||
|
assertEquals(3, seqFromFunction.count())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun shouldBuildSequenceWhenUsingFromChunks() {
|
||||||
|
val seqFromChunks = sequence {
|
||||||
|
yield(1)
|
||||||
|
yieldAll((2..5).toList())
|
||||||
|
}.toList()
|
||||||
|
assertEquals(5, seqFromChunks.count())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun shouldBuildSequenceWhenUsingFromCollection() {
|
||||||
|
val seqFromIterable = (1..10)
|
||||||
|
.asSequence()
|
||||||
|
.toList()
|
||||||
|
assertEquals(10, seqFromIterable.count())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun shouldShowNoCountDiffWhenUsingWithAndWithoutSequence() {
|
||||||
|
val withSequence = (1..10).asSequence()
|
||||||
|
.filter{it % 2 == 1}
|
||||||
|
.map { it * 2 }
|
||||||
|
.toList()
|
||||||
|
val withoutSequence = (1..10)
|
||||||
|
.filter{it % 2 == 1}
|
||||||
|
.map { it * 2 }
|
||||||
|
.toList()
|
||||||
|
assertEquals(withSequence.count(), withoutSequence.count())
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -28,7 +28,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>net.alchim31.maven</groupId>
|
<groupId>net.alchim31.maven</groupId>
|
||||||
<artifactId>scala-maven-plugin</artifactId>
|
<artifactId>scala-maven-plugin</artifactId>
|
||||||
<version>3.3.2</version>
|
<version>${scala.plugin.version}</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
@ -49,6 +49,7 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<scala.version>2.12.7</scala.version>
|
<scala.version>2.12.7</scala.version>
|
||||||
|
<scala.plugin.version>3.3.2</scala.plugin.version>
|
||||||
</properties>
|
</properties>
|
||||||
</project>
|
</project>
|
||||||
|
|
||||||
|
@ -12,6 +12,21 @@
|
|||||||
<version>1.0.0-SNAPSHOT</version>
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>github.release.repo</id>
|
||||||
|
<url>https://raw.github.com/bulldog2011/bulldog-repo/master/repo/releases/</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.leansoft</groupId>
|
||||||
|
<artifactId>bigqueue</artifactId>
|
||||||
|
<version>0.7.0</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<pluginManagement>
|
<pluginManagement>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
@ -0,0 +1,82 @@
|
|||||||
|
package com.baeldung.bigqueue;
|
||||||
|
|
||||||
|
import com.leansoft.bigqueue.BigQueueImpl;
|
||||||
|
import com.leansoft.bigqueue.IBigQueue;
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.junit.runners.JUnit4;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
@RunWith(JUnit4.class)
|
||||||
|
public class BigQueueLiveTest {
|
||||||
|
|
||||||
|
private IBigQueue bigQueue;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setup() throws IOException {
|
||||||
|
String queueDir = System.getProperty("user.home");
|
||||||
|
String queueName = "baeldung-queue";
|
||||||
|
bigQueue = new BigQueueImpl(queueDir, queueName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void emptyQueue() throws IOException {
|
||||||
|
bigQueue.removeAll();
|
||||||
|
bigQueue.gc();
|
||||||
|
bigQueue.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenAddingRecords_ThenTheSizeIsCorrect() throws IOException {
|
||||||
|
for (int i = 1; i <= 100; i++) {
|
||||||
|
bigQueue.enqueue(String.valueOf(i).getBytes());
|
||||||
|
}
|
||||||
|
|
||||||
|
assertEquals(100, bigQueue.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenAddingRecords_ThenTheyCanBeRetrieved() throws IOException {
|
||||||
|
bigQueue.enqueue(String.valueOf("new_record").getBytes());
|
||||||
|
|
||||||
|
String record = new String(bigQueue.dequeue());
|
||||||
|
assertEquals("new_record", record);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenDequeueingRecords_ThenTheyAreConsumed() throws IOException {
|
||||||
|
for (int i = 1; i <= 100; i++) {
|
||||||
|
bigQueue.enqueue(String.valueOf(i).getBytes());
|
||||||
|
}
|
||||||
|
bigQueue.dequeue();
|
||||||
|
|
||||||
|
assertEquals(99, bigQueue.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenPeekingRecords_ThenSizeDoesntChange() throws IOException {
|
||||||
|
for (int i = 1; i <= 100; i++) {
|
||||||
|
bigQueue.enqueue(String.valueOf(i).getBytes());
|
||||||
|
}
|
||||||
|
String firstRecord = new String(bigQueue.peek());
|
||||||
|
|
||||||
|
assertEquals("1", firstRecord);
|
||||||
|
assertEquals(100, bigQueue.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenEmptyingTheQueue_ThenItSizeIs0() throws IOException {
|
||||||
|
for (int i = 1; i <= 100; i++) {
|
||||||
|
bigQueue.enqueue(String.valueOf(i).getBytes());
|
||||||
|
}
|
||||||
|
bigQueue.removeAll();
|
||||||
|
|
||||||
|
assertEquals(0, bigQueue.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -44,12 +44,13 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.httpcomponents</groupId>
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
<artifactId>httpclient</artifactId>
|
<artifactId>httpclient</artifactId>
|
||||||
<version>4.3.5</version>
|
<version>${httpclient.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<dl4j.version>0.9.1</dl4j.version> <!-- Latest non beta version -->
|
<dl4j.version>0.9.1</dl4j.version> <!-- Latest non beta version -->
|
||||||
|
<httpclient.version>4.3.5</httpclient.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -175,10 +175,10 @@
|
|||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.1</version>
|
<version>${compiler.plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.8</source>
|
<source>${source.version}</source>
|
||||||
<target>1.8</target>
|
<target>${target.version}</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
@ -215,5 +215,8 @@
|
|||||||
<logback.version>1.2.3</logback.version>
|
<logback.version>1.2.3</logback.version>
|
||||||
<slf4j.version>1.7.25</slf4j.version>
|
<slf4j.version>1.7.25</slf4j.version>
|
||||||
<spring-boot-maven-plugin.version>2.0.4.RELEASE</spring-boot-maven-plugin.version>
|
<spring-boot-maven-plugin.version>2.0.4.RELEASE</spring-boot-maven-plugin.version>
|
||||||
|
<compiler.plugin.version>3.1</compiler.plugin.version>
|
||||||
|
<source.version>1.8</source.version>
|
||||||
|
<target.version>1.8</target.version>
|
||||||
</properties>
|
</properties>
|
||||||
</project>
|
</project>
|
||||||
|
@ -63,7 +63,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>net.ltgt.gwt.maven</groupId>
|
<groupId>net.ltgt.gwt.maven</groupId>
|
||||||
<artifactId>gwt-maven-plugin</artifactId>
|
<artifactId>gwt-maven-plugin</artifactId>
|
||||||
<version>1.0-rc-8</version>
|
<version>${gwt.plugin.version}</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
@ -78,7 +78,7 @@
|
|||||||
<failOnError>true</failOnError>
|
<failOnError>true</failOnError>
|
||||||
<!-- GWT compiler 2.8 requires 1.8, hence define sourceLevel here if
|
<!-- GWT compiler 2.8 requires 1.8, hence define sourceLevel here if
|
||||||
you use a different source language for java compilation -->
|
you use a different source language for java compilation -->
|
||||||
<sourceLevel>1.8</sourceLevel>
|
<sourceLevel>${maven.compiler.source}</sourceLevel>
|
||||||
<!-- Compiler configuration -->
|
<!-- Compiler configuration -->
|
||||||
<compilerArgs>
|
<compilerArgs>
|
||||||
<!-- Ask GWT to create the Story of Your Compile (SOYC) (gwt:compile) -->
|
<!-- Ask GWT to create the Story of Your Compile (SOYC) (gwt:compile) -->
|
||||||
@ -98,7 +98,7 @@
|
|||||||
<!-- 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>2.17</version>
|
<version>${surefire.plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<skip>true</skip>
|
<skip>true</skip>
|
||||||
</configuration>
|
</configuration>
|
||||||
@ -119,6 +119,8 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<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>
|
||||||
|
<surefire.plugin.version>2.17</surefire.plugin.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -46,19 +46,19 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jetbrains.spek</groupId>
|
<groupId>org.jetbrains.spek</groupId>
|
||||||
<artifactId>spek-api</artifactId>
|
<artifactId>spek-api</artifactId>
|
||||||
<version>1.1.5</version>
|
<version>${spek.api.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jetbrains.spek</groupId>
|
<groupId>org.jetbrains.spek</groupId>
|
||||||
<artifactId>spek-subject-extension</artifactId>
|
<artifactId>spek-subject-extension</artifactId>
|
||||||
<version>1.1.5</version>
|
<version>${spek.subject.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jetbrains.spek</groupId>
|
<groupId>org.jetbrains.spek</groupId>
|
||||||
<artifactId>spek-junit-platform-engine</artifactId>
|
<artifactId>spek-junit-platform-engine</artifactId>
|
||||||
<version>1.1.5</version>
|
<version>${spek.junit.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -195,6 +195,9 @@
|
|||||||
<junit.vintage.version>5.2.0</junit.vintage.version>
|
<junit.vintage.version>5.2.0</junit.vintage.version>
|
||||||
<assertj.version>3.10.0</assertj.version>
|
<assertj.version>3.10.0</assertj.version>
|
||||||
<maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
|
<maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
|
||||||
|
<spek.api.version>1.1.5</spek.api.version>
|
||||||
|
<spek.subject.version>1.1.5</spek.subject.version>
|
||||||
|
<spek.junit.version>1.1.5</spek.junit.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
|
<awaitility.version>3.1.2</awaitility.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -31,7 +32,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.awaitility</groupId>
|
<groupId>org.awaitility</groupId>
|
||||||
<artifactId>awaitility</artifactId>
|
<artifactId>awaitility</artifactId>
|
||||||
<version>3.1.2</version>
|
<version>${awaitility.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@ -12,12 +12,16 @@
|
|||||||
<artifactId>java-ee-8-security-api</artifactId>
|
<artifactId>java-ee-8-security-api</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<unboundid.ldapsdk.version>4.0.4</unboundid.ldapsdk.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.unboundid</groupId>
|
<groupId>com.unboundid</groupId>
|
||||||
<artifactId>unboundid-ldapsdk</artifactId>
|
<artifactId>unboundid-ldapsdk</artifactId>
|
||||||
<version>4.0.4</version>
|
<version>${unboundid.ldapsdk.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@ -21,6 +21,11 @@
|
|||||||
<artifactId>jmh-generator-annprocess</artifactId>
|
<artifactId>jmh-generator-annprocess</artifactId>
|
||||||
<version>${jmh-generator.version}</version>
|
<version>${jmh-generator.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>it.unimi.dsi</groupId>
|
||||||
|
<artifactId>dsiutils</artifactId>
|
||||||
|
<version>${dsiutils.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@ -33,4 +38,8 @@
|
|||||||
</resources>
|
</resources>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<dsiutils.version>2.6.0</dsiutils.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -7,7 +7,7 @@ public class BruteForcePrimeChecker implements PrimeChecker<Integer> {
|
|||||||
@Override
|
@Override
|
||||||
public boolean isPrime(Integer number) {
|
public boolean isPrime(Integer number) {
|
||||||
|
|
||||||
return number > 2 ? IntStream.range(2, number)
|
return number > 1 ? IntStream.range(2, number)
|
||||||
.noneMatch(n -> (number % n == 0)) : false;
|
.noneMatch(n -> (number % n == 0)) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ public class OptimisedPrimeChecker implements PrimeChecker<Integer> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPrime(Integer number) {
|
public boolean isPrime(Integer number) {
|
||||||
return number > 2 ? IntStream.rangeClosed(2, (int) Math.sqrt(number))
|
return number > 1 ? IntStream.rangeClosed(2, (int) Math.sqrt(number))
|
||||||
.noneMatch(n -> (number % n == 0)) : false;
|
.noneMatch(n -> (number % n == 0)) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,22 +11,24 @@ public class PrimeCheckerUnitTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenCheckIsPrime_thenTrue() {
|
public void whenCheckIsPrime_thenTrue() {
|
||||||
assertTrue(primeChecker.isPrime(13l));
|
assertTrue(primeChecker.isPrime(2L));
|
||||||
|
assertTrue(primeChecker.isPrime(13L));
|
||||||
assertTrue(primeChecker.isPrime(1009L));
|
assertTrue(primeChecker.isPrime(1009L));
|
||||||
assertTrue(primeChecker.isPrime(74207281L));
|
assertTrue(primeChecker.isPrime(74207281L));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenCheckIsPrime_thenFalse() {
|
public void whenCheckIsPrime_thenFalse() {
|
||||||
assertTrue(!primeChecker.isPrime(50L));
|
assertFalse(primeChecker.isPrime(50L));
|
||||||
assertTrue(!primeChecker.isPrime(1001L));
|
assertFalse(primeChecker.isPrime(1001L));
|
||||||
assertTrue(!primeChecker.isPrime(74207282L));
|
assertFalse(primeChecker.isPrime(74207282L));
|
||||||
}
|
}
|
||||||
|
|
||||||
private final BruteForcePrimeChecker bfPrimeChecker = new BruteForcePrimeChecker();
|
private final BruteForcePrimeChecker bfPrimeChecker = new BruteForcePrimeChecker();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenBFCheckIsPrime_thenTrue() {
|
public void whenBFCheckIsPrime_thenTrue() {
|
||||||
|
assertTrue(bfPrimeChecker.isPrime(2));
|
||||||
assertTrue(bfPrimeChecker.isPrime(13));
|
assertTrue(bfPrimeChecker.isPrime(13));
|
||||||
assertTrue(bfPrimeChecker.isPrime(1009));
|
assertTrue(bfPrimeChecker.isPrime(1009));
|
||||||
}
|
}
|
||||||
@ -41,6 +43,7 @@ public class PrimeCheckerUnitTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenOptCheckIsPrime_thenTrue() {
|
public void whenOptCheckIsPrime_thenTrue() {
|
||||||
|
assertTrue(optimisedPrimeChecker.isPrime(2));
|
||||||
assertTrue(optimisedPrimeChecker.isPrime(13));
|
assertTrue(optimisedPrimeChecker.isPrime(13));
|
||||||
assertTrue(optimisedPrimeChecker.isPrime(1009));
|
assertTrue(optimisedPrimeChecker.isPrime(1009));
|
||||||
}
|
}
|
||||||
@ -55,6 +58,7 @@ public class PrimeCheckerUnitTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenPrimesCheckIsPrime_thenTrue() {
|
public void whenPrimesCheckIsPrime_thenTrue() {
|
||||||
|
assertTrue(primesPrimeChecker.isPrime(2));
|
||||||
assertTrue(primesPrimeChecker.isPrime(13));
|
assertTrue(primesPrimeChecker.isPrime(13));
|
||||||
assertTrue(primesPrimeChecker.isPrime(1009));
|
assertTrue(primesPrimeChecker.isPrime(1009));
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,14 @@
|
|||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<relativePath>../parent-java</relativePath>
|
<relativePath>../parent-java</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>it.unimi.dsi</groupId>
|
||||||
|
<artifactId>dsiutils</artifactId>
|
||||||
|
<version>2.6.0</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<finalName>java-numbers-3</finalName>
|
<finalName>java-numbers-3</finalName>
|
||||||
|
@ -0,0 +1,103 @@
|
|||||||
|
package com.baeldung.randomnumbers;
|
||||||
|
|
||||||
|
import java.security.SecureRandom;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.SplittableRandom;
|
||||||
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
|
import org.apache.commons.math3.random.RandomDataGenerator;
|
||||||
|
|
||||||
|
import it.unimi.dsi.util.XoRoShiRo128PlusRandom;
|
||||||
|
|
||||||
|
public class RandomNumbersGenerator {
|
||||||
|
|
||||||
|
public Integer generateRandomWithMathRandom(int max, int min) {
|
||||||
|
return (int) ((Math.random() * (max - min)) + min);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer generateRandomWithNextInt() {
|
||||||
|
Random random = new Random();
|
||||||
|
int randomWithNextInt = random.nextInt();
|
||||||
|
return randomWithNextInt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer generateRandomWithNextIntWithinARange(int min, int max) {
|
||||||
|
Random random = new Random();
|
||||||
|
int randomWintNextIntWithinARange = random.nextInt(max - min) + min;
|
||||||
|
return randomWintNextIntWithinARange;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IntStream generateRandomUnlimitedIntStream() {
|
||||||
|
Random random = new Random();
|
||||||
|
IntStream unlimitedIntStream = random.ints();
|
||||||
|
return unlimitedIntStream;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IntStream generateRandomLimitedIntStream(long streamSize) {
|
||||||
|
Random random = new Random();
|
||||||
|
IntStream limitedIntStream = random.ints(streamSize);
|
||||||
|
return limitedIntStream;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IntStream generateRandomLimitedIntStreamWithinARange(int min, int max, long streamSize) {
|
||||||
|
Random random = new Random();
|
||||||
|
IntStream limitedIntStreamWithinARange = random.ints(streamSize, min, max);
|
||||||
|
return limitedIntStreamWithinARange;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer generateRandomWithThreadLocalRandom() {
|
||||||
|
int randomWithThreadLocalRandom = ThreadLocalRandom.current()
|
||||||
|
.nextInt();
|
||||||
|
return randomWithThreadLocalRandom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer generateRandomWithThreadLocalRandomInARange(int min, int max) {
|
||||||
|
int randomWithThreadLocalRandomInARange = ThreadLocalRandom.current()
|
||||||
|
.nextInt(min, max);
|
||||||
|
return randomWithThreadLocalRandomInARange;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer generateRandomWithThreadLocalRandomFromZero(int max) {
|
||||||
|
int randomWithThreadLocalRandomFromZero = ThreadLocalRandom.current()
|
||||||
|
.nextInt(max);
|
||||||
|
return randomWithThreadLocalRandomFromZero;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer generateRandomWithSplittableRandom(int min, int max) {
|
||||||
|
SplittableRandom splittableRandom = new SplittableRandom();
|
||||||
|
int randomWithSplittableRandom = splittableRandom.nextInt(min, max);
|
||||||
|
return randomWithSplittableRandom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IntStream generateRandomWithSplittableRandomLimitedIntStreamWithinARange(int min, int max, long streamSize) {
|
||||||
|
SplittableRandom splittableRandom = new SplittableRandom();
|
||||||
|
IntStream limitedIntStreamWithinARangeWithSplittableRandom = splittableRandom.ints(streamSize, min, max);
|
||||||
|
return limitedIntStreamWithinARangeWithSplittableRandom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer generateRandomWithSecureRandom() {
|
||||||
|
SecureRandom secureRandom = new SecureRandom();
|
||||||
|
int randomWithSecureRandom = secureRandom.nextInt();
|
||||||
|
return randomWithSecureRandom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer generateRandomWithSecureRandomWithinARange(int min, int max) {
|
||||||
|
SecureRandom secureRandom = new SecureRandom();
|
||||||
|
int randomWithSecureRandomWithinARange = secureRandom.nextInt(max - min) + min;
|
||||||
|
return randomWithSecureRandomWithinARange;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer generateRandomWithRandomDataGenerator(int min, int max) {
|
||||||
|
RandomDataGenerator randomDataGenerator = new RandomDataGenerator();
|
||||||
|
int randomWithRandomDataGenerator = randomDataGenerator.nextInt(min, max);
|
||||||
|
return randomWithRandomDataGenerator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer generateRandomWithXoRoShiRo128PlusRandom(int min, int max) {
|
||||||
|
XoRoShiRo128PlusRandom xoroRandom = new XoRoShiRo128PlusRandom();
|
||||||
|
int randomWithXoRoShiRo128PlusRandom = xoroRandom.nextInt(max - min) + min;
|
||||||
|
return randomWithXoRoShiRo128PlusRandom;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,154 @@
|
|||||||
|
package com.baeldung.randomnumbers;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class RandomNumbersGeneratorUnitTest {
|
||||||
|
|
||||||
|
private static final int MIN_RANGE = 1;
|
||||||
|
private static final int MAX_RANGE = 10;
|
||||||
|
private static final int MIN_RANGE_NEGATIVE = -10;
|
||||||
|
private static final int ITERATIONS = 50;
|
||||||
|
private static final long STREAM_SIZE = 50;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenGenerateRandomWithMathRandom_returnsSuccessfully() {
|
||||||
|
RandomNumbersGenerator generator = new RandomNumbersGenerator();
|
||||||
|
for (int i = 0; i < ITERATIONS; i++) {
|
||||||
|
int randomNumer = generator.generateRandomWithMathRandom(MIN_RANGE, MAX_RANGE);
|
||||||
|
assertTrue(isInRange(randomNumer, MIN_RANGE, MAX_RANGE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenGenerateRandomWithNextInt_returnsSuccessfully() {
|
||||||
|
RandomNumbersGenerator generator = new RandomNumbersGenerator();
|
||||||
|
for (int i = 0; i < ITERATIONS; i++) {
|
||||||
|
int randomNumber = generator.generateRandomWithNextInt();
|
||||||
|
assertTrue(isInRange(randomNumber, Integer.MIN_VALUE, Integer.MAX_VALUE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenGenerateRandomWithNextIntWithinARange_returnsSuccessfully() {
|
||||||
|
RandomNumbersGenerator generator = new RandomNumbersGenerator();
|
||||||
|
for (int i = 0; i < ITERATIONS; i++) {
|
||||||
|
int randomNumber = generator.generateRandomWithNextIntWithinARange(MIN_RANGE, MAX_RANGE);
|
||||||
|
assertTrue(isInRange(randomNumber, MIN_RANGE, MAX_RANGE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenGenerateRandomUnlimitedIntStream_returnsSuccessfully() {
|
||||||
|
RandomNumbersGenerator generator = new RandomNumbersGenerator();
|
||||||
|
IntStream stream = generator.generateRandomUnlimitedIntStream();
|
||||||
|
assertNotNull(stream);
|
||||||
|
Integer randomNumber = stream.findFirst()
|
||||||
|
.getAsInt();
|
||||||
|
assertNotNull(randomNumber);
|
||||||
|
assertTrue(isInRange(randomNumber, Integer.MIN_VALUE, Integer.MAX_VALUE));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenGenerateRandomLimitedIntStream_returnsSuccessfully() {
|
||||||
|
RandomNumbersGenerator generator = new RandomNumbersGenerator();
|
||||||
|
generator.generateRandomLimitedIntStream(STREAM_SIZE)
|
||||||
|
.forEach(randomNumber -> assertTrue(isInRange(randomNumber, Integer.MIN_VALUE, Integer.MAX_VALUE)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenGenerateRandomLimitedIntStreamWithinARange_returnsSuccessfully() {
|
||||||
|
RandomNumbersGenerator generator = new RandomNumbersGenerator();
|
||||||
|
generator.generateRandomLimitedIntStreamWithinARange(MIN_RANGE, MAX_RANGE, STREAM_SIZE)
|
||||||
|
.forEach(randomNumber -> assertTrue(isInRange(randomNumber, MIN_RANGE, MAX_RANGE)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenGenerateRandomWithThreadLocalRandom_returnsSuccessfully() {
|
||||||
|
RandomNumbersGenerator generator = new RandomNumbersGenerator();
|
||||||
|
for (int i = 0; i < ITERATIONS; i++) {
|
||||||
|
int randomNumber = generator.generateRandomWithThreadLocalRandom();
|
||||||
|
assertTrue(isInRange(randomNumber, Integer.MIN_VALUE, Integer.MAX_VALUE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenGenerateRandomWithThreadLocalRandomInARange_returnsSuccessfully() {
|
||||||
|
RandomNumbersGenerator generator = new RandomNumbersGenerator();
|
||||||
|
for (int i = 0; i < ITERATIONS; i++) {
|
||||||
|
int randomNumber = generator.generateRandomWithThreadLocalRandomInARange(MIN_RANGE, MAX_RANGE);
|
||||||
|
assertTrue(isInRange(randomNumber, MIN_RANGE, MAX_RANGE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenGenerateRandomWithThreadLocalRandomFromZero_returnsSuccessfully() {
|
||||||
|
RandomNumbersGenerator generator = new RandomNumbersGenerator();
|
||||||
|
for (int i = 0; i < ITERATIONS; i++) {
|
||||||
|
int randomNumber = generator.generateRandomWithThreadLocalRandomFromZero(MAX_RANGE);
|
||||||
|
assertTrue(isInRange(randomNumber, 0, MAX_RANGE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenGenerateRandomWithSplittableRandom_returnsSuccessfully() {
|
||||||
|
RandomNumbersGenerator generator = new RandomNumbersGenerator();
|
||||||
|
for (int i = 0; i < ITERATIONS; i++) {
|
||||||
|
int randomNumber = generator.generateRandomWithSplittableRandom(MIN_RANGE_NEGATIVE, MAX_RANGE);
|
||||||
|
assertTrue(isInRange(randomNumber, MIN_RANGE_NEGATIVE, MAX_RANGE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenGenerateRandomWithSplittableRandomLimitedIntStreamWithinARange_returnsSuccessfully() {
|
||||||
|
RandomNumbersGenerator generator = new RandomNumbersGenerator();
|
||||||
|
generator.generateRandomWithSplittableRandomLimitedIntStreamWithinARange(MIN_RANGE, MAX_RANGE, STREAM_SIZE)
|
||||||
|
.forEach(randomNumber -> assertTrue(isInRange(randomNumber, MIN_RANGE, MAX_RANGE)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenGenerateRandomWithSecureRandom_returnsSuccessfully() {
|
||||||
|
RandomNumbersGenerator generator = new RandomNumbersGenerator();
|
||||||
|
for (int i = 0; i < ITERATIONS; i++) {
|
||||||
|
int randomNumber = generator.generateRandomWithSecureRandom();
|
||||||
|
assertTrue(isInRange(randomNumber, Integer.MIN_VALUE, Integer.MAX_VALUE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenGenerateRandomWithSecureRandomWithinARange_returnsSuccessfully() {
|
||||||
|
RandomNumbersGenerator generator = new RandomNumbersGenerator();
|
||||||
|
for (int i = 0; i < ITERATIONS; i++) {
|
||||||
|
int randomNumber = generator.generateRandomWithSecureRandomWithinARange(MIN_RANGE, MAX_RANGE);
|
||||||
|
assertTrue(isInRange(randomNumber, MIN_RANGE, MAX_RANGE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenGenerateRandomWithRandomDataGenerator_returnsSuccessfully() {
|
||||||
|
RandomNumbersGenerator generator = new RandomNumbersGenerator();
|
||||||
|
for (int i = 0; i < ITERATIONS; i++) {
|
||||||
|
int randomNumber = generator.generateRandomWithRandomDataGenerator(MIN_RANGE, MAX_RANGE);
|
||||||
|
// RandomDataGenerator top is inclusive
|
||||||
|
assertTrue(isInRange(randomNumber, MIN_RANGE, MAX_RANGE + 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenGenerateRandomWithXoRoShiRo128PlusRandom_returnsSuccessfully() {
|
||||||
|
RandomNumbersGenerator generator = new RandomNumbersGenerator();
|
||||||
|
for (int i = 0; i < ITERATIONS; i++) {
|
||||||
|
int randomNumber = generator.generateRandomWithXoRoShiRo128PlusRandom(MIN_RANGE, MAX_RANGE);
|
||||||
|
assertTrue(isInRange(randomNumber, MIN_RANGE, MAX_RANGE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isInRange(int number, int min, int max) {
|
||||||
|
return min <= number && number < max;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -118,7 +118,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.mvc</groupId>
|
<groupId>javax.mvc</groupId>
|
||||||
<artifactId>javax.mvc-api</artifactId>
|
<artifactId>javax.mvc-api</artifactId>
|
||||||
<version>20160715</version>
|
<version>${mvc.api.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.glassfish.ozark</groupId>
|
<groupId>org.glassfish.ozark</groupId>
|
||||||
@ -215,7 +215,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.eclipse.m2e</groupId>
|
<groupId>org.eclipse.m2e</groupId>
|
||||||
<artifactId>lifecycle-mapping</artifactId>
|
<artifactId>lifecycle-mapping</artifactId>
|
||||||
<version>1.0.0</version>
|
<version>${lifecycle.mapping.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<lifecycleMappingMetadata>
|
<lifecycleMappingMetadata>
|
||||||
<pluginExecutions>
|
<pluginExecutions>
|
||||||
@ -506,6 +506,8 @@
|
|||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
<lifecycle.mapping.version>1.0.0</lifecycle.mapping.version>
|
||||||
|
<mvc.api.version>20160715</mvc.api.version>
|
||||||
<java.min.version>1.8</java.min.version>
|
<java.min.version>1.8</java.min.version>
|
||||||
<maven.min.version>3.0.0</maven.min.version>
|
<maven.min.version>3.0.0</maven.min.version>
|
||||||
<javaee_api.version>7.0</javaee_api.version>
|
<javaee_api.version>7.0</javaee_api.version>
|
||||||
|
@ -253,7 +253,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.wildfly.arquillian</groupId>
|
<groupId>org.wildfly.arquillian</groupId>
|
||||||
<artifactId>wildfly-arquillian-container-remote</artifactId>
|
<artifactId>wildfly-arquillian-container-remote</artifactId>
|
||||||
<version>2.2.0.Final</version>
|
<version>${wildfly.arquillian.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
@ -261,6 +261,7 @@
|
|||||||
</profiles>
|
</profiles>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
<wildfly.arquillian.version>2.2.0.Final</wildfly.arquillian.version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||||
<javaee-api.version>8.0</javaee-api.version>
|
<javaee-api.version>8.0</javaee-api.version>
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
</prerequisites>
|
</prerequisites>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
<lifecycle.mapping.version>1.0.0</lifecycle.mapping.version>
|
||||||
<argLine>-Djava.security.egd=file:/dev/./urandom -Xmx256m</argLine>
|
<argLine>-Djava.security.egd=file:/dev/./urandom -Xmx256m</argLine>
|
||||||
<assertj.version>3.6.2</assertj.version>
|
<assertj.version>3.6.2</assertj.version>
|
||||||
<awaitility.version>2.0.0</awaitility.version>
|
<awaitility.version>2.0.0</awaitility.version>
|
||||||
@ -433,7 +434,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.eclipse.m2e</groupId>
|
<groupId>org.eclipse.m2e</groupId>
|
||||||
<artifactId>lifecycle-mapping</artifactId>
|
<artifactId>lifecycle-mapping</artifactId>
|
||||||
<version>1.0.0</version>
|
<version>${lifecycle.mapping.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<lifecycleMappingMetadata>
|
<lifecycleMappingMetadata>
|
||||||
<pluginExecutions>
|
<pluginExecutions>
|
||||||
|
@ -92,6 +92,7 @@
|
|||||||
<undertow.version>1.4.10.Final</undertow.version>
|
<undertow.version>1.4.10.Final</undertow.version>
|
||||||
<validation-api.version>1.1.0.Final</validation-api.version>
|
<validation-api.version>1.1.0.Final</validation-api.version>
|
||||||
<yarn.version>v0.21.3</yarn.version>
|
<yarn.version>v0.21.3</yarn.version>
|
||||||
|
<lifecycle.mapping.version>1.0.0</lifecycle.mapping.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
@ -427,7 +428,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.eclipse.m2e</groupId>
|
<groupId>org.eclipse.m2e</groupId>
|
||||||
<artifactId>lifecycle-mapping</artifactId>
|
<artifactId>lifecycle-mapping</artifactId>
|
||||||
<version>1.0.0</version>
|
<version>${lifecycle.mapping.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<lifecycleMappingMetadata>
|
<lifecycleMappingMetadata>
|
||||||
<pluginExecutions>
|
<pluginExecutions>
|
||||||
|
@ -96,6 +96,7 @@
|
|||||||
<undertow.version>1.4.10.Final</undertow.version>
|
<undertow.version>1.4.10.Final</undertow.version>
|
||||||
<validation-api.version>1.1.0.Final</validation-api.version>
|
<validation-api.version>1.1.0.Final</validation-api.version>
|
||||||
<yarn.version>v0.21.3</yarn.version>
|
<yarn.version>v0.21.3</yarn.version>
|
||||||
|
<lifecycle.mapping.version>1.0.0</lifecycle.mapping.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
@ -469,7 +470,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.eclipse.m2e</groupId>
|
<groupId>org.eclipse.m2e</groupId>
|
||||||
<artifactId>lifecycle-mapping</artifactId>
|
<artifactId>lifecycle-mapping</artifactId>
|
||||||
<version>1.0.0</version>
|
<version>${lifecycle.mapping.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<lifecycleMappingMetadata>
|
<lifecycleMappingMetadata>
|
||||||
<pluginExecutions>
|
<pluginExecutions>
|
||||||
|
@ -302,7 +302,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.eclipse.m2e</groupId>
|
<groupId>org.eclipse.m2e</groupId>
|
||||||
<artifactId>lifecycle-mapping</artifactId>
|
<artifactId>lifecycle-mapping</artifactId>
|
||||||
<version>1.0.0</version>
|
<version>${lifecycle.mapping.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<lifecycleMappingMetadata>
|
<lifecycleMappingMetadata>
|
||||||
<pluginExecutions>
|
<pluginExecutions>
|
||||||
@ -398,8 +398,8 @@
|
|||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>${maven-compiler-plugin.version}</version>
|
<version>${maven-compiler-plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.8</source>
|
<source>${source.version}</source>
|
||||||
<target>1.8</target>
|
<target>${target.version}</target>
|
||||||
<annotationProcessorPaths>
|
<annotationProcessorPaths>
|
||||||
<path>
|
<path>
|
||||||
<groupId>org.mapstruct</groupId>
|
<groupId>org.mapstruct</groupId>
|
||||||
@ -881,6 +881,9 @@
|
|||||||
</profiles>
|
</profiles>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
<source.version>1.8</source.version>
|
||||||
|
<target.version>1.8</target.version>
|
||||||
|
<lifecycle.mapping.version>1.0.0</lifecycle.mapping.version>
|
||||||
<argLine>-Djava.security.egd=file:/dev/./urandom -Xmx256m</argLine>
|
<argLine>-Djava.security.egd=file:/dev/./urandom -Xmx256m</argLine>
|
||||||
<assertj.version>3.6.2</assertj.version>
|
<assertj.version>3.6.2</assertj.version>
|
||||||
<awaitility.version>2.0.0</awaitility.version>
|
<awaitility.version>2.0.0</awaitility.version>
|
||||||
|
@ -236,7 +236,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.zalando</groupId>
|
<groupId>org.zalando</groupId>
|
||||||
<artifactId>problem-spring-web</artifactId>
|
<artifactId>problem-spring-web</artifactId>
|
||||||
<version>0.24.0-RC.0</version>
|
<version>${spring.web.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.security.oauth</groupId>
|
<groupId>org.springframework.security.oauth</groupId>
|
||||||
@ -559,7 +559,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.eclipse.m2e</groupId>
|
<groupId>org.eclipse.m2e</groupId>
|
||||||
<artifactId>lifecycle-mapping</artifactId>
|
<artifactId>lifecycle-mapping</artifactId>
|
||||||
<version>1.0.0</version>
|
<version>${lifecycle.mapping.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<lifecycleMappingMetadata>
|
<lifecycleMappingMetadata>
|
||||||
<pluginExecutions>
|
<pluginExecutions>
|
||||||
@ -1012,6 +1012,8 @@
|
|||||||
</profiles>
|
</profiles>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
<lifecycle.mapping.version>1.0.0</lifecycle.mapping.version>
|
||||||
|
<spring.web.version>0.24.0-RC.0</spring.web.version>
|
||||||
<!-- Build properties -->
|
<!-- Build properties -->
|
||||||
<maven.version>3.0.0</maven.version>
|
<maven.version>3.0.0</maven.version>
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
|
@ -232,7 +232,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.zalando</groupId>
|
<groupId>org.zalando</groupId>
|
||||||
<artifactId>problem-spring-web</artifactId>
|
<artifactId>problem-spring-web</artifactId>
|
||||||
<version>0.24.0-RC.0</version>
|
<version>${spring.web.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.security.oauth</groupId>
|
<groupId>org.springframework.security.oauth</groupId>
|
||||||
@ -543,7 +543,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.eclipse.m2e</groupId>
|
<groupId>org.eclipse.m2e</groupId>
|
||||||
<artifactId>lifecycle-mapping</artifactId>
|
<artifactId>lifecycle-mapping</artifactId>
|
||||||
<version>1.0.0</version>
|
<version>${lifecycle.mapping.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<lifecycleMappingMetadata>
|
<lifecycleMappingMetadata>
|
||||||
<pluginExecutions>
|
<pluginExecutions>
|
||||||
@ -834,6 +834,8 @@
|
|||||||
</profiles>
|
</profiles>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
<lifecycle.mapping.version>1.0.0</lifecycle.mapping.version>
|
||||||
|
<spring.web.version>0.24.0-RC.0</spring.web.version>
|
||||||
<!-- Build properties -->
|
<!-- Build properties -->
|
||||||
<maven.version>3.0.0</maven.version>
|
<maven.version>3.0.0</maven.version>
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
|
@ -33,19 +33,19 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jetbrains.spek</groupId>
|
<groupId>org.jetbrains.spek</groupId>
|
||||||
<artifactId>spek-api</artifactId>
|
<artifactId>spek-api</artifactId>
|
||||||
<version>1.1.5</version>
|
<version>${spek.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jetbrains.spek</groupId>
|
<groupId>org.jetbrains.spek</groupId>
|
||||||
<artifactId>spek-subject-extension</artifactId>
|
<artifactId>spek-subject-extension</artifactId>
|
||||||
<version>1.1.5</version>
|
<version>${spek.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jetbrains.spek</groupId>
|
<groupId>org.jetbrains.spek</groupId>
|
||||||
<artifactId>spek-junit-platform-engine</artifactId>
|
<artifactId>spek-junit-platform-engine</artifactId>
|
||||||
<version>1.1.5</version>
|
<version>${spek.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -166,6 +166,7 @@
|
|||||||
<objenesis.version>2.6</objenesis.version>
|
<objenesis.version>2.6</objenesis.version>
|
||||||
<rxkotlin.version>2.3.0</rxkotlin.version>
|
<rxkotlin.version>2.3.0</rxkotlin.version>
|
||||||
<arrow-core.version>0.7.3</arrow-core.version>
|
<arrow-core.version>0.7.3</arrow-core.version>
|
||||||
|
<spek.version>1.1.5</spek.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -103,7 +103,7 @@
|
|||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-dependency-plugin</artifactId>
|
<artifactId>maven-dependency-plugin</artifactId>
|
||||||
<version>3.1.1</version>
|
<version>${dependency.plugin.version}</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>getClasspathFilenames</id>
|
<id>getClasspathFilenames</id>
|
||||||
@ -116,7 +116,7 @@
|
|||||||
<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.22.1</version>
|
<version>${surefire.plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<argLine>-Dco.paralleluniverse.fibers.verifyInstrumentation=true</argLine>
|
<argLine>-Dco.paralleluniverse.fibers.verifyInstrumentation=true</argLine>
|
||||||
<argLine>-javaagent:${co.paralleluniverse:quasar-core:jar}</argLine>
|
<argLine>-javaagent:${co.paralleluniverse:quasar-core:jar}</argLine>
|
||||||
@ -125,7 +125,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
<artifactId>exec-maven-plugin</artifactId>
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
<version>1.3.2</version>
|
<version>${exec.plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<workingDirectory>target/classes</workingDirectory>
|
<workingDirectory>target/classes</workingDirectory>
|
||||||
<executable>echo</executable>
|
<executable>echo</executable>
|
||||||
@ -145,6 +145,9 @@
|
|||||||
<kotlin.version>1.3.31</kotlin.version>
|
<kotlin.version>1.3.31</kotlin.version>
|
||||||
<org.slf4j.version>1.7.21</org.slf4j.version>
|
<org.slf4j.version>1.7.21</org.slf4j.version>
|
||||||
<logback.version>1.1.7</logback.version>
|
<logback.version>1.1.7</logback.version>
|
||||||
|
<dependency.plugin.version>3.1.1</dependency.plugin.version>
|
||||||
|
<surefire.plugin.version>2.22.1</surefire.plugin.version>
|
||||||
|
<exec.plugin.version>1.3.2</exec.plugin.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -23,10 +23,16 @@
|
|||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
<version>${lombok.version}</version>
|
<version>${lombok.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.cactoos</groupId>
|
||||||
|
<artifactId>cactoos</artifactId>
|
||||||
|
<version>${cactoos.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<jcommander.version>1.78</jcommander.version>
|
<jcommander.version>1.78</jcommander.version>
|
||||||
<lombok.version>1.18.6</lombok.version>
|
<lombok.version>1.18.6</lombok.version>
|
||||||
|
<cactoos.version>0.43</cactoos.version>
|
||||||
</properties>
|
</properties>
|
||||||
</project>
|
</project>
|
@ -0,0 +1,28 @@
|
|||||||
|
package com.baeldung.cactoos;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.cactoos.collection.Filtered;
|
||||||
|
import org.cactoos.iterable.IterableOf;
|
||||||
|
import org.cactoos.list.ListOf;
|
||||||
|
import org.cactoos.scalar.And;
|
||||||
|
import org.cactoos.text.FormattedText;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
public class CactoosCollectionUtils {
|
||||||
|
|
||||||
|
final Logger LOGGER = LoggerFactory.getLogger(CactoosCollectionUtils.class);
|
||||||
|
|
||||||
|
public void iterateCollection(List<String> strings) throws Exception {
|
||||||
|
new And((String input) -> LOGGER.info(new FormattedText("%s\n", input).asString()), strings).value();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Collection<String> getFilteredList(List<String> strings) {
|
||||||
|
Collection<String> filteredStrings = new ListOf<>(
|
||||||
|
new Filtered<>(string -> string.length() == 5, new IterableOf<>(strings)));
|
||||||
|
return filteredStrings;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
package com.baeldung.cactoos;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.cactoos.text.FormattedText;
|
||||||
|
import org.cactoos.text.IsBlank;
|
||||||
|
import org.cactoos.text.Lowered;
|
||||||
|
import org.cactoos.text.TextOf;
|
||||||
|
import org.cactoos.text.Upper;
|
||||||
|
|
||||||
|
public class CactoosStringUtils {
|
||||||
|
|
||||||
|
public String createString() throws IOException {
|
||||||
|
String testString = new TextOf("Test String").asString();
|
||||||
|
return testString;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String createdFormattedString(String stringToFormat) throws IOException {
|
||||||
|
String formattedString = new FormattedText("Hello %s", stringToFormat).asString();
|
||||||
|
return formattedString;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toLowerCase(String testString) throws IOException {
|
||||||
|
String lowerCaseString = new Lowered(new TextOf(testString)).asString();
|
||||||
|
return lowerCaseString;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toUpperCase(String testString) throws Exception {
|
||||||
|
String upperCaseString = new Upper(new TextOf(testString)).asString();
|
||||||
|
return upperCaseString;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isBlank(String testString) throws Exception {
|
||||||
|
return new IsBlank(new TextOf(testString)) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.baeldung.cactoos;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class CactoosCollectionUtilsUnitTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenFilteredClassIsCalledWithSpecificArgs_thenCorrespondingFilteredCollectionShouldBeReturned() throws IOException {
|
||||||
|
|
||||||
|
CactoosCollectionUtils obj = new CactoosCollectionUtils();
|
||||||
|
|
||||||
|
// when
|
||||||
|
List<String> strings = new ArrayList<String>() {
|
||||||
|
{
|
||||||
|
add("Hello");
|
||||||
|
add("John");
|
||||||
|
add("Smith");
|
||||||
|
add("Eric");
|
||||||
|
add("Dizzy");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
int size = obj.getFilteredList(strings).size();
|
||||||
|
|
||||||
|
// then
|
||||||
|
assertEquals(3, size);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
package com.baeldung.cactoos;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class CactoosStringUtilsUnitTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenFormattedTextIsPassedWithArgs_thenFormattedStringIsReturned() throws IOException {
|
||||||
|
|
||||||
|
CactoosStringUtils obj = new CactoosStringUtils();
|
||||||
|
|
||||||
|
// when
|
||||||
|
String formattedString = obj.createdFormattedString("John");
|
||||||
|
|
||||||
|
// then
|
||||||
|
assertEquals("Hello John", formattedString);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenStringIsPassesdToLoweredOrUpperClass_thenCorrespondingStringIsReturned() throws Exception {
|
||||||
|
|
||||||
|
CactoosStringUtils obj = new CactoosStringUtils();
|
||||||
|
|
||||||
|
// when
|
||||||
|
String lowerCaseString = obj.toLowerCase("TeSt StrIng");
|
||||||
|
String upperCaseString = obj.toUpperCase("TeSt StrIng");
|
||||||
|
|
||||||
|
// then
|
||||||
|
assertEquals("test string", lowerCaseString);
|
||||||
|
assertEquals("TEST STRING", upperCaseString);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenEmptyStringIsPassesd_thenIsBlankReturnsTrue() throws Exception {
|
||||||
|
|
||||||
|
CactoosStringUtils obj = new CactoosStringUtils();
|
||||||
|
|
||||||
|
// when
|
||||||
|
boolean isBlankEmptyString = obj.isBlank("");
|
||||||
|
boolean isBlankNull = obj.isBlank(null);
|
||||||
|
|
||||||
|
// then
|
||||||
|
assertEquals(true, isBlankEmptyString);
|
||||||
|
assertEquals(true, isBlankNull);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -183,7 +183,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>io.ebean</groupId>
|
<groupId>io.ebean</groupId>
|
||||||
<artifactId>ebean-maven-plugin</artifactId>
|
<artifactId>ebean-maven-plugin</artifactId>
|
||||||
<version>11.11.2</version>
|
<version>${ebean.plugin.version}</version>
|
||||||
<executions>
|
<executions>
|
||||||
<!-- enhance main classes -->
|
<!-- enhance main classes -->
|
||||||
<execution>
|
<execution>
|
||||||
@ -202,6 +202,7 @@
|
|||||||
</build>
|
</build>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
<ebean.plugin.version>11.11.2</ebean.plugin.version>
|
||||||
<reladomo.version>16.5.1</reladomo.version>
|
<reladomo.version>16.5.1</reladomo.version>
|
||||||
<build-helper-maven-plugin.version>3.0.0</build-helper-maven-plugin.version>
|
<build-helper-maven-plugin.version>3.0.0</build-helper-maven-plugin.version>
|
||||||
<maven-antrun-plugin.version>1.8</maven-antrun-plugin.version>
|
<maven-antrun-plugin.version>1.8</maven-antrun-plugin.version>
|
||||||
|
@ -74,19 +74,19 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-cli</groupId>
|
<groupId>commons-cli</groupId>
|
||||||
<artifactId>commons-cli</artifactId>
|
<artifactId>commons-cli</artifactId>
|
||||||
<version>1.2</version>
|
<version>${commons.cli.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-io</groupId>
|
<groupId>commons-io</groupId>
|
||||||
<artifactId>commons-io</artifactId>
|
<artifactId>commons-io</artifactId>
|
||||||
<version>2.1</version>
|
<version>${commons.io.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-httpclient</groupId>
|
<groupId>commons-httpclient</groupId>
|
||||||
<artifactId>commons-httpclient</artifactId>
|
<artifactId>commons-httpclient</artifactId>
|
||||||
<version>3.0.1</version>
|
<version>${httpclient.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
@ -133,7 +133,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-assembly-plugin</artifactId>
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
<version>2.3</version>
|
<version>${assembly.plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<descriptors>
|
<descriptors>
|
||||||
<descriptor>src/main/resources/assembly/hadoop-job.xml</descriptor>
|
<descriptor>src/main/resources/assembly/hadoop-job.xml</descriptor>
|
||||||
@ -158,6 +158,10 @@
|
|||||||
</build>
|
</build>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
<assembly.plugin.version>2.3</assembly.plugin.version>
|
||||||
|
<commons.cli.version>1.2</commons.cli.version>
|
||||||
|
<commons.io.version>2.1</commons.io.version>
|
||||||
|
<httpclient.version>3.0.1</httpclient.version>
|
||||||
<storm.version>1.2.2</storm.version>
|
<storm.version>1.2.2</storm.version>
|
||||||
<kafka.version>1.0.0</kafka.version>
|
<kafka.version>1.0.0</kafka.version>
|
||||||
<ignite.version>2.4.0</ignite.version>
|
<ignite.version>2.4.0</ignite.version>
|
||||||
|
@ -71,7 +71,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.code.gson</groupId>
|
<groupId>com.google.code.gson</groupId>
|
||||||
<artifactId>gson</artifactId>
|
<artifactId>gson</artifactId>
|
||||||
<version>2.8.5</version>
|
<version>${gson.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -116,6 +116,7 @@
|
|||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
<gson.version>2.8.5</gson.version>
|
||||||
<httpclient.version>4.5.3</httpclient.version>
|
<httpclient.version>4.5.3</httpclient.version>
|
||||||
<jackson.version>2.9.8</jackson.version>
|
<jackson.version>2.9.8</jackson.version>
|
||||||
<assertj.version>3.6.2</assertj.version>
|
<assertj.version>3.6.2</assertj.version>
|
||||||
|
@ -127,7 +127,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.asciidoctor</groupId>
|
<groupId>org.asciidoctor</groupId>
|
||||||
<artifactId>asciidoctor-maven-plugin</artifactId>
|
<artifactId>asciidoctor-maven-plugin</artifactId>
|
||||||
<version>1.5.7.1</version>
|
<version>${asciidoctor.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
@ -154,7 +154,8 @@
|
|||||||
</build>
|
</build>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<serenity.version>1.9.9</serenity.version>
|
<asciidoctor.version>1.5.7.1</asciidoctor.version>
|
||||||
|
<serenity.version>1.9.9</serenity.version>
|
||||||
<serenity.jbehave.version>1.9.0</serenity.jbehave.version>
|
<serenity.jbehave.version>1.9.0</serenity.jbehave.version>
|
||||||
<serenity.jira.version>1.9.0</serenity.jira.version>
|
<serenity.jira.version>1.9.0</serenity.jira.version>
|
||||||
<serenity.plugin.version>1.9.27</serenity.plugin.version>
|
<serenity.plugin.version>1.9.27</serenity.plugin.version>
|
||||||
|
@ -523,7 +523,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
<version>2.2</version>
|
<version>${shade.plugin.version}</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>package</phase>
|
<phase>package</phase>
|
||||||
@ -556,6 +556,7 @@
|
|||||||
</build>
|
</build>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
<shade.plugin.version>2.2</shade.plugin.version>
|
||||||
<multiverse.version>0.7.0</multiverse.version>
|
<multiverse.version>0.7.0</multiverse.version>
|
||||||
<cglib.version>3.2.7</cglib.version>
|
<cglib.version>3.2.7</cglib.version>
|
||||||
<javatuples.version>1.2</javatuples.version>
|
<javatuples.version>1.2</javatuples.version>
|
||||||
|
208
linux-bash/functions/src/main/bash/functions.sh
Executable file
208
linux-bash/functions/src/main/bash/functions.sh
Executable file
@ -0,0 +1,208 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Subsection 2.1
|
||||||
|
simple_function() {
|
||||||
|
for ((i=0;i<5;++i)) do
|
||||||
|
echo -n " "$i" ";
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
function simple_function_no_parantheses {
|
||||||
|
for ((i=0;i<5;++i)) do
|
||||||
|
echo -n " "$i" ";
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
function simple_for_loop()
|
||||||
|
for ((i=0;i<5;++i)) do
|
||||||
|
echo -n " "$i" ";
|
||||||
|
done
|
||||||
|
|
||||||
|
function simple_comparison()
|
||||||
|
if [[ "$1" -lt 5 ]]; then
|
||||||
|
echo "$1 is smaller than 5"
|
||||||
|
else
|
||||||
|
echo "$1 is greater than 5"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Subsection 2.2
|
||||||
|
function simple_inputs() {
|
||||||
|
echo "This is the first argument [$1]"
|
||||||
|
echo "This is the second argument [$2]"
|
||||||
|
echo "Calling function with $# aruments"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Subsection 2.3
|
||||||
|
global_sum=0
|
||||||
|
function global_sum_outputs() {
|
||||||
|
global_sum=$(($1+$2))
|
||||||
|
}
|
||||||
|
|
||||||
|
function cs_sum_outputs() {
|
||||||
|
sum=$(($1+$2))
|
||||||
|
echo $sum
|
||||||
|
}
|
||||||
|
|
||||||
|
# Subsection 2.4
|
||||||
|
function arg_ref_sum_outputs() {
|
||||||
|
declare -n sum_ref=$3
|
||||||
|
sum_ref=$(($1+$2))
|
||||||
|
}
|
||||||
|
|
||||||
|
# Subsection 3.1
|
||||||
|
variable="baeldung"
|
||||||
|
function variable_scope2() {
|
||||||
|
echo "Variable inside function variable_scope2: [$variable]"
|
||||||
|
local variable="ipsum"
|
||||||
|
}
|
||||||
|
|
||||||
|
function variable_scope() {
|
||||||
|
local variable="lorem"
|
||||||
|
echo "Variable inside function variable_scope: [$variable]"
|
||||||
|
variable_scope2
|
||||||
|
}
|
||||||
|
|
||||||
|
# Subsection 3.2
|
||||||
|
subshell_sum=0
|
||||||
|
function simple_subshell_sum() (
|
||||||
|
subshell_sum=$(($1+$2))
|
||||||
|
echo "Value of sum in function with global variables: [$subshell_sum]"
|
||||||
|
)
|
||||||
|
|
||||||
|
function simple_subshell_ref_sum() (
|
||||||
|
declare -n sum_ref=$3
|
||||||
|
sum_ref=$(($1+$2))
|
||||||
|
echo "Value of sum in function with ref arguments: [$sum_ref]"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Subsection 3.3
|
||||||
|
function redirection_in() {
|
||||||
|
while read input;
|
||||||
|
do
|
||||||
|
echo "$input"
|
||||||
|
done
|
||||||
|
} < infile
|
||||||
|
|
||||||
|
function redirection_in_ps() {
|
||||||
|
read
|
||||||
|
while read -a input;
|
||||||
|
do
|
||||||
|
echo "User[${input[2]}]->File[${input[8]}]"
|
||||||
|
done
|
||||||
|
} < <(ls -ll /)
|
||||||
|
|
||||||
|
function redirection_out_ps() {
|
||||||
|
declare -a output=("baeldung" "lorem" "ipsum" "caracg")
|
||||||
|
for element in "${output[@]}"
|
||||||
|
do
|
||||||
|
echo "$element"
|
||||||
|
done
|
||||||
|
} > >(grep "g")
|
||||||
|
|
||||||
|
function redirection_out() {
|
||||||
|
declare -a output=("baeldung" "lorem" "ipsum")
|
||||||
|
for element in "${output[@]}"
|
||||||
|
do
|
||||||
|
echo "$element"
|
||||||
|
done
|
||||||
|
} > outfile
|
||||||
|
|
||||||
|
# Subsection 3.4
|
||||||
|
function fibonnaci_recursion() {
|
||||||
|
argument=$1
|
||||||
|
if [[ "$argument" -eq 0 ]] || [[ "$argument" -eq 1 ]]; then
|
||||||
|
echo $argument
|
||||||
|
else
|
||||||
|
first=$(fibonnaci_recursion $(($argument-1)))
|
||||||
|
second=$(fibonnaci_recursion $(($argument-2)))
|
||||||
|
echo $(( $first + $second ))
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# main menu entry point
|
||||||
|
echo "****Functions samples menu*****"
|
||||||
|
PS3="Your choice (1,2,3 etc.):"
|
||||||
|
options=("function_definitions" "function_input_args" "function_outputs" \
|
||||||
|
"function_variables" "function_subshells" "function_redirections" \
|
||||||
|
"function_recursion" "quit")
|
||||||
|
select option in "${options[@]}"
|
||||||
|
do
|
||||||
|
case $option in
|
||||||
|
"function_definitions")
|
||||||
|
echo -e "\n"
|
||||||
|
echo "**Different ways to define a function**"
|
||||||
|
echo -e "No function keyword:"
|
||||||
|
simple_function
|
||||||
|
echo -e "\nNo function parantheses:"
|
||||||
|
simple_function_no_parantheses
|
||||||
|
echo -e "\nOmitting curly braces:"
|
||||||
|
simple_for_loop
|
||||||
|
echo -e "\n"
|
||||||
|
;;
|
||||||
|
"function_input_args")
|
||||||
|
echo -e "\n"
|
||||||
|
echo "**Passing inputs to a function**"
|
||||||
|
simple_inputs lorem ipsum
|
||||||
|
echo -e "\n"
|
||||||
|
;;
|
||||||
|
"function_outputs")
|
||||||
|
echo -e "\n"
|
||||||
|
echo "**Getting outputs from a function**"
|
||||||
|
global_sum_outputs 1 2
|
||||||
|
echo -e ">1+2 using global variables: [$global_sum]"
|
||||||
|
cs_sum=$(cs_sum_outputs 1 2)
|
||||||
|
echo -e ">1+2 using command substitution: [$cs_sum]"
|
||||||
|
arg_ref_sum_outputs 1 2 arg_ref_sum
|
||||||
|
echo -e ">1+2 using argument references: [$arg_ref_sum]"
|
||||||
|
echo -e "\n"
|
||||||
|
;;
|
||||||
|
"function_variables")
|
||||||
|
echo -e "\n"
|
||||||
|
echo "**Overriding variable scopes**"
|
||||||
|
echo "Global value of variable: [$variable]"
|
||||||
|
variable_scope
|
||||||
|
echo -e "\n"
|
||||||
|
;;
|
||||||
|
"function_subshells")
|
||||||
|
echo -e "\n"
|
||||||
|
echo "**Running function in subshell**"
|
||||||
|
echo "Global value of sum: [$subshell_sum]"
|
||||||
|
simple_subshell_sum 1 2
|
||||||
|
echo "Value of sum after subshell function with \
|
||||||
|
global variables: [$subshell_sum]"
|
||||||
|
subshell_sum_arg_ref=0
|
||||||
|
simple_subshell_ref_sum 1 2 subshell_sum_arg_ref
|
||||||
|
echo "Value of sum after subshell function with \
|
||||||
|
ref arguments: [$subshell_sum_arg_ref]"
|
||||||
|
echo -e "\n"
|
||||||
|
;;
|
||||||
|
"function_redirections")
|
||||||
|
echo -e "\n"
|
||||||
|
echo "**Function redirections**"
|
||||||
|
echo -e ">Function input redirection from file:"
|
||||||
|
redirection_in
|
||||||
|
echo -e ">Function input redirection from command:"
|
||||||
|
redirection_in_ps
|
||||||
|
echo -e ">Function output redirection to file:"
|
||||||
|
redirection_out
|
||||||
|
cat outfile
|
||||||
|
echo -e ">Function output redirection to command:"
|
||||||
|
red_ps=$(redirection_out_ps)
|
||||||
|
echo "$red_ps"
|
||||||
|
echo -e "\n"
|
||||||
|
;;
|
||||||
|
"function_recursion")
|
||||||
|
echo -e "\n"
|
||||||
|
echo "**Function recursion**"
|
||||||
|
fibo_res1=$(fibonnaci_recursion 7)
|
||||||
|
echo "The 7th Fibonnaci number: [$fibo_res1]"
|
||||||
|
fibo_res2=$(fibonnaci_recursion 15)
|
||||||
|
echo "The 15th Fibonnaci number: [$fibo_res2]"
|
||||||
|
echo -e "\n"
|
||||||
|
;;
|
||||||
|
"quit")
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
*) echo "Invalid option";;
|
||||||
|
esac
|
||||||
|
done
|
3
linux-bash/functions/src/main/bash/infile
Normal file
3
linux-bash/functions/src/main/bash/infile
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Honda Insight 2010
|
||||||
|
Honda Element 2006
|
||||||
|
Chevrolet Avalanche 2002
|
@ -15,26 +15,26 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.flogger</groupId>
|
<groupId>com.google.flogger</groupId>
|
||||||
<artifactId>flogger</artifactId>
|
<artifactId>flogger</artifactId>
|
||||||
<version>0.4</version>
|
<version>${flogger.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.flogger</groupId>
|
<groupId>com.google.flogger</groupId>
|
||||||
<artifactId>flogger-system-backend</artifactId>
|
<artifactId>flogger-system-backend</artifactId>
|
||||||
<version>0.4</version>
|
<version>${flogger.version}</version>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.flogger</groupId>
|
<groupId>com.google.flogger</groupId>
|
||||||
<artifactId>flogger-slf4j-backend</artifactId>
|
<artifactId>flogger-slf4j-backend</artifactId>
|
||||||
<version>0.4</version>
|
<version>${flogger.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.flogger</groupId>
|
<groupId>com.google.flogger</groupId>
|
||||||
<artifactId>flogger-log4j-backend</artifactId>
|
<artifactId>flogger-log4j-backend</artifactId>
|
||||||
<version>0.4</version>
|
<version>${flogger.version}</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>com.sun.jmx</groupId>
|
<groupId>com.sun.jmx</groupId>
|
||||||
@ -54,13 +54,18 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>log4j</groupId>
|
<groupId>log4j</groupId>
|
||||||
<artifactId>log4j</artifactId>
|
<artifactId>log4j</artifactId>
|
||||||
<version>1.2.17</version>
|
<version>${log4j.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>log4j</groupId>
|
<groupId>log4j</groupId>
|
||||||
<artifactId>apache-log4j-extras</artifactId>
|
<artifactId>apache-log4j-extras</artifactId>
|
||||||
<version>1.2.17</version>
|
<version>${log4j.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<flogger.version>0.4</flogger.version>
|
||||||
|
<log4j.version>1.2.17</log4j.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
@ -19,6 +19,15 @@
|
|||||||
<maven.compiler.target>1.7</maven.compiler.target>
|
<maven.compiler.target>1.7</maven.compiler.target>
|
||||||
<kotlin.version>1.3.50</kotlin.version>
|
<kotlin.version>1.3.50</kotlin.version>
|
||||||
<dl4j.version>0.9.1</dl4j.version>
|
<dl4j.version>0.9.1</dl4j.version>
|
||||||
|
<clean.plugin.version>3.1.0</clean.plugin.version>
|
||||||
|
<resources.plugin.version>3.0.2</resources.plugin.version>
|
||||||
|
<jar.plugin.version>3.0.2</jar.plugin.version>
|
||||||
|
<compiler.plugin.version>3.8.0</compiler.plugin.version>
|
||||||
|
<surefire.plugin.version>2.22.1</surefire.plugin.version>
|
||||||
|
<install.plugin.version>2.5.2</install.plugin.version>
|
||||||
|
<deploy.plugin.version>2.8.2</deploy.plugin.version>
|
||||||
|
<site.plugin.version>3.7.1</site.plugin.version>
|
||||||
|
<report.plugin.version>3.0.0</report.plugin.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -63,41 +72,41 @@
|
|||||||
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
|
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-clean-plugin</artifactId>
|
<artifactId>maven-clean-plugin</artifactId>
|
||||||
<version>3.1.0</version>
|
<version>${clean.plugin.version}</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
|
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-resources-plugin</artifactId>
|
<artifactId>maven-resources-plugin</artifactId>
|
||||||
<version>3.0.2</version>
|
<version>${resources.plugin.version}</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.8.0</version>
|
<version>${compiler.plugin.version}</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<version>2.22.1</version>
|
<version>${surefire.plugin.version}</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
<version>3.0.2</version>
|
<version>${jar.plugin.version}</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-install-plugin</artifactId>
|
<artifactId>maven-install-plugin</artifactId>
|
||||||
<version>2.5.2</version>
|
<version>${install.plugin.version}</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-deploy-plugin</artifactId>
|
<artifactId>maven-deploy-plugin</artifactId>
|
||||||
<version>2.8.2</version>
|
<version>${deploy.plugin.version}</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
|
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-site-plugin</artifactId>
|
<artifactId>maven-site-plugin</artifactId>
|
||||||
<version>3.7.1</version>
|
<version>${site.plugin.version}</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>${report.plugin.version}</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</pluginManagement>
|
</pluginManagement>
|
||||||
|
@ -12,13 +12,19 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.8.0</version>
|
<version>${compiler.plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>9</source>
|
<source>${source.version}</source>
|
||||||
<target>9</target>
|
<target>${target.version}</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<compiler.plugin.version>3.8.0</compiler.plugin.version>
|
||||||
|
<source.version>9</source.version>
|
||||||
|
<target.version>9</target.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
@ -8,16 +8,21 @@
|
|||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<commons.lang3.version>3.9</commons.lang3.version>
|
||||||
|
<junit.version>4.12</junit.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-lang3</artifactId>
|
<artifactId>commons-lang3</artifactId>
|
||||||
<version>3.9</version>
|
<version>${commons.lang3.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>4.12</version>
|
<version>${junit.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-war-plugin</artifactId>
|
<artifactId>maven-war-plugin</artifactId>
|
||||||
<!-- Update maven war plugin to 3.1.0 or higher -->
|
<!-- Update maven war plugin to 3.1.0 or higher -->
|
||||||
<version>3.1.0</version>
|
<version>${war.plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<!-- Set failOnMissingWebXml configuration for maven war plugin -->
|
<!-- Set failOnMissingWebXml configuration for maven war plugin -->
|
||||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||||
@ -26,6 +26,7 @@
|
|||||||
<!-- Set failOnMissingWebXml as false in properties section -->
|
<!-- Set failOnMissingWebXml as false in properties section -->
|
||||||
<properties>
|
<properties>
|
||||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||||
|
<war.plugin.version>3.1.0</war.plugin.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
@ -12,19 +12,19 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-io</groupId>
|
<groupId>commons-io</groupId>
|
||||||
<artifactId>commons-io</artifactId>
|
<artifactId>commons-io</artifactId>
|
||||||
<version>2.3</version>
|
<version>${commons.io.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-collections4</artifactId>
|
<artifactId>commons-collections4</artifactId>
|
||||||
<version>4.0</version>
|
<version>${commons.collections4.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-lang3</artifactId>
|
<artifactId>commons-lang3</artifactId>
|
||||||
<version>3.0</version>
|
<version>${commons.lang3.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -36,7 +36,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-beanutils</groupId>
|
<groupId>commons-beanutils</groupId>
|
||||||
<artifactId>commons-beanutils</artifactId>
|
<artifactId>commons-beanutils</artifactId>
|
||||||
<version>1.9.1</version>
|
<version>${commons.beanutils.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
@ -45,7 +45,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
<artifactId>versions-maven-plugin</artifactId>
|
<artifactId>versions-maven-plugin</artifactId>
|
||||||
<version>2.7</version>
|
<version>${versions.plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<excludes>
|
<excludes>
|
||||||
<exclude>org.apache.commons:commons-collections4</exclude>
|
<exclude>org.apache.commons:commons-collections4</exclude>
|
||||||
@ -71,6 +71,11 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<commons-compress-version>1.15</commons-compress-version>
|
<commons-compress-version>1.15</commons-compress-version>
|
||||||
|
<commons.io.version>2.3</commons.io.version>
|
||||||
|
<versions.plugin.version>2.7</versions.plugin.version>
|
||||||
|
<commons.beanutils.version>1.9.1</commons.beanutils.version>
|
||||||
|
<commons.lang3.version>3.0</commons.lang3.version>
|
||||||
|
<commons.collections4.version>4.0</commons.collections4.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
@ -14,6 +14,8 @@
|
|||||||
<liberty-maven-plugin.version>${liberty-plugin-version}</liberty-maven-plugin.version>
|
<liberty-maven-plugin.version>${liberty-plugin-version}</liberty-maven-plugin.version>
|
||||||
<defaultHttpPort>9080</defaultHttpPort>
|
<defaultHttpPort>9080</defaultHttpPort>
|
||||||
<defaultHttpsPort>9443</defaultHttpsPort>
|
<defaultHttpsPort>9443</defaultHttpsPort>
|
||||||
|
<cdi.api.version>2.0</cdi.api.version>
|
||||||
|
<rsapi.api.version>2.1</rsapi.api.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@ -65,14 +67,14 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.enterprise</groupId>
|
<groupId>javax.enterprise</groupId>
|
||||||
<artifactId>cdi-api</artifactId>
|
<artifactId>cdi-api</artifactId>
|
||||||
<version>2.0</version>
|
<version>${cdi.api.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.ws.rs</groupId>
|
<groupId>javax.ws.rs</groupId>
|
||||||
<artifactId>javax.ws.rs-api</artifactId>
|
<artifactId>javax.ws.rs-api</artifactId>
|
||||||
<version>2.1</version>
|
<version>${rsapi.api.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
@ -12,23 +12,26 @@
|
|||||||
<groupId>com.baeldung.multimodule-maven-project</groupId>
|
<groupId>com.baeldung.multimodule-maven-project</groupId>
|
||||||
<artifactId>multimodule-maven-project</artifactId>
|
<artifactId>multimodule-maven-project</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
|
<entitymodule.version>1.0</entitymodule.version>
|
||||||
|
<daomodule.version>1.0</daomodule.version>
|
||||||
|
<userdaomodule.version>1.0</userdaomodule.version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.baeldung.entitymodule</groupId>
|
<groupId>com.baeldung.entitymodule</groupId>
|
||||||
<artifactId>entitymodule</artifactId>
|
<artifactId>entitymodule</artifactId>
|
||||||
<version>1.0</version>
|
<version>${entitymodule.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.baeldung.daomodule</groupId>
|
<groupId>com.baeldung.daomodule</groupId>
|
||||||
<artifactId>daomodule</artifactId>
|
<artifactId>daomodule</artifactId>
|
||||||
<version>1.0</version>
|
<version>${daomodule.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.baeldung.userdaomodule</groupId>
|
<groupId>com.baeldung.userdaomodule</groupId>
|
||||||
<artifactId>userdaomodule</artifactId>
|
<artifactId>userdaomodule</artifactId>
|
||||||
<version>1.0</version>
|
<version>${userdaomodule.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@ -26,13 +26,13 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>4.12</version>
|
<version>${junit.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.assertj</groupId>
|
<groupId>org.assertj</groupId>
|
||||||
<artifactId>assertj-core</artifactId>
|
<artifactId>assertj-core</artifactId>
|
||||||
<version>3.12.2</version>
|
<version>${assertj.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
@ -44,10 +44,10 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.8.0</version>
|
<version>${compiler.plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>11</source>
|
<source>${source.version}</source>
|
||||||
<target>11</target>
|
<target>${target.version}</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
@ -56,6 +56,11 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<junit.version>4.12</junit.version>
|
||||||
|
<assertj.version>3.12.2</assertj.version>
|
||||||
|
<compiler.plugin.version>3.8.0</compiler.plugin.version>
|
||||||
|
<source.version>11</source.version>
|
||||||
|
<target.version>11</target.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -14,16 +14,21 @@
|
|||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<entitymodule.version>1.0</entitymodule.version>
|
||||||
|
<daomodule.version>1.0</daomodule.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.baeldung.entitymodule</groupId>
|
<groupId>com.baeldung.entitymodule</groupId>
|
||||||
<artifactId>entitymodule</artifactId>
|
<artifactId>entitymodule</artifactId>
|
||||||
<version>1.0</version>
|
<version>${entitymodule.version}1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.baeldung.daomodule</groupId>
|
<groupId>com.baeldung.daomodule</groupId>
|
||||||
<artifactId>daomodule</artifactId>
|
<artifactId>daomodule</artifactId>
|
||||||
<version>1.0</version>
|
<version>${daomodule.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.codehaus.plexus</groupId>
|
<groupId>org.codehaus.plexus</groupId>
|
||||||
<artifactId>plexus-component-metadata</artifactId>
|
<artifactId>plexus-component-metadata</artifactId>
|
||||||
<version>1.7.1</version>
|
<version>${plexus.component.version}</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
@ -48,6 +48,7 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven-core.version>3.5.4</maven-core.version>
|
<maven-core.version>3.5.4</maven-core.version>
|
||||||
|
<plexus.component.version>1.7.1</plexus.component.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
@ -49,7 +49,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.annotation</groupId>
|
<groupId>javax.annotation</groupId>
|
||||||
<artifactId>javax.annotation-api</artifactId>
|
<artifactId>javax.annotation-api</artifactId>
|
||||||
<version>1.3.2</version>
|
<version>${annotation.api.version}</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -60,19 +60,19 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ch.qos.logback</groupId>
|
<groupId>ch.qos.logback</groupId>
|
||||||
<artifactId>logback-classic</artifactId>
|
<artifactId>logback-classic</artifactId>
|
||||||
<version>1.2.3</version>
|
<version>${lombok.version}</version>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>4.12</version>
|
<version>${junit.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.projectreactor</groupId>
|
<groupId>io.projectreactor</groupId>
|
||||||
<artifactId>reactor-core</artifactId>
|
<artifactId>reactor-core</artifactId>
|
||||||
<version>3.1.6.RELEASE</version>
|
<version>${reactor.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
@ -81,7 +81,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
<version>3.1.0</version>
|
<version>${shade.plugin.version}</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>package</phase>
|
<phase>package</phase>
|
||||||
@ -102,7 +102,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
<artifactId>exec-maven-plugin</artifactId>
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
<version>1.6.0</version>
|
<version>${exec.plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<executable>java</executable>
|
<executable>java</executable>
|
||||||
<arguments>
|
<arguments>
|
||||||
@ -118,7 +118,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.7.0</version>
|
<version>${compiler.plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>${jdk.version}</source>
|
<source>${jdk.version}</source>
|
||||||
<target>${jdk.version}</target>
|
<target>${jdk.version}</target>
|
||||||
@ -142,6 +142,13 @@
|
|||||||
<exec.mainClass>com.baeldung.micronaut.helloworld.server.ServerApplication</exec.mainClass>
|
<exec.mainClass>com.baeldung.micronaut.helloworld.server.ServerApplication</exec.mainClass>
|
||||||
<micronaut.version>1.0.0.RC2</micronaut.version>
|
<micronaut.version>1.0.0.RC2</micronaut.version>
|
||||||
<jdk.version>1.8</jdk.version>
|
<jdk.version>1.8</jdk.version>
|
||||||
|
<annotation.api.version>1.3.2</annotation.api.version>
|
||||||
|
<lombok.version>1.2.3</lombok.version>
|
||||||
|
<junit.version>4.12</junit.version>
|
||||||
|
<reactor.version>3.1.6.RELEASE</reactor.version>
|
||||||
|
<compiler.plugin.version>3.7.0</compiler.plugin.version>
|
||||||
|
<exec.plugin.version>1.6.0</exec.plugin.version>
|
||||||
|
<shade.plugin.version>3.1.0</shade.plugin.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -13,6 +13,9 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<ninja.version>6.5.0</ninja.version>
|
<ninja.version>6.5.0</ninja.version>
|
||||||
<jetty.version>9.4.18.v20190429</jetty.version>
|
<jetty.version>9.4.18.v20190429</jetty.version>
|
||||||
|
<bootstrap.version>3.3.4</bootstrap.version>
|
||||||
|
<jquery.version>2.1.3</jquery.version>
|
||||||
|
<h2.version>1.4.186</h2.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@ -156,17 +159,17 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.webjars</groupId>
|
<groupId>org.webjars</groupId>
|
||||||
<artifactId>bootstrap</artifactId>
|
<artifactId>bootstrap</artifactId>
|
||||||
<version>3.3.4</version>
|
<version>${bootstrap.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.webjars</groupId>
|
<groupId>org.webjars</groupId>
|
||||||
<artifactId>jquery</artifactId>
|
<artifactId>jquery</artifactId>
|
||||||
<version>2.1.3</version>
|
<version>${jquery.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.h2database</groupId>
|
<groupId>com.h2database</groupId>
|
||||||
<artifactId>h2</artifactId>
|
<artifactId>h2</artifactId>
|
||||||
<version>1.4.186</version>
|
<version>${h2.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.ninjaframework</groupId>
|
<groupId>org.ninjaframework</groupId>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.hibernatelogging;
|
package com.baeldung.hibernate.logging;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.fail;
|
import static org.junit.jupiter.api.Assertions.fail;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user