click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r932848 - in /click/trunk/click/extras/test: menu.xml menu_custom.xml org/apache/click/extras/control/MenuFactoryTest.java
Date Sun, 11 Apr 2010 07:39:28 GMT
Author: sabob
Date: Sun Apr 11 07:39:27 2010
New Revision: 932848

URL: http://svn.apache.org/viewvc?rev=932848&view=rev
Log:
added menu tests

Added:
    click/trunk/click/extras/test/menu.xml
    click/trunk/click/extras/test/menu_custom.xml
    click/trunk/click/extras/test/org/apache/click/extras/control/MenuFactoryTest.java

Added: click/trunk/click/extras/test/menu.xml
URL: http://svn.apache.org/viewvc/click/trunk/click/extras/test/menu.xml?rev=932848&view=auto
==============================================================================
--- click/trunk/click/extras/test/menu.xml (added)
+++ click/trunk/click/extras/test/menu.xml Sun Apr 11 07:39:27 2010
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+   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.
+-->
+
+<menu>
+  <menu label="Home" path="home.htm" imageSrc="/assets/images/home.png">
+    <menu label="click.xml" path="source-viewer.htm?filename=WEB-INF/click.xml" title="Click
application descriptor" target="_blank" />
+  </menu>
+
+  <menu label="Intro Examples" path="#" imageSrc="/assets/images/intro.png">
+    <menu label="Hello World" path="introduction/hello-world.htm"/>
+  </menu>
+</menu>

Added: click/trunk/click/extras/test/menu_custom.xml
URL: http://svn.apache.org/viewvc/click/trunk/click/extras/test/menu_custom.xml?rev=932848&view=auto
==============================================================================
--- click/trunk/click/extras/test/menu_custom.xml (added)
+++ click/trunk/click/extras/test/menu_custom.xml Sun Apr 11 07:39:27 2010
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+   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.
+-->
+
+<menu>
+  <menu label="CustomMenu" path="custom-menu.htm">
+    <menu label="CustomSubMenu" path="custom-submenu.htm"/>
+  </menu>
+</menu>

Added: click/trunk/click/extras/test/org/apache/click/extras/control/MenuFactoryTest.java
URL: http://svn.apache.org/viewvc/click/trunk/click/extras/test/org/apache/click/extras/control/MenuFactoryTest.java?rev=932848&view=auto
==============================================================================
--- click/trunk/click/extras/test/org/apache/click/extras/control/MenuFactoryTest.java (added)
+++ click/trunk/click/extras/test/org/apache/click/extras/control/MenuFactoryTest.java Sun
Apr 11 07:39:27 2010
@@ -0,0 +1,89 @@
+/*
+ * 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.click.extras.control;
+
+import junit.framework.TestCase;
+import org.apache.click.MockContext;
+
+/**
+ * Provide tests for MenuFactory.
+ */
+public class MenuFactoryTest extends TestCase {
+
+    /**
+     * Check that Menus are loaded from default config: menu.xml.
+     */
+    public void testLoadMenuFromConfig() {
+        MockContext.initContext();
+
+        MenuFactory menuFactory = new MenuFactory();
+
+        Menu rootMenu = menuFactory.getRootMenu();
+        Menu menu1 = rootMenu.getChildren().get(0);
+
+        assertEquals(2, rootMenu.getChildren().size());
+        assertEquals("Home", menu1.getLabel());
+    }
+
+    /**
+     * Check that Menus are loaded from custom config: menu_custom.xml.
+     */
+    public void testLoadMenuFromCustomConfig() {
+        MockContext.initContext();
+
+        String customMenuConfig = "menu_custom.xml";
+
+        MenuFactory menuFactory = new MenuFactory();
+        Menu rootMenu = menuFactory.getRootMenu("customRootMenu", customMenuConfig);
+        Menu menu1 = rootMenu.getChildren().get(0);
+
+        assertEquals(1, rootMenu.getChildren().size());
+        assertEquals("CustomMenu", menu1.getLabel());
+    }
+
+    /**
+     * Test that Menus are loaded and cached.
+     */
+    public void testMenuCache() {
+        MockContext.initContext();
+
+        MenuFactory menuFactory = new MenuFactory();
+
+        Menu rootMenu = menuFactory.getRootMenu();
+
+        // Check that the same menu instance is returned on consecutive
+        // getRootMenu calls
+        assertSame(rootMenu, menuFactory.getRootMenu());
+    }
+
+    /**
+     * Check that Menus can be loaded and not cached.
+     */
+    public void testMenuNoCache() {
+        MockContext.initContext();
+
+        MenuFactory menuFactory = new MenuFactory();
+
+        Menu rootMenu = menuFactory.getRootMenu(false);
+
+        // Check that the different menu instances are returned on consecutive
+        // getRootMenu calls
+        assertNotSame(rootMenu, menuFactory.getRootMenu(false));
+    }
+}



Mime
View raw message