Permalink
Browse files

more simple tests

  • Loading branch information...
1 parent 29de597 commit 3955a3f6b900a058523fe3597796d4d23b8a7b20 @notnoop committed Jun 23, 2011
View
20 src/test/java/com/notnoop/mpns/internal/UtilitiesTest.java
@@ -0,0 +1,20 @@
+package com.notnoop.mpns.internal;
+
+import org.junit.Test;
+import static org.junit.Assert.*;
+import static org.hamcrest.CoreMatchers.*;
+
+import static com.notnoop.mpns.internal.Utilities.*;
+
+public class UtilitiesTest {
+
+ @Test
+ public void ifNonNullHandlesNull() {
+ assertThat(ifNonNull(null, "asdf"), is(""));
+ }
+
+ @Test
+ public void isNonNullHandlesNonNull() {
+ assertThat(ifNonNull("A", "asdf" + "fdsa"), is("asdffdsa"));
+ }
+}
View
37 src/test/java/com/notnoop/mpns/internal/XMLEscapingTest.java
@@ -0,0 +1,37 @@
+package com.notnoop.mpns.internal;
+
+import org.junit.Test;
+import static org.junit.Assert.*;
+import static org.hamcrest.CoreMatchers.*;
+
+import static com.notnoop.mpns.internal.Utilities.escapeXml;
+
+public class XMLEscapingTest {
+
+ @Test
+ public void escapesNull() {
+ assertThat(escapeXml(null), is((String)null));
+ }
+
+ @Test
+ public void escapeEmpty() {
+ assertThat(escapeXml(""), is(""));
+ }
+
+ @Test
+ public void escapeNonEntities() {
+ String text = "random;23$%^";
+ assertThat(escapeXml(text), is(text));
+ }
+
+ @Test
+ public void escapeAmpt() {
+ assertThat(escapeXml("test&"), is("test&"));
+ }
+
+ @Test
+ public void escapeAllValues() {
+ assertThat(escapeXml("AT&T called \"Johns's father\" > 2 hours ago < 5 years ago."),
+ is("AT&amp;T called &quot;Johns&apos;s father&quot; &gt; 2 hours ago &lt; 5 years ago."));
+ }
+}

0 comments on commit 3955a3f

Please sign in to comment.