KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > security > TestSLAnnotationPermissions


1 /**
2  * EasyBeans
3  * Copyright (C) 2006 Bull S.A.S.
4  * Contact: easybeans@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: TestSLAnnotationPermissions.java 979 2006-07-28 13:19:50Z studzine $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.security;
26
27 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.security.ItfSecurityPermissionTester;
28 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.security.SFSBSecurityPermissionTester01;
29 import org.objectweb.easybeans.tests.common.helper.EJBHelper;
30 import org.testng.annotations.BeforeMethod;
31 import org.testng.annotations.Test;
32
33 /**
34  * Verifies if the container manages the security roles defined by annotation.
35  * The bean used during the tests is stateless. The chapter verified is the 17.
36  * @reference JSR 220- FINAL RELEASE
37  * @requirement Application Server must be running; the bean
38  * SLSBSecurityPermissionTester00 and SFSBSecurityRoles must be deployed.
39  * @setup gets the reference of SLSBSecurityPermissionTester00.
40  * @author Gisele Pinheiro Souza
41  * @author Eduardo Studzinski Estima de Castro
42  */

43 public class TestSLAnnotationPermissions {
44
45     /**
46      * Bean used during the tests.
47      */

48     private ItfSecurityPermissionTester tester;
49
50     /**
51      * Creates the stateful bean used during the tests.
52      * @throws Exception if an error occurs during the lookup.
53      */

54     @BeforeMethod
55     public void setup() throws Exception JavaDoc {
56         tester = EJBHelper.getBeanRemoteInstance(SFSBSecurityPermissionTester01.class, ItfSecurityPermissionTester.class);
57     }
58
59     /**
60      * Verifies if it is possible to call a method with permitAll annotation.
61      * @input -
62      * @output the correct method execution.
63      */

64     @Test
65     public void testPermitAll(){
66        tester.testPermitAll();
67     }
68
69     /**
70      * Verifies if it is not possible call a method with denyAll annotation.
71      * @input -
72      * @output the correct method execution. The EJBAccessException is verified in the server site.
73      */

74     @Test
75     public void testDenyAll(){
76         tester.testDenyAll();
77     }
78
79     /**
80      * Verifies if a method with the allowsRoles annotation can be called by a
81      * bean that is defined in the annotation.
82      * @input -
83      * @output the correct method execution.
84      */

85     @Test
86     public void testAllowedRolesWithTwoRoles(){
87         tester.testAllowedRolesWithTwoRoles();
88     }
89
90     /**
91      * Verifies if the container does not permit that a bean can call a method
92      * in which it has the access denied.
93      * @input -
94      * @output the correct method execution. The EJBAccessException is verified
95      * in the server site.
96      */

97     @Test
98     public void testAllowedRolesWithOneRole(){
99         tester.testAllowedRolesWithOneRole();
100     }
101 }
102
Popular Tags