KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > lenya > ac > impl > IdentityTest


1 /*
2 * Copyright 1999-2004 The Apache Software Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */

16 package org.apache.lenya.ac.impl;
17
18 import junit.textui.TestRunner;
19
20 import org.apache.lenya.ac.AccessControlException;
21 import org.apache.lenya.ac.Identity;
22 import org.apache.lenya.ac.User;
23 import org.apache.lenya.cms.PublicationHelper;
24
25 public class IdentityTest extends AccessControlTest {
26
27     /**
28      * Ctor.
29      * @param test The test.
30      */

31     public IdentityTest(String JavaDoc test) {
32         super(test);
33     }
34
35     /**
36      * The main method.
37      * @param args The command-line arguments.
38      */

39     public static void main(String JavaDoc[] args) {
40         PublicationHelper.extractPublicationArguments(args);
41         TestRunner.run(IdentityTest.class);
42     }
43     
44     public static final String JavaDoc USER_ID = "lenya";
45
46     /**
47      * Tests the identity.
48      *
49      * @throws AccessControlException if an error occurs
50      */

51     public void testIdentity() throws AccessControlException {
52         Identity identity = new Identity();
53         User user = getAccessController().getAccreditableManager().getUserManager().getUser(USER_ID);
54         System.out.println("Adding user to identity: [" + user + "]");
55         identity.addIdentifiable(user);
56         
57         assertSame(user, identity.getUser());
58     }
59
60 }
61
Popular Tags