geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From genspr...@apache.org
Subject svn commit: r897794 - in /geronimo/server/branches/2.2/plugins/console/console-portal-driver/src/test: ./ java/ java/org/ java/org/apache/ java/org/apache/geronimo/ java/org/apache/geronimo/console/
Date Mon, 11 Jan 2010 08:38:55 GMT
Author: genspring
Date: Mon Jan 11 08:38:54 2010
New Revision: 897794

URL: http://svn.apache.org/viewvc?rev=897794&view=rev
Log:
GERONIMO-4994 missed unit test classes when applying patch.

Added:
    geronimo/server/branches/2.2/plugins/console/console-portal-driver/src/test/
    geronimo/server/branches/2.2/plugins/console/console-portal-driver/src/test/java/
    geronimo/server/branches/2.2/plugins/console/console-portal-driver/src/test/java/org/
    geronimo/server/branches/2.2/plugins/console/console-portal-driver/src/test/java/org/apache/
    geronimo/server/branches/2.2/plugins/console/console-portal-driver/src/test/java/org/apache/geronimo/
    geronimo/server/branches/2.2/plugins/console/console-portal-driver/src/test/java/org/apache/geronimo/console/
    geronimo/server/branches/2.2/plugins/console/console-portal-driver/src/test/java/org/apache/geronimo/console/NavigationJsonGeneratorTest.java
  (with props)
    geronimo/server/branches/2.2/plugins/console/console-portal-driver/src/test/java/org/apache/geronimo/console/TreeNodeTest.java
  (with props)

Added: geronimo/server/branches/2.2/plugins/console/console-portal-driver/src/test/java/org/apache/geronimo/console/NavigationJsonGeneratorTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/console/console-portal-driver/src/test/java/org/apache/geronimo/console/NavigationJsonGeneratorTest.java?rev=897794&view=auto
==============================================================================
--- geronimo/server/branches/2.2/plugins/console/console-portal-driver/src/test/java/org/apache/geronimo/console/NavigationJsonGeneratorTest.java
(added)
+++ geronimo/server/branches/2.2/plugins/console/console-portal-driver/src/test/java/org/apache/geronimo/console/NavigationJsonGeneratorTest.java
Mon Jan 11 08:38:54 2010
@@ -0,0 +1,102 @@
+/**
+ *  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.geronimo.console.navigation;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.geronimo.pluto.impl.PageConfig;
+
+/*
+* @version $Rev$ $Date$
+*/
+public class NavigationJsonGeneratorTest extends TestCase {
+
+    NavigationJsonGenerator navigationJsonGenerator;
+    List<PageConfig> pageList;
+    
+    protected void setUp() throws Exception {
+        super.setUp();
+        
+        navigationJsonGenerator=new NavigationJsonGenerator(null);
+        
+        pageList = new ArrayList<PageConfig>();
+        PageConfig pc = new PageConfig();
+
+        pc.setIcon("/images/ico_deploy_16x16.gif");
+        pc.setName("2-2/cat2/item2-2");
+        pc.setUri("/server/serverlog");
+
+        pageList.add(pc);
+
+        pc = new PageConfig();
+        pc.setIcon("/images/ico_deploy_16x16.gif");
+        pc.setName("1-1-1-1/cat1/cat1-1/cat1-1-1/item1-1-1-1");
+        pc.setUri("/server/serverlog");
+        pageList.add(pc);
+
+        
+        pc = new PageConfig();
+        pc.setIcon("/images/ico_deploy_16x16.gif");
+        pc.setName("2-2-1/cat2/cat2-1/item2-2-1");
+        pc.setUri("/server/serverlog");
+
+        pageList.add(pc);
+
+        pc = new PageConfig();
+        pc.setIcon("/images/ico_deploy_16x16.gif");
+        pc.setName("1-2/cat1/item1-2");
+        pc.setUri("/server/serverlog");
+        pageList.add(pc);
+    
+
+        
+    }
+
+    public void testGenerateTreeJSON() {
+        System.out.println("testGenerateTreeJSON() ------ ");
+        String json=navigationJsonGenerator.generateTreeJSON(pageList, "console", "/images/ico_deploy_16x16.gif");
+        
+        String expected="[\n{label: \'cat1\',id: \'1\',children: [{label: \'cat1-1\',id:
\'1-1\',children: [{label: \'cat1-1-1\',id: \'1-1-1\',children: [{label: \'<img src=\"console/images/ico_deploy_16x16.gif\"
alt=\"\" border=\"0\">&nbsp;<a href=\"console/portal/1-1-1-1/cat1/cat1-1/cat1-1-1/item1-1-1-1\">item1-1-1-1</a>\',id:
\'1-1-1-1\'}]\n}]\n},{label: \'<img src=\"console/images/ico_deploy_16x16.gif\" alt=\"\"
border=\"0\">&nbsp;<a href=\"console/portal/1-2/cat1/item1-2\">item1-2</a>\',id:
\'1-2\'}]\n},\n{label: \'cat2\',id: \'2\',children: [{label: \'<img src=\"console/images/ico_deploy_16x16.gif\"
alt=\"\" border=\"0\">&nbsp;<a href=\"console/portal/2-2/cat2/item2-2\">item2-2</a>\',id:
\'2-2\'}]\n}\n]";
+       
+        System.out.println(json);
+        Assert.assertEquals(expected,json);
+    }
+    
+    public void testGenerateQuickLauncherJSON() {
+        System.out.println("testGenerateQuickLauncherJSON() ------ ");
+        String json=navigationJsonGenerator.generateQuickLauncherJSON(pageList, "console",
"/images/ico_deploy_16x16.gif");
+        String expected="[\n\n{label: \'<img src=\"console/images/ico_deploy_16x16.gif\">&nbsp;<span>item1-1-1-1</span>\',name:
\'item1-1-1-1\'},\n{label: \'<img src=\"console/images/ico_deploy_16x16.gif\">&nbsp;<span>item1-2</span>\',name:
\'item1-2\'},\n{label: \'<img src=\"console/images/ico_deploy_16x16.gif\">&nbsp;<span>item2-2</span>\',name:
\'item2-2\'}\n]";
+       
+        System.out.println(json);
+        Assert.assertEquals(expected,json);
+
+    }
+    
+    public void testGenerateLinks() {
+        System.out.println("testGenerateLinks()------ ");
+        String json=navigationJsonGenerator.generateLinks(pageList, "console", "/images/ico_deploy_16x16.gif");
+        String expected="<ul>\n<li><a href=\"console/portal/1-1-1-1/cat1/cat1-1/cat1-1-1/item1-1-1-1\">item1-1-1-1</a></li>\n<li><a
href=\"console/portal/1-2/cat1/item1-2\">item1-2</a></li>\n<li><a
href=\"console/portal/2-2/cat2/item2-2\">item2-2</a></li>\n</ul>";
+
+        System.out.println(json);
+        Assert.assertEquals(expected,json);
+    }
+
+}

Propchange: geronimo/server/branches/2.2/plugins/console/console-portal-driver/src/test/java/org/apache/geronimo/console/NavigationJsonGeneratorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: geronimo/server/branches/2.2/plugins/console/console-portal-driver/src/test/java/org/apache/geronimo/console/TreeNodeTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/console/console-portal-driver/src/test/java/org/apache/geronimo/console/TreeNodeTest.java?rev=897794&view=auto
==============================================================================
--- geronimo/server/branches/2.2/plugins/console/console-portal-driver/src/test/java/org/apache/geronimo/console/TreeNodeTest.java
(added)
+++ geronimo/server/branches/2.2/plugins/console/console-portal-driver/src/test/java/org/apache/geronimo/console/TreeNodeTest.java
Mon Jan 11 08:38:54 2010
@@ -0,0 +1,134 @@
+/**
+ *  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.geronimo.console.navigation;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.geronimo.pluto.impl.PageConfig;
+/*
+* @version $Rev$ $Date$
+*/
+public class TreeNodeTest extends TestCase {
+
+    public void testCategoryTreeNode() {
+        
+        //second level category
+        TreeNode categoryNode=new TreeNode("1-2","server/kernel");
+        Assert.assertEquals("1-2", categoryNode.getId());
+        Assert.assertEquals("server/kernel", categoryNode.getPath());
+        Assert.assertEquals("kernel", categoryNode.getLabel());
+        Assert.assertEquals("/images/ico_folder_16x16.gif", categoryNode.getIcon());
+        Assert.assertFalse(categoryNode.isLeafNode());
+        Assert.assertFalse(categoryNode.isTopNode());
+        Assert.assertNotNull(categoryNode.getChildren());
+        
+        //top level category
+        categoryNode=new TreeNode("1","server");
+        Assert.assertEquals("1", categoryNode.getId());
+        Assert.assertEquals("server", categoryNode.getPath());
+        Assert.assertEquals("server", categoryNode.getLabel());
+        Assert.assertEquals("/images/ico_folder_16x16.gif", categoryNode.getIcon());
+        Assert.assertFalse(categoryNode.isLeafNode());
+        Assert.assertTrue(categoryNode.isTopNode());
+        Assert.assertNotNull(categoryNode.getChildren());
+        
+    }
+
+    public void testLeafTreeNode() {
+        
+        PageConfig pc = new PageConfig();
+        pc.setIcon("/images/ico_deploy_16x16.gif");
+        pc.setName("1-2/applications/deploy");
+        TreeNode leafNode=null;
+        try {
+           leafNode=new TreeNode(pc);
+        } catch (Exception e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        Assert.assertNotNull(leafNode);
+        Assert.assertEquals("1-2", leafNode.getId());
+        Assert.assertEquals("applications/deploy", leafNode.getPath());
+        Assert.assertEquals("deploy", leafNode.getLabel());
+        Assert.assertEquals("/images/ico_deploy_16x16.gif", leafNode.getIcon());
+        Assert.assertTrue(leafNode.isLeafNode());
+        Assert.assertFalse(leafNode.isTopNode());
+        Assert.assertNull(leafNode.getChildren());
+        
+        //test illegal pageConfig name
+        pc = new PageConfig();
+        pc.setIcon("/images/ico_deploy_16x16.gif");
+        pc.setName("applications/deploy");
+        leafNode=null;
+        try {
+           leafNode=new TreeNode(pc);
+        } catch (Exception e) {
+            return;
+        }
+        fail("Expected Ilegal ID Exception");
+    }
+    
+   
+    public void testPopulateTree() {
+        
+        List<PageConfig> pageConfigList = new ArrayList<PageConfig>();
+        PageConfig pc = new PageConfig();
+
+        pc.setIcon("/images/ico_deploy_16x16.gif");
+        pc.setName("2-2/cat2/item2-2");
+        pageConfigList.add(pc);
+
+        pc = new PageConfig();
+        pc.setIcon("/images/ico_deploy_16x16.gif");
+        pc.setName("1-1-1-1/cat1/cat1-1/cat1-1-1/item1-1-1-1");
+        pageConfigList.add(pc);
+
+        pc = new PageConfig();
+        pc.setIcon("/images/ico_deploy_16x16.gif");
+        pc.setName("2-2-1/cat2/cat2-1/item2-2-1");
+        pc.setUri("/server/serverlog");
+
+        pageConfigList.add(pc);
+        pc = new PageConfig();
+        pc.setIcon("/images/ico_deploy_16x16.gif");
+        pc.setName("1-2/cat1/item1-2");
+        pageConfigList.add(pc);
+        
+        
+        Map<String, TreeNode> navigationTree = new TreeMap<String, TreeNode>();
+        
+        for (PageConfig pageConfig : pageConfigList) {
+            try {
+                new TreeNode(pageConfig).populateTree(navigationTree);
+            } catch (Exception e) {
+                continue;
+            }
+        }
+       
+       String expectedString="[1, 1-1, 1-1-1, 1-1-1-1, 1-2, 2, 2-2, 2-2-1]";
+       Assert.assertEquals(expectedString, navigationTree.keySet().toString());
+       System.out.println(navigationTree.keySet());  
+        
+    }
+
+}

Propchange: geronimo/server/branches/2.2/plugins/console/console-portal-driver/src/test/java/org/apache/geronimo/console/TreeNodeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message