Merge branch 'master' into SpringReactiveKotlin
This commit is contained in:
commit
a5bba1e3b8
|
@ -4,7 +4,7 @@ before_install:
|
||||||
- echo "MAVEN_OPTS='-Xmx2048M -Xss128M -XX:+CMSClassUnloadingEnabled -XX:+UseG1GC -XX:-UseGCOverheadLimit'" > ~/.mavenrc
|
- echo "MAVEN_OPTS='-Xmx2048M -Xss128M -XX:+CMSClassUnloadingEnabled -XX:+UseG1GC -XX:-UseGCOverheadLimit'" > ~/.mavenrc
|
||||||
|
|
||||||
install: skip
|
install: skip
|
||||||
script: travis_wait 60 mvn -q install
|
script: travis_wait 60 mvn -q install -Pdefault
|
||||||
|
|
||||||
sudo: required
|
sudo: required
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
- [Ant Colony Optimization](http://www.baeldung.com/java-ant-colony-optimization)
|
- [Ant Colony Optimization](http://www.baeldung.com/java-ant-colony-optimization)
|
||||||
- [Validating Input With Finite Automata in Java](http://www.baeldung.com/java-finite-automata)
|
- [Validating Input With Finite Automata in Java](http://www.baeldung.com/java-finite-automata)
|
||||||
- [Introduction to Jenetics Library](http://www.baeldung.com/jenetics)
|
- [Introduction to Jenetics Library](http://www.baeldung.com/jenetics)
|
||||||
- [Check If a Number Is Prime in Java](http://www.baeldung.com/java-prime-numbers)
|
|
||||||
- [Example of Hill Climbing Algorithm](http://www.baeldung.com/java-hill-climbing-algorithm)
|
- [Example of Hill Climbing Algorithm](http://www.baeldung.com/java-hill-climbing-algorithm)
|
||||||
- [Monte Carlo Tree Search for Tic-Tac-Toe Game](http://www.baeldung.com/java-monte-carlo-tree-search)
|
- [Monte Carlo Tree Search for Tic-Tac-Toe Game](http://www.baeldung.com/java-monte-carlo-tree-search)
|
||||||
- [String Search Algorithms for Large Texts](http://www.baeldung.com/java-full-text-search-algorithms)
|
- [String Search Algorithms for Large Texts](http://www.baeldung.com/java-full-text-search-algorithms)
|
||||||
|
@ -21,7 +20,6 @@
|
||||||
- [Create a Sudoku Solver in Java](http://www.baeldung.com/java-sudoku)
|
- [Create a Sudoku Solver in Java](http://www.baeldung.com/java-sudoku)
|
||||||
- [Displaying Money Amounts in Words](http://www.baeldung.com/java-money-into-words)
|
- [Displaying Money Amounts in Words](http://www.baeldung.com/java-money-into-words)
|
||||||
- [A Collaborative Filtering Recommendation System in Java](http://www.baeldung.com/java-collaborative-filtering-recommendations)
|
- [A Collaborative Filtering Recommendation System in Java](http://www.baeldung.com/java-collaborative-filtering-recommendations)
|
||||||
- [Find All Pairs of Numbers in an Array That Add Up to a Given Sum](http://www.baeldung.com/java-algorithm-number-pairs-sum)
|
|
||||||
- [Converting Between Roman and Arabic Numerals in Java](http://www.baeldung.com/java-convert-roman-arabic)
|
- [Converting Between Roman and Arabic Numerals in Java](http://www.baeldung.com/java-convert-roman-arabic)
|
||||||
- [Practical Java Examples of the Big O Notation](http://www.baeldung.com/java-algorithm-complexity)
|
- [Practical Java Examples of the Big O Notation](http://www.baeldung.com/java-algorithm-complexity)
|
||||||
- [Find the Middle Element of a Linked List](http://www.baeldung.com/java-linked-list-middle-element)
|
- [Find the Middle Element of a Linked List](http://www.baeldung.com/java-linked-list-middle-element)
|
||||||
|
|
|
@ -6,7 +6,6 @@ import com.baeldung.algorithms.ga.annealing.SimulatedAnnealing;
|
||||||
import com.baeldung.algorithms.ga.ant_colony.AntColonyOptimization;
|
import com.baeldung.algorithms.ga.ant_colony.AntColonyOptimization;
|
||||||
import com.baeldung.algorithms.ga.binary.SimpleGeneticAlgorithm;
|
import com.baeldung.algorithms.ga.binary.SimpleGeneticAlgorithm;
|
||||||
import com.baeldung.algorithms.slope_one.SlopeOne;
|
import com.baeldung.algorithms.slope_one.SlopeOne;
|
||||||
import com.baeldung.algorithms.pairsaddupnumber.FindPairs;
|
|
||||||
|
|
||||||
public class RunAlgorithm {
|
public class RunAlgorithm {
|
||||||
|
|
||||||
|
@ -39,12 +38,6 @@ public class RunAlgorithm {
|
||||||
case 5:
|
case 5:
|
||||||
System.out.println("Please run the DijkstraAlgorithmTest.");
|
System.out.println("Please run the DijkstraAlgorithmTest.");
|
||||||
break;
|
break;
|
||||||
case 6:
|
|
||||||
final FindPairs findPairs = new FindPairs();
|
|
||||||
final int[] input = {1, 4, 3, 2, 1, 4, 4, 3, 3};
|
|
||||||
final int sum = 6;
|
|
||||||
findPairs.execute(input, sum);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
System.out.println("Unknown option");
|
System.out.println("Unknown option");
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,59 +0,0 @@
|
||||||
package com.baeldung.algorithms.prime;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.IntStream;
|
|
||||||
|
|
||||||
public class PrimeGenerator {
|
|
||||||
public static List<Integer> sieveOfEratosthenes(int n) {
|
|
||||||
final boolean prime[] = new boolean[n + 1];
|
|
||||||
Arrays.fill(prime, true);
|
|
||||||
|
|
||||||
for (int p = 2; p * p <= n; p++) {
|
|
||||||
if (prime[p]) {
|
|
||||||
for (int i = p * 2; i <= n; i += p)
|
|
||||||
prime[i] = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final List<Integer> primes = new LinkedList<>();
|
|
||||||
for (int i = 2; i <= n; i++) {
|
|
||||||
if (prime[i])
|
|
||||||
primes.add(i);
|
|
||||||
}
|
|
||||||
return primes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<Integer> primeNumbersBruteForce(int max) {
|
|
||||||
final List<Integer> primeNumbers = new LinkedList<Integer>();
|
|
||||||
for (int i = 2; i <= max; i++) {
|
|
||||||
if (isPrimeBruteForce(i)) {
|
|
||||||
primeNumbers.add(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return primeNumbers;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isPrimeBruteForce(int x) {
|
|
||||||
for (int i = 2; i < x; i++) {
|
|
||||||
if (x % i == 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<Integer> primeNumbersTill(int max) {
|
|
||||||
return IntStream.rangeClosed(2, max)
|
|
||||||
.filter(x -> isPrime(x))
|
|
||||||
.boxed()
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isPrime(int x) {
|
|
||||||
return IntStream.rangeClosed(2, (int) (Math.sqrt(x)))
|
|
||||||
.allMatch(n -> x % n != 0);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
package com.baeldung.algorithms.prime;
|
|
||||||
|
|
||||||
import static com.baeldung.algorithms.prime.PrimeGenerator.*;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import org.junit.Test;
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
public class PrimeGeneratorUnitTest {
|
|
||||||
@Test
|
|
||||||
public void whenBruteForced_returnsSuccessfully() {
|
|
||||||
final List<Integer> primeNumbers = primeNumbersBruteForce(20);
|
|
||||||
assertEquals(Arrays.asList(new Integer[] { 2, 3, 5, 7, 11, 13, 17, 19 }), primeNumbers);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenOptimized_returnsSuccessfully() {
|
|
||||||
final List<Integer> primeNumbers = primeNumbersTill(20);
|
|
||||||
assertEquals(Arrays.asList(new Integer[] { 2, 3, 5, 7, 11, 13, 17, 19 }), primeNumbers);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenSieveOfEratosthenes_returnsSuccessfully() {
|
|
||||||
final List<Integer> primeNumbers = sieveOfEratosthenes(20);
|
|
||||||
assertEquals(Arrays.asList(new Integer[] { 2, 3, 5, 7, 11, 13, 17, 19 }), primeNumbers);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -52,16 +52,21 @@
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>${maven-shade-plugin.version}</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<main.class>com.baeldung.bootique.App</main.class>
|
<main.class>com.baeldung.bootique.App</main.class>
|
||||||
<bootique-bom.version>0.23</bootique-bom.version>
|
<bootique-bom.version>0.23</bootique-bom.version>
|
||||||
|
|
||||||
|
<maven-shade-plugin.version>2.4.3</maven-shade-plugin.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.baeldung.java10.list;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CopyListServiceUnitTest {
|
||||||
|
|
||||||
|
@Test(expected = UnsupportedOperationException.class)
|
||||||
|
public void whenModifyCopyOfList_thenThrowsException() {
|
||||||
|
List<Integer> copyList = List.copyOf(Arrays.asList(1, 2, 3, 4));
|
||||||
|
}
|
||||||
|
}
|
|
@ -32,7 +32,6 @@
|
||||||
- [“Stream has already been operated upon or closed” Exception in Java](http://www.baeldung.com/java-stream-operated-upon-or-closed-exception)
|
- [“Stream has already been operated upon or closed” Exception in Java](http://www.baeldung.com/java-stream-operated-upon-or-closed-exception)
|
||||||
- [Display All Time Zones With GMT And UTC in Java](http://www.baeldung.com/java-time-zones)
|
- [Display All Time Zones With GMT And UTC in Java](http://www.baeldung.com/java-time-zones)
|
||||||
- [Copy a File with Java](http://www.baeldung.com/java-copy-file)
|
- [Copy a File with Java](http://www.baeldung.com/java-copy-file)
|
||||||
- [Generating Prime Numbers in Java](http://www.baeldung.com/java-generate-prime-numbers)
|
|
||||||
- [Static and Default Methods in Interfaces in Java](http://www.baeldung.com/java-static-default-methods)
|
- [Static and Default Methods in Interfaces in Java](http://www.baeldung.com/java-static-default-methods)
|
||||||
- [Iterable to Stream in Java](http://www.baeldung.com/java-iterable-to-stream)
|
- [Iterable to Stream in Java](http://www.baeldung.com/java-iterable-to-stream)
|
||||||
- [Converting String to Stream of chars](http://www.baeldung.com/java-string-to-stream)
|
- [Converting String to Stream of chars](http://www.baeldung.com/java-string-to-stream)
|
||||||
|
|
|
@ -128,77 +128,6 @@
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</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>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
|
|
@ -0,0 +1,73 @@
|
||||||
|
package com.baeldung.list;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
public class CopyListService {
|
||||||
|
|
||||||
|
public List<Flower> copyListByConstructor(List<Flower> source) {
|
||||||
|
return new ArrayList<Flower>(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Flower> copyListByConstructorAndEditOneFlowerInTheNewList(List<Flower> source) {
|
||||||
|
List<Flower> flowers = new ArrayList<>(source);
|
||||||
|
if(flowers.size() > 0) {
|
||||||
|
flowers.get(0).setPetals(flowers.get(0).getPetals() * 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
return flowers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Flower> copyListByAddAllMethod(List<Flower> source) {
|
||||||
|
List<Flower> flowers = new ArrayList<>();
|
||||||
|
flowers.addAll(source);
|
||||||
|
return flowers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Flower> copyListByAddAllMethodAndEditOneFlowerInTheNewList(List<Flower> source) {
|
||||||
|
List<Flower> flowers = new ArrayList<>();
|
||||||
|
flowers.addAll(source);
|
||||||
|
|
||||||
|
if(flowers.size() > 0) {
|
||||||
|
flowers.get(0).setPetals(flowers.get(0).getPetals() * 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
return flowers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Integer> copyListByCopyMethod(List<Integer> source, List<Integer> dest) {
|
||||||
|
Collections.copy(dest, source);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Flower> copyListByStream(List<Flower> source) {
|
||||||
|
return source.stream().collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Flower> copyListByStreamAndSkipFirstElement(List<Flower> source) {
|
||||||
|
return source.stream().skip(1).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Flower> copyListByStreamWithFilter(List<Flower> source, Integer moreThanPetals) {
|
||||||
|
return source.stream().filter(f -> f.getPetals() > moreThanPetals).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Flower> copyListByStreamWithOptional(List<Flower> source) {
|
||||||
|
return Optional.ofNullable(source)
|
||||||
|
.map(List::stream)
|
||||||
|
.orElseGet(Stream::empty)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Flower> copyListByStreamWithOptionalAndSkip(List<Flower> source) {
|
||||||
|
return Optional.ofNullable(source)
|
||||||
|
.map(List::stream)
|
||||||
|
.orElseGet(Stream::empty)
|
||||||
|
.skip(1)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.baeldung.list;
|
||||||
|
|
||||||
|
public class Flower {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private int petals;
|
||||||
|
|
||||||
|
public Flower(String name, int petals) {
|
||||||
|
this.name = name;
|
||||||
|
this.petals = petals;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPetals() {
|
||||||
|
return petals;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPetals(int petals) {
|
||||||
|
this.petals = petals;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,129 @@
|
||||||
|
package com.baeldung.list;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
public class CopyListServiceUnitTest {
|
||||||
|
|
||||||
|
List<Flower> flowers;
|
||||||
|
|
||||||
|
private CopyListService copyListService;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void init() {
|
||||||
|
this.copyListService = new CopyListService();
|
||||||
|
this.flowers = new ArrayList<>();
|
||||||
|
|
||||||
|
Flower poppy = new Flower("Poppy", 12);
|
||||||
|
flowers.add(poppy);
|
||||||
|
Flower anemone = new Flower("Anemone", 8);
|
||||||
|
flowers.add(anemone);
|
||||||
|
Flower catmint = new Flower("Catmint", 12);
|
||||||
|
flowers.add(catmint);
|
||||||
|
Flower diascia = new Flower("Diascia", 5);
|
||||||
|
flowers.add(diascia);
|
||||||
|
Flower iris = new Flower("Iris", 3);
|
||||||
|
flowers.add(iris);
|
||||||
|
Flower pansy = new Flower("Pansy", 5);
|
||||||
|
flowers.add(pansy);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenAList_whenListDoesNotHaveNullElements_thenReturnAnotherListWithTheSameElementsByConstructor() {
|
||||||
|
List<Flower> copy = copyListService.copyListByConstructor(flowers);
|
||||||
|
assertEquals(copy.size(), flowers.size());
|
||||||
|
assertTrue(copy.containsAll(flowers));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenAList_whenListDoesNotHaveNullElements_thenReturnAnotherListWithOneModifiedElementByConstructor() {
|
||||||
|
List<Flower> copy = copyListService.copyListByConstructorAndEditOneFlowerInTheNewList(flowers);
|
||||||
|
assertEquals(copy.size(), flowers.size());
|
||||||
|
assertTrue(copy.containsAll(flowers));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenAList_whenListDoesNotHaveNullElements_thenReturnAnotherListWithTheSameElementsByAddAllmethod() {
|
||||||
|
List<Flower> copy = copyListService.copyListByAddAllMethod(flowers);
|
||||||
|
assertEquals(copy.size(), flowers.size());
|
||||||
|
assertTrue(copy.containsAll(flowers));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenAList_whenListDoesNotHaveNullElements_thenReturnAnotherListWithOneModifiedElementByAddAllmethod() {
|
||||||
|
List<Flower> copy = copyListService.copyListByAddAllMethodAndEditOneFlowerInTheNewList(flowers);
|
||||||
|
assertEquals(copy.size(), flowers.size());
|
||||||
|
assertTrue(copy.containsAll(flowers));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenAList_whenListsHaveSameSize_thenReturnAnotherListWithTheSameElementsByCopyMethod() {
|
||||||
|
List<Integer> source = Arrays.asList(1,2,3);
|
||||||
|
List<Integer> dest = Arrays.asList(4,5,6);
|
||||||
|
|
||||||
|
dest = copyListService.copyListByCopyMethod(source, dest);
|
||||||
|
assertEquals(dest.size(), source.size());
|
||||||
|
assertTrue(dest.containsAll(source));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenAList_whenListsHaveDifferentSize_thenReturnAnotherListWithTheSameElementsByCopyMethod() {
|
||||||
|
List<Integer> source = Arrays.asList(1,2,3);
|
||||||
|
List<Integer> dest = Arrays.asList(5,6,7,8,9,10);
|
||||||
|
|
||||||
|
dest = copyListService.copyListByCopyMethod(source, dest);
|
||||||
|
assertNotEquals(dest.size(), source.size());
|
||||||
|
assertTrue(dest.containsAll(source));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenAList_whenListDoesNotHaveNullElements_thenReturnAnotherListWithTheSameElementsByStreamProcess() {
|
||||||
|
List<Flower> copy = copyListService.copyListByStream(flowers);
|
||||||
|
assertEquals(copy.size(), flowers.size());
|
||||||
|
assertTrue(copy.containsAll(flowers));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenAList_whenListDoesNotHaveNullElements_thenReturnAnotherListWithOneElementLessByStreamProcess() {
|
||||||
|
List<Flower> copy = copyListService.copyListByStreamAndSkipFirstElement(flowers);
|
||||||
|
assertNotEquals(copy.size(), flowers.size());
|
||||||
|
assertEquals(copy.size() + 1, flowers.size());
|
||||||
|
assertFalse(copy.containsAll(flowers));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenAList_whenListDoesNotHaveNullElements_thenReturnAnotherListWithFilterElementsByStreamProcess() {
|
||||||
|
List<Flower> copy = copyListService.copyListByStreamWithFilter(flowers, 5);
|
||||||
|
assertNotEquals(copy.size(), flowers.size());
|
||||||
|
assertEquals(copy.size() + 3, flowers.size());
|
||||||
|
assertFalse(copy.containsAll(flowers));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenAList_whenListIsNull_thenReturnEmptyListByStreamProcess() {
|
||||||
|
List<Flower> copy = copyListService.copyListByStreamWithOptional(null);
|
||||||
|
assertNotNull(copy);
|
||||||
|
assertEquals(copy.size(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenAList_whenListIsNotNull_thenReturnAnotherListWithTheElementsByStreamProcess() {
|
||||||
|
List<Flower> copy = copyListService.copyListByStreamWithOptional(flowers);
|
||||||
|
assertEquals(copy.size(), flowers.size());
|
||||||
|
assertTrue(copy.containsAll(flowers));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenAList_whenListIsNotNull_thenReturnAnotherListWithOneElementLessByStreamProcess() {
|
||||||
|
List<Flower> copy = copyListService.copyListByStreamWithOptionalAndSkip(flowers);
|
||||||
|
assertNotEquals(copy.size(), flowers.size());
|
||||||
|
assertEquals(copy.size() + 1, flowers.size());
|
||||||
|
assertFalse(copy.containsAll(flowers));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,81 @@
|
||||||
|
package com.baeldung.java.set;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
public class HashSetInitalizingUnitTest {
|
||||||
|
@Test
|
||||||
|
public void whenUsingJava_usingArraysStaticMethod_thenCorrectSize() {
|
||||||
|
Set<String> set = new HashSet<>(Arrays.asList("a", "b", "c"));
|
||||||
|
assertEquals(3, set.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenUsingJava_usingAnonymousClass_thenCorrectSize() {
|
||||||
|
Set<String> set = new HashSet<String>(){{
|
||||||
|
add("a");
|
||||||
|
add("b");
|
||||||
|
add("c");
|
||||||
|
}};
|
||||||
|
assertEquals(3, set.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenUsingJava_creatingSingletonSet_thenCorrectSize() {
|
||||||
|
Set<String> set = Collections.singleton("a");
|
||||||
|
assertEquals(1, set.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final <T> Set<T> newHashSet(T... objs) {
|
||||||
|
Set<T> set = new HashSet<T>();
|
||||||
|
Collections.addAll(set, objs);
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenUsingJava_usingCustomStaticUtilMethod_thenCorrectSize() {
|
||||||
|
Set<String> set = newHashSet("a","b","c");
|
||||||
|
assertEquals(3, set.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenUsingJava8_usingCollectOnStream_thenCorrectSize() {
|
||||||
|
Set<String> set = Stream.of("a", "b", "c").collect(Collectors.toSet());
|
||||||
|
assertEquals(3, set.size());
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void whenUsingJava8_fromStringArray_thenCorrectSize() {
|
||||||
|
String[] stringArray = {"a","b","c"};
|
||||||
|
Set<String> set = Arrays.stream(stringArray).collect(Collectors.toCollection(HashSet::new));
|
||||||
|
assertEquals(3, set.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Requires Java9 - uncomment if you are using Java 9 or higher
|
||||||
|
/*@Test
|
||||||
|
public void whenUsingJava9_usingCollectOnStream_thenCorrectSize() {
|
||||||
|
Set set = Set.of("a", "b", "c");
|
||||||
|
assertEquals(3, set.size());
|
||||||
|
}*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenUsingGoogleGuava_createMutableSet_thenCorrectSize() {
|
||||||
|
Set<String> set = Sets.newHashSet("a", "b", "c");
|
||||||
|
assertEquals(3, set.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenUsingGoogleGuava_createImmutableSet_thenCorrectSize() {
|
||||||
|
Set<String> set = ImmutableSet.of("a", "b", "c");
|
||||||
|
assertEquals(3, set.size());
|
||||||
|
}
|
||||||
|
}
|
|
@ -75,92 +75,7 @@
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</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>
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
|
|
@ -185,6 +185,7 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<version>${maven-jar-plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<archive>
|
<archive>
|
||||||
<manifest>
|
<manifest>
|
||||||
|
@ -195,79 +196,6 @@
|
||||||
</archive>
|
</archive>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</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>
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
<artifactId>exec-maven-plugin</artifactId>
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
|
@ -368,6 +296,7 @@
|
||||||
<protonpack.version>1.13</protonpack.version>
|
<protonpack.version>1.13</protonpack.version>
|
||||||
<streamex.version>0.6.5</streamex.version>
|
<streamex.version>0.6.5</streamex.version>
|
||||||
<vavr.version>0.9.0</vavr.version>
|
<vavr.version>0.9.0</vavr.version>
|
||||||
|
<spring-web.version>4.3.4.RELEASE</spring-web.version>
|
||||||
|
|
||||||
<!-- testing -->
|
<!-- testing -->
|
||||||
<assertj.version>3.6.1</assertj.version>
|
<assertj.version>3.6.1</assertj.version>
|
||||||
|
@ -376,7 +305,7 @@
|
||||||
<!-- maven plugins -->
|
<!-- maven plugins -->
|
||||||
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
|
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
|
||||||
<sun-tools.version>1.8.0</sun-tools.version>
|
<sun-tools.version>1.8.0</sun-tools.version>
|
||||||
<spring-web.version>4.3.4.RELEASE</spring-web.version>
|
<maven-jar-plugin.version>3.0.2</maven-jar-plugin.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -3,7 +3,6 @@
|
||||||
## Core Java Cookbooks and Examples
|
## Core Java Cookbooks and Examples
|
||||||
|
|
||||||
### Relevant Articles:
|
### Relevant Articles:
|
||||||
- [Java – Random Long, Float, Integer and Double](http://www.baeldung.com/java-generate-random-long-float-integer-double)
|
|
||||||
- [Java – Generate Random String](http://www.baeldung.com/java-random-string)
|
- [Java – Generate Random String](http://www.baeldung.com/java-random-string)
|
||||||
- [Java Timer](http://www.baeldung.com/java-timer-and-timertask)
|
- [Java Timer](http://www.baeldung.com/java-timer-and-timertask)
|
||||||
- [How to Run a Shell Command in Java](http://www.baeldung.com/run-shell-command-in-java)
|
- [How to Run a Shell Command in Java](http://www.baeldung.com/run-shell-command-in-java)
|
||||||
|
@ -38,7 +37,6 @@
|
||||||
- [A Quick JUnit vs TestNG Comparison](http://www.baeldung.com/junit-vs-testng)
|
- [A Quick JUnit vs TestNG Comparison](http://www.baeldung.com/junit-vs-testng)
|
||||||
- [Java Primitive Conversions](http://www.baeldung.com/java-primitive-conversions)
|
- [Java Primitive Conversions](http://www.baeldung.com/java-primitive-conversions)
|
||||||
- [Java Money and the Currency API](http://www.baeldung.com/java-money-and-currency)
|
- [Java Money and the Currency API](http://www.baeldung.com/java-money-and-currency)
|
||||||
- [Using Math.pow in Java](http://www.baeldung.com/java-math-pow)
|
|
||||||
- [Converting Strings to Enums in Java](http://www.baeldung.com/java-string-to-enum)
|
- [Converting Strings to Enums in Java](http://www.baeldung.com/java-string-to-enum)
|
||||||
- [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)
|
||||||
|
@ -49,7 +47,6 @@
|
||||||
- [How to Add a Single Element to a Stream](http://www.baeldung.com/java-stream-append-prepend)
|
- [How to Add a Single Element to a Stream](http://www.baeldung.com/java-stream-append-prepend)
|
||||||
- [Iterating Over Enum Values in Java](http://www.baeldung.com/java-enum-iteration)
|
- [Iterating Over Enum Values in Java](http://www.baeldung.com/java-enum-iteration)
|
||||||
- [Kotlin Java Interoperability](http://www.baeldung.com/kotlin-java-interoperability)
|
- [Kotlin Java Interoperability](http://www.baeldung.com/kotlin-java-interoperability)
|
||||||
- [How to Round a Number to N Decimal Places in Java](http://www.baeldung.com/java-round-decimal-number)
|
|
||||||
- [Changing Annotation Parameters At Runtime](http://www.baeldung.com/java-reflection-change-annotation-params)
|
- [Changing Annotation Parameters At Runtime](http://www.baeldung.com/java-reflection-change-annotation-params)
|
||||||
- [How to Find all Getters Returning Null](http://www.baeldung.com/java-getters-returning-null)
|
- [How to Find all Getters Returning Null](http://www.baeldung.com/java-getters-returning-null)
|
||||||
- [Changing the Order in a Sum Operation Can Produce Different Results?](http://www.baeldung.com/java-floating-point-sum-order)
|
- [Changing the Order in a Sum Operation Can Produce Different Results?](http://www.baeldung.com/java-floating-point-sum-order)
|
||||||
|
@ -77,7 +74,6 @@
|
||||||
- [“Sneaky Throws” in Java](http://www.baeldung.com/java-sneaky-throws)
|
- [“Sneaky Throws” in Java](http://www.baeldung.com/java-sneaky-throws)
|
||||||
- [OutOfMemoryError: GC Overhead Limit Exceeded](http://www.baeldung.com/java-gc-overhead-limit-exceeded)
|
- [OutOfMemoryError: GC Overhead Limit Exceeded](http://www.baeldung.com/java-gc-overhead-limit-exceeded)
|
||||||
- [StringBuilder and StringBuffer in Java](http://www.baeldung.com/java-string-builder-string-buffer)
|
- [StringBuilder and StringBuffer in Java](http://www.baeldung.com/java-string-builder-string-buffer)
|
||||||
- [Number of Digits in an Integer in Java](http://www.baeldung.com/java-number-of-digits-in-int)
|
|
||||||
- [Creating a Java Compiler Plugin](http://www.baeldung.com/java-build-compiler-plugin)
|
- [Creating a Java Compiler Plugin](http://www.baeldung.com/java-build-compiler-plugin)
|
||||||
- [A Guide to the Static Keyword in Java](http://www.baeldung.com/java-static)
|
- [A Guide to the Static Keyword in Java](http://www.baeldung.com/java-static)
|
||||||
- [Initializing Arrays in Java](http://www.baeldung.com/java-initialize-array)
|
- [Initializing Arrays in Java](http://www.baeldung.com/java-initialize-array)
|
||||||
|
@ -132,7 +128,6 @@
|
||||||
- [Find Sum and Average in a Java Array](http://www.baeldung.com/java-array-sum-average)
|
- [Find Sum and Average in a Java Array](http://www.baeldung.com/java-array-sum-average)
|
||||||
- [Java List UnsupportedOperationException](http://www.baeldung.com/java-list-unsupported-operation-exception)
|
- [Java List UnsupportedOperationException](http://www.baeldung.com/java-list-unsupported-operation-exception)
|
||||||
- [Type Erasure in Java Explained](http://www.baeldung.com/java-type-erasure)
|
- [Type Erasure in Java Explained](http://www.baeldung.com/java-type-erasure)
|
||||||
- [BigDecimal and BigInteger in Java](http://www.baeldung.com/java-bigdecimal-biginteger)
|
|
||||||
- [Display All Time Zones With GMT And UTC in Java](http://www.baeldung.com/java-time-zones)
|
- [Display All Time Zones With GMT And UTC in Java](http://www.baeldung.com/java-time-zones)
|
||||||
- [Join and Split Arrays and Collections in Java](http://www.baeldung.com/java-join-and-split)
|
- [Join and Split Arrays and Collections in Java](http://www.baeldung.com/java-join-and-split)
|
||||||
- [Check If Two Lists are Equal in Java](http://www.baeldung.com/java-test-a-list-for-ordinality-and-equality)
|
- [Check If Two Lists are Equal in Java](http://www.baeldung.com/java-test-a-list-for-ordinality-and-equality)
|
||||||
|
@ -147,7 +142,6 @@
|
||||||
- [Check If a String Is Numeric in Java](http://www.baeldung.com/java-check-string-number)
|
- [Check If a String Is Numeric in Java](http://www.baeldung.com/java-check-string-number)
|
||||||
- [Variable and Method Hiding in Java](http://www.baeldung.com/java-variable-method-hiding)
|
- [Variable and Method Hiding in Java](http://www.baeldung.com/java-variable-method-hiding)
|
||||||
- [Access Modifiers in Java](http://www.baeldung.com/java-access-modifiers)
|
- [Access Modifiers in Java](http://www.baeldung.com/java-access-modifiers)
|
||||||
- [NaN in Java](http://www.baeldung.com/java-not-a-number)
|
|
||||||
- [Infinite Loops in Java](http://www.baeldung.com/infinite-loops-java)
|
- [Infinite Loops in Java](http://www.baeldung.com/infinite-loops-java)
|
||||||
- [Why Use char[] Array Over a String for Storing Passwords in Java?](http://www.baeldung.com/java-storing-passwords)
|
- [Why Use char[] Array Over a String for Storing Passwords in Java?](http://www.baeldung.com/java-storing-passwords)
|
||||||
- [Introduction to Creational Design Patterns](http://www.baeldung.com/creational-design-patterns)
|
- [Introduction to Creational Design Patterns](http://www.baeldung.com/creational-design-patterns)
|
||||||
|
|
|
@ -25,16 +25,6 @@
|
||||||
<artifactId>commons-lang3</artifactId>
|
<artifactId>commons-lang3</artifactId>
|
||||||
<version>${commons-lang3.version}</version>
|
<version>${commons-lang3.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.commons</groupId>
|
|
||||||
<artifactId>commons-math3</artifactId>
|
|
||||||
<version>${commons-math3.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.decimal4j</groupId>
|
|
||||||
<artifactId>decimal4j</artifactId>
|
|
||||||
<version>${decimal4j.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bouncycastle</groupId>
|
<groupId>org.bouncycastle</groupId>
|
||||||
<artifactId>bcprov-jdk15on</artifactId>
|
<artifactId>bcprov-jdk15on</artifactId>
|
||||||
|
@ -393,6 +383,7 @@
|
||||||
<commons-lang3.version>3.5</commons-lang3.version>
|
<commons-lang3.version>3.5</commons-lang3.version>
|
||||||
<bouncycastle.version>1.55</bouncycastle.version>
|
<bouncycastle.version>1.55</bouncycastle.version>
|
||||||
<commons-codec.version>1.10</commons-codec.version>
|
<commons-codec.version>1.10</commons-codec.version>
|
||||||
|
<commons-io.version>2.5</commons-io.version>
|
||||||
<commons-math3.version>3.6.1</commons-math3.version>
|
<commons-math3.version>3.6.1</commons-math3.version>
|
||||||
<decimal4j.version>1.0.3</decimal4j.version>
|
<decimal4j.version>1.0.3</decimal4j.version>
|
||||||
<unix4j.version>0.4</unix4j.version>
|
<unix4j.version>0.4</unix4j.version>
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
package com.baeldung.maths;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.math.RoundingMode;
|
|
||||||
|
|
||||||
public class BigDecimalImpl {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
|
|
||||||
BigDecimal serviceTax = new BigDecimal("56.0084578639");
|
|
||||||
serviceTax = serviceTax.setScale(2, RoundingMode.CEILING);
|
|
||||||
|
|
||||||
BigDecimal entertainmentTax = new BigDecimal("23.00689");
|
|
||||||
entertainmentTax = entertainmentTax.setScale(2, RoundingMode.FLOOR);
|
|
||||||
|
|
||||||
BigDecimal totalTax = serviceTax.add(entertainmentTax);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
package com.baeldung.maths;
|
|
||||||
|
|
||||||
import java.math.BigInteger;
|
|
||||||
|
|
||||||
public class BigIntegerImpl {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
|
|
||||||
BigInteger numStarsMilkyWay = new BigInteger("8731409320171337804361260816606476");
|
|
||||||
BigInteger numStarsAndromeda = new BigInteger("5379309320171337804361260816606476");
|
|
||||||
|
|
||||||
BigInteger totalStars = numStarsMilkyWay.add(numStarsAndromeda);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -55,6 +55,7 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<version>${maven-jar-plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<archive>
|
<archive>
|
||||||
<manifest>
|
<manifest>
|
||||||
|
@ -91,6 +92,7 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>${maven-shade-plugin.version}</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
|
@ -133,6 +135,9 @@
|
||||||
<!-- testing -->
|
<!-- testing -->
|
||||||
<testng.version>6.10</testng.version>
|
<testng.version>6.10</testng.version>
|
||||||
<assertj.version>3.6.1</assertj.version>
|
<assertj.version>3.6.1</assertj.version>
|
||||||
|
|
||||||
|
<maven-shade-plugin.version>2.4.3</maven-shade-plugin.version>
|
||||||
|
<maven-jar-plugin.version>3.0.2</maven-jar-plugin.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -74,7 +74,7 @@
|
||||||
<port>9990</port>
|
<port>9990</port>
|
||||||
<username>testUser</username>
|
<username>testUser</username>
|
||||||
<password>admin1234!</password>
|
<password>admin1234!</password>
|
||||||
<filename>${build.finalName}.jar</filename>
|
<filename>${project.build.finalName}.jar</filename>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
|
|
@ -1,27 +1,14 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<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">
|
||||||
|
|
||||||
<!-- POM file generated with GWT webAppCreator -->
|
<!-- POM file generated with GWT webAppCreator -->
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>google_web_toolkit</artifactId>
|
<artifactId>google-web-toolkit</artifactId>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<name>com.baeldung.Google_web_toolkit</name>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
|
|
||||||
<!-- Setting maven.compiler.source to something different to 1.8
|
|
||||||
needs that you configure the sourceLevel in gwt-maven-plugin since
|
|
||||||
GWT compiler 2.8 requires 1.8 (see gwt-maven-plugin block below) -->
|
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
|
||||||
|
|
||||||
<!-- Don't let your Mac use a crazy non-standard encoding -->
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -61,7 +48,8 @@
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<!-- Output classes directly into the webapp, so that IDEs and "mvn process-classes" update them in DevMode -->
|
<!-- Output classes directly into the webapp, so that IDEs and "mvn process-classes"
|
||||||
|
update them in DevMode -->
|
||||||
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
|
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
|
||||||
|
|
||||||
<plugins>
|
<plugins>
|
||||||
|
@ -83,8 +71,8 @@
|
||||||
<moduleName>com.baeldung.Google_web_toolkit</moduleName>
|
<moduleName>com.baeldung.Google_web_toolkit</moduleName>
|
||||||
<moduleShortName>Google_web_toolkit</moduleShortName>
|
<moduleShortName>Google_web_toolkit</moduleShortName>
|
||||||
<failOnError>true</failOnError>
|
<failOnError>true</failOnError>
|
||||||
<!-- GWT compiler 2.8 requires 1.8, hence define sourceLevel here if you use
|
<!-- GWT compiler 2.8 requires 1.8, hence define sourceLevel here if
|
||||||
a different source language for java compilation -->
|
you use a different source language for java compilation -->
|
||||||
<sourceLevel>1.8</sourceLevel>
|
<sourceLevel>1.8</sourceLevel>
|
||||||
<!-- Compiler configuration -->
|
<!-- Compiler configuration -->
|
||||||
<compilerArgs>
|
<compilerArgs>
|
||||||
|
@ -113,4 +101,18 @@
|
||||||
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
|
||||||
|
<!-- Setting maven.compiler.source to something different to 1.8 needs
|
||||||
|
that you configure the sourceLevel in gwt-maven-plugin since GWT compiler
|
||||||
|
2.8 requires 1.8 (see gwt-maven-plugin block below) -->
|
||||||
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
|
|
||||||
|
<!-- Don't let your Mac use a crazy non-standard encoding -->
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -3,32 +3,27 @@
|
||||||
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>
|
||||||
|
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>java-ee-8-security-api</artifactId>
|
<artifactId>java-ee-8-security-api</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<modules>
|
|
||||||
<module>app-auth-basic-store-db</module>
|
|
||||||
<module>app-auth-form-store-ldap</module>
|
|
||||||
<module>app-auth-custom-form-store-custom</module>
|
|
||||||
<module>app-auth-custom-no-store</module>
|
|
||||||
</modules>
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax</groupId>
|
<groupId>javax</groupId>
|
||||||
<artifactId>javaee-web-api</artifactId>
|
<artifactId>javaee-web-api</artifactId>
|
||||||
<version>${javaee-version}</version>
|
<version>${javaee-version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-war-plugin</artifactId>
|
<artifactId>maven-war-plugin</artifactId>
|
||||||
|
<version>${maven-war-plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||||
<packagingExcludes>pom.xml</packagingExcludes>
|
<packagingExcludes>pom.xml</packagingExcludes>
|
||||||
|
@ -69,6 +64,15 @@
|
||||||
<liberty-maven-plugin.version>2.3</liberty-maven-plugin.version>
|
<liberty-maven-plugin.version>2.3</liberty-maven-plugin.version>
|
||||||
<openliberty-runtime.version>18.0.0.1</openliberty-runtime.version>
|
<openliberty-runtime.version>18.0.0.1</openliberty-runtime.version>
|
||||||
<h2-version>1.4.197</h2-version>
|
<h2-version>1.4.197</h2-version>
|
||||||
|
|
||||||
|
<maven-war-plugin.version>3.2.2</maven-war-plugin.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
<modules>
|
||||||
|
<module>app-auth-basic-store-db</module>
|
||||||
|
<module>app-auth-form-store-ldap</module>
|
||||||
|
<module>app-auth-custom-form-store-custom</module>
|
||||||
|
<module>app-auth-custom-no-store</module>
|
||||||
|
</modules>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
*.class
|
||||||
|
|
||||||
|
0.*
|
||||||
|
|
||||||
|
#folders#
|
||||||
|
/target
|
||||||
|
/neoDb*
|
||||||
|
/data
|
||||||
|
/src/main/webapp/WEB-INF/classes
|
||||||
|
*/META-INF/*
|
||||||
|
.resourceCache
|
||||||
|
|
||||||
|
# Packaged files #
|
||||||
|
*.jar
|
||||||
|
*.war
|
||||||
|
*.ear
|
||||||
|
|
||||||
|
# Files generated by integration tests
|
||||||
|
*.txt
|
||||||
|
backup-pom.xml
|
||||||
|
/bin/
|
||||||
|
/temp
|
||||||
|
|
||||||
|
#IntelliJ specific
|
||||||
|
.idea/
|
||||||
|
*.iml
|
|
@ -0,0 +1,14 @@
|
||||||
|
=========
|
||||||
|
|
||||||
|
## Java Number Cookbooks and Examples
|
||||||
|
|
||||||
|
### Relevant Articles:
|
||||||
|
- [Number of Digits in an Integer in Java](http://www.baeldung.com/java-number-of-digits-in-int)
|
||||||
|
- [NaN in Java](http://www.baeldung.com/java-not-a-number)
|
||||||
|
- [How to Round a Number to N Decimal Places in Java](http://www.baeldung.com/java-round-decimal-number)
|
||||||
|
- [Check If a Number Is Prime in Java](http://www.baeldung.com/java-prime-numbers)
|
||||||
|
- [Using Math.pow in Java](http://www.baeldung.com/java-math-pow)
|
||||||
|
- [Generating Prime Numbers in Java](http://www.baeldung.com/java-generate-prime-numbers)
|
||||||
|
- [BigDecimal and BigInteger in Java](http://www.baeldung.com/java-bigdecimal-biginteger)
|
||||||
|
- [Find All Pairs of Numbers in an Array That Add Up to a Given Sum](http://www.baeldung.com/java-algorithm-number-pairs-sum)
|
||||||
|
- [Java – Random Long, Float, Integer and Double](http://www.baeldung.com/java-generate-random-long-float-integer-double)
|
|
@ -0,0 +1,163 @@
|
||||||
|
<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">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>java-numbers</artifactId>
|
||||||
|
<version>0.1.0-SNAPSHOT</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<name>java-numbers</name>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>com.baeldung</groupId>
|
||||||
|
<artifactId>parent-java</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<relativePath>../parent-java</relativePath>
|
||||||
|
</parent>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>log4j</groupId>
|
||||||
|
<artifactId>log4j</artifactId>
|
||||||
|
<version>${log4j.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<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>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
|
<artifactId>jmh-core</artifactId>
|
||||||
|
<version>${jmh-core.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openjdk.jmh</groupId>
|
||||||
|
<artifactId>jmh-generator-annprocess</artifactId>
|
||||||
|
<version>${jmh-generator-annprocess.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-math3</artifactId>
|
||||||
|
<version>${commons-math3.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
<version>${commons-lang3.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.decimal4j</groupId>
|
||||||
|
<artifactId>decimal4j</artifactId>
|
||||||
|
<version>${decimal4j.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.assertj</groupId>
|
||||||
|
<artifactId>assertj-core</artifactId>
|
||||||
|
<version>${assertj.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<finalName>java-numbers</finalName>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<excludes>
|
||||||
|
<exclude>**/*IntegrationTest.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-javadoc-plugin</artifactId>
|
||||||
|
<version>${maven-javadoc-plugin.version}</version>
|
||||||
|
<configuration>
|
||||||
|
<source>1.8</source>
|
||||||
|
<target>1.8</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<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>
|
||||||
|
<includes>
|
||||||
|
<include>**/*IntegrationTest.java</include>
|
||||||
|
</includes>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<systemPropertyVariables>
|
||||||
|
<test.mime>json</test.mime>
|
||||||
|
</systemPropertyVariables>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<commons-math3.version>3.6.1</commons-math3.version>
|
||||||
|
<decimal4j.version>1.0.3</decimal4j.version>
|
||||||
|
<commons-lang3.version>3.5</commons-lang3.version>
|
||||||
|
|
||||||
|
<assertj.version>3.6.1</assertj.version>
|
||||||
|
|
||||||
|
<org.slf4j.version>1.7.21</org.slf4j.version>
|
||||||
|
<logback.version>1.1.7</logback.version>
|
||||||
|
<jmh-core.version>1.19</jmh-core.version>
|
||||||
|
<jmh-generator-annprocess.version>1.19</jmh-generator-annprocess.version>
|
||||||
|
|
||||||
|
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
|
||||||
|
<maven-javadoc-plugin.version>3.0.0-M1</maven-javadoc-plugin.version>
|
||||||
|
<maven-jar-plugin.version>3.0.2</maven-jar-plugin.version>
|
||||||
|
</properties>
|
||||||
|
</project>
|
|
@ -1,7 +1,6 @@
|
||||||
package com.baeldung.algorithms.primechecker;
|
package com.baeldung.algorithms.primechecker;
|
||||||
|
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
import java.util.stream.LongStream;
|
|
||||||
|
|
||||||
public class BruteForcePrimeChecker implements PrimeChecker<Integer> {
|
public class BruteForcePrimeChecker implements PrimeChecker<Integer> {
|
||||||
|
|
||||||
|
@ -12,5 +11,4 @@ public class BruteForcePrimeChecker implements PrimeChecker<Integer>{
|
||||||
.noneMatch(n -> (number % n == 0)) : false;
|
.noneMatch(n -> (number % n == 0)) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
package com.baeldung.algorithms.primechecker;
|
package com.baeldung.algorithms.primechecker;
|
||||||
|
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
import java.util.stream.LongStream;
|
|
||||||
|
|
||||||
public class OptimisedPrimeChecker implements PrimeChecker<Integer> {
|
public class OptimisedPrimeChecker implements PrimeChecker<Integer> {
|
||||||
|
|
||||||
|
@ -11,5 +10,4 @@ public class OptimisedPrimeChecker implements PrimeChecker<Integer>{
|
||||||
.noneMatch(n -> (number % n == 0)) : false;
|
.noneMatch(n -> (number % n == 0)) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package com.baeldung.algorithms.pairsaddupnumber;
|
package com.baeldung.pairsaddupnumber;
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -23,7 +23,7 @@ public class DifferentPairs {
|
||||||
public static List<Integer> findPairsWithForLoop(int[] input, int sum) {
|
public static List<Integer> findPairsWithForLoop(int[] input, int sum) {
|
||||||
final List<Integer> allDifferentPairs = new ArrayList<>();
|
final List<Integer> allDifferentPairs = new ArrayList<>();
|
||||||
// Aux. hash map
|
// Aux. hash map
|
||||||
final Map<Integer, Integer> pairs = new HashMap();
|
final Map<Integer, Integer> pairs = new HashMap<>();
|
||||||
for (int i : input) {
|
for (int i : input) {
|
||||||
if (pairs.containsKey(i)) {
|
if (pairs.containsKey(i)) {
|
||||||
if (pairs.get(i) != null) {
|
if (pairs.get(i) != null) {
|
||||||
|
@ -51,7 +51,7 @@ public class DifferentPairs {
|
||||||
public static List<Integer> findPairsWithStreamApi(int[] input, int sum) {
|
public static List<Integer> findPairsWithStreamApi(int[] input, int sum) {
|
||||||
final List<Integer> allDifferentPairs = new ArrayList<>();
|
final List<Integer> allDifferentPairs = new ArrayList<>();
|
||||||
// Aux. hash map
|
// Aux. hash map
|
||||||
final Map<Integer, Integer> pairs = new HashMap();
|
final Map<Integer, Integer> pairs = new HashMap<>();
|
||||||
IntStream.range(0, input.length).forEach(i -> {
|
IntStream.range(0, input.length).forEach(i -> {
|
||||||
if (pairs.containsKey(input[i])) {
|
if (pairs.containsKey(input[i])) {
|
||||||
if (pairs.get(input[i]) != null) {
|
if (pairs.get(input[i]) != null) {
|
|
@ -1,4 +1,4 @@
|
||||||
package com.baeldung.algorithms.pairsaddupnumber;
|
package com.baeldung.pairsaddupnumber;
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.baeldung.algorithms.pairsaddupnumber;
|
package com.baeldung.pairsaddupnumber;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
|
@ -0,0 +1,6 @@
|
||||||
|
log4j.rootLogger=DEBUG, A1
|
||||||
|
|
||||||
|
log4j.appender.A1=org.apache.log4j.ConsoleAppender
|
||||||
|
|
||||||
|
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
|
||||||
|
log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configuration>
|
||||||
|
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder>
|
||||||
|
<pattern>web - %date [%thread] %-5level %logger{36} - %message%n
|
||||||
|
</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<root level="INFO">
|
||||||
|
<appender-ref ref="STDOUT" />
|
||||||
|
</root>
|
||||||
|
</configuration>
|
|
@ -37,7 +37,6 @@ public class PrimeCheckerUnitTest {
|
||||||
assertFalse(bfPrimeChecker.isPrime(1001));
|
assertFalse(bfPrimeChecker.isPrime(1001));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private final OptimisedPrimeChecker optimisedPrimeChecker = new OptimisedPrimeChecker();
|
private final OptimisedPrimeChecker optimisedPrimeChecker = new OptimisedPrimeChecker();
|
||||||
|
|
||||||
@Test
|
@Test
|
|
@ -5,9 +5,6 @@ import org.decimal4j.util.DoubleRounder;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertNotEquals;
|
|
||||||
|
|
||||||
public class RoundUnitTest {
|
public class RoundUnitTest {
|
||||||
private double value = 2.03456d;
|
private double value = 2.03456d;
|
||||||
private int places = 2;
|
private int places = 2;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.baeldung.algorithms.pairsaddupnumber;
|
package com.baeldung.pairsaddupnumber;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.baeldung.algorithms.pairsaddupnumber;
|
package com.baeldung.pairsaddupnumber;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import java.util.List;
|
import java.util.List;
|
|
@ -1,10 +1,10 @@
|
||||||
package com.baeldung.prime;
|
package com.baeldung.prime;
|
||||||
|
|
||||||
import static com.baeldung.prime.PrimeGenerator.*;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static com.baeldung.prime.PrimeGenerator.*;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
public class PrimeGeneratorUnitTest {
|
public class PrimeGeneratorUnitTest {
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.java;
|
package com.baeldung.random;
|
||||||
|
|
||||||
import org.apache.commons.lang3.RandomStringUtils;
|
import org.apache.commons.lang3.RandomStringUtils;
|
||||||
import org.apache.commons.math3.random.RandomDataGenerator;
|
import org.apache.commons.math3.random.RandomDataGenerator;
|
|
@ -6,7 +6,7 @@
|
||||||
<artifactId>jhipster-monolithic</artifactId>
|
<artifactId>jhipster-monolithic</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
<name>JHipster Monolithic Application</name>
|
<description>JHipster Monolithic Application</description>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>parent-boot-1</artifactId>
|
<artifactId>parent-boot-1</artifactId>
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<version>${maven-jar-plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<archive>
|
<archive>
|
||||||
<manifest>
|
<manifest>
|
||||||
|
@ -46,6 +47,7 @@
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<openjdk.jmh.version>1.19</openjdk.jmh.version>
|
<openjdk.jmh.version>1.19</openjdk.jmh.version>
|
||||||
|
<maven-jar-plugin.version>3.0.2</maven-jar-plugin.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -44,6 +44,7 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>${maven-shade-plugin.version}</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
@ -52,6 +53,8 @@
|
||||||
<jooby.version>1.1.3</jooby.version>
|
<jooby.version>1.1.3</jooby.version>
|
||||||
<application.class>com.baeldung.jooby.App</application.class>
|
<application.class>com.baeldung.jooby.App</application.class>
|
||||||
<jooby-jedis.version>1.1.3</jooby-jedis.version>
|
<jooby-jedis.version>1.1.3</jooby-jedis.version>
|
||||||
|
|
||||||
|
<maven-shade-plugin.version>2.4.3</maven-shade-plugin.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -106,5 +106,4 @@ public class MavenWrapperDownloader {
|
||||||
fos.close();
|
fos.close();
|
||||||
rbc.close();
|
rbc.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,10 +1,10 @@
|
||||||
<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.msf4j</groupId>
|
<groupId>com.baeldung.msf4j</groupId>
|
||||||
<artifactId>msf4j</artifactId>
|
<artifactId>msf4j</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<name>WSO2 MSF4J Microservice</name>
|
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.wso2.msf4j</groupId>
|
<groupId>org.wso2.msf4j</groupId>
|
||||||
|
|
|
@ -5,8 +5,7 @@
|
||||||
<artifactId>parent-boot-2</artifactId>
|
<artifactId>parent-boot-2</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>Parent Boot 2</name>
|
<description>Parent for all Spring Boot 2 modules</description>
|
||||||
<description>Parent for all spring boot 2 modules</description>
|
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
|
|
@ -3,13 +3,15 @@ package com.baeldung.hibernate.manytomany.model;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.JoinTable;
|
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
|
import javax.persistence.JoinTable;
|
||||||
import javax.persistence.ManyToMany;
|
import javax.persistence.ManyToMany;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
@ -18,7 +20,7 @@ import javax.persistence.Table;
|
||||||
public class Employee implements Serializable {
|
public class Employee implements Serializable {
|
||||||
@Id
|
@Id
|
||||||
@Column(name = "employee_id")
|
@Column(name = "employee_id")
|
||||||
@GeneratedValue
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Long employeeId;
|
private Long employeeId;
|
||||||
|
|
||||||
@Column(name = "first_name")
|
@Column(name = "first_name")
|
||||||
|
|
|
@ -50,6 +50,8 @@ public class HibernateSearchConfig {
|
||||||
final BasicDataSource dataSource = new BasicDataSource();
|
final BasicDataSource dataSource = new BasicDataSource();
|
||||||
dataSource.setDriverClassName(Preconditions.checkNotNull(env.getProperty("jdbc.driverClassName")));
|
dataSource.setDriverClassName(Preconditions.checkNotNull(env.getProperty("jdbc.driverClassName")));
|
||||||
dataSource.setUrl(Preconditions.checkNotNull(env.getProperty("jdbc.url")));
|
dataSource.setUrl(Preconditions.checkNotNull(env.getProperty("jdbc.url")));
|
||||||
|
dataSource.setUsername(env.getProperty("jdbc.user"));
|
||||||
|
dataSource.setPassword(env.getProperty("jdbc.pass"));
|
||||||
|
|
||||||
return dataSource;
|
return dataSource;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableTransactionManagement
|
@EnableTransactionManagement
|
||||||
@PropertySource({ "classpath:persistence-mysql.properties" })
|
@PropertySource({ "classpath:persistence-h2.properties" })
|
||||||
@ComponentScan({ "com.baeldung.hibernate.manytomany" })
|
@ComponentScan({ "com.baeldung.hibernate.manytomany" })
|
||||||
public class PersistenceConfig {
|
public class PersistenceConfig {
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ public class PersistenceConfig {
|
||||||
|
|
||||||
private final Properties hibernateProperties() {
|
private final Properties hibernateProperties() {
|
||||||
final Properties hibernateProperties = new Properties();
|
final Properties hibernateProperties = new Properties();
|
||||||
//hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto"));
|
hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto"));
|
||||||
hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect"));
|
hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect"));
|
||||||
hibernateProperties.setProperty("hibernate.show_sql", "true");
|
hibernateProperties.setProperty("hibernate.show_sql", "true");
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ import java.util.Properties;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableTransactionManagement
|
@EnableTransactionManagement
|
||||||
@PropertySource({ "classpath:persistence-mysql.properties" })
|
@PropertySource({ "classpath:persistence-h2.properties" })
|
||||||
@ComponentScan({ "com.baeldung.persistence" })
|
@ComponentScan({ "com.baeldung.persistence" })
|
||||||
public class PersistenceConfig {
|
public class PersistenceConfig {
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ jdbc.driverClassName=org.h2.Driver
|
||||||
jdbc.url=jdbc:h2:mem:db;DB_CLOSE_DELAY=-1
|
jdbc.url=jdbc:h2:mem:db;DB_CLOSE_DELAY=-1
|
||||||
jdbc.eventGeneratedId=sa
|
jdbc.eventGeneratedId=sa
|
||||||
jdbc.user=sa
|
jdbc.user=sa
|
||||||
jdbc.pass=sa
|
jdbc.pass=
|
||||||
|
|
||||||
# hibernate.X
|
# hibernate.X
|
||||||
hibernate.dialect=org.hibernate.dialect.H2Dialect
|
hibernate.dialect=org.hibernate.dialect.H2Dialect
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE hibernate-configuration PUBLIC
|
||||||
|
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
|
||||||
|
"http://hibernate.org/dtd/hibernate-configuration-3.0.dtd">
|
||||||
|
<hibernate-configuration>
|
||||||
|
<session-factory>
|
||||||
|
<property name="hibernate.connection.driver_class">org.h2.Driver</property>
|
||||||
|
<property name="hibernate.connection.password"></property>
|
||||||
|
<property name="hibernate.connection.url">jdbc:h2:mem:spring_hibernate_many_to_many</property>
|
||||||
|
<property name="hibernate.connection.username">sa</property>
|
||||||
|
<property name="hibernate.dialect">org.hibernate.dialect.H2Dialect</property>
|
||||||
|
<property name="hibernate.current_session_context_class">thread</property>
|
||||||
|
<property name="hibernate.show_sql">true</property>
|
||||||
|
<property name="hibernate.hbm2ddl.auto">create-drop</property>
|
||||||
|
</session-factory>
|
||||||
|
</hibernate-configuration>
|
|
@ -24,7 +24,7 @@ import com.google.common.base.Preconditions;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableTransactionManagement
|
@EnableTransactionManagement
|
||||||
@PropertySource({ "classpath:persistence-mysql.properties" })
|
@PropertySource({ "classpath:persistence-h2.properties" })
|
||||||
@ComponentScan({ "org.baeldung.persistence" })
|
@ComponentScan({ "org.baeldung.persistence" })
|
||||||
@EnableJpaRepositories(basePackages = "org.baeldung.persistence.dao")
|
@EnableJpaRepositories(basePackages = "org.baeldung.persistence.dao")
|
||||||
public class PersistenceJPAConfig {
|
public class PersistenceJPAConfig {
|
||||||
|
|
|
@ -11,7 +11,7 @@ import javax.persistence.Table;
|
||||||
public class Possession {
|
public class Possession {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private long id;
|
private long id;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
|
@ -15,7 +15,7 @@ import javax.persistence.Table;
|
||||||
public class User {
|
public class User {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private int id;
|
private int id;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
jdbc.driverClassName=org.h2.Driver
|
jdbc.driverClassName=org.h2.Driver
|
||||||
jdbc.url=jdbc:h2:mem:db;DB_CLOSE_DELAY=-1
|
jdbc.url=jdbc:h2:mem:db;DB_CLOSE_DELAY=-1
|
||||||
jdbc.user=sa
|
jdbc.user=sa
|
||||||
# jdbc.pass=
|
jdbc.pass=
|
||||||
|
|
||||||
# hibernate.X
|
# hibernate.X
|
||||||
hibernate.dialect=org.hibernate.dialect.H2Dialect
|
hibernate.dialect=org.hibernate.dialect.H2Dialect
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
# jdbc.X
|
# jdbc.X
|
||||||
jdbc.driverClassName=com.mysql.cj.jdbc.Driver
|
jdbc.driverClassName=org.h2.Driver
|
||||||
user.jdbc.url=jdbc:mysql://localhost:3306/spring_jpa_user?createDatabaseIfNotExist=true
|
user.jdbc.url=jdbc:h2:mem:spring_jpa_user;DB_CLOSE_DELAY=-1;INIT=CREATE SCHEMA IF NOT EXISTS SPRING_JPA_USER
|
||||||
product.jdbc.url=jdbc:mysql://localhost:3306/spring_jpa_product?createDatabaseIfNotExist=true
|
product.jdbc.url=jdbc:h2:mem:spring_jpa_product;DB_CLOSE_DELAY=-1;INIT=CREATE SCHEMA IF NOT EXISTS SPRING_JPA_PRODUCT
|
||||||
jdbc.user=tutorialuser
|
jdbc.user=sa
|
||||||
jdbc.pass=tutorialmy5ql
|
jdbc.pass=
|
||||||
|
|
||||||
# hibernate.X
|
# hibernate.X
|
||||||
hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
|
hibernate.dialect=org.hibernate.dialect.H2Dialect
|
||||||
hibernate.show_sql=false
|
hibernate.show_sql=false
|
||||||
hibernate.hbm2ddl.auto=create-drop
|
hibernate.hbm2ddl.auto=create-drop
|
||||||
hibernate.cache.use_second_level_cache=false
|
hibernate.cache.use_second_level_cache=false
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
jdbc.driverClassName=org.h2.Driver
|
jdbc.driverClassName=org.h2.Driver
|
||||||
jdbc.url=jdbc:h2:mem:db;DB_CLOSE_DELAY=-1
|
jdbc.url=jdbc:h2:mem:db;DB_CLOSE_DELAY=-1
|
||||||
jdbc.user=sa
|
jdbc.user=sa
|
||||||
# jdbc.pass=
|
jdbc.pass=
|
||||||
|
|
||||||
# hibernate.X
|
# hibernate.X
|
||||||
hibernate.dialect=org.hibernate.dialect.H2Dialect
|
hibernate.dialect=org.hibernate.dialect.H2Dialect
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd"
|
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd"
|
||||||
>
|
>
|
||||||
|
|
||||||
<context:property-placeholder location="classpath:persistence-mysql.properties"/>
|
<context:property-placeholder location="classpath:persistence-h2.properties"/>
|
||||||
|
|
||||||
<bean id="myEmf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
|
<bean id="myEmf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
|
||||||
<property name="dataSource" ref="dataSource"/>
|
<property name="dataSource" ref="dataSource"/>
|
||||||
|
|
|
@ -9,11 +9,13 @@ import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.jdbc.core.JdbcTemplate;
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
|
import org.springframework.test.annotation.DirtiesContext;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@ContextConfiguration(classes = DataSourceRoutingTestConfiguration.class)
|
@ContextConfiguration(classes = DataSourceRoutingTestConfiguration.class)
|
||||||
|
@DirtiesContext
|
||||||
public class DataSourceRoutingIntegrationTest {
|
public class DataSourceRoutingIntegrationTest {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|
|
@ -10,6 +10,6 @@ public class PersistenceJPAConfigDeletion extends PersistenceJPAConfigL2Cache {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String[] getPackagesToScan() {
|
protected String[] getPackagesToScan() {
|
||||||
return new String[] { "org.baeldung.persistence.deletion.model" };
|
return new String[] { "org.baeldung.persistence.deletion.model", "org.baeldung.persistence.model" };
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -11,6 +11,7 @@ import org.baeldung.inmemory.persistence.model.SkillTag;
|
||||||
import org.baeldung.inmemory.persistence.model.Student;
|
import org.baeldung.inmemory.persistence.model.Student;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.test.annotation.DirtiesContext;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||||
|
@ -26,6 +27,7 @@ import static org.junit.Assert.assertEquals;
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@ContextConfiguration(classes = { StudentJpaConfig.class }, loader = AnnotationConfigContextLoader.class)
|
@ContextConfiguration(classes = { StudentJpaConfig.class }, loader = AnnotationConfigContextLoader.class)
|
||||||
@Transactional
|
@Transactional
|
||||||
|
@DirtiesContext
|
||||||
public class AdvancedTaggingIntegrationTest {
|
public class AdvancedTaggingIntegrationTest {
|
||||||
@Resource
|
@Resource
|
||||||
private StudentRepository studentRepository;
|
private StudentRepository studentRepository;
|
||||||
|
|
|
@ -12,11 +12,13 @@ import org.baeldung.inmemory.persistence.model.Student;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.test.annotation.DirtiesContext;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
|
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@ContextConfiguration(classes = { StudentJPAH2Config.class })
|
@ContextConfiguration(classes = { StudentJPAH2Config.class })
|
||||||
|
@DirtiesContext
|
||||||
public class ExtendedStudentRepositoryIntegrationTest {
|
public class ExtendedStudentRepositoryIntegrationTest {
|
||||||
@Resource
|
@Resource
|
||||||
private ExtendedStudentRepository extendedStudentRepository;
|
private ExtendedStudentRepository extendedStudentRepository;
|
||||||
|
|
|
@ -5,6 +5,7 @@ import org.baeldung.inmemory.persistence.dao.StudentRepository;
|
||||||
import org.baeldung.inmemory.persistence.model.Student;
|
import org.baeldung.inmemory.persistence.model.Student;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.test.annotation.DirtiesContext;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||||
|
@ -20,6 +21,7 @@ import static org.junit.Assert.assertEquals;
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@ContextConfiguration(classes = { StudentJpaConfig.class }, loader = AnnotationConfigContextLoader.class)
|
@ContextConfiguration(classes = { StudentJpaConfig.class }, loader = AnnotationConfigContextLoader.class)
|
||||||
@Transactional
|
@Transactional
|
||||||
|
@DirtiesContext
|
||||||
public class InMemoryDBIntegrationTest {
|
public class InMemoryDBIntegrationTest {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
|
|
|
@ -11,6 +11,7 @@ import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
import org.springframework.data.jpa.domain.JpaSort;
|
import org.springframework.data.jpa.domain.JpaSort;
|
||||||
import org.springframework.data.mapping.PropertyReferenceException;
|
import org.springframework.data.mapping.PropertyReferenceException;
|
||||||
|
import org.springframework.test.annotation.DirtiesContext;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
@ -25,6 +26,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@ContextConfiguration(classes = PersistenceJPAConfigL2Cache.class)
|
@ContextConfiguration(classes = PersistenceJPAConfigL2Cache.class)
|
||||||
|
@DirtiesContext
|
||||||
public class UserRepositoryIntegrationTest {
|
public class UserRepositoryIntegrationTest {
|
||||||
|
|
||||||
private final String USER_NAME_ADAM = "Adam";
|
private final String USER_NAME_ADAM = "Adam";
|
||||||
|
|
|
@ -8,6 +8,7 @@ import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.test.annotation.DirtiesContext;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||||
|
@ -23,6 +24,7 @@ import static org.junit.Assert.assertThat;
|
||||||
|
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@ContextConfiguration(classes = { PersistenceJPAConfigDeletion.class }, loader = AnnotationConfigContextLoader.class)
|
@ContextConfiguration(classes = { PersistenceJPAConfigDeletion.class }, loader = AnnotationConfigContextLoader.class)
|
||||||
|
@DirtiesContext
|
||||||
public class DeletionIntegrationTest {
|
public class DeletionIntegrationTest {
|
||||||
|
|
||||||
@PersistenceContext
|
@PersistenceContext
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue