Return-Path: Delivered-To: apmail-cocoon-cvs-archive@www.apache.org Received: (qmail 69393 invoked from network); 20 Oct 2004 16:42:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 20 Oct 2004 16:42:26 -0000 Received: (qmail 24665 invoked by uid 500); 20 Oct 2004 16:41:16 -0000 Delivered-To: apmail-cocoon-cvs-archive@cocoon.apache.org Received: (qmail 24435 invoked by uid 500); 20 Oct 2004 16:41:14 -0000 Mailing-List: contact cvs-help@cocoon.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@cocoon.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list cvs@cocoon.apache.org Received: (qmail 24348 invoked by uid 99); 20 Oct 2004 16:41:13 -0000 X-ASF-Spam-Status: No, hits=-10.0 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Wed, 20 Oct 2004 09:41:13 -0700 Received: (qmail 68522 invoked by uid 65534); 20 Oct 2004 16:41:11 -0000 Date: 20 Oct 2004 16:41:11 -0000 Message-ID: <20041020164111.68520.qmail@minotaur.apache.org> From: ugo@apache.org To: cvs@cocoon.apache.org Subject: svn commit: rev 55163 - in cocoon/whiteboard/ecmplus: lib src/test src/test/org src/test/org/apache src/test/org/apache/cocoon src/test/org/apache/cocoon/components src/test/org/apache/cocoon/components/container X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Author: ugo Date: Wed Oct 20 09:41:11 2004 New Revision: 55163 Added: cocoon/whiteboard/ecmplus/lib/ cocoon/whiteboard/ecmplus/lib/jmock-1.0.1.jar (contents, props changed) cocoon/whiteboard/ecmplus/src/test/ cocoon/whiteboard/ecmplus/src/test/org/ cocoon/whiteboard/ecmplus/src/test/org/apache/ cocoon/whiteboard/ecmplus/src/test/org/apache/cocoon/ cocoon/whiteboard/ecmplus/src/test/org/apache/cocoon/components/ cocoon/whiteboard/ecmplus/src/test/org/apache/cocoon/components/container/ cocoon/whiteboard/ecmplus/src/test/org/apache/cocoon/components/container/RoleManagerTestCase.java (contents, props changed) Log: Tests Added: cocoon/whiteboard/ecmplus/lib/jmock-1.0.1.jar ============================================================================== Binary file. No diff available. Added: cocoon/whiteboard/ecmplus/src/test/org/apache/cocoon/components/container/RoleManagerTestCase.java ============================================================================== --- (empty file) +++ cocoon/whiteboard/ecmplus/src/test/org/apache/cocoon/components/container/RoleManagerTestCase.java Wed Oct 20 09:41:11 2004 @@ -0,0 +1,74 @@ +/* + * Copyright 1999-2004 The Apache Software Foundation. + * + * Licensed 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.cocoon.components.container; + +import org.apache.avalon.framework.configuration.Configuration; +import org.apache.avalon.framework.configuration.ConfigurationException; +import org.apache.avalon.framework.logger.Logger; +import org.jmock.Mock; +import org.jmock.MockObjectTestCase; + + +/** + * Test cases for {@link RoleManager}. + * + * @version CVS $Id$ + */ +public class RoleManagerTestCase extends MockObjectTestCase { + + /** + * Constructor for RoleManagerTestCase. + * @param name The test name + */ + public RoleManagerTestCase(String name) { + super(name); + } + + /* + * @see TestCase#setUp() + */ + protected void setUp() throws Exception { + } + + public void testConfigureWithoutHints() throws ConfigurationException { + Mock conf = new Mock(Configuration.class); + Mock child0 = new Mock(Configuration.class); + Configuration roles[] = new Configuration[1]; + roles[0] = (Configuration) child0.proxy(); + Configuration hints[] = new Configuration[0]; + conf.expects(once()).method("getChildren").with(eq("role")) + .will(returnValue(roles)); + child0.expects(once()).method("getAttribute").with(eq("name")) + .will(returnValue("testName")); + child0.expects(once()).method("getAttribute").with(eq("shorthand")) + .will(returnValue("testShorthand")); + child0.expects(once()).method("getAttribute").with(eq("default-class"), eq(null)) + .will(returnValue("testClass")); + child0.expects(once()).method("getChildren").with(eq("hint")) + .will(returnValue(hints)); + Mock logger = new Mock(Logger.class); + logger.expects(this.atLeastOnce()).method("isDebugEnabled").will(returnValue(false)); + RoleManager rm = new RoleManager(null); + rm.enableLogging((Logger) logger.proxy()); + rm.configure((Configuration) conf.proxy()); + conf.verify(); + child0.verify(); + assertEquals("Role name for shorthand incorrect", "testName", rm.getRoleForName("testShorthand")); + assertEquals("Default class for role incorrect", "testClass", rm.getDefaultClassNameForRole("testName")); + assertEquals("Default class for hint must be empty", "", rm.getDefaultClassNameForHint("testName", "testShorthand")); + } + +}