cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1575735 - in /cayenne/main/trunk: cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/ cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/audit/ docs/doc/src/main/resources/
Date Sun, 09 Mar 2014 18:13:35 GMT
Author: aadamchik
Date: Sun Mar  9 18:13:35 2014
New Revision: 1575735

URL: http://svn.apache.org/r1575735
Log:
CAY-1904 Simple injection-friendly constructor for AuditableFilter

Modified:
    cayenne/main/trunk/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/AuditableFilter.java
    cayenne/main/trunk/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/audit/AuditableFilterTest.java
    cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt

Modified: cayenne/main/trunk/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/AuditableFilter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/AuditableFilter.java?rev=1575735&r1=1575734&r2=1575735&view=diff
==============================================================================
--- cayenne/main/trunk/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/AuditableFilter.java
(original)
+++ cayenne/main/trunk/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/AuditableFilter.java
Sun Mar  9 18:13:35 2014
@@ -52,15 +52,26 @@ public class AuditableFilter implements 
     protected AuditableProcessor processor;
     protected EntityResolver entityResolver;
 
-    public AuditableFilter(EntityResolver entityResolver, AuditableProcessor processor) {
+    /**
+     * @since 3.2
+     */
+    public AuditableFilter(AuditableProcessor processor) {
         this.processor = processor;
-        this.entityResolver = entityResolver;
         this.entityDescriptors = new ConcurrentHashMap<String, AuditableEntityDescriptor>();
         this.threadAggregator = new ThreadLocal<AuditableAggregator>();
     }
 
+    /**
+     * @deprecated since 3.1 use {@link #AuditableFilter(AuditableProcessor)}
+     *             constructor - EntityResolver will be initialized in 'init'.
+     */
+    @Deprecated
+    public AuditableFilter(EntityResolver entityResolver, AuditableProcessor processor) {
+        this(processor);
+    }
+
     public void init(DataChannel channel) {
-        // noop
+        this.entityResolver = channel.getEntityResolver();
     }
 
     public QueryResponse onQuery(ObjectContext originatingContext, Query query, DataChannelFilterChain
filterChain) {

Modified: cayenne/main/trunk/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/audit/AuditableFilterTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/audit/AuditableFilterTest.java?rev=1575735&r1=1575734&r2=1575735&view=diff
==============================================================================
--- cayenne/main/trunk/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/audit/AuditableFilterTest.java
(original)
+++ cayenne/main/trunk/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/audit/AuditableFilterTest.java
Sun Mar  9 18:13:35 2014
@@ -45,18 +45,24 @@ import org.mockito.stubbing.Answer;
 public class AuditableFilterTest extends TestCase {
 
     private AuditableProcessor processor;
-    private EntityResolver resolver;
     private ServerRuntime runtime;
+    private AuditableFilter filter;
 
     @Override
     protected void setUp() throws Exception {
-        processor = mock(AuditableProcessor.class);
-        resolver = mock(EntityResolver.class);
+
+        EntityResolver resolver = mock(EntityResolver.class);
 
         ObjEntity objectEntity = new ObjEntity("CayenneDataObject");
         when(resolver.lookupObjEntity(any(Object.class))).thenReturn(objectEntity);
 
-        runtime = new ServerRuntime("cayenne-lifecycle.xml");
+        DataChannel channel = mock(DataChannel.class);
+        when(channel.getEntityResolver()).thenReturn(resolver);
+
+        this.processor = mock(AuditableProcessor.class);
+        this.runtime = new ServerRuntime("cayenne-lifecycle.xml");
+        this.filter = new AuditableFilter(processor);
+        this.filter.init(channel);
     }
 
     @Override
@@ -66,7 +72,6 @@ public class AuditableFilterTest extends
 
     public void testInsertAudit() {
 
-        AuditableFilter filter = new AuditableFilter(resolver, processor);
         Persistent audited = mock(Persistent.class);
         filter.insertAudit(audited);
         filter.postSync();
@@ -76,7 +81,6 @@ public class AuditableFilterTest extends
 
     public void testDeleteAudit() {
 
-        AuditableFilter filter = new AuditableFilter(resolver, processor);
         Persistent audited = mock(Persistent.class);
         filter.deleteAudit(audited);
         filter.postSync();
@@ -86,7 +90,6 @@ public class AuditableFilterTest extends
 
     public void testUpdateAudit() {
 
-        AuditableFilter filter = new AuditableFilter(resolver, processor);
         Persistent audited = mock(Persistent.class);
         filter.updateAudit(audited);
         filter.postSync();
@@ -96,8 +99,6 @@ public class AuditableFilterTest extends
 
     public void testUpdateAuditChild() {
 
-        AuditableFilter filter = new AuditableFilter(resolver, processor);
-
         Persistent auditedParent = mock(Persistent.class);
         DataObject audited = new MockAuditableChild();
         audited.setObjectId(new ObjectId("MockAuditableChild", "a", 1));
@@ -119,7 +120,6 @@ public class AuditableFilterTest extends
         handler.relate(audited, auditedParent);
         context.commitChanges();
 
-        AuditableFilter filter = new AuditableFilter(resolver, processor);
         filter.updateAuditChild(audited);
         filter.postSync();
         verify(processor).audit(auditedParent, AuditableOperation.UPDATE);
@@ -127,7 +127,6 @@ public class AuditableFilterTest extends
 
     public void testOnSyncPassThrough() {
 
-        AuditableFilter filter = new AuditableFilter(resolver, processor);
         ObjectContext context = mock(ObjectContext.class);
         GraphDiff changes = mock(GraphDiff.class);
 
@@ -142,7 +141,6 @@ public class AuditableFilterTest extends
 
     public void testOnSyncAuditEventsCollapse() {
 
-        final AuditableFilter filter = new AuditableFilter(resolver, processor);
         ObjectContext context = mock(ObjectContext.class);
         GraphDiff changes = mock(GraphDiff.class);
 

Modified: cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt?rev=1575735&r1=1575734&r2=1575735&view=diff
==============================================================================
--- cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt (original)
+++ cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt Sun Mar  9 18:13:35 2014
@@ -33,6 +33,7 @@ CAY-1894 Support native PK generation us
 CAY-1899 ServerRuntimeBuilder
 CAY-1900 Allow DataNode name to be used as a root of SQLTemplate
 CAY-1901 Config-free ServerRuntime
+CAY-1904 Simple injection-friendly constructor for AuditableFilter
 
 Bug Fixes:
 



Mime
View raw message