Author: julien_viet
Date: 2010-11-30 08:24:31 -0500 (Tue, 30 Nov 2010)
New Revision: 5386
Added:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/ParamDescriptor.java
Modified:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/DescriptorBuilder.java
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/PathParamDescriptor.java
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RequestParamDescriptor.java
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteDescriptor.java
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteParamDescriptor.java
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouterDescriptor.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestBuildRoute.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestHierarchy.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestLegacyPortal.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestMatch.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPathParamEncoding.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortal.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortalConfiguration.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRender.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRequestParam.java
Log:
a bit more DSLized
Modified:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/DescriptorBuilder.java
===================================================================
---
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/DescriptorBuilder.java 2010-11-30
11:01:50 UTC (rev 5385)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/DescriptorBuilder.java 2010-11-30
13:24:31 UTC (rev 5386)
@@ -119,7 +119,7 @@
{
String qualifiedName = reader.getAttributeValue(null, "qname");
String value = reader.getAttributeValue(null, "value");
- routeDesc.add(new RouteParamDescriptor(qualifiedName).withValue(value));
+ routeDesc.with(new RouteParamDescriptor(qualifiedName).withValue(value));
}
else if (requestParamQN.equals(reader.getName()))
{
@@ -127,7 +127,7 @@
String name = reader.getAttributeValue(null, "name");
String value = reader.getAttributeValue(null, "value");
String optional = reader.getAttributeValue(null, "required");
- routeDesc.add(new
RequestParamDescriptor(qualifiedName).withName(name).withValue(value).required("true".equals(optional)));
+ routeDesc.with(new
RequestParamDescriptor(qualifiedName).named(name).withValue(value).required("true".equals(optional)));
}
else if (pathParamQN.equals(reader.getName()))
{
@@ -135,7 +135,7 @@
String pattern = reader.getAttributeValue(null, "pattern");
String encoded = reader.getAttributeValue(null, "encoding");
EncodingMode encodingMode = "preserve-path".equals(encoded) ?
EncodingMode.PRESERVE_PATH : EncodingMode.FORM;
- routeDesc.add(new
PathParamDescriptor(qualifiedName).withPattern(pattern).withEncodingMode(encodingMode));
+ routeDesc.with(new
PathParamDescriptor(qualifiedName).withPattern(pattern).withEncodingMode(encodingMode));
}
else if (routeQN.equals(reader.getName()))
{
Added:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/ParamDescriptor.java
===================================================================
---
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/ParamDescriptor.java
(rev 0)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/ParamDescriptor.java 2010-11-30
13:24:31 UTC (rev 5386)
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.metadata;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+public class ParamDescriptor
+{
+}
Modified:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/PathParamDescriptor.java
===================================================================
---
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/PathParamDescriptor.java 2010-11-30
11:01:50 UTC (rev 5385)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/PathParamDescriptor.java 2010-11-30
13:24:31 UTC (rev 5386)
@@ -26,7 +26,7 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public class PathParamDescriptor
+public class PathParamDescriptor extends ParamDescriptor
{
/** . */
Modified:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RequestParamDescriptor.java
===================================================================
---
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RequestParamDescriptor.java 2010-11-30
11:01:50 UTC (rev 5385)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RequestParamDescriptor.java 2010-11-30
13:24:31 UTC (rev 5386)
@@ -25,7 +25,7 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public class RequestParamDescriptor
+public class RequestParamDescriptor extends ParamDescriptor
{
/** . */
@@ -64,7 +64,7 @@
this.qualifiedName = QualifiedName.parse(qualifiedName);
}
- public RequestParamDescriptor withName(String name)
+ public RequestParamDescriptor named(String name)
{
this.name = name;
return this;
Modified:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteDescriptor.java
===================================================================
---
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteDescriptor.java 2010-11-30
11:01:50 UTC (rev 5385)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteDescriptor.java 2010-11-30
13:24:31 UTC (rev 5386)
@@ -20,7 +20,6 @@
package org.exoplatform.web.controller.metadata;
import org.exoplatform.web.controller.QualifiedName;
-import org.exoplatform.web.controller.router.EncodingMode;
import java.util.ArrayList;
import java.util.Collection;
@@ -88,24 +87,37 @@
return routeParams.get(name);
}
- public RouteDescriptor add(RouteParamDescriptor routeParam)
+ public RouteDescriptor with(ParamDescriptor... params)
{
- routeParams.put(routeParam.getQualifiedName(), routeParam);
+ if (params == null)
+ {
+ throw new NullPointerException();
+ }
+ for (ParamDescriptor param : params)
+ {
+ if (param == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (param instanceof RouteParamDescriptor)
+ {
+ RouteParamDescriptor routeParam = (RouteParamDescriptor)param;
+ routeParams.put(routeParam.getQualifiedName(), routeParam);
+ }
+ else if (param instanceof RequestParamDescriptor)
+ {
+ RequestParamDescriptor requestParam = (RequestParamDescriptor)param;
+ requestParams.put(requestParam.getName(), requestParam);
+ }
+ if (param instanceof PathParamDescriptor)
+ {
+ PathParamDescriptor pathParam = (PathParamDescriptor)param;
+ pathParams.put(pathParam.getQualifiedName(), pathParam);
+ }
+ }
return this;
}
- public RouteDescriptor add(RequestParamDescriptor requestParam)
- {
- requestParams.put(requestParam.getName(), requestParam);
- return this;
- }
-
- public RouteDescriptor add(PathParamDescriptor pathParam)
- {
- pathParams.put(pathParam.getQualifiedName(), pathParam);
- return this;
- }
-
public Collection<RequestParamDescriptor> getRequestParams()
{
return requestParams.values();
@@ -126,7 +138,7 @@
return pathParams;
}
- public RouteDescriptor add(RouteDescriptor child)
+ public RouteDescriptor sub(RouteDescriptor child)
{
children.add(child);
return this;
Modified:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteParamDescriptor.java
===================================================================
---
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteParamDescriptor.java 2010-11-30
11:01:50 UTC (rev 5385)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouteParamDescriptor.java 2010-11-30
13:24:31 UTC (rev 5386)
@@ -25,7 +25,7 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public class RouteParamDescriptor
+public class RouteParamDescriptor extends ParamDescriptor
{
/** . */
Modified:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouterDescriptor.java
===================================================================
---
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouterDescriptor.java 2010-11-30
11:01:50 UTC (rev 5385)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/metadata/RouterDescriptor.java 2010-11-30
13:24:31 UTC (rev 5386)
@@ -41,16 +41,25 @@
this.routes = new ArrayList<RouteDescriptor>();
}
- public RouterDescriptor add(RouteDescriptor route)
+ public RouterDescriptor add(RouteDescriptor... routes)
{
- if (route == null)
+ if (routes == null)
{
throw new NullPointerException();
}
//
- routes.add(route);
+ for (RouteDescriptor route : routes)
+ {
+ if (route == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ //
+ this.routes.add(route);
+ }
+
//
return this;
}
Modified:
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestBuildRoute.java
===================================================================
---
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestBuildRoute.java 2010-11-30
11:01:50 UTC (rev 5385)
+++
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestBuildRoute.java 2010-11-30
13:24:31 UTC (rev 5386)
@@ -35,7 +35,7 @@
String[] paths = {"/",""};
for (String path : paths)
{
- Router router = new Router(router().add(route(path)));
+ Router router = router().add(route(path)).build();
Route expectedRoute = new Route();
assertEquals(expectedRoute, router.root);
}
@@ -46,7 +46,7 @@
String[] paths = {"/a","a"};
for (String path : paths)
{
- Router router = new Router(router().add(route(path)));
+ Router router = router().add(route(path)).build();
Route expectedRoute = new Route();
expectedRoute.add(new SegmentRoute("a"));
assertEquals(expectedRoute, router.root);
@@ -58,7 +58,7 @@
String[] paths = {"/{a}","{a}"};
for (String path : paths)
{
- Router router = new Router(router().add(route(path)));
+ Router router = router().add(route(path)).build();
//
assertEquals(0, router.root.getSegmentNames().size());
@@ -80,7 +80,7 @@
String[] paths = {"/{q:a}","{q:a}"};
for (String path : paths)
{
- Router router = new Router(router().add(route(path)));
+ Router router = router().add(route(path)).build();
//
assertEquals(0, router.root.getSegmentNames().size());
@@ -102,7 +102,7 @@
String[] paths = {"/{a}","{a}"};
for (String path : paths)
{
- Router router = new
Router(router().add(route(path).add(pathParam("a").withPattern(".*"))));
+ Router router =
router().add(route(path).with(pathParam("a").withPattern(".*"))).build();
//
assertEquals(0, router.root.getSegmentNames().size());
Modified:
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestHierarchy.java
===================================================================
---
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestHierarchy.java 2010-11-30
11:01:50 UTC (rev 5385)
+++
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestHierarchy.java 2010-11-30
13:24:31 UTC (rev 5386)
@@ -36,8 +36,8 @@
public void testFoo() throws Exception
{
Router router = router().
-
add(route("/a").add(routeParam("foo").withValue("bar")).
-
add(route("/b").add(routeParam("juu").withValue("daa")))).
+
add(route("/a").with(routeParam("foo").withValue("bar")).
+
sub(route("/b").with(routeParam("juu").withValue("daa")))).
build();
//
Modified:
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestLegacyPortal.java
===================================================================
---
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestLegacyPortal.java 2010-11-30
11:01:50 UTC (rev 5385)
+++
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestLegacyPortal.java 2010-11-30
13:24:31 UTC (rev 5386)
@@ -42,16 +42,19 @@
{
this.router = router().
add(route("/").
- add(routeParam("gtn:handler").withValue("portal")).
-
add(requestParam("gtn:componentid").withName("portal:componentId")).
-
add(requestParam("gtn:action").withName("portal:action")).
-
add(requestParam("gtn:objectid").withName("portal:objectId")).
- add(route("/public/{gtn:sitename}{gtn:path}").
- add(routeParam("gtn:access").withValue("public")).
-
add(pathParam("gtn:path").withPattern(".*").preservingPath())).
- add(route("/private/{gtn:sitename}{gtn:path}").
- add(routeParam("gtn:access").withValue("private")).
-
add(pathParam("gtn:path").withPattern(".*").preservingPath()))).
+ with(
+ routeParam("gtn:handler").withValue("portal"),
+
requestParam("gtn:componentid").named("portal:componentId"),
+ requestParam("gtn:action").named("portal:action"),
+
requestParam("gtn:objectid").named("portal:objectId")).
+ sub(route("/public/{gtn:sitename}{gtn:path}").
+ with(
+ routeParam("gtn:access").withValue("public"),
+
pathParam("gtn:path").withPattern(".*").preservingPath())).
+ sub(route("/private/{gtn:sitename}{gtn:path}").
+ with(
+ routeParam("gtn:access").withValue("private"),
+
pathParam("gtn:path").withPattern(".*").preservingPath()))).
build();
}
Modified:
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestMatch.java
===================================================================
---
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestMatch.java 2010-11-30
11:01:50 UTC (rev 5385)
+++
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestMatch.java 2010-11-30
13:24:31 UTC (rev 5386)
@@ -87,7 +87,7 @@
public void testParameterPropagationToDescendants() throws Exception
{
Router router = router().
-
add(route("/").add(routeParam("p").withValue("a"))).
+
add(route("/").with(routeParam("p").withValue("a"))).
add(route("/a")).build();
//
@@ -96,7 +96,7 @@
public void testSimplePattern() throws Exception
{
- Router router =
router().add(route("/{p}").add(pathParam("p").withPattern("a"))).build();
+ Router router =
router().add(route("/{p}").with(pathParam("p").withPattern("a"))).build();
//
assertEquals(Collections.singletonMap(QualifiedName.create("p"),
"a"), router.route("/a"));
@@ -109,7 +109,7 @@
{
Router router = router().
add(route("/a")).
-
add(route("/{p}/b").add(pathParam("p").withPattern("a"))).
+
add(route("/{p}/b").with(pathParam("p").withPattern("a"))).
build();
//
@@ -122,7 +122,7 @@
public void testTwoRules1() throws Exception
{
Router router = router().
-
add(route("/a").add(routeParam("b").withValue("b"))).
+
add(route("/a").with(routeParam("b").withValue("b"))).
add(route("/a/b")).
build();
@@ -134,7 +134,7 @@
public void testTwoRules2() throws Exception
{
Router router = router().
-
add(route("/{a}").add(routeParam("b").withValue("b"))).
+
add(route("/{a}").with(routeParam("b").withValue("b"))).
add(route("/{a}/b")).
build();
@@ -149,7 +149,7 @@
public void testLang() throws Exception
{
Router router = router().
-
add(route("/{a}b").add(pathParam("a").withPattern("(([A-Za-z]{2})/)?").preservingPath())).
+
add(route("/{a}b").with(pathParam("a").withPattern("(([A-Za-z]{2})/)?").preservingPath())).
build();
//
Modified:
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPathParamEncoding.java
===================================================================
---
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPathParamEncoding.java 2010-11-30
11:01:50 UTC (rev 5385)
+++
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPathParamEncoding.java 2010-11-30
13:24:31 UTC (rev 5386)
@@ -33,7 +33,7 @@
public void testDefaultForm() throws Exception
{
- Router router =
router().add(route("/{p}").add(pathParam("p").withPattern(".+"))).build();
+ Router router =
router().add(route("/{p}").with(pathParam("p").withPattern(".+"))).build();
// Route
assertEquals(Collections.singletonMap(QualifiedName.create("p"),
"/"), router.route("/_"));
@@ -44,7 +44,7 @@
public void testPreservePath() throws Exception
{
- Router router =
router().add(route("/{p}").add(pathParam("p").withPattern("[^/]+").preservingPath())).build();
+ Router router =
router().add(route("/{p}").with(pathParam("p").withPattern("[^/]+").preservingPath())).build();
// Route
assertEquals(Collections.singletonMap(QualifiedName.create("p"),
"_"), router.route("/_"));
@@ -58,7 +58,7 @@
{
Router router = router().
add(route("/{p}").
- add(pathParam("p").withPattern("/[a-z]+/[a-z]+/?"))).
+ with(pathParam("p").withPattern("/[a-z]+/[a-z]+/?"))).
build();
// Route
@@ -75,7 +75,7 @@
public void testWildcardPathParamWithPreservePath() throws Exception
{
- Router router =
router().add(route("/{p}").add(pathParam("p").withPattern(".*").preservingPath())).build();
+ Router router =
router().add(route("/{p}").with(pathParam("p").withPattern(".*").preservingPath())).build();
// Render
assertEquals("/",
router.render(Collections.singletonMap(QualifiedName.create("p"),
"")));
@@ -92,7 +92,7 @@
public void testWildcardParamPathWithDefaultForm() throws Exception
{
- Router router =
router().add(route("/{p}").add(pathParam("p").withPattern(".*"))).build();
+ Router router =
router().add(route("/{p}").with(pathParam("p").withPattern(".*"))).build();
//
assertEquals("/_",
router.render(Collections.singletonMap(QualifiedName.create("p"),
"/")));
Modified:
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortal.java
===================================================================
---
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortal.java 2010-11-30
11:01:50 UTC (rev 5385)
+++
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortal.java 2010-11-30
13:24:31 UTC (rev 5386)
@@ -22,8 +22,6 @@
import org.exoplatform.web.controller.QualifiedName;
import static org.exoplatform.web.controller.metadata.DescriptorBuilder.*;
-import org.exoplatform.web.controller.metadata.RouterDescriptor;
-
import java.util.Collections;
/**
@@ -35,34 +33,37 @@
public void testLanguage1() throws Exception
{
- RouterDescriptor routerMD = router().add(
- route("/public{gtn:lang}").add(
-
pathParam("gtn:lang").withPattern("(/[A-Za-z][A-Za-z])?").preservingPath())
- );
- Router router = new Router(routerMD);
+ Router router = router().add(
+ route("/public{gtn:lang}").
+
with(pathParam("gtn:lang").withPattern("(/[A-Za-z][A-Za-z])?").preservingPath())).
+ build();
+
+ //
assertEquals(Collections.singletonMap(QualifiedName.parse("gtn:lang"),
""), router.route("/public"));
assertEquals(Collections.singletonMap(QualifiedName.parse("gtn:lang"),
"/fr"), router.route("/public/fr"));
}
public void testLanguage2() throws Exception
{
- RouterDescriptor routerMD = router().add(
- route("/{gtn:lang}public").add(
-
pathParam("gtn:lang").withPattern("([A-Za-z]{2}/)?").preservingPath())
- );
- Router router = new Router(routerMD);
+ Router router = router().add(
+ route("/{gtn:lang}public").
+
with(pathParam("gtn:lang").withPattern("([A-Za-z]{2}/)?").preservingPath())).
+ build();
+
+ //
assertEquals(Collections.singletonMap(QualifiedName.parse("gtn:lang"),
""), router.route("/public"));
assertEquals(Collections.singletonMap(QualifiedName.parse("gtn:lang"),
"fr/"), router.route("/fr/public"));
}
public void testLanguage3() throws Exception
{
- RouterDescriptor routerMD = router().
+ Router router = router().
add(route("/public")).
add(route("/{gtn:lang}/public").
- add(pathParam("gtn:lang").withPattern("([A-Za-z]{2})"))
- );
- Router router = new Router(routerMD);
+
with(pathParam("gtn:lang").withPattern("([A-Za-z]{2})"))).
+ build();
+
+ //
assertEquals(Collections.<QualifiedName, String>emptyMap(),
router.route("/public"));
assertEquals(Collections.singletonMap(QualifiedName.parse("gtn:lang"),
"fr"), router.route("/fr/public"));
}
Modified:
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortalConfiguration.java
===================================================================
---
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortalConfiguration.java 2010-11-30
11:01:50 UTC (rev 5385)
+++
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortalConfiguration.java 2010-11-30
13:24:31 UTC (rev 5386)
@@ -40,20 +40,25 @@
protected void setUp() throws Exception
{
this.router = router().
- add(route("/private/{gtn:sitetype}/{gtn:sitename}{gtn:path}").
- add(routeParam("gtn:controller").withValue("site")).
- add(routeParam("gtn:controller").withValue("site")).
-
add(requestParam("gtn:componentid").withName("portal:componentId")).
-
add(pathParam("gtn:path").withPattern(".*").preservingPath())).
- add(route("/private/{gtn:sitetype}/{gtn:sitename}{gtn:path}").
- add(routeParam("gtn:controller").withValue("site")).
-
add(pathParam("gtn:path").withPattern(".*").preservingPath())).
- add(route("/groups/{gtn:sitetype}/{gtn:sitename}{gtn:path}").
- add(routeParam("gtn:controller").withValue("site")).
-
add(pathParam("gtn:path").withPattern(".*").preservingPath())).
- add(route("/users/{gtn:sitetype}/{gtn:sitename}{gtn:path}").
- add(routeParam("gtn:controller").withValue("site")).
-
add(pathParam("gtn:path").withPattern(".*").preservingPath())).
+ add(
+ route("/private/{gtn:sitetype}/{gtn:sitename}{gtn:path}").
+ with(
+ routeParam("gtn:controller").withValue("site"),
+ routeParam("gtn:controller").withValue("site"),
+
requestParam("gtn:componentid").named("portal:componentId"),
+
pathParam("gtn:path").withPattern(".*").preservingPath()),
+ route("/private/{gtn:sitetype}/{gtn:sitename}{gtn:path}").
+ with(
+ routeParam("gtn:controller").withValue("site"),
+
pathParam("gtn:path").withPattern(".*").preservingPath()),
+ route("/groups/{gtn:sitetype}/{gtn:sitename}{gtn:path}").
+ with(
+ routeParam("gtn:controller").withValue("site"),
+
pathParam("gtn:path").withPattern(".*").preservingPath()),
+ route("/users/{gtn:sitetype}/{gtn:sitename}{gtn:path}").
+ with(
+ routeParam("gtn:controller").withValue("site"),
+
pathParam("gtn:path").withPattern(".*").preservingPath())).
build();
}
Modified:
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRender.java
===================================================================
---
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRender.java 2010-11-30
11:01:50 UTC (rev 5385)
+++
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRender.java 2010-11-30
13:24:31 UTC (rev 5386)
@@ -66,7 +66,7 @@
public void testSimplePatternPathParam() throws Exception
{
- Router router =
router().add(route("/{p}").add(pathParam("p").withPattern("a"))).build();
+ Router router =
router().add(route("/{p}").with(pathParam("p").withPattern("a"))).build();
//
assertEquals("/a",
router.render(Collections.singletonMap(QualifiedName.create("p"),
"a")));
@@ -78,7 +78,7 @@
Router router = router().
add(route("/a")).
add(route("/{p}/b").
- add(pathParam("p").withPattern("a"))).
+ with(pathParam("p").withPattern("a"))).
build();
//
@@ -92,7 +92,7 @@
{
Router router = router().
add(route("/{a}b").
-
add(pathParam("a").withPattern("(([A-Za-z]{2})/)?").preservingPath())).
+
with(pathParam("a").withPattern("(([A-Za-z]{2})/)?").preservingPath())).
build();
//
Modified:
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRequestParam.java
===================================================================
---
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRequestParam.java 2010-11-30
11:01:50 UTC (rev 5385)
+++
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestRequestParam.java 2010-11-30
13:24:31 UTC (rev 5386)
@@ -35,7 +35,7 @@
public void testRoot() throws Exception
{
- Router router =
router().add(route("/").add(requestParam("foo").withName("a").withValue("a").required())).build();
+ Router router =
router().add(route("/").with(requestParam("foo").named("a").withValue("a").required())).build();
//
assertNull(router.route("/"));
@@ -51,7 +51,7 @@
public void testSegment() throws Exception
{
- Router router =
router().add(route("/a").add(requestParam("foo").withName("a").withValue("a").required())).build();
+ Router router =
router().add(route("/a").with(requestParam("foo").named("a").withValue("a").required())).build();
//
assertNull(router.route("/a"));
@@ -67,7 +67,7 @@
public void testValuePattern() throws Exception
{
- Router router =
router().add(route("/a").add(requestParam("foo").withName("a").withValue("{[0-9]+}").required())).build();
+ Router router =
router().add(route("/a").with(requestParam("foo").named("a").withValue("{[0-9]+}").required())).build();
//
assertNull(router.route("/a"));
@@ -86,8 +86,8 @@
public void testPrecedence() throws Exception
{
Router router = router().
-
add(route("/a").add(requestParam("foo").withName("a").withValue("a").required())).
-
add(route("/a").add(requestParam("bar").withName("b").withValue("b").required())).
+
add(route("/a").with(requestParam("foo").named("a").withValue("a").required())).
+
add(route("/a").with(requestParam("bar").named("b").withValue("b").required())).
build();
//
@@ -109,10 +109,9 @@
public void testInheritance() throws Exception
{
- Router router = router().add(route("/a").
-
add(requestParam("foo").withName("a").withValue("a").required()).
- add(route("/b").
-
add(requestParam("bar").withName("b").withValue("b").required()))).
+ Router router = router().
+
add(route("/a").with(requestParam("foo").named("a").withValue("a").required()).
+
sub(route("/b").with(requestParam("bar").named("b").withValue("b").required()))).
build();
//
@@ -145,7 +144,7 @@
public void testOptional() throws Exception
{
Router router = router().add(route("/").
-
add(requestParam("foo").withName("a").withValue("a"))).build();
+
with(requestParam("foo").named("a").withValue("a"))).build();
//
assertEquals(Collections.<QualifiedName, String>emptyMap(),
router.route("/", Collections.<String, String[]>emptyMap()));
@@ -165,11 +164,9 @@
public void testMatchDescendantOfRootParameters() throws Exception
{
Router router = router().
- add(route("/").
-
add(requestParam("foo").withName("a").withValue("a")).
- add(route("/a").
-
add(requestParam("bar").withName("b").withValue("b")))
- ).build();
+
add(route("/").with(requestParam("foo").named("a").withValue("a")).
+
sub(route("/a").with(requestParam("bar").named("b").withValue("b")))).
+ build();
//
SimpleRenderContext renderContext = new SimpleRenderContext();