Skip to content

Commit

Permalink
Java-1470 Split libraries module
Browse files Browse the repository at this point in the history
  • Loading branch information
mikr committed Apr 29, 2020
1 parent 87db41d commit 19565aa
Show file tree
Hide file tree
Showing 54 changed files with 689 additions and 438 deletions.
44 changes: 11 additions & 33 deletions libraries-4/README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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)
21 changes: 21 additions & 0 deletions libraries-5/README.md
Original file line number Diff line number Diff line change
@@ -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)
132 changes: 131 additions & 1 deletion libraries-5/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import javax.annotation.Nonnull;

import org.junit.Assert;
import org.junit.Test;

import com.github.benmanes.caffeine.cache.*;
Expand Down Expand Up @@ -65,43 +66,43 @@ public void givenAsyncLoadingCache_whenGet_thenValuePopulated() {
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
Expand Down Expand Up @@ -138,7 +139,7 @@ public void givenCache_whenStatsEnabled_thenStatsRecorded() {
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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
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;

Expand Down Expand Up @@ -51,7 +53,7 @@ public void whenCreatingContainer_thenMustReturnContainerId() {
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
Expand Down Expand Up @@ -104,7 +106,7 @@ public void whenHavingContainer_thenInspectContainer() {
// then
InspectContainerResponse containerResponse = dockerClient.inspectContainerCmd(container.getId()).exec();

assertThat(containerResponse.getId(), is(container.getId()));
MatcherAssert.assertThat(containerResponse.getId(), Is.is(container.getId()));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
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;

Expand Down Expand Up @@ -81,7 +83,7 @@ public void givenListOfImages_whenInspectImage_thenMustReturnObject() {
InspectImageResponse imageResponse = dockerClient.inspectImageCmd(image.getId()).exec();

// then
assertThat(imageResponse.getId(), is(image.getId()));
MatcherAssert.assertThat(imageResponse.getId(), Is.is(image.getId()));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
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;
Expand Down Expand Up @@ -64,7 +65,7 @@ public void whenInspectingNetwork_thenSizeMustBeGreaterThanZero() {
Network network = dockerClient.inspectNetworkCmd().withNetworkId(networkName).exec();

// then
assertThat(network.getName(), is(networkName));
MatcherAssert.assertThat(network.getName(), is(networkName));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
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;

Expand Down Expand Up @@ -57,7 +58,7 @@ public void whenCreatingUnnamedVolume_thenGetVolumeId() {
CreateVolumeResponse unnamedVolume = dockerClient.createVolumeCmd().exec();

// then
assertThat(unnamedVolume.getName(), is(not(null)));
MatcherAssert.assertThat(unnamedVolume.getName(), is(not(null)));
}

@Test
Expand All @@ -67,7 +68,7 @@ public void whenCreatingNamedVolume_thenGetVolumeId() {
CreateVolumeResponse namedVolume = dockerClient.createVolumeCmd().withName("myNamedVolume").exec();

// then
assertThat(namedVolume.getName(), is(not(null)));
MatcherAssert.assertThat(namedVolume.getName(), is(not(null)));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.baeldung.atlassian.fugue;
package com.baeldung.fugue;

import io.atlassian.fugue.*;
import org.junit.Assert;
Expand Down
Loading

0 comments on commit 19565aa

Please sign in to comment.