Merge branch 'master' into master

This commit is contained in:
slavisa-baeldung 2017-05-18 01:08:29 +02:00 committed by GitHub
commit fe73a256d4
2828 changed files with 269550 additions and 18532 deletions

View File

@ -1,9 +1,13 @@
language: java language: java
install: travis_wait 60 mvn -q test before_install:
- export MAVEN_OPTS="-Xmx2048M -Xss128M -XX:+CMSClassUnloadingEnabled -XX:+UseG1GC -XX:-UseGCOverheadLimit"
- echo "MAVEN_OPTS='-Xmx2048M -Xss128M -XX:+CMSClassUnloadingEnabled -XX:+UseG1GC -XX:-UseGCOverheadLimit'" > ~/.mavenrc
install: travis_wait 60 mvn -q test -fae
before_script: before_script:
- echo "MAVEN_OPTS='-Xmx2048M -Xss128M -XX:MaxPermSize=2048M -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -XX:-UseGCOverheadLimit'" > ~/.mavenrc - echo "MAVEN_OPTS='-Xmx2048M -Xss128M -XX:+CMSClassUnloadingEnabled -XX:+UseG1GC -XX:-UseGCOverheadLimit'" > ~/.mavenrc
jdk: jdk:
- oraclejdk8 - oraclejdk8

View File

@ -6,6 +6,13 @@
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<url>http://maven.apache.org</url> <url>http://maven.apache.org</url>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.source>1.8</maven.compiler.source>
@ -40,24 +47,5 @@
<artifactId>slf4j-simple</artifactId> <artifactId>slf4j-simple</artifactId>
<version>1.7.21</version> <version>1.7.21</version>
</dependency> </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
</project> </project>

View File

@ -11,7 +11,7 @@ import static org.junit.Assert.assertNotNull;
/** /**
* Tests which show issues with JGit that we reported upstream. * Tests which show issues with JGit that we reported upstream.
*/ */
public class JGitBugTest { public class JGitBugIntegrationTest {
@Test @Test
public void testRevWalkDisposeClosesReader() throws IOException { public void testRevWalkDisposeClosesReader() throws IOException {
try (Repository repo = Helper.openJGitRepository()) { try (Repository repo = Helper.openJGitRepository()) {

View File

@ -2,7 +2,7 @@ package com.baeldung.jgit.porcelain;
import org.junit.Test; import org.junit.Test;
public class PorcelainTest { public class PorcelainUnitTest {
@Test @Test
public void runSamples() throws Exception { public void runSamples() throws Exception {
// simply call all the samples to see any severe problems with the samples // simply call all the samples to see any severe problems with the samples

View File

@ -8,12 +8,16 @@
<name>Twitter4J</name> <name>Twitter4J</name>
<url>http://maven.apache.org</url> <url>http://maven.apache.org</url>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<properties> <properties>
<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>
<java.version>1.8</java.version> <java.version>1.8</java.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties> </properties>
<dependencies> <dependencies>
@ -22,11 +26,6 @@
<artifactId>twitter4j-stream</artifactId> <artifactId>twitter4j-stream</artifactId>
<version>4.0.6</version> <version>4.0.6</version>
</dependency> </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
@ -40,7 +39,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.19.1</version> <version>${maven-surefire-plugin.version}</version>
<configuration> <configuration>
<excludes> <excludes>
<exclude>**/ApplicationTest.java</exclude> <exclude>**/ApplicationTest.java</exclude>

View File

@ -9,7 +9,7 @@ import org.junit.Test;
import twitter4j.TwitterException; import twitter4j.TwitterException;
public class ApplicationTest { public class ApplicationIntegrationTest {
/** /**
* In order run this jUnit test you need to configure your API details in the twitter4j.properties * In order run this jUnit test you need to configure your API details in the twitter4j.properties

View File

@ -1,81 +1,69 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 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> <modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<artifactId>algorithms</artifactId> <artifactId>algorithms</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<properties> <properties>
<junit.version>4.12</junit.version> <exec-maven-plugin.version>1.5.0</exec-maven-plugin.version>
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version> <lombok.version>1.16.12</lombok.version>
<exec-maven-plugin.version>1.5.0</exec-maven-plugin.version> <commons-math3.version>3.6.1</commons-math3.version>
<lombok.version>1.16.12</lombok.version> </properties>
<commons-math3.version>3.6.1</commons-math3.version>
</properties>
<dependencies> <parent>
<dependency> <groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId> <artifactId>commons-math3</artifactId>
<version>${commons-math3.version}</version> <version>${commons-math3.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
<version>${lombok.version}</version> <version>${lombok.version}</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>io.jenetics</groupId> <groupId>io.jenetics</groupId>
<artifactId>jenetics</artifactId> <artifactId>jenetics</artifactId>
<version>3.7.0</version> <version>3.7.0</version>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
<defaultGoal>install</defaultGoal> <pluginManagement>
<pluginManagement> <plugins>
<plugins> <plugin>
<plugin> <groupId>org.codehaus.mojo</groupId>
<groupId>org.apache.maven.plugins</groupId> <artifactId>exec-maven-plugin</artifactId>
<artifactId>maven-compiler-plugin</artifactId> <version>${exec-maven-plugin.version}</version>
<version>${maven-compiler-plugin.version}</version> </plugin>
<configuration> </plugins>
<source>1.8</source> </pluginManagement>
<target>1.8</target> </build>
</configuration> <reporting>
</plugin> <plugins>
<plugin> <plugin>
<groupId>org.codehaus.mojo</groupId> <groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId> <artifactId>cobertura-maven-plugin</artifactId>
<version>${exec-maven-plugin.version}</version> <version>2.7</version>
</plugin> <configuration>
</plugins> <instrumentation>
</pluginManagement> <ignores>
</build> <ignore>com/baeldung/algorithms/dijkstra/*</ignore>
<reporting> </ignores>
<plugins> <excludes>
<plugin> <exclude>com/baeldung/algorithms/dijkstra/*</exclude>
<groupId>org.codehaus.mojo</groupId> </excludes>
<artifactId>cobertura-maven-plugin</artifactId> </instrumentation>
<version>2.7</version> </configuration>
<configuration> </plugin>
<instrumentation> </plugins>
<ignores> </reporting>
<ignore>com/baeldung/algorithms/dijkstra/*</ignore>
</ignores>
<excludes>
<exclude>com/baeldung/algorithms/dijkstra/*</exclude>
</excludes>
</instrumentation>
</configuration>
</plugin>
</plugins>
</reporting>
</project> </project>

View File

@ -0,0 +1,22 @@
package algorithms;
import org.junit.Assert;
import org.junit.Test;
import com.baeldung.algorithms.ga.ant_colony.AntColonyOptimization;
public class AntColonyOptimizationLongRunningUnitTest {
@Test
public void testGenerateRandomMatrix() {
AntColonyOptimization antTSP = new AntColonyOptimization(5);
Assert.assertNotNull(antTSP.generateRandomMatrix(5));
}
@Test
public void testStartAntOptimization() {
AntColonyOptimization antTSP = new AntColonyOptimization(5);
Assert.assertNotNull(antTSP.solve());
}
}

View File

@ -1,22 +0,0 @@
package algorithms;
import org.junit.Assert;
import org.junit.Test;
import com.baeldung.algorithms.ga.ant_colony.AntColonyOptimization;
public class AntColonyOptimizationTest {
@Test
public void testGenerateRandomMatrix() {
AntColonyOptimization antTSP = new AntColonyOptimization(5);
Assert.assertNotNull(antTSP.generateRandomMatrix(5));
}
@Test
public void testStartAntOptimization() {
AntColonyOptimization antTSP = new AntColonyOptimization(5);
Assert.assertNotNull(antTSP.solve());
}
}

View File

@ -0,0 +1,16 @@
package algorithms;
import org.junit.Assert;
import org.junit.Test;
import com.baeldung.algorithms.ga.binary.SimpleGeneticAlgorithm;
public class BinaryGeneticAlgorithmLongRunningUnitTest {
@Test
public void testGA() {
SimpleGeneticAlgorithm ga = new SimpleGeneticAlgorithm();
Assert.assertTrue(ga.runAlgorithm(50, "1011000100000100010000100000100111001000000100000100000000001111"));
}
}

View File

@ -1,16 +0,0 @@
package algorithms;
import org.junit.Assert;
import org.junit.Test;
import com.baeldung.algorithms.ga.binary.SimpleGeneticAlgorithm;
public class BinaryGeneticAlgorithmUnitTest {
@Test
public void testGA() {
SimpleGeneticAlgorithm ga = new SimpleGeneticAlgorithm();
Assert.assertTrue(ga.runAlgorithm(50, "1011000100000100010000100000100111001000000100000100000000001111"));
}
}

View File

@ -11,7 +11,7 @@ import java.util.List;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
public class DijkstraAlgorithmTest { public class DijkstraAlgorithmLongRunningUnitTest {
@Test @Test
public void whenSPPSolved_thenCorrect() { public void whenSPPSolved_thenCorrect() {
@ -56,19 +56,29 @@ public class DijkstraAlgorithmTest {
for (Node node : graph.getNodes()) { for (Node node : graph.getNodes()) {
switch (node.getName()) { switch (node.getName()) {
case "B": case "B":
assertTrue(node.getShortestPath().equals(shortestPathForNodeB)); assertTrue(node
.getShortestPath()
.equals(shortestPathForNodeB));
break; break;
case "C": case "C":
assertTrue(node.getShortestPath().equals(shortestPathForNodeC)); assertTrue(node
.getShortestPath()
.equals(shortestPathForNodeC));
break; break;
case "D": case "D":
assertTrue(node.getShortestPath().equals(shortestPathForNodeD)); assertTrue(node
.getShortestPath()
.equals(shortestPathForNodeD));
break; break;
case "E": case "E":
assertTrue(node.getShortestPath().equals(shortestPathForNodeE)); assertTrue(node
.getShortestPath()
.equals(shortestPathForNodeE));
break; break;
case "F": case "F":
assertTrue(node.getShortestPath().equals(shortestPathForNodeF)); assertTrue(node
.getShortestPath()
.equals(shortestPathForNodeF));
break; break;
} }
} }

View File

@ -1,28 +1,27 @@
package algorithms; package algorithms;
import static org.junit.Assert.*;
import org.junit.Test;
import com.baeldung.automata.*; import com.baeldung.automata.*;
import org.junit.Test;
/** import static org.junit.Assert.assertTrue;
* Tests for {@link RtFiniteStateMachine}
*/ public final class RtFiniteStateMachineLongRunningUnitTest {
public final class RtFiniteStateMachineTest {
@Test @Test
public void acceptsSimplePair() { public void acceptsSimplePair() {
String json = "{\"key\":\"value\"}"; String json = "{\"key\":\"value\"}";
FiniteStateMachine machine = this.buildJsonStateMachine(); FiniteStateMachine machine = this.buildJsonStateMachine();
for (int i=0;i<json.length();i++) { for (int i = 0; i < json.length(); i++) {
machine = machine.switchState(String.valueOf(json.charAt(i))); machine = machine.switchState(String.valueOf(json.charAt(i)));
} }
assertTrue(machine.canStop()); assertTrue(machine.canStop());
} }
@Test @Test
public void acceptsMorePairs() { public void acceptsMorePairs() {
String json = "{\"key1\":\"value1\",\"key2\":\"value2\"}"; String json = "{\"key1\":\"value1\",\"key2\":\"value2\"}";
FiniteStateMachine machine = this.buildJsonStateMachine(); FiniteStateMachine machine = this.buildJsonStateMachine();
for (int i=0;i<json.length();i++) { for (int i = 0; i < json.length(); i++) {
machine = machine.switchState(String.valueOf(json.charAt(i))); machine = machine.switchState(String.valueOf(json.charAt(i)));
} }
assertTrue(machine.canStop()); assertTrue(machine.canStop());
@ -32,7 +31,7 @@ public final class RtFiniteStateMachineTest {
public void missingColon() { public void missingColon() {
String json = "{\"key\"\"value\"}"; String json = "{\"key\"\"value\"}";
FiniteStateMachine machine = this.buildJsonStateMachine(); FiniteStateMachine machine = this.buildJsonStateMachine();
for (int i=0;i<json.length();i++) { for (int i = 0; i < json.length(); i++) {
machine = machine.switchState(String.valueOf(json.charAt(i))); machine = machine.switchState(String.valueOf(json.charAt(i)));
} }
} }
@ -56,20 +55,12 @@ public final class RtFiniteStateMachineTest {
second.with(new RtTransition("\"", third)); second.with(new RtTransition("\"", third));
//Add transitions with chars 0-9 and a-z //Add transitions with chars 0-9 and a-z
for (int i = 0; i < 26; i++) { for (int i = 0; i < 26; i++) {
if(i<10) { if (i < 10) {
third = third.with( third = third.with(new RtTransition(String.valueOf(i), third));
new RtTransition(String.valueOf(i), third) sixth = sixth.with(new RtTransition(String.valueOf(i), sixth));
);
sixth = sixth.with(
new RtTransition(String.valueOf(i), sixth)
);
} }
third = third.with( third = third.with(new RtTransition(String.valueOf((char) ('a' + i)), third));
new RtTransition(String.valueOf((char) ('a' + i)), third) sixth = sixth.with(new RtTransition(String.valueOf((char) ('a' + i)), sixth));
);
sixth = sixth.with(
new RtTransition(String.valueOf((char) ('a' + i)), sixth)
);
} }
third.with(new RtTransition("\"", fourth)); third.with(new RtTransition("\"", fourth));
fourth.with(new RtTransition(":", fifth)); fourth.with(new RtTransition(":", fifth));

View File

@ -5,7 +5,7 @@ import org.junit.Test;
import com.baeldung.algorithms.ga.annealing.SimulatedAnnealing; import com.baeldung.algorithms.ga.annealing.SimulatedAnnealing;
public class SimulatedAnnealingTest { public class SimulatedAnnealingLongRunningUnitTest {
@Test @Test
public void testSimulateAnnealing() { public void testSimulateAnnealing() {

View File

@ -1,28 +0,0 @@
package com.baeldung.algorithms.primechecker;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import com.baeldung.algorithms.primechecker.BigIntegerPrimeChecker;
import com.baeldung.algorithms.primechecker.PrimeChecker;
public class BigIntegerPrimeCheckerTest {
BigIntegerPrimeChecker primeChecker = new BigIntegerPrimeChecker();
@Test
public void givenPrimeNumber_whenCheckIsPrime_thenTrue(){
assertTrue(primeChecker.isPrime(13l));
assertTrue(primeChecker.isPrime(1009L));
assertTrue(primeChecker.isPrime(74207281L));
}
@Test
public void givenNonPrimeNumber_whenCheckIsPrime_thenFalse(){
assertTrue(!primeChecker.isPrime(50L));
assertTrue(!primeChecker.isPrime(1001L));
assertTrue(!primeChecker.isPrime(74207282L));
}
}

View File

@ -1,27 +0,0 @@
package com.baeldung.algorithms.primechecker;
import org.junit.Test;
import com.baeldung.algorithms.primechecker.BruteForcePrimeChecker;
import static org.junit.Assert.*;
public class BruteForcePrimeCheckerTest {
BruteForcePrimeChecker primeChecker = new BruteForcePrimeChecker();
@Test
public void givenPrimeNumber_whenCheckIsPrime_thenTrue(){
assertTrue(primeChecker.isPrime(13));
assertTrue(primeChecker.isPrime(1009));
}
@Test
public void givenNonPrimeNumber_whenCheckIsPrime_thenFalse(){
assertTrue(!primeChecker.isPrime(50));
assertTrue(!primeChecker.isPrime(1001));
}
}

View File

@ -1,26 +0,0 @@
package com.baeldung.algorithms.primechecker;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import com.baeldung.algorithms.primechecker.OptimisedPrimeChecker;
import com.baeldung.algorithms.primechecker.PrimeChecker;
public class OptimisedPrimeCheckerTest {
OptimisedPrimeChecker primeChecker = new OptimisedPrimeChecker();
@Test
public void givenPrimeNumber_whenCheckIsPrime_thenTrue(){
assertTrue(primeChecker.isPrime(13));
assertTrue(primeChecker.isPrime(1009));
}
@Test
public void givenNonPrimeNumber_whenCheckIsPrime_thenFalse(){
assertTrue(!primeChecker.isPrime(50));
assertTrue(!primeChecker.isPrime(1001));
}
}

View File

@ -0,0 +1,69 @@
package com.baeldung.algorithms.primechecker;
import org.junit.Test;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public class PrimeCheckerUnitTest {
private final BigIntegerPrimeChecker primeChecker = new BigIntegerPrimeChecker();
@Test
public void whenCheckIsPrime_thenTrue(){
assertTrue(primeChecker.isPrime(13l));
assertTrue(primeChecker.isPrime(1009L));
assertTrue(primeChecker.isPrime(74207281L));
}
@Test
public void whenCheckIsPrime_thenFalse(){
assertTrue(!primeChecker.isPrime(50L));
assertTrue(!primeChecker.isPrime(1001L));
assertTrue(!primeChecker.isPrime(74207282L));
}
private final BruteForcePrimeChecker bfPrimeChecker = new BruteForcePrimeChecker();
@Test
public void whenBFCheckIsPrime_thenTrue(){
assertTrue(bfPrimeChecker.isPrime(13));
assertTrue(bfPrimeChecker.isPrime(1009));
}
@Test
public void whenBFCheckIsPrime_thenFalse(){
assertFalse(bfPrimeChecker.isPrime(50));
assertFalse(bfPrimeChecker.isPrime(1001));
}
private final OptimisedPrimeChecker optimisedPrimeChecker = new OptimisedPrimeChecker();
@Test
public void whenOptCheckIsPrime_thenTrue(){
assertTrue(optimisedPrimeChecker.isPrime(13));
assertTrue(optimisedPrimeChecker.isPrime(1009));
}
@Test
public void whenOptCheckIsPrime_thenFalse(){
assertFalse(optimisedPrimeChecker.isPrime(50));
assertFalse(optimisedPrimeChecker.isPrime(1001));
}
private final PrimesPrimeChecker primesPrimeChecker = new PrimesPrimeChecker();
@Test
public void whenPrimesCheckIsPrime_thenTrue() {
assertTrue(primesPrimeChecker.isPrime(13));
assertTrue(primesPrimeChecker.isPrime(1009));
}
@Test
public void whenPrimesCheckIsPrime_thenFalse() {
assertFalse(primesPrimeChecker.isPrime(50));
assertFalse(primesPrimeChecker.isPrime(1001));
}
}

View File

@ -1,25 +0,0 @@
package com.baeldung.algorithms.primechecker;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import com.baeldung.algorithms.primechecker.PrimeChecker;
import com.baeldung.algorithms.primechecker.PrimesPrimeChecker;
public class PrimesPrimeCheckerTest {
PrimesPrimeChecker primeChecker = new PrimesPrimeChecker();
@Test
public void givenPrimeNumber_whenCheckIsPrime_thenTrue() {
assertTrue(primeChecker.isPrime(13));
assertTrue(primeChecker.isPrime(1009));
}
@Test
public void givenNonPrimeNumber_whenCheckIsPrime_thenFalse() {
assertTrue(!primeChecker.isPrime(50));
assertTrue(!primeChecker.isPrime(1001));
}
}

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0" 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"> 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> <modelVersion>4.0.0</modelVersion>
<parent> <parent>

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
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> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
@ -13,11 +12,6 @@
<artifactId>annotation-user</artifactId> <artifactId>annotation-user</artifactId>
<properties>
<junit.version>4.12</junit.version>
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
</properties>
<dependencies> <dependencies>
<dependency> <dependency>
@ -26,31 +20,6 @@
<version>${project.parent.version}</version> <version>${project.parent.version}</version>
</dependency> </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project> </project>

View File

@ -4,7 +4,7 @@ import org.junit.Test;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
public class PersonBuilderTest { public class PersonBuilderUnitTest {
@Test @Test
public void whenBuildPersonWithBuilder_thenObjectHasPropertyValues() { public void whenBuildPersonWithBuilder_thenObjectHasPropertyValues() {

View File

@ -5,6 +5,11 @@
<artifactId>apache-bval</artifactId> <artifactId>apache-bval</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.apache.bval</groupId> <groupId>org.apache.bval</groupId>
@ -21,31 +26,9 @@
<artifactId>bval-extras</artifactId> <artifactId>bval-extras</artifactId>
<version>${bval.version}</version> <version>${bval.version}</version>
</dependency> </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<properties> <properties>
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
<junit.version>4.12</junit.version>
<bval.version>1.1.2</bval.version> <bval.version>1.1.2</bval.version>
</properties> </properties>
</project> </project>

View File

@ -17,7 +17,7 @@ import static org.junit.Assert.*;
import com.baeldung.model.User; import com.baeldung.model.User;
public class ValidationTest { public class ValidationIntegrationTest {
private static ValidatorFactory validatorFactory; private static ValidatorFactory validatorFactory;
private static Validator validator; private static Validator validator;

View File

@ -26,7 +26,7 @@ import org.apache.cxf.aegis.AegisReader;
import org.apache.cxf.aegis.AegisWriter; import org.apache.cxf.aegis.AegisWriter;
import org.apache.cxf.aegis.type.AegisType; import org.apache.cxf.aegis.type.AegisType;
public class BaeldungTest { public class BaeldungIntegrationTest {
private AegisContext context; private AegisContext context;
private String fileName = "baeldung.xml"; private String fileName = "baeldung.xml";

View File

@ -6,6 +6,12 @@
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<modules> <modules>
<module>cxf-introduction</module> <module>cxf-introduction</module>
<module>cxf-spring</module> <module>cxf-spring</module>
@ -14,33 +20,13 @@
</modules> </modules>
<properties> <properties>
<junit.version>4.12</junit.version>
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
<exec-maven-plugin.version>1.5.0</exec-maven-plugin.version> <exec-maven-plugin.version>1.5.0</exec-maven-plugin.version>
</properties> </properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build> <build>
<defaultGoal>install</defaultGoal> <defaultGoal>install</defaultGoal>
<pluginManagement> <pluginManagement>
<plugins> <plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin> <plugin>
<groupId>org.codehaus.mojo</groupId> <groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId> <artifactId>exec-maven-plugin</artifactId>

View File

@ -7,59 +7,14 @@
<name>apache-fop</name> <name>apache-fop</name>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<dependencies> <dependencies>
<!-- logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${org.slf4j.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
<!-- <scope>runtime</scope> -->
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${org.slf4j.version}</version>
<!-- <scope>runtime</scope> --> <!-- some spring dependencies need to compile against jcl -->
</dependency>
<!-- test scoped -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>${org.hamcrest.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>${org.hamcrest.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<!-- new dependencies --> <!-- new dependencies -->
<dependency> <dependency>
<groupId>org.apache.xmlgraphics</groupId> <groupId>org.apache.xmlgraphics</groupId>
<artifactId>fop</artifactId> <artifactId>fop</artifactId>
@ -125,35 +80,6 @@
<filtering>true</filtering> <filtering>true</filtering>
</resource> </resource>
</resources> </resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<forkCount>3</forkCount>
<reuseForks>true</reuseForks>
<excludes>
<exclude>**/*IntegrationTest.java</exclude>
<exclude>**/*LiveTest.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build> </build>
<profiles> <profiles>
@ -197,19 +123,6 @@
<avalon-framework.version>4.3</avalon-framework.version> <avalon-framework.version>4.3</avalon-framework.version>
<dbdoclet.version>8.0.2</dbdoclet.version> <dbdoclet.version>8.0.2</dbdoclet.version>
<jtidy.version>r938</jtidy.version> <jtidy.version>r938</jtidy.version>
<!-- logging -->
<org.slf4j.version>1.7.21</org.slf4j.version>
<logback.version>1.1.7</logback.version>
<!-- testing -->
<org.hamcrest.version>1.3</org.hamcrest.version>
<junit.version>4.12</junit.version>
<mockito.version>1.10.19</mockito.version>
<!-- maven plugins -->
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
</properties> </properties>
</project> </project>

View File

@ -5,34 +5,18 @@
<artifactId>apache-poi</artifactId> <artifactId>apache-poi</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<properties> <properties>
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
<junit.version>4.12</junit.version>
<poi.version>3.15</poi.version> <poi.version>3.15</poi.version>
<jexcel.version>1.0.6</jexcel.version> <jexcel.version>1.0.6</jexcel.version>
</properties> </properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies> <dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>org.apache.poi</groupId> <groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId> <artifactId>poi-ooxml</artifactId>

View File

@ -21,7 +21,7 @@ import org.junit.Test;
import org.junit.Before; import org.junit.Before;
import org.junit.After; import org.junit.After;
public class JExcelTest { public class JExcelIntegrationTest {
private JExcelHelper jExcelHelper; private JExcelHelper jExcelHelper;
private static String FILE_NAME = "temp.xls"; private static String FILE_NAME = "temp.xls";

View File

@ -18,7 +18,7 @@ import org.junit.Test;
import org.junit.Before; import org.junit.Before;
import org.junit.After; import org.junit.After;
public class ExcelTest { public class ExcelIntegrationTest {
private ExcelPOIHelper excelPOIHelper; private ExcelPOIHelper excelPOIHelper;
private static String FILE_NAME = "temp.xlsx"; private static String FILE_NAME = "temp.xlsx";

View File

@ -14,12 +14,12 @@ import org.apache.poi.xwpf.usermodel.XWPFRun;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
public class WordTest { public class WordIntegrationTest {
static WordDocument wordDocument; static WordDocument wordDocument;
@BeforeClass @BeforeClass
public static void generateMSWordFile() throws Exception { public static void generateMSWordFile() throws Exception {
WordTest.wordDocument = new WordDocument(); WordIntegrationTest.wordDocument = new WordDocument();
wordDocument.handleSimpleDoc(); wordDocument.handleSimpleDoc();
} }

View File

@ -1,50 +1,23 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 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> <modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<artifactId>apache-solrj</artifactId> <artifactId>apache-solrj</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>apache-solrj</name> <name>apache-solrj</name>
<properties> <parent>
<junit.version>4.12</junit.version> <groupId>com.baeldung</groupId>
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version> <artifactId>parent-modules</artifactId>
</properties> <version>1.0.0-SNAPSHOT</version>
</parent>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.apache.solr</groupId> <groupId>org.apache.solr</groupId>
<artifactId>solr-solrj</artifactId> <artifactId>solr-solrj</artifactId>
<version>6.4.0</version> <version>6.4.0</version>
</dependency> </dependency>
<dependency> </dependencies>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<excludes>
<exclude>**/*IntegrationTest.java</exclude>
<exclude>**/*LiveTest.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project> </project>

View File

@ -6,10 +6,14 @@
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<properties> <properties>
<java.versin>1.8</java.versin> <java.versin>1.8</java.versin>
<junit.version>4.12</junit.version>
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
<thrift.version>0.10.0</thrift.version> <thrift.version>0.10.0</thrift.version>
<maven-thrift.version>0.1.11</maven-thrift.version> <maven-thrift.version>0.1.11</maven-thrift.version>
</properties> </properties>
@ -27,13 +31,6 @@
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId> <artifactId>slf4j-simple</artifactId>
@ -45,22 +42,15 @@
<build> <build>
<defaultGoal>install</defaultGoal> <defaultGoal>install</defaultGoal>
<plugins> <plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin> <plugin>
<groupId>org.codehaus.mojo</groupId> <groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId> <artifactId>build-helper-maven-plugin</artifactId>
<executions> <executions>
<execution> <execution>
<phase>generate-sources</phase> <phase>generate-sources</phase>
<goals><goal>add-source</goal></goals> <goals>
<goal>add-source</goal>
</goals>
<configuration> <configuration>
<sources> <sources>
<source>generated</source> <source>generated</source>

View File

@ -6,7 +6,7 @@ import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
public class CrossPlatformServiceTest { public class CrossPlatformServiceIntegrationTest {
private CrossPlatformServiceServer server = new CrossPlatformServiceServer(); private CrossPlatformServiceServer server = new CrossPlatformServiceServer();

View File

@ -1,5 +1,5 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
@ -9,27 +9,22 @@
<packaging>war</packaging> <packaging>war</packaging>
<name>apache-velocity</name> <name>apache-velocity</name>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<properties> <properties>
<jdk.version>1.8</jdk.version> <jdk.version>1.8</jdk.version>
<jstl.version>1.2</jstl.version> <jstl.version>1.2</jstl.version>
<junit.version>4.11</junit.version>
<logback.version>1.0.13</logback.version>
<jcl-over-slf4j.version>1.7.5</jcl-over-slf4j.version>
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
<maven-war-plugin.version>2.6</maven-war-plugin.version> <maven-war-plugin.version>2.6</maven-war-plugin.version>
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
<org.apache.httpcomponents.version>4.5.2</org.apache.httpcomponents.version> <org.apache.httpcomponents.version>4.5.2</org.apache.httpcomponents.version>
<velocity-version>1.7</velocity-version> <velocity-version>1.7</velocity-version>
<velocity-tools-version>2.0</velocity-tools-version> <velocity-tools-version>2.0</velocity-tools-version>
</properties> </properties>
<dependencies> <dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>org.apache.velocity</groupId> <groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId> <artifactId>velocity</artifactId>
@ -40,16 +35,6 @@
<artifactId>velocity-tools</artifactId> <artifactId>velocity-tools</artifactId>
<version>${velocity-tools-version}</version> <version>${velocity-tools-version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${jcl-over-slf4j.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency> <dependency>
<groupId>org.apache.httpcomponents</groupId> <groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId> <artifactId>httpclient</artifactId>
@ -72,15 +57,6 @@
</resource> </resource>
</resources> </resources>
<plugins> <plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId> <artifactId>maven-war-plugin</artifactId>
@ -89,19 +65,6 @@
<failOnMissingWebXml>false</failOnMissingWebXml> <failOnMissingWebXml>false</failOnMissingWebXml>
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<excludes>
<exclude>**/*LiveTest.java</exclude>
</excludes>
<systemPropertyVariables>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins> </plugins>
</build> </build>
</project> </project>

View File

@ -6,20 +6,11 @@
<version>1.0</version> <version>1.0</version>
<name>autovalue</name> <name>autovalue</name>
<build> <parent>
<plugins> <groupId>com.baeldung</groupId>
<plugin> <artifactId>parent-modules</artifactId>
<groupId>org.apache.maven.plugins</groupId> <version>1.0.0-SNAPSHOT</version>
<artifactId>maven-compiler-plugin</artifactId> </parent>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>7</source>
<target>7</target>
<useIncrementalCompilation>false</useIncrementalCompilation>
</configuration>
</plugin>
</plugins>
</build>
<dependencies> <dependencies>
<dependency> <dependency>
@ -27,19 +18,10 @@
<artifactId>auto-value</artifactId> <artifactId>auto-value</artifactId>
<version>${auto-value.version}</version> <version>${auto-value.version}</version>
</dependency> </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<properties> <properties>
<auto-value.version>1.3</auto-value.version> <auto-value.version>1.3</auto-value.version>
<junit.version>4.12</junit.version>
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
</properties> </properties>
</project> </project>

View File

@ -1,75 +1,81 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 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> <modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<artifactId>aws</artifactId> <artifactId>aws</artifactId>
<version>0.1.0-SNAPSHOT</version> <version>0.1.0-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>aws</name> <name>aws</name>
<properties> <parent>
<commons-io.version>2.5</commons-io.version> <groupId>com.baeldung</groupId>
<aws-lambda-java-events.version>1.3.0</aws-lambda-java-events.version> <artifactId>parent-modules</artifactId>
<aws-lambda-java-core.version>1.1.0</aws-lambda-java-core.version> <version>1.0.0-SNAPSHOT</version>
<gson.version>2.8.0</gson.version> </parent>
</properties>
<dependencies> <properties>
<dependency> <commons-io.version>2.5</commons-io.version>
<groupId>com.amazonaws</groupId> <aws-lambda-java-events.version>1.3.0</aws-lambda-java-events.version>
<artifactId>aws-lambda-java-core</artifactId> <aws-lambda-java-core.version>1.1.0</aws-lambda-java-core.version>
<version>${aws-lambda-java-core.version}</version> <gson.version>2.8.0</gson.version>
<exclusions> </properties>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency> <dependencies>
<groupId>com.amazonaws</groupId> <dependency>
<artifactId>aws-lambda-java-events</artifactId> <groupId>com.amazonaws</groupId>
<version>${aws-lambda-java-events.version}</version> <artifactId>aws-lambda-java-core</artifactId>
<exclusions> <version>${aws-lambda-java-core.version}</version>
<exclusion> <exclusions>
<artifactId>commons-logging</artifactId> <exclusion>
<groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId>
</exclusion> <groupId>commons-logging</groupId>
</exclusions> </exclusion>
</dependency> </exclusions>
</dependency>
<dependency> <dependency>
<groupId>commons-io</groupId> <groupId>com.amazonaws</groupId>
<artifactId>commons-io</artifactId> <artifactId>aws-lambda-java-events</artifactId>
<version>${commons-io.version}</version> <version>${aws-lambda-java-events.version}</version>
</dependency> <exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency> <dependency>
<groupId>com.google.code.gson</groupId> <groupId>commons-io</groupId>
<artifactId>gson</artifactId> <artifactId>commons-io</artifactId>
<version>${gson.version}</version> <version>${commons-io.version}</version>
</dependency> </dependency>
</dependencies>
<build> <dependency>
<plugins> <groupId>com.google.code.gson</groupId>
<plugin> <artifactId>gson</artifactId>
<groupId>org.apache.maven.plugins</groupId> <version>${gson.version}</version>
<artifactId>maven-shade-plugin</artifactId> </dependency>
<version>3.0.0</version> </dependencies>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom> <build>
</configuration> <plugins>
<executions> <plugin>
<execution> <groupId>org.apache.maven.plugins</groupId>
<phase>package</phase> <artifactId>maven-shade-plugin</artifactId>
<goals> <version>3.0.0</version>
<goal>shade</goal> <configuration>
</goals> <createDependencyReducedPom>false</createDependencyReducedPom>
</execution> </configuration>
</executions> <executions>
</plugin> <execution>
</plugins> <phase>package</phase>
</build> <goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project> </project>

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>parent-modules</artifactId> <artifactId>parent-modules</artifactId>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
@ -10,18 +9,6 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>axon</artifactId> <artifactId>axon</artifactId>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies> <dependencies>
<dependency> <dependency>
@ -35,18 +22,10 @@
<artifactId>axon-core</artifactId> <artifactId>axon-core</artifactId>
<version>${axon.version}</version> <version>${axon.version}</version>
</dependency> </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<properties> <properties>
<axon.version>3.0.2</axon.version> <axon.version>3.0.2</axon.version>
<junit.version>4.12</junit.version>
</properties> </properties>
</project> </project>

View File

@ -12,7 +12,7 @@ import org.junit.Test;
import java.util.UUID; import java.util.UUID;
public class MessagesAggregateTest { public class MessagesAggregateIntegrationTest {
private FixtureConfiguration<MessagesAggregate> fixture; private FixtureConfiguration<MessagesAggregate> fixture;

View File

@ -7,6 +7,12 @@
<artifactId>cdi</artifactId> <artifactId>cdi</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
@ -30,12 +36,6 @@
<version>${weld-se-core.version}</version> <version>${weld-se-core.version}</version>
</dependency> </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId> <artifactId>spring-test</artifactId>
@ -45,23 +45,6 @@
</dependencies> </dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<excludes>
<exclude>**/*IntegrationTest.java</exclude>
<exclude>**/*LiveTest.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
<profiles> <profiles>
<profile> <profile>
<id>integration</id> <id>integration</id>
@ -100,8 +83,6 @@
<spring.version>4.3.4.RELEASE</spring.version> <spring.version>4.3.4.RELEASE</spring.version>
<aspectjweaver.version>1.8.9</aspectjweaver.version> <aspectjweaver.version>1.8.9</aspectjweaver.version>
<weld-se-core.version>2.4.1.Final</weld-se-core.version> <weld-se-core.version>2.4.1.Final</weld-se-core.version>
<junit.version>4.12</junit.version>
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
</properties> </properties>
</project> </project>

View File

@ -10,7 +10,7 @@ import java.util.stream.Stream;
import org.junit.Test; import org.junit.Test;
public class Java9OptionalsStreamTest { public class Java9OptionalsStreamUnitTest {
private static List<Optional<String>> listOfOptionals = Arrays.asList(Optional.empty(), Optional.of("foo"), Optional.empty(), Optional.of("bar")); private static List<Optional<String>> listOfOptionals = Arrays.asList(Optional.empty(), Optional.of("foo"), Optional.empty(), Optional.of("bar"));

View File

@ -11,7 +11,7 @@ import java.util.List;
import org.junit.Test; import org.junit.Test;
public class MultiResultionImageTest { public class MultiResultionImageUnitTest {
@Test @Test
public void baseMultiResImageTest() { public void baseMultiResImageTest() {

View File

@ -6,7 +6,7 @@ import java.util.stream.Stream;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
public class OptionalToStreamTest { public class OptionalToStreamUnitTest {
@Test @Test
public void testOptionalToStream() { public void testOptionalToStream() {

View File

@ -5,7 +5,7 @@ import org.junit.Test;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
public class SetExamplesTest { public class SetExamplesUnitTest {
@Test @Test
public void testUnmutableSet() { public void testUnmutableSet() {

View File

@ -9,7 +9,7 @@ import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import org.junit.Test; import org.junit.Test;
public class CompletableFutureTest { public class CompletableFutureUnitTest {
@Test @Test
public void testDelay () throws Exception { public void testDelay () throws Exception {
Object input = new Object(); Object input = new Object();

View File

@ -24,7 +24,7 @@ import javax.net.ssl.SSLParameters;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
public class SimpleHttpRequestsTest { public class SimpleHttpRequestsUnitTest {
private URI httpURI; private URI httpURI;

View File

@ -2,7 +2,7 @@ package com.baeldung.java9.language;
import org.junit.Test; import org.junit.Test;
public class DiamondTest { public class DiamondUnitTest {
static class FooClass<X> { static class FooClass<X> {
FooClass(X x) { FooClass(X x) {

View File

@ -3,7 +3,7 @@ package com.baeldung.java9.language;
import com.baeldung.java9.language.PrivateInterface; import com.baeldung.java9.language.PrivateInterface;
import org.junit.Test; import org.junit.Test;
public class PrivateInterfaceTest { public class PrivateInterfaceUnitTest {
@Test @Test
public void test() { public void test() {

View File

@ -3,7 +3,7 @@ package com.baeldung.java9.language;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import org.junit.Test; import org.junit.Test;
public class TryWithResourcesTest { public class TryWithResourcesUnitTest {
static int closeCount = 0; static int closeCount = 0;

View File

@ -9,7 +9,7 @@ import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
public class ListFactoryMethodsTest { public class ListFactoryMethodsUnitTest {
@Test @Test
public void whenListCreated_thenSuccess() { public void whenListCreated_thenSuccess() {

View File

@ -8,7 +8,7 @@ import org.junit.Test;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
public class MapFactoryMethodsTest { public class MapFactoryMethodsUnitTest {
@Test @Test
public void whenMapCreated_thenSuccess() { public void whenMapCreated_thenSuccess() {

View File

@ -9,7 +9,7 @@ import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
public class SetFactoryMethodsTest { public class SetFactoryMethodsUnitTest {
@Test @Test
public void whenSetCreated_thenSuccess() { public void whenSetCreated_thenSuccess() {

View File

@ -8,7 +8,7 @@ import java.util.function.Function;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
public class CollectorImprovementTest { public class CollectorImprovementUnitTest {
@Test @Test
public void givenList_whenSatifyPredicate_thenMapValueWithOccurences() { public void givenList_whenSatifyPredicate_thenMapValueWithOccurences() {
List<Integer> numbers = List.of(1, 2, 3, 5, 5); List<Integer> numbers = List.of(1, 2, 3, 5, 5);

View File

@ -12,7 +12,7 @@ import java.util.stream.Stream;
import static java.lang.Integer.*; import static java.lang.Integer.*;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
public class StreamFeaturesTest { public class StreamFeaturesUnitTest {
public static class TakeAndDropWhileTest { public static class TakeAndDropWhileTest {

View File

@ -16,7 +16,7 @@ import org.slf4j.LoggerFactory;
* Created by sanaulla on 2/23/2017. * Created by sanaulla on 2/23/2017.
*/ */
public class ProcessAPIEnhancementsTest { public class ProcessAPIEnhancementsUnitTest {
Logger log = LoggerFactory.getLogger(ProcessAPIEnhancementsTest.class); Logger log = LoggerFactory.getLogger(ProcessAPIEnhancementsTest.class);

View File

@ -20,7 +20,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
public class ProcessApi { public class ProcessApiUnitTest {
@Before @Before
public void init() { public void init() {

View File

@ -13,7 +13,7 @@ import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.Stopwatch; import org.junit.rules.Stopwatch;
public class BaeldungBatchSubscriberImplTest { public class BaeldungBatchSubscriberImplIntegrationTest {
private static final int ITEM_SIZE = 10; private static final int ITEM_SIZE = 10;
private SubmissionPublisher<String> publisher; private SubmissionPublisher<String> publisher;

View File

@ -13,7 +13,7 @@ import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.Stopwatch; import org.junit.rules.Stopwatch;
public class BaeldungSubscriberImplTest { public class BaeldungSubscriberImplIntegrationTest {
private static final int ITEM_SIZE = 10; private static final int ITEM_SIZE = 10;
private SubmissionPublisher<String> publisher; private SubmissionPublisher<String> publisher;

View File

@ -2,7 +2,7 @@ package com.baeldung.java9.stackwalker;
import org.junit.Test; import org.junit.Test;
public class StackWalkerDemoTest { public class StackWalkerDemoUnitTest {
@Test @Test
public void giveStalkWalker_whenWalkingTheStack_thenShowStackFrames() { public void giveStalkWalker_whenWalkingTheStack_thenShowStackFrames() {

View File

@ -98,3 +98,7 @@
- [Quick Guide to the Java StringTokenizer](http://www.baeldung.com/java-stringtokenizer) - [Quick Guide to the Java StringTokenizer](http://www.baeldung.com/java-stringtokenizer)
- [JVM Log Forging](http://www.baeldung.com/jvm-log-forging) - [JVM Log Forging](http://www.baeldung.com/jvm-log-forging)
- [Guide to sun.misc.Unsafe](http://www.baeldung.com/java-unsafe) - [Guide to sun.misc.Unsafe](http://www.baeldung.com/java-unsafe)
- [HashSet and TreeSet Comparison](http://www.baeldung.com/java-hashset-vs-treeset)
- [How to Perform a Simple HTTP Request in Java](http://www.baeldung.com/java-http-request)
- [Call Methods at Runtime Using Java Reflection](http://www.baeldung.com/java-method-reflection)
- [Guide to DelayQueue](http://www.baeldung.com/java-delay-queue)

View File

@ -1,458 +1,392 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 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> <modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<artifactId>core-java</artifactId> <artifactId>core-java</artifactId>
<version>0.1.0-SNAPSHOT</version> <version>0.1.0-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>core-java</name> <name>core-java</name>
<dependencies> <dependencies>
<!-- utils --> <!-- utils -->
<dependency> <dependency>
<groupId>net.sourceforge.collections</groupId> <groupId>net.sourceforge.collections</groupId>
<artifactId>collections-generic</artifactId> <artifactId>collections-generic</artifactId>
<version>${collections-generic.version}</version> <version>${collections-generic.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.google.guava</groupId> <groupId>com.google.guava</groupId>
<artifactId>guava</artifactId> <artifactId>guava</artifactId>
<version>${guava.version}</version> <version>${guava.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>${commons-collections4.version}</version> <version>${commons-collections4.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>commons-io</groupId> <groupId>commons-io</groupId>
<artifactId>commons-io</artifactId> <artifactId>commons-io</artifactId>
<version>${commons-io.version}</version> <version>${commons-io.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>${commons-lang3.version}</version> <version>${commons-lang3.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId> <artifactId>commons-math3</artifactId>
<version>${commons-math3.version}</version> <version>${commons-math3.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.bouncycastle</groupId> <groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId> <artifactId>bcprov-jdk15on</artifactId>
<version>${bouncycastle.version}</version> <version>${bouncycastle.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.unix4j</groupId> <groupId>org.unix4j</groupId>
<artifactId>unix4j-command</artifactId> <artifactId>unix4j-command</artifactId>
<version>${unix4j.version}</version> <version>${unix4j.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.googlecode.grep4j</groupId> <groupId>com.googlecode.grep4j</groupId>
<artifactId>grep4j</artifactId> <artifactId>grep4j</artifactId>
<version>${grep4j.version}</version> <version>${grep4j.version}</version>
</dependency> </dependency>
<!-- web --> <!-- web -->
<!-- marshalling --> <!-- marshalling -->
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId> <artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version> <version>${jackson.version}</version>
</dependency> </dependency>
<!-- logging --> <!-- logging -->
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId> <artifactId>slf4j-api</artifactId>
<version>${org.slf4j.version}</version> <version>${org.slf4j.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>ch.qos.logback</groupId> <groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId> <artifactId>logback-classic</artifactId>
<version>${logback.version}</version> <version>${logback.version}</version>
<!-- <scope>runtime</scope> --> <!-- <scope>runtime</scope> -->
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId> <artifactId>jcl-over-slf4j</artifactId>
<version>${org.slf4j.version}</version> <version>${org.slf4j.version}</version>
<!-- <scope>runtime</scope> --> <!-- some spring dependencies need to compile against jcl --> <!-- <scope>runtime</scope> --> <!-- some spring dependencies need to compile against jcl -->
</dependency> </dependency>
<dependency> <dependency> <!-- needed to bridge to slf4j for projects that use the log4j APIs directly -->
<groupId>org.projectlombok</groupId> <groupId>org.slf4j</groupId>
<artifactId>lombok</artifactId> <artifactId>log4j-over-slf4j</artifactId>
<version>${lombok.version}</version> <version>${org.slf4j.version}</version>
<scope>provided</scope> </dependency>
</dependency> <dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
<!-- test scoped --> <!-- test scoped -->
<dependency> <dependency>
<groupId>org.hamcrest</groupId> <groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId> <artifactId>hamcrest-all</artifactId>
<version>1.3</version> <version>1.3</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
<version>${junit.version}</version> <version>${junit.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.hamcrest</groupId> <groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId> <artifactId>hamcrest-core</artifactId>
<version>${org.hamcrest.version}</version> <version>${org.hamcrest.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.hamcrest</groupId> <groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId> <artifactId>hamcrest-library</artifactId>
<version>${org.hamcrest.version}</version> <version>${org.hamcrest.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>${assertj.version}</version> <version>${assertj.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.testng</groupId> <groupId>org.mockito</groupId>
<artifactId>testng</artifactId> <artifactId>mockito-core</artifactId>
<version>${testng.version}</version> <version>${mockito.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>com.jayway.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>${avaitility.version}</version>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>commons-codec</groupId>
<artifactId>mockito-core</artifactId> <artifactId>commons-codec</artifactId>
<version>${mockito.version}</version> <version>${commons-codec.version}</version>
<scope>test</scope> </dependency>
</dependency>
<dependency>
<groupId>com.jayway.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>${avaitility.version}</version>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>commons-codec</groupId> <groupId>org.javamoney</groupId>
<artifactId>commons-codec</artifactId> <artifactId>moneta</artifactId>
<version>${commons-codec.version}</version> <version>1.1</version>
</dependency> </dependency>
<dependency>
<groupId>org.javamoney</groupId>
<artifactId>moneta</artifactId>
<version>1.1</version>
</dependency>
<dependency> <dependency>
<groupId>org.owasp.esapi</groupId> <groupId>org.owasp.esapi</groupId>
<artifactId>esapi</artifactId> <artifactId>esapi</artifactId>
<version>2.1.0.1</version> <version>2.1.0.1</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- JDO -->
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>javax.jdo</artifactId>
<version>3.2.0-m6</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId>
<version>5.1.0-m1</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-api-jdo</artifactId>
<version>5.1.0-m1</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-rdbms</artifactId>
<version>5.1.0-m1</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-maven-plugin</artifactId>
<version>5.0.2</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.194</version>
</dependency> </dependency>
<dependency> </dependencies>
<groupId>org.owasp.esapi</groupId>
<artifactId>esapi</artifactId>
<version>2.1.0.1</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies> <build>
<finalName>core-java</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<build> <plugins>
<finalName>core-java</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
<exclude>**/*IntegrationTest.java</exclude>
<exclude>**/*LongRunningUnitTest.java</exclude>
<exclude>**/*ManualTest.java</exclude>
</excludes>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/libs</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>libs/</classpathPrefix>
<mainClass>org.baeldung.executable.ExecutableMavenJar</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<archiveBaseDirectory>${project.basedir}</archiveBaseDirectory>
<archive>
<manifest>
<mainClass>org.baeldung.executable.ExecutableMavenJar</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.baeldung.executable.ExecutableMavenJar</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.jolira</groupId>
<artifactId>onejar-maven-plugin</artifactId>
<executions>
<execution>
<configuration>
<mainClass>org.baeldung.executable.ExecutableMavenJar</mainClass>
<attachToBuild>true</attachToBuild>
<filename>${project.build.finalName}-onejar.${project.packaging}</filename>
</configuration>
<goals>
<goal>one-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<classifier>spring-boot</classifier>
<mainClass>org.baeldung.executable.ExecutableMavenJar</mainClass>
</configuration>
</execution>
</executions>
</plugin>
<!-- JDO Plugin -->
<plugin> <plugin>
<groupId>org.datanucleus</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>datanucleus-maven-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>5.0.2</version> <version>${maven-compiler-plugin.version}</version>
<configuration> <configuration>
<api>JDO</api> <source>1.8</source>
<props>${basedir}/datanucleus.properties</props> <target>1.8</target>
<log4jConfiguration>${basedir}/log4j.properties</log4jConfiguration> </configuration>
<verbose>true</verbose> </plugin>
</configuration>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
<exclude>**/*IntegrationTest.java</exclude>
<exclude>**/*LongRunningUnitTest.java</exclude>
<exclude>**/*ManualTest.java</exclude>
</excludes>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions> <executions>
<execution> <execution>
<phase>process-classes</phase> <id>copy-dependencies</id>
<goals> <phase>prepare-package</phase>
<goal>enhance</goal> <goals>
</goals> <goal>copy-dependencies</goal>
</execution> </goals>
</executions> <configuration>
</plugin> <outputDirectory>${project.build.directory}/libs</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins> <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>libs/</classpathPrefix>
<mainClass>org.baeldung.executable.ExecutableMavenJar</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</build> <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<archiveBaseDirectory>${project.basedir}</archiveBaseDirectory>
<archive>
<manifest>
<mainClass>org.baeldung.executable.ExecutableMavenJar</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
<profiles> <plugin>
<profile> <groupId>org.apache.maven.plugins</groupId>
<id>integration</id> <artifactId>maven-shade-plugin</artifactId>
<build> <executions>
<plugins> <execution>
<plugin> <goals>
<groupId>org.apache.maven.plugins</groupId> <goal>shade</goal>
<artifactId>maven-surefire-plugin</artifactId> </goals>
<executions> <configuration>
<execution> <shadedArtifactAttached>true</shadedArtifactAttached>
<phase>integration-test</phase> <transformers>
<goals> <transformer
<goal>test</goal> implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
</goals> <mainClass>org.baeldung.executable.ExecutableMavenJar</mainClass>
<configuration> </transformer>
<excludes> </transformers>
<exclude>**/*ManualTest.java</exclude> </configuration>
</excludes> </execution>
<includes> </executions>
<include>**/*IntegrationTest.java</include> </plugin>
</includes>
</configuration>
</execution>
</executions>
<configuration>
<systemPropertyVariables>
<test.mime>json</test.mime>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<properties> <plugin>
<!-- marshalling --> <groupId>com.jolira</groupId>
<jackson.version>2.8.5</jackson.version> <artifactId>onejar-maven-plugin</artifactId>
<executions>
<execution>
<configuration>
<mainClass>org.baeldung.executable.ExecutableMavenJar</mainClass>
<attachToBuild>true</attachToBuild>
<filename>${project.build.finalName}-onejar.${project.packaging}</filename>
</configuration>
<goals>
<goal>one-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- logging --> <plugin>
<org.slf4j.version>1.7.21</org.slf4j.version> <groupId>org.springframework.boot</groupId>
<logback.version>1.1.7</logback.version> <artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<classifier>spring-boot</classifier>
<mainClass>org.baeldung.executable.ExecutableMavenJar</mainClass>
</configuration>
</execution>
</executions>
</plugin>
<!-- util --> </plugins>
<guava.version>21.0</guava.version>
<commons-lang3.version>3.5</commons-lang3.version>
<bouncycastle.version>1.55</bouncycastle.version>
<commons-codec.version>1.10</commons-codec.version>
<commons-math3.version>3.6.1</commons-math3.version>
<commons-io.version>2.5</commons-io.version>
<commons-collections4.version>4.1</commons-collections4.version>
<collections-generic.version>4.01</collections-generic.version>
<unix4j.version>0.4</unix4j.version>
<grep4j.version>1.8.7</grep4j.version>
<lombok.version>1.16.12</lombok.version>
<!-- testing --> </build>
<org.hamcrest.version>1.3</org.hamcrest.version>
<junit.version>4.12</junit.version>
<mockito.version>1.10.19</mockito.version>
<testng.version>6.10</testng.version>
<assertj.version>3.6.1</assertj.version>
<avaitility.version>1.7.0</avaitility.version>
<!-- maven plugins --> <profiles>
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version> <profile>
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version> <id>integration</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<excludes>
<exclude>**/*ManualTest.java</exclude>
</excludes>
<includes>
<include>**/*IntegrationTest.java</include>
</includes>
</configuration>
</execution>
</executions>
<configuration>
<systemPropertyVariables>
<test.mime>json</test.mime>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</properties> <properties>
<!-- marshalling -->
<jackson.version>2.8.5</jackson.version>
<!-- logging -->
<org.slf4j.version>1.7.21</org.slf4j.version>
<logback.version>1.1.7</logback.version>
<!-- util -->
<guava.version>21.0</guava.version>
<commons-lang3.version>3.5</commons-lang3.version>
<bouncycastle.version>1.55</bouncycastle.version>
<commons-codec.version>1.10</commons-codec.version>
<commons-math3.version>3.6.1</commons-math3.version>
<commons-io.version>2.5</commons-io.version>
<commons-collections4.version>4.1</commons-collections4.version>
<collections-generic.version>4.01</collections-generic.version>
<unix4j.version>0.4</unix4j.version>
<grep4j.version>1.8.7</grep4j.version>
<lombok.version>1.16.12</lombok.version>
<!-- testing -->
<org.hamcrest.version>1.3</org.hamcrest.version>
<junit.version>4.12</junit.version>
<mockito.version>1.10.19</mockito.version>
<assertj.version>3.6.1</assertj.version>
<avaitility.version>1.7.0</avaitility.version>
<!-- maven plugins -->
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
</properties>
</project> </project>

View File

@ -0,0 +1,35 @@
package com.baeldung.concurrent.delayqueue;
import com.google.common.primitives.Ints;
import java.util.concurrent.Delayed;
import java.util.concurrent.TimeUnit;
public class DelayObject implements Delayed {
private String data;
private long startTime;
public DelayObject(String data, long delayInMilliseconds) {
this.data = data;
this.startTime = System.currentTimeMillis() + delayInMilliseconds;
}
@Override
public long getDelay(TimeUnit unit) {
long diff = startTime - System.currentTimeMillis();
return unit.convert(diff, TimeUnit.MILLISECONDS);
}
@Override
public int compareTo(Delayed o) {
return Ints.saturatedCast(this.startTime - ((DelayObject) o).startTime);
}
@Override
public String toString() {
return "{" +
"data='" + data + '\'' +
", startTime=" + startTime +
'}';
}
}

View File

@ -0,0 +1,30 @@
package com.baeldung.concurrent.delayqueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.atomic.AtomicInteger;
public class DelayQueueConsumer implements Runnable {
private BlockingQueue<DelayObject> queue;
private final Integer numberOfElementsToTake;
public final AtomicInteger numberOfConsumedElements = new AtomicInteger();
public DelayQueueConsumer(BlockingQueue<DelayObject> queue, Integer numberOfElementsToTake) {
this.queue = queue;
this.numberOfElementsToTake = numberOfElementsToTake;
}
@Override
public void run() {
for (int i = 0; i < numberOfElementsToTake; i++) {
try {
DelayObject object = queue.take();
numberOfConsumedElements.incrementAndGet();
System.out.println("Consumer take: " + object);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}

View File

@ -0,0 +1,34 @@
package com.baeldung.concurrent.delayqueue;
import java.util.UUID;
import java.util.concurrent.BlockingQueue;
public class DelayQueueProducer implements Runnable {
private BlockingQueue<DelayObject> queue;
private final Integer numberOfElementsToProduce;
private final Integer delayOfEachProducedMessageMilliseconds;
public DelayQueueProducer(BlockingQueue<DelayObject> queue,
Integer numberOfElementsToProduce,
Integer delayOfEachProducedMessageMilliseconds) {
this.queue = queue;
this.numberOfElementsToProduce = numberOfElementsToProduce;
this.delayOfEachProducedMessageMilliseconds = delayOfEachProducedMessageMilliseconds;
}
@Override
public void run() {
for (int i = 0; i < numberOfElementsToProduce; i++) {
DelayObject object
= new DelayObject(UUID.randomUUID().toString(), delayOfEachProducedMessageMilliseconds);
System.out.println("Put object = " + object);
try {
queue.put(object);
Thread.sleep(500);
} catch (InterruptedException ie) {
ie.printStackTrace();
}
}
}
}

View File

@ -0,0 +1,27 @@
package com.baeldung.concurrent.phaser;
import java.util.concurrent.Phaser;
class LongRunningAction implements Runnable {
private String threadName;
private Phaser ph;
LongRunningAction(String threadName, Phaser ph) {
this.threadName = threadName;
this.ph = ph;
ph.register();
}
@Override
public void run() {
System.out.println("This is phase " + ph.getPhase());
System.out.println("Thread " + threadName + " before long running action");
ph.arriveAndAwaitAdvance();
try {
Thread.sleep(20);
} catch (InterruptedException e) {
e.printStackTrace();
}
ph.arriveAndDeregister();
}
}

View File

@ -0,0 +1,21 @@
package com.baeldung.concurrent.skiplist;
import java.time.ZonedDateTime;
public class Event {
private final ZonedDateTime eventTime;
private final String content;
public Event(ZonedDateTime eventTime, String content) {
this.eventTime = eventTime;
this.content = content;
}
public ZonedDateTime getEventTime() {
return eventTime;
}
public String getContent() {
return content;
}
}

View File

@ -0,0 +1,29 @@
package com.baeldung.concurrent.skiplist;
import java.time.ZonedDateTime;
import java.util.Comparator;
import java.util.concurrent.ConcurrentNavigableMap;
import java.util.concurrent.ConcurrentSkipListMap;
public class EventWindowSort {
private final ConcurrentSkipListMap<ZonedDateTime, String> events
= new ConcurrentSkipListMap<>(Comparator.comparingLong(value -> value.toInstant().toEpochMilli()));
public void acceptEvent(Event event) {
events.put(event.getEventTime(), event.getContent());
}
public ConcurrentNavigableMap<ZonedDateTime, String> getEventsFromLastMinute() {
return events.tailMap(ZonedDateTime
.now()
.minusMinutes(1));
}
public ConcurrentNavigableMap<ZonedDateTime, String> getEventsOlderThatOneMinute() {
return events.headMap(ZonedDateTime
.now()
.minusMinutes(1));
}
}

View File

@ -0,0 +1,27 @@
package com.baeldung.concurrent.sleepwait;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/***
* Example of waking up a waiting thread
*/
public class ThreadA {
private static final Logger LOG = LoggerFactory.getLogger(ThreadA.class);
private static final ThreadB b = new ThreadB();
public static void main(String... args) throws InterruptedException {
b.start();
synchronized (b) {
while (b.sum == 0) {
LOG.debug("Waiting for ThreadB to complete...");
b.wait();
}
LOG.debug("ThreadB has completed. Sum from that thread is: " + b.sum);
}
}
}

View File

@ -0,0 +1,20 @@
package com.baeldung.concurrent.sleepwait;
/***
* Example of waking up a waiting thread
*/
class ThreadB extends Thread {
int sum;
@Override
public void run() {
synchronized (this) {
int i = 0;
while (i < 100000) {
sum += i;
i++;
}
notify();
}
}
}

View File

@ -0,0 +1,29 @@
package com.baeldung.concurrent.sleepwait;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/***
* Example of wait() and sleep() methods
*/
public class WaitSleepExample {
private static final Logger LOG = LoggerFactory.getLogger(WaitSleepExample.class);
private static final Object LOCK = new Object();
public static void main(String... args) throws InterruptedException {
sleepWaitInSyncronizedBlocks();
}
private static void sleepWaitInSyncronizedBlocks() throws InterruptedException {
Thread.sleep(1000); // called on the thread
LOG.debug("Thread '" + Thread.currentThread().getName() + "' is woken after sleeping for 1 second");
synchronized (LOCK) {
LOCK.wait(1000); // called on the object, synchronization required
LOG.debug("Object '" + LOCK + "' is woken after waiting for 1 second");
}
}
}

View File

@ -0,0 +1,35 @@
package com.baeldung.concurrent.synchronize;
public class BaeldungSynchronizedBlocks {
private int count = 0;
private static int staticCount = 0;
public void performSynchronisedTask() {
synchronized (this) {
setCount(getCount() + 1);
}
}
public static void performStaticSyncTask() {
synchronized (BaeldungSynchronizedBlocks.class) {
setStaticCount(getStaticCount() + 1);
}
}
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
public static int getStaticCount() {
return staticCount;
}
public static void setStaticCount(int staticCount) {
BaeldungSynchronizedBlocks.staticCount = staticCount;
}
}

View File

@ -0,0 +1,37 @@
package com.baeldung.concurrent.synchronize;
public class BaeldungSynchronizedMethods {
private int sum = 0;
private int syncSum = 0;
public static int staticSum = 0;
public void calculate() {
setSum(getSum() + 1);
}
public synchronized void synchronisedCalculate() {
setSyncSum(getSyncSum() + 1);
}
public static synchronized void syncStaticCalculate() {
staticSum = staticSum + 1;
}
public int getSum() {
return sum;
}
public void setSum(int sum) {
this.sum = sum;
}
public int getSyncSum() {
return syncSum;
}
public void setSyncSum(int syncSum) {
this.syncSum = syncSum;
}
}

View File

@ -1,14 +1,19 @@
package com.baeldung.dirmonitoring; package com.baeldung.dirmonitoring;
import java.io.File;
import org.apache.commons.io.monitor.FileAlterationListener; import org.apache.commons.io.monitor.FileAlterationListener;
import org.apache.commons.io.monitor.FileAlterationListenerAdaptor; import org.apache.commons.io.monitor.FileAlterationListenerAdaptor;
import org.apache.commons.io.monitor.FileAlterationMonitor; import org.apache.commons.io.monitor.FileAlterationMonitor;
import org.apache.commons.io.monitor.FileAlterationObserver; import org.apache.commons.io.monitor.FileAlterationObserver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
public class DirectoryMonitoringExample { public class DirectoryMonitoringExample {
private static final Logger LOG = LoggerFactory.getLogger(DirectoryMonitoringExample.class);
public static final int POLL_INTERVAL = 500; public static final int POLL_INTERVAL = 500;
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
@ -17,17 +22,17 @@ public class DirectoryMonitoringExample {
FileAlterationListener listener = new FileAlterationListenerAdaptor() { FileAlterationListener listener = new FileAlterationListenerAdaptor() {
@Override @Override
public void onFileCreate(File file) { public void onFileCreate(File file) {
System.out.println("File: " + file.getName() + " created"); LOG.debug("File: " + file.getName() + " created");
} }
@Override @Override
public void onFileDelete(File file) { public void onFileDelete(File file) {
System.out.println("File: " + file.getName() + " deleted"); LOG.debug("File: " + file.getName() + " deleted");
} }
@Override @Override
public void onFileChange(File file) { public void onFileChange(File file) {
System.out.println("File: " + file.getName() + " changed"); LOG.debug("File: " + file.getName() + " changed");
} }
}; };
observer.addListener(listener); observer.addListener(listener);

View File

@ -1,9 +1,14 @@
package com.baeldung.doublecolon; package com.baeldung.doublecolon;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.function.Function; import java.util.function.Function;
public class MacbookPro extends Computer { public class MacbookPro extends Computer {
private static final Logger LOG = LoggerFactory.getLogger(MacbookPro.class);
public MacbookPro(int age, String color) { public MacbookPro(int age, String color) {
super(age, color); super(age, color);
} }
@ -14,12 +19,12 @@ public class MacbookPro extends Computer {
@Override @Override
public void turnOnPc() { public void turnOnPc() {
System.out.println("MacbookPro turned on"); LOG.debug("MacbookPro turned on");
} }
@Override @Override
public void turnOffPc() { public void turnOffPc() {
System.out.println("MacbookPro turned off"); LOG.debug("MacbookPro turned off");
} }
@Override @Override
@ -27,7 +32,7 @@ public class MacbookPro extends Computer {
Function<Double, Double> function = super::calculateValue; Function<Double, Double> function = super::calculateValue;
final Double pcValue = function.apply(initialValue); final Double pcValue = function.apply(initialValue);
System.out.println("First value is:" + pcValue); LOG.debug("First value is:" + pcValue);
return pcValue + (initialValue / 10); return pcValue + (initialValue / 10);
} }

View File

@ -0,0 +1,19 @@
package com.baeldung.dynamicproxy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
public class DynamicInvocationHandler implements InvocationHandler {
private static Logger LOGGER = LoggerFactory.getLogger(DynamicInvocationHandler.class);
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
LOGGER.info("Invoked method: {}", method.getName());
return 42;
}
}

View File

@ -0,0 +1,36 @@
package com.baeldung.dynamicproxy;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class TimingDynamicInvocationHandler implements InvocationHandler {
private static Logger LOGGER = LoggerFactory.getLogger(TimingDynamicInvocationHandler.class);
private final Map<String, Method> methods = new HashMap<>();
private Object target;
public TimingDynamicInvocationHandler(Object target) {
this.target = target;
for(Method method: target.getClass().getDeclaredMethods()) {
this.methods.put(method.getName(), method);
}
}
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
long start = System.nanoTime();
Object result = methods.get(method.getName()).invoke(target, args);
long elapsed = System.nanoTime() - start;
LOGGER.info("Executing {} finished in {} ns", method.getName(), elapsed);
return result;
}
}

View File

@ -0,0 +1,30 @@
package com.baeldung.exceptions;
import org.apache.commons.lang3.exception.ExceptionUtils;
import java.io.PrintWriter;
import java.io.StringWriter;
public class StackTraceToString {
public static void main(String[] args) {
// Convert a StackTrace to String using core java
try {
throw new NullPointerException();
} catch (Exception e) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
System.out.println(sw.toString());
}
// Convert a StackTrace to String using Apache Commons
try {
throw new IndexOutOfBoundsException();
} catch (Exception e) {
System.out.println(ExceptionUtils.getStackTrace(e));
}
}
}

View File

@ -0,0 +1,21 @@
package com.baeldung.http;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Map;
public class ParameterStringBuilder {
public static String getParamsString(Map<String, String> params) throws UnsupportedEncodingException {
StringBuilder result = new StringBuilder();
for (Map.Entry<String, String> entry : params.entrySet()) {
result.append(URLEncoder.encode(entry.getKey(), "UTF-8"));
result.append("=");
result.append(URLEncoder.encode(entry.getValue(), "UTF-8"));
result.append("&");
}
String resultString = result.toString();
return resultString.length() > 0 ? resultString.substring(0, resultString.length() - 1) : resultString;
}
}

View File

@ -1,6 +1,11 @@
package com.baeldung.java.map; package com.baeldung.java.map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class MyKey { public class MyKey {
private static final Logger LOG = LoggerFactory.getLogger(MyKey.class);
private String name; private String name;
private int id; private int id;
@ -27,7 +32,7 @@ public class MyKey {
@Override @Override
public int hashCode() { public int hashCode() {
System.out.println("Calling hashCode()"); LOG.debug("Calling hashCode()");
return id; return id;
} }
@ -38,7 +43,7 @@ public class MyKey {
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
System.out.println("Calling equals() for key: " + obj); LOG.debug("Calling equals() for key: " + obj);
if (this == obj) if (this == obj)
return true; return true;
if (obj == null) if (obj == null)

View File

@ -0,0 +1,21 @@
package com.baeldung.java.reflection;
public class Operations {
public double publicSum(int a, double b) {
return a + b;
}
public static double publicStaticMultiply(float a, long b) {
return a * b;
}
private boolean privateAnd(boolean a, boolean b) {
return a && b;
}
protected int protectedMax(int a, int b) {
return a > b ? a : b;
}
}

View File

@ -0,0 +1,51 @@
package com.baeldung.jdbc;
public class Employee {
private int id;
private String name;
private String position;
private double salary;
public Employee() {
}
public Employee(int id, String name, double salary, String position) {
this.id = id;
this.name = name;
this.salary = salary;
this.position = position;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getSalary() {
return salary;
}
public void setSalary(double salary) {
this.salary = salary;
}
public String getPosition() {
return position;
}
public void setPosition(String position) {
this.position = position;
}
}

View File

@ -1,143 +0,0 @@
package com.baeldung.jdo;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.jdo.PersistenceManager;
import javax.jdo.PersistenceManagerFactory;
import javax.jdo.Query;
import javax.jdo.Transaction;
import org.datanucleus.api.jdo.JDOPersistenceManagerFactory;
import org.datanucleus.metadata.PersistenceUnitMetaData;
public class GuideToJDO {
private static final Logger LOGGER = Logger.getLogger(GuideToJDO.class.getName());
private Random rnd = new Random();
private PersistenceUnitMetaData pumd;
public static void main(String[] args) {
new GuideToJDO();
}
public GuideToJDO() {
CreateProperties();
CreateProducts();
ListProducts();
UpdateProducts();
ListProducts();
DeleteProducts();
ListProducts();
}
public void CreateProperties(){
pumd = new PersistenceUnitMetaData("dynamic-unit", "RESOURCE_LOCAL", null);
pumd.addClassName("com.baeldung.jdo.Product");
pumd.setExcludeUnlistedClasses();
pumd.addProperty("javax.jdo.option.ConnectionDriverName", "org.h2.Driver");
pumd.addProperty("javax.jdo.option.ConnectionURL", "jdbc:h2:mem:mypersistence");
pumd.addProperty("javax.jdo.option.ConnectionUserName", "sa");
pumd.addProperty("javax.jdo.option.ConnectionPassword", "");
pumd.addProperty("datanucleus.autoCreateSchema", "true");
}
public void CreateProducts() {
PersistenceManagerFactory pmf = new JDOPersistenceManagerFactory(pumd, null);
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
Product product = new Product("Tablet", 80.0);
pm.makePersistent(product);
Product product2 = new Product("Phone", 20.0);
pm.makePersistent(product2);
Product product3 = new Product("Laptop", 200.0);
pm.makePersistent(product3);
for (int i = 0; i < 100; i++) {
String nam = "Product-" + i;
double price = rnd.nextDouble();
Product productx = new Product(nam, price);
pm.makePersistent(productx);
}
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
}
@SuppressWarnings("rawtypes")
public void UpdateProducts(){
PersistenceManagerFactory pmf = new JDOPersistenceManagerFactory(pumd, null);
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
Query query = pm.newQuery(Product.class, "name == \"Phone\"");
Collection result = (Collection) query.execute();
Product product = (Product) result.iterator().next();
product.setName("Android Phone");
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
}
@SuppressWarnings("rawtypes")
public void DeleteProducts(){
PersistenceManagerFactory pmf = new JDOPersistenceManagerFactory(pumd, null);
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
Query query = pm.newQuery(Product.class, "name == \"Android Phone\"");
Collection result = (Collection) query.execute();
Product product = (Product) result.iterator().next();
pm.deletePersistent(product);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public void ListProducts() {
PersistenceManagerFactory pmf = new JDOPersistenceManagerFactory(pumd, null);
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
Query q = pm.newQuery("SELECT FROM " + Product.class.getName() + " WHERE price > 10");
List<Product> products = (List<Product>) q.execute();
Iterator<Product> iter = products.iterator();
while (iter.hasNext()) {
Product p = iter.next();
LOGGER.log(Level.WARNING, "Product name: {0} - Price: {1}", new Object[] { p.name, p.price });
}
LOGGER.log(Level.INFO, "--------------------------------------------------------------");
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
}
}

View File

@ -1,23 +1,28 @@
package com.baeldung.jmx; package com.baeldung.jmx;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Game implements GameMBean { public class Game implements GameMBean {
private static final Logger LOG = LoggerFactory.getLogger(Game.class);
private String playerName; private String playerName;
@Override @Override
public void playFootball(String clubName) { public void playFootball(String clubName) {
System.out.println(this.playerName + " playing football for " + clubName); LOG.debug(this.playerName + " playing football for " + clubName);
} }
@Override @Override
public String getPlayerName() { public String getPlayerName() {
System.out.println("Return playerName " + this.playerName); LOG.debug("Return playerName " + this.playerName);
return playerName; return playerName;
} }
@Override @Override
public void setPlayerName(String playerName) { public void setPlayerName(String playerName) {
System.out.println("Set playerName to value " + playerName); LOG.debug("Set playerName to value " + playerName);
this.playerName = playerName; this.playerName = playerName;
} }

View File

@ -1,19 +1,20 @@
package com.baeldung.jmx; package com.baeldung.jmx;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.management.*;
import java.lang.management.ManagementFactory; import java.lang.management.ManagementFactory;
import javax.management.InstanceAlreadyExistsException;
import javax.management.MBeanRegistrationException;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
import javax.management.NotCompliantMBeanException;
import javax.management.ObjectName;
public class JMXTutorialMainlauncher { public class JMXTutorialMainlauncher {
private static final Logger LOG = LoggerFactory.getLogger(JMXTutorialMainlauncher.class);
public static void main(String[] args) { public static void main(String[] args) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
System.out.println("This is basic JMX tutorial"); LOG.debug("This is basic JMX tutorial");
ObjectName objectName = null; ObjectName objectName = null;
try { try {
objectName = new ObjectName("com.baeldung.tutorial:type=basic,name=game"); objectName = new ObjectName("com.baeldung.tutorial:type=basic,name=game");
@ -27,8 +28,8 @@ public class JMXTutorialMainlauncher {
} catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e) { } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e) {
e.printStackTrace(); e.printStackTrace();
} }
System.out.println("Registration for Game mbean with the platform server is successfull"); LOG.debug("Registration for Game mbean with the platform server is successfull");
System.out.println("Please open jconsole to access Game mbean"); LOG.debug("Please open jconsole to access Game mbean");
while (true) { while (true) {
// to ensure application does not terminate // to ensure application does not terminate
} }

View File

@ -0,0 +1,15 @@
package com.baeuldung.serialization;
public class Address {
private int houseNumber;
public int getHouseNumber() {
return houseNumber;
}
public void setHouseNumber(int houseNumber) {
this.houseNumber = houseNumber;
}
}

View File

@ -0,0 +1,44 @@
package com.baeuldung.serialization;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
public class Employee implements Serializable {
private static final long serialVersionUID = 1L;
private transient Address address; // not an serializable object
private Person person;
public Address getAddress() {
return address;
}
public void setAddress(Address address) {
this.address = address;
}
public Person getPerson() {
return person;
}
public void setPerson(Person person) {
this.person = person;
}
private void writeObject(ObjectOutputStream oos) throws IOException {
oos.defaultWriteObject();
oos.writeObject(address.getHouseNumber());
}
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
ois.defaultReadObject();
Integer houseNumber = (Integer) ois.readObject();
Address a = new Address();
a.setHouseNumber(houseNumber);
this.setAddress(a);
}
}

View File

@ -0,0 +1,30 @@
package com.baeuldung.serialization;
import java.io.Serializable;
public class Person implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private int age;
private String name;
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

View File

@ -1,9 +1,16 @@
package com.baeldung.socket; package com.baeldung.socket;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*; import java.io.*;
import java.net.*; import java.net.*;
public class EchoClient { public class EchoClient {
private static final Logger LOG = LoggerFactory.getLogger(EchoClient.class);
private Socket clientSocket; private Socket clientSocket;
private PrintWriter out; private PrintWriter out;
private BufferedReader in; private BufferedReader in;
@ -14,7 +21,7 @@ public class EchoClient {
out = new PrintWriter(clientSocket.getOutputStream(), true); out = new PrintWriter(clientSocket.getOutputStream(), true);
in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
} catch (IOException e) { } catch (IOException e) {
System.out.print(e); LOG.debug("Error when initializing connection", e);
} }
} }
@ -34,7 +41,7 @@ public class EchoClient {
out.close(); out.close();
clientSocket.close(); clientSocket.close();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); LOG.debug("error when closing", e);
} }
} }

View File

@ -1,9 +1,15 @@
package com.baeldung.socket; package com.baeldung.socket;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.*; import java.net.*;
import java.io.*; import java.io.*;
public class EchoMultiServer { public class EchoMultiServer {
private static final Logger LOG = LoggerFactory.getLogger(EchoMultiServer.class);
private ServerSocket serverSocket; private ServerSocket serverSocket;
public void start(int port) { public void start(int port) {
@ -57,7 +63,7 @@ public class EchoMultiServer {
clientSocket.close(); clientSocket.close();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); LOG.debug(e.getMessage());
} }
} }
} }

View File

@ -1,9 +1,15 @@
package com.baeldung.socket; package com.baeldung.socket;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.*; import java.net.*;
import java.io.*; import java.io.*;
public class EchoServer { public class EchoServer {
private static final Logger LOG = LoggerFactory.getLogger(EchoServer.class);
private ServerSocket serverSocket; private ServerSocket serverSocket;
private Socket clientSocket; private Socket clientSocket;
private PrintWriter out; private PrintWriter out;
@ -24,7 +30,7 @@ public class EchoServer {
out.println(inputLine); out.println(inputLine);
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); LOG.debug(e.getMessage());
} }
} }
@ -36,7 +42,7 @@ public class EchoServer {
clientSocket.close(); clientSocket.close();
serverSocket.close(); serverSocket.close();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); LOG.debug(e.getMessage());
} }
} }

View File

@ -1,5 +1,8 @@
package com.baeldung.socket; package com.baeldung.socket;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
@ -7,6 +10,9 @@ import java.io.PrintWriter;
import java.net.Socket; import java.net.Socket;
public class GreetClient { public class GreetClient {
private static final Logger LOG = LoggerFactory.getLogger(EchoMultiServer.class);
private Socket clientSocket; private Socket clientSocket;
private PrintWriter out; private PrintWriter out;
private BufferedReader in; private BufferedReader in;
@ -17,7 +23,7 @@ public class GreetClient {
out = new PrintWriter(clientSocket.getOutputStream(), true); out = new PrintWriter(clientSocket.getOutputStream(), true);
in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
} catch (IOException e) { } catch (IOException e) {
LOG.debug(e.getMessage());
} }
} }
@ -37,7 +43,7 @@ public class GreetClient {
out.close(); out.close();
clientSocket.close(); clientSocket.close();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); LOG.debug(e.getMessage());
} }
} }

View File

@ -1,9 +1,15 @@
package com.baeldung.socket; package com.baeldung.socket;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.*; import java.net.*;
import java.io.*; import java.io.*;
public class GreetServer { public class GreetServer {
private static final Logger LOG = LoggerFactory.getLogger(GreetServer.class);
private ServerSocket serverSocket; private ServerSocket serverSocket;
private Socket clientSocket; private Socket clientSocket;
private PrintWriter out; private PrintWriter out;
@ -21,7 +27,7 @@ public class GreetServer {
else else
out.println("unrecognised greeting"); out.println("unrecognised greeting");
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); LOG.debug(e.getMessage());
} }
} }
@ -33,7 +39,7 @@ public class GreetServer {
clientSocket.close(); clientSocket.close();
serverSocket.close(); serverSocket.close();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); LOG.debug(e.getMessage());
} }
} }

View File

@ -0,0 +1,8 @@
package com.baeldung.stackoverflowerror;
public class AccountHolder {
private String firstName;
private String lastName;
AccountHolder jointAccountHolder = new AccountHolder();
}

View File

@ -0,0 +1,16 @@
package com.baeldung.stackoverflowerror;
public class ClassOne {
private int oneValue;
private ClassTwo clsTwoInstance = null;
public ClassOne() {
oneValue = 0;
clsTwoInstance = new ClassTwo();
}
public ClassOne(int oneValue, ClassTwo clsTwoInstance) {
this.oneValue = oneValue;
this.clsTwoInstance = clsTwoInstance;
}
}

View File

@ -0,0 +1,16 @@
package com.baeldung.stackoverflowerror;
public class ClassTwo {
private int twoValue;
private ClassOne clsOneInstance = null;
public ClassTwo() {
twoValue = 10;
clsOneInstance = new ClassOne();
}
public ClassTwo(int twoValue, ClassOne clsOneInstance) {
this.twoValue = twoValue;
this.clsOneInstance = clsOneInstance;
}
}

View File

@ -0,0 +1,7 @@
package com.baeldung.stackoverflowerror;
public class InfiniteRecursionWithTerminationCondition {
public int calculateFactorial(final int number) {
return number == 1 ? 1 : number * calculateFactorial(number - 1);
}
}

View File

@ -0,0 +1,7 @@
package com.baeldung.stackoverflowerror;
public class RecursionWithCorrectTerminationCondition {
public int calculateFactorial(final int number) {
return number <= 1 ? 1 : number * calculateFactorial(number - 1);
}
}

View File

@ -0,0 +1,7 @@
package com.baeldung.stackoverflowerror;
public class UnintendedInfiniteRecursion {
public int calculateFactorial(int number) {
return number * calculateFactorial(number - 1);
}
}

View File

@ -1,9 +1,15 @@
package com.baeldung.stream; package com.baeldung.stream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.stream.Stream; import java.util.stream.Stream;
public class InfiniteStreams { public class InfiniteStreams {
private static final Logger LOG = LoggerFactory.getLogger(InfiniteStreams.class);
public static void main(String[] args) { public static void main(String[] args) {
doWhileOldWay(); doWhileOldWay();
@ -15,7 +21,7 @@ public class InfiniteStreams {
int i = 0; int i = 0;
while (i < 10) { while (i < 10) {
System.out.println(i); LOG.debug("{}", i);
i++; i++;
} }
} }

View File

@ -0,0 +1,26 @@
package com.baeldung.string;
import java.util.Optional;
public class StringHelper {
public static String removeLastChar(String s) {
return (s == null || s.length() == 0) ? s : (s.substring(0, s.length() - 1));
}
public static String removeLastCharRegex(String s) {
return (s == null) ? s : s.replaceAll(".$", "");
}
public static String removeLastCharOptional(String s) {
return Optional.ofNullable(s)
.filter(str -> str.length() != 0)
.map(str -> str.substring(0, str.length() - 1))
.orElse(s);
}
public static String removeLastCharRegexOptional(String s) {
return Optional.ofNullable(s)
.map(str -> str.replaceAll(".$", ""))
.orElse(s);
}
}

Some files were not shown because too many files have changed in this diff Show More