Author: mwringe
Date: 2010-06-23 13:15:32 -0400 (Wed, 23 Jun 2010)
New Revision: 3434
Modified:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v1/MarkupTestCase.java
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/ServiceDescriptionHandler.java
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/config/impl/ProducerRegistrationRequirementsImpl.java
components/wsrp/trunk/test/
components/wsrp/trunk/test/src/main/java/org/gatein/wsrp/test/support/MockHttpServletRequest.java
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v1/MarkupTestCase.java
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v1/RegistrationTestCase.java
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v1/ServiceDescriptionTestCase.java
Log:
GTNWSRP-46: More test updates.
- renable disabled tests, should still have a failure in the consumer MarkupTest due to
missing cookies.
- update MockHttpServletRequest to return locahost and 8080 as the host and port values
- update ServiceDescriptionHandler to properly change the registration values from
required to not required. Update to use nanotime instead of millis since millis is not
accurate enough. Test added to ServiceDescriptionTestCase for his behavour.
Modified:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v1/MarkupTestCase.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v1/MarkupTestCase.java 2010-06-23
13:13:02 UTC (rev 3433)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v1/MarkupTestCase.java 2010-06-23
17:15:32 UTC (rev 3434)
@@ -179,8 +179,7 @@
ExtendedAssert.assertFalse(sessionInfo.isPerGroupCookies());
ExtendedAssert.assertTrue(sessionInfo.isInitCookieDone());
- //TODO: look into the failure later, it doesn't seem like cookie are ever set
in the session info.
- //ExtendedAssert.assertNotNull(sessionInfo.getUserCookie());
+ ExtendedAssert.assertNotNull(sessionInfo.getUserCookie());
ExtendedAssert.assertEquals(1, behavior.getInitCookieCallCount());
}
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/ServiceDescriptionHandler.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/ServiceDescriptionHandler.java 2010-06-23
13:13:02 UTC (rev 3433)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/ServiceDescriptionHandler.java 2010-06-23
17:15:32 UTC (rev 3434)
@@ -101,14 +101,12 @@
ProducerRegistrationRequirements requirements =
producer.getProducerRegistrationRequirements();
+ //update the registration properties with the registration requirements
+ serviceDescription.updateRegistrationProperties(requirements);
+
// if we don't have registration information but a registration is required,
send registration props information
boolean needsRegistrationProperties = registration == null &&
requirements.isRegistrationRequired();
- // TODO: verify if this is the correct behaviour. We should always make this
change, as if the reqistrationRequired goes from true to false, the serviceDescriptions
will never occur.
- if (needsRegistrationProperties)
- {
- serviceDescription.updateRegistrationProperties(requirements);
- }
-
+
boolean needsPortletDescriptions = !(registration == null &&
requirements.isRegistrationRequired()
&& requirements.isRegistrationRequiredForFullDescription());
if (needsPortletDescriptions)
@@ -419,7 +417,7 @@
registrationNoPortletsServiceDescription.setRequiresRegistration(requirements.isRegistrationRequired());
registrationPortletsServiceDescription.setRequiresRegistration(requirements.isRegistrationRequired());
- lastGenerated = System.currentTimeMillis();
+ lastGenerated = System.nanoTime();
}
}
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/config/impl/ProducerRegistrationRequirementsImpl.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/config/impl/ProducerRegistrationRequirementsImpl.java 2010-06-23
13:13:02 UTC (rev 3433)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/config/impl/ProducerRegistrationRequirementsImpl.java 2010-06-23
17:15:32 UTC (rev 3434)
@@ -80,7 +80,7 @@
private void modifyNow()
{
- lastModified = System.currentTimeMillis();
+ lastModified = System.nanoTime();
}
public long getLastModified()
Property changes on: components/wsrp/trunk/test
___________________________________________________________________
Name: svn:ignore
+ target
Modified:
components/wsrp/trunk/test/src/main/java/org/gatein/wsrp/test/support/MockHttpServletRequest.java
===================================================================
---
components/wsrp/trunk/test/src/main/java/org/gatein/wsrp/test/support/MockHttpServletRequest.java 2010-06-23
13:13:02 UTC (rev 3433)
+++
components/wsrp/trunk/test/src/main/java/org/gatein/wsrp/test/support/MockHttpServletRequest.java 2010-06-23
17:15:32 UTC (rev 3434)
@@ -46,8 +46,8 @@
private Map attrs;
public static String scheme = "http";
- public static String serverName = "test";
- public static Integer serverPort = 1234;
+ public static String serverName = "localhost";
+ public static Integer serverPort = 8080;
private MockHttpServletRequest(HttpSession session)
{
Modified:
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v1/MarkupTestCase.java
===================================================================
---
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v1/MarkupTestCase.java 2010-06-23
13:13:02 UTC (rev 3433)
+++
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v1/MarkupTestCase.java 2010-06-23
17:15:32 UTC (rev 3434)
@@ -643,8 +643,7 @@
return namedString;
}
- //TODO: enable this test, it doesn't work or make sense right now since we are
using a mockhttpservletrequest
- //@Test
+ @Test
public void testGetMarkupWithResource() throws Exception
{
undeploy(DEFAULT_MARKUP_PORTLET_WAR);
@@ -658,12 +657,13 @@
String markupString = res.getMarkupContext().getMarkupString();
// accept either localhost or 127.0.0.1 for the host part of the generated
markup
+ // note that we are using a MockHttpServletRequest, so the host and port come
from there.
String markupStart = "<img
src='wsrp_rewrite?wsrp-urlType=resource&wsrp-url=http%3A%2F%2F";
String markupEnd =
"%3A8080%2Ftest-resource-portlet%2Fgif%2Flogo.gif&wsrp-requiresRewrite=true/wsrp_rewrite'/>";
String localhostMarkup = markupStart + "localhost" + markupEnd;
String homeIPMarkup = markupStart + "127.0.0.1" + markupEnd;
boolean result = localhostMarkup.equals(markupString) ||
homeIPMarkup.equals(markupString);
- ExtendedAssert.assertTrue(result);
+ ExtendedAssert.assertTrue("Expectd '" + localhostMarkup +
"' or '" + homeIPMarkup + "' but received '" +
markupString + "'." , result);
}
finally
{
@@ -671,8 +671,7 @@
}
}
- //TODO: enable this test, it doesn't work or make sense right now since we are
using a mockhttpservletrequest
- //@Test
+ @Test
public void testGetMarkupWithNonURLEncodedResource() throws Exception
{
undeploy(DEFAULT_MARKUP_PORTLET_WAR);
@@ -686,12 +685,13 @@
String markupString = res.getMarkupContext().getMarkupString();
// accept either localhost or 127.0.0.1 for the host part of the generated
markup
+ // note that we are using a MockHttpServletRequest, so the host and port come
from there.
String markupStart = "<img src='http://";
String markupEnd =
":8080/test-resourcenoencodeurl-portlet/gif/logo.gif'/>";
String localhostMarkup = markupStart + "localhost" + markupEnd;
String homeIPMarkup = markupStart + "127.0.0.1" + markupEnd;
boolean result = localhostMarkup.equals(markupString) ||
homeIPMarkup.equals(markupString);
- ExtendedAssert.assertTrue(result);
+ ExtendedAssert.assertTrue("Expectd '" + localhostMarkup +
"' or '" + homeIPMarkup + "' but received '" +
markupString + "'.", result);
}
finally
{
Modified:
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v1/RegistrationTestCase.java
===================================================================
---
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v1/RegistrationTestCase.java 2010-06-23
13:13:02 UTC (rev 3433)
+++
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v1/RegistrationTestCase.java 2010-06-23
17:15:32 UTC (rev 3434)
@@ -24,6 +24,7 @@
package org.gatein.wsrp.protocol.v1;
import org.gatein.registration.Registration;
+import org.gatein.registration.RegistrationException;
import org.gatein.registration.RegistrationManager;
import org.gatein.wsrp.WSRPConstants;
import org.gatein.wsrp.WSRPUtils;
@@ -46,6 +47,7 @@
import org.oasis.wsrp.v1.V1GetMarkup;
import org.oasis.wsrp.v1.V1GetServiceDescription;
import org.oasis.wsrp.v1.V1InvalidRegistration;
+import org.oasis.wsrp.v1.V1MissingParameters;
import org.oasis.wsrp.v1.V1ModifyRegistration;
import org.oasis.wsrp.v1.V1OperationFailed;
import org.oasis.wsrp.v1.V1PropertyDescription;
@@ -144,9 +146,8 @@
producer.register(regData);
}
- //TODO: reneable this test when its issues are fixed.
//@Test
- public void testRegistrationHandle() throws Exception//V1OperationFailed,
V1MissingParameters, RegistrationException
+ public void testRegistrationHandle() throws Exception
{
try
{
Modified:
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v1/ServiceDescriptionTestCase.java
===================================================================
---
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v1/ServiceDescriptionTestCase.java 2010-06-23
13:13:02 UTC (rev 3433)
+++
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v1/ServiceDescriptionTestCase.java 2010-06-23
17:15:32 UTC (rev 3434)
@@ -100,8 +100,7 @@
}
}
- //TODO: disable for now
- //@Test
+ @Test
public void testNotRequiringRegistration() throws Throwable
{
producer.getConfigurationService().getConfiguration().getRegistrationRequirements().setRegistrationRequired(false);
@@ -116,6 +115,35 @@
// No registration properties
ExtendedAssert.assertNull(sd.getRegistrationPropertyDescription());
}
+
+ /**
+ * Test to make sure that when switching from required to not-required (and
vise-versa) that
+ * the change properly persists to the service description.
+ *
+ * @throws Throwable
+ */
+ @Test
+ public void testNotRequiringRegistrationSwitching() throws Throwable
+ {
+
producer.getConfigurationService().getConfiguration().getRegistrationRequirements().setRegistrationRequired(false);
+ V1GetServiceDescription gs = getNoRegistrationServiceDescriptionRequest();
+ V1ServiceDescription sd = producer.getServiceDescription(gs);
+
+ // registration is not required
+ ExtendedAssert.assertFalse(sd.isRequiresRegistration());
+
+
producer.getConfigurationService().getConfiguration().getRegistrationRequirements().setRegistrationRequired(true);
+ gs = getNoRegistrationServiceDescriptionRequest();
+ sd = producer.getServiceDescription(gs);
+
+ ExtendedAssert.assertTrue(sd.isRequiresRegistration());
+
+
producer.getConfigurationService().getConfiguration().getRegistrationRequirements().setRegistrationRequired(false);
+ gs = getNoRegistrationServiceDescriptionRequest();
+ sd = producer.getServiceDescription(gs);
+
+ ExtendedAssert.assertFalse(sd.isRequiresRegistration());
+ }
@Test
public void testRequiringRegistrationNotProvidingPortlets() throws Throwable
Show replies by date