From 981d2819a828dad943b0bd4f6df818cfae4ab0df Mon Sep 17 00:00:00 2001 From: erik Date: Tue, 11 May 2010 19:59:10 +0000 Subject: [PATCH] --- .../authentication/JaasUserAccessor.java | 8 +--- .../wamblee/security/authentication/User.java | 1 - .../authentication/UserAdminInitializer.java | 5 +-- .../authentication/UserAdministration.java | 3 -- .../UserAdministrationImpl.java | 2 - .../authentication/jpa/JpaUserSet.java | 1 - .../AbstractAuthorizationRule.java | 4 -- .../AbstractAuthorizationService.java | 2 - .../authorization/AbstractUserCondition.java | 2 - .../authorization/AnyUserCondition.java | 1 - .../authorization/AuthorizationRule.java | 1 - .../authorization/GroupUserCondition.java | 1 - .../authorization/UrlAuthorizationRule.java | 4 -- .../security/authorization/UserCondition.java | 2 - .../jpa/JpaAuthorizationService.java | 2 - .../UserAdministrationImplTest.java | 17 +------ .../AuthorizationServiceTest.java | 4 +- .../authorization/TestAuthorizationRule.java | 5 +-- .../authorization/TestUserAccessor.java | 5 --- .../UrlAuthorizationRuleTest.java | 6 +-- .../jpa/JpaUserAdministrationTest.java | 15 ------- .../jpa/JpaAuthorizationServiceTest.java | 10 ----- .../wamblee/persistence/JpaMergeSupport.java | 8 ++-- .../java/org/wamblee/xml/XslTransformer.java | 5 +-- .../java/org/wamblee/test/AssertionUtils.java | 5 +-- .../eclipselink/JndiSessionCustomizer.java | 44 +++++++++---------- .../eclipselink/DatabaseUtilsTest.java | 20 --------- .../eclipselink/MyEntityExampleTest.java | 22 ---------- .../support/persistence/ExternalDatabase.java | 8 ---- .../toplink/JndiSessionCustomizer.java | 44 +++++++++---------- .../toplink/DatabaseUtilsTest.java | 20 --------- .../toplink/MyEntityExampleTest.java | 22 ---------- 32 files changed, 54 insertions(+), 245 deletions(-) diff --git a/security/impl/src/main/java/org/wamblee/security/authentication/JaasUserAccessor.java b/security/impl/src/main/java/org/wamblee/security/authentication/JaasUserAccessor.java index 9148268d..0ac6aa73 100644 --- a/security/impl/src/main/java/org/wamblee/security/authentication/JaasUserAccessor.java +++ b/security/impl/src/main/java/org/wamblee/security/authentication/JaasUserAccessor.java @@ -29,10 +29,6 @@ import javax.security.auth.Subject; * @author Erik Brakkee */ public class JaasUserAccessor implements UserAccessor { - /** - * User administration to use. - */ - private UserAdministration admin; /** * Class of the JAAS user principal. @@ -47,9 +43,7 @@ public class JaasUserAccessor implements UserAccessor { * @param aUserClassName * Class name of the user principal. */ - public JaasUserAccessor(UserAdministration aAdmin, String aUserClassName) { - admin = aAdmin; - + public JaasUserAccessor(String aUserClassName) { try { userPrincipalClass = Class.forName(aUserClassName); diff --git a/security/impl/src/main/java/org/wamblee/security/authentication/User.java b/security/impl/src/main/java/org/wamblee/security/authentication/User.java index 5e6666b7..12db71a3 100644 --- a/security/impl/src/main/java/org/wamblee/security/authentication/User.java +++ b/security/impl/src/main/java/org/wamblee/security/authentication/User.java @@ -20,7 +20,6 @@ import java.util.Set; import java.util.TreeSet; import javax.persistence.CascadeType; -import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; diff --git a/security/impl/src/main/java/org/wamblee/security/authentication/UserAdminInitializer.java b/security/impl/src/main/java/org/wamblee/security/authentication/UserAdminInitializer.java index f716dfbd..3c33319a 100644 --- a/security/impl/src/main/java/org/wamblee/security/authentication/UserAdminInitializer.java +++ b/security/impl/src/main/java/org/wamblee/security/authentication/UserAdminInitializer.java @@ -17,8 +17,6 @@ package org.wamblee.security.authentication; import org.apache.log4j.Logger; -import java.security.NoSuchAlgorithmException; - /** * User administration initializer. It populates the user administration with a * number of groups and users but only in case no users exist. @@ -34,8 +32,7 @@ public class UserAdminInitializer { * */ public UserAdminInitializer(UserAdministration aAdmin, String[] aUsers, - String[] aGroups, String[] aPasswords) throws UserMgtException, - NoSuchAlgorithmException { + String[] aGroups, String[] aPasswords) throws UserMgtException { if ((aUsers.length != aGroups.length) || (aUsers.length != aPasswords.length)) { throw new IllegalArgumentException( diff --git a/security/impl/src/main/java/org/wamblee/security/authentication/UserAdministration.java b/security/impl/src/main/java/org/wamblee/security/authentication/UserAdministration.java index ab8b8f1c..7ed58086 100644 --- a/security/impl/src/main/java/org/wamblee/security/authentication/UserAdministration.java +++ b/security/impl/src/main/java/org/wamblee/security/authentication/UserAdministration.java @@ -16,9 +16,6 @@ package org.wamblee.security.authentication; import java.util.List; -import java.util.Set; - -import org.wamblee.security.authentication.UserMgtException.Reason; /** * Interface for user administration. Manages the users and groups. diff --git a/security/impl/src/main/java/org/wamblee/security/authentication/UserAdministrationImpl.java b/security/impl/src/main/java/org/wamblee/security/authentication/UserAdministrationImpl.java index bbec0055..61505a9f 100644 --- a/security/impl/src/main/java/org/wamblee/security/authentication/UserAdministrationImpl.java +++ b/security/impl/src/main/java/org/wamblee/security/authentication/UserAdministrationImpl.java @@ -18,9 +18,7 @@ package org.wamblee.security.authentication; import static org.wamblee.security.authentication.UserMgtException.Reason.*; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; -import java.util.Set; import org.wamblee.security.authentication.UserMgtException.Reason; diff --git a/security/impl/src/main/java/org/wamblee/security/authentication/jpa/JpaUserSet.java b/security/impl/src/main/java/org/wamblee/security/authentication/jpa/JpaUserSet.java index 167e6f4d..657af65c 100644 --- a/security/impl/src/main/java/org/wamblee/security/authentication/jpa/JpaUserSet.java +++ b/security/impl/src/main/java/org/wamblee/security/authentication/jpa/JpaUserSet.java @@ -24,7 +24,6 @@ import javax.persistence.NoResultException; import javax.persistence.TypedQuery; import org.wamblee.cache.Cache; -import org.wamblee.cache.ZeroCache; import org.wamblee.persistence.JpaMergeSupport; import org.wamblee.security.authentication.AbstractUserSet; import org.wamblee.security.authentication.Group; diff --git a/security/impl/src/main/java/org/wamblee/security/authorization/AbstractAuthorizationRule.java b/security/impl/src/main/java/org/wamblee/security/authorization/AbstractAuthorizationRule.java index 14ce4340..828a8915 100644 --- a/security/impl/src/main/java/org/wamblee/security/authorization/AbstractAuthorizationRule.java +++ b/security/impl/src/main/java/org/wamblee/security/authorization/AbstractAuthorizationRule.java @@ -23,12 +23,8 @@ import javax.persistence.Id; import javax.persistence.Inheritance; import javax.persistence.InheritanceType; import javax.persistence.Table; -import javax.persistence.Transient; import javax.persistence.Version; -import org.wamblee.security.authentication.User; -import org.wamblee.security.authentication.UserAdministration; - /** * Represents an authorization rule to determine whether an operation is allowed * on a resource. diff --git a/security/impl/src/main/java/org/wamblee/security/authorization/AbstractAuthorizationService.java b/security/impl/src/main/java/org/wamblee/security/authorization/AbstractAuthorizationService.java index 6cdb4ca2..79b9d3d0 100644 --- a/security/impl/src/main/java/org/wamblee/security/authorization/AbstractAuthorizationService.java +++ b/security/impl/src/main/java/org/wamblee/security/authorization/AbstractAuthorizationService.java @@ -27,8 +27,6 @@ import javax.persistence.NamedQuery; import javax.persistence.Table; import javax.persistence.Version; -import org.wamblee.security.authentication.UserAccessor; - /** * Service to determine if access to a certain resource is allowed. * diff --git a/security/impl/src/main/java/org/wamblee/security/authorization/AbstractUserCondition.java b/security/impl/src/main/java/org/wamblee/security/authorization/AbstractUserCondition.java index 96952075..74487bce 100644 --- a/security/impl/src/main/java/org/wamblee/security/authorization/AbstractUserCondition.java +++ b/security/impl/src/main/java/org/wamblee/security/authorization/AbstractUserCondition.java @@ -25,8 +25,6 @@ import javax.persistence.InheritanceType; import javax.persistence.Table; import javax.persistence.Version; -import org.wamblee.security.authentication.User; - /** * Condition used to match a user against a specified set of users. * diff --git a/security/impl/src/main/java/org/wamblee/security/authorization/AnyUserCondition.java b/security/impl/src/main/java/org/wamblee/security/authorization/AnyUserCondition.java index 0dfe29ae..88ee8013 100644 --- a/security/impl/src/main/java/org/wamblee/security/authorization/AnyUserCondition.java +++ b/security/impl/src/main/java/org/wamblee/security/authorization/AnyUserCondition.java @@ -19,7 +19,6 @@ package org.wamblee.security.authorization; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; -import org.wamblee.security.authentication.User; import org.wamblee.security.authentication.UserAdministration; /** 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 709591df..37ce1c87 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 @@ -15,7 +15,6 @@ */ package org.wamblee.security.authorization; -import org.wamblee.security.authentication.User; import org.wamblee.security.authentication.UserAdministration; /** 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 8386d35b..f50c3d12 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 @@ -21,7 +21,6 @@ import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; import javax.persistence.Transient; -import org.wamblee.security.authentication.User; import org.wamblee.security.authentication.UserAdministration; 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 3ed810df..c6845755 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 @@ -17,20 +17,16 @@ package org.wamblee.security.authorization; import static org.wamblee.security.authorization.AuthorizationResult.*; -import javax.enterprise.inject.Typed; 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.OneToOne; import javax.persistence.Transient; import org.apache.log4j.Logger; -import org.wamblee.security.authentication.User; import org.wamblee.security.authentication.UserAdministration; /** 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 76387276..af0feb04 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 @@ -15,8 +15,6 @@ */ package org.wamblee.security.authorization; -import org.wamblee.security.authentication.User; -import org.wamblee.security.authentication.UserAdminInitializer; import org.wamblee.security.authentication.UserAdministration; /** diff --git a/security/impl/src/main/java/org/wamblee/security/authorization/jpa/JpaAuthorizationService.java b/security/impl/src/main/java/org/wamblee/security/authorization/jpa/JpaAuthorizationService.java index 333781c6..43bfee33 100644 --- a/security/impl/src/main/java/org/wamblee/security/authorization/jpa/JpaAuthorizationService.java +++ b/security/impl/src/main/java/org/wamblee/security/authorization/jpa/JpaAuthorizationService.java @@ -21,11 +21,9 @@ import javax.persistence.NonUniqueResultException; import org.wamblee.cache.ComputedValue; import org.wamblee.cache.ComputedValue.Computation; -import org.wamblee.persistence.JpaMergeSupport; import org.wamblee.security.authentication.UserAccessor; import org.wamblee.security.authentication.UserAdministration; import org.wamblee.security.authorization.AbstractAuthorizationService; -import org.wamblee.security.authorization.AbstractAuthorizationRule; import org.wamblee.security.authorization.AuthorizationRule; import org.wamblee.security.authorization.AuthorizationService; import org.wamblee.security.authorization.DefaultAuthorizationService; diff --git a/security/impl/src/test/java/org/wamblee/security/authentication/UserAdministrationImplTest.java b/security/impl/src/test/java/org/wamblee/security/authentication/UserAdministrationImplTest.java index 76e7b46f..3bdcbf8d 100644 --- a/security/impl/src/test/java/org/wamblee/security/authentication/UserAdministrationImplTest.java +++ b/security/impl/src/test/java/org/wamblee/security/authentication/UserAdministrationImplTest.java @@ -15,27 +15,14 @@ */ package org.wamblee.security.authentication; +import java.util.List; + import junit.framework.TestCase; import org.apache.log4j.Logger; -import org.junit.Test; - -import org.wamblee.security.authentication.Group; -import org.wamblee.security.authentication.GroupSet; -import org.wamblee.security.authentication.InMemoryGroupSet; -import org.wamblee.security.authentication.InMemoryUserSet; -import org.wamblee.security.authentication.RegexpNameValidator; -import org.wamblee.security.authentication.User; -import org.wamblee.security.authentication.UserAdministration; -import org.wamblee.security.authentication.UserAdministrationImpl; -import org.wamblee.security.authentication.UserMgtException; -import org.wamblee.security.authentication.UserSet; import org.wamblee.security.authentication.UserMgtException.Reason; import org.wamblee.security.encryption.Md5HexMessageDigester; -import java.util.List; -import java.util.Set; - /** * Test of user administration implementation. * diff --git a/security/impl/src/test/java/org/wamblee/security/authorization/AuthorizationServiceTest.java b/security/impl/src/test/java/org/wamblee/security/authorization/AuthorizationServiceTest.java index d79ee55f..3e6f1594 100644 --- a/security/impl/src/test/java/org/wamblee/security/authorization/AuthorizationServiceTest.java +++ b/security/impl/src/test/java/org/wamblee/security/authorization/AuthorizationServiceTest.java @@ -15,11 +15,9 @@ */ package org.wamblee.security.authorization; +import static org.wamblee.security.authorization.AuthorizationResult.*; import junit.framework.TestCase; -import static org.wamblee.security.authorization.AuthorizationResult.DENIED; -import static org.wamblee.security.authorization.AuthorizationResult.GRANTED; -import org.junit.Ignore; import org.wamblee.security.authentication.UserAccessor; import org.wamblee.security.authentication.UserAdministration; diff --git a/security/impl/src/test/java/org/wamblee/security/authorization/TestAuthorizationRule.java b/security/impl/src/test/java/org/wamblee/security/authorization/TestAuthorizationRule.java index 2cae2732..d633840b 100644 --- a/security/impl/src/test/java/org/wamblee/security/authorization/TestAuthorizationRule.java +++ b/security/impl/src/test/java/org/wamblee/security/authorization/TestAuthorizationRule.java @@ -15,15 +15,12 @@ */ package org.wamblee.security.authorization; -import static org.wamblee.security.authorization.AuthorizationResult.DENIED; -import static org.wamblee.security.authorization.AuthorizationResult.GRANTED; +import static org.wamblee.security.authorization.AuthorizationResult.*; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; import javax.persistence.Transient; -import org.wamblee.security.authentication.User; - /** * Test authorization rule that also counts the number of times the rule * matches. diff --git a/security/impl/src/test/java/org/wamblee/security/authorization/TestUserAccessor.java b/security/impl/src/test/java/org/wamblee/security/authorization/TestUserAccessor.java index 73ed12c8..7ff738df 100644 --- a/security/impl/src/test/java/org/wamblee/security/authorization/TestUserAccessor.java +++ b/security/impl/src/test/java/org/wamblee/security/authorization/TestUserAccessor.java @@ -15,17 +15,12 @@ */ package org.wamblee.security.authorization; -import junit.framework.TestCase; - -import org.wamblee.security.authentication.Group; import org.wamblee.security.authentication.InMemoryGroupSet; import org.wamblee.security.authentication.InMemoryUserSet; import org.wamblee.security.authentication.RegexpNameValidator; -import org.wamblee.security.authentication.User; import org.wamblee.security.authentication.UserAccessor; import org.wamblee.security.authentication.UserAdministration; import org.wamblee.security.authentication.UserAdministrationImpl; -import org.wamblee.security.authentication.UserMgtException; import org.wamblee.security.authentication.UserMgtException.Reason; import org.wamblee.security.encryption.Md5HexMessageDigester; diff --git a/security/impl/src/test/java/org/wamblee/security/authorization/UrlAuthorizationRuleTest.java b/security/impl/src/test/java/org/wamblee/security/authorization/UrlAuthorizationRuleTest.java index 8625f9ed..335a606e 100644 --- a/security/impl/src/test/java/org/wamblee/security/authorization/UrlAuthorizationRuleTest.java +++ b/security/impl/src/test/java/org/wamblee/security/authorization/UrlAuthorizationRuleTest.java @@ -15,12 +15,8 @@ */ package org.wamblee.security.authorization; +import static org.wamblee.security.authorization.AuthorizationResult.*; import junit.framework.TestCase; -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.authentication.User; /** * Tests for the {@link org.wamblee.security.authorization.UrlAuthorizationRule} diff --git a/security/jpatest/src/test/java/org/wamblee/security/authentication/jpa/JpaUserAdministrationTest.java b/security/jpatest/src/test/java/org/wamblee/security/authentication/jpa/JpaUserAdministrationTest.java index 8eaa8bec..c5bd6dbb 100644 --- a/security/jpatest/src/test/java/org/wamblee/security/authentication/jpa/JpaUserAdministrationTest.java +++ b/security/jpatest/src/test/java/org/wamblee/security/authentication/jpa/JpaUserAdministrationTest.java @@ -20,23 +20,8 @@ import java.sql.Connection; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.junit.Ignore; -import org.wamblee.cache.EhCache; -import org.wamblee.io.ClassPathResource; -import org.wamblee.security.authentication.GroupSet; -import org.wamblee.security.authentication.NameValidator; -import org.wamblee.security.authentication.RegexpNameValidator; -import org.wamblee.security.authentication.User; import org.wamblee.security.authentication.UserAdministration; -import org.wamblee.security.authentication.UserAdministrationImpl; import org.wamblee.security.authentication.UserAdministrationImplTest; -import org.wamblee.security.authentication.UserSet; -import org.wamblee.security.authentication.jpa.JpaGroupSet; -import org.wamblee.security.authentication.jpa.JpaUserSet; -import org.wamblee.security.encryption.Md5HexMessageDigester; -import org.wamblee.security.encryption.MessageDigester; -import org.wamblee.support.persistence.JpaTester; -import org.wamblee.support.persistence.TransactionProxyFactory; import org.wamblee.support.persistence.DatabaseUtils.JdbcUnitOfWork; /** diff --git a/security/jpatest/src/test/java/org/wamblee/security/authorization/jpa/JpaAuthorizationServiceTest.java b/security/jpatest/src/test/java/org/wamblee/security/authorization/jpa/JpaAuthorizationServiceTest.java index d2053c2c..a6f0ae33 100644 --- a/security/jpatest/src/test/java/org/wamblee/security/authorization/jpa/JpaAuthorizationServiceTest.java +++ b/security/jpatest/src/test/java/org/wamblee/security/authorization/jpa/JpaAuthorizationServiceTest.java @@ -15,20 +15,12 @@ */ package org.wamblee.security.authorization.jpa; -import static org.wamblee.security.authorization.AuthorizationResult.*; - -import javax.persistence.EntityManager; - import org.apache.log4j.Logger; import org.wamblee.security.authentication.jpa.SecurityPersistenceUnit; -import org.wamblee.security.authorization.AllOperation; -import org.wamblee.security.authorization.AuthorizationRule; import org.wamblee.security.authorization.AuthorizationService; import org.wamblee.security.authorization.AuthorizationServiceTest; -import org.wamblee.security.authorization.DefaultAuthorizationService; import org.wamblee.support.persistence.JpaTester; import org.wamblee.support.persistence.TransactionProxyFactory; -import org.wamblee.support.persistence.JpaBuilder.JpaUnitOfWork; /** * Unit test for the persistent authorization service. @@ -53,8 +45,6 @@ public class JpaAuthorizationServiceTest extends AuthorizationServiceTest { private JpaTester jpaTester; - private AuthorizationService authorizationService; - @Override protected void setUp() throws Exception { jpaTester = new JpaTester(new SecurityPersistenceUnit()); diff --git a/support/general/src/main/java/org/wamblee/persistence/JpaMergeSupport.java b/support/general/src/main/java/org/wamblee/persistence/JpaMergeSupport.java index 6230656f..4254dad6 100644 --- a/support/general/src/main/java/org/wamblee/persistence/JpaMergeSupport.java +++ b/support/general/src/main/java/org/wamblee/persistence/JpaMergeSupport.java @@ -29,7 +29,6 @@ import javax.persistence.EntityManager; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wamblee.persistence.PersistentFactory.EntityAccessor; import org.wamblee.reflection.ReflectionUtils; /** @@ -140,11 +139,10 @@ public class JpaMergeSupport { throw new IllegalArgumentException( "Mismatch between primary key values: " + aPersistent + " " + aMerged); - } else { - persistentWrapper.setPersistedVersion(mergedWrapper - .getPersistedVersion()); - persistentWrapper.setPrimaryKey(mergedWrapper.getPrimaryKey()); } + persistentWrapper.setPersistedVersion(mergedWrapper + .getPersistedVersion()); + persistentWrapper.setPrimaryKey(mergedWrapper.getPrimaryKey()); List methods = ReflectionUtils.getAllMethods(aPersistent .getClass(), Object.class); diff --git a/support/general/src/main/java/org/wamblee/xml/XslTransformer.java b/support/general/src/main/java/org/wamblee/xml/XslTransformer.java index 78be8a56..6bd9eb43 100644 --- a/support/general/src/main/java/org/wamblee/xml/XslTransformer.java +++ b/support/general/src/main/java/org/wamblee/xml/XslTransformer.java @@ -85,9 +85,8 @@ public class XslTransformer { } catch (IOException e) { throw new TransformerException(e.getMessage(), e); } - } else { - throw new TransformerException("Cannot read '" + aXslt + "'"); - } + } + throw new TransformerException("Cannot read '" + aXslt + "'"); } return resolver.resolve(aXslt, ""); diff --git a/support/general/src/test/java/org/wamblee/test/AssertionUtils.java b/support/general/src/test/java/org/wamblee/test/AssertionUtils.java index 8c25fc13..9c211b7a 100644 --- a/support/general/src/test/java/org/wamblee/test/AssertionUtils.java +++ b/support/general/src/test/java/org/wamblee/test/AssertionUtils.java @@ -141,9 +141,8 @@ public final class AssertionUtils { LOG.info("Expected exception occured " + t.getMessage()); return; // ok - } else { - throw new RuntimeException(t); - } + } + throw new RuntimeException(t); } } diff --git a/test/eclipselink/src/main/java/org/wamblee/support/persistence/eclipselink/JndiSessionCustomizer.java b/test/eclipselink/src/main/java/org/wamblee/support/persistence/eclipselink/JndiSessionCustomizer.java index ca74ec5c..03beb900 100644 --- a/test/eclipselink/src/main/java/org/wamblee/support/persistence/eclipselink/JndiSessionCustomizer.java +++ b/test/eclipselink/src/main/java/org/wamblee/support/persistence/eclipselink/JndiSessionCustomizer.java @@ -12,7 +12,7 @@ * 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.support.persistence.eclipselink; import org.eclipse.persistence.config.SessionCustomizer; @@ -52,33 +52,29 @@ public class JndiSessionCustomizer implements SessionCustomizer { try { context = new InitialContext(); - if (null != context) { - connector = (JNDIConnector) aSession.getLogin().getConnector(); // possible - // CCE - // Change from COMPOSITE_NAME_LOOKUP to STRING_LOOKUP - // Note: if both jta and non-jta elements exist this will only - // change the first one - and may still result in - // the COMPOSITE_NAME_LOOKUP being set - // Make sure only jta-data-source is in persistence.xml with no - // non-jta-data-source property set + connector = (JNDIConnector) aSession.getLogin().getConnector(); // possible + // CCE + // Change from COMPOSITE_NAME_LOOKUP to STRING_LOOKUP + // Note: if both jta and non-jta elements exist this will only + // change the first one - and may still result in + // the COMPOSITE_NAME_LOOKUP being set + // Make sure only jta-data-source is in persistence.xml with no + // non-jta-data-source property set - connector.setLookupType(JNDIConnector.STRING_LOOKUP); + connector.setLookupType(JNDIConnector.STRING_LOOKUP); - // Or, if you are specifying both JTA and non-JTA in your - // persistence.xml then set both connectors to be safe - JNDIConnector writeConnector = (JNDIConnector) aSession - .getLogin().getConnector(); - writeConnector.setLookupType(JNDIConnector.STRING_LOOKUP); + // Or, if you are specifying both JTA and non-JTA in your + // persistence.xml then set both connectors to be safe + JNDIConnector writeConnector = (JNDIConnector) aSession.getLogin() + .getConnector(); + writeConnector.setLookupType(JNDIConnector.STRING_LOOKUP); - JNDIConnector readConnector = (JNDIConnector) ((DatabaseLogin) ((ServerSession) aSession) - .getReadConnectionPool().getLogin()).getConnector(); - readConnector.setLookupType(JNDIConnector.STRING_LOOKUP); + JNDIConnector readConnector = (JNDIConnector) ((DatabaseLogin) ((ServerSession) aSession) + .getReadConnectionPool().getLogin()).getConnector(); + readConnector.setLookupType(JNDIConnector.STRING_LOOKUP); - System.out.println("JndiSessionCustomizer: configured " + - connector.getName()); - } else { - throw new Exception("JndiSessionCustomizer: Context is null"); - } + System.out.println("JndiSessionCustomizer: configured " + + connector.getName()); } catch (Exception e) { e.printStackTrace(); } diff --git a/test/eclipselink/src/test/java/org/wamblee/support/persistence/eclipselink/DatabaseUtilsTest.java b/test/eclipselink/src/test/java/org/wamblee/support/persistence/eclipselink/DatabaseUtilsTest.java index b2113694..3fbf2f20 100644 --- a/test/eclipselink/src/test/java/org/wamblee/support/persistence/eclipselink/DatabaseUtilsTest.java +++ b/test/eclipselink/src/test/java/org/wamblee/support/persistence/eclipselink/DatabaseUtilsTest.java @@ -15,27 +15,7 @@ */ package org.wamblee.support.persistence.eclipselink; -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/eclipselink/src/test/java/org/wamblee/support/persistence/eclipselink/MyEntityExampleTest.java b/test/eclipselink/src/test/java/org/wamblee/support/persistence/eclipselink/MyEntityExampleTest.java index 84a90d21..e95afb8f 100644 --- a/test/eclipselink/src/test/java/org/wamblee/support/persistence/eclipselink/MyEntityExampleTest.java +++ b/test/eclipselink/src/test/java/org/wamblee/support/persistence/eclipselink/MyEntityExampleTest.java @@ -15,30 +15,8 @@ */ package org.wamblee.support.persistence.eclipselink; -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. */ 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 32e469ea..31bcf1e2 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,9 +15,6 @@ */ package org.wamblee.support.persistence; -import java.util.logging.Logger; - -import javax.sql.DataSource; /** * Database that encapsulates connection to an external database. Database @@ -31,9 +28,6 @@ import javax.sql.DataSource; */ public class ExternalDatabase extends AbstractDatabase { - private static final Logger LOGGER = Logger - .getLogger(ExternalDatabase.class.getName()); - /** * System property/environment variable that defines the database URL. */ @@ -53,8 +47,6 @@ public class ExternalDatabase extends AbstractDatabase { private String itsUser; private String itsPassword; - private DataSource itsDataSource; - public ExternalDatabase() { // Empty } diff --git a/test/toplink-essentials/src/main/java/org/wamblee/support/persistence/toplink/JndiSessionCustomizer.java b/test/toplink-essentials/src/main/java/org/wamblee/support/persistence/toplink/JndiSessionCustomizer.java index bc4a23a0..71d95d6f 100644 --- a/test/toplink-essentials/src/main/java/org/wamblee/support/persistence/toplink/JndiSessionCustomizer.java +++ b/test/toplink-essentials/src/main/java/org/wamblee/support/persistence/toplink/JndiSessionCustomizer.java @@ -12,7 +12,7 @@ * 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.support.persistence.toplink; import oracle.toplink.essentials.jndi.JNDIConnector; @@ -52,33 +52,29 @@ public class JndiSessionCustomizer implements SessionCustomizer { try { context = new InitialContext(); - if (null != context) { - connector = (JNDIConnector) aSession.getLogin().getConnector(); // possible - // CCE - // Change from COMPOSITE_NAME_LOOKUP to STRING_LOOKUP - // Note: if both jta and non-jta elements exist this will only - // change the first one - and may still result in - // the COMPOSITE_NAME_LOOKUP being set - // Make sure only jta-data-source is in persistence.xml with no - // non-jta-data-source property set + connector = (JNDIConnector) aSession.getLogin().getConnector(); // possible + // CCE + // Change from COMPOSITE_NAME_LOOKUP to STRING_LOOKUP + // Note: if both jta and non-jta elements exist this will only + // change the first one - and may still result in + // the COMPOSITE_NAME_LOOKUP being set + // Make sure only jta-data-source is in persistence.xml with no + // non-jta-data-source property set - connector.setLookupType(JNDIConnector.STRING_LOOKUP); + connector.setLookupType(JNDIConnector.STRING_LOOKUP); - // Or, if you are specifying both JTA and non-JTA in your - // persistence.xml then set both connectors to be safe - JNDIConnector writeConnector = (JNDIConnector) aSession - .getLogin().getConnector(); - writeConnector.setLookupType(JNDIConnector.STRING_LOOKUP); + // Or, if you are specifying both JTA and non-JTA in your + // persistence.xml then set both connectors to be safe + JNDIConnector writeConnector = (JNDIConnector) aSession.getLogin() + .getConnector(); + writeConnector.setLookupType(JNDIConnector.STRING_LOOKUP); - JNDIConnector readConnector = (JNDIConnector) ((DatabaseLogin) ((ServerSession) aSession) - .getReadConnectionPool().getLogin()).getConnector(); - readConnector.setLookupType(JNDIConnector.STRING_LOOKUP); + JNDIConnector readConnector = (JNDIConnector) ((DatabaseLogin) ((ServerSession) aSession) + .getReadConnectionPool().getLogin()).getConnector(); + readConnector.setLookupType(JNDIConnector.STRING_LOOKUP); - System.out.println("JndiSessionCustomizer: configured " + - connector.getName()); - } else { - throw new Exception("JndiSessionCustomizer: Context is null"); - } + System.out.println("JndiSessionCustomizer: configured " + + connector.getName()); } catch (Exception e) { e.printStackTrace(); } diff --git a/test/toplink-essentials/src/test/java/org/wamblee/support/persistence/toplink/DatabaseUtilsTest.java b/test/toplink-essentials/src/test/java/org/wamblee/support/persistence/toplink/DatabaseUtilsTest.java index 63974a33..c45ea93c 100644 --- a/test/toplink-essentials/src/test/java/org/wamblee/support/persistence/toplink/DatabaseUtilsTest.java +++ b/test/toplink-essentials/src/test/java/org/wamblee/support/persistence/toplink/DatabaseUtilsTest.java @@ -15,27 +15,7 @@ */ package org.wamblee.support.persistence.toplink; -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/toplink-essentials/src/test/java/org/wamblee/support/persistence/toplink/MyEntityExampleTest.java b/test/toplink-essentials/src/test/java/org/wamblee/support/persistence/toplink/MyEntityExampleTest.java index ebd299a9..8d60e75e 100644 --- a/test/toplink-essentials/src/test/java/org/wamblee/support/persistence/toplink/MyEntityExampleTest.java +++ b/test/toplink-essentials/src/test/java/org/wamblee/support/persistence/toplink/MyEntityExampleTest.java @@ -15,30 +15,8 @@ */ package org.wamblee.support.persistence.toplink; -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