Author: ate
Date: Sun Jul 1 21:01:08 2012
New Revision: 1356028
URL: http://svn.apache.org/viewvc?rev=1356028&view=rev
Log:
RAVE-697: minimal skeleton of a page definition, just a basic runtime model to
get started
the hmvc processing will need to leverage custom HandlerMapping and
HandlerAdapter to intercept and map the dynamic page model
Added:
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcPageHandlerAdapter.java
(with props)
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcPageHandlerMapping.java
(with props)
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/PageDefinition.java
(with props)
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/PageFragment.java
(with props)
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/service/
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/service/APageService.java
(with props)
rave/sandbox/content-services/rave-web-hmvc/src/test/
rave/sandbox/content-services/rave-web-hmvc/src/test/java/
rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/
rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/
rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/
rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/portal/
rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/portal/web/
rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/portal/web/model/
rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/portal/web/model/PageDefinitionTest.java
(with props)
rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/portal/web/model/PageFragmentTest.java
(with props)
Modified:
rave/sandbox/content-services/rave-web-hmvc/pom.xml
Modified: rave/sandbox/content-services/rave-web-hmvc/pom.xml
URL:
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/pom.xml?rev=1356028&r1=1356027&r2=1356028&view=diff
==============================================================================
--- rave/sandbox/content-services/rave-web-hmvc/pom.xml (original)
+++ rave/sandbox/content-services/rave-web-hmvc/pom.xml Sun Jul 1 21:01:08 2012
@@ -46,6 +46,11 @@
<artifactId>spring-web</artifactId>
<version>${org.springframework.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-webmvc</artifactId>
+ <version>${org.springframework.version}</version>
+ </dependency>
<dependency>
<groupId>org.slf4j</groupId>
Added:
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcPageHandlerAdapter.java
URL:
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcPageHandlerAdapter.java?rev=1356028&view=auto
==============================================================================
---
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcPageHandlerAdapter.java
(added)
+++
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcPageHandlerAdapter.java
Sun Jul 1 21:01:08 2012
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.rave.portal.web.hmvc;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.web.method.HandlerMethod;
+import org.springframework.web.servlet.ModelAndView;
+import org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter;
+
+public class HmvcPageHandlerAdapter extends AbstractHandlerMethodAdapter {
+
+ /* (non-Javadoc)
+ * @see
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter#supportsInternal(org.springframework.web.method.HandlerMethod)
+ */
+ @Override
+ protected boolean supportsInternal(HandlerMethod handlerMethod) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter#handleInternal(javax.servlet.http.HttpServletRequest,
javax.servlet.http.HttpServletResponse,
org.springframework.web.method.HandlerMethod)
+ */
+ @Override
+ protected ModelAndView handleInternal(HttpServletRequest request,
HttpServletResponse response,
+ HandlerMethod handlerMethod) throws Exception {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter#getLastModifiedInternal(javax.servlet.http.HttpServletRequest,
org.springframework.web.method.HandlerMethod)
+ */
+ @Override
+ protected long getLastModifiedInternal(HttpServletRequest request,
HandlerMethod handlerMethod) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+}
Propchange:
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcPageHandlerAdapter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcPageHandlerAdapter.java
------------------------------------------------------------------------------
svn:keywords = Id
Added:
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcPageHandlerMapping.java
URL:
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcPageHandlerMapping.java?rev=1356028&view=auto
==============================================================================
---
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcPageHandlerMapping.java
(added)
+++
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcPageHandlerMapping.java
Sun Jul 1 21:01:08 2012
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.rave.portal.web.hmvc;
+
+import
org.springframework.web.servlet.mvc.support.AbstractControllerUrlHandlerMapping;
+
+public class HmvcPageHandlerMapping extends
AbstractControllerUrlHandlerMapping {
+
+ @Override
+ protected String[] buildUrlsForHandler(String beanName, Class beanClass) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Propchange:
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcPageHandlerMapping.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcPageHandlerMapping.java
------------------------------------------------------------------------------
svn:keywords = Id
Added:
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/PageDefinition.java
URL:
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/PageDefinition.java?rev=1356028&view=auto
==============================================================================
---
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/PageDefinition.java
(added)
+++
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/PageDefinition.java
Sun Jul 1 21:01:08 2012
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.rave.portal.web.model;
+
+public class PageDefinition extends PageFragment {
+
+ protected PageDefinition() {
+ super();
+ }
+
+ public PageDefinition(String id, String name) {
+ super(id, name);
+ }
+
+ @Override
+ public final PageFragment getParent() {
+ return null;
+ }
+
+ @Override
+ public final void setParent(PageFragment parent) {
+ throw new UnsupportedOperationException("A PageDefinition cannot have
a parent");
+ }
+}
Propchange:
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/PageDefinition.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/PageDefinition.java
------------------------------------------------------------------------------
svn:keywords = Id
Added:
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/PageFragment.java
URL:
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/PageFragment.java?rev=1356028&view=auto
==============================================================================
---
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/PageFragment.java
(added)
+++
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/PageFragment.java
Sun Jul 1 21:01:08 2012
@@ -0,0 +1,223 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.rave.portal.web.model;
+
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.rave.portal.model.User;
+import org.apache.rave.portal.model.Widget;
+
+public class PageFragment {
+
+ public static final char PATH_DELIMITER = '/';
+
+ public static enum TYPE {
+ TEMPLATE, COMPONENT, CONTAINER, WIDGET
+ };
+
+ public static enum STATE {
+ ENABLED, VISIBLE, DECORATED, MAXIMIZED, LOCKED
+ };
+
+ private PageFragment parent;
+ private PageFragment reference;
+ private String id;
+ private String name;
+ private String path;
+ private String displayName;
+ private String description;
+ private TYPE type = TYPE.TEMPLATE;
+ private Object controller;
+ private Widget widget;
+ private List<PageFragment> children;
+ private String src;
+ private User owner;
+ // TODO: private List<Acl> acls;
+ private Map<String, String> properties;
+ private String theme;
+ private EnumSet<STATE> state = EnumSet.range(STATE.ENABLED,
STATE.DECORATED);
+
+ protected PageFragment() {
+ }
+
+ public PageFragment(String id, String name) {
+ setId(id);
+ setName(name);
+ }
+
+ public PageFragment(PageFragment parent, String id, String name) {
+ setParent(parent);
+ setId(id);
+ setName(name);
+ if (parent != null) {
+ parent.getChildren().add(this);
+ }
+ }
+
+ public PageFragment getParent() {
+ return parent;
+ }
+
+ public void setParent(PageFragment parent) {
+ this.parent = parent;
+ }
+
+ public PageFragment getReference() {
+ return reference;
+ }
+
+ public void setReference(PageFragment reference) {
+ this.reference = reference;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ name = (name != null ? name.trim() : "");
+ if (name.length() == 0) {
+ throw new IllegalArgumentException("Null, empty or whitespace only
name value is not allowed");
+ }
+ if (name.indexOf(PATH_DELIMITER) != -1) {
+ throw new IllegalArgumentException("Name may not contain the path
delimiter character ('"+PATH_DELIMITER+"')");
+ }
+ if (getParent() != null) {
+ for (PageFragment child : getParent().getChildren()) {
+ if (child != this && child.getName().equals(name)) {
+ throw new IllegalArgumentException("Name already in use by
a sibling");
+ }
+ }
+ }
+ this.path = null;
+ this.name = name;
+ }
+
+ public String getPath() {
+ if (path == null) {
+ if (getParent() != null) {
+ path = getParent().getPath();
+ if (path.length() > 0) {
+ path += PATH_DELIMITER;
+ }
+ path += getName();
+ }
+ else {
+ path = "";
+ }
+ }
+ return path;
+ }
+
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public void setDisplayName(String displayName) {
+ this.displayName = displayName;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public TYPE getType() {
+ return getParent() != null ? getParent().getType() : type;
+ }
+
+ public void setType(TYPE type) {
+ this.type = type;
+ }
+
+ public Object getController() {
+ return controller;
+ }
+
+ public void setController(Object controller) {
+ this.controller = controller;
+ }
+
+ public Widget getWidget() {
+ return widget;
+ }
+
+ public void setWidget(Widget widget) {
+ this.widget = widget;
+ }
+
+ public List<PageFragment> getChildren() {
+ if (children == null) {
+ children = new ArrayList<PageFragment>();
+ }
+ return children;
+ }
+
+ public String getSrc() {
+ return src;
+ }
+
+ public void setSrc(String src) {
+ this.src = src;
+ }
+
+ public User getOwner() {
+ return owner;
+ }
+
+ public void setOwner(User owner) {
+ this.owner = owner;
+ }
+
+ public Map<String, String> getProperties() {
+ if (properties == null ) {
+ properties = new HashMap<String,String>();
+ }
+ return properties;
+ }
+
+ public String getTheme() {
+ return theme;
+ }
+
+ public void setTheme(String theme) {
+ this.theme = theme;
+ }
+
+ public boolean isStateLocked() {
+ return state.contains(STATE.LOCKED);
+ }
+
+ public void setStateLocked() {
+ state.add(STATE.LOCKED);
+ }
+}
Propchange:
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/PageFragment.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/PageFragment.java
------------------------------------------------------------------------------
svn:keywords = Id
Added:
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/service/APageService.java
URL:
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/service/APageService.java?rev=1356028&view=auto
==============================================================================
---
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/service/APageService.java
(added)
+++
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/service/APageService.java
Sun Jul 1 21:01:08 2012
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.rave.portal.web.service;
+
+import org.apache.rave.portal.web.model.PageDefinition;
+import org.apache.rave.portal.web.model.PageFragment;
+
+public class APageService {
+
+ private PageFragment defaultTemplateSrc(PageFragment pf) {
+ pf.setSrc("/WEB-INF/page/"+pf.getPath()+".jsp");
+ return pf;
+ }
+
+ public PageDefinition getAPage() {
+ PageDefinition apage = new PageDefinition("/pages/apage","apage");
+ apage.setSrc(apage.getPath()+".ftl");
+ PageFragment header = defaultTemplateSrc(new PageFragment(apage,
"/pages/apage/header", "header"));
+ PageFragment body = defaultTemplateSrc(new PageFragment(apage,
"/pages/apage/body", "body"));
+ PageFragment bodyLeft = defaultTemplateSrc(new PageFragment(body,
"/pages/apage/body/left", "left"));
+ PageFragment bodyCenter = defaultTemplateSrc(new PageFragment(body,
"/pages/apage/body/center", "center"));
+ PageFragment bodyRight = defaultTemplateSrc(new PageFragment(body,
"/pages/apage/body/right", "right"));
+ PageFragment footer = defaultTemplateSrc(new PageFragment(apage,
"/pages/apage/footer", "footer"));
+ return apage;
+ }
+}
Propchange:
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/service/APageService.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/service/APageService.java
------------------------------------------------------------------------------
svn:keywords = Id
Added:
rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/portal/web/model/PageDefinitionTest.java
URL:
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/portal/web/model/PageDefinitionTest.java?rev=1356028&view=auto
==============================================================================
---
rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/portal/web/model/PageDefinitionTest.java
(added)
+++
rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/portal/web/model/PageDefinitionTest.java
Sun Jul 1 21:01:08 2012
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.rave.portal.web.model;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class PageDefinitionTest {
+
+ @Test
+ public void testPageDefinition() throws Exception {
+ PageDefinition pd = new PageDefinition("/pages/1", "a");
+ try {
+ pd.setParent(new PageFragment("/pages/2", "a"));
+ Assert.fail("Expected setting PageDefinition parent to fail");
+ }
+ catch (UnsupportedOperationException uoe) {
+ }
+ }
+}
Propchange:
rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/portal/web/model/PageDefinitionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/portal/web/model/PageDefinitionTest.java
------------------------------------------------------------------------------
svn:keywords = Id
Added:
rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/portal/web/model/PageFragmentTest.java
URL:
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/portal/web/model/PageFragmentTest.java?rev=1356028&view=auto
==============================================================================
---
rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/portal/web/model/PageFragmentTest.java
(added)
+++
rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/portal/web/model/PageFragmentTest.java
Sun Jul 1 21:01:08 2012
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.rave.portal.web.model;
+
+import static junit.framework.Assert.assertEquals;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class PageFragmentTest {
+
+ private void checkSetNameFail(PageFragment pf, String name, String
failMessage) {
+ try {
+ pf.setName(name);
+ Assert.fail(failMessage);
+ }
+ catch (IllegalArgumentException iae) {
+ }
+ }
+
+ @Test
+ public void testIdAndPath() throws Exception {
+ PageDefinition pd = new PageDefinition("/pages/a", "a");
+ assertEquals("", pd.getPath());
+ PageFragment pf = new PageFragment(pd, "/pages/a/a", "a");
+ assertEquals("a", pf.getPath());
+ pf = new PageFragment(pd, "/pages/a/b", "b");
+ try {
+ new PageFragment(pd, "/pages/a/b", "b");
+ Assert.fail("Expected adding PageFragment to fail with same id as
sibling");
+ }
+ catch (IllegalArgumentException ise) {
+ }
+ pf = new PageFragment(pf, "/pages/a/b/c", "c");
+ assertEquals("b/c", pf.getPath());
+ pf.setName("d");
+ assertEquals("b/d", pf.getPath());
+ assertEquals("/pages/a/b/c", pf.getId());
+ new PageFragment(pf.getParent(), "/pages/a/b/c", "c");
+ checkSetNameFail(pf,"c", "Expected changing PageFragment id to fail
with same id as sibling");
+ checkSetNameFail(pf," ", "Expected changing PageFragment id to fail
with empty string");
+ checkSetNameFail(pf,"x/z", "Expected changing PageFragment id to fail
with embedded path delimiter");
+ checkSetNameFail(pf,null, "Expected changing PageFragment id to fail
with null value");
+ checkSetNameFail(pf,"", "Expected changing PageFragment id to fail
with zero length string");
+ }
+}
Propchange:
rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/portal/web/model/PageFragmentTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/portal/web/model/PageFragmentTest.java
------------------------------------------------------------------------------
svn:keywords = Id