Removed DOCUMENT ME comments that were generated and applied source code
[utils] / security / src / test / java / org / wamblee / security / authorization / hibernate / PersistentAuthorizationServiceTest.java
index b1a369347032d6122a01145543659a5afb5ab6ab..b4d6f6b974a5490b336fd3037100c2a1685a788e 100644 (file)
@@ -1,33 +1,37 @@
 /*
  * Copyright 2005 the original author or authors.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.wamblee.security.authorization.hibernate;
 
-import java.sql.SQLException;
-
 import org.apache.log4j.Logger;
+
 import org.hibernate.cfg.Configuration;
+
 import org.hibernate.dialect.MySQL5Dialect;
 import org.hibernate.dialect.MySQL5InnoDBDialect;
+
 import org.hibernate.tool.hbm2ddl.SchemaExport;
+
 import org.springframework.orm.hibernate3.HibernateTemplate;
+
 import org.wamblee.general.BeanKernel;
+
 import org.wamblee.security.authorization.AuthorizationService;
 import org.wamblee.security.authorization.AuthorizationServiceTest;
 import org.wamblee.security.authorization.TestUserAccessor;
+
 import org.wamblee.system.adapters.ClassConfiguration;
 import org.wamblee.system.adapters.ClassConfigurationTest;
 import org.wamblee.system.adapters.DefaultContainer;
@@ -36,60 +40,71 @@ import org.wamblee.system.components.DatabaseComponentFactory;
 import org.wamblee.system.core.Scope;
 import org.wamblee.system.spring.component.DatabaseTesterComponent;
 import org.wamblee.system.spring.component.DatasourceComponent;
+
 import org.wamblee.usermgt.UserAccessor;
 import org.wamblee.usermgt.hibernate.AuthorizationComponent;
 import org.wamblee.usermgt.hibernate.HibernateUserAdministrationTest;
 import org.wamblee.usermgt.hibernate.UserAdministrationComponent;
 
+import java.sql.SQLException;
+
 /**
  * Unit test for the persistent authorization service.
  * 
  * @author Erik Brakkee
  */
 public class PersistentAuthorizationServiceTest extends
-        AuthorizationServiceTest {
-
+    AuthorizationServiceTest {
     private static final Logger LOGGER = Logger
-            .getLogger(PersistentAuthorizationServiceTest.class);
+        .getLogger(PersistentAuthorizationServiceTest.class);
 
     private static final String SERVICE_TABLE = "AUTHORIZATION_SERVICE";
+
     private static final String RULES_TABLE = "AUTHORIZATION_RULES";
+
     private static final String SERVICE_RULES_TABLE = "AUTHORIZATION_SERVICE_RULES";
+
     private static final String OPERATIONCOND_TABLE = "OPERATION_CONDITIONS";
+
     private static final String PATHCOND_TABLE = "PATH_CONDITIONS";
+
     private static final String USERCOND_TABLE = "USER_CONDITIONS";
 
     private DefaultContainer container;
+
     private Scope scope;
 
     private DatabaseTesterComponent databaseTester;
+
     private UserAccessor userAccessor;
+
     private HibernateTemplate hibernateTemplate;
+
     private AuthorizationService authorizationService;
 
     @Override
     protected void setUp() throws Exception {
-
         container = new DefaultContainer("top");
         DatabaseComponentFactory.addDatabaseConfig(container);
         container.addComponent(new DatasourceComponent("datasource"));
+
         ClassConfiguration useraccessorConfig = new ClassConfiguration(
-                TestUserAccessor.class);
+            TestUserAccessor.class);
         useraccessorConfig.getObjectConfig().getSetterConfig().initAllSetters();
         container.addComponent("userAccessor", useraccessorConfig);
-        container.addComponent(new AuthorizationComponent("authorization",
-                true));
+        container
+            .addComponent(new AuthorizationComponent("authorization", true));
 
         ClassConfiguration dbtesterConfig = new ClassConfiguration(
-                DatabaseTesterComponent.class);
+            DatabaseTesterComponent.class);
         dbtesterConfig.getObjectConfig().getSetterConfig().initAllSetters();
         container.addComponent("databaseTester", dbtesterConfig);
 
         ObjectConfiguration config = new ObjectConfiguration(
-                PersistentAuthorizationServiceTest.class);
+            PersistentAuthorizationServiceTest.class);
         config.getSetterConfig().clear().add("setUserAccessor").add(
-                "setDatabaseTester").add("setHibernateTemplate").add(
-                "setAuthorizationService");
+            "setDatabaseTester").add("setHibernateTemplate").add(
+            "setAuthorizationService");
         container.addComponent("testcase", this, config);
 
         scope = container.start();
@@ -112,7 +127,7 @@ public class PersistentAuthorizationServiceTest extends
     }
 
     public void setAuthorizationService(
-            AuthorizationService aAuthorizationService) {
+        AuthorizationService aAuthorizationService) {
         authorizationService = aAuthorizationService;
     }
 
@@ -126,7 +141,8 @@ public class PersistentAuthorizationServiceTest extends
     @Override
     protected AuthorizationService createService() {
         PersistentAuthorizationService service = new PersistentAuthorizationService(
-                "DEFAULT", hibernateTemplate, createUserAccessor(), 10000);
+            "DEFAULT", hibernateTemplate, createUserAccessor(), 10000);
+
         return service;
     }
 
@@ -143,34 +159,37 @@ public class PersistentAuthorizationServiceTest extends
             assertEquals(1, databaseTester.getTableSize(SERVICE_TABLE));
             assertEquals(aCount, databaseTester.getTableSize(RULES_TABLE));
             assertEquals(aCount, databaseTester
-                    .getTableSize(SERVICE_RULES_TABLE));
+                .getTableSize(SERVICE_RULES_TABLE));
             assertEquals(aCount, databaseTester.getTableSize(USERCOND_TABLE));
             assertEquals(aCount, databaseTester.getTableSize(PATHCOND_TABLE));
             assertEquals(aCount, databaseTester
-                    .getTableSize(OPERATIONCOND_TABLE));
+                .getTableSize(OPERATIONCOND_TABLE));
         } catch (SQLException e) {
             throw new RuntimeException(e);
         }
-
     }
 
-    public void testSchemaExport() { 
+    public void testSchemaExport() {
         Configuration config = new Configuration();
-        for (String mappingFile: new AuthorizationMappingFiles()) { 
-           config.addResource(mappingFile);
+
+        for (String mappingFile : new AuthorizationMappingFiles()) {
+            config.addResource(mappingFile);
         }
-        config.setProperty("hibernate.dialect", MySQL5InnoDBDialect.class.getName());
+
+        config.setProperty("hibernate.dialect", MySQL5InnoDBDialect.class
+            .getName());
+
         SchemaExport exporter = new SchemaExport(config);
         exporter.setOutputFile("target/mysql5.schema.sql");
-        exporter.create(true,false);
+        exporter.create(true, false);
     }
 
     public void testPerformance() {
-
         PersistentAuthorizationService service = (PersistentAuthorizationService) getService();
 
         int n = 1000;
         long time = System.currentTimeMillis();
+
         for (int i = 0; i < n; i++) {
             testFirstRuleGrants();
             resetTestRules();
@@ -180,8 +199,9 @@ public class PersistentAuthorizationServiceTest extends
             resetTestRules();
             testNoRulesSupportResource();
         }
-        LOGGER.info("Executed " + 4 * n + " authorization checks in "
-                + (float) (System.currentTimeMillis() - time) / (float) 1000
-                + " seconds.");
+
+        LOGGER.info("Executed " + (4 * n) + " authorization checks in " +
+            ((float) (System.currentTimeMillis() - time) / (float) 1000) +
+            " seconds.");
     }
 }