Return-Path: Delivered-To: apmail-click-commits-archive@www.apache.org Received: (qmail 50727 invoked from network); 11 Apr 2010 07:39:49 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 11 Apr 2010 07:39:49 -0000 Received: (qmail 32210 invoked by uid 500); 11 Apr 2010 07:39:49 -0000 Delivered-To: apmail-click-commits-archive@click.apache.org Received: (qmail 32192 invoked by uid 500); 11 Apr 2010 07:39:49 -0000 Mailing-List: contact commits-help@click.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: click-dev@click.apache.org Delivered-To: mailing list commits@click.apache.org Received: (qmail 32184 invoked by uid 99); 11 Apr 2010 07:39:49 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 11 Apr 2010 07:39:49 +0000 X-ASF-Spam-Status: No, hits=-1660.6 required=10.0 tests=ALL_TRUSTED,AWL X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 11 Apr 2010 07:39:48 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 388B32388A39; Sun, 11 Apr 2010 07:39:28 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@click.apache.org From: sabob@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100411073928.388B32388A39@eris.apache.org> 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 @@ + + + + + + + + + + + + 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 @@ + + + + + + + + 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)); + } +}