Merge pull request #8125 from eugenp/revert-8119-BAEL-3275-2

Revert "BAEL-3275: Using blocking queue for pub-sub"
This commit is contained in:
Eric Martin
2019-10-31 20:43:47 -05:00
committed by GitHub
parent db85c8f275
commit 3225470df5
20543 changed files with 1642750 additions and 0 deletions
@@ -0,0 +1,18 @@
package com.baeldung.text;
import org.apache.commons.text.diff.EditScript;
import org.apache.commons.text.diff.StringsComparator;
import org.junit.Assert;
import org.junit.Test;
public class DiffUnitTest {
@Test
public void whenEditScript_thenCorrect() {
StringsComparator cmp = new StringsComparator("ABCFGH", "BCDEFG");
EditScript<Character> script = cmp.getScript();
int mod = script.getModifications();
Assert.assertEquals(4, mod);
}
}
@@ -0,0 +1,25 @@
package com.baeldung.text;
import org.apache.commons.text.similarity.LongestCommonSubsequence;
import org.apache.commons.text.similarity.LongestCommonSubsequenceDistance;
import org.junit.Assert;
import org.junit.Test;
public class LongestCommonSubsequenceUnitTest {
@Test
public void whenCompare_thenCorrect() {
LongestCommonSubsequence lcs = new LongestCommonSubsequence();
int countLcs = lcs.apply("New York", "New Hampshire");
Assert.assertEquals(5, countLcs);
}
@Test
public void whenCalculateDistance_thenCorrect() {
LongestCommonSubsequenceDistance lcsd = new LongestCommonSubsequenceDistance();
int countLcsd = lcsd.apply("New York", "New Hampshire");
Assert.assertEquals(11, countLcsd);
}
}
@@ -0,0 +1,24 @@
package com.baeldung.text;
import org.apache.commons.text.StrBuilder;
import org.junit.Assert;
import org.junit.Test;
public class StrBuilderUnitTest {
@Test
public void whenReplaced_thenCorrect() {
StrBuilder strBuilder = new StrBuilder("example StrBuilder!");
strBuilder.replaceAll("example", "new");
Assert.assertEquals(new StrBuilder("new StrBuilder!"), strBuilder);
}
@Test
public void whenCleared_thenEmpty() {
StrBuilder strBuilder = new StrBuilder("example StrBuilder!");
strBuilder.clear();
Assert.assertEquals(new StrBuilder(""), strBuilder);
}
}
@@ -0,0 +1,23 @@
package com.baeldung.text;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.text.StrSubstitutor;
import org.junit.Assert;
import org.junit.Test;
public class StrSubstitutorUnitTest {
@Test
public void whenSubstituted_thenCorrect() {
Map<String, String> substitutes = new HashMap<>();
substitutes.put("name", "John");
substitutes.put("college", "University of Stanford");
String templateString = "My name is ${name} and I am a student at the ${college}.";
StrSubstitutor sub = new StrSubstitutor(substitutes);
String result = sub.replace(templateString);
Assert.assertEquals("My name is John and I am a student at the University of Stanford.", result);
}
}
@@ -0,0 +1,16 @@
package com.baeldung.text;
import org.apache.commons.text.translate.UnicodeEscaper;
import org.junit.Assert;
import org.junit.Test;
public class UnicodeEscaperUnitTest {
@Test
public void whenTranslate_thenCorrect() {
UnicodeEscaper ue = UnicodeEscaper.above(0);
String result = ue.translate("ABCD");
Assert.assertEquals("\\u0041\\u0042\\u0043\\u0044", result);
}
}
@@ -0,0 +1,23 @@
package com.baeldung.text;
import org.apache.commons.text.WordUtils;
import org.junit.Assert;
import org.junit.Test;
public class WordUtilsUnitTest {
@Test
public void whenCapitalized_thenCorrect() {
String toBeCapitalized = "to be capitalized!";
String result = WordUtils.capitalize(toBeCapitalized);
Assert.assertEquals("To Be Capitalized!", result);
}
@Test
public void whenContainsWords_thenCorrect() {
boolean containsWords = WordUtils.containsAllWords("String to search", "to", "search");
Assert.assertTrue(containsWords);
}
}