sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomm...@apache.org
Subject svn commit: r1770383 - in /sling/trunk/contrib/extensions/distribution/core/src: main/java/org/apache/sling/distribution/monitor/impl/ main/java/org/apache/sling/distribution/trigger/impl/ test/java/org/apache/sling/distribution/trigger/impl/
Date Fri, 18 Nov 2016 14:17:09 GMT
Author: tommaso
Date: Fri Nov 18 14:17:09 2016
New Revision: 1770383

URL: http://svn.apache.org/viewvc?rev=1770383&view=rev
Log:
SLING-6300 - added patch from Simone Tripodi for MBeans testing, minor fixes to JcrEventTriggerTest

Modified:
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/monitor/impl/DistributionPackageMBeanImpl.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/monitor/impl/MonitoringDistributionPackageBuilder.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/trigger/impl/JcrEventDistributionTrigger.java
    sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/trigger/impl/JcrEventDistributionTriggerTest.java

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/monitor/impl/DistributionPackageMBeanImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/monitor/impl/DistributionPackageMBeanImpl.java?rev=1770383&r1=1770382&r2=1770383&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/monitor/impl/DistributionPackageMBeanImpl.java
(original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/monitor/impl/DistributionPackageMBeanImpl.java
Fri Nov 18 14:17:09 2016
@@ -18,40 +18,30 @@
  */
 package org.apache.sling.distribution.monitor.impl;
 
+import org.apache.sling.distribution.packaging.DistributionPackage;
+
 /**
  * Implementation of {@link DistributionPackageMBean}
  */
 public final class DistributionPackageMBeanImpl implements DistributionPackageMBean {
 
-    private final String id;
+    private final DistributionPackage distributionPackage;
 
     private final String type;
 
-    private final String[] paths;
-
-    private final String requestType;
-
-    private final long size;
-
     private final long processingTime;
 
-    public DistributionPackageMBeanImpl(String id,
+    public DistributionPackageMBeanImpl(DistributionPackage distributionPackage,
                                         String type,
-                                        String[] paths,
-                                        String requestType,
-                                        long size,
                                         long processingTime) {
-        this.id = id;
+        this.distributionPackage = distributionPackage;
         this.type = type;
-        this.paths = paths;
-        this.requestType = requestType;
-        this.size = size;
         this.processingTime = processingTime;
     }
 
     @Override
     public String getId() {
-        return id;
+        return distributionPackage.getId();
     }
 
     @Override
@@ -61,17 +51,17 @@ public final class DistributionPackageMB
 
     @Override
     public String[] getPaths() {
-        return paths;
+        return distributionPackage.getInfo().getPaths();
     }
 
     @Override
     public String getRequestType() {
-        return requestType;
+        return distributionPackage.getInfo().getRequestType().name().toLowerCase();
     }
 
     @Override
     public long getSize() {
-        return size;
+        return distributionPackage.getSize();
     }
 
     @Override

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/monitor/impl/MonitoringDistributionPackageBuilder.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/monitor/impl/MonitoringDistributionPackageBuilder.java?rev=1770383&r1=1770382&r2=1770383&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/monitor/impl/MonitoringDistributionPackageBuilder.java
(original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/monitor/impl/MonitoringDistributionPackageBuilder.java
Fri Nov 18 14:17:09 2016
@@ -98,11 +98,8 @@ public final class MonitoringDistributio
     private final void registerDistributionPackageMBean(long start, DistributionPackage distributionPackage)
{
         long processingTime = System.currentTimeMillis() - start;
 
-        DistributionPackageMBean mBean = new DistributionPackageMBeanImpl(distributionPackage.getId(),
+        DistributionPackageMBean mBean = new DistributionPackageMBeanImpl(distributionPackage,
                                                                           wrapped.getType(),
-                                                                          distributionPackage.getInfo().getPaths(),
-                                                                          distributionPackage.getInfo().getRequestType().name(),
-                                                                          distributionPackage.getSize(),
                                                                           processingTime);
 
         Dictionary<String, String> mbeanProps = new Hashtable<String, String>();

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/trigger/impl/JcrEventDistributionTrigger.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/trigger/impl/JcrEventDistributionTrigger.java?rev=1770383&r1=1770382&r2=1770383&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/trigger/impl/JcrEventDistributionTrigger.java
(original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/trigger/impl/JcrEventDistributionTrigger.java
Fri Nov 18 14:17:09 2016
@@ -92,6 +92,7 @@ public class JcrEventDistributionTrigger
 
         for (String pattern : ignoredPathsPatterns) {
             if (path.matches(pattern)) {
+                log.debug("path {} ignored", path);
                 return true;
             }
         }

Modified: sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/trigger/impl/JcrEventDistributionTriggerTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/trigger/impl/JcrEventDistributionTriggerTest.java?rev=1770383&r1=1770382&r2=1770383&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/trigger/impl/JcrEventDistributionTriggerTest.java
(original)
+++ sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/trigger/impl/JcrEventDistributionTriggerTest.java
Fri Nov 18 14:17:09 2016
@@ -40,7 +40,7 @@ public class JcrEventDistributionTrigger
     public void testProcessEventWithoutPathProperty() throws Exception {
         SlingRepository repository = mock(SlingRepository.class);
         Scheduler scheduler = mock(Scheduler.class);
-        ResourceResolverFactory resolverFactory  = mock(ResourceResolverFactory.class);
+        ResourceResolverFactory resolverFactory = mock(ResourceResolverFactory.class);
 
         String path = "/some/path";
         String serviceName = "serviceId";
@@ -54,7 +54,7 @@ public class JcrEventDistributionTrigger
     public void testProcessEventWithPathProperty() throws Exception {
         SlingRepository repository = mock(SlingRepository.class);
         Scheduler scheduler = mock(Scheduler.class);
-        ResourceResolverFactory resolverFactory  = mock(ResourceResolverFactory.class);
+        ResourceResolverFactory resolverFactory = mock(ResourceResolverFactory.class);
 
         String path = "/some/path";
         String serviceName = "serviceId";
@@ -64,4 +64,20 @@ public class JcrEventDistributionTrigger
         DistributionRequest distributionRequest = jcrEventdistributionTrigger.processEvent(event);
         assertNotNull(distributionRequest);
     }
+
+    @Test
+    public void testProcessEventOnIgnoredPattern() throws Exception {
+        SlingRepository repository = mock(SlingRepository.class);
+        Scheduler scheduler = mock(Scheduler.class);
+        ResourceResolverFactory resolverFactory = mock(ResourceResolverFactory.class);
+
+        String path = "/home/users";
+        String serviceName = "serviceId";
+        String[] ignoredPaths = new String[]{"/home/users/\\w"};
+        JcrEventDistributionTrigger jcrEventdistributionTrigger = new JcrEventDistributionTrigger(repository,
scheduler, resolverFactory, path, false, serviceName, ignoredPaths);
+        Event event = mock(Event.class);
+        when(event.getPath()).thenReturn("/home/users/a");
+        DistributionRequest distributionRequest = jcrEventdistributionTrigger.processEvent(event);
+        assertNull(distributionRequest);
+    }
 }
\ No newline at end of file



Mime
View raw message