[java-idp-integration-tests COMMIT] /trunk/src/test/java/net/shibboleth/idp/test/localstorage/LocalStorageTest.java
noreply at shibboleth.net
noreply at shibboleth.net
Mon Jun 8 13:18:14 EDT 2015
Author: tzeller
Date: Mon Jun 8 13:18:14 2015
New Revision: 63
URL: http://svn.shibboleth.net/view/java-idp-integration-tests?rev=63&view=rev
Log:
IDP-594 Add another simple test, minor cleanup.
Modified:
trunk/src/test/java/net/shibboleth/idp/test/localstorage/LocalStorageTest.java
Modified: trunk/src/test/java/net/shibboleth/idp/test/localstorage/LocalStorageTest.java
URL: http://svn.shibboleth.net/view/java-idp-integration-tests/trunk/src/test/java/net/shibboleth/idp/test/localstorage/LocalStorageTest.java?rev=63&r1=62&r2=63&view=diff
==============================================================================
--- trunk/src/test/java/net/shibboleth/idp/test/localstorage/LocalStorageTest.java (original)
+++ trunk/src/test/java/net/shibboleth/idp/test/localstorage/LocalStorageTest.java Mon Jun 8 13:18:14 2015
@@ -27,6 +27,7 @@
import net.shibboleth.idp.test.BaseIntegrationTest;
import net.shibboleth.utilities.java.support.collection.Pair;
import net.shibboleth.utilities.java.support.net.URLBuilder;
+import net.shibboleth.utilities.java.support.primitive.StringSupport;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
@@ -224,46 +225,107 @@
return URL;
}
- @Test public void testNothingToRead() throws Exception {
-
- startJettyServer();
-
- driver.get(buildReadURL(testKey));
-
- waitForLocalStorageTestViewPage();
-
+ /**
+ * Assert that reading from local storage was successful
+ *
+ * Must be called after {@link #waitForLocalStorageTestViewPage()}.
+ *
+ * @param itemKey the local storage item key
+ * @param itemValue the local storage item value
+ */
+ protected void assertSuccessfulRead(@Nullable final String itemKey, @Nullable final String itemValue) {
Assert.assertEquals(getLocalStorageException(), "");
- Assert.assertEquals(getLocalStorageKey(), testKey);
+ Assert.assertEquals(getLocalStorageKey(), itemKey);
Assert.assertEquals(getLocalStorageSuccess(), "true");
Assert.assertEquals(getLocalStorageSupported(), "true");
- if (driver instanceof HtmlUnitDriver) {
- Assert.assertEquals(getLocalStorageValue(), "null");
+
+ // if the itemValue is empty
+ if (StringSupport.trimOrNull(itemValue) == null) {
+ // look for "null" when using HtmlUnit as the client
+ if (driver instanceof HtmlUnitDriver) {
+ Assert.assertEquals(getLocalStorageValue(), "null");
+ }
+ Assert.assertNull(getLocalStorageValueViaWrapper(testKey));
} else {
- Assert.assertEquals(getLocalStorageValue(), "");
+ Assert.assertEquals(getLocalStorageValue(), itemValue);
+ Assert.assertEquals(getLocalStorageValueViaWrapper(itemKey), itemValue);
}
- Assert.assertEquals(getLocalStorageValueViaGetItem(), "null");
- Assert.assertNull(getLocalStorageValueViaWrapper(testKey));
+
Assert.assertEquals(getLocalStorageVersion(), ""); // TODO
}
- @Test public void testWrite() throws Exception {
-
- startJettyServer();
-
- driver.get(buildWriteURL(testKey, testValue));
-
- waitForLocalStorageTestViewPage();
-
+ /**
+ * Assert that writing to local storage was successful.
+ *
+ * Must be called after {@link #waitForLocalStorageTestViewPage()}.
+ *
+ * @param itemKey the local storage item key
+ * @param itemValue the expected local storage item value
+ */
+ protected void assertSuccessfulWrite(@Nullable final String itemKey, @Nullable final String itemValue) {
Assert.assertEquals(getLocalStorageException(), "");
- Assert.assertEquals(getLocalStorageKey(), testKey);
+ Assert.assertEquals(getLocalStorageKey(), itemKey);
Assert.assertEquals(getLocalStorageSuccess(), "true");
Assert.assertEquals(getLocalStorageSupported(), ""); // Not returned from write flow
- Assert.assertEquals(getLocalStorageValue(), testValue);
- Assert.assertEquals(getLocalStorageValueViaGetItem(), testValue);
- Assert.assertEquals(getLocalStorageValueViaWrapper(testKey), testValue);
+ Assert.assertEquals(getLocalStorageValue(), itemValue);
+ Assert.assertEquals(getLocalStorageValueViaGetItem(), itemValue);
+ Assert.assertEquals(getLocalStorageValueViaWrapper(itemKey), itemValue);
Assert.assertEquals(getLocalStorageVersion(), ""); // TODO
}
+ @Test public void testNothingToRead() throws Exception {
+
+ startJettyServer();
+
+ driver.get(buildReadURL(testKey));
+
+ waitForLocalStorageTestViewPage();
+
+ assertSuccessfulRead(testKey, "");
+ }
+
+ @Test public void testRead() throws Exception {
+
+ startJettyServer();
+
+ driver.get(buildWriteURL(testKey, testValue));
+
+ waitForLocalStorageTestViewPage();
+
+ driver.get(buildReadURL(testKey));
+
+ waitForLocalStorageTestViewPage();
+
+ assertSuccessfulRead(testKey, testValue);
+ }
+
[... 31 lines stripped ...]
More information about the commits
mailing list