Merge pull request #28 from h908714124/add-maven-pom

add a maven pom, and a basic unit test, to StringCT-java
This commit is contained in:
Riccardo Spagni 2018-06-19 17:57:45 +02:00 committed by GitHub
commit ce82e4a0c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 124 additions and 0 deletions

10
.gitignore vendored Normal file
View file

@ -0,0 +1,10 @@
# c
*.o
# Maven
target
# Intellij IDEA
.idea
*.iml

View file

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>research-lab</groupId>
<artifactId>StringCT</artifactId>
<version>0-SNAPSHOT</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- Dependency versions -->
<junit.version>4.12</junit.version>
<bcprov-jdk15on.version>1.59</bcprov-jdk15on.version>
<commons-pool2.version>2.4.2</commons-pool2.version>
<commons-codec.version>1.10</commons-codec.version>
</properties>
<dependencies>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-debug-jdk15on</artifactId>
<version>${bcprov-jdk15on.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
<version>${commons-pool2.version}</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>${commons-codec.version}</version>
</dependency>
<!--
==========
Test scope
==========
-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>${project.basedir}/src</sourceDirectory>
<testSourceDirectory>${project.basedir}/test</testSourceDirectory>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<forkCount>1</forkCount>
<reuseForks>false</reuseForks>
</configuration>
</plugin>
<plugin>
<version>3.0.1</version>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<phase>verify</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View file

@ -0,0 +1,29 @@
package org.nem.core.utils;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import org.junit.Test;
public class ArrayUtilsTest {
@Test
public void duplicate() {
// Arrange
byte[] bytes = "test".getBytes(StandardCharsets.UTF_8);
int bytesHash = Arrays.hashCode(bytes);
// Act
byte[] duplicate = ArrayUtils.duplicate(bytes);
// Assert: original array is unchanged
assertEquals(bytesHash, Arrays.hashCode(bytes));
// Assert: check duplicate
assertArrayEquals(bytes, duplicate);
}
}