You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2014/07/09 14:09:35 UTC
svn commit: r1609125 - in
/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src:
main/java/org/apache/myfaces/tobago/example/demo/NavigationTree.java
test/java/org/apache/myfaces/tobago/example/demo/NavigationUnitTest.java
Author: lofwyr
Date: Wed Jul 9 12:09:35 2014
New Revision: 1609125
URL: http://svn.apache.org/r1609125
Log:
demo: unit test
Modified:
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/NavigationTree.java
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/test/java/org/apache/myfaces/tobago/example/demo/NavigationUnitTest.java
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/NavigationTree.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/NavigationTree.java?rev=1609125&r1=1609124&r2=1609125&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/NavigationTree.java (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/NavigationTree.java Wed Jul 9 12:09:35 2014
@@ -67,11 +67,12 @@ public class NavigationTree implements S
}
@PostConstruct
- private void postConstruct() {
+ protected void postConstruct() {
// todo: refactor with Java EE 7
final ServletContext servletContext;
servletContext = ((ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext());
final List<String> list = locateResourcesInWar(servletContext, "/content", new ArrayList<String>());
+
list.add("/content/root-dummy.xhtml"); // helps to build the tree, this is not an existing file
final List<NavigationNode> nodes = new ArrayList<NavigationNode>();
for (final String path : list) {
@@ -100,7 +101,7 @@ public class NavigationTree implements S
}
}
- private static List<String> locateResourcesInWar(
+ protected List<String> locateResourcesInWar(
final ServletContext servletContext, final String directory, final List<String> result) {
final Set<String> resourcePaths = servletContext.getResourcePaths(directory);
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/test/java/org/apache/myfaces/tobago/example/demo/NavigationUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/test/java/org/apache/myfaces/tobago/example/demo/NavigationUnitTest.java?rev=1609125&r1=1609124&r2=1609125&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/test/java/org/apache/myfaces/tobago/example/demo/NavigationUnitTest.java (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/test/java/org/apache/myfaces/tobago/example/demo/NavigationUnitTest.java Wed Jul 9 12:09:35 2014
@@ -23,25 +23,32 @@ import org.apache.myfaces.tobago.interna
import org.junit.Assert;
import org.junit.Test;
+import javax.servlet.ServletContext;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class NavigationUnitTest extends AbstractTobagoTestBase {
+ private static final List<String> LIST = new ArrayList<String>(Arrays.asList(
+ "/content/00/test-1.xhtml",
+ "/content/00/07/test-2.xhtml",
+ "/content/01/test.xhtml",
+ "/content/00/00/test-4.xhtml",
+ "/content/bad.jsp",
+ "/content/00_00_bad.gif"
+ ));
+
@Test
public void testFileNames() {
- final List<String> list = new ArrayList<String>(Arrays.asList(
- "/content/00/test-1.xhtml",
-// todo "/content/00/x-bad.xhtml", // x- means excluded
- "/content/00/07/test-2.xhtml",
- "/content/00/07/x-bad.xhtml", // x- means excluded
- "/content/01/test.xhtml",
- "/content/00/00/test-4.xhtml",
- "/content/bad.jsp",
- "/content/00_00_bad.gif"
- ));
- final NavigationTree navigation = new NavigationTree(list);
+ final NavigationTree navigation = new NavigationTree() {
+ @Override
+ protected List<String> locateResourcesInWar(
+ ServletContext servletContext, String directory, List<String> result) {
+ return LIST;
+ }
+ };
+ navigation.postConstruct();
final NavigationNode root = navigation.getTree();
Assert.assertEquals(2, root.getChildCount());
final NavigationNode n00 = (NavigationNode) root.getChildAt(0);