diff --git a/pom.xml b/pom.xml
index 789fa18..4b4bf51 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,6 +7,18 @@
com.zipcodewilmington
regex
1.0-SNAPSHOT
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ 7
+ 7
+
+
+
+
diff --git a/src/test/java/HamletParserTest.java b/src/test/java/HamletParserTest.java
index 7670909..0590718 100644
--- a/src/test/java/HamletParserTest.java
+++ b/src/test/java/HamletParserTest.java
@@ -1,6 +1,10 @@
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
import static org.junit.Assert.*;
public class HamletParserTest {
@@ -15,17 +19,50 @@ public void setUp() {
@Test
public void testChangeHamletToLeon() {
+ Pattern pattern = Pattern.compile("[H|h]amlet", Pattern.CASE_INSENSITIVE);
+ Matcher matcher = pattern.matcher(hamletText);
+ String result = matcher.replaceAll("Leon");
+ System.out.println(result);
}
@Test
public void testChangeHoratioToTariq() {
+ Pattern pattern = Pattern.compile("[H|h]oratio", Pattern.CASE_INSENSITIVE);
+ Matcher matcher = pattern.matcher(hamletText);
+ String result = matcher.replaceAll("Tariq");
+ System.out.println(result);
}
@Test
public void testFindHoratio() {
+ Boolean expected = true;
+
+ Pattern pattern = Pattern.compile("Horatio", Pattern.CASE_INSENSITIVE);
+ Matcher matcher = pattern.matcher(hamletText);
+ Boolean actual = matcher.find();
+
+ Assert.assertEquals(expected, actual);
}
@Test
public void testFindHamlet() {
+ Boolean expected = true;
+
+ Pattern pattern = Pattern.compile("Hamlet", Pattern.CASE_INSENSITIVE);
+ Matcher matcher = pattern.matcher(hamletText);
+ Boolean actual = matcher.find();
+
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test (expected = AssertionError.class)
+ public void testFindARegexNotThere_Failure() {
+ Boolean expected = true;
+
+ Pattern pattern = Pattern.compile("AppleBottomJeans", Pattern.CASE_INSENSITIVE);
+ Matcher matcher = pattern.matcher(hamletText);
+ Boolean actual = matcher.find(0);
+
+ Assert.assertEquals(expected, actual);
}
}
\ No newline at end of file