From 5bbd2c6e9dcf47e312122a3205c78b676a724e07 Mon Sep 17 00:00:00 2001 From: Erik Brakkee Date: Fri, 30 Apr 2010 19:05:13 +0000 Subject: [PATCH] --- .../authorization/AuthorizationRule.java | 2 - .../authorization/AuthorizationService.java | 64 ++++++++++++++++--- .../DefaultAuthorizationService.java | 19 ++++-- .../authorization/GroupUserCondition.java | 2 +- .../authorization/IsaOperationCondition.java | 2 - .../authorization/OperationCondition.java | 2 - .../security/authorization/PathCondition.java | 2 - .../authorization/RegexpPathCondition.java | 2 - .../authorization/UrlAuthorizationRule.java | 10 +-- .../security/authorization/UserCondition.java | 3 - .../main/java/org/wamblee/usermgt/Group.java | 3 - .../main/java/org/wamblee/usermgt/User.java | 9 +-- .../wamblee/usermgt/InMemoryGroupSetTest.java | 6 +- .../PersistentAuthorizationService.java | 19 +++--- .../usermgt/UserGroupRepositoryComponent.java | 9 +-- .../PersistentAuthorizationServiceTest.java | 18 +----- .../wamblee/usermgt/jpa/JpaGroupSetTest.java | 2 - .../java/org/wamblee/io/SimpleProcess.java | 8 +-- .../persistence/PersistentFactory.java | 1 - .../concurrency/ReadWriteLockTest.java | 1 - .../test/java/org/wamblee/io/TestData.java | 7 +- .../org/wamblee/xml/XslTransformerTest.java | 16 ++--- .../general/spring/SpringBeanFactory.java | 3 - .../jndi/StubInitialContextFactory.java | 3 - .../support/persistence/ExternalDatabase.java | 8 --- .../persistence/TransactionProxyFactory.java | 1 - .../ThreadSpecificProxyFactoryTest.java | 6 +- .../persistence/MyEntityExampleTestBase.java | 12 +--- .../hibernate/DatabaseUtilsTest.java | 20 ------ .../hibernate/MyEntityExampleTest.java | 22 ------- 30 files changed, 105 insertions(+), 177 deletions(-) diff --git a/security/impl/src/main/java/org/wamblee/security/authorization/AuthorizationRule.java b/security/impl/src/main/java/org/wamblee/security/authorization/AuthorizationRule.java index 4e0f5641..a4654cb0 100644 --- a/security/impl/src/main/java/org/wamblee/security/authorization/AuthorizationRule.java +++ b/security/impl/src/main/java/org/wamblee/security/authorization/AuthorizationRule.java @@ -25,8 +25,6 @@ import javax.persistence.InheritanceType; import javax.persistence.Table; import javax.persistence.Version; -import org.wamblee.persistence.Persistent; - import org.wamblee.usermgt.User; /** diff --git a/security/impl/src/main/java/org/wamblee/security/authorization/AuthorizationService.java b/security/impl/src/main/java/org/wamblee/security/authorization/AuthorizationService.java index 6bb5db27..13f4a105 100644 --- a/security/impl/src/main/java/org/wamblee/security/authorization/AuthorizationService.java +++ b/security/impl/src/main/java/org/wamblee/security/authorization/AuthorizationService.java @@ -15,14 +15,55 @@ */ package org.wamblee.security.authorization; -import org.wamblee.persistence.Persistent; +import javax.persistence.DiscriminatorColumn; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.Table; +import javax.persistence.Version; + +import org.wamblee.usermgt.UserAccessor; /** * Service to determine if access to a certain resource is allowed. * * @author Erik Brakkee */ -public interface AuthorizationService extends Persistent { +@Entity +@Table(name = "SEC_AUTH_SVC") +@Inheritance(strategy = InheritanceType.SINGLE_TABLE) +@DiscriminatorColumn(name = "TYPE") +@NamedQueries( + @NamedQuery(name = AuthorizationService.QUERY_FIND_BY_NAME, + query = "select s from AuthorizationService s where s.name = :" + + AuthorizationService.NAME_PARAM) + ) +public abstract class AuthorizationService { + + public static final String QUERY_FIND_BY_NAME = "AuthorizationService.findByName"; + public static final String NAME_PARAM = "name"; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long primaryKey; + + @Version + private int version; + + public AuthorizationService() { + // Empty. + } + + public AuthorizationService(AuthorizationService aSvc) { + primaryKey = aSvc.primaryKey; + version = aSvc.version; + } + /** * Checks whether an operation is allowed on a resource. * @@ -33,16 +74,16 @@ public interface AuthorizationService extends Persistent { * * @return Checks whether the operation is allowed on a resource. */ - boolean isAllowed(Object aResource, Operation aOperation); + public abstract boolean isAllowed(Object aResource, Operation aOperation); - T check(T aResource, Operation aOperation); + public abstract T check(T aResource, Operation aOperation); /** * Gets the authorization rules. * * @return Rules. */ - AuthorizationRule[] getRules(); + public abstract AuthorizationRule[] getRules(); /** * Appends a new authorization rule to the end. @@ -50,7 +91,7 @@ public interface AuthorizationService extends Persistent { * @param aRule * Rule to append. */ - void appendRule(AuthorizationRule aRule); + public abstract void appendRule(AuthorizationRule aRule); /** * Removes a rule. @@ -58,7 +99,7 @@ public interface AuthorizationService extends Persistent { * @param aIndex * Index of the rule to remove. */ - void removeRule(int aIndex); + public abstract void removeRule(int aIndex); /** * Inserts a rule. @@ -68,5 +109,12 @@ public interface AuthorizationService extends Persistent { * @param aRule * Rule to insert. */ - void insertRuleAfter(int aIndex, AuthorizationRule aRule); + public abstract void insertRuleAfter(int aIndex, AuthorizationRule aRule); + + /** + * Sets the user accessor so that the authorization service can get access to the logged in + * user. + * @param aUserAccessor User accessor. + */ + public abstract void setUserAccessor(UserAccessor aUserAccessor); } diff --git a/security/impl/src/main/java/org/wamblee/security/authorization/DefaultAuthorizationService.java b/security/impl/src/main/java/org/wamblee/security/authorization/DefaultAuthorizationService.java index 048d66cc..a086ab47 100644 --- a/security/impl/src/main/java/org/wamblee/security/authorization/DefaultAuthorizationService.java +++ b/security/impl/src/main/java/org/wamblee/security/authorization/DefaultAuthorizationService.java @@ -12,17 +12,18 @@ * 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; +import java.util.ArrayList; +import java.util.List; + +import javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; -import org.wamblee.security.AbstractPersistent; import org.wamblee.usermgt.User; import org.wamblee.usermgt.UserAccessor; -import java.util.ArrayList; -import java.util.List; - /** * Default implementation of an authorization service. To determine whether * access to a resource is allowed, the service consults a number of @@ -33,8 +34,11 @@ import java.util.List; * * @author Erik Brakkee */ -public class DefaultAuthorizationService extends AbstractPersistent implements - AuthorizationService { +@Entity +@DiscriminatorValue("DEFAULT") +public class DefaultAuthorizationService extends AuthorizationService { + + /** * List of ordered authorization rules. */ @@ -79,6 +83,7 @@ public class DefaultAuthorizationService extends AbstractPersistent implements * @param aUserAccessor * User accessor. */ + @Override public void setUserAccessor(UserAccessor aUserAccessor) { userAccessor = aUserAccessor; } diff --git a/security/impl/src/main/java/org/wamblee/security/authorization/GroupUserCondition.java b/security/impl/src/main/java/org/wamblee/security/authorization/GroupUserCondition.java index d4cde7f2..78367db1 100644 --- a/security/impl/src/main/java/org/wamblee/security/authorization/GroupUserCondition.java +++ b/security/impl/src/main/java/org/wamblee/security/authorization/GroupUserCondition.java @@ -20,9 +20,9 @@ import javax.persistence.Column; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; -import org.wamblee.security.AbstractPersistent; import org.wamblee.usermgt.User; + /** * Checks if a user against a specific group. * diff --git a/security/impl/src/main/java/org/wamblee/security/authorization/IsaOperationCondition.java b/security/impl/src/main/java/org/wamblee/security/authorization/IsaOperationCondition.java index 4e927437..9d2b6cb7 100644 --- a/security/impl/src/main/java/org/wamblee/security/authorization/IsaOperationCondition.java +++ b/security/impl/src/main/java/org/wamblee/security/authorization/IsaOperationCondition.java @@ -21,8 +21,6 @@ import javax.persistence.Column; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; -import org.wamblee.security.AbstractPersistent; - /** * Determiens if an operation is a subclass of a specified operation. */ diff --git a/security/impl/src/main/java/org/wamblee/security/authorization/OperationCondition.java b/security/impl/src/main/java/org/wamblee/security/authorization/OperationCondition.java index 3e8f8fb4..34d026dc 100644 --- a/security/impl/src/main/java/org/wamblee/security/authorization/OperationCondition.java +++ b/security/impl/src/main/java/org/wamblee/security/authorization/OperationCondition.java @@ -25,8 +25,6 @@ import javax.persistence.InheritanceType; import javax.persistence.Table; import javax.persistence.Version; -import org.wamblee.persistence.Persistent; - /** * Checks if an operation matches a condition. * diff --git a/security/impl/src/main/java/org/wamblee/security/authorization/PathCondition.java b/security/impl/src/main/java/org/wamblee/security/authorization/PathCondition.java index b1c6670a..51b97f5f 100644 --- a/security/impl/src/main/java/org/wamblee/security/authorization/PathCondition.java +++ b/security/impl/src/main/java/org/wamblee/security/authorization/PathCondition.java @@ -25,8 +25,6 @@ import javax.persistence.InheritanceType; import javax.persistence.Table; import javax.persistence.Version; -import org.wamblee.persistence.Persistent; - /** * Checks if a path satisfies a condition. * diff --git a/security/impl/src/main/java/org/wamblee/security/authorization/RegexpPathCondition.java b/security/impl/src/main/java/org/wamblee/security/authorization/RegexpPathCondition.java index e1fa87d4..fe58cfc7 100644 --- a/security/impl/src/main/java/org/wamblee/security/authorization/RegexpPathCondition.java +++ b/security/impl/src/main/java/org/wamblee/security/authorization/RegexpPathCondition.java @@ -18,8 +18,6 @@ package org.wamblee.security.authorization; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; -import org.wamblee.security.AbstractPersistent; - /** * Condition to check whether a path matches a given regula expression. * diff --git a/security/impl/src/main/java/org/wamblee/security/authorization/UrlAuthorizationRule.java b/security/impl/src/main/java/org/wamblee/security/authorization/UrlAuthorizationRule.java index 0ae744c4..c2834935 100644 --- a/security/impl/src/main/java/org/wamblee/security/authorization/UrlAuthorizationRule.java +++ b/security/impl/src/main/java/org/wamblee/security/authorization/UrlAuthorizationRule.java @@ -15,24 +15,18 @@ */ package org.wamblee.security.authorization; +import static org.wamblee.security.authorization.AuthorizationResult.*; + import javax.persistence.Access; import javax.persistence.AccessType; import javax.persistence.CascadeType; import javax.persistence.Column; -import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.Transient; import org.apache.log4j.Logger; - -import static org.wamblee.security.authorization.AuthorizationResult.DENIED; -import static org.wamblee.security.authorization.AuthorizationResult.GRANTED; -import static org.wamblee.security.authorization.AuthorizationResult.UNDECIDED; -import static org.wamblee.security.authorization.AuthorizationResult.UNSUPPORTED_RESOURCE; - -import org.wamblee.security.AbstractPersistent; import org.wamblee.usermgt.User; /** diff --git a/security/impl/src/main/java/org/wamblee/security/authorization/UserCondition.java b/security/impl/src/main/java/org/wamblee/security/authorization/UserCondition.java index 293869b4..8b6eee94 100644 --- a/security/impl/src/main/java/org/wamblee/security/authorization/UserCondition.java +++ b/security/impl/src/main/java/org/wamblee/security/authorization/UserCondition.java @@ -16,7 +16,6 @@ package org.wamblee.security.authorization; import javax.persistence.DiscriminatorColumn; -import javax.persistence.DiscriminatorType; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; @@ -26,8 +25,6 @@ import javax.persistence.InheritanceType; import javax.persistence.Table; import javax.persistence.Version; -import org.wamblee.persistence.Persistent; - import org.wamblee.usermgt.User; /** diff --git a/security/impl/src/main/java/org/wamblee/usermgt/Group.java b/security/impl/src/main/java/org/wamblee/usermgt/Group.java index ad3e3ec2..87ab4ac7 100644 --- a/security/impl/src/main/java/org/wamblee/usermgt/Group.java +++ b/security/impl/src/main/java/org/wamblee/usermgt/Group.java @@ -25,11 +25,8 @@ import javax.persistence.Id; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.Table; -import javax.persistence.UniqueConstraint; import javax.persistence.Version; -import org.wamblee.security.AbstractPersistent; - /** * Represents a group. * diff --git a/security/impl/src/main/java/org/wamblee/usermgt/User.java b/security/impl/src/main/java/org/wamblee/usermgt/User.java index 00280bcc..7462507a 100644 --- a/security/impl/src/main/java/org/wamblee/usermgt/User.java +++ b/security/impl/src/main/java/org/wamblee/usermgt/User.java @@ -15,13 +15,7 @@ */ package org.wamblee.usermgt; -import org.wamblee.security.AbstractPersistent; -import org.wamblee.security.encryption.MessageDigester; - -import org.wamblee.usermgt.UserMgtException.Reason; - import java.io.Serializable; - import java.util.Set; import java.util.TreeSet; @@ -38,6 +32,9 @@ import javax.persistence.Table; import javax.persistence.Transient; import javax.persistence.Version; +import org.wamblee.security.encryption.MessageDigester; +import org.wamblee.usermgt.UserMgtException.Reason; + /** * Represents a user. The methods for managing the groups of the user have * package scope. Managing the groups of the user should be done through the diff --git a/security/impl/src/test/java/org/wamblee/usermgt/InMemoryGroupSetTest.java b/security/impl/src/test/java/org/wamblee/usermgt/InMemoryGroupSetTest.java index 49b631df..9a52241f 100644 --- a/security/impl/src/test/java/org/wamblee/usermgt/InMemoryGroupSetTest.java +++ b/security/impl/src/test/java/org/wamblee/usermgt/InMemoryGroupSetTest.java @@ -15,12 +15,10 @@ */ package org.wamblee.usermgt; -import junit.framework.TestCase; - -import java.sql.SQLException; - import java.util.Set; +import junit.framework.TestCase; + /** * Tests the inmemory group set. Intended to be subclassed for other * implementations of group set. diff --git a/security/jpatest/src/main/java/org/wamblee/security/authorization/hibernate/PersistentAuthorizationService.java b/security/jpatest/src/main/java/org/wamblee/security/authorization/hibernate/PersistentAuthorizationService.java index e7510bf9..79c0a85d 100644 --- a/security/jpatest/src/main/java/org/wamblee/security/authorization/hibernate/PersistentAuthorizationService.java +++ b/security/jpatest/src/main/java/org/wamblee/security/authorization/hibernate/PersistentAuthorizationService.java @@ -15,20 +15,15 @@ */ package org.wamblee.security.authorization.hibernate; -import org.springframework.orm.hibernate3.HibernateTemplate; - -import org.wamblee.persistence.hibernate.HibernateSupport; +import java.util.List; -import org.wamblee.security.AbstractPersistent; +import org.springframework.orm.hibernate3.HibernateTemplate; import org.wamblee.security.authorization.AuthorizationRule; import org.wamblee.security.authorization.AuthorizationService; import org.wamblee.security.authorization.DefaultAuthorizationService; import org.wamblee.security.authorization.Operation; - import org.wamblee.usermgt.UserAccessor; -import java.util.List; - /** * Authorization service with persistent storage. This is a wrapper for * {@link org.wamblee.security.authorization.DefaultAuthorizationService} which @@ -36,8 +31,7 @@ import java.util.List; * * @author Erik Brakkee */ -public class PersistentAuthorizationService extends AbstractPersistent - implements AuthorizationService { +public class PersistentAuthorizationService extends AuthorizationService { /** * Name of query to find the service by name. */ @@ -100,6 +94,11 @@ public class PersistentAuthorizationService extends AbstractPersistent userAccessor = aAccessor; name = aName; } + + @Override + public void setUserAccessor(UserAccessor aUserAccessor) { + userAccessor = aUserAccessor; + } /** * Initialize service if needed. @@ -222,6 +221,6 @@ public class PersistentAuthorizationService extends AbstractPersistent * Saves any changes to the service state if necessary. */ private void save() { - HibernateSupport.merge(template, service); + // HibernateSupport.merge(template, service); } } diff --git a/security/jpatest/src/main/java/org/wamblee/usermgt/UserGroupRepositoryComponent.java b/security/jpatest/src/main/java/org/wamblee/usermgt/UserGroupRepositoryComponent.java index e133459f..118da989 100644 --- a/security/jpatest/src/main/java/org/wamblee/usermgt/UserGroupRepositoryComponent.java +++ b/security/jpatest/src/main/java/org/wamblee/usermgt/UserGroupRepositoryComponent.java @@ -15,22 +15,17 @@ */ package org.wamblee.usermgt; -import net.sf.ehcache.Ehcache; +import java.util.HashMap; +import java.util.Map; import org.hibernate.SessionFactory; - import org.wamblee.cache.EhCache; - import org.wamblee.system.core.DefaultProvidedInterface; import org.wamblee.system.core.DefaultRequiredInterface; import org.wamblee.system.core.ProvidedInterface; import org.wamblee.system.core.RequiredInterface; import org.wamblee.system.spring.SpringComponent; -import java.util.HashMap; -import java.util.Map; -import java.util.TreeMap; - /** * * @author $author$ diff --git a/security/jpatest/src/test/java/org/wamblee/security/authorization/hibernate/PersistentAuthorizationServiceTest.java b/security/jpatest/src/test/java/org/wamblee/security/authorization/hibernate/PersistentAuthorizationServiceTest.java index 9ba63e34..15fc40e2 100644 --- a/security/jpatest/src/test/java/org/wamblee/security/authorization/hibernate/PersistentAuthorizationServiceTest.java +++ b/security/jpatest/src/test/java/org/wamblee/security/authorization/hibernate/PersistentAuthorizationServiceTest.java @@ -15,39 +15,25 @@ */ package org.wamblee.security.authorization.hibernate; -import org.apache.log4j.Logger; +import java.sql.SQLException; -import org.hibernate.annotations.AccessType; +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; import org.wamblee.system.adapters.ObjectConfiguration; 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. diff --git a/security/jpatest/src/test/java/org/wamblee/usermgt/jpa/JpaGroupSetTest.java b/security/jpatest/src/test/java/org/wamblee/usermgt/jpa/JpaGroupSetTest.java index 49bb6c03..4ece0ba4 100644 --- a/security/jpatest/src/test/java/org/wamblee/usermgt/jpa/JpaGroupSetTest.java +++ b/security/jpatest/src/test/java/org/wamblee/usermgt/jpa/JpaGroupSetTest.java @@ -2,11 +2,9 @@ package org.wamblee.usermgt.jpa; import java.sql.Connection; import java.sql.ResultSet; -import java.sql.SQLException; import org.junit.After; import org.junit.Before; -import org.junit.Ignore; import org.wamblee.support.persistence.JpaTester; import org.wamblee.support.persistence.TransactionProxyFactory; import org.wamblee.support.persistence.DatabaseUtils.JdbcUnitOfWork; diff --git a/support/general/src/main/java/org/wamblee/io/SimpleProcess.java b/support/general/src/main/java/org/wamblee/io/SimpleProcess.java index f0090f53..5e18b16c 100644 --- a/support/general/src/main/java/org/wamblee/io/SimpleProcess.java +++ b/support/general/src/main/java/org/wamblee/io/SimpleProcess.java @@ -15,20 +15,18 @@ */ package org.wamblee.io; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.PrintStream; import java.io.StringWriter; import java.io.Writer; import java.util.Arrays; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + /** * * @author $author$ diff --git a/support/general/src/main/java/org/wamblee/persistence/PersistentFactory.java b/support/general/src/main/java/org/wamblee/persistence/PersistentFactory.java index 7dfb460b..fddc76b9 100644 --- a/support/general/src/main/java/org/wamblee/persistence/PersistentFactory.java +++ b/support/general/src/main/java/org/wamblee/persistence/PersistentFactory.java @@ -18,7 +18,6 @@ package org.wamblee.persistence; import java.io.Serializable; import java.lang.annotation.Annotation; import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.List; import java.util.Map; diff --git a/support/general/src/test/java/org/wamblee/concurrency/ReadWriteLockTest.java b/support/general/src/test/java/org/wamblee/concurrency/ReadWriteLockTest.java index 0cb27433..273abd0e 100644 --- a/support/general/src/test/java/org/wamblee/concurrency/ReadWriteLockTest.java +++ b/support/general/src/test/java/org/wamblee/concurrency/ReadWriteLockTest.java @@ -15,7 +15,6 @@ */ package org.wamblee.concurrency; -import junit.framework.Assert; import junit.framework.TestCase; /** diff --git a/support/general/src/test/java/org/wamblee/io/TestData.java b/support/general/src/test/java/org/wamblee/io/TestData.java index f34b0a00..f7e4b3dc 100644 --- a/support/general/src/test/java/org/wamblee/io/TestData.java +++ b/support/general/src/test/java/org/wamblee/io/TestData.java @@ -15,18 +15,13 @@ */ package org.wamblee.io; -import junit.framework.Assert; - import java.io.ByteArrayInputStream; import java.io.File; -import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; -import java.io.OutputStream; -import java.nio.MappedByteBuffer; -import java.nio.channels.FileChannel; +import junit.framework.Assert; /** * TestData provides a convenient interface for managing test output files. diff --git a/support/general/src/test/java/org/wamblee/xml/XslTransformerTest.java b/support/general/src/test/java/org/wamblee/xml/XslTransformerTest.java index 0c5c2697..bf46528d 100644 --- a/support/general/src/test/java/org/wamblee/xml/XslTransformerTest.java +++ b/support/general/src/test/java/org/wamblee/xml/XslTransformerTest.java @@ -15,16 +15,7 @@ */ package org.wamblee.xml; -import junit.framework.TestCase; - -import org.w3c.dom.Document; - -import org.wamblee.io.ClassPathResource; -import org.wamblee.io.FileSystemUtils; -import org.wamblee.io.InputResource; - import java.io.ByteArrayOutputStream; -import java.io.File; import java.io.IOException; import javax.xml.parsers.DocumentBuilder; @@ -35,6 +26,13 @@ import javax.xml.transform.TransformerException; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; +import junit.framework.TestCase; + +import org.w3c.dom.Document; +import org.wamblee.io.ClassPathResource; +import org.wamblee.io.FileSystemUtils; +import org.wamblee.io.InputResource; + /** * Tests the XSL transformer. * diff --git a/support/spring/src/main/java/org/wamblee/general/spring/SpringBeanFactory.java b/support/spring/src/main/java/org/wamblee/general/spring/SpringBeanFactory.java index a45ae3eb..4ffb43ed 100644 --- a/support/spring/src/main/java/org/wamblee/general/spring/SpringBeanFactory.java +++ b/support/spring/src/main/java/org/wamblee/general/spring/SpringBeanFactory.java @@ -18,12 +18,9 @@ package org.wamblee.general.spring; import org.springframework.beans.BeansException; import org.springframework.beans.factory.access.BeanFactoryLocator; import org.springframework.beans.factory.access.BeanFactoryReference; - import org.springframework.context.access.ContextSingletonBeanFactoryLocator; - import org.wamblee.general.BeanFactory; import org.wamblee.general.BeanFactoryException; -import org.wamblee.general.BeanKernel; /** * Bean factory which uses Spring. This bean factory cannot be configured diff --git a/test/enterprise/src/main/java/org/wamblee/support/jndi/StubInitialContextFactory.java b/test/enterprise/src/main/java/org/wamblee/support/jndi/StubInitialContextFactory.java index 8a9409d0..d65968a2 100644 --- a/test/enterprise/src/main/java/org/wamblee/support/jndi/StubInitialContextFactory.java +++ b/test/enterprise/src/main/java/org/wamblee/support/jndi/StubInitialContextFactory.java @@ -15,12 +15,9 @@ */ package org.wamblee.support.jndi; -import java.util.HashMap; import java.util.Hashtable; -import java.util.Map; import javax.naming.Context; -import javax.naming.InitialContext; import javax.naming.NamingException; import javax.naming.spi.InitialContextFactory; diff --git a/test/enterprise/src/main/java/org/wamblee/support/persistence/ExternalDatabase.java b/test/enterprise/src/main/java/org/wamblee/support/persistence/ExternalDatabase.java index b8167036..32e469ea 100644 --- a/test/enterprise/src/main/java/org/wamblee/support/persistence/ExternalDatabase.java +++ b/test/enterprise/src/main/java/org/wamblee/support/persistence/ExternalDatabase.java @@ -15,18 +15,10 @@ */ package org.wamblee.support.persistence; -import java.util.Arrays; -import java.util.List; import java.util.logging.Logger; import javax.sql.DataSource; -import org.apache.commons.dbcp.ConnectionFactory; -import org.apache.commons.dbcp.DriverManagerConnectionFactory; -import org.apache.commons.dbcp.PoolableConnectionFactory; -import org.apache.commons.dbcp.PoolingDataSource; -import org.apache.commons.pool.impl.GenericObjectPool; - /** * Database that encapsulates connection to an external database. Database * connection details can be configured through system properties and diff --git a/test/enterprise/src/main/java/org/wamblee/support/persistence/TransactionProxyFactory.java b/test/enterprise/src/main/java/org/wamblee/support/persistence/TransactionProxyFactory.java index d3d2884b..e56d34fa 100644 --- a/test/enterprise/src/main/java/org/wamblee/support/persistence/TransactionProxyFactory.java +++ b/test/enterprise/src/main/java/org/wamblee/support/persistence/TransactionProxyFactory.java @@ -20,7 +20,6 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Proxy; -import javax.management.RuntimeErrorException; import javax.persistence.EntityManager; import org.wamblee.support.ThreadSpecificProxyFactory; diff --git a/test/enterprise/src/test/java/org/wamblee/support/ThreadSpecificProxyFactoryTest.java b/test/enterprise/src/test/java/org/wamblee/support/ThreadSpecificProxyFactoryTest.java index cb03843a..0e9dbe48 100644 --- a/test/enterprise/src/test/java/org/wamblee/support/ThreadSpecificProxyFactoryTest.java +++ b/test/enterprise/src/test/java/org/wamblee/support/ThreadSpecificProxyFactoryTest.java @@ -15,13 +15,13 @@ */ package org.wamblee.support; -import javax.xml.ws.Holder; +import static junit.framework.Assert.*; +import static org.mockito.Matchers.*; +import static org.mockito.Mockito.*; import org.junit.After; import org.junit.Before; import org.junit.Test; -import static junit.framework.TestCase.*; -import static org.mockito.Mockito.*; public class ThreadSpecificProxyFactoryTest { diff --git a/test/enterprise/src/test/java/org/wamblee/support/persistence/MyEntityExampleTestBase.java b/test/enterprise/src/test/java/org/wamblee/support/persistence/MyEntityExampleTestBase.java index 7cb81a92..dcefee59 100644 --- a/test/enterprise/src/test/java/org/wamblee/support/persistence/MyEntityExampleTestBase.java +++ b/test/enterprise/src/test/java/org/wamblee/support/persistence/MyEntityExampleTestBase.java @@ -15,25 +15,17 @@ */ package org.wamblee.support.persistence; +import static junit.framework.Assert.*; + import javax.persistence.EntityManager; -import javax.persistence.Persistence; -import javax.sql.DataSource; -import org.dbunit.DataSourceDatabaseTester; -import org.dbunit.DatabaseTestCase; import org.dbunit.IDatabaseTester; import org.dbunit.dataset.ITable; -import org.dbunit.dataset.filter.ITableFilterSimple; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.wamblee.support.persistence.DatabaseUtils; -import org.wamblee.support.persistence.JpaBuilder; -import org.wamblee.support.persistence.JpaTester; import org.wamblee.support.persistence.JpaBuilder.JpaUnitOfWork; -import static junit.framework.Assert.*; - /** * This class shows an example of how to test an entity using jpa. */ diff --git a/test/hibernate/src/test/java/org/wamblee/support/persistence/hibernate/DatabaseUtilsTest.java b/test/hibernate/src/test/java/org/wamblee/support/persistence/hibernate/DatabaseUtilsTest.java index 4032465e..6059c956 100644 --- a/test/hibernate/src/test/java/org/wamblee/support/persistence/hibernate/DatabaseUtilsTest.java +++ b/test/hibernate/src/test/java/org/wamblee/support/persistence/hibernate/DatabaseUtilsTest.java @@ -15,27 +15,7 @@ */ package org.wamblee.support.persistence.hibernate; -import static junit.framework.Assert.assertEquals; - -import org.dbunit.IDatabaseTester; - -import org.dbunit.dataset.ITable; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import org.wamblee.support.persistence.Database; -import org.wamblee.support.persistence.DatabaseBuilder; -import org.wamblee.support.persistence.DatabaseUtils; import org.wamblee.support.persistence.DatabaseUtilsTestBase; -import org.wamblee.support.persistence.JpaBuilder; -import org.wamblee.support.persistence.JpaBuilder.JpaUnitOfWork; -import org.wamblee.support.persistence.PersistenceUnitDescription; - -import javax.persistence.EntityManager; - -import javax.sql.DataSource; /** * diff --git a/test/hibernate/src/test/java/org/wamblee/support/persistence/hibernate/MyEntityExampleTest.java b/test/hibernate/src/test/java/org/wamblee/support/persistence/hibernate/MyEntityExampleTest.java index 6e3e578b..3ac32a5d 100644 --- a/test/hibernate/src/test/java/org/wamblee/support/persistence/hibernate/MyEntityExampleTest.java +++ b/test/hibernate/src/test/java/org/wamblee/support/persistence/hibernate/MyEntityExampleTest.java @@ -15,30 +15,8 @@ */ package org.wamblee.support.persistence.hibernate; -import static junit.framework.Assert.*; - -import org.dbunit.DataSourceDatabaseTester; -import org.dbunit.DatabaseTestCase; -import org.dbunit.IDatabaseTester; - -import org.dbunit.dataset.ITable; -import org.dbunit.dataset.filter.ITableFilterSimple; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import org.wamblee.support.persistence.DatabaseUtils; -import org.wamblee.support.persistence.JpaBuilder; -import org.wamblee.support.persistence.JpaBuilder.JpaUnitOfWork; -import org.wamblee.support.persistence.JpaTester; import org.wamblee.support.persistence.MyEntityExampleTestBase; -import javax.persistence.EntityManager; -import javax.persistence.Persistence; - -import javax.sql.DataSource; - /** * This class shows an example of how to test an entity using jpa. */ -- 2.31.1