01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.wicket.authorization.strategies.role.metadata;
18:
19: import junit.framework.TestCase;
20:
21: import org.apache.wicket.authorization.Action;
22: import org.apache.wicket.authorization.strategies.role.Roles;
23:
24: /**
25: * Test case for {@link org.apache.wicket.authorization.strategies.role.metadata.ActionPermissions}.
26: *
27: * @author Eelco Hillenius
28: */
29: public class ActionPermissionsTest extends TestCase {
30: /**
31: * Construct.
32: */
33: public ActionPermissionsTest() {
34: super ();
35: }
36:
37: /**
38: * Construct.
39: * @param arg0
40: */
41: public ActionPermissionsTest(String arg0) {
42: super (arg0);
43: }
44:
45: /**
46: * Test adding roles.
47: *
48: * @throws Exception
49: */
50: public void testAdd1() throws Exception {
51: ActionPermissions permissions = new ActionPermissions();
52: Action mambo = new Action("mambo");
53: permissions.authorize(mambo, new Roles("jonathan"));
54: permissions.authorize(mambo, new Roles("johan"));
55: permissions.authorize(mambo, new Roles("maurice"));
56: permissions.authorize(mambo, new Roles("eelco"));
57: assertEquals(4, permissions.rolesFor(mambo).size());
58: permissions.unauthorize(mambo, new Roles("maurice"));
59: assertEquals(3, permissions.rolesFor(mambo).size());
60: permissions.authorizeAll(mambo);
61: assertEquals(null, permissions.rolesFor(mambo));
62: }
63: }
|