Java-1470 Split libraries module
This commit is contained in:
+11
-33
@@ -1,4 +1,4 @@
|
||||
## Libraries
|
||||
## Libraries-4
|
||||
|
||||
This module contains articles about various Java libraries.
|
||||
These are small libraries that are relatively easy to use and do not require any separate module of their own.
|
||||
@@ -8,36 +8,14 @@ The code examples related to different libraries are each in their own module.
|
||||
Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-modules) we already have separate modules. Please make sure to have a look at the existing modules in such cases.
|
||||
|
||||
### Relevant articles
|
||||
|
||||
- [Introduction to Javatuples](https://www.baeldung.com/java-tuples)
|
||||
- [Introduction to Javassist](https://www.baeldung.com/javassist)
|
||||
- [Introduction to Apache Flink with Java](https://www.baeldung.com/apache-flink)
|
||||
- [Intro to JaVers](https://www.baeldung.com/javers)
|
||||
- [Merging Streams in Java](https://www.baeldung.com/java-merge-streams)
|
||||
- [Introduction to Quartz](https://www.baeldung.com/quartz)
|
||||
- [How to Warm Up the JVM](https://www.baeldung.com/java-jvm-warmup)
|
||||
- [Software Transactional Memory in Java Using Multiverse](https://www.baeldung.com/java-multiverse-stm)
|
||||
- [Locality-Sensitive Hashing in Java Using Java-LSH](https://www.baeldung.com/locality-sensitive-hashing)
|
||||
- [Introduction to Neuroph](https://www.baeldung.com/neuroph)
|
||||
|
||||
#5
|
||||
- [Introduction to Caffeine](https://www.baeldung.com/java-caching-caffeine)
|
||||
- [Introduction to StreamEx](https://www.baeldung.com/streamex)
|
||||
- [A Docker Guide for Java](https://www.baeldung.com/docker-java-api)
|
||||
- [Introduction to Akka Actors in Java](https://www.baeldung.com/akka-actors-java)
|
||||
- [A Guide to Byte Buddy](https://www.baeldung.com/byte-buddy)
|
||||
- [Introduction to jOOL](https://www.baeldung.com/jool)
|
||||
- [Consumer Driven Contracts with Pact](https://www.baeldung.com/pact-junit-consumer-driven-contracts)
|
||||
- [Introduction to Atlassian Fugue](https://www.baeldung.com/java-fugue)
|
||||
- [Publish and Receive Messages with Nats Java Client](https://www.baeldung.com/nats-java-client)
|
||||
- [Java Concurrency Utility with JCTools](https://www.baeldung.com/java-concurrency-jc-tools)
|
||||
|
||||
#6
|
||||
- [Introduction to JavaPoet](https://www.baeldung.com/java-poet)
|
||||
- [Guide to Resilience4j](https://www.baeldung.com/resilience4j)
|
||||
- [Implementing a FTP-Client in Java](https://www.baeldung.com/java-ftp-client)
|
||||
- [Introduction to Functional Java](https://www.baeldung.com/java-functional-library)
|
||||
- [A Guide to the Reflections Library](https://www.baeldung.com/reflections-library)
|
||||
|
||||
- [Exactly Once Processing in Kafka](https://www.baeldung.com/kafka-exactly-once)
|
||||
- [Quick Guide to RSS with Rome](https://www.baeldung.com/rome-rss)
|
||||
- [Introduction to PCollections](https://www.baeldung.com/java-pcollections)
|
||||
- [Introduction to Eclipse Collections](https://www.baeldung.com/eclipse-collections)
|
||||
- [DistinctBy in the Java Stream API](https://www.baeldung.com/java-streams-distinct-by)
|
||||
- [Introduction to NoException](https://www.baeldung.com/no-exception)
|
||||
- [Spring Yarg Integration](https://www.baeldung.com/spring-yarg)
|
||||
- [Delete a Directory Recursively in Java](https://www.baeldung.com/java-delete-directory)
|
||||
- [Guide to JDeferred](https://www.baeldung.com/jdeferred)
|
||||
- [Introduction to MBassador](https://www.baeldung.com/mbassador)
|
||||
- [Using Pairs in Java](https://www.baeldung.com/java-pairs)
|
||||
- More articles [[next -->]](/libraries-2)
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
## Libraries-5
|
||||
|
||||
This module contains articles about various Java libraries.
|
||||
These are small libraries that are relatively easy to use and do not require any separate module of their own.
|
||||
|
||||
The code examples related to different libraries are each in their own module.
|
||||
|
||||
Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-modules) we already have separate modules. Please make sure to have a look at the existing modules in such cases.
|
||||
|
||||
### Relevant articles
|
||||
- [Introduction to Caffeine](https://www.baeldung.com/java-caching-caffeine)
|
||||
- [Introduction to StreamEx](https://www.baeldung.com/streamex)
|
||||
- [A Docker Guide for Java](https://www.baeldung.com/docker-java-api)
|
||||
- [Introduction to Akka Actors in Java](https://www.baeldung.com/akka-actors-java)
|
||||
- [A Guide to Byte Buddy](https://www.baeldung.com/byte-buddy)
|
||||
- [Introduction to jOOL](https://www.baeldung.com/jool)
|
||||
- [Consumer Driven Contracts with Pact](https://www.baeldung.com/pact-junit-consumer-driven-contracts)
|
||||
- [Introduction to Atlassian Fugue](https://www.baeldung.com/java-fugue)
|
||||
- [Publish and Receive Messages with Nats Java Client](https://www.baeldung.com/nats-java-client)
|
||||
- [Java Concurrency Utility with JCTools](https://www.baeldung.com/java-concurrency-jc-tools)
|
||||
- More articles [[<-- prev]](/libraries-4) [[next -->]](/libraries-6)
|
||||
+131
-1
@@ -7,9 +7,139 @@
|
||||
<groupId>com.baeldung</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>libraries-5</artifactId>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>${assertj.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jooq</groupId>
|
||||
<artifactId>jool</artifactId>
|
||||
<version>${jool.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>au.com.dius</groupId>
|
||||
<artifactId>pact-jvm-consumer-junit_2.11</artifactId>
|
||||
<version>${pact.version}</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.codehaus.groovy</groupId>
|
||||
<artifactId>groovy-all</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.typesafe.akka/akka-actor -->
|
||||
<dependency>
|
||||
<groupId>com.typesafe.akka</groupId>
|
||||
<artifactId>akka-actor_2.12</artifactId>
|
||||
<version>${typesafe-akka.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.typesafe.akka</groupId>
|
||||
<artifactId>akka-testkit_2.12</artifactId>
|
||||
<version>${typesafe-akka.version}</version>
|
||||
<scope>test</scope>
|
||||
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>one.util</groupId>
|
||||
<artifactId>streamex</artifactId>
|
||||
<version>${streamex.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.bytebuddy</groupId>
|
||||
<artifactId>byte-buddy</artifactId>
|
||||
<version>${bytebuddy.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.bytebuddy</groupId>
|
||||
<artifactId>byte-buddy-agent</artifactId>
|
||||
<version>${bytebuddy.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--Java Docker API Client -->
|
||||
<dependency>
|
||||
<groupId>com.github.docker-java</groupId>
|
||||
<artifactId>docker-java</artifactId>
|
||||
<version>${docker.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!--Java Docker API Client -->
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.ben-manes.caffeine</groupId>
|
||||
<artifactId>caffeine</artifactId>
|
||||
<version>${caffeine.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
<artifactId>jsr305</artifactId>
|
||||
<version>${findbugs.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- Atlassian Fugue -->
|
||||
<dependency>
|
||||
<groupId>io.atlassian.fugue</groupId>
|
||||
<artifactId>fugue</artifactId>
|
||||
<version>${fugue.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.nats</groupId>
|
||||
<artifactId>jnats</artifactId>
|
||||
<version>${jnats.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jctools</groupId>
|
||||
<artifactId>jctools-core</artifactId>
|
||||
<version>${jctools.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjdk.jmh</groupId>
|
||||
<artifactId>jmh-core</artifactId>
|
||||
<version>${jmh.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<pact.version>3.5.0</pact.version>
|
||||
<jool.version>0.9.12</jool.version>
|
||||
<spring.version>4.3.8.RELEASE</spring.version>
|
||||
<assertj.version>3.6.2</assertj.version>
|
||||
<typesafe-akka.version>2.5.26</typesafe-akka.version>
|
||||
<streamex.version>0.6.5</streamex.version>
|
||||
<bytebuddy.version>1.7.1</bytebuddy.version>
|
||||
<docker.version>3.0.14</docker.version>
|
||||
<caffeine.version>2.5.5</caffeine.version>
|
||||
<findbugs.version>3.0.2</findbugs.version>
|
||||
<fugue.version>4.5.1</fugue.version>
|
||||
<jnats.version>1.0</jnats.version>
|
||||
<jctools.version>2.1.2</jctools.version>
|
||||
<jmh.version>1.19</jmh.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
+11
-10
@@ -8,6 +8,7 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.*;
|
||||
@@ -65,43 +66,43 @@ public class CaffeineUnitTest {
|
||||
assertEquals("Data for " + key, dataObject.getData());
|
||||
});
|
||||
|
||||
cache.getAll(Arrays.asList("A", "B", "C")).thenAccept(dataObjectMap -> assertEquals(3, dataObjectMap.size()));
|
||||
cache.getAll(Arrays.asList("A", "B", "C")).thenAccept(dataObjectMap -> Assert.assertEquals(3, dataObjectMap.size()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenLoadingCacheWithSmallSize_whenPut_thenSizeIsConstant() {
|
||||
LoadingCache<String, DataObject> cache = Caffeine.newBuilder().maximumSize(1).refreshAfterWrite(10, TimeUnit.MINUTES).build(k -> DataObject.get("Data for " + k));
|
||||
|
||||
assertEquals(0, cache.estimatedSize());
|
||||
Assert.assertEquals(0, cache.estimatedSize());
|
||||
|
||||
cache.get("A");
|
||||
|
||||
assertEquals(1, cache.estimatedSize());
|
||||
Assert.assertEquals(1, cache.estimatedSize());
|
||||
|
||||
cache.get("B");
|
||||
cache.cleanUp();
|
||||
|
||||
assertEquals(1, cache.estimatedSize());
|
||||
Assert.assertEquals(1, cache.estimatedSize());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenLoadingCacheWithWeigher_whenPut_thenSizeIsConstant() {
|
||||
LoadingCache<String, DataObject> cache = Caffeine.newBuilder().maximumWeight(10).weigher((k, v) -> 5).build(k -> DataObject.get("Data for " + k));
|
||||
|
||||
assertEquals(0, cache.estimatedSize());
|
||||
Assert.assertEquals(0, cache.estimatedSize());
|
||||
|
||||
cache.get("A");
|
||||
|
||||
assertEquals(1, cache.estimatedSize());
|
||||
Assert.assertEquals(1, cache.estimatedSize());
|
||||
|
||||
cache.get("B");
|
||||
|
||||
assertEquals(2, cache.estimatedSize());
|
||||
Assert.assertEquals(2, cache.estimatedSize());
|
||||
|
||||
cache.get("C");
|
||||
cache.cleanUp();
|
||||
|
||||
assertEquals(2, cache.estimatedSize());
|
||||
Assert.assertEquals(2, cache.estimatedSize());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -138,7 +139,7 @@ public class CaffeineUnitTest {
|
||||
cache.get("A");
|
||||
cache.get("A");
|
||||
|
||||
assertEquals(1, cache.stats().hitCount());
|
||||
assertEquals(1, cache.stats().missCount());
|
||||
Assert.assertEquals(1, cache.stats().hitCount());
|
||||
Assert.assertEquals(1, cache.stats().missCount());
|
||||
}
|
||||
}
|
||||
+4
-2
@@ -6,6 +6,8 @@ import com.github.dockerjava.api.command.InspectContainerResponse;
|
||||
import com.github.dockerjava.api.model.Container;
|
||||
import com.github.dockerjava.api.model.PortBinding;
|
||||
import com.github.dockerjava.core.DockerClientBuilder;
|
||||
import org.hamcrest.MatcherAssert;
|
||||
import org.hamcrest.core.Is;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -51,7 +53,7 @@ public class ContainerLiveTest {
|
||||
CreateContainerResponse container = dockerClient.createContainerCmd("mongo:3.6").withCmd("--bind_ip_all").withName("mongo").withHostName("baeldung").withEnv("MONGO_LATEST_VERSION=3.6").withPortBindings(PortBinding.parse("9999:27017")).exec();
|
||||
|
||||
// then
|
||||
assertThat(container.getId(), is(not(null)));
|
||||
MatcherAssert.assertThat(container.getId(), is(not(null)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -104,7 +106,7 @@ public class ContainerLiveTest {
|
||||
// then
|
||||
InspectContainerResponse containerResponse = dockerClient.inspectContainerCmd(container.getId()).exec();
|
||||
|
||||
assertThat(containerResponse.getId(), is(container.getId()));
|
||||
MatcherAssert.assertThat(containerResponse.getId(), Is.is(container.getId()));
|
||||
}
|
||||
|
||||
@Test
|
||||
+3
-1
@@ -8,6 +8,8 @@ import com.github.dockerjava.core.DockerClientBuilder;
|
||||
import com.github.dockerjava.core.command.BuildImageResultCallback;
|
||||
import com.github.dockerjava.core.command.PullImageResultCallback;
|
||||
import com.github.dockerjava.core.command.PushImageResultCallback;
|
||||
import org.hamcrest.MatcherAssert;
|
||||
import org.hamcrest.core.Is;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -81,7 +83,7 @@ public class ImageLiveTest {
|
||||
InspectImageResponse imageResponse = dockerClient.inspectImageCmd(image.getId()).exec();
|
||||
|
||||
// then
|
||||
assertThat(imageResponse.getId(), is(image.getId()));
|
||||
MatcherAssert.assertThat(imageResponse.getId(), Is.is(image.getId()));
|
||||
}
|
||||
|
||||
@Test
|
||||
+2
-1
@@ -5,6 +5,7 @@ import com.github.dockerjava.api.command.CreateNetworkResponse;
|
||||
import com.github.dockerjava.api.model.Network;
|
||||
import com.github.dockerjava.api.model.Network.Ipam;
|
||||
import com.github.dockerjava.core.DockerClientBuilder;
|
||||
import org.hamcrest.MatcherAssert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
@@ -64,7 +65,7 @@ public class NetworkLiveTest {
|
||||
Network network = dockerClient.inspectNetworkCmd().withNetworkId(networkName).exec();
|
||||
|
||||
// then
|
||||
assertThat(network.getName(), is(networkName));
|
||||
MatcherAssert.assertThat(network.getName(), is(networkName));
|
||||
}
|
||||
|
||||
@Test
|
||||
+3
-2
@@ -5,6 +5,7 @@ import com.github.dockerjava.api.command.CreateVolumeResponse;
|
||||
import com.github.dockerjava.api.command.InspectVolumeResponse;
|
||||
import com.github.dockerjava.api.command.ListVolumesResponse;
|
||||
import com.github.dockerjava.core.DockerClientBuilder;
|
||||
import org.hamcrest.MatcherAssert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -57,7 +58,7 @@ public class VolumeLiveTest {
|
||||
CreateVolumeResponse unnamedVolume = dockerClient.createVolumeCmd().exec();
|
||||
|
||||
// then
|
||||
assertThat(unnamedVolume.getName(), is(not(null)));
|
||||
MatcherAssert.assertThat(unnamedVolume.getName(), is(not(null)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -67,7 +68,7 @@ public class VolumeLiveTest {
|
||||
CreateVolumeResponse namedVolume = dockerClient.createVolumeCmd().withName("myNamedVolume").exec();
|
||||
|
||||
// then
|
||||
assertThat(namedVolume.getName(), is(not(null)));
|
||||
MatcherAssert.assertThat(namedVolume.getName(), is(not(null)));
|
||||
}
|
||||
|
||||
@Test
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.baeldung.atlassian.fugue;
|
||||
package com.baeldung.fugue;
|
||||
|
||||
import io.atlassian.fugue.*;
|
||||
import org.junit.Assert;
|
||||
+5
-4
@@ -1,5 +1,6 @@
|
||||
package com.baeldung.jctools;
|
||||
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.jctools.queues.SpscArrayQueue;
|
||||
import org.jctools.queues.SpscChunkedArrayQueue;
|
||||
import org.junit.Test;
|
||||
@@ -44,16 +45,16 @@ public class JCToolsUnitTest {
|
||||
@Test
|
||||
public void whenQueueIsFull_thenNoMoreElementsCanBeAdded() throws InterruptedException {
|
||||
SpscChunkedArrayQueue<Integer> queue = new SpscChunkedArrayQueue<>(8, 16);
|
||||
assertThat(queue.capacity()).isEqualTo(16);
|
||||
Assertions.assertThat(queue.capacity()).isEqualTo(16);
|
||||
|
||||
CountDownLatch startConsuming = new CountDownLatch(1);
|
||||
CountDownLatch awakeProducer = new CountDownLatch(1);
|
||||
AtomicReference<Throwable> error = new AtomicReference<>();
|
||||
Thread producer = new Thread(() -> {
|
||||
IntStream.range(0, queue.capacity()).forEach(i -> {
|
||||
assertThat(queue.offer(i)).isTrue();
|
||||
Assertions.assertThat(queue.offer(i)).isTrue();
|
||||
});
|
||||
assertThat(queue.offer(queue.capacity())).isFalse();
|
||||
Assertions.assertThat(queue.offer(queue.capacity())).isFalse();
|
||||
startConsuming.countDown();
|
||||
try {
|
||||
awakeProducer.await();
|
||||
@@ -61,7 +62,7 @@ public class JCToolsUnitTest {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
assertThat(queue.offer(queue.capacity())).isTrue();
|
||||
Assertions.assertThat(queue.offer(queue.capacity())).isTrue();
|
||||
});
|
||||
producer.setUncaughtExceptionHandler((t, e) -> {
|
||||
error.set(e);
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user