1   /**
2    * Copyright 2005-2006 the original author or authors.
3    *
4    * Licensed under the Gnu General Pubic License, Version 2.0 (the
5    * "License"); you may not use this file except in compliance with
6    * the License. You may obtain a copy of the License at
7    *
8    *      http://www.opensource.org/licenses/gpl-license.php
9    *
10   * This program is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13   * See the Gnu General Public License for more details.
14   */
15  package org.figure8.join.businessobjects.security;
16  
17  import junit.framework.Test;
18  import junit.framework.TestCase;
19  import junit.framework.TestSuite;
20  /**
21   * JUnit tests for Permission business object.
22   * @author <a href="mailto:laurent.broudoux@free.fr">Laurent Broudoux</a>
23   * @version $Revision: 1.1 $
24   */
25  public class PermissionTest extends TestCase{
26  
27     // Constructors -------------------------------------------------------------
28  
29     /** Default constructor. Build a test case using a name. */
30     public PermissionTest(String testName){
31        super(testName);
32     }
33  
34  
35     // Override of TestCase -----------------------------------------------------
36  
37     /**
38      * Make this class a TestSuite.
39      * @return A TestSuite containing this TestCase.
40      */
41     public static Test suite(){
42        TestSuite suite = new TestSuite(PermissionTest.class);
43        return suite;
44     }
45  
46  
47     // Public -------------------------------------------------------------------
48  
49     /** Test the isGlobalPermission flag. */
50     public void testIsGlobalPermission(){
51        // Create global permission (without resource attached).
52        Permission permission = new Permission(new Role(), "userId");
53        assertEquals("Permission is a global one", permission.isGlobalPermission(), true);
54     }
55  
56     /** Test the isResourcePermssion flag. */
57     public void testIsResourcePermission(){
58        // Create global permission (with resource attached).
59        Permission permission = new Permission(new Role(), "userId", "resourceId");
60        assertEquals("Permission is a resource one", permission.isResourcePermission(), true);
61     }
62  }