Removing unnecessary files

This commit is contained in:
Nick 2019-12-08 10:34:46 +00:00
parent a805787669
commit 0ef184239f
3 changed files with 0 additions and 273 deletions

View File

@ -1,161 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>java-strings-3</artifactId>
<version>0.1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>java-strings-3</name>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-java</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../parent-java</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
<version>${jmh-core.version}</version>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>${jmh-core.version}</version>
</dependency>
<dependency>
<groupId>com.ibm.icu</groupId>
<artifactId>icu4j</artifactId>
<version>${icu4j.version}</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io.version}</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>${commons-codec.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>${org.hamcrest.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.bitbucket.cowwoc</groupId>
<artifactId>diff-match-patch</artifactId>
<version>1.2</version>
<scope>test</scope>
</dependency>
<!-- Added for password generation -->
<dependency>
<groupId>org.passay</groupId>
<artifactId>passay</artifactId>
<version>${passay.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>${commons-text.version}</version>
</dependency>
<dependency>
<groupId>com.vdurmont</groupId>
<artifactId>emoji-java</artifactId>
<version>${emoji-java.version}</version>
</dependency>
<dependency>
<groupId>org.ahocorasick</groupId>
<artifactId>ahocorasick</artifactId>
<version>${ahocorasick.version}</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>${validation-api.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>${hibernate-validator.version}</version>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<version>${javax.el-api.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>javax.el</artifactId>
<version>${javax.el.version}</version>
</dependency>
</dependencies>
<build>
<finalName>java-strings-3</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArgument>-parameters</compilerArgument>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<commons-lang3.version>3.8.1</commons-lang3.version>
<commons-codec.version>1.10</commons-codec.version>
<passay.version>1.3.1</passay.version>
<!-- testing -->
<assertj.version>3.6.1</assertj.version>
<emoji-java.version>4.0.0</emoji-java.version>
<ahocorasick.version>0.4.0</ahocorasick.version>
<icu4j.version>61.1</icu4j.version>
<guava.version>28.0-jre</guava.version>
<commons-text.version>1.4</commons-text.version>
<validation-api.version>2.0.0.Final</validation-api.version>
<hibernate-validator.version>6.0.2.Final</hibernate-validator.version>
<javax.el-api.version>3.0.0</javax.el-api.version>
<javax.el.version>2.2.6</javax.el.version>
</properties>
</project>

View File

@ -1,73 +0,0 @@
package com.baeldung.stringdiff;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.bitbucket.cowwoc.diffmatchpatch.DiffMatchPatch;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@State(Scope.Benchmark)
public class StringDiffBenchmarkUnitTest {
private DiffMatchPatch diffMatchPatch = new DiffMatchPatch();
private List<String> inputs = randomizeInputs(10000);
public static void main(String[] args) throws RunnerException {
Options opts = new OptionsBuilder().include(".*")
.warmupIterations(1)
.measurementIterations(50)
.jvmArgs("-Xms2g", "-Xmx2g")
.shouldDoGC(true)
.forks(1)
.build();
new Runner(opts).run();
}
@Benchmark
public int diffMatchPatch() {
for (int i = 0; i < inputs.size() - 1; i++) {
diffMatchPatch.diffMain(inputs.get(i), inputs.get(i + 1), false);
}
return inputs.size();
}
@Benchmark
public int stringUtils() {
for (int i = 0; i < inputs.size() - 1; i++) {
StringUtils.difference(inputs.get(i), inputs.get(i + 1));
}
return inputs.size();
}
/**
* Creates a list of a given size, containing 30 character long strings,
* each starting with a static prefix of 10 characters and followed by
* a random 20 character suffix
*
* @return a {@link List} of randomised strings
*/
private List<String> randomizeInputs(int size) {
String staticPart = "ABCDEF1234";
List<String> inputs = new ArrayList<>();
for (int i = 0; i < size; i++) {
inputs.add(staticPart + RandomStringUtils.randomAlphabetic(20));
}
return inputs;
}
}

View File

@ -1,39 +0,0 @@
package com.baeldung.stringdiff;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import org.apache.commons.lang3.StringUtils;
import org.bitbucket.cowwoc.diffmatchpatch.DiffMatchPatch;
import org.bitbucket.cowwoc.diffmatchpatch.DiffMatchPatch.Operation;
import org.junit.Test;
public class StringDiffUnitTest {
private DiffMatchPatch diffMatchPatch = new DiffMatchPatch();
// Test samples
private final String text1 = "ABCDELMN";
private final String text2 = "ABCFGLMN";
@Test
public void givenTwoStrings_whenDiffMatchPatch_thenReturnCorrectDiff() {
assertThat(diffMatchPatch.diffMain(text1, text2, false), containsInAnyOrder(
new DiffMatchPatch.Diff(Operation.EQUAL, "ABC"),
new DiffMatchPatch.Diff(Operation.DELETE, "DE"),
new DiffMatchPatch.Diff(Operation.INSERT, "FG"),
new DiffMatchPatch.Diff(Operation.EQUAL, "LMN")));
assertThat(diffMatchPatch.diffMain(text2, text1, false), containsInAnyOrder(
new DiffMatchPatch.Diff(Operation.EQUAL, "ABC"),
new DiffMatchPatch.Diff(Operation.INSERT, "DE"),
new DiffMatchPatch.Diff(Operation.DELETE, "FG"),
new DiffMatchPatch.Diff(Operation.EQUAL, "LMN")));
}
@Test
public void givenTwoStrings_whenStringUtilsDifference_thenReturnCorrectDiff() {
assertThat(StringUtils.difference(text1, text2), is("FGLMN"));
assertThat(StringUtils.difference(text2, text1), is("DELMN"));
}
}