taylor 2004/04/06 17:49:08
Modified: portal/src/test/org/apache/jetspeed/containers
test-navstate-container.groovy
portal/src/test/org/apache/jetspeed/container/session
TestNavigationalState.java
Log:
switched over to sessions-based NavState and URL management
filling in some more unit tests as we go
PR:
Obtained from:
Submitted by:
Reviewed by:
CVS: ----------------------------------------------------------------------
CVS: PR:
CVS: If this change addresses a PR in the problem report tracking
CVS: database, then enter the PR number(s) here.
CVS: Obtained from:
CVS: If this change has been taken from another system, such as NCSA,
CVS: then name the system in this line, otherwise delete it.
CVS: Submitted by:
CVS: If this code has been contributed to Apache by someone else; i.e.,
CVS: they sent us a patch or a new module, then include their name/email
CVS: address here. If this is your work then delete this line.
CVS: Reviewed by:
CVS: If we are doing pre-commit code reviews and someone else has
CVS: reviewed your changes, include their name(s) here.
CVS: If you have not had it reviewed then delete this line.
Revision Changes Path
1.5 +16 -5
jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/containers/test-navstate-container.groovy
Index: test-navstate-container.groovy
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/containers/test-navstate-container.groovy,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- test-navstate-container.groovy 6 Apr 2004 19:57:19 -0000 1.4
+++ test-navstate-container.groovy 7 Apr 2004 00:49:08 -0000 1.5
@@ -35,14 +35,19 @@
//
-// Navigational State component
+// Navigational State component: Pluto Path
//
// navigationKeys: prefix, action, mode, state, renderparam, pid, prev_mode,
prev_state, key_delim
-// navigationKeys = "_,ac,md,st,rp,pid,pm,ps,:"
-navigationKeys = "_,a,m,s,r,i,pm,ps,:"
+navigationKeys = "_,ac,md,st,rp,pid,pm,ps,:"
+navStateClass = "org.apache.jetspeed.container.session.impl.PathNavigationalState"
+urlClass = "org.apache.jetspeed.container.url.impl.PathPortalURL"
+container.registerComponentImplementation("PathNavs",
JetspeedNavigationalStateComponent,
+ new Parameter[] {new ConstantParameter(navStateClass),
+ new ConstantParameter(urlClass),
+ new ConstantParameter(navigationKeys)} )
+
-// navStateClass =
"org.apache.jetspeed.container.session.impl.PathNavigationalState"
-// urlClass = "org.apache.jetspeed.container.url.impl.PathPortalURL"
+navigationKeys = "_,a,m,s,r,i,pm,ps,:"
navStateClass =
"org.apache.jetspeed.container.session.impl.SessionNavigationalState"
urlClass = "org.apache.jetspeed.container.url.impl.SessionPortalURL"
container.registerComponentImplementation(NavigationalStateComponent,
JetspeedNavigationalStateComponent,
@@ -57,6 +62,12 @@
container.registerComponentImplementation(RequestContextComponent,
JetspeedRequestContextComponent,
new Parameter[] {new ComponentParameter(NavigationalStateComponent),
new ConstantParameter(requestContextClass)} )
+
+requestContextClass = "org.apache.jetspeed.request.JetspeedRequestContext"
+container.registerComponentImplementation("PlutoRC",
JetspeedRequestContextComponent,
+ new Parameter[] {new ComponentParameter("PathNavs"),
+ new ConstantParameter(requestContextClass)} )
+
return container
1.6 +70 -68
jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/container/session/TestNavigationalState.java
Index: TestNavigationalState.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/container/session/TestNavigationalState.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- TestNavigationalState.java 6 Apr 2004 19:48:21 -0000 1.5
+++ TestNavigationalState.java 7 Apr 2004 00:49:08 -0000 1.6
@@ -28,6 +28,7 @@
import org.apache.jetspeed.components.AbstractComponentAwareTestCase;
import org.apache.jetspeed.components.ComponentAwareTestSuite;
+import org.apache.jetspeed.container.url.PortalURL;
import org.apache.jetspeed.om.window.impl.PortletWindowImpl;
import org.apache.jetspeed.request.RequestContext;
import org.apache.jetspeed.request.RequestContextComponent;
@@ -51,8 +52,10 @@
public class TestNavigationalState extends AbstractComponentAwareTestCase
{
private MutablePicoContainer container;
- private NavigationalStateComponent navState;
- private RequestContextComponent rcc;
+ private NavigationalStateComponent navSession;
+ private NavigationalStateComponent navPluto;
+ private RequestContextComponent rcSession;
+ private RequestContextComponent rcPluto;
/**
* Defines the testcase name for JUnit.
@@ -79,8 +82,12 @@
super.setUp();
container = (MutablePicoContainer) getContainer();
assertNotNull("container is null", container);
- navState = (NavigationalStateComponent)
container.getComponentInstance(NavigationalStateComponent.class);
- rcc = (RequestContextComponent)
container.getComponentInstance(RequestContextComponent.class);
+ navSession = (NavigationalStateComponent)
container.getComponentInstance(NavigationalStateComponent.class);
+ navPluto = (NavigationalStateComponent)
container.getComponentInstance("PathNavs");
+
+ rcSession = (RequestContextComponent)
container.getComponentInstance(RequestContextComponent.class);
+ rcPluto = (RequestContextComponent)
container.getComponentInstance("PlutoRC");
+
}
/**
@@ -96,100 +103,95 @@
return suite;
}
- public void xtestModeAndState()
+ public void testAllComponents()
+ throws Exception
{
System.out.println("Starting Navs Mode and State test");
- assertNotNull("nav state component is null", navState);
- assertNotNull("request context component is null", rcc);
-
- MockHttpServletRequest request = new MockHttpServletRequest();
- MockHttpSession session = new MockHttpSession();
- HttpServletResponse response = new MockHttpServletResponse();
- ServletConfig config = new MockServletConfig();
- request.setSession(session);
- request.setPathInfo("/stuff/");
- RequestContext context = rcc.create(
- (HttpServletRequest)request,
- response,
- config);
-
- PortletWindow window = new PortletWindowImpl("33");
- PortletWindow window2 = new PortletWindowImpl("222");
+ assertNotNull("nav state component is null", navPluto);
+ assertNotNull("pluto nav state component is null", navPluto);
+ assertNotNull("request context component is null", rcSession);
+ assertNotNull("pathrequest context component is null", rcPluto);
+
+ // general navigational state test
+ navigationTest(navSession, rcSession);
+ navigationTest(navPluto, rcPluto);
+
+ // URL tests
+ String result = urlTest(navPluto, rcPluto);
+ assertEquals("Session URL not equal",
"http://www.sporteportal.com/jetspeed/portal/_st_33/minimized/_ac_33/AC/_rp_33_test/1_one/_md_33/edit",
result);
+ result = urlTest(navSession, rcSession);
+ assertEquals("Session URL not equal",
"http://www.sporteportal.com/jetspeed/portal/_a_33/A/_s_33/minimized/_m_33/edit/_r_33_test/1_one",
result);
- NavigationalState nav = navState.create(context);
- nav.setState(window, WindowState.MAXIMIZED);
- nav.setMode(window, PortletMode.HELP);
-
- // Check that they come out correctly
- assertTrue("window mode is not set",
nav.getMode(window).equals(PortletMode.HELP));
- assertTrue("window state is not set",
nav.getState(window).equals(WindowState.MAXIMIZED));
- assertTrue("window mode is not set",
nav.getMode(window2).equals(PortletMode.VIEW));
System.out.println("Ending Navs Mode and State test");
}
- public void testNavParams()
- {
- System.out.println("Starting Nav Params test");
- MockServletConfig config = new MockServletConfig();
- //config.
-
- /*
- assertNotNull("nav state component is null", navState);
- assertNotNull("request context component is null", rcc);
-
+ private void navigationTest(NavigationalStateComponent component,
RequestContextComponent rc)
+ throws Exception
+ {
MockHttpServletRequest request = new MockHttpServletRequest();
MockHttpSession session = new MockHttpSession();
HttpServletResponse response = new MockHttpServletResponse();
ServletConfig config = new MockServletConfig();
request.setSession(session);
- RequestContext context = rcc.create(
- (HttpServletRequest)request,
- response,
- config);
- request.setPathInfo(buildPath(context, window)));
+ request.setPathInfo("/stuff/");
+ RequestContext context = rc.create(
+ (HttpServletRequest)request,
+ response,
+ config);
- PortletWindow window = new PortletWindowImpl("33");
+ PortletWindow window = new PortletWindowImpl("111");
PortletWindow window2 = new PortletWindowImpl("222");
+ PortletWindow window3 = new PortletWindowImpl("333");
- NavigationalState nav = navState.create(context);
+ NavigationalState nav = component.create(context);
nav.setState(window, WindowState.MAXIMIZED);
nav.setMode(window, PortletMode.HELP);
+ nav.setMode(window2, PortletMode.EDIT);
+ // TODO: test prev mode, prev state
+
// Check that they come out correctly
assertTrue("window mode is not set",
nav.getMode(window).equals(PortletMode.HELP));
assertTrue("window state is not set",
nav.getState(window).equals(WindowState.MAXIMIZED));
- assertTrue("window mode is not set",
nav.getMode(window2).equals(PortletMode.VIEW));
- */
+ assertTrue("window mode is not set",
nav.getMode(window2).equals(PortletMode.EDIT));
+ assertTrue("window mode is not set",
nav.getMode(window3).equals(PortletMode.VIEW));
- System.out.println("Ending nav state test");
- //String result = buildPath(config);
- //System.out.println("result = " + result);
}
-
- private String buildPath(ServletConfig config)
- {
- Map params = new HashMap();
- params.put("parm-1", "value-1");
- params.put("parm-2", "value-2");
+ public String urlTest(NavigationalStateComponent component,
RequestContextComponent rc)
+ throws Exception
+ {
+ String [] values =
+ {
+ "one"
+ };
+
+ MockServletConfig config = new MockServletConfig();
MockHttpServletRequest request = new MockHttpServletRequest();
HttpServletResponse response = new MockHttpServletResponse();
request.setServerName("www.sporteportal.com");
request.setScheme("http");
- RequestContext context = rcc.create(
+ request.setContextPath("/jetspeed");
+ request.setServletPath("/portal");
+
+ RequestContext context = rc.create(
(HttpServletRequest)request,
response,
config);
- NavigationalState nav = navState.create(context);
- assertNotNull("nav is null", nav);
+ PortalURL url = component.createURL(context);
+ assertNotNull("URL is null", url);
PortletWindow window = new PortletWindowImpl("33");
-
- PortletURLProvider provider = new PortletURLProviderImpl(context, nav,
window);
- provider.setAction();
- provider.setPortletMode(PortletMode.EDIT);
- provider.setWindowState(WindowState.MINIMIZED);
- provider.setParameters(params);
- return provider.toString();
+ url.setAction(window);
+ url.setMode(window, PortletMode.EDIT);
+ url.setState(window, WindowState.MINIMIZED);
+ url.setRenderParam(window, "test", values);
+
+ // CANT TEST WITHOUT SETTING UP DATABASE
+ // PortletWindow target = url.getPortletWindowOfAction();
+ //assertNotNull("target window is null", target);
+ //assertEquals("target window should equal window 33", target.getId(),
"33");
+ System.out.println("URL = " + url.toString());
+ return url.toString();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]