(no commit message)
authorErik Brakkee <erik@brakkee.org>
Tue, 11 May 2010 19:59:10 +0000 (19:59 +0000)
committerErik Brakkee <erik@brakkee.org>
Tue, 11 May 2010 19:59:10 +0000 (19:59 +0000)
32 files changed:
security/impl/src/main/java/org/wamblee/security/authentication/JaasUserAccessor.java
security/impl/src/main/java/org/wamblee/security/authentication/User.java
security/impl/src/main/java/org/wamblee/security/authentication/UserAdminInitializer.java
security/impl/src/main/java/org/wamblee/security/authentication/UserAdministration.java
security/impl/src/main/java/org/wamblee/security/authentication/UserAdministrationImpl.java
security/impl/src/main/java/org/wamblee/security/authentication/jpa/JpaUserSet.java
security/impl/src/main/java/org/wamblee/security/authorization/AbstractAuthorizationRule.java
security/impl/src/main/java/org/wamblee/security/authorization/AbstractAuthorizationService.java
security/impl/src/main/java/org/wamblee/security/authorization/AbstractUserCondition.java
security/impl/src/main/java/org/wamblee/security/authorization/AnyUserCondition.java
security/impl/src/main/java/org/wamblee/security/authorization/AuthorizationRule.java
security/impl/src/main/java/org/wamblee/security/authorization/GroupUserCondition.java
security/impl/src/main/java/org/wamblee/security/authorization/UrlAuthorizationRule.java
security/impl/src/main/java/org/wamblee/security/authorization/UserCondition.java
security/impl/src/main/java/org/wamblee/security/authorization/jpa/JpaAuthorizationService.java
security/impl/src/test/java/org/wamblee/security/authentication/UserAdministrationImplTest.java
security/impl/src/test/java/org/wamblee/security/authorization/AuthorizationServiceTest.java
security/impl/src/test/java/org/wamblee/security/authorization/TestAuthorizationRule.java
security/impl/src/test/java/org/wamblee/security/authorization/TestUserAccessor.java
security/impl/src/test/java/org/wamblee/security/authorization/UrlAuthorizationRuleTest.java
security/jpatest/src/test/java/org/wamblee/security/authentication/jpa/JpaUserAdministrationTest.java
security/jpatest/src/test/java/org/wamblee/security/authorization/jpa/JpaAuthorizationServiceTest.java
support/general/src/main/java/org/wamblee/persistence/JpaMergeSupport.java
support/general/src/main/java/org/wamblee/xml/XslTransformer.java
support/general/src/test/java/org/wamblee/test/AssertionUtils.java
test/eclipselink/src/main/java/org/wamblee/support/persistence/eclipselink/JndiSessionCustomizer.java
test/eclipselink/src/test/java/org/wamblee/support/persistence/eclipselink/DatabaseUtilsTest.java
test/eclipselink/src/test/java/org/wamblee/support/persistence/eclipselink/MyEntityExampleTest.java
test/enterprise/src/main/java/org/wamblee/support/persistence/ExternalDatabase.java
test/toplink-essentials/src/main/java/org/wamblee/support/persistence/toplink/JndiSessionCustomizer.java
test/toplink-essentials/src/test/java/org/wamblee/support/persistence/toplink/DatabaseUtilsTest.java
test/toplink-essentials/src/test/java/org/wamblee/support/persistence/toplink/MyEntityExampleTest.java

index 9148268df41427b39b6ce9c7a730f0e904d97129..0ac6aa730073d36f9f89654809b1d04f29a24b31 100644 (file)
@@ -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);
 
index 5e6666b7be9027520440e390c8fd6d4c9ab5d90d..12db71a3de98ebf65d1e29ac3718032aa0194a59 100644 (file)
@@ -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;
index f716dfbdad9e720fa202f758653432e64ed59fc1..3c33319aa58ee3915d65efe80274dc466dfac85d 100644 (file)
@@ -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(
index ab8b8f1c82fad8cbd421b914b94be5ab613d918a..7ed58086f5083a3532e34937552be296fb9bcab0 100644 (file)
@@ -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.
index bbec005525182f1e277a17c035ad6a68c7a2c058..61505a9fa627d705f3cc0cc8715eaff1fd0fbbfa 100644 (file)
@@ -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;
 
index 167e6f4d8472aaee8d54fb29683447f715be03d2..657af65c48c93751dce2760d2bf43659a1d9f73c 100644 (file)
@@ -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;
index 14ce434089b18163472428540101e8484b15c385..828a89151e51c9e41185261f9ab8f575b87fd6e9 100644 (file)
@@ -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.
index 6cdb4ca24f162f1375294f48b215486654bae97f..79b9d3d0df5b8a55ef0c1cf52f8b7fadb87d55a1 100644 (file)
@@ -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.
  * 
index 96952075c69370a3214e47ed6093a107b32bb55b..74487bce9e67d56ff894924909d4a7784cb7450c 100644 (file)
@@ -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.
  * 
index 0dfe29ae1c403ad1b39adc35b73aae568049f861..88ee8013ce8c83f6e8a8a3637896451f6593e52f 100644 (file)
@@ -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;
 
 /**
index 709591df65f9abcd244b4e7fb2f031fc0c4147ed..37ce1c872ac62980162d37321b9694b33e7d446d 100644 (file)
@@ -15,7 +15,6 @@
  */
 package org.wamblee.security.authorization;
 
-import org.wamblee.security.authentication.User;
 import org.wamblee.security.authentication.UserAdministration;
 
 /**
index 8386d35b1f1859ac8030ecdc0aa399ee1ddcd566..f50c3d120bfb38468cbe115c44b23928f72b4052 100644 (file)
@@ -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;
 
 
index 3ed810df9a0a10699acc182f862d7c361c8508e1..c68457559a42892ca2e3aa8739ee34ea88e41b73 100644 (file)
@@ -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;
 
 /**
index 76387276280ab29fda7c576ab746c823ad0e6ee6..af0feb041809d95b08c5f419f62396d8a2aefa48 100644 (file)
@@ -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;
 
 /**
index 333781c62e19bfa40ce0f2195d302bd870dfce88..43bfee33671b793bd320dc2367bf515c2f10e85c 100644 (file)
@@ -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;
index 76e7b46f222640dde84bd4ea7ec29dc5d101da6f..3bdcbf8de9b11636dcadb9bbfb287befc9513895 100644 (file)
  */
 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.
  * 
index d79ee55f7c2bc77df66a355842be45c9d31bd634..3e6f159412448e29d7d9e199dec025919e5f5c59 100644 (file)
  */ 
 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;
 
index 2cae273264ea86f705bb8f34d382ab3be46d27f9..d633840be746e453d659729fbb17c604e5f64a23 100644 (file)
  */ 
 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.
index 73ed12c830315627a5485936538939f3c6564ed4..7ff738dfeef4606268aa3097443c7275a3e7abbe 100644 (file)
  */ 
 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;
 
index 8625f9edddfcb34c363f4d2fc018f86ab22bd652..335a606e3f83672dc3e331e483f3e78c1f26ef13 100644 (file)
  */ 
 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}
index 8eaa8becfe14909f48c75307b64c63cb7c1ee55d..c5bd6dbb3332d1f427bd4328151f609d1dbf91b8 100644 (file)
@@ -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;
 
 /**
index d2053c2c5f42f1ee0f88cda40fd8d1dd4f719ba3..a6f0ae333d791a5f0a54641af5dc1626992fab0f 100644 (file)
  */
 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());
index 6230656f0f3933a37a879849ded6418c62c83d46..4254dad6649820ad5c8d2ee295c245ec2e40e09e 100644 (file)
@@ -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<Method> methods = ReflectionUtils.getAllMethods(aPersistent
             .getClass(), Object.class);
index 78be8a567d9ae40296c98febcb6d537408d2faf5..6bd9eb43c6499bad1d2bcd997e744bb3052f0856 100644 (file)
@@ -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, "");
index 8c25fc13f6963646653ee3cab510c6d622899b2e..9c211b7ad5ea8ce4a9afd66556600f56f875ae52 100644 (file)
@@ -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);
         }
     }
 
index ca74ec5cebc45c908098524540171e1e0eff44eb..03beb9005f763d7850c0cb56656f2028508d7272 100644 (file)
@@ -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();
         }
index b211369460f506155bea71f7c6fbb0fbdf5398bd..3fbf2f20927b2e1d83ecce994074e0b87e337135 100644 (file)
  */ 
 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;
 
 /**
  * 
index 84a90d21e7bc40dffbd8cd45ab7f05b53fe5f3eb..e95afb8fc556b2432300538f36274e6b3a809e7b 100644 (file)
  */ 
 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.
  */
index 32e469ea3a54f4be2bcc0ae9272d7d233986ff89..31bcf1e2e090bf2e7522b0677e557086fd1728d0 100644 (file)
@@ -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
     }
index bc4a23a091f8b8bd57d5c2869d07524daa518b5c..71d95d6f13c66e428e2e4e76e49036c4ea76f71d 100644 (file)
@@ -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();
         }
index 63974a33de28963e2405567b8e6e34cda1c3ebf0..c45ea93ce0fe272f6f4ec85c981635ec37074203 100644 (file)
  */ 
 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;
 
 /**
  * 
index ebd299a9b1248c05bc09965c13cdceded7675cb1..8d60e75ef36d299dbe1c42f3875a737c09f9791d 100644 (file)
  */ 
 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.
  */