diff --git a/.mvn/wrapper/MavenWrapperDownloader.java b/.mvn/wrapper/MavenWrapperDownloader.java
new file mode 100644
index 0000000..fa4f7b4
--- /dev/null
+++ b/.mvn/wrapper/MavenWrapperDownloader.java
@@ -0,0 +1,110 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+*/
+
+import java.net.*;
+import java.io.*;
+import java.nio.channels.*;
+import java.util.Properties;
+
+public class MavenWrapperDownloader {
+
+ /**
+ * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
+ */
+ private static final String DEFAULT_DOWNLOAD_URL =
+ "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar";
+
+ /**
+ * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
+ * use instead of the default one.
+ */
+ private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
+ ".mvn/wrapper/maven-wrapper.properties";
+
+ /**
+ * Path where the maven-wrapper.jar will be saved to.
+ */
+ private static final String MAVEN_WRAPPER_JAR_PATH =
+ ".mvn/wrapper/maven-wrapper.jar";
+
+ /**
+ * Name of the property which should be used to override the default download url for the wrapper.
+ */
+ private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
+
+ public static void main(String args[]) {
+ System.out.println("- Downloader started");
+ File baseDirectory = new File(args[0]);
+ System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
+
+ // If the maven-wrapper.properties exists, read it and check if it contains a custom
+ // wrapperUrl parameter.
+ File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
+ String url = DEFAULT_DOWNLOAD_URL;
+ if(mavenWrapperPropertyFile.exists()) {
+ FileInputStream mavenWrapperPropertyFileInputStream = null;
+ try {
+ mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
+ Properties mavenWrapperProperties = new Properties();
+ mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
+ url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
+ } catch (IOException e) {
+ System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
+ } finally {
+ try {
+ if(mavenWrapperPropertyFileInputStream != null) {
+ mavenWrapperPropertyFileInputStream.close();
+ }
+ } catch (IOException e) {
+ // Ignore ...
+ }
+ }
+ }
+ System.out.println("- Downloading from: : " + url);
+
+ File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
+ if(!outputFile.getParentFile().exists()) {
+ if(!outputFile.getParentFile().mkdirs()) {
+ System.out.println(
+ "- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'");
+ }
+ }
+ System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
+ try {
+ downloadFileFromURL(url, outputFile);
+ System.out.println("Done");
+ System.exit(0);
+ } catch (Throwable e) {
+ System.out.println("- Error downloading");
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+
+ private static void downloadFileFromURL(String urlString, File destination) throws Exception {
+ URL website = new URL(urlString);
+ ReadableByteChannel rbc;
+ rbc = Channels.newChannel(website.openStream());
+ FileOutputStream fos = new FileOutputStream(destination);
+ fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
+ fos.close();
+ rbc.close();
+ }
+
+}
diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties
new file mode 100644
index 0000000..cd0d451
--- /dev/null
+++ b/.mvn/wrapper/maven-wrapper.properties
@@ -0,0 +1 @@
+distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip
diff --git a/.travis.yml b/.travis.yml
index 0b3f6c0..552dd25 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,7 +2,7 @@
language: java
jdk:
- - oraclejdk8
+ - openjdk11
install:
mvn --settings .settings.xml install -DskipTests=true -Dmaven.javadoc.skip=true -Dgpg.skip -B -V
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8f60d13..c1c4724 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -21,6 +21,29 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Add handshake error handling (exceptions? error logs?).
- Turn on checkstyle JavaDocs module.
- Add updates to the protocol, like new `ControlMessage`.
+- Do we really need `ErlangInteger.cache` methods?
+- Add atom's table equivalent.
+
+## [2.0.0](https://github.com/appulse-projects/encon-java/releases/tag/2.0.0) - 2018-10-14
+
+### Changed
+
+- Module `encon-config` now is a configuration framework for laoding, dumping and mapping different configurations and a fancy and flexible way;
+- According to the new `encon-config` implementation, all configurations were moved to the appropriate modules.
+
+## [1.6.7](https://github.com/appulse-projects/encon-java/releases/tag/1.6.7) - 2018-10-07
+
+### Changed
+
+- Quick fix for [GitHub issue](https://github.com/appulse-projects/encon-java/issues/13), removed `ErlangPid` and `EralngAtom` caches.
+
+## [1.6.6](https://github.com/appulse-projects/encon-java/releases/tag/1.6.6) - 2018-10-02
+
+### Changed
+
+- Quick fix for [GitHub issue](https://github.com/appulse-projects/encon-java/issues/11), refactored `ErlangInteger` cache;
+
+- Correctly setup `checkstyle`/`epmd`/`findbugs` validation phases.
## [1.6.5](https://github.com/appulse-projects/encon-java/releases/tag/1.6.5) - 2018-09-28
diff --git a/README.md b/README.md
index 5c1c775..4b2c6fd 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,11 @@
# Overview
[](https://travis-ci.org/appulse-projects/encon-java)
-[](https://maven-badges.herokuapp.com/maven-central/io.appulse.encon/encon)
+[](https://search.maven.org/search?q=g:io.appulse.encon)
+[](http://www.apache.org/licenses/LICENSE-2.0.html)
+
+
+
Java implementation of **E**rlang **N**ode **CON**nector (using Eralng Distribution Protocol). For more information, visit the [site](https://appulse.io).
@@ -46,7 +50,7 @@ $> mvn clean compile
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
-[INFO] encon 1.6.5 ........................................ SUCCESS [ 1.210 s]
+[INFO] encon 2.0.0 ........................................ SUCCESS [ 1.210 s]
[INFO] encon-common ....................................... SUCCESS [ 25.693 s]
[INFO] encon-terms ........................................ SUCCESS [ 27.517 s]
[INFO] encon-config ....................................... SUCCESS [ 18.707 s]
@@ -64,7 +68,7 @@ $> mvn clean compile
[INFO] handler-advanced ................................... SUCCESS [ 11.289 s]
[INFO] load-config ........................................ SUCCESS [ 3.725 s]
[INFO] load-config-spring ................................. SUCCESS [ 6.420 s]
-[INFO] benchmark 1.6.5 .................................... SUCCESS [ 5.594 s]
+[INFO] benchmark 2.0.0 .................................... SUCCESS [ 5.594 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
diff --git a/benchmark/README.md b/benchmark/README.md
index 01ccce5..1cf381c 100644
--- a/benchmark/README.md
+++ b/benchmark/README.md
@@ -37,9 +37,9 @@ H/W path Device Class Description
* **JMH version:** 1.21
-* **VM version:** JDK 1.8.0_181, Java HotSpot(TM) 64-Bit Server VM, 25.181-b13
+* **VM version:** JDK 11.0.1, OpenJDK 64-Bit Server VM, 11.0.1+13
-* **VM options:** -Xms1G -Xmx2G
+* **VM options:** -Xms3G -Xmx4G
* **Warmup:** 10 iterations, 10 s each
@@ -59,14 +59,14 @@ The installation consist of a server node at separate thread, which echoes the m
| implementation | clients | score | error | units |
|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-------:|------------:|------------:|:------|
-| [encon](https://github.com/appulse-projects/encon-java/blob/master/benchmark/src/main/java/io/appulse/encon/benchmark/Encon_Node2NodeBenchmarks.java#L130) | 1 | `11679.266` | `414.090` | ops/s |
-| [jinterface](https://github.com/appulse-projects/encon-java/blob/master/benchmark/src/main/java/io/appulse/encon/benchmark/JInterface_Node2NodeBenchmarks.java#L109) | 1 | `11862.914` | `385.573` | ops/s |
-| [encon](https://github.com/appulse-projects/encon-java/blob/master/benchmark/src/main/java/io/appulse/encon/benchmark/Encon_Node2NodeBenchmarks.java#L138) | 2 | `22337.500` | `918.292` | ops/s |
-| [jinterface](https://github.com/appulse-projects/encon-java/blob/master/benchmark/src/main/java/io/appulse/encon/benchmark/JInterface_Node2NodeBenchmarks.java#L117) | 2 | `18217.878` | `861.270` | ops/s |
-| [encon](https://github.com/appulse-projects/encon-java/blob/master/benchmark/src/main/java/io/appulse/encon/benchmark/Encon_Node2NodeBenchmarks.java#L146) | 4 | `36001.870` | `2033.472` | ops/s |
-| [jinterface](https://github.com/appulse-projects/encon-java/blob/master/benchmark/src/main/java/io/appulse/encon/benchmark/JInterface_Node2NodeBenchmarks.java#L125) | 4 | `23202.485` | `1295.186` | ops/s |
-| [encon](https://github.com/appulse-projects/encon-java/blob/master/benchmark/src/main/java/io/appulse/encon/benchmark/Encon_Node2NodeBenchmarks.java#L154) | 8 | `44742.858` | `1865.853` | ops/s |
-| [jinterface](https://github.com/appulse-projects/encon-java/blob/master/benchmark/src/main/java/io/appulse/encon/benchmark/JInterface_Node2NodeBenchmarks.java#L133) | 8 | `23495.184` | `671.766` | ops/s |
+| [encon](https://github.com/appulse-projects/encon-java/blob/master/benchmark/src/main/java/io/appulse/encon/benchmark/Encon_Node2NodeBenchmarks.java#L130) | 1 | `13404.955` | `832.219` | ops/s |
+| [jinterface](https://github.com/appulse-projects/encon-java/blob/master/benchmark/src/main/java/io/appulse/encon/benchmark/JInterface_Node2NodeBenchmarks.java#L109) | 1 | `11382.375` | `358.907` | ops/s |
+| [encon](https://github.com/appulse-projects/encon-java/blob/master/benchmark/src/main/java/io/appulse/encon/benchmark/Encon_Node2NodeBenchmarks.java#L138) | 2 | `21676.979` | `654.934` | ops/s |
+| [jinterface](https://github.com/appulse-projects/encon-java/blob/master/benchmark/src/main/java/io/appulse/encon/benchmark/JInterface_Node2NodeBenchmarks.java#L117) | 2 | `18982.318` | `395.596` | ops/s |
+| [encon](https://github.com/appulse-projects/encon-java/blob/master/benchmark/src/main/java/io/appulse/encon/benchmark/Encon_Node2NodeBenchmarks.java#L146) | 4 | `33532.304` | `609.782` | ops/s |
+| [jinterface](https://github.com/appulse-projects/encon-java/blob/master/benchmark/src/main/java/io/appulse/encon/benchmark/JInterface_Node2NodeBenchmarks.java#L125) | 4 | `23027.511` | `327.508` | ops/s |
+| [encon](https://github.com/appulse-projects/encon-java/blob/master/benchmark/src/main/java/io/appulse/encon/benchmark/Encon_Node2NodeBenchmarks.java#L154) | 8 | `48659.749` | `572.108` | ops/s |
+| [jinterface](https://github.com/appulse-projects/encon-java/blob/master/benchmark/src/main/java/io/appulse/encon/benchmark/JInterface_Node2NodeBenchmarks.java#L133) | 8 | `25457.217` | `295.665` | ops/s |
### Mailbox to mailbox
@@ -74,31 +74,38 @@ In this test we have only one node and two mailboxes which send the message to e
| implementation | score | error | units |
|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------:|------------:|:------|
-| [encon](https://github.com/appulse-projects/encon-java/blob/master/benchmark/src/main/java/io/appulse/encon/benchmark/Encon_SimpleBenchmarks.java#L57) | `4080746.356` | `79809.419` | ops/s |
-| [jinterface](https://github.com/appulse-projects/encon-java/blob/master/benchmark/src/main/java/io/appulse/encon/benchmark/JInterface_SimpleBenchmarks.java#L51) | `4885380.490` | `61920.971` | ops/s |
+| [encon](https://github.com/appulse-projects/encon-java/blob/master/benchmark/src/main/java/io/appulse/encon/benchmark/Encon_SimpleBenchmarks.java#L57) | `2906135.871` | `46718.600` | ops/s |
+| [jinterface](https://github.com/appulse-projects/encon-java/blob/master/benchmark/src/main/java/io/appulse/encon/benchmark/JInterface_SimpleBenchmarks.java#L51) | `3388805.729` | `10400.968` | ops/s |
## How to setup the environment
-1. Add Java repository:
+1. Update and upgrade the distro:
```bash
-$> sudo add-apt-repository --yes ppa:webupd8team/java
+$> sudo apt-get update --yes && sudo apt-get upgrade --yes
```
-2. Update and upgrade the distro:
+2. Install `git`, `curl`, `zip` and `unzip`:
```bash
-$> sudo apt-get update --yes && sudo apt-get upgrade --yes
+$> sudo apt-get install --yes git curl zip unzip
+```
+
+3. Install `sdkman`:
+
+```bash
+$> curl -s "https://get.sdkman.io" | bash
+$> source "$HOME/.sdkman/bin/sdkman-init.sh"
```
-3. Install `Git`, `Java 8` and `Maven`:
+4. Install `Java`:
```bash
-$> sudo apt-get install --yes oracle-java8-installer git maven
+$> sdk install java 11.0.1-open
```
-4. Clone the repo:
+5. Clone the repo:
```bash
$> git clone https://github.com/appulse-projects/encon-java.git
@@ -115,7 +122,7 @@ $> cd encon-java
2. Build the project with only needed dependencies:
```bash
-$> mvn clean package \
+$> ./mvnw clean package \
-DskipTests \
-Dgpg.skip \
-Dfindbugs.skip=true \
@@ -128,18 +135,20 @@ $> mvn clean package \
3. Run the tests
```bash
-$> nohup java -Xms1G -Xmx2G -jar benchmark/target/benchmarks.jar > job.logs 2>&1 &
+$> nohup java -Xms3G -Xmx4G -jar benchmark/target/benchmarks.jar > job.logs 2>&1 &
```
### One-liner
```bash
-$> sudo add-apt-repository --yes ppa:webupd8team/java && \
- sudo apt-get update --yes && sudo apt-get upgrade --yes && \
- sudo apt-get install --yes oracle-java8-installer git maven && \
+$> sudo apt-get update --yes && sudo apt-get upgrade --yes && \
+ sudo apt-get install --yes git curl zip unzip && \
+ curl -s "https://get.sdkman.io" | bash && \
+ source "$HOME/.sdkman/bin/sdkman-init.sh" && \
+ sdk install java 11.0.1-open && \
git clone https://github.com/appulse-projects/encon-java.git && \
cd encon-java && \
- mvn clean package \
+ ./mvnw clean package \
-DskipTests \
-Dgpg.skip \
-Dfindbugs.skip=true \
@@ -147,5 +156,5 @@ $> sudo add-apt-repository --yes ppa:webupd8team/java && \
-Dcheckstyle.skip \
-Dmaven.test.skip=true \
-pl benchmark -am && \
- nohup java -Xms1G -Xmx2G -jar benchmark/target/benchmarks.jar > job.logs 2>&1 &
+ nohup java -Xms3G -Xmx4G -jar benchmark/target/benchmarks.jar > job.logs 2>&1 &
```
diff --git a/benchmark/pom.xml b/benchmark/pom.xml
index 2066446..350ba29 100644
--- a/benchmark/pom.xml
+++ b/benchmark/pom.xml
@@ -25,20 +25,12 @@ limitations under the License.
io.appulse.enconencon-parent
- 1.6.5
+ 2.0.0benchmarkjar
-
- UTF-8
- UTF-8
-
- 1.8
- 1.8
-
-
io.appulse.epmd.java
@@ -55,12 +47,6 @@ limitations under the License.
jinterface
-
- org.projectlombok
- lombok
- provided
-
-
org.openjdk.jmhjmh-core
@@ -75,20 +61,10 @@ limitations under the License.
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.1
-
- ${maven.compiler.target}
- ${maven.compiler.source}
- ${maven.compiler.target}
-
- org.apache.maven.pluginsmaven-shade-plugin
- 2.2
+ 3.2.1package
diff --git a/benchmark/src/main/java/io/appulse/encon/benchmark/Encon_Node2NodeBenchmarks.java b/benchmark/src/main/java/io/appulse/encon/benchmark/Encon_Node2NodeBenchmarks.java
index 374dbe9..0ed7a3c 100644
--- a/benchmark/src/main/java/io/appulse/encon/benchmark/Encon_Node2NodeBenchmarks.java
+++ b/benchmark/src/main/java/io/appulse/encon/benchmark/Encon_Node2NodeBenchmarks.java
@@ -27,8 +27,8 @@
import io.appulse.encon.Node;
import io.appulse.encon.Nodes;
-import io.appulse.encon.config.NodeConfig;
-import io.appulse.encon.config.ServerConfig;
+import io.appulse.encon.NodesConfig.NodeConfig;
+import io.appulse.encon.NodesConfig.NodeConfig.ServerConfig;
import io.appulse.encon.mailbox.Mailbox;
import io.appulse.encon.terms.ErlangTerm;
import io.appulse.encon.terms.type.ErlangPid;
diff --git a/benchmark/src/main/java/io/appulse/encon/benchmark/Encon_SimpleBenchmarks.java b/benchmark/src/main/java/io/appulse/encon/benchmark/Encon_SimpleBenchmarks.java
index f5072ee..c249cdb 100644
--- a/benchmark/src/main/java/io/appulse/encon/benchmark/Encon_SimpleBenchmarks.java
+++ b/benchmark/src/main/java/io/appulse/encon/benchmark/Encon_SimpleBenchmarks.java
@@ -25,8 +25,8 @@
import io.appulse.encon.Node;
import io.appulse.encon.Nodes;
-import io.appulse.encon.config.NodeConfig;
-import io.appulse.encon.config.ServerConfig;
+import io.appulse.encon.NodesConfig.NodeConfig;
+import io.appulse.encon.NodesConfig.NodeConfig.ServerConfig;
import io.appulse.encon.connection.regular.Message;
import io.appulse.encon.mailbox.Mailbox;
import io.appulse.encon.terms.ErlangTerm;
diff --git a/encon-common/README.md b/encon-common/README.md
index 780dbd7..72923eb 100644
--- a/encon-common/README.md
+++ b/encon-common/README.md
@@ -1,3 +1,11 @@
# Overview
+[](https://travis-ci.org/appulse-projects/encon-java)
+[](https://search.maven.org/search?q=a:encon-common)
+[](http://www.apache.org/licenses/LICENSE-2.0.html)
+[](http://www.javadoc.io/doc/io.appulse.encon/encon-common)
+
+
+
+
Encon's common classes for all subprojects.
diff --git a/encon-common/pom.xml b/encon-common/pom.xml
index b41a7b9..5b7888c 100644
--- a/encon-common/pom.xml
+++ b/encon-common/pom.xml
@@ -25,45 +25,17 @@ limitations under the License.
io.appulse.enconencon-parent
- 1.6.5
+ 2.0.0encon-commonjar
-
- org.projectlombok
- lombok
- provided
-
-
io.appulse.epmd.javacore
-
-
- com.google.code.findbugs
- annotations
- provided
-
-
- com.google.code.findbugs
- jsr305
- provided
-
-
-
- junit
- junit
- test
-
-
- org.assertj
- assertj-core
- test
-
@@ -78,14 +50,13 @@ limitations under the License.
- org.codehaus.mojo
- findbugs-maven-plugin
+ com.github.spotbugs
+ spotbugs-maven-pluginorg.apache.maven.pluginsmaven-pmd-plugin
-
org.apache.maven.pluginsmaven-checkstyle-plugin
diff --git a/encon-common/src/main/java/io/appulse/encon/common/NodeDescriptor.java b/encon-common/src/main/java/io/appulse/encon/common/NodeDescriptor.java
index 0ba31ed..e67de2e 100644
--- a/encon-common/src/main/java/io/appulse/encon/common/NodeDescriptor.java
+++ b/encon-common/src/main/java/io/appulse/encon/common/NodeDescriptor.java
@@ -26,6 +26,7 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Stream;
+import edu.umd.cs.findbugs.annotations.SuppressWarnings;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
@@ -185,6 +186,7 @@ public static boolean removeFromCache (@NonNull NodeDescriptor descriptor) {
private static NodeDescriptor getFromCacheOrCreateNew (@NonNull String node) {
val atIndex = node.indexOf('@');
+ @SuppressWarnings("PMD.LinguisticNaming")
val isShortName = atIndex < 0 || node.indexOf('.', atIndex) < 0;
return getFromCacheOrCreateNew(node, isShortName);
}
diff --git a/encon-common/src/test/java/io/appulse/encon/common/DistributionFlagTest.java b/encon-common/src/test/java/io/appulse/encon/common/DistributionFlagTest.java
index 6b0ee46..3975219 100644
--- a/encon-common/src/test/java/io/appulse/encon/common/DistributionFlagTest.java
+++ b/encon-common/src/test/java/io/appulse/encon/common/DistributionFlagTest.java
@@ -23,38 +23,46 @@
import java.util.stream.Stream;
-import io.appulse.utils.test.TestMethodNamePrinter;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestRule;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
/**
*
* @author Artem Labazin
* @since 1.0.0
*/
-public class DistributionFlagTest {
+@DisplayName("Check distribution flags enum")
+class DistributionFlagTest {
- @Rule
- public TestRule watcher = new TestMethodNamePrinter();
+ @BeforeEach
+ void beforeEach (TestInfo testInfo) {
+ System.out.println("- " + testInfo.getDisplayName());
+ }
@Test
- public void parse () {
+ @DisplayName("check if distribution flag's code could be converted to its enum value")
+ void couldConvert () {
Stream.of(DistributionFlag.values()).forEach(it -> {
assertThat(DistributionFlag.parse(it.getCode()))
.hasSize(1)
.first()
.isEqualTo(it);
});
+ }
+ @Test
+ @DisplayName("unfold integer to set of distribution flags")
+ void unfold () {
assertThat(DistributionFlag.parse(262_147))
.hasSize(3)
.contains(PUBLISHED, ATOM_CACHE, BIG_CREATION);
}
@Test
- public void bitwiseOr () {
+ @DisplayName("fold enum values to integer")
+ void fold () {
assertThat(DistributionFlag.bitwiseOr(PUBLISHED, ATOM_CACHE, BIG_CREATION))
.isEqualTo(262_147);
}
diff --git a/encon-common/src/test/java/io/appulse/encon/common/NodeDescriptorTest.java b/encon-common/src/test/java/io/appulse/encon/common/NodeDescriptorTest.java
index 8db6b81..eaa8586 100644
--- a/encon-common/src/test/java/io/appulse/encon/common/NodeDescriptorTest.java
+++ b/encon-common/src/test/java/io/appulse/encon/common/NodeDescriptorTest.java
@@ -20,25 +20,28 @@
import java.net.InetAddress;
-import io.appulse.utils.test.TestMethodNamePrinter;
-
import org.assertj.core.api.SoftAssertions;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestRule;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
/**
*
* @author Artem Labazin
* @since 1.0.0
*/
-public class NodeDescriptorTest {
+@DisplayName("Check node descriptor")
+class NodeDescriptorTest {
- @Rule
- public TestRule watcher = new TestMethodNamePrinter();
+ @BeforeEach
+ void beforeEach (TestInfo testInfo) {
+ System.out.println("- " + testInfo.getDisplayName());
+ }
@Test
- public void fullShortName () throws Exception {
+ @DisplayName("parse short node's name with localhost host")
+ void fullShortName () throws Exception {
InetAddress address = InetAddress.getByName("localhost");
String fullName = "popa@localhost";
NodeDescriptor.removeFromCache(fullName);
@@ -72,7 +75,8 @@ public void fullShortName () throws Exception {
}
@Test
- public void shortName () throws Exception {
+ @DisplayName("parse short node's name without host")
+ void shortName () throws Exception {
InetAddress address = InetAddress.getLoopbackAddress();
String tmp = InetAddress.getLocalHost().getHostName();
int dotIndex = tmp.indexOf('.');
@@ -112,7 +116,8 @@ public void shortName () throws Exception {
}
@Test
- public void fullLongName () throws Exception {
+ @DisplayName("parse full node's name with host")
+ void fullLongName () throws Exception {
InetAddress address = InetAddress.getByName("localhost");
String fullName = "popa@localhost";
NodeDescriptor.removeFromCache(fullName);
diff --git a/encon-config/README.md b/encon-config/README.md
index 0e2c281..05e36d7 100644
--- a/encon-config/README.md
+++ b/encon-config/README.md
@@ -1,5 +1,13 @@
# Overview
+[](https://travis-ci.org/appulse-projects/encon-java)
+[](https://search.maven.org/search?q=a:encon-config)
+[](http://www.apache.org/licenses/LICENSE-2.0.html)
+[](http://www.javadoc.io/doc/io.appulse.encon/encon-config)
+
+
+
+
Encon's configuration classes.
## Usage
@@ -14,7 +22,7 @@ First of all, add config's dependency:
io.appulse.enconencon-config
- 1.6.5
+ 2.0.0
...
@@ -23,7 +31,7 @@ First of all, add config's dependency:
**Gradle**:
```groovy
-compile 'io.appulse.encon:encon-config:1.6.5'
+compile 'io.appulse.encon:encon-config:2.0.0'
```
### File based configuration
diff --git a/encon-config/pom.xml b/encon-config/pom.xml
index 71aa168..dd4ee74 100644
--- a/encon-config/pom.xml
+++ b/encon-config/pom.xml
@@ -25,53 +25,21 @@ limitations under the License.
io.appulse.enconencon-parent
- 1.6.5
+ 2.0.0encon-configjar
-
- org.projectlombok
- lombok
- provided
-
-
-
- io.appulse.epmd.java
- client
-
-
- ${project.groupId}
- encon-common
- ${project.version}
- org.yamlsnakeyaml
- 1.21
-
-
-
- com.google.code.findbugs
- annotations
- provided
-
-
- com.google.code.findbugs
- jsr305
- provided
- junit
- junit
- test
-
-
- org.assertj
- assertj-core
+ io.appulse
+ utils-javatest
@@ -88,14 +56,13 @@ limitations under the License.
- org.codehaus.mojo
- findbugs-maven-plugin
+ com.github.spotbugs
+ spotbugs-maven-pluginorg.apache.maven.pluginsmaven-pmd-plugin
-
org.apache.maven.pluginsmaven-checkstyle-plugin
diff --git a/encon-config/src/main/java/io/appulse/encon/config/AbstractConfig.java b/encon-config/src/main/java/io/appulse/encon/config/AbstractConfig.java
new file mode 100644
index 0000000..60a47de
--- /dev/null
+++ b/encon-config/src/main/java/io/appulse/encon/config/AbstractConfig.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2018 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.appulse.encon.config;
+
+import static io.appulse.encon.config.ConfigTree.NodeType.LIST;
+import static java.nio.file.StandardOpenOption.CREATE;
+import static java.util.Locale.US;
+import static java.util.Optional.empty;
+import static java.util.Optional.ofNullable;
+
+import java.io.OutputStream;
+import java.io.Writer;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Properties;
+
+import io.appulse.encon.config.ConfigTree.ConfigNode;
+import io.appulse.encon.config.ConfigTree.ConfigNodeList;
+import io.appulse.encon.config.ConfigTree.ConfigNodeMap;
+
+import lombok.Cleanup;
+import lombok.NonNull;
+import lombok.SneakyThrows;
+import org.yaml.snakeyaml.Yaml;
+
+/**
+ *
+ * @author Artem Labazin
+ * @since 2.0.0
+ */
+abstract class AbstractConfig implements Config {
+
+ @Override
+ @SneakyThrows
+ public void dumpTo (@NonNull Path path) {
+ if (Files.notExists(path)) {
+ Files.createFile(path);
+ }
+
+ Map map = getConfigTree().toMap();
+ @Cleanup Writer writer = Files.newBufferedWriter(path, CREATE);
+
+ String fileName = path.toString().toLowerCase(US);
+ if (fileName.endsWith(".yml") || fileName.endsWith(".yaml")) {
+ Yaml yaml = new Yaml();
+ yaml.dump(map, writer);
+ return;
+ }
+
+ Properties properties = new Properties();
+ properties.putAll(map);
+
+ if (fileName.endsWith(".properties")) {
+ properties.store(writer, fileName);
+ } else if (fileName.endsWith(".xml")) {
+ @Cleanup OutputStream outputStream = Files.newOutputStream(path);
+ properties.storeToXML(outputStream, fileName, fileName);
+ } else {
+ throw new UnsupportedOperationException("Unsupported file extension " + fileName);
+ }
+ }
+
+ @Override
+ public boolean containsKey (@NonNull String key) {
+ return getConfigTree().containsKey(key);
+ }
+
+ @Override
+ public Optional get (String key, @NonNull Class type) {
+ ConfigNode node = getConfigTree().get(key);
+ if (node == null) {
+ return empty();
+ }
+ T result = ConfigNodeMapping.map(node, type);
+ return ofNullable(result);
+ }
+
+ @Override
+ public Optional> getList (@NonNull String key, @NonNull Class type) {
+ ConfigNode node = getConfigTree().get(key);
+ if (node == null || node.getType() != LIST) {
+ return empty();
+ }
+ List result = ConfigNodeMapping.toGenericList((ConfigNodeList) node, type);
+ return ofNullable(result);
+ }
+
+ @Override
+ public Optional
- org.codehaus.mojo
- findbugs-maven-plugin
+ com.github.spotbugs
+ spotbugs-maven-pluginorg.apache.maven.pluginsmaven-pmd-plugin
-
org.apache.maven.pluginsmaven-checkstyle-plugin
diff --git a/encon-databind/src/main/java/io/appulse/encon/databind/deserializer/PojoDeserializerBinary.java b/encon-databind/src/main/java/io/appulse/encon/databind/deserializer/PojoDeserializerBinary.java
index f57fce8..0282d08 100644
--- a/encon-databind/src/main/java/io/appulse/encon/databind/deserializer/PojoDeserializerBinary.java
+++ b/encon-databind/src/main/java/io/appulse/encon/databind/deserializer/PojoDeserializerBinary.java
@@ -25,7 +25,7 @@
* Eralng's term binary deserializer to specified type.
*
* @since 1.1.0
- * @author alabazin
+ * @author Artem Labazin
*/
public class PojoDeserializerBinary implements Deserializer {
diff --git a/encon-databind/src/main/java/io/appulse/encon/databind/parser/PojoDescriptor.java b/encon-databind/src/main/java/io/appulse/encon/databind/parser/PojoDescriptor.java
index 7d957df..c219c3b 100644
--- a/encon-databind/src/main/java/io/appulse/encon/databind/parser/PojoDescriptor.java
+++ b/encon-databind/src/main/java/io/appulse/encon/databind/parser/PojoDescriptor.java
@@ -46,4 +46,7 @@ public final class PojoDescriptor {
public String getName () {
return type.getSimpleName();
}
+
+ public static class PojoDescriptorBuilder {
+ }
}
diff --git a/encon-databind/src/main/java/io/appulse/encon/databind/serializer/PojoSerializerAbstractCollection.java b/encon-databind/src/main/java/io/appulse/encon/databind/serializer/PojoSerializerAbstractCollection.java
index 286bf5a..9ce528c 100644
--- a/encon-databind/src/main/java/io/appulse/encon/databind/serializer/PojoSerializerAbstractCollection.java
+++ b/encon-databind/src/main/java/io/appulse/encon/databind/serializer/PojoSerializerAbstractCollection.java
@@ -26,7 +26,7 @@
* Abstract collection serializer.
*
* @since 1.1.0
- * @author alabazin
+ * @author Artem Labazin
*/
abstract class PojoSerializerAbstractCollection implements Serializer {
diff --git a/encon-databind/src/main/java/io/appulse/encon/databind/serializer/PojoSerializerBinary.java b/encon-databind/src/main/java/io/appulse/encon/databind/serializer/PojoSerializerBinary.java
index 2f380f6..089b3d7 100644
--- a/encon-databind/src/main/java/io/appulse/encon/databind/serializer/PojoSerializerBinary.java
+++ b/encon-databind/src/main/java/io/appulse/encon/databind/serializer/PojoSerializerBinary.java
@@ -30,7 +30,7 @@
* POJO's serializer into Erlang's binary.
*
* @since 1.1.0
- * @author alabazin
+ * @author Artem Labazin
*/
public class PojoSerializerBinary implements Serializer {
diff --git a/encon-databind/src/test/java/io/appulse/encon/databind/TermMapperDifferentWrappersTest.java b/encon-databind/src/test/java/io/appulse/encon/databind/TermMapperDifferentWrappersTest.java
index abf9903..3a2a48e 100644
--- a/encon-databind/src/test/java/io/appulse/encon/databind/TermMapperDifferentWrappersTest.java
+++ b/encon-databind/src/test/java/io/appulse/encon/databind/TermMapperDifferentWrappersTest.java
@@ -27,21 +27,33 @@
import io.appulse.encon.databind.annotation.AsErlangList;
import io.appulse.encon.databind.annotation.AsErlangMap;
import io.appulse.encon.databind.annotation.AsErlangTuple;
+
import java.io.Serializable;
+
import lombok.experimental.FieldDefaults;
import lombok.val;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
/**
*
* @since 1.1.0
* @author Artem Labazin
*/
+@DisplayName("Different term wrappers tests")
@FieldDefaults(level = PRIVATE, makeFinal = true)
-public class TermMapperDifferentWrappersTest {
+class TermMapperDifferentWrappersTest {
+
+ @BeforeEach
+ void beforeEach (TestInfo testInfo) {
+ System.out.println("- " + testInfo.getDisplayName());
+ }
@Test
- public void defaultWrapper () {
+ @DisplayName("default wrapper")
+ void defaultWrapper () {
val erlangTerm = TermMapper.serialize(new DefaultWrapper());
assertThat(erlangTerm.getType())
.isEqualTo(SMALL_TUPLE);
@@ -51,7 +63,8 @@ public void defaultWrapper () {
}
@Test
- public void listWrapper () {
+ @DisplayName("list wrapper")
+ void listWrapper () {
val erlangTerm = TermMapper.serialize(new ListWrapper());
assertThat(erlangTerm.getType())
.isEqualTo(LIST);
@@ -61,7 +74,8 @@ public void listWrapper () {
}
@Test
- public void tupleWrapper () {
+ @DisplayName("tuple wrapper")
+ void tupleWrapper () {
val erlangTerm = TermMapper.serialize(new TupleWrapper());
assertThat(erlangTerm.getType())
.isEqualTo(SMALL_TUPLE);
@@ -71,7 +85,8 @@ public void tupleWrapper () {
}
@Test
- public void mapWrapper () {
+ @DisplayName("map wrapper")
+ void mapWrapper () {
val erlangTerm = TermMapper.serialize(new MapWrapper());
assertThat(erlangTerm.getType())
.isEqualTo(MAP);
@@ -81,7 +96,8 @@ public void mapWrapper () {
}
@Test
- public void binaryWrapper () {
+ @DisplayName("binary wrapper")
+ void binaryWrapper () {
val erlangTerm = TermMapper.serialize(new BinaryWrapper());
assertThat(erlangTerm.getType())
.isEqualTo(BINARY);
diff --git a/encon-databind/src/test/java/io/appulse/encon/databind/TermMapperTest.java b/encon-databind/src/test/java/io/appulse/encon/databind/TermMapperTest.java
index 753b694..f32987c 100644
--- a/encon-databind/src/test/java/io/appulse/encon/databind/TermMapperTest.java
+++ b/encon-databind/src/test/java/io/appulse/encon/databind/TermMapperTest.java
@@ -38,18 +38,28 @@
import lombok.NoArgsConstructor;
import lombok.experimental.FieldDefaults;
import lombok.val;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
/**
*
* @since 1.6.0
* @author Artem Labazin
*/
+@DisplayName("Term mapping test to POJO")
@FieldDefaults(level = PRIVATE, makeFinal = true)
-public class TermMapperTest {
+class TermMapperTest {
+
+ @BeforeEach
+ void beforeEach (TestInfo testInfo) {
+ System.out.println("- " + testInfo.getDisplayName());
+ }
@Test
- public void simple () {
+ @DisplayName("simple POJO mapping")
+ void simple () {
val pojo = new Pojo(
"Artem",
27,
diff --git a/encon-handler/README.md b/encon-handler/README.md
index c4ac5b4..38e7a5f 100644
--- a/encon-handler/README.md
+++ b/encon-handler/README.md
@@ -1,5 +1,13 @@
# Overview
+[](https://travis-ci.org/appulse-projects/encon-java)
+[](https://search.maven.org/search?q=a:encon-handler)
+[](http://www.apache.org/licenses/LICENSE-2.0.html)
+[](http://www.javadoc.io/doc/io.appulse.encon/encon-handler)
+
+
+
+
Different classes for convenient mailbox handling.
## Usage
@@ -14,7 +22,7 @@ First of all, add dependency:
io.appulse.enconencon-handler
- 1.6.5
+ 2.0.0
...
@@ -23,7 +31,7 @@ First of all, add dependency:
**Gradle**:
```groovy
-compile 'io.appulse.encon:encon-handler:1.6.5'
+compile 'io.appulse.encon:encon-handler:2.0.0'
```
### Basics
diff --git a/encon-handler/pom.xml b/encon-handler/pom.xml
index fb82bb0..2c837d5 100644
--- a/encon-handler/pom.xml
+++ b/encon-handler/pom.xml
@@ -25,19 +25,13 @@ limitations under the License.
io.appulse.enconencon-parent
- 1.6.5
+ 2.0.0encon-handlerjar
-
- org.projectlombok
- lombok
- provided
-
-
${project.groupId}encon
@@ -52,29 +46,7 @@ limitations under the License.
cglibcglib
- 3.2.7
-
-
-
- com.google.code.findbugs
- annotations
- provided
-
-
- com.google.code.findbugs
- jsr305
- provided
-
-
-
- junit
- junit
- test
-
-
- org.assertj
- assertj-core
- test
+ 3.2.9
@@ -90,14 +62,13 @@ limitations under the License.
- org.codehaus.mojo
- findbugs-maven-plugin
+ com.github.spotbugs
+ spotbugs-maven-pluginorg.apache.maven.pluginsmaven-pmd-plugin
-
org.apache.maven.pluginsmaven-checkstyle-plugin
diff --git a/encon-handler/src/main/java/io/appulse/encon/handler/mailbox/AbstractMailboxHandler.java b/encon-handler/src/main/java/io/appulse/encon/handler/mailbox/AbstractMailboxHandler.java
index 96852bc..766eddd 100644
--- a/encon-handler/src/main/java/io/appulse/encon/handler/mailbox/AbstractMailboxHandler.java
+++ b/encon-handler/src/main/java/io/appulse/encon/handler/mailbox/AbstractMailboxHandler.java
@@ -39,7 +39,7 @@
* you only need to "tell" how to get a message from a queue.
*
* @since 1.4.0
- * @author alabazin
+ * @author Artem Labazin
*/
@Slf4j
@RequiredArgsConstructor
diff --git a/encon-handler/src/main/java/io/appulse/encon/handler/mailbox/DefaultMailboxHandler.java b/encon-handler/src/main/java/io/appulse/encon/handler/mailbox/DefaultMailboxHandler.java
index 053a0d5..34a66ea 100644
--- a/encon-handler/src/main/java/io/appulse/encon/handler/mailbox/DefaultMailboxHandler.java
+++ b/encon-handler/src/main/java/io/appulse/encon/handler/mailbox/DefaultMailboxHandler.java
@@ -29,7 +29,7 @@
* Default {@link AbstractMailboxHandler} implementation.
*
* @since 1.5.0
- * @author alabazin
+ * @author Artem Labazin
*/
@FieldDefaults(level = PRIVATE, makeFinal = true)
public class DefaultMailboxHandler extends AbstractMailboxHandler {
diff --git a/encon-handler/src/main/java/io/appulse/encon/handler/message/MessageHandler.java b/encon-handler/src/main/java/io/appulse/encon/handler/message/MessageHandler.java
index d157e6c..d2a600c 100644
--- a/encon-handler/src/main/java/io/appulse/encon/handler/message/MessageHandler.java
+++ b/encon-handler/src/main/java/io/appulse/encon/handler/message/MessageHandler.java
@@ -24,7 +24,7 @@
* Received messages handler interface.
*
* @since 1.4.0
- * @author alabazin
+ * @author Artem Labazin
*/
public interface MessageHandler {
diff --git a/encon-handler/src/main/java/io/appulse/encon/handler/message/exception/MethodInvocationException.java b/encon-handler/src/main/java/io/appulse/encon/handler/message/exception/MethodInvocationException.java
index fcda5cc..ec5cd70 100644
--- a/encon-handler/src/main/java/io/appulse/encon/handler/message/exception/MethodInvocationException.java
+++ b/encon-handler/src/main/java/io/appulse/encon/handler/message/exception/MethodInvocationException.java
@@ -30,7 +30,7 @@
/**
*
* @since 1.6.0
- * @author alabazin
+ * @author Artem Labazin
*/
@Getter
@FieldDefaults(level = PRIVATE, makeFinal = true)
diff --git a/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/BuilderProxyMethodInterceptor.java b/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/BuilderProxyMethodInterceptor.java
index 5a0322d..2e77e19 100644
--- a/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/BuilderProxyMethodInterceptor.java
+++ b/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/BuilderProxyMethodInterceptor.java
@@ -35,7 +35,7 @@
/**
*
* @since 1.4.0
- * @author alabazin
+ * @author Artem Labazin
*/
@Slf4j
@Builder
diff --git a/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/Matchers.java b/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/Matchers.java
index fa0178d..442ecf8 100644
--- a/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/Matchers.java
+++ b/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/Matchers.java
@@ -41,14 +41,14 @@
* The set of pattern matching helpers.
*
* @since 1.4.0
- * @author alabazin
+ * @author Artem Labazin
*/
public final class Matchers {
/**
* Matches anything, including nulls and varargs.
*
- * For primitive types use {@code #any*()} family or {@link #isA(Class)} or {@link #any(Class)}.
+ * For primitive types use {@code #any*()} family or {@link #is(Class)} or {@link #any(Class)}.
*
* @param the accepted type
*
@@ -82,7 +82,7 @@ public static T any (Class type) {
*
* @return {@code null}
*/
- public static T isA (Class type) {
+ public static T is (Class type) {
reportMatcher(new InstanceOf(type));
return defaultValue(type);
}
@@ -356,7 +356,7 @@ public static T eq (T value) {
*
* @return {@code null}
*/
- public static T isNull () {
+ public static T nullMatches () {
reportMatcher(NULL);
return null;
}
@@ -368,7 +368,7 @@ public static T isNull () {
*
* @return {@code null}
*/
- public static T isNotNull () {
+ public static T notNullMatches () {
reportMatcher(NOT_NULL);
return null;
}
diff --git a/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/MethodArgumentMatcher.java b/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/MethodArgumentMatcher.java
index 5f16029..be47a2e 100644
--- a/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/MethodArgumentMatcher.java
+++ b/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/MethodArgumentMatcher.java
@@ -34,7 +34,7 @@
* Method argument matcher.
*
* @since 1.4.0
- * @author alabazin
+ * @author Artem Labazin
*/
public interface MethodArgumentMatcher {
diff --git a/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/MethodArgumentsTransformer.java b/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/MethodArgumentsTransformer.java
index c301d14..69ba98f 100644
--- a/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/MethodArgumentsTransformer.java
+++ b/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/MethodArgumentsTransformer.java
@@ -33,7 +33,7 @@
/**
*
* @since 1.6.0
- * @author alabazin
+ * @author Artem Labazin
*/
@Slf4j
@Getter
diff --git a/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/MethodArgumentsWrapper.java b/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/MethodArgumentsWrapper.java
index 9cc2a9f..13e8440 100644
--- a/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/MethodArgumentsWrapper.java
+++ b/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/MethodArgumentsWrapper.java
@@ -24,7 +24,7 @@
/**
*
* @since 1.4.0
- * @author alabazin
+ * @author Artem Labazin
*/
enum MethodArgumentsWrapper {
diff --git a/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/MethodDescriptor.java b/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/MethodDescriptor.java
index 3f5a849..7e2248d 100644
--- a/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/MethodDescriptor.java
+++ b/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/MethodDescriptor.java
@@ -38,7 +38,7 @@
/**
*
* @since 1.6.0
- * @author alabazin
+ * @author Artem Labazin
*/
@Slf4j
@Getter
diff --git a/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/MethodInvoker.java b/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/MethodInvoker.java
index 55df095..842aa91 100644
--- a/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/MethodInvoker.java
+++ b/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/MethodInvoker.java
@@ -36,7 +36,7 @@
* Method invoker.
*
* @since 1.6.0
- * @author alabazin
+ * @author Artem Labazin
*/
@Slf4j
@Getter
diff --git a/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/MethodMatcher.java b/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/MethodMatcher.java
index 5ee391c..b2f793e 100644
--- a/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/MethodMatcher.java
+++ b/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/MethodMatcher.java
@@ -34,7 +34,7 @@
/**
*
* @since 1.6.0
- * @author alabazin
+ * @author Artem Labazin
*/
@Slf4j
@Getter
diff --git a/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/MethodMatcherMessageHandler.java b/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/MethodMatcherMessageHandler.java
index bb5397b..52f0cdb 100644
--- a/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/MethodMatcherMessageHandler.java
+++ b/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/MethodMatcherMessageHandler.java
@@ -40,7 +40,7 @@
* incoming messages handlers.
*
* @since 1.4.0
- * @author alabazin
+ * @author Artem Labazin
*/
@Slf4j
@Getter
diff --git a/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/MethodMatcherMessageHandlerBuilder.java b/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/MethodMatcherMessageHandlerBuilder.java
index 5b02993..31c41d8 100644
--- a/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/MethodMatcherMessageHandlerBuilder.java
+++ b/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/MethodMatcherMessageHandlerBuilder.java
@@ -29,6 +29,7 @@
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import lombok.NoArgsConstructor;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
@@ -42,7 +43,7 @@
* Builder of a new {@link MethodMatcherMessageHandler} instance.
*
* @since 1.4.0
- * @author alabazin
+ * @author Artem Labazin
*/
@NoArgsConstructor(access = PACKAGE)
@FieldDefaults(level = PRIVATE, makeFinal = true)
@@ -77,6 +78,7 @@ public MethodMatcherMessageHandler build () {
return new MethodMatcherMessageHandler(map);
}
+ @SuppressFBWarnings("UPM_UNCALLED_PRIVATE_METHOD")
private T createProxy (T object, MethodArgumentsWrapper wrapper) {
val cacheKey = WrapperCacheKey.of(object.getClass(), wrapper);
val proxy = wrappedCache.get(cacheKey);
diff --git a/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/Primitives.java b/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/Primitives.java
index c1a4da2..91123ff 100644
--- a/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/Primitives.java
+++ b/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/Primitives.java
@@ -22,7 +22,7 @@
/**
*
* @since 1.4.0
- * @author alabazin
+ * @author Artem Labazin
*/
final class Primitives {
diff --git a/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/ThreadLocalStorage.java b/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/ThreadLocalStorage.java
index 6759cfa..61bc028 100644
--- a/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/ThreadLocalStorage.java
+++ b/encon-handler/src/main/java/io/appulse/encon/handler/message/matcher/ThreadLocalStorage.java
@@ -22,7 +22,7 @@
/**
*
* @since 1.4.0
- * @author alabazin
+ * @author Artem Labazin
*/
final class ThreadLocalStorage {
diff --git a/encon-handler/src/test/java/io/appulse/encon/handler/message/matcher/MethodMatcherMessageHandlerTest.java b/encon-handler/src/test/java/io/appulse/encon/handler/message/matcher/MethodMatcherMessageHandlerTest.java
index 540faf1..3b95d8b 100644
--- a/encon-handler/src/test/java/io/appulse/encon/handler/message/matcher/MethodMatcherMessageHandlerTest.java
+++ b/encon-handler/src/test/java/io/appulse/encon/handler/message/matcher/MethodMatcherMessageHandlerTest.java
@@ -33,26 +33,30 @@
import io.appulse.encon.handler.message.matcher.MethodMatcherMessageHandler;
import io.appulse.encon.terms.ErlangTerm;
-import io.appulse.utils.test.TestMethodNamePrinter;
-import lombok.val;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestRule;
+import lombok.val;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
/**
*
- * @author alabazin
+ * @author Artem Labazin
*/
-public class MethodMatcherMessageHandlerTest {
-
- @Rule
- public TestRule watcher = new TestMethodNamePrinter();
+@DisplayName("Method matcher message handler tests")
+class MethodMatcherMessageHandlerTest {
static List list = new ArrayList<>();
+ @BeforeEach
+ void beforeEach (TestInfo testInfo) {
+ System.out.println("- " + testInfo.getDisplayName());
+ }
+
@Test
- public void test () {
+ @DisplayName("different handlers matches")
+ void test () {
MyService1 service1 = new MyService1();
MyService2 service2 = new MyService2();
@@ -76,7 +80,8 @@ public void test () {
}
@Test
- public void throwsAmbigousException () {
+ @DisplayName("throws ambigous exception")
+ void throwsAmbigousException () {
MyService2 service = new MyService2();
val builder = MethodMatcherMessageHandler.builder()
.wrap(service);
diff --git a/encon-spring/README.md b/encon-spring/README.md
index 9be038b..1029d17 100644
--- a/encon-spring/README.md
+++ b/encon-spring/README.md
@@ -1,5 +1,13 @@
# Overview
+[](https://travis-ci.org/appulse-projects/encon-java)
+[](https://search.maven.org/search?q=a:encon-spring)
+[](http://www.apache.org/licenses/LICENSE-2.0.html)
+[](http://www.javadoc.io/doc/io.appulse.encon/encon-spring)
+
+
+
+
Package for Encon's Spring integration.
Example:
diff --git a/encon-spring/pom.xml b/encon-spring/pom.xml
index 8cc8886..1ec3654 100644
--- a/encon-spring/pom.xml
+++ b/encon-spring/pom.xml
@@ -25,19 +25,13 @@ limitations under the License.
io.appulse.enconencon-parent
- 1.6.5
+ 2.0.0encon-springjar
-
- org.projectlombok
- lombok
- provided
-
-
${project.groupId}encon
@@ -57,29 +51,7 @@ limitations under the License.
org.springframework.bootspring-boot-starter
- 2.0.4.RELEASE
-
-
-
- com.google.code.findbugs
- annotations
- provided
-
-
- com.google.code.findbugs
- jsr305
- provided
-
-
-
- junit
- junit
- test
-
-
- org.assertj
- assertj-core
- test
+ 2.1.1.RELEASE
@@ -95,14 +67,13 @@ limitations under the License.
- org.codehaus.mojo
- findbugs-maven-plugin
+ com.github.spotbugs
+ spotbugs-maven-pluginorg.apache.maven.pluginsmaven-pmd-plugin
-
org.apache.maven.pluginsmaven-checkstyle-plugin
diff --git a/encon-spring/src/main/java/io/appulse/encon/spring/BeanPostProcessorErlangMailboxAnnotation.java b/encon-spring/src/main/java/io/appulse/encon/spring/BeanPostProcessorErlangMailboxAnnotation.java
index 6c0880e..2ce5d6c 100644
--- a/encon-spring/src/main/java/io/appulse/encon/spring/BeanPostProcessorErlangMailboxAnnotation.java
+++ b/encon-spring/src/main/java/io/appulse/encon/spring/BeanPostProcessorErlangMailboxAnnotation.java
@@ -41,7 +41,7 @@
/**
*
* @since 1.6.0
- * @author alabazin
+ * @author Artem Labazin
*/
@RequiredArgsConstructor
@FieldDefaults(level = PRIVATE, makeFinal = true)
diff --git a/encon-spring/src/main/java/io/appulse/encon/spring/BeanPostProcessorInjectMailboxAnnotation.java b/encon-spring/src/main/java/io/appulse/encon/spring/BeanPostProcessorInjectMailboxAnnotation.java
index 2e6cc4b..42ac9e2 100644
--- a/encon-spring/src/main/java/io/appulse/encon/spring/BeanPostProcessorInjectMailboxAnnotation.java
+++ b/encon-spring/src/main/java/io/appulse/encon/spring/BeanPostProcessorInjectMailboxAnnotation.java
@@ -43,7 +43,7 @@
/**
*
* @since 1.6.0
- * @author alabazin
+ * @author Artem Labazin
*/
@RequiredArgsConstructor
@FieldDefaults(level = PRIVATE, makeFinal = true)
diff --git a/encon-spring/src/main/java/io/appulse/encon/spring/BeanPostProcessorMailboxHandler.java b/encon-spring/src/main/java/io/appulse/encon/spring/BeanPostProcessorMailboxHandler.java
index 6aafc5b..7936d10 100644
--- a/encon-spring/src/main/java/io/appulse/encon/spring/BeanPostProcessorMailboxHandler.java
+++ b/encon-spring/src/main/java/io/appulse/encon/spring/BeanPostProcessorMailboxHandler.java
@@ -45,7 +45,7 @@
/**
*
* @since 1.6.0
- * @author alabazin
+ * @author Artem Labazin
*/
@Slf4j
@RequiredArgsConstructor
diff --git a/encon-spring/src/main/java/io/appulse/encon/spring/EnconAutoConfiguration.java b/encon-spring/src/main/java/io/appulse/encon/spring/EnconAutoConfiguration.java
index 6a7f5d4..d1f25b2 100644
--- a/encon-spring/src/main/java/io/appulse/encon/spring/EnconAutoConfiguration.java
+++ b/encon-spring/src/main/java/io/appulse/encon/spring/EnconAutoConfiguration.java
@@ -33,6 +33,7 @@
import io.appulse.encon.spring.EnconAutoConfiguration.MailboxOperationsConfiguration;
import lombok.experimental.FieldDefaults;
+import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
@@ -52,6 +53,7 @@
* @since 1.6.0
* @author Artem Labazin
*/
+@Slf4j
@Configuration
@ConditionalOnClass({
Node.class,
@@ -84,6 +86,7 @@ public Config defaultConfig () {
@ConditionalOnMissingBean
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
public Nodes defaultEnconNodes (Config config) {
+ log.debug("Configuration loaded\n{}", config);
val nodes = Nodes.start(config);
for (Node node : nodes) {
val descriptor = node.getDescriptor();
diff --git a/encon-spring/src/main/java/io/appulse/encon/spring/EnconProperties.java b/encon-spring/src/main/java/io/appulse/encon/spring/EnconProperties.java
index 1154c6e..9e80a1d 100644
--- a/encon-spring/src/main/java/io/appulse/encon/spring/EnconProperties.java
+++ b/encon-spring/src/main/java/io/appulse/encon/spring/EnconProperties.java
@@ -20,18 +20,13 @@
import static lombok.AccessLevel.PACKAGE;
import static lombok.AccessLevel.PRIVATE;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
import javax.annotation.PostConstruct;
+import io.appulse.encon.NodesConfig;
import io.appulse.encon.config.Config;
-import io.appulse.encon.config.Defaults;
-import io.appulse.encon.config.NodeConfig;
import lombok.Data;
import lombok.Getter;
-import lombok.NonNull;
import lombok.experimental.FieldDefaults;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@@ -40,13 +35,13 @@
/**
*
* @since 1.6.0
- * @author alabazin
+ * @author Artem Labazin
*/
@Data
@Component
@Validated
@FieldDefaults(level = PRIVATE)
-@ConfigurationProperties(prefix = "spring.encon")
+@ConfigurationProperties(prefix = "spring")
public class EnconProperties {
@Getter(value = PACKAGE, lazy = true)
@@ -54,10 +49,7 @@ public class EnconProperties {
Boolean enabled;
- Defaults defaults;
-
- @NonNull
- Map nodes = new LinkedHashMap<>();
+ NodesConfig encon;
/**
* Post construct. Initialize with default values the fields.
@@ -67,15 +59,11 @@ public void postConstruct () {
if (enabled == null) {
enabled = TRUE;
}
- if (defaults == null) {
- defaults = Defaults.INSTANCE;
- }
}
private Config createConfig () {
return Config.builder()
- .defaults(defaults)
- .nodes(nodes)
+ .config(encon)
.build();
}
}
diff --git a/encon-spring/src/main/java/io/appulse/encon/spring/ErlangMailbox.java b/encon-spring/src/main/java/io/appulse/encon/spring/ErlangMailbox.java
index 2128d5e..333ff74 100644
--- a/encon-spring/src/main/java/io/appulse/encon/spring/ErlangMailbox.java
+++ b/encon-spring/src/main/java/io/appulse/encon/spring/ErlangMailbox.java
@@ -30,7 +30,7 @@
/**
*
* @since 1.6.0
- * @author alabazin
+ * @author Artem Labazin
*/
@Component
@Documented
diff --git a/encon-spring/src/main/java/io/appulse/encon/spring/InjectMailbox.java b/encon-spring/src/main/java/io/appulse/encon/spring/InjectMailbox.java
index 3cba90d..1ca3202 100644
--- a/encon-spring/src/main/java/io/appulse/encon/spring/InjectMailbox.java
+++ b/encon-spring/src/main/java/io/appulse/encon/spring/InjectMailbox.java
@@ -26,7 +26,7 @@
/**
*
* @since 1.6.0
- * @author alabazin
+ * @author Artem Labazin
*/
@Documented
@Target(FIELD)
diff --git a/encon-spring/src/main/java/io/appulse/encon/spring/MailboxOperations.java b/encon-spring/src/main/java/io/appulse/encon/spring/MailboxOperations.java
index 7ef8201..9d92994 100644
--- a/encon-spring/src/main/java/io/appulse/encon/spring/MailboxOperations.java
+++ b/encon-spring/src/main/java/io/appulse/encon/spring/MailboxOperations.java
@@ -40,7 +40,7 @@
/**
*
* @since 1.6.0
- * @author alabazin
+ * @author Artem Labazin
*/
@Builder
@RequiredArgsConstructor
diff --git a/encon-spring/src/main/java/io/appulse/encon/spring/MatchingCaseMapping.java b/encon-spring/src/main/java/io/appulse/encon/spring/MatchingCaseMapping.java
index 4d9a63a..827fbc3 100644
--- a/encon-spring/src/main/java/io/appulse/encon/spring/MatchingCaseMapping.java
+++ b/encon-spring/src/main/java/io/appulse/encon/spring/MatchingCaseMapping.java
@@ -26,7 +26,7 @@
/**
*
* @since 1.6.0
- * @author alabazin
+ * @author Artem Labazin
*/
@Documented
@Target(METHOD)
diff --git a/encon-spring/src/main/java/io/appulse/encon/spring/MessageWrapper.java b/encon-spring/src/main/java/io/appulse/encon/spring/MessageWrapper.java
index df63562..f1b20e0 100644
--- a/encon-spring/src/main/java/io/appulse/encon/spring/MessageWrapper.java
+++ b/encon-spring/src/main/java/io/appulse/encon/spring/MessageWrapper.java
@@ -30,7 +30,7 @@
/**
*
* @since 1.6.0
- * @author alabazin
+ * @author Artem Labazin
*/
enum MessageWrapper {
diff --git a/encon-terms/README.md b/encon-terms/README.md
index 5f86cf5..ce03d25 100644
--- a/encon-terms/README.md
+++ b/encon-terms/README.md
@@ -1,3 +1,11 @@
# Overview
+[](https://travis-ci.org/appulse-projects/encon-java)
+[](https://search.maven.org/search?q=a:encon-terms)
+[](http://www.apache.org/licenses/LICENSE-2.0.html)
+[](http://www.javadoc.io/doc/io.appulse.encon/encon-terms)
+
+
+
+
The set of Erlang's terms classes and different helpers.
diff --git a/encon-terms/pom.xml b/encon-terms/pom.xml
index d8a2387..bca0826 100644
--- a/encon-terms/pom.xml
+++ b/encon-terms/pom.xml
@@ -25,52 +25,24 @@ limitations under the License.
io.appulse.enconencon-parent
- 1.6.5
+ 2.0.0encon-termsjar
-
- org.projectlombok
- lombok
- provided
-
-
${project.groupId}encon-common${project.version}
-
- com.google.code.findbugs
- annotations
- provided
-
-
- com.google.code.findbugs
- jsr305
- provided
-
-
io.nettynetty-buffer
-
-
- junit
- junit
- test
-
-
- org.assertj
- assertj-core
- test
-
@@ -85,14 +57,13 @@ limitations under the License.
- org.codehaus.mojo
- findbugs-maven-plugin
+ com.github.spotbugs
+ spotbugs-maven-pluginorg.apache.maven.pluginsmaven-pmd-plugin
-
org.apache.maven.pluginsmaven-checkstyle-plugin
diff --git a/encon-terms/src/main/java/io/appulse/encon/terms/Erlang.java b/encon-terms/src/main/java/io/appulse/encon/terms/Erlang.java
index 00c6b1f..847f4d0 100644
--- a/encon-terms/src/main/java/io/appulse/encon/terms/Erlang.java
+++ b/encon-terms/src/main/java/io/appulse/encon/terms/Erlang.java
@@ -55,7 +55,7 @@ public final class Erlang {
/**
* Cached enpty (0-size string) {@link ErlangAtom} instance.
*/
- public static final ErlangAtom EMPTY_ATOM = ErlangAtom.cached("");
+ public static final ErlangAtom EMPTY_ATOM = new ErlangAtom("");
/**
* Creates new {@link ErlangAtom} instance from {@code boolean} (true/false value) .
@@ -65,7 +65,9 @@ public final class Erlang {
* @return {@link ErlangAtom} new instance
*/
public static ErlangAtom atom (boolean value) {
- return ErlangAtom.cached(value);
+ return value
+ ? ErlangAtom.ATOM_TRUE
+ : ErlangAtom.ATOM_FALSE;
}
/**
@@ -76,7 +78,7 @@ public static ErlangAtom atom (boolean value) {
* @return {@link ErlangAtom} new instance
*/
public static ErlangAtom atom (@NonNull String value) {
- return ErlangAtom.cached(value);
+ return new ErlangAtom(value);
}
/**
diff --git a/encon-terms/src/main/java/io/appulse/encon/terms/ErlangTerm.java b/encon-terms/src/main/java/io/appulse/encon/terms/ErlangTerm.java
index e697902..38d64cb 100644
--- a/encon-terms/src/main/java/io/appulse/encon/terms/ErlangTerm.java
+++ b/encon-terms/src/main/java/io/appulse/encon/terms/ErlangTerm.java
@@ -95,7 +95,7 @@ public static T newInstance (@NonNull ByteBuf buffer) {
case INTEGER:
case SMALL_BIG:
case LARGE_BIG:
- return (T) ErlangInteger.cached(type, buffer);
+ return (T) new ErlangInteger(type, buffer);
case FLOAT:
case NEW_FLOAT:
return (T) new ErlangFloat(type, buffer);
@@ -108,7 +108,7 @@ public static T newInstance (@NonNull ByteBuf buffer) {
return (T) new ErlangPort(type, buffer);
case PID:
case NEW_PID:
- return (T) ErlangPid.cached(type, buffer);
+ return (T) new ErlangPid(type, buffer);
case SMALL_TUPLE:
case LARGE_TUPLE:
return (T) new ErlangTuple(type, buffer);
@@ -133,7 +133,7 @@ public static T newInstance (@NonNull ByteBuf buffer) {
case SMALL_ATOM_UTF8:
case ATOM:
case SMALL_ATOM:
- return (T) ErlangAtom.cached(type, buffer);
+ return (T) new ErlangAtom(type, buffer);
default:
val message = String.format("Unknown term type %s (%d)", type.name(), typeByte);
throw new ErlangTermDecodeException(message);
diff --git a/encon-terms/src/main/java/io/appulse/encon/terms/TermType.java b/encon-terms/src/main/java/io/appulse/encon/terms/TermType.java
index 85b4c73..6aa25f0 100644
--- a/encon-terms/src/main/java/io/appulse/encon/terms/TermType.java
+++ b/encon-terms/src/main/java/io/appulse/encon/terms/TermType.java
@@ -487,7 +487,7 @@ public enum TermType {
*
*
* Encodes a map. The Arity field is an unsigned 4 byte integer in big-endian format that determines the
- * number of key-value pairs in the map. Key and value pairs (Ki => Vi) are encoded in section Pairs in the
+ * number of key-value pairs in the map. Key and value pairs (Ki => Vi) are encoded in section Pairs in the
* following order: K1, V1, K2, V2,..., Kn, Vn.
*
* Duplicate keys are not allowed within the same map.
@@ -661,7 +661,7 @@ public enum TermType {
FUNCTION(117, ErlangFunction.class),
/**
- * This is the new encoding of internal funs: fun F/A and fun(Arg1,..) -> ... end.
+ * This is the new encoding of internal funs: fun F/A and fun(Arg1,..) -> ... end.
*
* Structure:
*
diff --git a/encon-terms/src/main/java/io/appulse/encon/terms/type/ErlangAtom.java b/encon-terms/src/main/java/io/appulse/encon/terms/type/ErlangAtom.java
index a0b9232..f9cf9f8 100644
--- a/encon-terms/src/main/java/io/appulse/encon/terms/type/ErlangAtom.java
+++ b/encon-terms/src/main/java/io/appulse/encon/terms/type/ErlangAtom.java
@@ -21,25 +21,20 @@
import static io.appulse.encon.terms.TermType.SMALL_ATOM_UTF8;
import static java.nio.charset.StandardCharsets.ISO_8859_1;
import static java.nio.charset.StandardCharsets.UTF_8;
-import static java.util.Locale.ENGLISH;
import static lombok.AccessLevel.PRIVATE;
import java.nio.charset.Charset;
-import java.util.Arrays;
import io.appulse.encon.terms.ErlangTerm;
import io.appulse.encon.terms.TermType;
import io.appulse.encon.terms.exception.IllegalErlangTermTypeException;
-import io.appulse.utils.cache.LruCache;
import io.netty.buffer.ByteBuf;
-import io.netty.util.ByteProcessor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NonNull;
import lombok.ToString;
import lombok.experimental.FieldDefaults;
-import lombok.experimental.NonFinal;
/**
* An atom is a literal, a constant with name. An atom is to be enclosed in
@@ -51,83 +46,48 @@
* @author Artem Labazin
*/
@ToString
+@SuppressWarnings("deprecation")
@EqualsAndHashCode(callSuper = true, of = "bytes")
@FieldDefaults(level = PRIVATE, makeFinal = true)
public class ErlangAtom extends ErlangTerm {
private static final long serialVersionUID = -2748345367418129439L;
- private static final int MAX_ATOM_CODE_POINTS_LENGTH = 255;
-
- private static final int MAX_SMALL_ATOM_BYTES_LENGTH = 255;
-
- private static final LruCache CACHE = new LruCache<>(1000);
+ public static final ErlangAtom ATOM_TRUE = new ErlangAtom(true);
- private static final ErlangAtom ATOM_TRUE = cached(Boolean.TRUE.toString().toLowerCase(ENGLISH));
+ public static final ErlangAtom ATOM_FALSE = new ErlangAtom(false);
- private static final ErlangAtom ATOM_FALSE = cached(Boolean.FALSE.toString().toLowerCase(ENGLISH));
-
- public static ErlangAtom cached (boolean value) {
- return value
- ? ATOM_TRUE
- : ATOM_FALSE;
- }
-
- public static ErlangAtom cached (String value) {
- Charset charset = UTF_8;
- byte[] bytes = value.getBytes(charset);
- int hashCode = Arrays.hashCode(bytes);
- return CACHE.computeIfAbsent(hashCode, key -> new ErlangAtom(value, charset, bytes));
- }
-
- @SuppressWarnings("deprecation")
- public static ErlangAtom cached (TermType type, ByteBuf buffer) {
- ByteArrayHashCode byteProcessor = new ByteArrayHashCode();
-
- int length = type == SMALL_ATOM || type == SMALL_ATOM_UTF8
- ? buffer.readUnsignedByte()
- : buffer.readUnsignedShort();
-
- buffer.forEachByte(buffer.readerIndex(), length, byteProcessor);
+ private static final int MAX_ATOM_CODE_POINTS_LENGTH = 255;
- return CACHE.compute(byteProcessor.getHashCode(), (key, value) -> {
- if (value == null) {
- return new ErlangAtom(type, buffer, length);
- } else {
- buffer.skipBytes(length);
- return value;
- }
- });
- }
+ private static final int MAX_SMALL_ATOM_BYTES_LENGTH = 255;
- @NonFinal
- String value;
+ @Getter(lazy = true, value = PRIVATE)
+ String value = createString();
byte[] bytes;
transient Charset charset;
/**
- * Constructs Erlang's atom object with specific {@link String} value.
+ * Constructs Erlang's term object with specific {@link TermType} from {@link ByteBuf}.
*
- * @param value {@link String} atom's value
+ * @param type object's type
+ *
+ * @param buffer byte buffer
*/
- public ErlangAtom (@NonNull String value) {
- super();
+ public ErlangAtom (TermType type, ByteBuf buffer) {
+ super(type);
- this.value = value.codePointCount(0, value.length()) <= MAX_ATOM_CODE_POINTS_LENGTH
- ? value
- // Throwing an exception would be better I think, but truncation
- // seems to be the way it has been done in other parts of OTP...
- : new String(value.codePoints().toArray(), 0, MAX_ATOM_CODE_POINTS_LENGTH);
+ int length = type == SMALL_ATOM || type == SMALL_ATOM_UTF8
+ ? buffer.readUnsignedByte()
+ : buffer.readUnsignedShort();
- charset = UTF_8;
- bytes = this.value.getBytes(charset);
- if (bytes.length > MAX_SMALL_ATOM_BYTES_LENGTH) {
- setType(ATOM_UTF8);
- } else {
- setType(SMALL_ATOM_UTF8);
- }
+ charset = type == SMALL_ATOM_UTF8 || type == ATOM_UTF8
+ ? UTF_8
+ : ISO_8859_1;
+
+ bytes = new byte[length];
+ buffer.readBytes(bytes);
}
/**
@@ -136,46 +96,31 @@ public ErlangAtom (@NonNull String value) {
* @param value {@code boolean} atom's value
*/
public ErlangAtom (boolean value) {
- super(SMALL_ATOM_UTF8);
- charset = UTF_8;
- this.value = Boolean.toString(value);
- bytes = value
- ? Boolean.TRUE.toString().getBytes(charset)
- : Boolean.FALSE.toString().getBytes(charset);
+ this(Boolean.toString(value), UTF_8);
}
/**
- * Constructs Erlang's term object with specific {@link TermType} from {@link ByteBuf}.
- *
- * @param type object's type
- *
- * @param buffer byte buffer
+ * Constructs Erlang's atom object with specific {@link String} value.
*
- * @param length amount of useful bytes
+ * @param value {@link String} atom's value
*/
- private ErlangAtom (TermType type, ByteBuf buffer, int length) {
- super(type);
-
- charset = type == SMALL_ATOM_UTF8 || type == ATOM_UTF8
- ? UTF_8
- : ISO_8859_1;
-
- bytes = new byte[length];
- buffer.readBytes(bytes);
+ public ErlangAtom (String value) {
+ this(value, UTF_8);
}
- @SuppressWarnings("PMD.ArrayIsStoredDirectly")
- private ErlangAtom (String value, Charset charset, byte[] bytes) {
+ public ErlangAtom (@NonNull String value, @NonNull Charset charset) {
super();
- this.value = value.codePointCount(0, value.length()) <= MAX_ATOM_CODE_POINTS_LENGTH
- ? value
- // Throwing an exception would be better I think, but truncation
- // seems to be the way it has been done in other parts of OTP...
- : new String(value.codePoints().toArray(), 0, MAX_ATOM_CODE_POINTS_LENGTH);
+ if (value.codePointCount(0, value.length()) <= MAX_ATOM_CODE_POINTS_LENGTH) {
+ this.value.set(value);
+ } else {
+ // Throwing an exception would be better I think, but truncation
+ // seems to be the way it has been done in other parts of OTP...
+ this.value.set(new String(value.codePoints().toArray(), 0, MAX_ATOM_CODE_POINTS_LENGTH));
+ }
this.charset = charset;
- this.bytes = bytes;
+ this.bytes = getValue().getBytes(charset);
if (bytes.length > MAX_SMALL_ATOM_BYTES_LENGTH) {
setType(ATOM_UTF8);
} else {
@@ -195,10 +140,7 @@ public boolean asBoolean (boolean defaultValue) {
@Override
public String asText (String defaultValue) {
- if (value == null) {
- value = new String(bytes, charset);
- }
- return value;
+ return getValue();
}
@Override
@@ -233,16 +175,7 @@ protected void serialize (ByteBuf buffer) {
buffer.writeBytes(bytes);
}
- @Getter
- @FieldDefaults(level = PRIVATE)
- private static class ByteArrayHashCode implements ByteProcessor {
-
- int hashCode = 1;
-
- @Override
- public boolean process (byte value) throws Exception {
- hashCode = 31 * hashCode + value;
- return true;
- }
+ private String createString () {
+ return new String(bytes, charset);
}
}
diff --git a/encon-terms/src/main/java/io/appulse/encon/terms/type/ErlangInteger.java b/encon-terms/src/main/java/io/appulse/encon/terms/type/ErlangInteger.java
index 1158358..a8d9196 100644
--- a/encon-terms/src/main/java/io/appulse/encon/terms/type/ErlangInteger.java
+++ b/encon-terms/src/main/java/io/appulse/encon/terms/type/ErlangInteger.java
@@ -31,12 +31,9 @@
import io.appulse.encon.terms.TermType;
import io.appulse.encon.terms.exception.ErlangTermDecodeException;
import io.appulse.encon.terms.exception.IllegalErlangTermTypeException;
-import io.appulse.utils.cache.LruCache;
import io.netty.buffer.ByteBuf;
-import io.netty.util.ByteProcessor;
import lombok.EqualsAndHashCode;
-import lombok.Getter;
import lombok.NonNull;
import lombok.ToString;
import lombok.experimental.FieldDefaults;
@@ -64,8 +61,6 @@ public class ErlangInteger extends ErlangTerm {
private static final int MAX_SMALL_BIG_BYTES_LENGTH = 255;
- private static final LruCache CACHE = new LruCache<>(1000);
-
/**
* Creates cached {@link ErlangInteger} value.
*
@@ -74,15 +69,7 @@ public class ErlangInteger extends ErlangTerm {
* @return new or cached {@link ErlangInteger} object
*/
public static ErlangInteger cached (byte value) {
- int hashCode = 31 + value;
-
- ErlangInteger result = CACHE.get(hashCode);
- if (result != null) {
- return result;
- }
- result = new ErlangInteger(value);
- CACHE.put(hashCode, result);
- return result;
+ return ErlangIntegerCache.CACHE[value + (-ErlangIntegerCache.LOW)];
}
/**
@@ -93,16 +80,10 @@ public static ErlangInteger cached (byte value) {
* @return new or cached {@link ErlangInteger} object
*/
public static ErlangInteger cached (char value) {
- int hashCode = 31 + (byte) (value >> 8);
- hashCode = 31 * hashCode + (byte) value;
-
- ErlangInteger result = CACHE.get(hashCode);
- if (result != null) {
- return result;
+ if (value <= ErlangIntegerCache.HIGH) {
+ return ErlangIntegerCache.CACHE[value + (-ErlangIntegerCache.LOW)];
}
- result = new ErlangInteger(value);
- CACHE.put(hashCode, result);
- return result;
+ return new ErlangInteger(value);
}
/**
@@ -113,16 +94,10 @@ public static ErlangInteger cached (char value) {
* @return new or cached {@link ErlangInteger} object
*/
public static ErlangInteger cached (short value) {
- int hashCode = 31 + (byte) (value >> 8);
- hashCode = 31 * hashCode + (byte) value;
-
- ErlangInteger result = CACHE.get(hashCode);
- if (result != null) {
- return result;
+ if (value >= ErlangIntegerCache.LOW && value <= ErlangIntegerCache.HIGH) {
+ return ErlangIntegerCache.CACHE[value + (-ErlangIntegerCache.LOW)];
}
- result = new ErlangInteger(value);
- CACHE.put(hashCode, result);
- return result;
+ return new ErlangInteger(value);
}
/**
@@ -133,18 +108,10 @@ public static ErlangInteger cached (short value) {
* @return new or cached {@link ErlangInteger} object
*/
public static ErlangInteger cached (int value) {
- int hashCode = 31 + (byte) (value >> 24);
- hashCode = 31 * hashCode + (byte) (value >> 16);
- hashCode = 31 * hashCode + (byte) (value >> 8);
- hashCode = 31 * hashCode + (byte) value;
-
- ErlangInteger result = CACHE.get(hashCode);
- if (result != null) {
- return result;
+ if (value >= ErlangIntegerCache.LOW && value <= ErlangIntegerCache.HIGH) {
+ return ErlangIntegerCache.CACHE[value + (-ErlangIntegerCache.LOW)];
}
- result = new ErlangInteger(value);
- CACHE.put(hashCode, result);
- return result;
+ return new ErlangInteger(value);
}
/**
@@ -155,22 +122,10 @@ public static ErlangInteger cached (int value) {
* @return new or cached {@link ErlangInteger} object
*/
public static ErlangInteger cached (long value) {
- int hashCode = 31 + (byte) (value >> 56);
- hashCode = 31 * hashCode + (byte) (value >> 48);
- hashCode = 31 * hashCode + (byte) (value >> 40);
- hashCode = 31 * hashCode + (byte) (value >> 32);
- hashCode = 31 * hashCode + (byte) (value >> 24);
- hashCode = 31 * hashCode + (byte) (value >> 16);
- hashCode = 31 * hashCode + (byte) (value >> 8);
- hashCode = 31 * hashCode + (byte) value;
-
- ErlangInteger result = CACHE.get(hashCode);
- if (result != null) {
- return result;
+ if (value >= ErlangIntegerCache.LOW && value <= ErlangIntegerCache.HIGH) {
+ return ErlangIntegerCache.CACHE[(int) value + (-ErlangIntegerCache.LOW)];
}
- result = new ErlangInteger(value);
- CACHE.put(hashCode, result);
- return result;
+ return new ErlangInteger(value);
}
/**
@@ -187,39 +142,6 @@ public static ErlangInteger cached (BigInteger value) {
return new ErlangInteger(value);
}
- public static ErlangInteger cached (TermType type, @NonNull ByteBuf buffer) {
- int index = buffer.readerIndex();
- ByteArrayHashCode byteProcessor = new ByteArrayHashCode();
-
- int length;
- switch (type) {
- case SMALL_INTEGER:
- length = Byte.BYTES;
- break;
- case INTEGER:
- length = Integer.BYTES;
- break;
- case SMALL_BIG:
- length = buffer.readByte() + Byte.BYTES;
- break;
- case LARGE_BIG:
- default:
- length = buffer.readInt() + Byte.BYTES;
- }
-
- buffer.forEachByte(buffer.readerIndex(), length, byteProcessor);
-
- return CACHE.compute(byteProcessor.getHashCode(), (key, value) -> {
- if (value == null) {
- buffer.readerIndex(index);
- return new ErlangInteger(type, buffer);
- } else {
- buffer.skipBytes(length);
- return value;
- }
- });
- }
-
BigInteger value;
@NonFinal
@@ -476,16 +398,21 @@ private void reverse (byte[] data) {
}
}
- @Getter
- @FieldDefaults(level = PRIVATE)
- private static class ByteArrayHashCode implements ByteProcessor {
+ @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
+ private static class ErlangIntegerCache {
- int hashCode = 1;
+ private static final int LOW = -128;
- @Override
- public boolean process (byte value) throws Exception {
- hashCode = 31 * hashCode + value;
- return true;
+ private static final int HIGH = 127;
+
+ private static final ErlangInteger[] CACHE;
+
+ static {
+ CACHE = new ErlangInteger[(HIGH - LOW) + 1];
+ int value = LOW;
+ for (int index = 0; index < CACHE.length; index++) {
+ CACHE[index] = new ErlangInteger(value++);
+ }
}
}
}
diff --git a/encon-terms/src/main/java/io/appulse/encon/terms/type/ErlangPid.java b/encon-terms/src/main/java/io/appulse/encon/terms/type/ErlangPid.java
index cd512ee..efc783f 100644
--- a/encon-terms/src/main/java/io/appulse/encon/terms/type/ErlangPid.java
+++ b/encon-terms/src/main/java/io/appulse/encon/terms/type/ErlangPid.java
@@ -17,8 +17,6 @@
package io.appulse.encon.terms.type;
import static io.appulse.encon.terms.TermType.PID;
-import static io.appulse.encon.terms.TermType.SMALL_ATOM;
-import static io.appulse.encon.terms.TermType.SMALL_ATOM_UTF8;
import static java.util.Optional.ofNullable;
import static lombok.AccessLevel.PRIVATE;
@@ -27,10 +25,8 @@
import io.appulse.encon.terms.ErlangTerm;
import io.appulse.encon.terms.TermType;
import io.appulse.encon.terms.exception.IllegalErlangTermTypeException;
-import io.appulse.utils.cache.LruCache;
import io.netty.buffer.ByteBuf;
-import io.netty.util.ByteProcessor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
@@ -51,34 +47,6 @@ public class ErlangPid extends ErlangTerm {
private static final long serialVersionUID = 7083159089429831665L;
- private static final LruCache CACHE = new LruCache<>(1000);
-
- @SuppressWarnings("deprecation")
- public static ErlangPid cached (TermType type, ByteBuf buffer) {
- int index = buffer.readerIndex();
- byte nodeNameType = buffer.readByte();
- int nodeNameLength = nodeNameType == SMALL_ATOM.getCode() || nodeNameType == SMALL_ATOM_UTF8.getCode()
- ? buffer.readUnsignedByte()
- : buffer.readUnsignedShort();
-
- int length = type == PID
- ? nodeNameLength + 9
- : nodeNameLength + 12;
-
- ByteArrayHashCode byteProcessor = new ByteArrayHashCode();
- buffer.forEachByte(buffer.readerIndex(), length, byteProcessor);
-
- return CACHE.compute(byteProcessor.getHashCode(), (key, value) -> {
- if (value == null) {
- buffer.readerIndex(index);
- return new ErlangPid(type, buffer);
- } else {
- buffer.skipBytes(length);
- return value;
- }
- });
- }
-
@NonFinal
NodeDescriptor descriptor;
@@ -183,17 +151,4 @@ protected void serialize (ByteBuf buffer) {
throw new IllegalErlangTermTypeException(getClass(), getType());
}
}
-
- @Getter
- @FieldDefaults(level = PRIVATE)
- private static class ByteArrayHashCode implements ByteProcessor {
-
- int hashCode = 1;
-
- @Override
- public boolean process (byte value) throws Exception {
- hashCode = 31 * hashCode + value;
- return true;
- }
- }
}
diff --git a/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangAtomTest.java b/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangAtomTest.java
index 80a4db9..2176d5f 100644
--- a/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangAtomTest.java
+++ b/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangAtomTest.java
@@ -24,11 +24,9 @@
import java.util.stream.IntStream;
-
import io.appulse.encon.terms.Erlang;
import io.appulse.encon.terms.ErlangTerm;
import io.appulse.utils.Bytes;
-import io.appulse.utils.test.TestMethodNamePrinter;
import erlang.OtpInputStream;
import erlang.OtpOutputStream;
@@ -36,22 +34,27 @@
import lombok.SneakyThrows;
import lombok.val;
import org.assertj.core.api.SoftAssertions;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestRule;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
/**
*
* @author Artem Labazin
* @since 1.0.0
*/
-public class ErlangAtomTest {
+@DisplayName("Check Erlang's Atom term type")
+class ErlangAtomTest {
- @Rule
- public TestRule watcher = new TestMethodNamePrinter();
+ @BeforeEach
+ void beforeEach (TestInfo testInfo) {
+ System.out.println("- " + testInfo.getDisplayName());
+ }
@Test
- public void instantiate () {
+ @DisplayName("create new instance by constructor")
+ void instantiate () {
assertThat(new ErlangAtom("hello").getType())
.isEqualTo(SMALL_ATOM_UTF8);
@@ -63,7 +66,8 @@ public void instantiate () {
}
@Test
- public void newInstance () {
+ @DisplayName("create new instance from bytes")
+ void newInstance () {
val value = "hello";
val bytes = Bytes.allocate()
.put1B(SMALL_ATOM_UTF8.getCode())
@@ -87,7 +91,8 @@ public void newInstance () {
}
@Test
- public void toBytes () {
+ @DisplayName("convert instance to byte array")
+ void toBytes () {
val value = "hello";
val expected = Bytes.allocate()
.put1B(SMALL_ATOM_UTF8.getCode())
@@ -100,7 +105,8 @@ public void toBytes () {
}
@Test
- public void encode () {
+ @DisplayName("encode instance to byte array and compare with jinterface output")
+ void encode () {
val smallValue = "popa";
val smallAtom = new ErlangAtom(smallValue);
@@ -132,7 +138,8 @@ public void encode () {
}
@Test
- public void decode () throws Exception {
+ @DisplayName("decode instance from byte array and compare with jinterface result")
+ void decode () throws Exception {
val value1 = "hello";
val bytes1 = Bytes.allocate()
.put1B(SMALL_ATOM_UTF8.getCode())
diff --git a/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangBinaryTest.java b/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangBinaryTest.java
index e8c8346..5696b8f 100644
--- a/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangBinaryTest.java
+++ b/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangBinaryTest.java
@@ -20,11 +20,9 @@
import static io.netty.buffer.Unpooled.wrappedBuffer;
import static org.assertj.core.api.Assertions.assertThat;
-
import io.appulse.encon.terms.Erlang;
import io.appulse.encon.terms.ErlangTerm;
import io.appulse.utils.Bytes;
-import io.appulse.utils.test.TestMethodNamePrinter;
import erlang.OtpErlangBinary;
import erlang.OtpInputStream;
@@ -32,22 +30,27 @@
import lombok.SneakyThrows;
import lombok.val;
import org.assertj.core.api.SoftAssertions;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestRule;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
/**
*
* @author Artem Labazin
* @since 1.0.0
*/
-public class ErlangBinaryTest {
+@DisplayName("Check Erlang's Binary term type")
+class ErlangBinaryTest {
- @Rule
- public TestRule watcher = new TestMethodNamePrinter();
+ @BeforeEach
+ void beforeEach (TestInfo testInfo) {
+ System.out.println("- " + testInfo.getDisplayName());
+ }
@Test
- public void instantiate () {
+ @DisplayName("create new instance by constructor")
+ void instantiate () {
val value = new byte[] { 1, 2, 3 };
assertThat(new ErlangBinary(value).asBinary())
@@ -55,7 +58,8 @@ public void instantiate () {
}
@Test
- public void newInstance () {
+ @DisplayName("create new instance from bytes")
+ void newInstance () {
val value = new byte[] { 1, 2, 3 };
val bytes = Bytes.allocate()
@@ -77,7 +81,8 @@ public void newInstance () {
}
@Test
- public void toBytes () {
+ @DisplayName("convert instance to byte array")
+ void toBytes () {
val value = new byte[] { 1, 2, 3 };
val expected = Bytes.allocate()
@@ -91,14 +96,16 @@ public void toBytes () {
}
@Test
- public void encode () {
+ @DisplayName("encode instance to byte array and compare with jinterface output")
+ void encode () {
val binary = new byte[] { 1, 2, 3, 4, 5 };
assertThat(Erlang.binary(binary).toBytes())
.isEqualTo(bytes(binary));
}
@Test
- public void decode () throws Exception {
+ @DisplayName("decode instance from byte array and compare with jinterface result")
+ void decode () throws Exception {
val value = new byte[] { 1, 2, 3 };
val bytes = Bytes.allocate()
diff --git a/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangBitStringTest.java b/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangBitStringTest.java
index 2b654cf..3378166 100644
--- a/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangBitStringTest.java
+++ b/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangBitStringTest.java
@@ -21,12 +21,10 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
import io.appulse.encon.terms.Erlang;
import io.appulse.encon.terms.exception.ErlangTermValidationException;
import io.appulse.encon.terms.ErlangTerm;
import io.appulse.utils.Bytes;
-import io.appulse.utils.test.TestMethodNamePrinter;
import erlang.OtpErlangBitstr;
import erlang.OtpInputStream;
@@ -34,22 +32,27 @@
import lombok.SneakyThrows;
import lombok.val;
import org.assertj.core.api.SoftAssertions;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestRule;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
/**
*
* @author Artem Labazin
* @since 1.0.0
*/
-public class ErlangBitStringTest {
+@DisplayName("Check Erlang's BitString term type")
+class ErlangBitStringTest {
- @Rule
- public TestRule watcher = new TestMethodNamePrinter();
+ @BeforeEach
+ void beforeEach (TestInfo testInfo) {
+ System.out.println("- " + testInfo.getDisplayName());
+ }
@Test
- public void erlangTermValidationException () {
+ @DisplayName("checks throwing exceptions in constructor")
+ void erlangTermValidationException () {
assertThatThrownBy(() -> new ErlangBitString(new byte[] { 1 }, -1))
.isInstanceOf(ErlangTermValidationException.class)
.hasMessage("Padding must be in range 0..7");
@@ -60,7 +63,8 @@ public void erlangTermValidationException () {
}
@Test
- public void newInstance () {
+ @DisplayName("create new instance from bytes")
+ void newInstance () {
val value = new byte[] { 1, 2, 3 };
val pad = 3;
@@ -84,7 +88,8 @@ public void newInstance () {
}
@Test
- public void toBytes () {
+ @DisplayName("convert instance to byte array")
+ void toBytes () {
val bits = new byte[] { 1, 2, 3 };
val pad = 3;
@@ -100,7 +105,8 @@ public void toBytes () {
}
@Test
- public void encode () {
+ @DisplayName("encode instance to byte array and compare with jinterface output")
+ void encode () {
val binary = new byte[] { 1, 2, 3 };
assertThat(Erlang.bitstr(binary, 1).toBytes())
@@ -114,7 +120,8 @@ public void encode () {
}
@Test
- public void decode () throws Exception {
+ @DisplayName("decode instance from byte array and compare with jinterface result")
+ void decode () throws Exception {
val bits = new byte[] { 1, 2, 3 };
val pad = 3;
diff --git a/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangFloatTest.java b/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangFloatTest.java
index 3053c49..d69eac2 100644
--- a/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangFloatTest.java
+++ b/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangFloatTest.java
@@ -26,28 +26,34 @@
import erlang.OtpErlangFloat;
import erlang.OtpInputStream;
import erlang.OtpOutputStream;
+
import io.appulse.encon.terms.Erlang;
import io.appulse.encon.terms.ErlangTerm;
import io.appulse.utils.Bytes;
-import io.appulse.utils.test.TestMethodNamePrinter;
+
import lombok.SneakyThrows;
import lombok.val;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestRule;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
/**
*
* @author Artem Labazin
* @since 1.0.0
*/
-public class ErlangFloatTest {
+@DisplayName("Check Erlang's Float term type")
+class ErlangFloatTest {
- @Rule
- public TestRule watcher = new TestMethodNamePrinter();
+ @BeforeEach
+ void beforeEach (TestInfo testInfo) {
+ System.out.println("- " + testInfo.getDisplayName());
+ }
@Test
- public void encode () {
+ @DisplayName("encode instance to byte array and compare with jinterface output")
+ void encode () {
assertThat(Erlang.number(Float.MIN_NORMAL).toBytes())
.isEqualTo(bytes(Float.MIN_NORMAL));
@@ -68,7 +74,8 @@ public void encode () {
}
@Test
- public void decode () throws Exception {
+ @DisplayName("decode instance from byte array and compare with jinterface result")
+ void decode () throws Exception {
val bytes1 = Bytes.allocate()
.put1B(FLOAT.getCode())
.put(String.format("%031.20e", Float.MAX_VALUE).getBytes(ISO_8859_1))
diff --git a/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangIntegerTest.java b/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangIntegerTest.java
index 3110520..2f79da9 100644
--- a/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangIntegerTest.java
+++ b/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangIntegerTest.java
@@ -27,32 +27,35 @@
import java.util.Arrays;
import java.util.stream.IntStream;
-
import io.appulse.encon.terms.ErlangTerm;
import io.appulse.utils.Bytes;
-import io.appulse.utils.test.TestMethodNamePrinter;
import erlang.OtpErlangLong;
import erlang.OtpInputStream;
import erlang.OtpOutputStream;
import lombok.SneakyThrows;
import lombok.val;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestRule;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
/**
*
* @author Artem Labazin
* @since 1.0.0
*/
-public class ErlangIntegerTest {
+@DisplayName("Check Erlang's Integer term type")
+class ErlangIntegerTest {
- @Rule
- public TestRule watcher = new TestMethodNamePrinter();
+ @BeforeEach
+ void beforeEach (TestInfo testInfo) {
+ System.out.println("- " + testInfo.getDisplayName());
+ }
@Test
- public void instantiate () {
+ @DisplayName("create new instance by constructor")
+ void instantiate () {
assertThat(new ErlangInteger(254).getType())
.isEqualTo(SMALL_INTEGER);
@@ -73,7 +76,8 @@ public void instantiate () {
}
@Test
- public void encode () {
+ @DisplayName("encode instance to byte array and compare with jinterface output")
+ void encode () {
assertThat(new ErlangInteger(Character.MIN_VALUE).toBytes())
.isEqualTo(bytes(Character.MIN_VALUE));
@@ -119,7 +123,8 @@ public void encode () {
}
@Test
- public void decode () throws Exception {
+ @DisplayName("decode instance from byte array and compare with jinterface result")
+ void decode () throws Exception {
val bytes1 = Bytes.allocate()
.put1B(SMALL_INTEGER.getCode())
.put1B(255)
@@ -167,6 +172,14 @@ public void decode () throws Exception {
}
}
+ @Test
+ @DisplayName("checks caching values")
+ void cached () {
+ ErlangInteger num1 = ErlangInteger.cached(1273);
+ ErlangInteger num2 = ErlangInteger.cached(117);
+ assertThat(num1).isNotEqualTo(num2);
+ }
+
@SneakyThrows
private byte[] bytes (char value) {
try (OtpOutputStream output = new OtpOutputStream()) {
diff --git a/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangListTest.java b/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangListTest.java
index 356ffd8..875886a 100644
--- a/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangListTest.java
+++ b/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangListTest.java
@@ -22,10 +22,8 @@
import java.util.stream.Stream;
-
import io.appulse.encon.terms.ErlangTerm;
import io.appulse.utils.Bytes;
-import io.appulse.utils.test.TestMethodNamePrinter;
import erlang.OtpErlangAtom;
import erlang.OtpErlangList;
@@ -33,22 +31,27 @@
import lombok.SneakyThrows;
import lombok.val;
import org.assertj.core.api.SoftAssertions;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestRule;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
/**
*
* @author Artem Labazin
* @since 1.0.0
*/
-public class ErlangListTest {
+@DisplayName("Check Erlang's List term type")
+class ErlangListTest {
- @Rule
- public TestRule watcher = new TestMethodNamePrinter();
+ @BeforeEach
+ void beforeEach (TestInfo testInfo) {
+ System.out.println("- " + testInfo.getDisplayName());
+ }
@Test
- public void newInstance () {
+ @DisplayName("create new instance from bytes")
+ void newInstance () {
val value = new ErlangNil();
val bytes = Bytes.allocate()
.put1B(LIST.getCode())
@@ -80,7 +83,8 @@ public void newInstance () {
}
@Test
- public void toBytes () {
+ @DisplayName("convert instance to byte array")
+ void toBytes () {
val value = new ErlangNil();
val expected = Bytes.allocate()
.put1B(LIST.getCode())
@@ -94,7 +98,8 @@ public void toBytes () {
}
@Test
- public void encode () {
+ @DisplayName("encode instance to byte array and compare with jinterface output")
+ void encode () {
String[] values = new String[] {
"one",
"two",
diff --git a/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangMapTest.java b/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangMapTest.java
index 4124052..044deea 100644
--- a/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangMapTest.java
+++ b/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangMapTest.java
@@ -22,31 +22,34 @@
import java.util.LinkedHashMap;
import java.util.List;
-
import io.appulse.encon.terms.ErlangTerm;
-import io.appulse.utils.test.TestMethodNamePrinter;
import erlang.OtpErlangMap;
import erlang.OtpErlangObject;
import erlang.OtpErlangString;
import erlang.OtpOutputStream;
import lombok.SneakyThrows;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestRule;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
/**
*
* @author Artem Labazin
* @since 1.0.0
*/
-public class ErlangMapTest {
+@DisplayName("Check Erlang's Map term type")
+class ErlangMapTest {
- @Rule
- public TestRule watcher = new TestMethodNamePrinter();
+ @BeforeEach
+ void beforeEach (TestInfo testInfo) {
+ System.out.println("- " + testInfo.getDisplayName());
+ }
@Test
- public void encode () {
+ @DisplayName("encode instance to byte array and compare with jinterface output")
+ void encode () {
LinkedHashMap value = new LinkedHashMap<>(3);
value.put("one", "1");
value.put("two", "2");
diff --git a/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangNilTest.java b/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangNilTest.java
index 4aafb86..07109c9 100644
--- a/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangNilTest.java
+++ b/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangNilTest.java
@@ -22,27 +22,31 @@
import io.appulse.encon.terms.ErlangTerm;
import io.appulse.utils.Bytes;
-import io.appulse.utils.test.TestMethodNamePrinter;
import erlang.OtpOutputStream;
import lombok.SneakyThrows;
import lombok.val;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestRule;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
/**
*
* @author Artem Labazin
* @since 1.0.0
*/
-public class ErlangNilTest {
+@DisplayName("Check Erlang's NIL term type")
+class ErlangNilTest {
- @Rule
- public TestRule watcher = new TestMethodNamePrinter();
+ @BeforeEach
+ void beforeEach (TestInfo testInfo) {
+ System.out.println("- " + testInfo.getDisplayName());
+ }
@Test
- public void newInstance () {
+ @DisplayName("create new instance from bytes")
+ void newInstance () {
val bytes = Bytes.allocate()
.put1B(NIL.getCode())
.array();
@@ -54,7 +58,8 @@ public void newInstance () {
}
@Test
- public void toBytes () {
+ @DisplayName("convert instance to byte array")
+ void toBytes () {
val expected = Bytes.allocate()
.put1B(NIL.getCode())
.array();
@@ -64,7 +69,8 @@ public void toBytes () {
}
@Test
- public void encode () {
+ @DisplayName("encode instance to byte array and compare with jinterface output")
+ void encode () {
assertThat(new ErlangNil().toBytes())
.isEqualTo(bytes());
}
diff --git a/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangPidTest.java b/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangPidTest.java
index 8951b8a..b382643 100644
--- a/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangPidTest.java
+++ b/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangPidTest.java
@@ -24,28 +24,34 @@
import erlang.OtpErlangPid;
import erlang.OtpInputStream;
import erlang.OtpOutputStream;
+
import io.appulse.encon.terms.ErlangTerm;
import io.appulse.utils.Bytes;
-import io.appulse.utils.test.TestMethodNamePrinter;
+
import lombok.SneakyThrows;
import lombok.val;
import org.assertj.core.api.SoftAssertions;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestRule;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
/**
*
* @author Artem Labazin
* @since 1.0.0
*/
-public class ErlangPidTest {
+@DisplayName("Check Erlang's Pid term type")
+class ErlangPidTest {
- @Rule
- public TestRule watcher = new TestMethodNamePrinter();
+ @BeforeEach
+ void beforeEach (TestInfo testInfo) {
+ System.out.println("- " + testInfo.getDisplayName());
+ }
@Test
- public void newInstance () {
+ @DisplayName("create new instance from bytes")
+ void newInstance () {
val node = "popa";
val id = 500;
val serial = 10;
@@ -78,7 +84,8 @@ public void newInstance () {
}
@Test
- public void toBytes () {
+ @DisplayName("convert instance to byte array")
+ void toBytes () {
val node = "popa";
val id = 500;
val serial = 10;
@@ -104,7 +111,8 @@ public void toBytes () {
}
@Test
- public void encode () {
+ @DisplayName("encode instance to byte array and compare with jinterface output")
+ void encode () {
assertThat(ErlangPid.builder()
.node("popa@localhost")
.id(1)
@@ -128,7 +136,8 @@ public void encode () {
}
@Test
- public void decode () throws Exception {
+ @DisplayName("decode instance from byte array and compare with jinterface result")
+ void decode () throws Exception {
byte[] bytes1 = Bytes.allocate()
.put1B(PID.getCode())
.put(new ErlangAtom("popa@localhost").toBytes())
diff --git a/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangPortTest.java b/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangPortTest.java
index 0265952..c6f4c3b 100644
--- a/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangPortTest.java
+++ b/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangPortTest.java
@@ -23,7 +23,6 @@
import io.appulse.encon.terms.ErlangTerm;
import io.appulse.utils.Bytes;
-import io.appulse.utils.test.TestMethodNamePrinter;
import erlang.OtpErlangPort;
import erlang.OtpInputStream;
@@ -31,22 +30,27 @@
import lombok.SneakyThrows;
import lombok.val;
import org.assertj.core.api.SoftAssertions;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestRule;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
/**
*
* @author Artem Labazin
* @since 1.0.0
*/
-public class ErlangPortTest {
+@DisplayName("Check Erlang's Port term type")
+class ErlangPortTest {
- @Rule
- public TestRule watcher = new TestMethodNamePrinter();
+ @BeforeEach
+ void beforeEach (TestInfo testInfo) {
+ System.out.println("- " + testInfo.getDisplayName());
+ }
@Test
- public void newInstance () {
+ @DisplayName("create new instance from bytes")
+ void newInstance () {
val node = "popa@localhost";
val id = 500;
val creation = 42;
@@ -74,7 +78,8 @@ public void newInstance () {
}
@Test
- public void toBytes () {
+ @DisplayName("convert instance to byte array")
+ void toBytes () {
val node = "popa@localhost";
val id = 500;
val creation = 42;
@@ -97,7 +102,8 @@ public void toBytes () {
}
@Test
- public void encode () {
+ @DisplayName("encode instance to byte array and compare with jinterface output")
+ void encode () {
assertThat(ErlangPort.builder()
.node("popa@localhost")
.id(1)
@@ -119,7 +125,8 @@ public void encode () {
}
@Test
- public void decode () throws Exception {
+ @DisplayName("decode instance from byte array and compare with jinterface result")
+ void decode () throws Exception {
byte[] bytes1 = Bytes.allocate()
.put1B(PORT.getCode())
.put(new ErlangAtom("popa@localhost").toBytes())
diff --git a/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangReferenceTest.java b/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangReferenceTest.java
index 92ef439..cdcdc19 100644
--- a/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangReferenceTest.java
+++ b/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangReferenceTest.java
@@ -26,7 +26,6 @@
import io.appulse.encon.terms.ErlangTerm;
import io.appulse.utils.Bytes;
-import io.appulse.utils.test.TestMethodNamePrinter;
import erlang.OtpErlangRef;
import erlang.OtpInputStream;
@@ -35,9 +34,10 @@
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.assertj.core.api.SoftAssertions;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestRule;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
/**
*
@@ -45,13 +45,17 @@
* @since 1.0.0
*/
@Slf4j
-public class ErlangReferenceTest {
+@DisplayName("Check Erlang's Reference term type")
+class ErlangReferenceTest {
- @Rule
- public TestRule watcher = new TestMethodNamePrinter();
+ @BeforeEach
+ void beforeEach (TestInfo testInfo) {
+ System.out.println("- " + testInfo.getDisplayName());
+ }
@Test
- public void instantiate () {
+ @DisplayName("create new instance by constructor")
+ void instantiate () {
assertThat(ErlangReference.builder()
.node("popa")
.id(3)
@@ -63,7 +67,8 @@ public void instantiate () {
}
@Test
- public void newInstance () {
+ @DisplayName("create new instance from bytes")
+ void newInstance () {
val node = "popa@localhost";
val ids = new long[] { 1, 0, 0 };
val creation = 42;
@@ -100,7 +105,8 @@ public void newInstance () {
}
@Test
- public void toBytes () {
+ @DisplayName("convert instance to byte array")
+ void toBytes () {
val node = "popa@localhost";
val ids = new long[] { 1, 0, 0 };
val creation = 42;
@@ -129,7 +135,8 @@ public void toBytes () {
}
@Test
- public void encode () {
+ @DisplayName("encode instance to byte array and compare with jinterface output")
+ void encode () {
assertThat(ErlangReference.builder()
.node("popa@localhost")
.ids(new long[] { 1 })
@@ -168,7 +175,8 @@ public void encode () {
}
@Test
- public void decode () throws Exception {
+ @DisplayName("decode instance from byte array and compare with jinterface result")
+ void decode () throws Exception {
byte[] bytes1 = Bytes.allocate()
.put1B(REFERENCE.getCode())
.put(new ErlangAtom("popa@localhost").toBytes())
diff --git a/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangStringTest.java b/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangStringTest.java
index 9ae437e..fad4c72 100644
--- a/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangStringTest.java
+++ b/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangStringTest.java
@@ -25,29 +25,33 @@
import io.appulse.encon.terms.ErlangTerm;
import io.appulse.utils.Bytes;
-import io.appulse.utils.test.TestMethodNamePrinter;
import erlang.OtpErlangString;
import erlang.OtpInputStream;
import erlang.OtpOutputStream;
import lombok.SneakyThrows;
import lombok.val;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestRule;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
/**
*
* @author Artem Labazin
* @since 1.0.0
*/
-public class ErlangStringTest {
+@DisplayName("Check Erlang's String term type")
+class ErlangStringTest {
- @Rule
- public TestRule watcher = new TestMethodNamePrinter();
+ @BeforeEach
+ void beforeEach (TestInfo testInfo) {
+ System.out.println("- " + testInfo.getDisplayName());
+ }
@Test
- public void encode () {
+ @DisplayName("encode instance to byte array and compare with jinterface output")
+ void encode () {
assertThat(new ErlangString("").toBytes())
.isEqualTo(bytes(""));
@@ -64,7 +68,8 @@ public void encode () {
}
@Test
- public void decode () throws Exception {
+ @DisplayName("decode instance from byte array and compare with jinterface result")
+ void decode () throws Exception {
val bytes = Bytes.allocate()
.put1B(STRING.getCode())
.put2B("popa".length())
diff --git a/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangTupleTest.java b/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangTupleTest.java
index 091cf5f..2a9666e 100644
--- a/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangTupleTest.java
+++ b/encon-terms/src/test/java/io/appulse/encon/terms/type/ErlangTupleTest.java
@@ -29,7 +29,6 @@
import io.appulse.encon.terms.ErlangTerm;
import io.appulse.utils.Bytes;
-import io.appulse.utils.test.TestMethodNamePrinter;
import erlang.OtpErlangAtom;
import erlang.OtpErlangInt;
@@ -42,22 +41,27 @@
import lombok.SneakyThrows;
import lombok.val;
import org.assertj.core.api.SoftAssertions;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestRule;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
/**
*
* @author Artem Labazin
* @since 1.0.0
*/
-public class ErlangTupleTest {
+@DisplayName("Check Erlang's Tuple term type")
+class ErlangTupleTest {
- @Rule
- public TestRule watcher = new TestMethodNamePrinter();
+ @BeforeEach
+ void beforeEach (TestInfo testInfo) {
+ System.out.println("- " + testInfo.getDisplayName());
+ }
@Test
- public void instantiate () {
+ @DisplayName("create new instance by constructor")
+ void instantiate () {
assertThat(new ErlangTuple(new ErlangNil()).getType())
.isEqualTo(SMALL_TUPLE);
@@ -71,7 +75,8 @@ public void instantiate () {
}
@Test
- public void newInstance () {
+ @DisplayName("create new instance from bytes")
+ void newInstance () {
val value = new ErlangNil();
val bytes = Bytes.allocate()
.put1B(SMALL_TUPLE.getCode())
@@ -99,7 +104,8 @@ public void newInstance () {
}
@Test
- public void toBytes () {
+ @DisplayName("convert instance to byte array")
+ void toBytes () {
val value = new ErlangNil();
val expected = Bytes.allocate()
.put1B(SMALL_TUPLE.getCode())
@@ -112,7 +118,8 @@ public void toBytes () {
}
@Test
- public void encode () {
+ @DisplayName("encode instance to byte array and compare with jinterface output")
+ void encode () {
String[] values = new String[] {
"one",
"two",
diff --git a/encon/README.md b/encon/README.md
index e947af2..ebc4b31 100644
--- a/encon/README.md
+++ b/encon/README.md
@@ -1,5 +1,13 @@
# Overview
+[](https://travis-ci.org/appulse-projects/encon-java)
+[](https://search.maven.org/search?q=a:encon)
+[](http://www.apache.org/licenses/LICENSE-2.0.html)
+[](http://www.javadoc.io/doc/io.appulse.encon/encon)
+
+
+
+
This project contains the general-purpose data-binding functionality.
- [Add dependency](#add-dependency)
@@ -21,7 +29,7 @@ Adding encon's dependency to your `JVM` app:
io.appulse.enconencon
- 1.6.5
+ 2.0.0
...
@@ -30,7 +38,7 @@ Adding encon's dependency to your `JVM` app:
**Gradle**:
```groovy
-compile 'io.appulse.encon:encon:1.6.5'
+compile 'io.appulse.encon:encon:2.0.0'
```
## Start the Node
diff --git a/encon/pom.xml b/encon/pom.xml
index 9380b1d..879baba 100644
--- a/encon/pom.xml
+++ b/encon/pom.xml
@@ -25,19 +25,13 @@ limitations under the License.
io.appulse.enconencon-parent
- 1.6.5
+ 2.0.0enconjar
-
- org.projectlombok
- lombok
- provided
-
-
${project.groupId}encon-common
@@ -67,21 +61,9 @@ limitations under the License.
client
-
- com.google.code.findbugs
- annotations
- provided
-
-
- com.google.code.findbugs
- jsr305
- provided
-
-
org.yamlsnakeyaml
- 1.21
@@ -99,21 +81,6 @@ limitations under the License.
servertest
-
- junit
- junit
- test
-
-
- org.assertj
- assertj-core
- test
-
-
- org.mockito
- mockito-core
- test
-
@@ -128,14 +95,13 @@ limitations under the License.
- org.codehaus.mojo
- findbugs-maven-plugin
+ com.github.spotbugs
+ spotbugs-maven-pluginorg.apache.maven.pluginsmaven-pmd-plugin
-
org.apache.maven.pluginsmaven-checkstyle-plugin
diff --git a/encon/src/main/java/io/appulse/encon/ModuleRemoteProcedureCall.java b/encon/src/main/java/io/appulse/encon/ModuleRemoteProcedureCall.java
new file mode 100644
index 0000000..302b0bd
--- /dev/null
+++ b/encon/src/main/java/io/appulse/encon/ModuleRemoteProcedureCall.java
@@ -0,0 +1,404 @@
+/*
+ * Copyright 2018 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.appulse.encon;
+
+import static io.appulse.encon.terms.Erlang.NIL;
+import static io.appulse.encon.terms.Erlang.atom;
+import static io.appulse.encon.terms.Erlang.list;
+import static io.appulse.encon.terms.Erlang.tuple;
+import static java.util.Optional.ofNullable;
+import static java.util.concurrent.TimeUnit.NANOSECONDS;
+import static lombok.AccessLevel.PACKAGE;
+import static lombok.AccessLevel.PRIVATE;
+
+import java.util.Optional;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
+
+import io.appulse.encon.common.NodeDescriptor;
+import io.appulse.encon.common.RemoteNode;
+import io.appulse.encon.connection.regular.Message;
+import io.appulse.encon.exception.NoSuchRemoteNodeException;
+import io.appulse.encon.mailbox.Mailbox;
+import io.appulse.encon.terms.ErlangTerm;
+import io.appulse.encon.terms.type.ErlangAtom;
+
+import lombok.AllArgsConstructor;
+import lombok.NonNull;
+import lombok.experimental.FieldDefaults;
+import lombok.val;
+
+/**
+ * Module with set of methods for remote procedure calls.
+ *
+ * @since 2.0.0
+ * @author Artem Labazin
+ */
+@AllArgsConstructor(access = PACKAGE)
+@FieldDefaults(level = PRIVATE, makeFinal = true)
+public class ModuleRemoteProcedureCall {
+
+ Node node;
+
+ /**
+ * Send an RPC request to the remote Erlang node. This convenience function
+ * creates the following message and sends it to 'rex' on the remote node:
+ *
+ *
+ * Note that this method has unpredicatble results if the remote node is not
+ * an Erlang node.
+ *
+ *
+ *
+ * The response will be send back to this node in format:
+ *
+ * { :rex, response_body }
+ *
+ *
+ *
+ * @param remoteNodeName remote node name
+ *
+ * @param module the name of the Erlang module containing the function to be called.
+ *
+ * @param function the name of the function to call.
+ *
+ * @param args a list of Erlang terms, to be used as arguments to the function.
+ *
+ * @return response holder, instance of {@link RpcResponse}.
+ */
+ public RpcResponse call (@NonNull String remoteNodeName, @NonNull String module, @NonNull String function, ErlangTerm ...args) {
+ return call(remoteNodeName, atom(module), atom(function), args);
+ }
+
+ /**
+ * Send an RPC request to the remote Erlang node. This convenience function
+ * creates the following message and sends it to 'rex' on the remote node:
+ *
+ *
+ * Note that this method has unpredicatble results if the remote node is not
+ * an Erlang node.
+ *
+ *
+ *
+ * The response will be send back to this node in format:
+ *
+ * { :rex, response_body }
+ *
+ *
+ *
+ * @param descriptor remote node descriptor
+ *
+ * @param module the name of the Erlang module containing the function to be called.
+ *
+ * @param function the name of the function to call.
+ *
+ * @param args a list of Erlang terms, to be used as arguments to the function.
+ *
+ * @return response holder, instance of {@link RpcResponse}.
+ */
+ public RpcResponse call (@NonNull NodeDescriptor descriptor, @NonNull String module, @NonNull String function, ErlangTerm ...args) {
+ return call(descriptor, atom(module), atom(function), args);
+ }
+
+ /**
+ * Send an RPC request to the remote Erlang node. This convenience function
+ * creates the following message and sends it to 'rex' on the remote node:
+ *
+ *
+ * Note that this method has unpredicatble results if the remote node is not
+ * an Erlang node.
+ *
+ *
+ *
+ * The response will be send back to this node in format:
+ *
+ * { :rex, response_body }
+ *
+ *
+ *
+ * @param remote remote node descriptor
+ *
+ * @param module the name of the Erlang module containing the function to be called.
+ *
+ * @param function the name of the function to call.
+ *
+ * @param args a list of Erlang terms, to be used as arguments to the function.
+ *
+ * @return response holder, instance of {@link RpcResponse}.
+ */
+ public RpcResponse call (@NonNull RemoteNode remote, @NonNull String module, @NonNull String function, ErlangTerm ...args) {
+ return call(remote, atom(module), atom(function), args);
+ }
+
+ /**
+ * Send an RPC request to the remote Erlang node. This convenience function
+ * creates the following message and sends it to 'rex' on the remote node:
+ *
+ *
+ * Note that this method has unpredicatble results if the remote node is not
+ * an Erlang node.
+ *
+ *
+ *
+ * The response will be send back to this node in format:
+ *
+ * { :rex, response_body }
+ *
+ *
+ *
+ * @param remoteNodeName remote node name
+ *
+ * @param module the atom of the Erlang module containing the function to be called.
+ *
+ * @param function the atom of the function to call.
+ *
+ * @param args a list of Erlang terms, to be used as arguments to the function.
+ *
+ * @return response holder, instance of {@link RpcResponse}.
+ */
+ public RpcResponse call (@NonNull String remoteNodeName, @NonNull ErlangAtom module, @NonNull ErlangAtom function, ErlangTerm ...args) {
+ val descriptor = NodeDescriptor.from(remoteNodeName);
+ return call(descriptor, module, function, args);
+ }
+
+ /**
+ * Send an RPC request to the remote Erlang node. This convenience function
+ * creates the following message and sends it to 'rex' on the remote node:
+ *
+ *
+ * Note that this method has unpredicatble results if the remote node is not
+ * an Erlang node.
+ *
+ *
+ *
+ * The response will be send back to this node in format:
+ *
+ * { :rex, response_body }
+ *
+ *
+ *
+ * @param descriptor remote node descriptor
+ *
+ * @param module the atom of the Erlang module containing the function to be called.
+ *
+ * @param function the atom of the function to call.
+ *
+ * @param args a list of Erlang terms, to be used as arguments to the function.
+ *
+ * @return response holder, instance of {@link RpcResponse}.
+ */
+ public RpcResponse call (@NonNull NodeDescriptor descriptor,
+ @NonNull ErlangAtom module,
+ @NonNull ErlangAtom function,
+ ErlangTerm ...args
+ ) {
+ RemoteNode remote = node.lookup(descriptor);
+ if (remote == null) {
+ throw new NoSuchRemoteNodeException(descriptor);
+ }
+ return call(remote, module, function, args);
+ }
+
+ /**
+ * Send an RPC request to the remote Erlang node. This convenience function
+ * creates the following message and sends it to 'rex' on the remote node:
+ *
+ *
+ * Note that this method has unpredicatble results if the remote node is not
+ * an Erlang node.
+ *
+ *
+ *
+ * The response will be send back to this node in format:
+ *
+ * { :rex, response_body }
+ *
+ *
+ *
+ * @param remote remote node descriptor
+ *
+ * @param module the atom of the Erlang module containing the function to be called.
+ *
+ * @param function the atom of the function to call.
+ *
+ * @param args a list of Erlang terms, to be used as arguments to the function.
+ *
+ * @return response holder, instance of {@link RpcResponse}.
+ */
+ @SuppressWarnings("PMD.AccessorClassGeneration")
+ public RpcResponse call (@NonNull RemoteNode remote, @NonNull ErlangAtom module, @NonNull ErlangAtom function, ErlangTerm ...args) {
+ ErlangTerm argumentsList;
+ if (args == null || args.length == 0) {
+ argumentsList = NIL;
+ } else if (args.length == 1 && args[0].isList()) {
+ argumentsList = args[0];
+ } else {
+ argumentsList = list(args);
+ }
+
+ Mailbox mailbox = node.mailbox().build();
+ mailbox.send(remote, "rex", tuple(
+ mailbox.getPid(),
+ tuple(
+ atom("call"),
+ module,
+ function,
+ argumentsList,
+ atom("user")
+ )
+ ));
+ return new RpcResponse(mailbox);
+ }
+
+ /**
+ * Remote procedure call response holder.
+ */
+ @FieldDefaults(level = PRIVATE)
+ public static final class RpcResponse {
+
+ Mailbox mailbox;
+
+ final AtomicReference response = new AtomicReference<>(null);
+
+ private RpcResponse (Mailbox mailbox) {
+ this.mailbox = mailbox;
+ }
+
+ /**
+ * Checks if a response was coming or not.
+ *
+ * @return {@code true} if this holder has a response, {@code false} otherwise.
+ */
+ public boolean hasResponse () {
+ return response.get() != null || (mailbox != null && mailbox.size() == 0);
+ }
+
+ /**
+ * Receive an RPC reply from the remote Erlang node in asynchronous manner.
+ * This convenience function receives a message from the remote node, and expects it to have
+ * the following format:
+ *
+ *
+ * { :rex, ErlangTerm }
+ *
+ *
+ * @return the second element of the tuple if the received message is a
+ * two-tuple, otherwise empty. No further error checking is
+ * performed.
+ */
+ public Optional getAsync () {
+ ErlangTerm result = response.get();
+ if (result == null) {
+ result = getSync(1, NANOSECONDS);
+ }
+ return ofNullable(result);
+ }
+
+ /**
+ * Receive an RPC reply from the remote Erlang node in synchronous manner.
+ * This convenience function receives a message from the remote node, and expects it to have
+ * the following format:
+ *
+ *
+ * { :rex, ErlangTerm }
+ *
+ *
+ * @return the second element of the tuple if the received message is a
+ * two-tuple, otherwise null. No further error checking is
+ * performed.
+ */
+ public ErlangTerm getSync () {
+ ErlangTerm result = response.get();
+ if (result != null) {
+ return result;
+ }
+ return mailbox.receive()
+ .getBody()
+ .get(1)
+ .map(this::process)
+ .orElse(null);
+ }
+
+ /**
+ * Receive an RPC reply from the remote Erlang node in synchronous manner.
+ * This convenience function receives a message from the remote node, and expects it to have
+ * the following format:
+ *
+ *
+ * { :rex, ErlangTerm }
+ *
+ *
+ * @param timeout how long to wait before giving up, in units of
+ * {@code unit}
+ * @param unit a {@code TimeUnit} determining how to interpret the
+ * {@code timeout} parameter
+ *
+ * @return the second element of the tuple if the received message is a
+ * two-tuple, otherwise null. No further error checking is
+ * performed. It also could return {@code null} if the specified
+ * waiting time elapses before an element is available
+ */
+ public ErlangTerm getSync (long timeout, TimeUnit unit) {
+ ErlangTerm result = response.get();
+ if (result != null) {
+ return result;
+ }
+ Message message = mailbox.receive(timeout, unit);
+ if (message == null) {
+ return null;
+ }
+ return message.getBody()
+ .get(1)
+ .map(this::process)
+ .orElse(null);
+ }
+
+ @SuppressWarnings("PMD.NullAssignment")
+ private ErlangTerm process (ErlangTerm term) {
+ if (!response.compareAndSet(null, term)) {
+ return null;
+ }
+ mailbox.close();
+ mailbox = null;
+ return term;
+ }
+ }
+}
diff --git a/encon/src/main/java/io/appulse/encon/Node.java b/encon/src/main/java/io/appulse/encon/Node.java
index 9cb2ce8..59e4997 100644
--- a/encon/src/main/java/io/appulse/encon/Node.java
+++ b/encon/src/main/java/io/appulse/encon/Node.java
@@ -23,10 +23,10 @@
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
+import io.appulse.encon.NodesConfig.NodeConfig;
import io.appulse.encon.common.Meta;
import io.appulse.encon.common.NodeDescriptor;
import io.appulse.encon.common.RemoteNode;
-import io.appulse.encon.config.NodeConfig;
import io.appulse.encon.connection.Connection;
import io.appulse.encon.mailbox.Mailbox;
import io.appulse.encon.mailbox.ModuleMailbox;
@@ -41,7 +41,6 @@
import lombok.ToString;
import lombok.experimental.FieldDefaults;
import lombok.extern.slf4j.Slf4j;
-import lombok.val;
/**
* Node's state holder and provider of all needed functions.
@@ -59,23 +58,26 @@
@FieldDefaults(level = PACKAGE, makeFinal = true)
public final class Node implements Closeable {
- static Node newInstance (@NonNull String name, @NonNull NodeConfig config) {
+ // static Node newInstance (@NonNull String name, @NonNull Config config) {
+ // NodeConfig nodeConfig = config.get(NodeConfig.class, NodeConfig.DEFAULT);
+ static Node newInstance (@NonNull String name, @NonNull NodeConfig nodeConfig) {
+ NodeConfig configCopy = new NodeConfig(nodeConfig);
- val descriptor = NodeDescriptor.from(name, config.getShortName());
- log.debug("Creating new Node '{}' with config:\n {}\n", descriptor.getFullName(), config);
+ NodeDescriptor descriptor = NodeDescriptor.from(name, configCopy.getShortName());
+ log.debug("Creating new Node '{}' with config:\n {}\n", descriptor.getFullName(), configCopy);
- val meta = Meta.builder()
- .type(config.getType())
- .protocol(config.getProtocol())
- .low(config.getLowVersion())
- .high(config.getHighVersion())
- .flags(config.getDistributionFlags())
+ Meta meta = Meta.builder()
+ .type(configCopy.getType())
+ .protocol(configCopy.getProtocol())
+ .low(configCopy.getLowVersion())
+ .high(configCopy.getHighVersion())
+ .flags(configCopy.getDistributionFlags())
.build();
- val epmd = new EpmdClient(config.getEpmdPort());
- val creation = epmd.register(Registration.builder()
+ EpmdClient epmd = new EpmdClient(configCopy.getEpmdPort());
+ int creation = epmd.register(Registration.builder()
.name(descriptor.getNodeName())
- .port(config.getServer().getPort())
+ .port(configCopy.getServer().getOrFindAndSetPort())
.type(meta.getType())
.protocol(meta.getProtocol())
.high(meta.getHigh())
@@ -89,17 +91,11 @@ static Node newInstance (@NonNull String name, @NonNull NodeConfig config) {
.meta(meta)
.epmd(epmd)
.creation(creation)
- .config(config)
+ .config(configCopy)
.build();
node.moduleMailbox.registerNetKernelMailbox();
- config.getMailboxes().forEach(it -> {
- node.mailbox()
- .name(it.getName())
- .build();
- });
-
log.debug("Node '{}' was created", descriptor.getFullName());
return node;
}
@@ -137,6 +133,8 @@ static Node newInstance (@NonNull String name, @NonNull NodeConfig config) {
ModuleClient moduleClient;
+ ModuleRemoteProcedureCall moduleRemoteProcedureCall;
+
@Builder
private Node (@NonNull NodeDescriptor descriptor,
@NonNull Meta meta,
@@ -144,12 +142,14 @@ private Node (@NonNull NodeDescriptor descriptor,
int creation,
@NonNull NodeConfig config
) {
+ NodeConfig configCopy = new NodeConfig(config);
+
this.descriptor = descriptor;
this.meta = meta;
this.epmd = epmd;
- cookie = config.getCookie();
- port = config.getServer().getPort();
+ cookie = configCopy.getCookie();
+ port = configCopy.getServer().getOrFindAndSetPort();
generatorPid = new GeneratorPid(descriptor.getFullName(), creation);
generatorPort = new GeneratorPort(descriptor.getFullName(), creation);
@@ -159,12 +159,24 @@ private Node (@NonNull NodeDescriptor descriptor,
moduleLookup = new ModuleLookup(epmd);
moduleConnection = new ModuleConnection(
descriptor.getNodeName(),
- config.getServer().getBossThreads(),
- config.getServer().getWorkerThreads()
+ configCopy.getServer().getBossThreads(),
+ configCopy.getServer().getWorkerThreads()
);
moduleServer = new ModuleServer(this, moduleConnection, port);
- moduleClient = new ModuleClient(this, moduleConnection, config.getShortName());
+ moduleClient = new ModuleClient(this, moduleConnection, configCopy.getShortName());
moduleMailbox = new ModuleMailbox(this, () -> generatorPid.generate());
+
+ moduleRemoteProcedureCall = new ModuleRemoteProcedureCall(this);
+ }
+
+ /**
+ * Returns reference on {@link ModuleRemoteProcedureCall} instance
+ * for calling remote node's functions.
+ *
+ * @return {@link ModuleRemoteProcedureCall} instance.
+ */
+ public ModuleRemoteProcedureCall rpc () {
+ return moduleRemoteProcedureCall;
}
/**
diff --git a/encon/src/main/java/io/appulse/encon/Nodes.java b/encon/src/main/java/io/appulse/encon/Nodes.java
index b29362e..d9102a0 100644
--- a/encon/src/main/java/io/appulse/encon/Nodes.java
+++ b/encon/src/main/java/io/appulse/encon/Nodes.java
@@ -26,16 +26,14 @@
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
+import io.appulse.encon.NodesConfig.NodeConfig;
import io.appulse.encon.common.NodeDescriptor;
import io.appulse.encon.config.Config;
-import io.appulse.encon.config.Defaults;
-import io.appulse.encon.config.NodeConfig;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.experimental.FieldDefaults;
import lombok.extern.slf4j.Slf4j;
-import lombok.val;
/**
* The set of different helper functions
@@ -55,7 +53,9 @@ public final class Nodes implements Iterable, Closeable {
* @return a new {@link Nodes} instance
*/
public static Nodes start () {
- val config = Config.builder().build();
+ Config config = Config.builder()
+ .build();
+
return start(config);
}
@@ -67,13 +67,12 @@ public static Nodes start () {
* @return a new {@link Nodes} instance
*/
public static Nodes start (@NonNull Config config) {
- val copy = new Config(config);
- log.debug("Creating ERTS instance with config {}", copy);
+ log.debug("Creating ERTS instance with config {}", config);
- val erts = new Nodes(copy.getDefaults(), new ConcurrentHashMap<>());
- copy.getNodes()
- .entrySet()
- .forEach(it -> erts.newNode(it.getKey(), it.getValue()));
+ Nodes erts = new Nodes(config, new ConcurrentHashMap<>());
+ config.get(NodesConfig.class).ifPresent(cfg -> {
+ cfg.getNodes().forEach((name, nodeConfig) -> erts.newNode(name, nodeConfig));
+ });
return erts;
}
@@ -114,12 +113,10 @@ public static Node singleNode (@NonNull String name, boolean isShortNamed) {
* @return new {@link Node} instance
*/
public static Node singleNode (@NonNull String name, @NonNull NodeConfig nodeConfig) {
- val copy = new NodeConfig(nodeConfig);
- copy.withDefaultsFrom(Defaults.INSTANCE);
- return Node.newInstance(name, copy);
+ return Node.newInstance(name, nodeConfig);
}
- Defaults defaults;
+ Config config;
Map nodes;
@@ -131,7 +128,7 @@ public static Node singleNode (@NonNull String name, @NonNull NodeConfig nodeCon
* @return new {@link Node} instance
*/
public Node newNode (@NonNull String name) {
- val nodeConfig = NodeConfig.builder().build();
+ NodeConfig nodeConfig = config.get("nodex." + name, NodeConfig.class, NodeConfig.DEFAULT);
return newNode(name, nodeConfig);
}
@@ -145,9 +142,9 @@ public Node newNode (@NonNull String name) {
* @return new {@link Node} instance
*/
public Node newNode (@NonNull String name, boolean isShortNamed) {
- val nodeConfig = NodeConfig.builder()
- .shortName(isShortNamed)
- .build();
+ NodeConfig nodeConfig = config.get("nodex." + name, NodeConfig.class, NodeConfig.DEFAULT)
+ .withShortName(isShortNamed);
+
return newNode(name, nodeConfig);
}
@@ -162,9 +159,7 @@ public Node newNode (@NonNull String name, boolean isShortNamed) {
* @return new {@link Node} instance
*/
public Node newNode (@NonNull String name, @NonNull NodeConfig nodeConfig) {
- val copy = new NodeConfig(nodeConfig);
- copy.withDefaultsFrom(defaults);
- val node = Node.newInstance(name, copy);
+ Node node = Node.newInstance(name, nodeConfig);
nodes.put(node.getDescriptor(), node);
return node;
}
@@ -177,7 +172,7 @@ public Node newNode (@NonNull String name, @NonNull NodeConfig nodeConfig) {
* @return optional value, which could contains a searching node
*/
public Optional node (@NonNull String name) {
- val descriptor = NodeDescriptor.from(name);
+ NodeDescriptor descriptor = NodeDescriptor.from(name);
return node(descriptor);
}
@@ -209,7 +204,7 @@ public Collection nodes () {
* @return the previous value associated with a name, or {@code null} if there was no mapping for name.
*/
public Node remove (@NonNull String name) {
- val descriptor = NodeDescriptor.from(name);
+ NodeDescriptor descriptor = NodeDescriptor.from(name);
return remove(descriptor);
}
diff --git a/encon/src/main/java/io/appulse/encon/NodesConfig.java b/encon/src/main/java/io/appulse/encon/NodesConfig.java
new file mode 100644
index 0000000..83f3db7
--- /dev/null
+++ b/encon/src/main/java/io/appulse/encon/NodesConfig.java
@@ -0,0 +1,287 @@
+/*
+ * Copyright 2018 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.appulse.encon;
+
+import static io.appulse.encon.common.DistributionFlag.BIG_CREATION;
+import static io.appulse.encon.common.DistributionFlag.BIT_BINARIES;
+import static io.appulse.encon.common.DistributionFlag.EXTENDED_PIDS_PORTS;
+import static io.appulse.encon.common.DistributionFlag.EXTENDED_REFERENCES;
+import static io.appulse.encon.common.DistributionFlag.FUN_TAGS;
+import static io.appulse.encon.common.DistributionFlag.MAP_TAG;
+import static io.appulse.encon.common.DistributionFlag.NEW_FLOATS;
+import static io.appulse.encon.common.DistributionFlag.NEW_FUN_TAGS;
+import static io.appulse.encon.common.DistributionFlag.UTF8_ATOMS;
+import static io.appulse.epmd.java.core.model.NodeType.R6_ERLANG;
+import static io.appulse.epmd.java.core.model.Protocol.TCP;
+import static io.appulse.epmd.java.core.model.Version.R6;
+import static java.lang.Boolean.FALSE;
+import static java.util.Arrays.asList;
+import static java.util.Locale.ENGLISH;
+import static java.util.Optional.ofNullable;
+import static java.util.stream.Collectors.toMap;
+import static lombok.AccessLevel.PRIVATE;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import io.appulse.encon.common.DistributionFlag;
+import io.appulse.epmd.java.client.EpmdClient;
+import io.appulse.epmd.java.core.model.NodeType;
+import io.appulse.epmd.java.core.model.Protocol;
+import io.appulse.epmd.java.core.model.Version;
+import io.appulse.utils.SocketUtils;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.NonNull;
+import lombok.Singular;
+import lombok.experimental.FieldDefaults;
+import lombok.experimental.Wither;
+
+/**
+ *
+ * @author Artem Labazin
+ * @since 2.0.0
+ */
+@Data
+@Wither
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder(toBuilder = true)
+@FieldDefaults(level = PRIVATE)
+public final class NodesConfig {
+
+ @Singular
+ Map nodes;
+
+ public NodesConfig (@NonNull NodesConfig other) {
+ this.nodes = other.getNodes()
+ .entrySet()
+ .stream()
+ .collect(toMap(Entry::getKey, it -> new NodeConfig(it.getValue())));
+ }
+
+ @Data
+ @Wither
+ @NoArgsConstructor
+ @AllArgsConstructor
+ @Builder(toBuilder = true)
+ @FieldDefaults(level = PRIVATE)
+ public static final class NodeConfig {
+
+ private static final Set DEFAULT_DISTRIBUTION_FLAGS = new HashSet<>(asList(
+ EXTENDED_REFERENCES,
+ EXTENDED_PIDS_PORTS,
+ BIT_BINARIES,
+ NEW_FLOATS,
+ FUN_TAGS,
+ NEW_FUN_TAGS,
+ UTF8_ATOMS,
+ MAP_TAG,
+ BIG_CREATION
+ ));
+
+ public static final NodeConfig DEFAULT = NodeConfig.builder().build();
+
+ /**
+ * Returns default cookie. It could be an empty string or content of ~/.erlang.cookie file.
+ *
+ * @return default cookie value
+ */
+ public static String getDefaultCookie () {
+ Path cookieFile = Paths.get(getHomeDir(), ".erlang.cookie");
+ if (!Files.exists(cookieFile)) {
+ return "";
+ }
+
+ try {
+ return Files.lines(cookieFile)
+ .filter(Objects::nonNull)
+ .map(String::trim)
+ .filter(it -> !it.isEmpty())
+ .findFirst()
+ .orElse("");
+ } catch (IOException ex) {
+ return "";
+ }
+ }
+
+ /**
+ * Returns user's home directory.
+ *
+ * @return user's home directory
+ */
+ public static String getHomeDir () {
+ String home = System.getProperty("user.home");
+ if (!System.getProperty("os.name").toLowerCase(ENGLISH).contains("windows")) {
+ return home;
+ }
+
+ String drive = System.getenv("HOMEDRIVE");
+ String path = System.getenv("HOMEPATH");
+ return drive == null || path == null
+ ? home
+ : drive + path;
+ }
+
+ public static NodeConfigBuilder builder () {
+ Set clone = new HashSet<>(DEFAULT_DISTRIBUTION_FLAGS);
+ return new NodeConfigBuilder().distributionFlags(clone);
+ }
+
+ @Builder.Default
+ int epmdPort = EpmdClient.Default.PORT;
+
+ @Builder.Default
+ NodeType type = R6_ERLANG;
+
+ @Builder.Default
+ Boolean shortName = FALSE;
+
+ @Builder.Default
+ String cookie = getDefaultCookie();
+
+ @Builder.Default
+ Protocol protocol = TCP;
+
+ @Builder.Default
+ Version lowVersion = R6;
+
+ @Builder.Default
+ Version highVersion = R6;
+
+ @Singular
+ Set distributionFlags;
+
+ @Builder.Default
+ ServerConfig server = ServerConfig.builder()
+ .bossThreads(1)
+ .workerThreads(2)
+ .build();
+
+ @Builder.Default
+ CompressionConfig compression = CompressionConfig.builder()
+ .enabled(FALSE)
+ .level(-1)
+ .build();
+
+ public NodeConfig (@NonNull NodeConfig other) {
+ epmdPort = other.getEpmdPort();
+ type = other.getType();
+ shortName = other.getShortName();
+ cookie = other.getCookie();
+ protocol = other.getProtocol();
+ lowVersion = other.getLowVersion();
+ highVersion = other.getHighVersion();
+
+ Set flags = ofNullable(other.getDistributionFlags())
+ .orElse(DEFAULT_DISTRIBUTION_FLAGS);
+
+ distributionFlags = new HashSet<>(flags);
+
+ server = ofNullable(other.getServer())
+ .map(ServerConfig::new)
+ .orElse(null);
+
+ compression = ofNullable(other.getCompression())
+ .map(CompressionConfig::new)
+ .orElse(null);
+ }
+
+ @Data
+ @Wither
+ @NoArgsConstructor
+ @AllArgsConstructor
+ @Builder(toBuilder = true)
+ @FieldDefaults(level = PRIVATE)
+ public static final class ServerConfig {
+
+ private static final AtomicInteger UPPER_BOUND = new AtomicInteger(65535);
+
+ public static int findFreePort () {
+ while (true) {
+ int currentValue = UPPER_BOUND.get();
+ Optional optional = SocketUtils.findFreePort(1024, currentValue);
+ if (!optional.isPresent()) {
+ UPPER_BOUND.set(65535);
+ continue;
+ }
+
+ int port = optional.get();
+ if (UPPER_BOUND.compareAndSet(currentValue, port - 1)) {
+ return port;
+ }
+ }
+ }
+
+ Integer port;
+
+ @Builder.Default
+ Integer bossThreads = 1;
+
+ @Builder.Default
+ Integer workerThreads = 2;
+
+ public ServerConfig (@NonNull ServerConfig other) {
+ port = other.getPort();
+ bossThreads = other.getBossThreads();
+ workerThreads = other.getWorkerThreads();
+ }
+
+ public int getOrFindAndSetPort () {
+ if (port == null) {
+ port = findFreePort();
+ }
+ return port;
+ }
+ }
+
+ @Data
+ @Wither
+ @NoArgsConstructor
+ @AllArgsConstructor
+ @Builder(toBuilder = true)
+ @FieldDefaults(level = PRIVATE)
+ public static final class CompressionConfig {
+
+ @Builder.Default
+ Boolean enabled = FALSE;
+
+ @Builder.Default
+ Integer level = -1;
+
+ public CompressionConfig (@NonNull CompressionConfig other) {
+ enabled = other.getEnabled();
+ level = other.getLevel();
+ }
+ }
+ }
+
+ public static class NodeConfigBuilder {
+ }
+}
diff --git a/encon/src/main/java/io/appulse/encon/connection/handshake/message/Message.java b/encon/src/main/java/io/appulse/encon/connection/handshake/message/Message.java
index fd6c9b1..018eff4 100644
--- a/encon/src/main/java/io/appulse/encon/connection/handshake/message/Message.java
+++ b/encon/src/main/java/io/appulse/encon/connection/handshake/message/Message.java
@@ -18,6 +18,8 @@
import static lombok.AccessLevel.PRIVATE;
+import java.lang.reflect.Constructor;
+
import io.netty.buffer.ByteBuf;
import lombok.Getter;
import lombok.NonNull;
@@ -38,7 +40,8 @@ public static T parse (@NonNull ByteBuf buffer, @NonNull Cla
if (!MessageType.check(buffer.readByte(), type)) {
throw new IllegalArgumentException();
}
- T result = type.newInstance();
+ Constructor constructor = type.getConstructor();
+ T result = constructor.newInstance();
result.read(buffer);
return result;
}
diff --git a/encon/src/main/java/io/appulse/encon/mailbox/Mailbox.java b/encon/src/main/java/io/appulse/encon/mailbox/Mailbox.java
index d8739c9..12b14da 100644
--- a/encon/src/main/java/io/appulse/encon/mailbox/Mailbox.java
+++ b/encon/src/main/java/io/appulse/encon/mailbox/Mailbox.java
@@ -16,10 +16,7 @@
package io.appulse.encon.mailbox;
-import static io.appulse.encon.terms.Erlang.NIL;
import static io.appulse.encon.terms.Erlang.atom;
-import static io.appulse.encon.terms.Erlang.list;
-import static io.appulse.encon.terms.Erlang.tuple;
import static lombok.AccessLevel.PACKAGE;
import static lombok.AccessLevel.PRIVATE;
@@ -45,7 +42,6 @@
import io.appulse.encon.mailbox.exception.MailboxWithSuchPidDoesntExistException;
import io.appulse.encon.mailbox.exception.ReceivedExitException;
import io.appulse.encon.terms.ErlangTerm;
-import io.appulse.encon.terms.type.ErlangAtom;
import io.appulse.encon.terms.type.ErlangPid;
import lombok.AllArgsConstructor;
@@ -224,280 +220,6 @@ public void send (@NonNull RemoteNode remote, @NonNull String mailbox, @NonNull
}
}
- /**
- * Send an RPC request to the remote Erlang node. This convenience function
- * creates the following message and sends it to 'rex' on the remote node:
- *
- *
- * Note that this method has unpredicatble results if the remote node is not
- * an Erlang node.
- *
- *
- *
- * The response will be send back to this node in format:
- *
- * { :rex, response_body }
- *
- *
- *
- * @param remoteNodeName remote node name
- *
- * @param module the name of the Erlang module containing the function to be called.
- *
- * @param function the name of the function to call.
- *
- * @param args a list of Erlang terms, to be used as arguments to the function.
- *
- * @since 1.6.4
- */
- public void call (@NonNull String remoteNodeName, @NonNull String module, @NonNull String function, ErlangTerm ...args) {
- call(remoteNodeName, atom(module), atom(function), args);
- }
-
- /**
- * Send an RPC request to the remote Erlang node. This convenience function
- * creates the following message and sends it to 'rex' on the remote node:
- *
- *
- * Note that this method has unpredicatble results if the remote node is not
- * an Erlang node.
- *
- *
- *
- * The response will be send back to this node in format:
- *
- * { :rex, response_body }
- *
- *
- *
- * @param descriptor remote node descriptor
- *
- * @param module the name of the Erlang module containing the function to be called.
- *
- * @param function the name of the function to call.
- *
- * @param args a list of Erlang terms, to be used as arguments to the function.
- *
- * @since 1.6.4
- */
- public void call (@NonNull NodeDescriptor descriptor, @NonNull String module, @NonNull String function, ErlangTerm ...args) {
- call(descriptor, atom(module), atom(function), args);
- }
-
- /**
- * Send an RPC request to the remote Erlang node. This convenience function
- * creates the following message and sends it to 'rex' on the remote node:
- *
- *
- * Note that this method has unpredicatble results if the remote node is not
- * an Erlang node.
- *
- *
- *
- * The response will be send back to this node in format:
- *
- * { :rex, response_body }
- *
- *
- *
- * @param remote remote node descriptor
- *
- * @param module the name of the Erlang module containing the function to be called.
- *
- * @param function the name of the function to call.
- *
- * @param args a list of Erlang terms, to be used as arguments to the function.
- *
- * @since 1.6.4
- */
- public void call (@NonNull RemoteNode remote, @NonNull String module, @NonNull String function, ErlangTerm ...args) {
- call(remote, atom(module), atom(function), args);
- }
-
- /**
- * Send an RPC request to the remote Erlang node. This convenience function
- * creates the following message and sends it to 'rex' on the remote node:
- *
- *
- * Note that this method has unpredicatble results if the remote node is not
- * an Erlang node.
- *
- *
- *
- * The response will be send back to this node in format:
- *
- * { :rex, response_body }
- *
- *
- *
- * @param remoteNodeName remote node name
- *
- * @param module the atom of the Erlang module containing the function to be called.
- *
- * @param function the atom of the function to call.
- *
- * @param args a list of Erlang terms, to be used as arguments to the function.
- *
- * @since 1.6.4
- */
- public void call (@NonNull String remoteNodeName, @NonNull ErlangAtom module, @NonNull ErlangAtom function, ErlangTerm ...args) {
- val descriptor = NodeDescriptor.from(remoteNodeName);
- call(descriptor, module, function, args);
- }
-
- /**
- * Send an RPC request to the remote Erlang node. This convenience function
- * creates the following message and sends it to 'rex' on the remote node:
- *
- *
- * Note that this method has unpredicatble results if the remote node is not
- * an Erlang node.
- *
- *
- *
- * The response will be send back to this node in format:
- *
- * { :rex, response_body }
- *
- *
- *
- * @param descriptor remote node descriptor
- *
- * @param module the atom of the Erlang module containing the function to be called.
- *
- * @param function the atom of the function to call.
- *
- * @param args a list of Erlang terms, to be used as arguments to the function.
- *
- * @since 1.6.4
- */
- public void call (@NonNull NodeDescriptor descriptor, @NonNull ErlangAtom module, @NonNull ErlangAtom function, ErlangTerm ...args) {
- RemoteNode remote = node.lookup(descriptor);
- if (remote == null) {
- throw new NoSuchRemoteNodeException(descriptor);
- }
- call(remote, module, function, args);
- }
-
- /**
- * Send an RPC request to the remote Erlang node. This convenience function
- * creates the following message and sends it to 'rex' on the remote node:
- *
- *
- * Note that this method has unpredicatble results if the remote node is not
- * an Erlang node.
- *
- *
- *
- * The response will be send back to this node in format:
- *
- * { :rex, response_body }
- *
- *
- *
- * @param remote remote node descriptor
- *
- * @param module the atom of the Erlang module containing the function to be called.
- *
- * @param function the atom of the function to call.
- *
- * @param args a list of Erlang terms, to be used as arguments to the function.
- *
- * @since 1.6.4
- */
- public void call (@NonNull RemoteNode remote, @NonNull ErlangAtom module, @NonNull ErlangAtom function, ErlangTerm ...args) {
- ErlangTerm argumentsList;
- if (args == null || args.length == 0) {
- argumentsList = NIL;
- } else if (args.length == 1 && args[0].isList()) {
- argumentsList = args[0];
- } else {
- argumentsList = list(args);
- }
-
- send(remote, "rex", tuple(
- pid,
- tuple(
- atom("call"),
- module,
- function,
- argumentsList,
- atom("user")
- )
- ));
- }
-
- /**
- * Receive an RPC reply from the remote Erlang node. This convenience
- * function receives a message from the remote node, and expects it to have
- * the following format:
- *
- *
- * { :rex, ErlangTerm }
- *
- *
- * @return the second element of the tuple if the received message is a
- * two-tuple, otherwise null. No further error checking is
- * performed.
- */
- public ErlangTerm receiveRemoteProcedureResult () {
- return receive().getBody()
- .get(1)
- .orElse(null);
- }
-
- /**
- * Receive an RPC reply from the remote Erlang node. This convenience
- * function receives a message from the remote node, and expects it to have
- * the following format:
- *
- *
- * { :rex, ErlangTerm }
- *
- *
- * @param timeout how long to wait before giving up, in units of
- * {@code unit}
- * @param unit a {@code TimeUnit} determining how to interpret the
- * {@code timeout} parameter
- *
- * @return the second element of the tuple if the received message is a
- * two-tuple, otherwise null. No further error checking is
- * performed. It also could return {@ null} if the specified
- * waiting time elapses before an element is available
- */
- public ErlangTerm receiveRemoteProcedureResult (long timeout, TimeUnit unit) {
- Message message = receive(timeout, unit);
- if (message == null) {
- return null;
- }
- return message.getBody()
- .get(1)
- .orElse(null);
- }
/**
* Links the mailbox.
diff --git a/encon/src/test/java/io/appulse/encon/GeneratorPidTest.java b/encon/src/test/java/io/appulse/encon/GeneratorPidTest.java
index c4fa9bd..040dd67 100644
--- a/encon/src/test/java/io/appulse/encon/GeneratorPidTest.java
+++ b/encon/src/test/java/io/appulse/encon/GeneratorPidTest.java
@@ -19,26 +19,31 @@
import static org.assertj.core.api.Assertions.assertThat;
import io.appulse.encon.common.NodeDescriptor;
-import io.appulse.utils.test.TestMethodNamePrinter;
+
import lombok.val;
import org.assertj.core.api.SoftAssertions;
-import org.junit.Rule;
-import org.junit.rules.TestRule;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
/**
*
* @author Artem Labazin
* @since 1.0.0
*/
-public class GeneratorPidTest {
+@DisplayName("Pid generator tests")
+class GeneratorPidTest {
- @Rule
- public TestRule watcher = new TestMethodNamePrinter();
+ @BeforeEach
+ void beforeEach (TestInfo testInfo) {
+ System.out.println("- " + testInfo.getDisplayName());
+ }
@Test
- public void generate () {
+ @DisplayName("generate")
+ void generate () {
val descriptor = NodeDescriptor.from("popa");
val creation = 1;
diff --git a/encon/src/test/java/io/appulse/encon/GeneratorPortTest.java b/encon/src/test/java/io/appulse/encon/GeneratorPortTest.java
index 65617fe..3c01f81 100644
--- a/encon/src/test/java/io/appulse/encon/GeneratorPortTest.java
+++ b/encon/src/test/java/io/appulse/encon/GeneratorPortTest.java
@@ -19,26 +19,31 @@
import static org.assertj.core.api.Assertions.assertThat;
import io.appulse.encon.common.NodeDescriptor;
-import io.appulse.utils.test.TestMethodNamePrinter;
+
import lombok.val;
import org.assertj.core.api.SoftAssertions;
-import org.junit.Rule;
-import org.junit.rules.TestRule;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
/**
*
* @author Artem Labazin
* @since 1.0.0
*/
-public class GeneratorPortTest {
+@DisplayName("Port generator tests")
+class GeneratorPortTest {
- @Rule
- public TestRule watcher = new TestMethodNamePrinter();
+ @BeforeEach
+ void beforeEach (TestInfo testInfo) {
+ System.out.println("- " + testInfo.getDisplayName());
+ }
@Test
- public void generate () {
+ @DisplayName("generate")
+ void generate () {
val descriptor = NodeDescriptor.from("popa");
val creation = 1;
diff --git a/encon/src/test/java/io/appulse/encon/GeneratorReferenceTest.java b/encon/src/test/java/io/appulse/encon/GeneratorReferenceTest.java
index bedb085..ae43d90 100644
--- a/encon/src/test/java/io/appulse/encon/GeneratorReferenceTest.java
+++ b/encon/src/test/java/io/appulse/encon/GeneratorReferenceTest.java
@@ -19,26 +19,30 @@
import static org.assertj.core.api.Assertions.assertThat;
import io.appulse.encon.common.NodeDescriptor;
-import io.appulse.utils.test.TestMethodNamePrinter;
import lombok.val;
import org.assertj.core.api.SoftAssertions;
-import org.junit.Rule;
-import org.junit.rules.TestRule;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
/**
*
* @author Artem Labazin
* @since 1.0.0
*/
-public class GeneratorReferenceTest {
+@DisplayName("Reference generator tests")
+class GeneratorReferenceTest {
- @Rule
- public TestRule watcher = new TestMethodNamePrinter();
+ @BeforeEach
+ void beforeEach (TestInfo testInfo) {
+ System.out.println("- " + testInfo.getDisplayName());
+ }
@Test
- public void generateReference () {
+ @DisplayName("generate")
+ void generateReference () {
val descriptor = NodeDescriptor.from("popa");
val creation = 1;
diff --git a/encon/src/test/java/io/appulse/encon/NodeTest.java b/encon/src/test/java/io/appulse/encon/NodeTest.java
index 27b5bbb..ed866c1 100644
--- a/encon/src/test/java/io/appulse/encon/NodeTest.java
+++ b/encon/src/test/java/io/appulse/encon/NodeTest.java
@@ -28,37 +28,33 @@
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.assertj.core.api.Assertions.assertThat;
import static java.util.Optional.ofNullable;
-import static io.appulse.encon.connection.control.ControlMessageTag.SEND;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadLocalRandom;
-import io.appulse.encon.config.MailboxConfig;
-import io.appulse.encon.config.NodeConfig;
-import io.appulse.encon.config.ServerConfig;
-import io.appulse.encon.connection.control.ControlMessage;
-import io.appulse.encon.connection.regular.Message;
+import io.appulse.encon.ModuleRemoteProcedureCall.RpcResponse;
+import io.appulse.encon.NodesConfig.NodeConfig;
+import io.appulse.encon.NodesConfig.NodeConfig.ServerConfig;
import io.appulse.encon.mailbox.Mailbox;
import io.appulse.encon.mailbox.exception.ReceivedExitException;
import io.appulse.encon.terms.ErlangTerm;
import io.appulse.encon.terms.type.ErlangAtom;
-import io.appulse.utils.test.TestMethodNamePrinter;
import io.appulse.epmd.java.server.cli.CommonOptions;
import io.appulse.epmd.java.server.command.server.ServerCommandExecutor;
import io.appulse.epmd.java.server.command.server.ServerCommandOptions;
import io.appulse.utils.SocketUtils;
-import java.util.concurrent.ThreadLocalRandom;
-
import lombok.val;
import lombok.extern.slf4j.Slf4j;
import org.assertj.core.api.SoftAssertions;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.After;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestRule;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
/**
*
@@ -66,7 +62,8 @@
* @since 1.0.0
*/
@Slf4j
-public class NodeTest {
+@DisplayName("Node tests")
+class NodeTest {
private static final String ELIXIR_ECHO_SERVER = "echo@localhost";
@@ -74,14 +71,10 @@ public class NodeTest {
private static ServerCommandExecutor epmdServer;
- @Rule
- public TestRule watcher = new TestMethodNamePrinter();
-
-
Node node;
- @BeforeClass
- public static void beforeClass () {
+ @BeforeAll
+ static void beforeAll () {
if (SocketUtils.isPortAvailable(4369)) {
executor = Executors.newSingleThreadExecutor();
epmdServer = new ServerCommandExecutor(new CommonOptions(), new ServerCommandOptions());
@@ -89,8 +82,8 @@ public static void beforeClass () {
}
}
- @AfterClass
- public static void afterClass () {
+ @AfterAll
+ static void afterAll () {
ofNullable(epmdServer)
.ifPresent(ServerCommandExecutor::close);
@@ -98,8 +91,13 @@ public static void afterClass () {
.ifPresent(ExecutorService::shutdown);
}
- @After
- public void after () throws Exception {
+ @BeforeEach
+ void beforeEach (TestInfo testInfo) {
+ System.out.println("- " + testInfo.getDisplayName());
+ }
+
+ @AfterEach
+ void afterEach () throws Exception {
if (node != null) {
node.close();
node = null;
@@ -108,7 +106,8 @@ public void after () throws Exception {
}
@Test
- public void register () {
+ @DisplayName("node registration")
+ void register () {
val name = createName();
node = Nodes.singleNode(name, true);
@@ -137,13 +136,14 @@ public void register () {
}
@Test
- public void ping () throws Exception {
+ @DisplayName("sending ping message")
+ void ping () throws Exception {
val name1 = createName();
val name2 = createName();
node = Nodes.singleNode(name1, NodeConfig.builder()
- .shortName(true)
- .cookie("secret")
- .build()
+ .shortName(true)
+ .cookie("secret")
+ .build()
);
assertThat(node.ping(ELIXIR_ECHO_SERVER))
@@ -175,26 +175,19 @@ public void ping () throws Exception {
}
@Test
- public void instantiating () throws Exception {
+ @DisplayName("simple instantiating")
+ void instantiating () throws Exception {
val name = createName();
node = Nodes.singleNode(name, NodeConfig.builder()
- .shortName(true)
- .mailbox(MailboxConfig.builder()
- .name("one")
- .build())
- .mailbox(MailboxConfig.builder()
- .name("two")
- .build())
- .build()
+ .shortName(true)
+ .build()
);
-
- assertThat(node.mailbox("one")).isNotNull();
- assertThat(node.mailbox("two")).isNotNull();
- assertThat(node.mailbox("three")).isNull();
+ assertThat(node.mailbox("one")).isNull();
}
@Test
- public void sendFromOneToAnotherNode () throws Exception {
+ @DisplayName("send message from one node to another")
+ void sendFromOneToAnotherNode () throws Exception {
val name1 = createName();
val name2 = createName();
@@ -226,7 +219,8 @@ public void sendFromOneToAnotherNode () throws Exception {
}
@Test
- public void sendWithRedirect () throws Exception {
+ @DisplayName("send message from A node, through Elixir echo, to B node")
+ void sendWithRedirect () throws Exception {
val config = NodeConfig.builder()
.shortName(true)
.cookie("secret")
@@ -285,7 +279,8 @@ public void sendWithRedirect () throws Exception {
}
@Test
- public void send () throws Exception {
+ @DisplayName("send message to Elixir echo server and catch back")
+ void send () throws Exception {
val name = createName();
node = Nodes.singleNode(name, NodeConfig.builder()
.shortName(true)
@@ -327,7 +322,8 @@ public void send () throws Exception {
}
@Test
- public void link () throws Exception {
+ @DisplayName("link two nodes")
+ void link () throws Exception {
val name = createName();
node = Nodes.singleNode(name, true);
@@ -355,7 +351,8 @@ public void link () throws Exception {
}
@Test
- public void exit () throws Exception {
+ @DisplayName("send exit message from node A to node B")
+ void exit () throws Exception {
val name = createName();
node = Nodes.singleNode(name, true);
@@ -382,40 +379,27 @@ public void exit () throws Exception {
}
@Test
- public void remoteProcedureCall () throws Exception {
+ @DisplayName("send RPC message to Elixir echo server")
+ void remoteProcedureCall () throws Exception {
val name = createName();
node = Nodes.singleNode(name, NodeConfig.builder()
.shortName(true)
.cookie("secret")
.build());
- Mailbox mailbox = node.mailbox().build();
- mailbox.call(ELIXIR_ECHO_SERVER, "erlang", "date");
-
- Message message = mailbox.receive(5, SECONDS);
- assertThat(message.getHeader())
- .extracting(ControlMessage::getTag)
- .isEqualTo(SEND);
-
- assertThat(message.getBody())
- .isNotNull();
-
- ErlangTerm term = message.getBody();
- assertThat(term.isTuple()).isTrue();
- assertThat(term.size()).isEqualTo(2);
-
- assertThat(term.getUnsafe(0).asText()).isEqualTo("rex");
- assertThat(term.getUnsafe(1).isTuple()).isTrue();
+ RpcResponse response = node.rpc()
+ .call(ELIXIR_ECHO_SERVER, "erlang", "date");
- ErlangTerm response1 = term.getUnsafe(1);
- assertThat(response1.getUnsafe(0).isNumber()).isTrue();
- assertThat(response1.getUnsafe(1).isNumber()).isTrue();
- assertThat(response1.getUnsafe(2).isNumber()).isTrue();
+ ErlangTerm payload = response.getSync(5, SECONDS);
+ assertThat(payload.getUnsafe(0).isNumber()).isTrue();
+ assertThat(payload.getUnsafe(1).isNumber()).isTrue();
+ assertThat(payload.getUnsafe(2).isNumber()).isTrue();
- mailbox.call(ELIXIR_ECHO_SERVER, "erlang", "date");
- ErlangTerm response2 = mailbox.receiveRemoteProcedureResult(5, SECONDS);
- assertThat(response2).isEqualTo(response1);
+ assertThat(response.hasResponse()).isTrue();
+ assertThat(response.getAsync().get())
+ .isEqualTo(payload)
+ .isSameAs(payload);
}
private String createName () {
diff --git a/encon/src/test/java/io/appulse/encon/NodesTest.java b/encon/src/test/java/io/appulse/encon/NodesTest.java
index d98404f..1a4e8ba 100644
--- a/encon/src/test/java/io/appulse/encon/NodesTest.java
+++ b/encon/src/test/java/io/appulse/encon/NodesTest.java
@@ -23,40 +23,33 @@
import java.util.concurrent.Executors;
import io.appulse.encon.config.Config;
-import io.appulse.encon.config.Defaults;
-import io.appulse.encon.config.MailboxConfig;
-import io.appulse.encon.config.NodeConfig;
-import io.appulse.encon.config.ServerConfig;
import io.appulse.epmd.java.server.cli.CommonOptions;
import io.appulse.epmd.java.server.command.server.ServerCommandExecutor;
import io.appulse.epmd.java.server.command.server.ServerCommandOptions;
import io.appulse.utils.SocketUtils;
-import io.appulse.utils.test.TestMethodNamePrinter;
+import io.appulse.encon.NodesConfig.NodeConfig;
-import lombok.val;
-
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestRule;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
/**
*
* @author Artem Labazin
* @since 1.0.0
*/
-public class NodesTest {
+@DisplayName("Nodes cluster tests")
+class NodesTest {
private static ExecutorService executor;
private static ServerCommandExecutor epmdServer;
- @Rule
- public TestRule watcher = new TestMethodNamePrinter();
-
- @BeforeClass
- public static void beforeClass () {
+ @BeforeAll
+ static void beforeClass () {
if (SocketUtils.isPortAvailable(4369)) {
executor = Executors.newSingleThreadExecutor();
epmdServer = new ServerCommandExecutor(new CommonOptions(), new ServerCommandOptions());
@@ -64,8 +57,8 @@ public static void beforeClass () {
}
}
- @AfterClass
- public static void afterClass () {
+ @AfterAll
+ static void afterClass () {
ofNullable(epmdServer)
.ifPresent(ServerCommandExecutor::close);
@@ -73,32 +66,26 @@ public static void afterClass () {
.ifPresent(ExecutorService::shutdown);
}
+ @BeforeEach
+ void beforeEach (TestInfo testInfo) {
+ System.out.println("- " + testInfo.getDisplayName());
+ }
+
@Test
- public void instantiating () {
- val config = Config.builder()
- .defaults(Defaults.builder()
- .cookie("kojima-secret")
- .server(ServerConfig.builder()
- .bossThreads(1)
- .workerThreads(1)
- .build())
+ @DisplayName("start several nodes from programmatically config")
+ void instantiating () {
+ Config config = Config.builder()
+ .config(NodesConfig.builder()
+ .node("kojima1", NodeConfig.DEFAULT)
+ .node("kojima2", NodeConfig.DEFAULT)
.build())
- .node("kojima1", new NodeConfig())
- .node("kojima2", new NodeConfig())
- .node("ocelot", NodeConfig.builder()
- .mailbox(MailboxConfig.builder()
- .name("revolver")
- .build())
- .build())
.build();
- try (val nodes = Nodes.start(config)) {
+ try (Nodes nodes = Nodes.start(config)) {
assertThat(nodes.node("kojima1"))
.isPresent();
assertThat(nodes.node("kojima2"))
.isPresent();
- assertThat(nodes.node("ocelot"))
- .isPresent();
assertThat(nodes.node("kojima3"))
.isNotPresent();
}
diff --git a/encon/src/test/java/io/appulse/encon/connection/ConnectionModuleTest.java b/encon/src/test/java/io/appulse/encon/connection/ConnectionModuleTest.java
index aaae7c9..0cf1389 100644
--- a/encon/src/test/java/io/appulse/encon/connection/ConnectionModuleTest.java
+++ b/encon/src/test/java/io/appulse/encon/connection/ConnectionModuleTest.java
@@ -20,17 +20,27 @@
import java.util.concurrent.CompletableFuture;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
/**
*
* @author Artem Labazin
* @since 1.0.0
*/
-public class ConnectionModuleTest {
+@DisplayName("Connection module tests")
+class ConnectionModuleTest {
+
+ @BeforeEach
+ void beforeEach (TestInfo testInfo) {
+ System.out.println("- " + testInfo.getDisplayName());
+ }
@Test
- public void futureTests () {
+ @DisplayName("future POC")
+ void futureTests () {
CompletableFuture future = CompletableFuture.completedFuture("Hello world");
assertThat(future)
.isCompleted()
diff --git a/examples/custom-queue/pom.xml b/examples/custom-queue/pom.xml
index 460e9ba..7992ea2 100644
--- a/examples/custom-queue/pom.xml
+++ b/examples/custom-queue/pom.xml
@@ -25,7 +25,7 @@ limitations under the License.
io.appulse.enconexamples
- 1.6.5
+ 2.0.0io.appulse.encon.examples
@@ -33,12 +33,6 @@ limitations under the License.
jar
- UTF-8
- UTF-8
-
- 1.8
- 1.8
-
io.appulse.encon.examples.custom.queue.Main
@@ -48,17 +42,6 @@ limitations under the License.
encon${project.version}
-
-
- junit
- junit
- test
-
-
- org.assertj
- assertj-core
- test
-
diff --git a/examples/custom-queue/src/main/java/io/appulse/encon/examples/custom/queue/Main.java b/examples/custom-queue/src/main/java/io/appulse/encon/examples/custom/queue/Main.java
index 5b766a8..2010c3e 100644
--- a/examples/custom-queue/src/main/java/io/appulse/encon/examples/custom/queue/Main.java
+++ b/examples/custom-queue/src/main/java/io/appulse/encon/examples/custom/queue/Main.java
@@ -22,7 +22,7 @@
import io.appulse.encon.Node;
import io.appulse.encon.Nodes;
-import io.appulse.encon.config.NodeConfig;
+import io.appulse.encon.NodesConfig.NodeConfig;
import io.appulse.encon.mailbox.Mailbox;
import io.appulse.encon.terms.ErlangTerm;
import io.appulse.encon.terms.type.ErlangPid;
diff --git a/examples/custom-queue/src/test/java/io/appulse/encon/examples/custom/queue/MainTest.java b/examples/custom-queue/src/test/java/io/appulse/encon/examples/custom/queue/MainTest.java
index e129bc8..04175d3 100644
--- a/examples/custom-queue/src/test/java/io/appulse/encon/examples/custom/queue/MainTest.java
+++ b/examples/custom-queue/src/test/java/io/appulse/encon/examples/custom/queue/MainTest.java
@@ -29,17 +29,17 @@
import io.appulse.encon.mailbox.Mailbox;
import io.appulse.encon.terms.ErlangTerm;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
* @since 1.6.2
* @author Artem Labazin
*/
-public class MainTest {
+class MainTest {
@Test
- public void test () throws Exception {
+ void test () throws Exception {
ExecutorService executorService = Executors.newSingleThreadExecutor();
executorService.execute(() -> Main.main(null));
diff --git a/examples/databind/pom.xml b/examples/databind/pom.xml
index ac909af..405912e 100644
--- a/examples/databind/pom.xml
+++ b/examples/databind/pom.xml
@@ -25,7 +25,7 @@ limitations under the License.
io.appulse.enconexamples
- 1.6.5
+ 2.0.0io.appulse.encon.examples
@@ -33,21 +33,10 @@ limitations under the License.
jar
- UTF-8
- UTF-8
-
- 1.8
- 1.8
-
io.appulse.encon.examples.databind.Main
-
- org.projectlombok
- lombok
-
-
io.appulse.enconencon
@@ -58,17 +47,6 @@ limitations under the License.
encon-databind${project.version}
-
-
- junit
- junit
- test
-
-
- org.assertj
- assertj-core
- test
-
@@ -76,7 +54,7 @@ limitations under the License.
org.apache.maven.pluginsmaven-shade-plugin
- 3.1.0
+ 3.2.1
diff --git a/examples/databind/src/test/java/io/appulse/encon/examples/databind/MainTest.java b/examples/databind/src/test/java/io/appulse/encon/examples/databind/MainTest.java
index 59e1cec..6c6b0b3 100644
--- a/examples/databind/src/test/java/io/appulse/encon/examples/databind/MainTest.java
+++ b/examples/databind/src/test/java/io/appulse/encon/examples/databind/MainTest.java
@@ -30,17 +30,17 @@
import io.appulse.encon.mailbox.Mailbox;
import io.appulse.encon.terms.ErlangTerm;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
* @since 1.6.2
* @author Artem Labazin
*/
-public class MainTest {
+class MainTest {
@Test
- public void test () throws Exception {
+ void test () throws Exception {
ExecutorService executorService = Executors.newSingleThreadExecutor();
executorService.execute(() -> Main.main(null));
diff --git a/examples/echo-server-spring/pom.xml b/examples/echo-server-spring/pom.xml
index 2b24d4c..d33b3a9 100644
--- a/examples/echo-server-spring/pom.xml
+++ b/examples/echo-server-spring/pom.xml
@@ -25,7 +25,7 @@ limitations under the License.
io.appulse.enconexamples
- 1.6.5
+ 2.0.0
@@ -33,7 +33,7 @@ limitations under the License.
org.springframework.bootspring-boot-dependencies
- 2.0.4.RELEASE
+ 2.1.1.RELEASEpomimport
@@ -44,23 +44,12 @@ limitations under the License.
echo-server-springjar
-
- UTF-8
- 1.8
- 1.8
-
-
org.springframework.bootspring-boot-starter
-
- org.projectlombok
- lombok
-
-
io.appulse.enconencon-spring
@@ -77,16 +66,6 @@ limitations under the License.
spring-boot-starter-testtest
-
- junit
- junit
- test
-
-
- org.assertj
- assertj-core
- test
-
@@ -94,7 +73,7 @@ limitations under the License.
org.springframework.bootspring-boot-maven-plugin
- 2.0.4.RELEASE
+ 2.1.1.RELEASE
diff --git a/examples/echo-server-spring/src/main/java/io/appulse/encon/examples/echo/server/spring/MyPojo1.java b/examples/echo-server-spring/src/main/java/io/appulse/encon/examples/echo/server/spring/MyPojo1.java
index ab43073..f0a7457 100644
--- a/examples/echo-server-spring/src/main/java/io/appulse/encon/examples/echo/server/spring/MyPojo1.java
+++ b/examples/echo-server-spring/src/main/java/io/appulse/encon/examples/echo/server/spring/MyPojo1.java
@@ -32,7 +32,7 @@
/**
*
* @since 1.6.0
- * @author alabazin
+ * @author Artem Labazin
*/
@Data
@Builder
diff --git a/examples/echo-server-spring/src/main/resources/application.yml b/examples/echo-server-spring/src/main/resources/application.yml
index 59ec549..308c5af 100644
--- a/examples/echo-server-spring/src/main/resources/application.yml
+++ b/examples/echo-server-spring/src/main/resources/application.yml
@@ -1,4 +1,8 @@
spring.encon:
- defaults:
- cookie: secret
+ nodes:
+ echo-client:
+ shortName: true
+ echo-server:
+ shortName: true
+
diff --git a/examples/echo-server-spring/src/test/java/io/appulse/encon/examples/echo/server/spring/MainTest.java b/examples/echo-server-spring/src/test/java/io/appulse/encon/examples/echo/server/spring/MainTest.java
index c656fbf..8067d50 100644
--- a/examples/echo-server-spring/src/test/java/io/appulse/encon/examples/echo/server/spring/MainTest.java
+++ b/examples/echo-server-spring/src/test/java/io/appulse/encon/examples/echo/server/spring/MainTest.java
@@ -35,18 +35,19 @@
import io.appulse.epmd.java.server.command.server.ServerCommandExecutor;
import io.appulse.epmd.java.server.command.server.ServerCommandOptions;
import io.appulse.utils.SocketUtils;
-import io.appulse.utils.test.TestMethodNamePrinter;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestRule;
-import org.junit.runner.RunWith;
+
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringBootConfiguration;
-import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.ComponentScan;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+import org.springframework.test.context.junit4.SpringRunner;
/**
*
@@ -59,24 +60,15 @@
EchoClient.class,
EnconProperties.class
})
-@RunWith(SpringRunner.class)
-public class MainTest {
+@ExtendWith(SpringExtension.class)
+class MainTest {
private static ExecutorService executor;
private static ServerCommandExecutor epmdServer;
- @Rule
- public TestRule watcher = new TestMethodNamePrinter();
-
- @Autowired
- EchoClient client;
-
- @Autowired
- EchoServer server;
-
- @BeforeClass
- public static void beforeClass () {
+ @BeforeAll
+ static void beforeAll () {
if (SocketUtils.isPortAvailable(4369)) {
executor = Executors.newSingleThreadExecutor();
epmdServer = new ServerCommandExecutor(new CommonOptions(), new ServerCommandOptions());
@@ -84,8 +76,8 @@ public static void beforeClass () {
}
}
- @AfterClass
- public static void afterClass () {
+ @AfterAll
+ static void afterAll () {
ofNullable(epmdServer)
.ifPresent(ServerCommandExecutor::close);
@@ -93,8 +85,19 @@ public static void afterClass () {
.ifPresent(ExecutorService::shutdown);
}
+ @Autowired
+ EchoClient client;
+
+ @Autowired
+ EchoServer server;
+
+ @BeforeEach
+ void beforeEach (TestInfo testInfo) {
+ System.out.println("- " + testInfo.getDisplayName());
+ }
+
@Test
- public void term () {
+ void term () {
ErlangTerm request = tuple(
client.pid(),
tuple(
@@ -114,7 +117,7 @@ public void term () {
}
@Test
- public void pojo () {
+ void pojo () {
MyPojo2 request = new MyPojo2(
client.pid(),
"Artem",
diff --git a/examples/echo-server/pom.xml b/examples/echo-server/pom.xml
index a22adf3..a1512b3 100644
--- a/examples/echo-server/pom.xml
+++ b/examples/echo-server/pom.xml
@@ -25,26 +25,14 @@ limitations under the License.
io.appulse.enconexamples
- 1.6.5
+ 2.0.0io.appulse.encon.examplesecho-serverjar
-
- UTF-8
- UTF-8
-
- 1.8
- 1.8
-
-
-
- org.projectlombok
- lombok
- io.appulse.enconencon
@@ -55,11 +43,5 @@ limitations under the License.
encon-databind${project.version}
-
-
- junit
- junit
- test
-
diff --git a/examples/echo-server/src/main/java/io/appulse/encon/examples/echo/server/EchoClientNode.java b/examples/echo-server/src/main/java/io/appulse/encon/examples/echo/server/EchoClientNode.java
index 7b50395..d6ea068 100644
--- a/examples/echo-server/src/main/java/io/appulse/encon/examples/echo/server/EchoClientNode.java
+++ b/examples/echo-server/src/main/java/io/appulse/encon/examples/echo/server/EchoClientNode.java
@@ -22,7 +22,7 @@
import io.appulse.encon.Node;
import io.appulse.encon.Nodes;
-import io.appulse.encon.config.NodeConfig;
+import io.appulse.encon.NodesConfig.NodeConfig;
import io.appulse.encon.databind.TermMapper;
import io.appulse.encon.mailbox.Mailbox;
import io.appulse.encon.terms.ErlangTerm;
@@ -35,13 +35,13 @@
* @author Artem Labazin
*/
@FieldDefaults(level = PRIVATE, makeFinal = true)
-class EchoClientNode implements Closeable {
+public class EchoClientNode implements Closeable {
Node node;
Mailbox mailbox;
- EchoClientNode (String cookie) {
+ public EchoClientNode (String cookie) {
NodeConfig config = NodeConfig.builder()
.shortName(TRUE)
.cookie(cookie)
diff --git a/examples/echo-server/src/main/java/io/appulse/encon/examples/echo/server/EchoServerNode.java b/examples/echo-server/src/main/java/io/appulse/encon/examples/echo/server/EchoServerNode.java
index 927c7ff..185fd4a 100644
--- a/examples/echo-server/src/main/java/io/appulse/encon/examples/echo/server/EchoServerNode.java
+++ b/examples/echo-server/src/main/java/io/appulse/encon/examples/echo/server/EchoServerNode.java
@@ -24,7 +24,7 @@
import io.appulse.encon.Node;
import io.appulse.encon.Nodes;
-import io.appulse.encon.config.NodeConfig;
+import io.appulse.encon.NodesConfig.NodeConfig;
import io.appulse.encon.connection.regular.Message;
import io.appulse.encon.mailbox.Mailbox;
import io.appulse.encon.terms.ErlangTerm;
@@ -40,13 +40,13 @@
*/
@Slf4j
@FieldDefaults(level = PRIVATE, makeFinal = true)
-class EchoServerNode implements Runnable, Closeable {
+public class EchoServerNode implements Runnable, Closeable {
Node node;
Mailbox mailbox;
- EchoServerNode (String nodeName, String cookie, String mailboxName) {
+ public EchoServerNode (String nodeName, String cookie, String mailboxName) {
NodeConfig config = NodeConfig.builder()
.shortName(TRUE)
.cookie(cookie)
diff --git a/examples/echo-server/src/test/java/io/appulse/encon/examples/echo/server/MainTest.java b/examples/echo-server/src/test/java/io/appulse/encon/examples/echo/server/MainTest.java
index e5e83dc..03e9bd7 100644
--- a/examples/echo-server/src/test/java/io/appulse/encon/examples/echo/server/MainTest.java
+++ b/examples/echo-server/src/test/java/io/appulse/encon/examples/echo/server/MainTest.java
@@ -20,9 +20,9 @@
import static io.appulse.encon.terms.Erlang.number;
import static io.appulse.encon.terms.Erlang.string;
import static io.appulse.encon.terms.Erlang.tuple;
-import static org.junit.Assert.assertEquals;
import static java.util.Arrays.asList;
import static java.util.Collections.singleton;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -39,16 +39,16 @@
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.EqualsAndHashCode;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
*
* @since 1.6.0
* @author Artem Labazin
*/
-public class MainTest {
+class MainTest {
final String SERVER_NODE_NAME = "echo-server";
final String SERVER_MAILBOX_NAME = "echo";
@@ -59,8 +59,8 @@ public class MainTest {
EchoServerNode server;
EchoClientNode client;
- @Before
- public void before () {
+ @BeforeEach
+ void beforeEach () {
server = new EchoServerNode(SERVER_NODE_NAME, COOKIE, SERVER_MAILBOX_NAME);
client = new EchoClientNode(COOKIE);
@@ -68,15 +68,15 @@ public void before () {
executor.execute(server);
}
- @After
- public void after () {
+ @AfterEach
+ void afterEach () {
client.close();
server.close();
executor.shutdown();
}
@Test
- public void term () {
+ void term () {
ErlangTerm request = tuple(
atom("ok"),
number(42),
@@ -91,7 +91,7 @@ public void term () {
}
@Test
- public void pojo () {
+ void pojo () {
MyPojo request = new MyPojo(
"Artem",
27,
diff --git a/examples/handler-advanced/pom.xml b/examples/handler-advanced/pom.xml
index 00830c9..a443105 100644
--- a/examples/handler-advanced/pom.xml
+++ b/examples/handler-advanced/pom.xml
@@ -25,27 +25,14 @@ limitations under the License.
io.appulse.enconexamples
- 1.6.5
+ 2.0.0io.appulse.encon.exampleshandler-advancedjar
-
- UTF-8
- UTF-8
-
- 1.8
- 1.8
-
-
-
- org.projectlombok
- lombok
-
-
io.appulse.enconencon
@@ -56,16 +43,5 @@ limitations under the License.
encon-handler${project.version}
-
-
- junit
- junit
- test
-
-
- org.assertj
- assertj-core
- test
-
diff --git a/examples/handler-advanced/src/test/java/io/appulse/encon/examples/handler/advanced/MainTest.java b/examples/handler-advanced/src/test/java/io/appulse/encon/examples/handler/advanced/MainTest.java
index 0776ce6..5c2f073 100644
--- a/examples/handler-advanced/src/test/java/io/appulse/encon/examples/handler/advanced/MainTest.java
+++ b/examples/handler-advanced/src/test/java/io/appulse/encon/examples/handler/advanced/MainTest.java
@@ -28,17 +28,17 @@
import io.appulse.encon.Nodes;
import io.appulse.encon.mailbox.Mailbox;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
* @since 1.6.2
* @author Artem Labazin
*/
-public class MainTest {
+class MainTest {
@Test
- public void test () throws Exception {
+ void test () throws Exception {
Server server = new Server();
server.start();
diff --git a/examples/handler-basic/pom.xml b/examples/handler-basic/pom.xml
index 92d6d20..3754a6a 100644
--- a/examples/handler-basic/pom.xml
+++ b/examples/handler-basic/pom.xml
@@ -25,27 +25,14 @@ limitations under the License.
io.appulse.enconexamples
- 1.6.5
+ 2.0.0io.appulse.encon.exampleshandler-basicjar
-
- UTF-8
- UTF-8
-
- 1.8
- 1.8
-
-
-
- org.projectlombok
- lombok
-
-
io.appulse.enconencon
@@ -56,16 +43,5 @@ limitations under the License.
encon-handler${project.version}
-
-
- junit
- junit
- test
-
-
- org.assertj
- assertj-core
- test
-
diff --git a/examples/handler-basic/src/test/java/io/appulse/encon/examples/handler/basic/MainTest.java b/examples/handler-basic/src/test/java/io/appulse/encon/examples/handler/basic/MainTest.java
index 7d2348e..d84c8fe 100644
--- a/examples/handler-basic/src/test/java/io/appulse/encon/examples/handler/basic/MainTest.java
+++ b/examples/handler-basic/src/test/java/io/appulse/encon/examples/handler/basic/MainTest.java
@@ -26,17 +26,17 @@
import io.appulse.encon.mailbox.Mailbox;
import io.appulse.encon.terms.ErlangTerm;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
* @since 1.6.2
* @author Artem Labazin
*/
-public class MainTest {
+class MainTest {
@Test
- public void test () throws Exception {
+ void test () throws Exception {
Server server = new Server();
server.start();
diff --git a/examples/load-config-spring/pom.xml b/examples/load-config-spring/pom.xml
index 310b821..6b8bf3e 100644
--- a/examples/load-config-spring/pom.xml
+++ b/examples/load-config-spring/pom.xml
@@ -25,7 +25,7 @@ limitations under the License.
io.appulse.enconexamples
- 1.6.5
+ 2.0.0
@@ -33,7 +33,7 @@ limitations under the License.
org.springframework.bootspring-boot-dependencies
- 2.0.4.RELEASE
+ 2.1.1.RELEASEpomimport
@@ -45,10 +45,6 @@ limitations under the License.
jar
- UTF-8
- 1.8
- 1.8
-
io.appulse.encon.examples.load.config.spring.Main
@@ -58,11 +54,6 @@ limitations under the License.
spring-boot-starter
-
- org.projectlombok
- lombok
-
-
io.appulse.enconencon-spring
@@ -79,16 +70,6 @@ limitations under the License.
spring-boot-starter-testtest
-
- junit
- junit
- test
-
-
- org.assertj
- assertj-core
- test
-
@@ -96,7 +77,7 @@ limitations under the License.
org.springframework.bootspring-boot-maven-plugin
- 2.0.4.RELEASE
+ 2.1.1.RELEASE
diff --git a/examples/load-config-spring/src/main/resources/application.yml b/examples/load-config-spring/src/main/resources/application.yml
index 2bfd4c0..f688b6c 100644
--- a/examples/load-config-spring/src/main/resources/application.yml
+++ b/examples/load-config-spring/src/main/resources/application.yml
@@ -1,26 +1,14 @@
spring.encon:
- defaults:
- type: R3_ERLANG
- short-name: true
- cookie: secret
- protocol: TCP
- low-version: R4
- high-version: R6
- distribution-flags:
- - MAP_TAG
- - BIG_CREATION
- server:
- boss-threads: 2
- worker-threads: 4
-
nodes:
node-1:
type: R3_HIDDEN
+ shortName: true
cookie: non-secret
- low-version: R5C
- high-version: R6
- distribution-flags:
+ protocol: TCP
+ lowVersion: R5C
+ highVersion: R6
+ distributionFlags:
- EXTENDED_REFERENCES
- EXTENDED_PIDS_PORTS
- BIT_BINARIES
@@ -30,14 +18,21 @@ spring.encon:
- UTF8_ATOMS
- MAP_TAG
- BIG_CREATION
- mailboxes:
- - name: another
- - name: another_one
server:
port: 8971
- boss-threads: 1
- worker-threads: 2
+ bossThreads: 1
+ workerThreads: 2
node-2:
- short-name: false
+ type: R3_ERLANG
+ shortName: false
cookie: popa
+ protocol: TCP
+ lowVersion: R4
+ highVersion: R6
+ distributionFlags:
+ - MAP_TAG
+ - BIG_CREATION
+ server:
+ bossThreads: 2
+ workerThreads: 4
diff --git a/examples/load-config-spring/src/test/java/io/appulse/encon/examples/load/config/spring/MainTest.java b/examples/load-config-spring/src/test/java/io/appulse/encon/examples/load/config/spring/MainTest.java
index 4c0a127..4522701 100644
--- a/examples/load-config-spring/src/test/java/io/appulse/encon/examples/load/config/spring/MainTest.java
+++ b/examples/load-config-spring/src/test/java/io/appulse/encon/examples/load/config/spring/MainTest.java
@@ -16,7 +16,6 @@
package io.appulse.encon.examples.load.config.spring;
-
import static io.appulse.encon.common.DistributionFlag.BIG_CREATION;
import static io.appulse.encon.common.DistributionFlag.BIT_BINARIES;
import static io.appulse.encon.common.DistributionFlag.EXTENDED_PIDS_PORTS;
@@ -38,12 +37,12 @@
import io.appulse.encon.config.Config;
import lombok.extern.slf4j.Slf4j;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.ApplicationContext;
-import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
/**
*
@@ -51,9 +50,9 @@
* @author Artem Labazin
*/
@Slf4j
-@RunWith(SpringRunner.class)
+@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = Main.class)
-public class MainTest {
+class MainTest {
@Autowired
Config defaultConfig;
@@ -62,14 +61,14 @@ public class MainTest {
ApplicationContext context;
@Test
- public void test () {
+ void test () {
try {
assertThat(context.containsBean("node-1")).isTrue();
assertThat(context.containsBean("node-2")).isTrue();
assertThat(context.containsBean("node-1_net_kernelMailbox")).isFalse();
- assertThat(context.containsBean("node-1_anotherMailbox")).isTrue();
- assertThat(context.containsBean("node-1_another_oneMailbox")).isTrue();
+ // assertThat(context.containsBean("node-1_anotherMailbox")).isTrue();
+ // assertThat(context.containsBean("node-1_another_oneMailbox")).isTrue();
assertThat(context.containsBean("node-2_net_kernelMailbox")).isFalse();
} catch (Throwable ex) {
@@ -122,9 +121,9 @@ private void checkNode1 (Node node) {
assertThat(node.mailbox("net_kernel")).isNotNull();
- assertThat(node.mailbox("another")).isNotNull();
- assertThat(node.mailbox("another_one")).isNotNull();
- assertThat(node.mailboxes()).hasSize(3);
+ // assertThat(node.mailbox("another")).isNotNull();
+ // assertThat(node.mailbox("another_one")).isNotNull();
+ assertThat(node.mailboxes()).hasSize(1);
}
private void checkNode2 (Node node) {
diff --git a/examples/load-config/pom.xml b/examples/load-config/pom.xml
index 1bcfca9..69f9b56 100644
--- a/examples/load-config/pom.xml
+++ b/examples/load-config/pom.xml
@@ -25,43 +25,18 @@ limitations under the License.
io.appulse.enconexamples
- 1.6.5
+ 2.0.0io.appulse.encon.examplesload-configjar
-
- UTF-8
- UTF-8
-
- 1.8
- 1.8
-
-
-
- org.projectlombok
- lombok
- provided
-
-
io.appulse.enconencon${project.version}
-
-
- junit
- junit
- test
-
-
- org.assertj
- assertj-core
- test
-
diff --git a/examples/load-config/src/main/resources/nodes.yml b/examples/load-config/src/main/resources/nodes.yml
index a7e13fe..a921efb 100644
--- a/examples/load-config/src/main/resources/nodes.yml
+++ b/examples/load-config/src/main/resources/nodes.yml
@@ -1,25 +1,13 @@
-defaults:
- type: R3_ERLANG
- short-name: true
- cookie: secret
- protocol: TCP
- low-version: R4
- high-version: R6
- distribution-flags:
- - MAP_TAG
- - BIG_CREATION
- server:
- boss-threads: 2
- worker-threads: 4
-
nodes:
node-1:
type: R3_HIDDEN
+ shortName: true
cookie: non-secret
- low-version: R5C
- high-version: R6
- distribution-flags:
+ protocol: TCP
+ lowVersion: R5C
+ highVersion: R6
+ distributionFlags:
- EXTENDED_REFERENCES
- EXTENDED_PIDS_PORTS
- BIT_BINARIES
@@ -29,14 +17,21 @@ nodes:
- UTF8_ATOMS
- MAP_TAG
- BIG_CREATION
- mailboxes:
- - name: another
- - name: another_one
server:
port: 8971
- boss-threads: 1
- worker-threads: 2
+ bossThreads: 1
+ workerThreads: 2
node-2:
- short-name: false
+ type: R3_ERLANG
+ shortName: false
cookie: popa
+ protocol: TCP
+ lowVersion: R4
+ highVersion: R6
+ distributionFlags:
+ - MAP_TAG
+ - BIG_CREATION
+ server:
+ bossThreads: 2
+ workerThreads: 4
diff --git a/examples/load-config/src/test/java/io/appulse/encon/examples/load/config/MainTest.java b/examples/load-config/src/test/java/io/appulse/encon/examples/load/config/MainTest.java
index 0ddc2d4..7e860d9 100644
--- a/examples/load-config/src/test/java/io/appulse/encon/examples/load/config/MainTest.java
+++ b/examples/load-config/src/test/java/io/appulse/encon/examples/load/config/MainTest.java
@@ -36,7 +36,7 @@
import io.appulse.encon.Node;
import lombok.extern.slf4j.Slf4j;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
@@ -44,10 +44,10 @@
* @author Artem Labazin
*/
@Slf4j
-public class MainTest {
+class MainTest {
@Test
- public void test () {
+ void test () {
Server server = new Server();
server.start();
@@ -100,9 +100,7 @@ private void checkNode1 (Server server) {
assertThat(node.mailbox("net_kernel")).isNotNull();
- assertThat(node.mailbox("another")).isNotNull();
- assertThat(node.mailbox("another_one")).isNotNull();
- assertThat(node.mailboxes()).hasSize(3);
+ assertThat(node.mailboxes()).hasSize(1);
}
private void checkNode2 (Server server) {
diff --git a/examples/pom.xml b/examples/pom.xml
index f504ec0..cc374de 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -25,7 +25,7 @@ limitations under the License.
io.appulse.enconencon-parent
- 1.6.5
+ 2.0.0examples
diff --git a/examples/simple/pom.xml b/examples/simple/pom.xml
index 88e4a05..5946067 100644
--- a/examples/simple/pom.xml
+++ b/examples/simple/pom.xml
@@ -25,7 +25,7 @@ limitations under the License.
io.appulse.enconexamples
- 1.6.5
+ 2.0.0io.appulse.encon.examples
@@ -33,12 +33,6 @@ limitations under the License.
jar
- UTF-8
- UTF-8
-
- 1.8
- 1.8
-
io.appulse.encon.examples.simple.Main
@@ -48,17 +42,6 @@ limitations under the License.
encon${project.version}
-
-
- junit
- junit
- test
-
-
- org.assertj
- assertj-core
- test
-
@@ -66,7 +49,7 @@ limitations under the License.
org.apache.maven.pluginsmaven-shade-plugin
- 3.1.0
+ 3.2.1
diff --git a/examples/simple/src/main/java/io/appulse/encon/examples/simple/Main.java b/examples/simple/src/main/java/io/appulse/encon/examples/simple/Main.java
index 275d16e..3c79f75 100644
--- a/examples/simple/src/main/java/io/appulse/encon/examples/simple/Main.java
+++ b/examples/simple/src/main/java/io/appulse/encon/examples/simple/Main.java
@@ -20,7 +20,7 @@
import io.appulse.encon.Node;
import io.appulse.encon.Nodes;
-import io.appulse.encon.config.NodeConfig;
+import io.appulse.encon.NodesConfig.NodeConfig;
import io.appulse.encon.mailbox.Mailbox;
import io.appulse.encon.terms.ErlangTerm;
import io.appulse.encon.terms.type.ErlangPid;
diff --git a/examples/simple/src/test/java/io/appulse/encon/examples/simple/MainTest.java b/examples/simple/src/test/java/io/appulse/encon/examples/simple/MainTest.java
index 5c7e2e6..c4663a6 100644
--- a/examples/simple/src/test/java/io/appulse/encon/examples/simple/MainTest.java
+++ b/examples/simple/src/test/java/io/appulse/encon/examples/simple/MainTest.java
@@ -29,17 +29,17 @@
import io.appulse.encon.mailbox.Mailbox;
import io.appulse.encon.terms.ErlangTerm;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
* @since 1.6.2
* @author Artem Labazin
*/
-public class MainTest {
+class MainTest {
@Test
- public void test () throws Exception {
+ void test () throws Exception {
ExecutorService executorService = Executors.newSingleThreadExecutor();
executorService.execute(() -> Main.main(null));
diff --git a/mvnw b/mvnw
new file mode 100755
index 0000000..5551fde
--- /dev/null
+++ b/mvnw
@@ -0,0 +1,286 @@
+#!/bin/sh
+# ----------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# ----------------------------------------------------------------------------
+
+# ----------------------------------------------------------------------------
+# Maven2 Start Up Batch script
+#
+# Required ENV vars:
+# ------------------
+# JAVA_HOME - location of a JDK home dir
+#
+# Optional ENV vars
+# -----------------
+# M2_HOME - location of maven2's installed home dir
+# MAVEN_OPTS - parameters passed to the Java VM when running Maven
+# e.g. to debug Maven itself, use
+# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
+# ----------------------------------------------------------------------------
+
+if [ -z "$MAVEN_SKIP_RC" ] ; then
+
+ if [ -f /etc/mavenrc ] ; then
+ . /etc/mavenrc
+ fi
+
+ if [ -f "$HOME/.mavenrc" ] ; then
+ . "$HOME/.mavenrc"
+ fi
+
+fi
+
+# OS specific support. $var _must_ be set to either true or false.
+cygwin=false;
+darwin=false;
+mingw=false
+case "`uname`" in
+ CYGWIN*) cygwin=true ;;
+ MINGW*) mingw=true;;
+ Darwin*) darwin=true
+ # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
+ # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
+ if [ -z "$JAVA_HOME" ]; then
+ if [ -x "/usr/libexec/java_home" ]; then
+ export JAVA_HOME="`/usr/libexec/java_home`"
+ else
+ export JAVA_HOME="/Library/Java/Home"
+ fi
+ fi
+ ;;
+esac
+
+if [ -z "$JAVA_HOME" ] ; then
+ if [ -r /etc/gentoo-release ] ; then
+ JAVA_HOME=`java-config --jre-home`
+ fi
+fi
+
+if [ -z "$M2_HOME" ] ; then
+ ## resolve links - $0 may be a link to maven's home
+ PRG="$0"
+
+ # need this for relative symlinks
+ while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG="`dirname "$PRG"`/$link"
+ fi
+ done
+
+ saveddir=`pwd`
+
+ M2_HOME=`dirname "$PRG"`/..
+
+ # make it fully qualified
+ M2_HOME=`cd "$M2_HOME" && pwd`
+
+ cd "$saveddir"
+ # echo Using m2 at $M2_HOME
+fi
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched
+if $cygwin ; then
+ [ -n "$M2_HOME" ] &&
+ M2_HOME=`cygpath --unix "$M2_HOME"`
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+ [ -n "$CLASSPATH" ] &&
+ CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
+fi
+
+# For Mingw, ensure paths are in UNIX format before anything is touched
+if $mingw ; then
+ [ -n "$M2_HOME" ] &&
+ M2_HOME="`(cd "$M2_HOME"; pwd)`"
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
+ # TODO classpath?
+fi
+
+if [ -z "$JAVA_HOME" ]; then
+ javaExecutable="`which javac`"
+ if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
+ # readlink(1) is not available as standard on Solaris 10.
+ readLink=`which readlink`
+ if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
+ if $darwin ; then
+ javaHome="`dirname \"$javaExecutable\"`"
+ javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
+ else
+ javaExecutable="`readlink -f \"$javaExecutable\"`"
+ fi
+ javaHome="`dirname \"$javaExecutable\"`"
+ javaHome=`expr "$javaHome" : '\(.*\)/bin'`
+ JAVA_HOME="$javaHome"
+ export JAVA_HOME
+ fi
+ fi
+fi
+
+if [ -z "$JAVACMD" ] ; then
+ if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ else
+ JAVACMD="`which java`"
+ fi
+fi
+
+if [ ! -x "$JAVACMD" ] ; then
+ echo "Error: JAVA_HOME is not defined correctly." >&2
+ echo " We cannot execute $JAVACMD" >&2
+ exit 1
+fi
+
+if [ -z "$JAVA_HOME" ] ; then
+ echo "Warning: JAVA_HOME environment variable is not set."
+fi
+
+CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
+
+# traverses directory structure from process work directory to filesystem root
+# first directory with .mvn subdirectory is considered project base directory
+find_maven_basedir() {
+
+ if [ -z "$1" ]
+ then
+ echo "Path not specified to find_maven_basedir"
+ return 1
+ fi
+
+ basedir="$1"
+ wdir="$1"
+ while [ "$wdir" != '/' ] ; do
+ if [ -d "$wdir"/.mvn ] ; then
+ basedir=$wdir
+ break
+ fi
+ # workaround for JBEAP-8937 (on Solaris 10/Sparc)
+ if [ -d "${wdir}" ]; then
+ wdir=`cd "$wdir/.."; pwd`
+ fi
+ # end of workaround
+ done
+ echo "${basedir}"
+}
+
+# concatenates all lines of a file
+concat_lines() {
+ if [ -f "$1" ]; then
+ echo "$(tr -s '\n' ' ' < "$1")"
+ fi
+}
+
+BASE_DIR=`find_maven_basedir "$(pwd)"`
+if [ -z "$BASE_DIR" ]; then
+ exit 1;
+fi
+
+##########################################################################################
+# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
+# This allows using the maven wrapper in projects that prohibit checking in binary data.
+##########################################################################################
+if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Found .mvn/wrapper/maven-wrapper.jar"
+ fi
+else
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
+ fi
+ jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
+ while IFS="=" read key value; do
+ case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
+ esac
+ done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Downloading from: $jarUrl"
+ fi
+ wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
+
+ if command -v wget > /dev/null; then
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Found wget ... using wget"
+ fi
+ wget "$jarUrl" -O "$wrapperJarPath"
+ elif command -v curl > /dev/null; then
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Found curl ... using curl"
+ fi
+ curl -o "$wrapperJarPath" "$jarUrl"
+ else
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Falling back to using Java to download"
+ fi
+ javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
+ if [ -e "$javaClass" ]; then
+ if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo " - Compiling MavenWrapperDownloader.java ..."
+ fi
+ # Compiling the Java class
+ ("$JAVA_HOME/bin/javac" "$javaClass")
+ fi
+ if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
+ # Running the downloader
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo " - Running MavenWrapperDownloader.java ..."
+ fi
+ ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
+ fi
+ fi
+ fi
+fi
+##########################################################################################
+# End of extension
+##########################################################################################
+
+export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
+if [ "$MVNW_VERBOSE" = true ]; then
+ echo $MAVEN_PROJECTBASEDIR
+fi
+MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin; then
+ [ -n "$M2_HOME" ] &&
+ M2_HOME=`cygpath --path --windows "$M2_HOME"`
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
+ [ -n "$CLASSPATH" ] &&
+ CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
+ [ -n "$MAVEN_PROJECTBASEDIR" ] &&
+ MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
+fi
+
+WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+
+exec "$JAVACMD" \
+ $MAVEN_OPTS \
+ -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
+ "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
+ ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
diff --git a/mvnw.cmd b/mvnw.cmd
new file mode 100644
index 0000000..0e344f6
--- /dev/null
+++ b/mvnw.cmd
@@ -0,0 +1,161 @@
+@REM ----------------------------------------------------------------------------
+@REM Licensed to the Apache Software Foundation (ASF) under one
+@REM or more contributor license agreements. See the NOTICE file
+@REM distributed with this work for additional information
+@REM regarding copyright ownership. The ASF licenses this file
+@REM to you under the Apache License, Version 2.0 (the
+@REM "License"); you may not use this file except in compliance
+@REM with the License. You may obtain a copy of the License at
+@REM
+@REM http://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM Unless required by applicable law or agreed to in writing,
+@REM software distributed under the License is distributed on an
+@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+@REM KIND, either express or implied. See the License for the
+@REM specific language governing permissions and limitations
+@REM under the License.
+@REM ----------------------------------------------------------------------------
+
+@REM ----------------------------------------------------------------------------
+@REM Maven2 Start Up Batch script
+@REM
+@REM Required ENV vars:
+@REM JAVA_HOME - location of a JDK home dir
+@REM
+@REM Optional ENV vars
+@REM M2_HOME - location of maven2's installed home dir
+@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
+@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
+@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
+@REM e.g. to debug Maven itself, use
+@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
+@REM ----------------------------------------------------------------------------
+
+@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
+@echo off
+@REM set title of command window
+title %0
+@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
+@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
+
+@REM set %HOME% to equivalent of $HOME
+if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
+
+@REM Execute a user defined script before this one
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
+@REM check for pre script, once with legacy .bat ending and once with .cmd ending
+if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
+if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
+:skipRcPre
+
+@setlocal
+
+set ERROR_CODE=0
+
+@REM To isolate internal variables from possible post scripts, we use another setlocal
+@setlocal
+
+@REM ==== START VALIDATION ====
+if not "%JAVA_HOME%" == "" goto OkJHome
+
+echo.
+echo Error: JAVA_HOME not found in your environment. >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo.
+goto error
+
+:OkJHome
+if exist "%JAVA_HOME%\bin\java.exe" goto init
+
+echo.
+echo Error: JAVA_HOME is set to an invalid directory. >&2
+echo JAVA_HOME = "%JAVA_HOME%" >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo.
+goto error
+
+@REM ==== END VALIDATION ====
+
+:init
+
+@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
+@REM Fallback to current working directory if not found.
+
+set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
+IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
+
+set EXEC_DIR=%CD%
+set WDIR=%EXEC_DIR%
+:findBaseDir
+IF EXIST "%WDIR%"\.mvn goto baseDirFound
+cd ..
+IF "%WDIR%"=="%CD%" goto baseDirNotFound
+set WDIR=%CD%
+goto findBaseDir
+
+:baseDirFound
+set MAVEN_PROJECTBASEDIR=%WDIR%
+cd "%EXEC_DIR%"
+goto endDetectBaseDir
+
+:baseDirNotFound
+set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
+cd "%EXEC_DIR%"
+
+:endDetectBaseDir
+
+IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
+
+@setlocal EnableExtensions EnableDelayedExpansion
+for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
+@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
+
+:endReadAdditionalConfig
+
+SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
+set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
+set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+
+set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
+FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO (
+ IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
+)
+
+@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
+@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
+if exist %WRAPPER_JAR% (
+ echo Found %WRAPPER_JAR%
+) else (
+ echo Couldn't find %WRAPPER_JAR%, downloading it ...
+ echo Downloading from: %DOWNLOAD_URL%
+ powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"
+ echo Finished downloading %WRAPPER_JAR%
+)
+@REM End of extension
+
+%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
+if ERRORLEVEL 1 goto error
+goto end
+
+:error
+set ERROR_CODE=1
+
+:end
+@endlocal & set ERROR_CODE=%ERROR_CODE%
+
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
+@REM check for post script, once with legacy .bat ending and once with .cmd ending
+if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
+if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
+:skipRcPost
+
+@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
+if "%MAVEN_BATCH_PAUSE%" == "on" pause
+
+if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
+
+exit /B %ERROR_CODE%
diff --git a/pom.xml b/pom.xml
index a1413b2..b68ad06 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,18 +24,20 @@ limitations under the License.
io.appulse.enconencon-parent
- 1.6.5
+ 2.0.0pomUTF-8UTF-8
- 1.8
- 1.8
+ 11
- 1.8
- 1.8
+ ${java.version}
+ ${java.version}
+
+ ${java.version}
+ ${java.version}
@@ -74,7 +76,7 @@ limitations under the License.
https://github.com/appulse-projects/encon-javascm:git:https://github.com/appulse-projects/encon-java.gitscm:git:https://github.com/appulse-projects/encon-java.git
- 1.6.5
+ 2.0.0
@@ -104,26 +106,71 @@ limitations under the License.
Artem Labazinxxlabaza@gmail.com
-
- ambivalence42
- Sokol Andrey
- sokolandrey1993@mail.ru
-
-
- isv
- Stan Ignatev
- i.v.stanislav@gmail.com
-
+
+
+ org.projectlombok
+ lombok
+ 1.18.4
+ provided
+
+
+
+ net.jcip
+ jcip-annotations
+ 1.0
+ provided
+
+
+ com.github.spotbugs
+ spotbugs-annotations
+ 3.1.9
+ provided
+
+
+ com.google.code.findbugs
+ jsr305
+ 3.0.2
+ provided
+
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ 5.3.2
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-params
+ 5.3.2
+ test
+
+
+
+ org.assertj
+ assertj-core
+ 3.11.1
+ test
+
+
+
+ org.mockito
+ mockito-core
+ 2.23.4
+ test
+
+
+ org.mockito
+ mockito-junit-jupiter
+ 2.23.4
+ test
+
+
+
-
- org.projectlombok
- lombok
- 1.18.2
-
-
io.appulselogging-java
@@ -149,6 +196,12 @@ limitations under the License.
server1.0.2
+
+
+ org.yaml
+ snakeyaml
+ 1.23
+ org.erlang.otp
@@ -156,31 +209,20 @@ limitations under the License.
1.6.1
-
- com.google.code.findbugs
- annotations
- 3.0.1u2
-
-
- com.google.code.findbugs
- jsr305
- 3.0.2
-
-
io.nettynetty-buffer
- 4.1.29.Final
+ 4.1.32.Finalio.nettynetty-handler
- 4.1.29.Final
+ 4.1.32.Finalio.nettynetty-transport-native-epoll
- 4.1.29.Final
+ 4.1.32.Finallinux-x86_64
@@ -209,22 +251,6 @@ limitations under the License.
jmh-generator-annprocess1.21
-
-
- junit
- junit
- 4.12
-
-
- org.assertj
- assertj-core
- 3.11.1
-
-
- org.mockito
- mockito-core
- 2.22.0
-
@@ -232,9 +258,9 @@ limitations under the License.
- org.codehaus.mojo
- findbugs-maven-plugin
- 3.0.5
+ com.github.spotbugs
+ spotbugs-maven-plugin
+ 3.1.8MaxLow
@@ -243,22 +269,22 @@ limitations under the License.
- analyze-compile
- compile
+ spotbugs-validation
+ verifycheck
+
org.apache.maven.pluginsmaven-pmd-plugin
- 3.10.0
+ 3.11.0${project.build.sourceEncoding}${maven.compiler.source}
- truetruetruetrue
@@ -269,7 +295,8 @@ limitations under the License.
- package
+ pmd-validation
+ verifycheck
@@ -285,13 +312,13 @@ limitations under the License.
com.puppycrawl.toolscheckstyle
- 8.12
+ 8.15
- validate
- validate
+ checkstyle-validation
+ verifycheck
@@ -310,7 +337,7 @@ limitations under the License.
org.apache.maven.pluginsmaven-javadoc-plugin
- 2.10.4
+ 3.0.1-Xdoclint:none-Xdoclint:none
@@ -320,7 +347,7 @@ limitations under the License.
UTF-8trueprotected
- 1.8
+ ${java.version}true
@@ -375,7 +402,7 @@ limitations under the License.
sign-artifacts
- verify
+ installsign
@@ -386,17 +413,68 @@ limitations under the License.
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.8.0
+
+ ${java.version}
+ ${maven.compiler.target}
+ ${maven.compiler.source}
+ ${maven.compiler.target}
+
+
+
+
+ pl.project13.maven
+ git-commit-id-plugin
+ 2.2.5
+
+
+ git-infos
+
+ revision
+
+
+
+
+ true
+ false
+ true
+ false
+ git
+
+ ${project.build.outputDirectory}/git.properties
+
+ yyyy-MM-dd'T'HH:mm:ssZ
+ ${project.basedir}/.git
+
+ git.closest.tag.commit.count
+ git.closest.tag.name
+
+
+
+
org.apache.maven.pluginsmaven-surefire-plugin
- 2.21.0
+ 2.22.1
+
+ --illegal-access=permit
+ false**/*Test.java
+ **/*Tests.java
+ **/Test*.java
+ **/it/****/*IntegrationTest.java
+ **/*IntegrationTests.java
+ **/*IT.java
+ **/IT*.java
@@ -404,14 +482,20 @@ limitations under the License.
org.apache.maven.pluginsmaven-failsafe-plugin
- 2.21.0
+ 2.22.1
+
+ --illegal-access=permit
+ **/*IntegrationTest.java
+ **/*IntegrationTests.java
+ **/*IT.java
+ **/IT*.java
+ **/it/**/*Test.java
+ **/it/**/*Tests.java
+ **/it/**/Test*.java
-
- **/*Test.java
-