[jboss-cvs] jboss-portal/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer ...
Chris Laprun
chris.laprun at jboss.com
Wed Aug 2 19:48:23 EDT 2006
User: claprun
Date: 06/08/02 19:48:23
Modified: wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer
MarkupTestCase.java NeedPortletHandleTest.java
Log:
- Implemented producer-side support for sending caching information to consumers.
- Added caching support tests.
- Improved tests.
Revision Changes Path
1.12 +52 -41 jboss-portal/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/MarkupTestCase.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: MarkupTestCase.java
===================================================================
RCS file: /cvsroot/jboss/jboss-portal/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/MarkupTestCase.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- MarkupTestCase.java 4 Jul 2006 21:05:52 -0000 1.11
+++ MarkupTestCase.java 2 Aug 2006 23:48:23 -0000 1.12
@@ -29,6 +29,7 @@
import org.jboss.portal.wsrp.WSRPRenderURL;
import org.jboss.portal.wsrp.WSRPTypeFactory;
import org.jboss.portal.wsrp.core.BlockingInteractionResponse;
+import org.jboss.portal.wsrp.core.CacheControl;
import org.jboss.portal.wsrp.core.GetMarkup;
import org.jboss.portal.wsrp.core.InitCookie;
import org.jboss.portal.wsrp.core.InteractionParams;
@@ -47,17 +48,18 @@
/**
* @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
- * @version $Revision: 1.11 $
+ * @version $Revision: 1.12 $
* @since 2.4
*/
public class MarkupTestCase extends org.jboss.portal.test.wsrp.v1.producer.NeedPortletHandleTest
{
private static final String DEFAULT_VIEW_MARKUP = "<p>symbol unset stock value: value unset</p>";
+ private static final String DEFAULT_MARKUP_PORTLET_WAR = "test-markup-portlet.war";
public MarkupTestCase()
throws Exception
{
- super("MarkupTestCase", "test-markup-portlet.war");
+ super("MarkupTestCase", DEFAULT_MARKUP_PORTLET_WAR);
}
public void testGetMarkupViewNoSession() throws Exception
@@ -97,12 +99,11 @@
public void testGetMarkupRenderParameters() throws Exception
{
- undeploy("test-markup-portlet.war");
+ undeploy(DEFAULT_MARKUP_PORTLET_WAR);
String archiveName = "test-renderparam-portlet.war";
deploy(archiveName);
- String handle = getHandleForPortletDeployedIn(archiveName);
- GetMarkup gm = createMarkupRequest(handle);
+ GetMarkup gm = createMarkupRequest(archiveName);
MarkupResponse res = markupService.getMarkup(gm);
String markupString = res.getMarkupContext().getMarkupString();
@@ -128,7 +129,8 @@
WSRPActionURL incrementAction = (WSRPActionURL)incrementURL;
// let's see now if we can increment the counter
- PerformBlockingInteraction performBlockingInteraction = WSRPTypeFactory.createDefaultPerformBlockingInteraction(handle);
+ PerformBlockingInteraction performBlockingInteraction =
+ WSRPTypeFactory.createDefaultPerformBlockingInteraction(getHandleForPortletDeployedIn(archiveName));
InteractionParams interactionParams = performBlockingInteraction.getInteractionParams();
interactionParams.setInteractionState(incrementAction.getInteractionState().getStringValue());
markupService.performBlockingInteraction(performBlockingInteraction);
@@ -149,13 +151,12 @@
// fix-me: this test is not completely right...
public void testGetMarkupSession() throws Exception
{
- undeploy("test-markup-portlet.war");
+ undeploy(DEFAULT_MARKUP_PORTLET_WAR);
// deploy session-manipulating portlet
String sessionPortletArchive = "test-session-portlet.war";
deploy(sessionPortletArchive);
- String handle = getHandleForPortletDeployedIn(sessionPortletArchive);
- GetMarkup getMarkup = createMarkupRequest(handle);
+ GetMarkup getMarkup = createMarkupRequest(sessionPortletArchive);
MarkupResponse response = markupService.getMarkup(getMarkup);
@@ -275,6 +276,29 @@
checkMarkupResponse(response, "<p>" + symbol + " stock value: 123.45</p>");
}
+ public void testMarkupCaching() throws Exception
+ {
+ GetMarkup getMarkup = createMarkupRequest();
+
+ MarkupResponse response = markupService.getMarkup(getMarkup);
+
+ CacheControl cacheControl = response.getMarkupContext().getCacheControl();
+ assertNotNull(cacheControl);
+ assertEquals(WSRPConstants.CACHE_PER_USER, cacheControl.getUserScope());
+ assertEquals(15, cacheControl.getExpires());
+
+ undeploy(DEFAULT_MARKUP_PORTLET_WAR);
+ String sessionPortletArchive = "test-session-portlet.war";
+ deploy(sessionPortletArchive);
+
+ response = markupService.getMarkup(createMarkupRequest(sessionPortletArchive));
+
+ cacheControl = response.getMarkupContext().getCacheControl();
+ assertNull(cacheControl);
+
+ undeploy(sessionPortletArchive);
+ }
+
public void testInitCookie() throws Exception
{
InitCookie initCookie = new InitCookie();
@@ -288,7 +312,7 @@
public void testReleaseSessions() throws Exception
{
- undeploy("test-markup-portlet.war");
+ undeploy(DEFAULT_MARKUP_PORTLET_WAR);
String sessionPortletArchive = "test-session-portlet.war";
deploy(sessionPortletArchive);
@@ -297,7 +321,7 @@
initRegistrationInfo();
RegistrationContext rc = registerConsumer();
- GetMarkup gm = createMarkupRequest(handle);
+ GetMarkup gm = createMarkupRequest(sessionPortletArchive);
gm.setRegistrationContext(rc);
MarkupResponse res = markupService.getMarkup(gm);
@@ -335,14 +359,11 @@
public void testGetMarkupWithDispatcherPortlet() throws Exception
{
- undeploy("test-markup-portlet.war");
+ undeploy(DEFAULT_MARKUP_PORTLET_WAR);
String dispatcherPortletArchive = "test-dispatcher-portlet.war";
deploy(dispatcherPortletArchive);
- // need to get the handle before we init the registration otherwise we won't get any offered portlets!
- String handle = getHandleForPortletDeployedIn(dispatcherPortletArchive);
-
- GetMarkup getMarkup = createMarkupRequest(handle);
+ GetMarkup getMarkup = createMarkupRequest(dispatcherPortletArchive);
MarkupResponse response = markupService.getMarkup(getMarkup);
checkMarkupResponse(response, "test");
@@ -352,14 +373,11 @@
public void testGetMarkupWithNoContent() throws Exception
{
- undeploy("test-markup-portlet.war");
+ undeploy(DEFAULT_MARKUP_PORTLET_WAR);
String basicPortletArchive = "test-basic-portlet.war";
deploy(basicPortletArchive);
- // need to get the handle before we init the registration otherwise we won't get any offered portlets!
- String handle = getHandleForPortletDeployedIn(basicPortletArchive);
-
- GetMarkup getMarkup = createMarkupRequest(handle);
+ GetMarkup getMarkup = createMarkupRequest(basicPortletArchive);
MarkupResponse response = markupService.getMarkup(getMarkup);
checkMarkupResponse(response, "");
@@ -369,14 +387,11 @@
public void testGetMarkupWithNonStandardLocales() throws Exception
{
- undeploy("test-markup-portlet.war");
- String basicContentPortletArchive = "test-getlocales-portlet.war";
- deploy(basicContentPortletArchive);
+ undeploy(DEFAULT_MARKUP_PORTLET_WAR);
+ String getLocalesPortletArchive = "test-getlocales-portlet.war";
+ deploy(getLocalesPortletArchive);
- // need to get the handle before we init the registration otherwise we won't get any offered portlets!
- String handle = getHandleForPortletDeployedIn(basicContentPortletArchive);
-
- GetMarkup getMarkup = createMarkupRequest(handle);
+ GetMarkup getMarkup = createMarkupRequest(getLocalesPortletArchive);
getMarkup.getMarkupParams().setLocales(new String[]{"en_US"});
MarkupResponse response = null;
@@ -392,18 +407,16 @@
}
// checkMarkupResponse(response, "GetLocalesPortlet"); // should we return try to generate markup regardless?
- undeploy(basicContentPortletArchive);
+ undeploy(getLocalesPortletArchive);
}
public void testGetMarkupWithEncodedURLs() throws Exception
{
- undeploy("test-markup-portlet.war");
+ undeploy(DEFAULT_MARKUP_PORTLET_WAR);
String encodeURLPortletArchive = "test-encodeurl-portlet.war";
deploy(encodeURLPortletArchive);
- String handle = getHandleForPortletDeployedIn(encodeURLPortletArchive);
-
- GetMarkup getMarkup = createMarkupRequest(handle);
+ GetMarkup getMarkup = createMarkupRequest(encodeURLPortletArchive);
MarkupResponse response = markupService.getMarkup(getMarkup);
checkMarkupResponse(response, "wsrp_rewrite?wsrp-urlType=blockingAction&wsrp-interactionState=JBPNS_/wsrp_rewrite\n" +
@@ -412,7 +425,7 @@
undeploy(encodeURLPortletArchive);
}
- private void checkMarkupResponse(MarkupResponse response, String markupString)
+ private MarkupContext checkMarkupResponse(MarkupResponse response, String markupString)
{
assertNotNull(response);
@@ -423,21 +436,19 @@
assertEquals("title", markupContext.getPreferredTitle());
assertTrue(markupContext.getRequiresUrlRewriting().booleanValue());
assertEquals(markupString, markupContext.getMarkupString());
+
+ return markupContext;
}
/**
* Creates a valid Markup request.
*
- * @param handle
+ * @param archiveName
* @return a basic, valid GetMarkup object representing the markup request
*/
- private GetMarkup createMarkupRequest(String handle) throws Exception
- {
- if (handle == null)
+ private GetMarkup createMarkupRequest(String archiveName) throws Exception
{
- handle = getDefaultHandle();
- }
- GetMarkup getMarkup = WSRPTypeFactory.createDefaultMarkupRequest(handle);
+ GetMarkup getMarkup = WSRPTypeFactory.createDefaultMarkupRequest(getHandleForPortletDeployedIn(archiveName));
getMarkup.getMarkupParams().setMarkupCharacterSets(new String[]{WSRPConstants.DEFAULT_CHARACTER_SET});
return getMarkup;
1.5 +8 -2 jboss-portal/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/NeedPortletHandleTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: NeedPortletHandleTest.java
===================================================================
RCS file: /cvsroot/jboss/jboss-portal/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/NeedPortletHandleTest.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- NeedPortletHandleTest.java 3 Jul 2006 14:27:39 -0000 1.4
+++ NeedPortletHandleTest.java 2 Aug 2006 23:48:23 -0000 1.5
@@ -36,7 +36,7 @@
/**
* @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
- * @version $Revision: 1.4 $
+ * @version $Revision: 1.5 $
* @since 2.4
*/
public abstract class NeedPortletHandleTest extends V1ProducerBaseTest
@@ -61,12 +61,18 @@
protected String getHandleForPortletDeployedIn(String archiveName)
throws org.jboss.portal.wsrp.core.OperationFailedFault, org.jboss.portal.wsrp.core.InvalidRegistrationFault, java.rmi.RemoteException
{
+// printMappings("getHandleForPortletDeployedIn");
+ if (archiveName == null)
+ {
+ archiveName = portletWARFileName;
+ }
+
return (String)warFileName2handle.get(archiveName);
}
protected String getDefaultHandle() throws RemoteException, InvalidRegistrationFault, OperationFailedFault
{
- return getHandleForPortletDeployedIn(portletWARFileName);
+ return getHandleForPortletDeployedIn(null);
}
/**
More information about the jboss-cvs-commits
mailing list