[jboss-svn-commits] JBL Code SVN: r32811 - labs/jbossrules/trunk/drools-guvnor/src/test/java/org/drools/guvnor/server.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue May 11 01:47:59 EDT 2010
Author: jervisliu
Date: 2010-05-11 01:47:59 -0400 (Tue, 11 May 2010)
New Revision: 32811
Modified:
labs/jbossrules/trunk/drools-guvnor/src/test/java/org/drools/guvnor/server/ServiceImplSecurityTest.java
Log:
More test for GUVNOR-537 and GUVNOR-533
Modified: labs/jbossrules/trunk/drools-guvnor/src/test/java/org/drools/guvnor/server/ServiceImplSecurityTest.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/test/java/org/drools/guvnor/server/ServiceImplSecurityTest.java 2010-05-11 02:27:31 UTC (rev 32810)
+++ labs/jbossrules/trunk/drools-guvnor/src/test/java/org/drools/guvnor/server/ServiceImplSecurityTest.java 2010-05-11 05:47:59 UTC (rev 32811)
@@ -1044,6 +1044,58 @@
}
}
+ public void testLoadChildCategories() throws Exception {
+ try {
+ ServiceImplementation impl = getService();
+ String package1Name = "testLoadChildCategoriesPack1";
+ String category1Name = "testLoadChildCategoriesCat1";
+ String category2Name = "testLoadChildCategoriesCat2";
+
+ impl.repository.createPackage(package1Name, "desc");
+ impl.createCategory("", category1Name, "this is a cat");
+ impl.createCategory("", category2Name, "this is a cat");
+
+ impl.createNewRule("testLoadChildCategoriesRule1",
+ "description", category1Name, package1Name, AssetFormats.DRL);
+
+ impl.createNewRule("testLoadChildCategoriesRule2",
+ "description", category2Name, package1Name, AssetFormats.DRL);
+
+ // Mock up SEAM contexts
+ Map application = new HashMap<String, Object>();
+ Lifecycle.beginApplication(application);
+ Lifecycle.beginCall();
+ MockIdentity midentity = new MockIdentity();
+ RoleBasedPermissionResolver resolver = new RoleBasedPermissionResolver();
+ resolver.setEnableRoleBasedAuthorization(true);
+ midentity.addPermissionResolver(resolver);
+ midentity.create();
+
+ Contexts.getSessionContext().set(
+ "org.jboss.seam.security.identity", midentity);
+ Contexts.getSessionContext().set(
+ "org.drools.guvnor.client.rpc.RepositoryService", impl);
+
+ List<RoleBasedPermission> pbps = new ArrayList<RoleBasedPermission>();
+ pbps.add(new RoleBasedPermission("jervis",
+ RoleTypes.ANALYST,
+ null, category1Name));
+ MockRoleBasedPermissionStore store = new MockRoleBasedPermissionStore(pbps);
+ Contexts.getSessionContext().set("org.drools.guvnor.server.security.RoleBasedPermissionStore", store);
+
+ // Put permission list in session.
+ RoleBasedPermissionManager testManager = new RoleBasedPermissionManager();
+ testManager.create();
+ Contexts.getSessionContext().set("roleBasedPermissionManager", testManager);
+
+ String[] res = impl.loadChildCategories("/");
+ assertEquals(1, res.length);
+ } finally {
+ Lifecycle.endApplication();
+ }
+ }
+
+
public void testloadRuleListForCategoriesPackageReadonly() throws Exception {
try {
ServiceImplementation impl = getService();
More information about the jboss-svn-commits
mailing list