Merge branch 'master' of https://github.com/eugenp/tutorials into BAEL-11603
This commit is contained in:
commit
a5d63e6cff
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,4 +1,5 @@
|
||||
*/bin/*
|
||||
bin/
|
||||
|
||||
*.class
|
||||
|
||||
@ -21,6 +22,9 @@
|
||||
*.iws
|
||||
out/
|
||||
|
||||
# VSCode
|
||||
.vscode/
|
||||
|
||||
# Mac
|
||||
.DS_Store
|
||||
|
||||
|
@ -32,7 +32,7 @@ Running a Spring Boot module
|
||||
====================
|
||||
To run a Spring Boot module run the command: `mvn spring-boot:run` in the module directory
|
||||
|
||||
#Running Tests
|
||||
###Running Tests
|
||||
|
||||
The command `mvn clean install` will run the unit tests in a module.
|
||||
To run the integration tests, use the command `mvn clean install -Pintegration-lite-first`
|
||||
|
@ -6,4 +6,4 @@
|
||||
- [Practical Java Examples of the Big O Notation](http://www.baeldung.com/java-algorithm-complexity)
|
||||
- [Checking If a List Is Sorted in Java](https://www.baeldung.com/java-check-if-list-sorted)
|
||||
- [Checking if a Java Graph has a Cycle](https://www.baeldung.com/java-graph-has-a-cycle)
|
||||
- [A Guide to the Folding Technique](https://www.baeldung.com/folding-hashing-technique)
|
||||
- [A Guide to the Folding Technique in Java](https://www.baeldung.com/folding-hashing-technique)
|
||||
|
@ -82,7 +82,6 @@
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<olingo2.version>2.0.11</olingo2.version>
|
||||
</properties>
|
||||
|
||||
|
@ -112,7 +112,6 @@
|
||||
</repositories>
|
||||
|
||||
<properties>
|
||||
<commons-io.version>2.5</commons-io.version>
|
||||
<aws-lambda-java-events.version>1.3.0</aws-lambda-java-events.version>
|
||||
<aws-lambda-java-core.version>1.1.0</aws-lambda-java-core.version>
|
||||
<gson.version>2.8.0</gson.version>
|
||||
|
@ -175,8 +175,6 @@
|
||||
<junit.platform.version>1.0.0</junit.platform.version>
|
||||
<hsqldb.version>2.4.0</hsqldb.version>
|
||||
<spock-core.version>1.1-groovy-2.4</spock-core.version>
|
||||
<commons-lang3.version>3.9</commons-lang3.version>
|
||||
<java.version>1.8</java.version>
|
||||
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
|
||||
<logback.version>1.2.3</logback.version>
|
||||
<groovy.version>2.5.7</groovy.version>
|
||||
|
@ -0,0 +1,52 @@
|
||||
package com.baeldung.concatenate
|
||||
|
||||
class Wonder {
|
||||
|
||||
String numOfWonder = 'seven'
|
||||
|
||||
String operator_plus() {
|
||||
return 'The ' + numOfWonder + ' wonders of the world'
|
||||
}
|
||||
|
||||
String operator_left() {
|
||||
return 'The ' << numOfWonder << ' wonders of ' << 'the world'
|
||||
}
|
||||
|
||||
String interpolation_one() {
|
||||
return "The $numOfWonder wonders of the world"
|
||||
|
||||
}
|
||||
|
||||
String interpolation_two() {
|
||||
return "The ${numOfWonder} wonders of the world"
|
||||
}
|
||||
|
||||
String multilineString() {
|
||||
return """
|
||||
There are $numOfWonder wonders of the world.
|
||||
Can you name them all?
|
||||
1. The Great Pyramid of Giza
|
||||
2. Hanging Gardens of Babylon
|
||||
3. Colossus of Rhode
|
||||
4. Lighthouse of Alexendra
|
||||
5. Temple of Artemis
|
||||
6. Status of Zeus at Olympia
|
||||
7. Mausoleum at Halicarnassus
|
||||
"""
|
||||
}
|
||||
|
||||
String method_concat() {
|
||||
return 'The '.concat(numOfWonder).concat(' wonders of the world')
|
||||
|
||||
}
|
||||
|
||||
String method_builder() {
|
||||
return new StringBuilder()
|
||||
.append('The ').append(numOfWonder).append(' wonders of the world')
|
||||
}
|
||||
|
||||
String method_buffer() {
|
||||
return new StringBuffer()
|
||||
.append('The ').append(numOfWonder).append(' wonders of the world')
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
package com.baeldung.concatenate
|
||||
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
import static org.junit.Assert.*
|
||||
|
||||
class WonderUnitTest {
|
||||
|
||||
static final String EXPECTED_SINGLE_LINE = "The seven wonders of the world"
|
||||
|
||||
Wonder wonder
|
||||
|
||||
@Before
|
||||
void before() {
|
||||
wonder = new Wonder()
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenUsingOperatorPlus_thenConcatCorrectly() {
|
||||
assertEquals(EXPECTED_SINGLE_LINE, wonder.operator_plus())
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenUsingOperatorLeft_thenConcatCorrectly() {
|
||||
assertEquals(EXPECTED_SINGLE_LINE, wonder.operator_left())
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenUsingInterpolationOne_thenConcatCorrectly() {
|
||||
assertEquals(EXPECTED_SINGLE_LINE, wonder.interpolation_one())
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenUsingInterpolationTwo_thenConcatCorrectly() {
|
||||
assertEquals(EXPECTED_SINGLE_LINE, wonder.interpolation_two())
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenUsingMultiline_thenConcatCorrectly() {
|
||||
def expectedMultiline = """
|
||||
There are seven wonders of the world.
|
||||
Can you name them all?
|
||||
1. The Great Pyramid of Giza
|
||||
2. Hanging Gardens of Babylon
|
||||
3. Colossus of Rhode
|
||||
4. Lighthouse of Alexendra
|
||||
5. Temple of Artemis
|
||||
6. Status of Zeus at Olympia
|
||||
7. Mausoleum at Halicarnassus
|
||||
"""
|
||||
assertEquals(expectedMultiline, wonder.multilineString())
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenUsingMethodConcat_thenConcatCorrectly() {
|
||||
assertEquals(EXPECTED_SINGLE_LINE, wonder.method_concat())
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenUsingMethodBuilder_thenConcatCorrectly() {
|
||||
assertEquals(EXPECTED_SINGLE_LINE, wonder.method_builder())
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenUsingMethodBuffer_thenConcatCorrectly() {
|
||||
assertEquals(EXPECTED_SINGLE_LINE, wonder.method_buffer())
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
## Relevant articles:
|
||||
|
||||
- [Negate a Predicate Method Reference with Java 11](https://www.baeldung.com/java-negate-predicate-method-reference)
|
3
core-java-modules/core-java-12/README.md
Normal file
3
core-java-modules/core-java-12/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
## Relevant articles:
|
||||
|
||||
- [String API Updates in Java 12](https://www.baeldung.com/java12-string-api)
|
@ -175,7 +175,6 @@
|
||||
|
||||
<properties>
|
||||
<!-- util -->
|
||||
<commons-lang3.version>3.5</commons-lang3.version>
|
||||
<commons-math3.version>3.6.1</commons-math3.version>
|
||||
<commons-collections4.version>4.1</commons-collections4.version>
|
||||
<collections-generic.version>4.01</collections-generic.version>
|
||||
|
@ -259,4 +259,15 @@ public class OptionalUnitTest {
|
||||
LOG.debug("Getting default value...");
|
||||
return "Default Value";
|
||||
}
|
||||
|
||||
// Uncomment code when code base is compatiable with Java 11
|
||||
// @Test
|
||||
// public void givenAnEmptyOptional_thenIsEmptyBehavesAsExpected() {
|
||||
// Optional<String> opt = Optional.of("Baeldung");
|
||||
// assertFalse(opt.isEmpty());
|
||||
//
|
||||
// opt = Optional.ofNullable(null);
|
||||
// assertTrue(opt.isEmpty());
|
||||
// }
|
||||
|
||||
}
|
@ -42,7 +42,7 @@ public class CoreJavaCollectionsUnitTest {
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
public final void givenUsingGuavaBuilder_whenUnmodifiableListIsCreatedFromOriginal_thenNoLongerModifiable() {
|
||||
final List<String> list = new ArrayList<String>(Arrays.asList("one", "two", "three"));
|
||||
final ImmutableList<Object> unmodifiableList = ImmutableList.builder().addAll(list).build();
|
||||
final ImmutableList<String> unmodifiableList = ImmutableList.<String>builder().addAll(list).build();
|
||||
unmodifiableList.add("four");
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,6 @@
|
||||
<properties>
|
||||
<!-- util -->
|
||||
<guava.version>21.0</guava.version>
|
||||
<commons-lang3.version>3.5</commons-lang3.version>
|
||||
<commons-math3.version>3.6.1</commons-math3.version>
|
||||
<commons-collections4.version>4.1</commons-collections4.version>
|
||||
<collections-generic.version>4.01</collections-generic.version>
|
||||
|
@ -17,3 +17,4 @@
|
||||
- [Runnable vs. Callable in Java](http://www.baeldung.com/java-runnable-callable)
|
||||
- [What is Thread-Safety and How to Achieve it?](https://www.baeldung.com/java-thread-safety)
|
||||
- [How to Start a Thread in Java](https://www.baeldung.com/java-start-thread)
|
||||
- [How to Delay Code Execution in Java](https://www.baeldung.com/java-delay-code-execution)
|
||||
|
@ -45,8 +45,6 @@
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<!-- util -->
|
||||
<commons-lang3.version>3.5</commons-lang3.version>
|
||||
<!-- testing -->
|
||||
<assertj.version>3.6.1</assertj.version>
|
||||
<avaitility.version>1.7.0</avaitility.version>
|
||||
|
@ -62,7 +62,6 @@
|
||||
<properties>
|
||||
<!-- util -->
|
||||
<guava.version>21.0</guava.version>
|
||||
<commons-lang3.version>3.5</commons-lang3.version>
|
||||
<commons-math3.version>3.6.1</commons-math3.version>
|
||||
<commons-collections4.version>4.1</commons-collections4.version>
|
||||
<collections-generic.version>4.01</collections-generic.version>
|
||||
|
3
core-java-modules/core-java-exceptions/README.md
Normal file
3
core-java-modules/core-java-exceptions/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
## Relevant articles:
|
||||
|
||||
- [Will an Error Be Caught by Catch Block in Java?](https://www.baeldung.com/java-error-catch)
|
@ -248,7 +248,6 @@
|
||||
<properties>
|
||||
|
||||
<!-- util -->
|
||||
<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>
|
||||
|
@ -35,7 +35,6 @@
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<commons-lang3.version>3.5</commons-lang3.version>
|
||||
<assertj.version>3.6.1</assertj.version>
|
||||
</properties>
|
||||
</project>
|
||||
|
3
core-java-modules/core-java-lambdas/README.md
Normal file
3
core-java-modules/core-java-lambdas/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
## Relevant articles:
|
||||
|
||||
- [Why Do Local Variables Used in Lambdas Have to Be Final or Effectively Final?](https://www.baeldung.com/java-lambda-effectively-final-local-variables)
|
@ -75,13 +75,7 @@
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
|
||||
<!-- marshalling -->
|
||||
<jackson.version>2.8.5</jackson.version>
|
||||
<gson.version>2.8.2</gson.version>
|
||||
|
||||
<!-- util -->
|
||||
<commons-lang3.version>3.5</commons-lang3.version>
|
||||
<!-- testing -->
|
||||
<assertj-core.version>3.10.0</assertj-core.version>
|
||||
<equalsverifier.version>3.0.3</equalsverifier.version>
|
||||
|
@ -75,9 +75,6 @@
|
||||
|
||||
<properties>
|
||||
<gson.version>2.8.2</gson.version>
|
||||
|
||||
<!-- util -->
|
||||
<commons-lang3.version>3.5</commons-lang3.version>
|
||||
|
||||
<javax.mail.version>1.5.0-b01</javax.mail.version>
|
||||
|
||||
|
@ -42,8 +42,6 @@
|
||||
|
||||
<properties>
|
||||
<javax.mail.version>1.5.0-b01</javax.mail.version>
|
||||
<commons-io.version>2.5</commons-io.version>
|
||||
<commons-lang3.version>3.5</commons-lang3.version>
|
||||
<springframework.spring-web.version>4.3.4.RELEASE</springframework.spring-web.version>
|
||||
</properties>
|
||||
</project>
|
||||
|
@ -19,12 +19,12 @@
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<version>${h2database.version}</version>
|
||||
<version>${h2.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>${jackson.databind.version}</version>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@ -48,7 +48,5 @@
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<hibernate.core.version>5.4.0.Final</hibernate.core.version>
|
||||
<h2database.version>1.4.197</h2database.version>
|
||||
<jackson.databind.version>2.9.8</jackson.databind.version>
|
||||
</properties>
|
||||
</project>
|
@ -68,7 +68,6 @@
|
||||
|
||||
<properties>
|
||||
<!-- util -->
|
||||
<commons-lang3.version>3.5</commons-lang3.version>
|
||||
<commons-collections4.version>4.1</commons-collections4.version>
|
||||
<collections-generic.version>4.01</collections-generic.version>
|
||||
|
||||
|
@ -23,11 +23,4 @@
|
||||
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
|
||||
<!-- util -->
|
||||
<commons-lang3.version>3.8.1</commons-lang3.version>
|
||||
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
|
@ -43,7 +43,6 @@
|
||||
<properties>
|
||||
|
||||
<!-- util -->
|
||||
<commons-lang3.version>3.8.1</commons-lang3.version>
|
||||
<bouncycastle.version>1.60</bouncycastle.version>
|
||||
<commons-codec.version>1.11</commons-codec.version>
|
||||
|
||||
|
@ -264,7 +264,6 @@
|
||||
|
||||
<!-- util -->
|
||||
<guava.version>23.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>
|
||||
|
@ -113,7 +113,7 @@
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<version>${h2database.version}</version>
|
||||
<version>${h2.version}</version>
|
||||
</dependency>
|
||||
<!-- instrumentation -->
|
||||
<dependency>
|
||||
@ -453,8 +453,6 @@
|
||||
<gson.version>2.8.2</gson.version>
|
||||
|
||||
<!-- util -->
|
||||
<commons-lang3.version>3.9</commons-lang3.version>
|
||||
<commons-io.version>2.5</commons-io.version>
|
||||
<commons-math3.version>3.6.1</commons-math3.version>
|
||||
<decimal4j.version>1.0.3</decimal4j.version>
|
||||
<unix4j.version>0.4</unix4j.version>
|
||||
@ -471,7 +469,6 @@
|
||||
<maven-surefire-plugin.version>2.21.0</maven-surefire-plugin.version>
|
||||
|
||||
<javamoney.moneta.version>1.1</javamoney.moneta.version>
|
||||
<h2database.version>1.4.197</h2database.version>
|
||||
<esapi.version>2.1.0.1</esapi.version>
|
||||
<jmh-core.version>1.19</jmh-core.version>
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<version>${junit.jupiter.version}</version>
|
||||
<version>${junit-jupiter.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -88,7 +88,7 @@
|
||||
|
||||
<properties>
|
||||
<kotlin.version>1.3.30</kotlin.version>
|
||||
<junit.jupiter.version>5.4.2</junit.jupiter.version>
|
||||
<junit-jupiter.version>5.4.2</junit-jupiter.version>
|
||||
<mockito.version>2.27.0</mockito.version>
|
||||
<byte-buddy.version>1.9.12</byte-buddy.version>
|
||||
<assertj.version>3.10.0</assertj.version>
|
||||
|
@ -39,7 +39,7 @@
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<version>${h2database.version}</version>
|
||||
<version>${h2.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.kittinunf.fuel</groupId>
|
||||
@ -76,11 +76,9 @@
|
||||
|
||||
<properties>
|
||||
<commons-math3.version>3.6.1</commons-math3.version>
|
||||
<commons-lang3.version>3.8.1</commons-lang3.version>
|
||||
<junit.platform.version>1.1.1</junit.platform.version>
|
||||
<junit.vintage.version>5.2.0</junit.vintage.version>
|
||||
<assertj.version>3.10.0</assertj.version>
|
||||
<h2database.version>1.4.197</h2database.version>
|
||||
<fuel.version>1.15.0</fuel.version>
|
||||
<kovenant.version>3.3.0</kovenant.version>
|
||||
<injekt-core.version>1.16.1</injekt-core.version>
|
||||
|
@ -69,7 +69,6 @@
|
||||
<properties>
|
||||
<couchbase.client.version>2.5.0</couchbase.client.version>
|
||||
<spring-framework.version>4.3.5.RELEASE</spring-framework.version>
|
||||
<commons-lang3.version>3.5</commons-lang3.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
|
@ -115,7 +115,6 @@
|
||||
|
||||
<properties>
|
||||
<!-- util -->
|
||||
<commons-lang3.version>3.5</commons-lang3.version>
|
||||
<disruptor.version>3.3.6</disruptor.version>
|
||||
<!-- testing -->
|
||||
<testng.version>6.10</testng.version>
|
||||
|
@ -26,7 +26,6 @@
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<commons-lang3.version>3.5</commons-lang3.version>
|
||||
<dozer.version>5.5.1</dozer.version>
|
||||
</properties>
|
||||
|
||||
|
@ -58,6 +58,5 @@
|
||||
<flyway-core.version>5.1.4</flyway-core.version>
|
||||
<tomcat-jdbc.version>8.5.33</tomcat-jdbc.version>
|
||||
<javax.annotation-api.version>1.3.2</javax.annotation-api.version>
|
||||
<h2.version>1.4.197</h2.version>
|
||||
</properties>
|
||||
</project>
|
||||
|
@ -64,7 +64,6 @@
|
||||
<!-- marshalling -->
|
||||
<gson.version>2.8.0</gson.version>
|
||||
<!-- util -->
|
||||
<commons-lang3.version>3.5</commons-lang3.version>
|
||||
<commons-collections4.version>4.1</commons-collections4.version>
|
||||
<joda-time.version>2.9.6</joda-time.version>
|
||||
</properties>
|
||||
|
@ -55,7 +55,6 @@
|
||||
<properties>
|
||||
<!-- util -->
|
||||
<guava.version>24.0-jre</guava.version>
|
||||
<commons-lang3.version>3.5</commons-lang3.version>
|
||||
<commons-collections4.version>4.1</commons-collections4.version>
|
||||
|
||||
<!-- testing -->
|
||||
|
@ -49,7 +49,6 @@
|
||||
<properties>
|
||||
<!-- util -->
|
||||
<guava.version>24.0-jre</guava.version>
|
||||
<commons-lang3.version>3.5</commons-lang3.version>
|
||||
|
||||
<!-- testing -->
|
||||
<assertj.version>3.6.1</assertj.version>
|
||||
|
@ -297,7 +297,6 @@
|
||||
<properties>
|
||||
<!-- util -->
|
||||
<guava.version>19.0</guava.version>
|
||||
<commons-lang3.version>3.5</commons-lang3.version>
|
||||
<commons-codec.version>1.10</commons-codec.version>
|
||||
<httpasyncclient.version>4.1.4</httpasyncclient.version>
|
||||
<!-- testing -->
|
||||
@ -305,7 +304,6 @@
|
||||
<httpcore.version>4.4.11</httpcore.version>
|
||||
<httpclient.version>4.5.8</httpclient.version> <!-- 4.3.6 --> <!-- 4.4-beta1 -->
|
||||
<!-- maven plugins -->
|
||||
<maven-war-plugin.version>2.6</maven-war-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.6.1</cargo-maven2-plugin.version>
|
||||
</properties>
|
||||
|
||||
|
@ -120,7 +120,6 @@
|
||||
<properties>
|
||||
<!-- util -->
|
||||
<guava.version>19.0</guava.version>
|
||||
<commons-lang3.version>3.5</commons-lang3.version>
|
||||
<commons-codec.version>1.10</commons-codec.version>
|
||||
<httpasyncclient.version>4.1.4</httpasyncclient.version>
|
||||
<!-- testing -->
|
||||
|
@ -65,7 +65,6 @@
|
||||
<hystrix-core.version>1.5.8</hystrix-core.version>
|
||||
<rxjava-core.version>0.20.7</rxjava-core.version>
|
||||
<!-- maven plugins -->
|
||||
<maven-war-plugin.version>2.6</maven-war-plugin.version>
|
||||
<maven-resources-plugin.version>2.7</maven-resources-plugin.version>
|
||||
<hystrix-metrics-event-stream.version>1.5.8</hystrix-metrics-event-stream.version>
|
||||
<hystrix-dashboard.version>1.5.8</hystrix-dashboard.version>
|
||||
|
@ -118,7 +118,6 @@
|
||||
|
||||
<properties>
|
||||
<!-- util -->
|
||||
<commons-lang3.version>3.8</commons-lang3.version>
|
||||
<joda-time.version>2.10</joda-time.version>
|
||||
<gson.version>2.8.5</gson.version>
|
||||
<commons-collections4.version>4.2</commons-collections4.version>
|
||||
|
@ -118,7 +118,6 @@
|
||||
|
||||
<properties>
|
||||
<!-- util -->
|
||||
<commons-lang3.version>3.8</commons-lang3.version>
|
||||
<joda-time.version>2.10</joda-time.version>
|
||||
<gson.version>2.8.5</gson.version>
|
||||
<commons-collections4.version>4.2</commons-collections4.version>
|
||||
|
@ -33,7 +33,6 @@
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<commons-lang3.version>3.5</commons-lang3.version>
|
||||
<commons-collections4.version>4.1</commons-collections4.version>
|
||||
<assertj.version>3.6.1</assertj.version>
|
||||
</properties>
|
||||
|
@ -54,7 +54,6 @@
|
||||
<trove4j.version>3.0.2</trove4j.version>
|
||||
<fastutil.version>8.1.0</fastutil.version>
|
||||
<colt.version>1.2.0</colt.version>
|
||||
<commons-lang3.version>3.8.1</commons-lang3.version>
|
||||
<assertj.version>3.11.1</assertj.version>
|
||||
</properties>
|
||||
|
||||
|
@ -44,7 +44,6 @@
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<commons-lang3.version>3.5</commons-lang3.version>
|
||||
<commons-collections4.version>4.1</commons-collections4.version>
|
||||
<collections-generic.version>4.01</collections-generic.version>
|
||||
<avaitility.version>1.7.0</avaitility.version>
|
||||
|
@ -74,8 +74,6 @@
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<!-- util -->
|
||||
<commons-lang3.version>3.5</commons-lang3.version>
|
||||
<joda-time.version>2.10</joda-time.version>
|
||||
<!-- testing -->
|
||||
<assertj.version>3.6.1</assertj.version>
|
||||
|
@ -72,8 +72,6 @@
|
||||
<javaee-version>8.0</javaee-version>
|
||||
<liberty-maven-plugin.version>2.3</liberty-maven-plugin.version>
|
||||
<openliberty-runtime.version>18.0.0.1</openliberty-runtime.version>
|
||||
|
||||
<maven-war-plugin.version>3.2.2</maven-war-plugin.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
|
26
java-numbers-2/.gitignore
vendored
Normal file
26
java-numbers-2/.gitignore
vendored
Normal file
@ -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
|
135
java-numbers-2/pom.xml
Normal file
135
java-numbers-2/pom.xml
Normal file
@ -0,0 +1,135 @@
|
||||
<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-2</artifactId>
|
||||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>java-numbers-2</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<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.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-2</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
<plugins>
|
||||
|
||||
<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>
|
||||
|
||||
<maven-surefire-plugin.version>2.21.0</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>
|
@ -0,0 +1,68 @@
|
||||
package com.baeldung.lossyconversion;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class ConversionTechniquesUnitTest {
|
||||
|
||||
@Test
|
||||
public void testPrimitiveConversion() {
|
||||
|
||||
long longNum = 24;
|
||||
short shortNum = (short) longNum;
|
||||
assertEquals(24, shortNum);
|
||||
|
||||
double doubleNum = 15.6;
|
||||
int integerNum = (int) doubleNum;
|
||||
assertEquals(15, integerNum);
|
||||
|
||||
long largeLongNum = 32768;
|
||||
short minShortNum = (short) largeLongNum;
|
||||
assertEquals(-32768, minShortNum);
|
||||
|
||||
long smallLongNum = -32769;
|
||||
short maxShortNum = (short) smallLongNum;
|
||||
assertEquals(32767, maxShortNum);
|
||||
|
||||
long maxLong = Long.MAX_VALUE;
|
||||
int minInt = (int) maxLong;
|
||||
assertEquals(-1, minInt);
|
||||
|
||||
long minLong = Long.MIN_VALUE;
|
||||
int maxInt = (int) minLong;
|
||||
assertEquals(0, maxInt);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWrapperToPrimitiveConversion() {
|
||||
|
||||
Float floatNum = 17.564f;
|
||||
long longNum = floatNum.longValue();
|
||||
assertEquals(17, longNum);
|
||||
|
||||
Double doubleNum = 15.9999;
|
||||
longNum = doubleNum.longValue();
|
||||
assertEquals(15, longNum);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWrapperToPrimitiveConversionUsingMathRound() {
|
||||
|
||||
Double doubleNum = 15.9999;
|
||||
long longNum = Math.round(doubleNum);
|
||||
assertEquals(16, longNum);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWrapperConversion() {
|
||||
|
||||
Double doubleNum = 10.3;
|
||||
double dbl = doubleNum.doubleValue(); //unboxing
|
||||
int intgr = (int) dbl; //downcasting
|
||||
Integer intNum = Integer.valueOf(intgr);
|
||||
assertEquals(Integer.valueOf(10), intNum);
|
||||
}
|
||||
|
||||
}
|
@ -121,7 +121,6 @@
|
||||
<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>
|
||||
|
||||
|
@ -106,7 +106,6 @@
|
||||
|
||||
<properties>
|
||||
<!-- util -->
|
||||
<commons-lang3.version>3.5</commons-lang3.version>
|
||||
<vavr.version>0.9.0</vavr.version>
|
||||
<protonpack.version>1.15</protonpack.version>
|
||||
<streamex.version>0.6.5</streamex.version>
|
||||
|
@ -4,3 +4,4 @@
|
||||
- [Check If a String Contains a Substring](https://www.baeldung.com/java-string-contains-substring)
|
||||
- [Removing Stopwords from a String in Java](https://www.baeldung.com/java-string-remove-stopwords)
|
||||
- [Blank and Empty Strings in Java](https://www.baeldung.com/java-blank-empty-strings)
|
||||
- [String Initialization in Java](https://www.baeldung.com/java-string-initialization)
|
||||
|
@ -88,7 +88,6 @@
|
||||
<assertj.version>3.9.1</assertj.version>
|
||||
<mockito.version>2.21.0</mockito.version>
|
||||
<commons-fileupload.version>1.3.3</commons-fileupload.version>
|
||||
<commons-io.version>2.6</commons-io.version>
|
||||
<javax.servlet-api.version>4.0.1</javax.servlet-api.version>
|
||||
</properties>
|
||||
</project>
|
||||
|
@ -130,8 +130,6 @@
|
||||
<!-- maven plugins -->
|
||||
<jaxb2-maven-plugin.version>2.3</jaxb2-maven-plugin.version>
|
||||
<istack-commons-runtime.version>3.0.2</istack-commons-runtime.version>
|
||||
<commons-io.version>2.5</commons-io.version>
|
||||
<commons-lang3.version>3.5</commons-lang3.version>
|
||||
<lifecycle-mapping-plugin.version>1.0.0</lifecycle-mapping-plugin.version>
|
||||
|
||||
<javax.activation.version>1.1</javax.activation.version>
|
||||
|
@ -519,11 +519,9 @@
|
||||
<tyrus.version>1.13</tyrus.version>
|
||||
<jersey.version>2.25</jersey.version>
|
||||
<arquillian-glassfish.version>1.0.0.Final</arquillian-glassfish.version>
|
||||
<maven-war-plugin.version>2.6</maven-war-plugin.version>
|
||||
<org.springframework.security.version>4.2.3.RELEASE</org.springframework.security.version>
|
||||
<maven-surefire-plugin.version>2.21.0</maven-surefire-plugin.version>
|
||||
<taglibs.standard.version>1.1.2</taglibs.standard.version>
|
||||
<commons-io.version>2.4</commons-io.version>
|
||||
<com.sun.faces.jsf.version>2.2.14</com.sun.faces.jsf.version>
|
||||
<httpclient.version>4.5</httpclient.version>
|
||||
<arquillian-drone-bom.version>2.0.1.Final</arquillian-drone-bom.version>
|
||||
|
@ -2,43 +2,16 @@
|
||||
<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">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>jee-kotlin</artifactId>
|
||||
<name>jee-kotlin</name>
|
||||
<packaging>war</packaging>
|
||||
|
||||
<parent>
|
||||
<artifactId>parent-modules</artifactId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>jee-kotlin</artifactId>
|
||||
<name>jee-kotlin</name>
|
||||
<packaging>war</packaging>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||
<javaee-api.version>8.0</javaee-api.version>
|
||||
|
||||
|
||||
<kotlin.version>1.3.41</kotlin.version>
|
||||
<kotlin.code.style>official</kotlin.code.style>
|
||||
<kotlin.compiler.incremental>true</kotlin.compiler.incremental>
|
||||
|
||||
|
||||
<wildfly.version>8.2.1.Final</wildfly.version>
|
||||
<mvn-war-plugin.version>3.2.3</mvn-war-plugin.version>
|
||||
<maven-surefire-plugin.version>2.21.0</maven-surefire-plugin.version>
|
||||
<maven-dependency-plugin.version>3.1.1</maven-dependency-plugin.version>
|
||||
|
||||
<arquillian_core.version>1.4.1.Final</arquillian_core.version>
|
||||
<arquillian-drone-bom.version>2.0.1.Final</arquillian-drone-bom.version>
|
||||
<arquillian-rest-client.version>1.0.0.Alpha4</arquillian-rest-client.version>
|
||||
|
||||
<junit.version>4.12</junit.version>
|
||||
<resteasy.version>3.8.0.Final</resteasy.version>
|
||||
<jackson.version>2.9.8</jackson.version>
|
||||
<shrinkwrap.version>3.1.3</shrinkwrap.version>
|
||||
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
@ -134,7 +107,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>${mvn-war-plugin.version}</version>
|
||||
<version>${maven-war-plugin.version}</version>
|
||||
<configuration>
|
||||
<warSourceDirectory>webapp</warSourceDirectory>
|
||||
<warName>kotlin</warName>
|
||||
@ -286,4 +259,28 @@
|
||||
</dependencies>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||
<javaee-api.version>8.0</javaee-api.version>
|
||||
|
||||
|
||||
<kotlin.version>1.3.41</kotlin.version>
|
||||
<kotlin.code.style>official</kotlin.code.style>
|
||||
<kotlin.compiler.incremental>true</kotlin.compiler.incremental>
|
||||
|
||||
|
||||
<wildfly.version>8.2.1.Final</wildfly.version>
|
||||
<maven-surefire-plugin.version>2.21.0</maven-surefire-plugin.version>
|
||||
<maven-dependency-plugin.version>3.1.1</maven-dependency-plugin.version>
|
||||
|
||||
<arquillian_core.version>1.4.1.Final</arquillian_core.version>
|
||||
<arquillian-drone-bom.version>2.0.1.Final</arquillian-drone-bom.version>
|
||||
<arquillian-rest-client.version>1.0.0.Alpha4</arquillian-rest-client.version>
|
||||
|
||||
<resteasy.version>3.8.0.Final</resteasy.version>
|
||||
<shrinkwrap.version>3.1.3</shrinkwrap.version>
|
||||
|
||||
</properties>
|
||||
</project>
|
||||
|
@ -80,7 +80,6 @@
|
||||
|
||||
<properties>
|
||||
<jersey.version>2.26</jersey.version>
|
||||
<maven-war-plugin.version>3.2.0</maven-war-plugin.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
|
@ -1,6 +0,0 @@
|
||||
## Relevant articles:
|
||||
|
||||
- [JHipster with a Microservice Architecture](http://www.baeldung.com/jhipster-microservices)
|
||||
- [Intro to JHipster](http://www.baeldung.com/jhipster)
|
||||
- [Building a Basic UAA-Secured JHipster Microservice](https://www.baeldung.com/jhipster-uaa-secured-micro-service)
|
||||
- [Creating New Roles and Authorities in JHipster](https://www.baeldung.com/jhipster-new-roles)
|
@ -99,9 +99,6 @@
|
||||
<com.sun.faces.version>2.2.14</com.sun.faces.version>
|
||||
<javax.el.version>3.0.0</javax.el.version>
|
||||
|
||||
<!-- maven plugins -->
|
||||
<maven-war-plugin.version>2.6</maven-war-plugin.version>
|
||||
|
||||
<primefaces.version>6.2</primefaces.version>
|
||||
</properties>
|
||||
|
||||
|
@ -83,7 +83,6 @@
|
||||
|
||||
<properties>
|
||||
<maven-jar-plugin.version>3.0.2</maven-jar-plugin.version>
|
||||
<maven-war-plugin.version>3.0.0</maven-war-plugin.version>
|
||||
<jnlp-jardiff.version>1.6.0</jnlp-jardiff.version>
|
||||
<jnlp-servlet.version>1.6.0</jnlp-servlet.version>
|
||||
</properties>
|
||||
|
@ -94,7 +94,7 @@
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<version>${h2database.version}</version>
|
||||
<version>${h2.version}</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/io.arrow-kt/arrow-core -->
|
||||
<dependency>
|
||||
@ -184,7 +184,6 @@
|
||||
<junit.platform.version>1.1.1</junit.platform.version>
|
||||
<junit.vintage.version>5.2.0</junit.vintage.version>
|
||||
<assertj.version>3.10.0</assertj.version>
|
||||
<h2database.version>1.4.197</h2database.version>
|
||||
<exposed.version>0.10.4</exposed.version>
|
||||
<mockk.version>1.9.3</mockk.version>
|
||||
</properties>
|
||||
|
@ -25,7 +25,7 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>${commons-lang.version}</version>
|
||||
<version>${commons-lang3.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
@ -35,7 +35,7 @@
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>${commons.io.version}</version>
|
||||
<version>${commons-io.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-chain</groupId>
|
||||
@ -87,13 +87,12 @@
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<commons-lang.version>3.6</commons-lang.version>
|
||||
<commons-lang3.version>3.6</commons-lang3.version>
|
||||
<commons-text.version>1.1</commons-text.version>
|
||||
<commons-beanutils.version>1.9.3</commons-beanutils.version>
|
||||
<commons-chain.version>1.2</commons-chain.version>
|
||||
<commons-csv.version>1.4</commons-csv.version>
|
||||
<assertj.version>3.6.2</assertj.version>
|
||||
<commons.io.version>2.5</commons.io.version>
|
||||
<commons.dbutils.version>1.6</commons.dbutils.version>
|
||||
<commons.collections.version>4.1</commons.collections.version>
|
||||
<org.hamcrest.java-hamcrest.version>2.0.0.0</org.hamcrest.java-hamcrest.version>
|
||||
|
@ -449,7 +449,6 @@
|
||||
<gson.version>2.8.2</gson.version>
|
||||
<cache.version>1.1.0</cache.version>
|
||||
<flink.version>1.5.0</flink.version>
|
||||
<jackson.version>2.9.7</jackson.version>
|
||||
<awaitility.version>3.0.0</awaitility.version>
|
||||
<assertj.version>3.6.2</assertj.version>
|
||||
<hazelcast.version>3.8.4</hazelcast.version>
|
||||
|
@ -52,7 +52,7 @@
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>${commons.io.version}</version>
|
||||
<version>${commons-io.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
@ -114,7 +114,6 @@
|
||||
<properties>
|
||||
<assertj.version>3.6.2</assertj.version>
|
||||
<httpclient.version>4.5.3</httpclient.version>
|
||||
<commons.io.version>2.5</commons.io.version>
|
||||
<jetty.version>9.4.8.v20171121</jetty.version>
|
||||
<netty.version>4.1.20.Final</netty.version>
|
||||
<commons.collections.version>4.1</commons.collections.version>
|
||||
|
@ -45,7 +45,7 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>${commons-lang.version}</version>
|
||||
<version>${commons-lang3.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-net</groupId>
|
||||
@ -818,7 +818,6 @@
|
||||
<crdt.version>0.1.0</crdt.version>
|
||||
<multiverse.version>0.7.0</multiverse.version>
|
||||
<cglib.version>3.2.7</cglib.version>
|
||||
<commons-lang.version>3.6</commons-lang.version>
|
||||
<jasypt.version>1.9.2</jasypt.version>
|
||||
<javatuples.version>1.2</javatuples.version>
|
||||
<javaassist.version>3.21.0-GA</javaassist.version>
|
||||
@ -826,12 +825,10 @@
|
||||
<jsonassert.version>1.5.0</jsonassert.version>
|
||||
<javers.version>3.1.0</javers.version>
|
||||
<httpclient.version>4.5.3</httpclient.version>
|
||||
<h2.version>1.4.196</h2.version>
|
||||
<jnats.version>1.0</jnats.version>
|
||||
|
||||
|
||||
<httpclient.version>4.5.3</httpclient.version>
|
||||
<jackson.version>2.9.7</jackson.version>
|
||||
<neuroph.version>2.92</neuroph.version>
|
||||
<serenity.version>1.9.26</serenity.version>
|
||||
<serenity.jbehave.version>1.41.0</serenity.jbehave.version>
|
||||
|
@ -101,7 +101,6 @@
|
||||
<log4j2.version>2.7</log4j2.version>
|
||||
<disruptor.version>3.3.6</disruptor.version>
|
||||
<jbosslogging.version>3.3.0.Final</jbosslogging.version>
|
||||
<maven-war-plugin.version>2.4</maven-war-plugin.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
|
@ -299,7 +299,6 @@
|
||||
</profiles>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<maven.resources.version>3.0.2</maven.resources.version>
|
||||
<maven.compiler.version>3.8.0</maven.compiler.version>
|
||||
<maven.surefire.version>2.22.0</maven.surefire.version>
|
||||
@ -310,6 +309,5 @@
|
||||
<resources.name>Baeldung</resources.name>
|
||||
<jetty.version>9.4.11.v20180605</jetty.version>
|
||||
<jersey.version>2.27</jersey.version>
|
||||
<junit.version>4.12</junit.version>
|
||||
</properties>
|
||||
</project>
|
@ -1,3 +0,0 @@
|
||||
### Relevant Articles:
|
||||
|
||||
- [Intro to Morphia](http://www.baeldung.com/intro-to-morphia)
|
@ -1,43 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.baeldung.morphia</groupId>
|
||||
<artifactId>morphia</artifactId>
|
||||
<name>morphia</name>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-modules</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<relativePath>..</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>dev.morphia.morphia</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>${morphia.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring-boot-maven-plugin.version}</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<spring-boot-maven-plugin.version>1.4.2.RELEASE</spring-boot-maven-plugin.version>
|
||||
<morphia.version>1.5.3</morphia.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
@ -23,14 +23,13 @@
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>${junit.jupiter.version}</version>
|
||||
<version>${junit-jupiter.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<spring.version>4.3.22.RELEASE</spring.version>
|
||||
<junit.jupiter.version>5.0.2</junit.jupiter.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
@ -23,14 +23,13 @@
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>${junit.jupiter.version}</version>
|
||||
<version>${junit-jupiter.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<spring.version>5.1.4.RELEASE</spring.version>
|
||||
<junit.jupiter.version>5.0.2</junit.jupiter.version>
|
||||
<spring-security.version>5.1.4.RELEASE</spring-security.version>
|
||||
</properties>
|
||||
|
||||
|
@ -38,6 +38,5 @@
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<intellij.annotations.version>16.0.2</intellij.annotations.version>
|
||||
<commons-lang3.version>3.5</commons-lang3.version>
|
||||
</properties>
|
||||
</project>
|
||||
|
@ -51,7 +51,6 @@
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<maven-war-plugin.version>3.0.0</maven-war-plugin.version>
|
||||
<jetty-maven-plugin.version>9.4.0.v20161208</jetty-maven-plugin.version>
|
||||
</properties>
|
||||
|
||||
|
@ -317,7 +317,6 @@
|
||||
<war.plugin.version>2.6</war.plugin.version>
|
||||
<apt-maven-plugin.version>1.1.3</apt-maven-plugin.version>
|
||||
<jandex.version>1.2.5.Final-redhat-1</jandex.version>
|
||||
<commons-lang3.version>3.5</commons-lang3.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
|
@ -4,3 +4,4 @@
|
||||
- [Persisting Maps with Hibernate](https://www.baeldung.com/hibernate-persisting-maps)
|
||||
- [Difference Between @Size, @Length, and @Column(length=value)](https://www.baeldung.com/jpa-size-length-column-differences)
|
||||
- [Hibernate Validator Specific Constraints](https://www.baeldung.com/hibernate-validator-constraints)
|
||||
- [Hibernate One to Many Annotation Tutorial](http://www.baeldung.com/hibernate-one-to-many)
|
@ -58,7 +58,7 @@
|
||||
<finalName>hibernate-mapping</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/test/resources</directory>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
|
@ -1,8 +1,9 @@
|
||||
package com.baeldung.hibernate.oneToMany.config;
|
||||
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.boot.Metadata;
|
||||
import org.hibernate.boot.MetadataSources;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
|
||||
public class HibernateAnnotationUtil {
|
||||
@ -12,16 +13,12 @@ public class HibernateAnnotationUtil {
|
||||
private static SessionFactory buildSessionFactory() {
|
||||
try {
|
||||
// Create the SessionFactory from hibernate-annotation.cfg.xml
|
||||
Configuration configuration = new Configuration();
|
||||
configuration.configure("hibernate-annotation.cfg.xml");
|
||||
System.out.println("Hibernate Annotation Configuration loaded");
|
||||
|
||||
ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()).build();
|
||||
System.out.println("Hibernate Annotation serviceRegistry created");
|
||||
|
||||
SessionFactory sessionFactory = configuration.buildSessionFactory(serviceRegistry);
|
||||
ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().configure("hibernate-annotation.cfg.xml").build();
|
||||
Metadata metadata = new MetadataSources(serviceRegistry).getMetadataBuilder().build();
|
||||
SessionFactory sessionFactory = metadata.getSessionFactoryBuilder().build();
|
||||
|
||||
return sessionFactory;
|
||||
|
||||
} catch (Throwable ex) {
|
||||
System.err.println("Initial SessionFactory creation failed." + ex);
|
||||
ex.printStackTrace();
|
@ -4,11 +4,11 @@
|
||||
"http://hibernate.org/dtd/hibernate-configuration-3.0.dtd">
|
||||
<hibernate-configuration>
|
||||
<session-factory>
|
||||
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
|
||||
<property name="hibernate.connection.password">mypassword</property>
|
||||
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/spring_hibernate_one_to_many?createDatabaseIfNotExist=true</property>
|
||||
<property name="hibernate.connection.username">myuser</property>
|
||||
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
|
||||
<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_one_to_many</property>
|
||||
<property name="hibernate.connection.username">sa</property>
|
||||
<property name="hibernate.dialect">org.hibernate.dialect.H2Dialect</property>
|
||||
<property name="hbm2ddl.auto">create</property>
|
||||
<property name="hibernate.current_session_context_class">thread</property>
|
||||
<property name="hibernate.show_sql">true</property>
|
@ -10,7 +10,7 @@ import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.dialect.HSQLDialect;
|
||||
import org.hibernate.dialect.H2Dialect;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
@ -18,6 +18,7 @@ import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.baeldung.hibernate.oneToMany.model.Cart;
|
||||
import com.baeldung.hibernate.oneToMany.model.Items;
|
||||
|
||||
@ -33,9 +34,9 @@ public class HibernateOneToManyAnnotationMainIntegrationTest {
|
||||
@BeforeClass
|
||||
public static void beforeTests() {
|
||||
Configuration configuration = new Configuration().addAnnotatedClass(Cart.class).addAnnotatedClass(Items.class)
|
||||
.setProperty("hibernate.dialect", HSQLDialect.class.getName())
|
||||
.setProperty("hibernate.connection.driver_class", org.hsqldb.jdbcDriver.class.getName())
|
||||
.setProperty("hibernate.connection.url", "jdbc:hsqldb:mem:test")
|
||||
.setProperty("hibernate.dialect", H2Dialect.class.getName())
|
||||
.setProperty("hibernate.connection.driver_class", org.h2.Driver.class.getName())
|
||||
.setProperty("hibernate.connection.url", "jdbc:h2:mem:test")
|
||||
.setProperty("hibernate.connection.username", "sa").setProperty("hibernate.connection.password", "")
|
||||
.setProperty("hibernate.hbm2ddl.auto", "update");
|
||||
ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder()
|
@ -13,3 +13,4 @@
|
||||
- [Defining JPA Entities](https://www.baeldung.com/jpa-entities)
|
||||
- [JPA @Basic Annotation](https://www.baeldung.com/jpa-basic-annotation)
|
||||
- [Default Column Values in JPA](https://www.baeldung.com/jpa-default-column-values)
|
||||
- [Persisting Enums in JPA](https://www.baeldung.com/jpa-persisting-enums-in-jpa)
|
||||
|
@ -1,40 +1,49 @@
|
||||
<?xml version="1.0"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>java-mongodb</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>java-mongodb</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<name>java-mongodb</name>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-modules</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<relativePath>../../</relativePath>
|
||||
</parent>
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-modules</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<relativePath>../../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>de.flapdoodle.embedmongo</groupId>
|
||||
<artifactId>de.flapdoodle.embedmongo</artifactId>
|
||||
<version>${flapdoodle.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mongodb</groupId>
|
||||
<artifactId>mongo-java-driver</artifactId>
|
||||
<version>${mongo.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.flapdoodle.embedmongo</groupId>
|
||||
<artifactId>de.flapdoodle.embedmongo</artifactId>
|
||||
<version>${flapdoodle.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mongodb</groupId>
|
||||
<artifactId>mongo-java-driver</artifactId>
|
||||
<version>${mongo.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
<dependency>
|
||||
<groupId>dev.morphia.morphia</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>${morphia.version}</version>
|
||||
</dependency>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<mongo.version>3.10.1</mongo.version>
|
||||
<flapdoodle.version>1.11</flapdoodle.version>
|
||||
</properties>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<mongo.version>3.10.1</mongo.version>
|
||||
<flapdoodle.version>1.11</flapdoodle.version>
|
||||
<morphia.version>1.5.3</morphia.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
|
@ -2,6 +2,7 @@ package com.baeldung.morphia;
|
||||
|
||||
import static dev.morphia.aggregation.Group.grouping;
|
||||
import static dev.morphia.aggregation.Group.push;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
@ -51,8 +52,8 @@ public class MorphiaIntegrationTest {
|
||||
.contains("Learning Java")
|
||||
.find()
|
||||
.toList();
|
||||
assertEquals(books.size(), 1);
|
||||
assertEquals(books.get(0), book);
|
||||
assertEquals(1, books.size());
|
||||
assertEquals(book, books.get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -71,8 +72,8 @@ public class MorphiaIntegrationTest {
|
||||
.contains("Learning Java")
|
||||
.find()
|
||||
.toList();
|
||||
assertEquals(books.get(0)
|
||||
.getCost(), 4.95);
|
||||
assertEquals(4.95, books.get(0)
|
||||
.getCost());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -89,7 +90,7 @@ public class MorphiaIntegrationTest {
|
||||
.contains("Learning Java")
|
||||
.find()
|
||||
.toList();
|
||||
assertEquals(books.size(), 0);
|
||||
assertEquals(0, books.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -123,7 +124,7 @@ public class MorphiaIntegrationTest {
|
||||
assertEquals(books.size(), 1);
|
||||
assertEquals("Learning Java", books.get(0)
|
||||
.getTitle());
|
||||
assertEquals(null, books.get(0)
|
||||
assertNull(books.get(0)
|
||||
.getAuthor());
|
||||
}
|
||||
|
3
persistence-modules/jpa-hibernate-cascade-type/README.md
Normal file
3
persistence-modules/jpa-hibernate-cascade-type/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
## Relevant articles:
|
||||
|
||||
- [Overview of JPA/Hibernate Cascade Types](https://www.baeldung.com/jpa-cascade-types)
|
@ -2,3 +2,4 @@
|
||||
|
||||
- [Auto-Generated Field for MongoDB using Spring Boot](https://www.baeldung.com/spring-boot-mongodb-auto-generated-field)
|
||||
- [Spring Boot Integration Testing with Embedded MongoDB](http://www.baeldung.com/spring-boot-embedded-mongodb)
|
||||
- [Upload and Retrieve Files Using MongoDB and Spring Boot](https://www.baeldung.com/spring-boot-mongodb-upload-file)
|
||||
|
@ -12,3 +12,4 @@
|
||||
- [Batch Insert/Update with Hibernate/JPA](https://www.baeldung.com/jpa-hibernate-batch-insert-update)
|
||||
- [Difference Between save() and saveAndFlush() in Spring Data JPA](https://www.baeldung.com/spring-data-jpa-save-saveandflush)
|
||||
- [Derived Query Methods in Spring Data JPA Repositories](https://www.baeldung.com/spring-data-derived-queries)
|
||||
- [LIKE Queries in Spring JPA Repositories](https://www.baeldung.com/spring-jpa-like-queries)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user