incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomm...@apache.org
Subject svn commit: r1564382 [2/2] - in /sling/trunk/contrib/extensions/replication/src: main/java/org/apache/sling/replication/agent/ main/java/org/apache/sling/replication/agent/impl/ main/java/org/apache/sling/replication/queue/impl/jobhandling/ main/java/o...
Date Tue, 04 Feb 2014 17:16:36 GMT
Added: sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/impl/RepositoryTransportHandlerFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/impl/RepositoryTransportHandlerFactory.java?rev=1564382&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/impl/RepositoryTransportHandlerFactory.java
(added)
+++ sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/impl/RepositoryTransportHandlerFactory.java
Tue Feb  4 17:16:36 2014
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, 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.apache.sling.replication.transport.impl;
+
+import org.apache.felix.scr.annotations.*;
+import org.apache.sling.jcr.api.SlingRepository;
+import org.apache.sling.replication.agent.ReplicationAgentConfiguration;
+import org.apache.sling.replication.communication.ReplicationEndpoint;
+import org.apache.sling.replication.event.ReplicationEventFactory;
+import org.apache.sling.replication.transport.TransportHandler;
+import org.apache.sling.replication.transport.authentication.TransportAuthenticationProvider;
+import org.apache.sling.replication.transport.authentication.TransportAuthenticationProviderFactory;
+import org.apache.sling.replication.transport.authentication.impl.RepositoryTransportAuthenticationProviderFactory;
+import org.osgi.framework.BundleContext;
+
+import javax.jcr.Session;
+import java.util.Dictionary;
+import java.util.Map;
+
+@Component(metatype = true,
+        label = "Replication Transport Handler Factory - Repository",
+        description = "OSGi configuration based RepositoryTransportHandler service factory",
+        name = RepositoryTransportHandlerFactory.SERVICE_PID,
+        configurationFactory = true,
+        specVersion = "1.1",
+        policy = ConfigurationPolicy.REQUIRE)
+public class RepositoryTransportHandlerFactory extends AbstractTransportHandlerFactory {
+    static final String SERVICE_PID = "org.apache.sling.replication.transport.impl.RepositoryTransportHandlerFactory";
+
+    private static final String DEFAULT_AUTHENTICATION_FACTORY = "(name=" + RepositoryTransportAuthenticationProviderFactory.TYPE
+ ")";
+
+
+    @Property(boolValue = true)
+    private static final String ENABLED = "enabled";
+
+    @Property
+    private static final String NAME = "name";
+
+    @Property(cardinality = 1000)
+    private static final String ENDPOINT = ReplicationAgentConfiguration.ENDPOINT;
+
+    @Property(name = ReplicationAgentConfiguration.TRANSPORT_AUTHENTICATION_FACTORY, value
= DEFAULT_AUTHENTICATION_FACTORY)
+    @Reference(name = "TransportAuthenticationProviderFactory", target = DEFAULT_AUTHENTICATION_FACTORY,
policy = ReferencePolicy.DYNAMIC)
+    private TransportAuthenticationProviderFactory transportAuthenticationProviderFactory;
+
+    @Property
+    private static final String AUTHENTICATION_PROPERTIES = ReplicationAgentConfiguration.AUTHENTICATION_PROPERTIES;
+
+
+    @Reference
+    private SlingRepository repository;
+
+    @Reference
+    private ReplicationEventFactory replicationEventFactory;
+
+    @Override
+    protected TransportHandler createTransportHandler(Map<String, ?> config,
+                                                      Dictionary<String, Object> props,
+                                                      TransportAuthenticationProvider transportAuthenticationProvider,
+                                                      ReplicationEndpoint[] endpoints, TransportEndpointStrategyType
endpointStrategyType) {
+
+
+        return new RepositoryTransportHandler(repository,
+                replicationEventFactory,
+                (TransportAuthenticationProvider<SlingRepository,Session>) transportAuthenticationProvider,
+                endpoints);
+    }
+
+    @Override
+    protected TransportAuthenticationProviderFactory getAuthenticationFactory() {
+        return transportAuthenticationProviderFactory;
+    }
+
+    @Activate
+    protected void activate(BundleContext context, Map<String, ?> config) throws Exception
{
+        super.activate(context, config);
+    }
+
+    @Deactivate
+    protected void deactivate() {
+        super.deactivate();
+    }
+}

Propchange: sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/impl/RepositoryTransportHandlerFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/impl/TransportEndpointStrategyType.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/impl/TransportEndpointStrategyType.java?rev=1564382&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/impl/TransportEndpointStrategyType.java
(added)
+++ sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/impl/TransportEndpointStrategyType.java
Tue Feb  4 17:16:36 2014
@@ -0,0 +1,7 @@
+package org.apache.sling.replication.transport.impl;
+
+public enum TransportEndpointStrategyType {
+    FirstSuccessful,
+    OneSuccessful,
+    All
+}

Propchange: sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/impl/TransportEndpointStrategyType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config.author/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-publish-reverse.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config.author/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-publish-reverse.json?rev=1564382&r1=1564381&r2=1564382&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config.author/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-publish-reverse.json
(original)
+++ sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config.author/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-publish-reverse.json
Tue Feb  4 17:16:36 2014
@@ -1,12 +1,9 @@
 {
     "jcr:primaryType" : "sling:OsgiConfig",
     "name" : "publish-reverse",
-    "endpoint" : "http://localhost:4503/system/replication/agent/reverserepo",
-    "TransportHandler.target" : "(name=poll)", 
+    "TransportHandler.target" : "(name=http-publish-poll)",
     "ReplicationPackageBuilder.target" : "(name=void)",
     "ReplicationQueueProvider.target" : "(name=sjh)",
-    "TransportAuthenticationProviderFactory.target" : "(name=user)",
-    "authentication.properties" : ["user=admin","password=admin"],
     "ReplicationQueueDistributionStrategy.target" : "(name=single)",
     "rules" : ["scheduled poll every 30 sec"]
 }

Modified: sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config.author/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-publish.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config.author/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-publish.json?rev=1564382&r1=1564381&r2=1564382&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config.author/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-publish.json
(original)
+++ sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config.author/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-publish.json
Tue Feb  4 17:16:36 2014
@@ -1,11 +1,8 @@
 {
     "jcr:primaryType" : "sling:OsgiConfig",
     "name" : "publish",
-    "endpoint" : "http://localhost:4503/system/replication/receive",
-    "TransportHandler.target" : "(name=http)", 
+    "TransportHandler.target" : "(name=http-publish-receive)",
     "ReplicationPackageBuilder.target" : "(name=vlt)",
     "ReplicationQueueProvider.target" : "(name=sjh)",
-    "TransportAuthenticationProviderFactory.target" : "(name=user)",
-    "authentication.properties" : ["user=admin","password=admin"],
     "ReplicationQueueDistributionStrategy.target" : "(name=single)"
 }

Added: sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config.author/org.apache.sling.replication.transport.impl.HttpTransportHandlerFactory-http-publish-receive.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config.author/org.apache.sling.replication.transport.impl.HttpTransportHandlerFactory-http-publish-receive.json?rev=1564382&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config.author/org.apache.sling.replication.transport.impl.HttpTransportHandlerFactory-http-publish-receive.json
(added)
+++ sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config.author/org.apache.sling.replication.transport.impl.HttpTransportHandlerFactory-http-publish-receive.json
Tue Feb  4 17:16:36 2014
@@ -0,0 +1,7 @@
+{
+    "jcr:primaryType" : "sling:OsgiConfig",
+    "name" : "http-publish-receive",
+    "TransportAuthenticationProviderFactory.target" : "(name=user)",
+    "authentication.properties" : ["user=admin","password=admin"],
+    "endpoints" : [ "http://localhost:4503/system/replication/receive" ]
+}
\ No newline at end of file

Added: sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config.author/org.apache.sling.replication.transport.impl.PollingTransportHandlerFactory-http-publish-poll.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config.author/org.apache.sling.replication.transport.impl.PollingTransportHandlerFactory-http-publish-poll.json?rev=1564382&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config.author/org.apache.sling.replication.transport.impl.PollingTransportHandlerFactory-http-publish-poll.json
(added)
+++ sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config.author/org.apache.sling.replication.transport.impl.PollingTransportHandlerFactory-http-publish-poll.json
Tue Feb  4 17:16:36 2014
@@ -0,0 +1,8 @@
+{
+    "jcr:primaryType" : "sling:OsgiConfig",
+    "name" : "http-publish-poll",
+    "poll.items" : 10,
+    "TransportAuthenticationProviderFactory.target" : "(name=user)",
+    "authentication.properties" : ["user=admin","password=admin"],
+    "endpoints" : [ "http://localhost:4503/system/replication/agent/reverserepo" ]
+}
\ No newline at end of file

Added: sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config.publish/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-author.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config.publish/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-author.json?rev=1564382&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config.publish/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-author.json
(added)
+++ sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config.publish/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-author.json
Tue Feb  4 17:16:36 2014
@@ -0,0 +1,10 @@
+{
+    "jcr:primaryType" : "sling:OsgiConfig",
+    "name" : "author",
+    "TransportHandler.target" : "(name=http-author-receive)",
+    "ReplicationPackageBuilder.target" : "(name=vlt)",
+    "ReplicationQueueProvider.target" : "(name=sjh)",
+    "ReplicationQueueDistributionStrategy.target" : "(name=error)",
+    "rules" : ["trigger on path: /content/usergenerated"],
+    "enabled" : false
+}

Added: sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config.publish/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-cache-flush.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config.publish/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-cache-flush.json?rev=1564382&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config.publish/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-cache-flush.json
(added)
+++ sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config.publish/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-cache-flush.json
Tue Feb  4 17:16:36 2014
@@ -0,0 +1,11 @@
+{
+    "jcr:primaryType" : "sling:OsgiConfig",
+    "name" : "cache-flush",
+    "TransportHandler.target" : "(name=http-cache-flush)",
+    "useAggregatePaths" : false,
+    "ReplicationPackageBuilder.target" : "(name=void)",
+    "ReplicationQueueProvider.target" : "(name=simple)",
+    "ReplicationQueueDistributionStrategy.target" : "(name=single)",
+    "rules" : ["trigger on path: /content/usergenerated"],
+    "enabled" : false
+}

Added: sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config.publish/org.apache.sling.replication.transport.impl.HttpTransportHandlerFactory-http-author-receive.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config.publish/org.apache.sling.replication.transport.impl.HttpTransportHandlerFactory-http-author-receive.json?rev=1564382&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config.publish/org.apache.sling.replication.transport.impl.HttpTransportHandlerFactory-http-author-receive.json
(added)
+++ sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config.publish/org.apache.sling.replication.transport.impl.HttpTransportHandlerFactory-http-author-receive.json
Tue Feb  4 17:16:36 2014
@@ -0,0 +1,7 @@
+{
+    "jcr:primaryType" : "sling:OsgiConfig",
+    "name" : "http-author-receive",
+    "TransportAuthenticationProviderFactory.target" : "(name=user)",
+    "authentication.properties" : ["user=admin","password=admin"],
+    "endpoints" : [ "http://localhost:4502/system/replication/receive" ]
+}
\ No newline at end of file

Added: sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config.publish/org.apache.sling.replication.transport.impl.HttpTransportHandlerFactory-http-cache-flush.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config.publish/org.apache.sling.replication.transport.impl.HttpTransportHandlerFactory-http-cache-flush.json?rev=1564382&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config.publish/org.apache.sling.replication.transport.impl.HttpTransportHandlerFactory-http-cache-flush.json
(added)
+++ sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config.publish/org.apache.sling.replication.transport.impl.HttpTransportHandlerFactory-http-cache-flush.json
Tue Feb  4 17:16:36 2014
@@ -0,0 +1,13 @@
+{
+    "jcr:primaryType" : "sling:OsgiConfig",
+    "name" : "http-cache-flush",
+    "useCustomHeaders" : true,
+    "customHeaders" : [
+            "Path: {path}",
+            "add -> Action : REFRESH",
+            "delete -> Change : REMOVE" ],
+    "useCustomBody": true,
+    "customBody" : "",
+    "TransportAuthenticationProviderFactory.target" : "(name=nop)",
+    "endpoints" : [ "http://localhost:8000/invalidatecache" ]
+}
\ No newline at end of file

Modified: sling/trunk/contrib/extensions/replication/src/test/java/org/apache/sling/replication/agent/impl/ReplicationAgentResourceProviderTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/test/java/org/apache/sling/replication/agent/impl/ReplicationAgentResourceProviderTest.java?rev=1564382&r1=1564381&r2=1564382&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/test/java/org/apache/sling/replication/agent/impl/ReplicationAgentResourceProviderTest.java
(original)
+++ sling/trunk/contrib/extensions/replication/src/test/java/org/apache/sling/replication/agent/impl/ReplicationAgentResourceProviderTest.java
Tue Feb  4 17:16:36 2014
@@ -18,25 +18,21 @@
  */
 package org.apache.sling.replication.agent.impl;
 
+import javax.jcr.Session;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.replication.agent.AgentConfigurationException;
 import org.apache.sling.replication.agent.ReplicationAgent;
 import org.apache.sling.replication.agent.ReplicationAgentConfiguration;
 import org.apache.sling.replication.agent.ReplicationAgentConfigurationManager;
-import org.hamcrest.Description;
-import org.hamcrest.Matcher;
 import org.junit.Test;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceReference;
 
-import javax.jcr.Session;
-
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
-import static org.mockito.Matchers.*;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
@@ -56,20 +52,6 @@ public class ReplicationAgentResourcePro
         assertNull(resource);
     }
 
-//    @Test
-//    public void testAgentResolutionWithSpecifiedAgentService() throws Exception {
-//        String path = "publish";
-//        BundleContext context = mock(BundleContext.class);
-//        createMockedReplicationAgent(path, context);
-//        ReplicationAgentResourceProvider agentResourceProvider = new ReplicationAgentResourceProvider();
-//        agentResourceProvider.activate(context);
-//        ResourceResolver resourceResolver = mock(ResourceResolver.class);
-//
-//        Resource resource = agentResourceProvider.getResource(resourceResolver, path);
-//        assertNotNull(resource);
-//        assertEquals(ReplicationAgentResource.RESOURCE_TYPE, resource.getResourceType());
-//    }
-
     @Test
     public void testAgentConfigurationResolutionWithSpecifiedAgentService() throws Exception
{
         String path = ReplicationAgentConfigurationResource.BASE_PATH  + "/publish";
@@ -107,7 +89,7 @@ public class ReplicationAgentResourcePro
         String filter = "(name=" + path + ")";
         when(context.getServiceReferences(ReplicationAgent.class.getName(), filter)).thenReturn(
                         agentServiceReferences);
-        SimpleReplicationAgent replicationAgent = new SimpleReplicationAgent(path, null,
null, true,
+        SimpleReplicationAgent replicationAgent = new SimpleReplicationAgent(path, null,
true,
                         null, null, null, null, null);
         when(context.getService(serviceReference)).thenReturn(replicationAgent);
         return replicationAgent;

Modified: sling/trunk/contrib/extensions/replication/src/test/java/org/apache/sling/replication/agent/impl/ReplicationAgentServiceFactoryTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/test/java/org/apache/sling/replication/agent/impl/ReplicationAgentServiceFactoryTest.java?rev=1564382&r1=1564381&r2=1564382&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/test/java/org/apache/sling/replication/agent/impl/ReplicationAgentServiceFactoryTest.java
(original)
+++ sling/trunk/contrib/extensions/replication/src/test/java/org/apache/sling/replication/agent/impl/ReplicationAgentServiceFactoryTest.java
Tue Feb  4 17:16:36 2014
@@ -26,15 +26,11 @@ import org.apache.sling.replication.queu
 import org.apache.sling.replication.queue.ReplicationQueueProvider;
 import org.apache.sling.replication.serialization.ReplicationPackageBuilder;
 import org.apache.sling.replication.transport.TransportHandler;
-import org.apache.sling.replication.transport.authentication.TransportAuthenticationProvider;
-import org.apache.sling.replication.transport.authentication.TransportAuthenticationProviderFactory;
 import org.junit.Test;
 import org.osgi.framework.BundleContext;
 
 import static org.junit.Assert.fail;
-import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
 
 /**
  * Testcase for {@link ReplicationAgentServiceFactory}
@@ -65,14 +61,6 @@ public class ReplicationAgentServiceFact
         TransportHandler transportHandler = mock(TransportHandler.class);
         transportField.set(serviceFactory, transportHandler);
 
-        Field transportAuthenticationField = serviceFactory.getClass().getDeclaredField("transportAuthenticationProviderFactory");
-        transportAuthenticationField.setAccessible(true);
-        TransportAuthenticationProviderFactory transportAuthenticationProviderFactory = mock(TransportAuthenticationProviderFactory.class);
-        transportAuthenticationField.set(serviceFactory, transportAuthenticationProviderFactory);
-
-        TransportAuthenticationProvider transportAuthenticationProvider = mock(TransportAuthenticationProvider.class);
-        when(transportAuthenticationProviderFactory.createAuthenticationProvider(any(Map.class))).thenReturn(transportAuthenticationProvider);
-        when(transportHandler.supportsAuthenticationProvider(any(TransportAuthenticationProvider.class))).thenReturn(true);
 
         Map<String, Object> dictionary = new HashMap<String, Object>();
         dictionary.put("endpoint", "http://somewhere.com");

Modified: sling/trunk/contrib/extensions/replication/src/test/java/org/apache/sling/replication/agent/impl/SimpleReplicationAgentTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/test/java/org/apache/sling/replication/agent/impl/SimpleReplicationAgentTest.java?rev=1564382&r1=1564381&r2=1564382&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/test/java/org/apache/sling/replication/agent/impl/SimpleReplicationAgentTest.java
(original)
+++ sling/trunk/contrib/extensions/replication/src/test/java/org/apache/sling/replication/agent/impl/SimpleReplicationAgentTest.java
Tue Feb  4 17:16:36 2014
@@ -21,20 +21,24 @@ package org.apache.sling.replication.age
 import org.apache.sling.replication.communication.ReplicationActionType;
 import org.apache.sling.replication.communication.ReplicationRequest;
 import org.apache.sling.replication.communication.ReplicationResponse;
-import org.apache.sling.replication.queue.*;
+import org.apache.sling.replication.queue.ReplicationQueue;
+import org.apache.sling.replication.queue.ReplicationQueueDistributionStrategy;
+import org.apache.sling.replication.queue.ReplicationQueueItem;
+import org.apache.sling.replication.queue.ReplicationQueueItemState;
+import org.apache.sling.replication.queue.ReplicationQueueProvider;
 import org.apache.sling.replication.queue.impl.simple.SimpleReplicationQueue;
 import org.apache.sling.replication.serialization.ReplicationPackage;
 import org.apache.sling.replication.serialization.ReplicationPackageBuilder;
-import org.apache.sling.replication.queue.ReplicationQueueItem;
 import org.apache.sling.replication.transport.TransportHandler;
-import org.apache.sling.replication.transport.authentication.TransportAuthenticationProvider;
 import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.*;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
@@ -46,15 +50,13 @@ public class SimpleReplicationAgentTest 
     @Test
     public void testProcess() throws Exception {
         String name = "sample-agent";
-        String endpoint = "/tmp";
         TransportHandler transportHandler = mock(TransportHandler.class);
         ReplicationPackageBuilder packageBuilder = mock(ReplicationPackageBuilder.class);
         when(packageBuilder.getPackage(anyString())).thenReturn(mock(ReplicationPackage.class));
         ReplicationQueueProvider queueProvider = mock(ReplicationQueueProvider.class);
-        TransportAuthenticationProvider transportAuthenticationProvider = mock(TransportAuthenticationProvider.class);
         ReplicationQueueDistributionStrategy distributionHandler = mock(ReplicationQueueDistributionStrategy.class);
-        SimpleReplicationAgent agent = new SimpleReplicationAgent(name, endpoint, new String[0],
true,
-                        transportHandler, packageBuilder, queueProvider, transportAuthenticationProvider,
distributionHandler);
+        SimpleReplicationAgent agent = new SimpleReplicationAgent(name, new String[0], true,
+                        transportHandler, packageBuilder, queueProvider, distributionHandler,
null);
         ReplicationQueueItem item = mock(ReplicationQueueItem.class);
         assertTrue(agent.process(item));
     }
@@ -62,14 +64,12 @@ public class SimpleReplicationAgentTest 
     @Test
     public void testSyncReplicationWithFailingDistributionStrategy() throws Exception {
         String name = "sample-agent";
-        String endpoint = "/tmp";
         TransportHandler transportHandler = mock(TransportHandler.class);
         ReplicationPackageBuilder packageBuilder = mock(ReplicationPackageBuilder.class);
         ReplicationQueueProvider queueProvider = mock(ReplicationQueueProvider.class);
-        TransportAuthenticationProvider transportAuthenticationProvider = mock(TransportAuthenticationProvider.class);
         ReplicationQueueDistributionStrategy distributionHandler = mock(ReplicationQueueDistributionStrategy.class);
-        SimpleReplicationAgent agent = new SimpleReplicationAgent(name, endpoint, new String[0],
true,
-                        transportHandler, packageBuilder, queueProvider, transportAuthenticationProvider,
distributionHandler);
+        SimpleReplicationAgent agent = new SimpleReplicationAgent(name, new String[0], true,
+                        transportHandler, packageBuilder, queueProvider, distributionHandler,
null);
         ReplicationRequest request = new ReplicationRequest(System.nanoTime(),
                         ReplicationActionType.ADD, "/");
         ReplicationPackage replicationPackage = mock(ReplicationPackage.class);
@@ -84,14 +84,12 @@ public class SimpleReplicationAgentTest 
     @Test
     public void testSyncReplicationWithWorkingDistributionStrategy() throws Exception {
         String name = "sample-agent";
-        String endpoint = "/tmp";
         TransportHandler transportHandler = mock(TransportHandler.class);
         ReplicationPackageBuilder packageBuilder = mock(ReplicationPackageBuilder.class);
         ReplicationQueueProvider queueProvider = mock(ReplicationQueueProvider.class);
-        TransportAuthenticationProvider transportAuthenticationProvider = mock(TransportAuthenticationProvider.class);
         ReplicationQueueDistributionStrategy distributionHandler = mock(ReplicationQueueDistributionStrategy.class);
-        SimpleReplicationAgent agent = new SimpleReplicationAgent(name, endpoint, new String[0],
true,
-                transportHandler, packageBuilder, queueProvider, transportAuthenticationProvider,
distributionHandler);
+        SimpleReplicationAgent agent = new SimpleReplicationAgent(name, new String[0], true,
+                transportHandler, packageBuilder, queueProvider, distributionHandler, null);
         ReplicationRequest request = new ReplicationRequest(System.nanoTime(),
                 ReplicationActionType.ADD, "/");
         ReplicationPackage replicationPackage = mock(ReplicationPackage.class);
@@ -109,14 +107,12 @@ public class SimpleReplicationAgentTest 
     @Test
     public void testAsyncReplication() throws Exception {
         String name = "sample-agent";
-        String endpoint = "/tmp";
         TransportHandler transportHandler = mock(TransportHandler.class);
         ReplicationPackageBuilder packageBuilder = mock(ReplicationPackageBuilder.class);
         ReplicationQueueProvider queueProvider = mock(ReplicationQueueProvider.class);
-        TransportAuthenticationProvider transportAuthenticationProvider = mock(TransportAuthenticationProvider.class);
         ReplicationQueueDistributionStrategy distributionHandler = mock(ReplicationQueueDistributionStrategy.class);
-        SimpleReplicationAgent agent = new SimpleReplicationAgent(name, endpoint, new String[0],
true,
-                transportHandler, packageBuilder, queueProvider, transportAuthenticationProvider,
distributionHandler);
+        SimpleReplicationAgent agent = new SimpleReplicationAgent(name, new String[0], true,
+                transportHandler, packageBuilder, queueProvider, distributionHandler, null);
         ReplicationRequest request = new ReplicationRequest(System.nanoTime(),
                 ReplicationActionType.ADD, "/");
         ReplicationPackage replicationPackage = mock(ReplicationPackage.class);
@@ -129,14 +125,12 @@ public class SimpleReplicationAgentTest 
     @Test
     public void testGetDefaultQueue() throws Exception {
         String name = "sample-agent";
-        String endpoint = "/tmp";
         TransportHandler transportHandler = mock(TransportHandler.class);
         ReplicationPackageBuilder packageBuilder = mock(ReplicationPackageBuilder.class);
         ReplicationQueueProvider queueProvider = mock(ReplicationQueueProvider.class);
-        TransportAuthenticationProvider transportAuthenticationProvider = mock(TransportAuthenticationProvider.class);
         ReplicationQueueDistributionStrategy distributionHandler = mock(ReplicationQueueDistributionStrategy.class);
-        SimpleReplicationAgent agent = new SimpleReplicationAgent(name, endpoint, new String[0],
true,
-                transportHandler, packageBuilder, queueProvider, transportAuthenticationProvider,
distributionHandler);
+        SimpleReplicationAgent agent = new SimpleReplicationAgent(name, new String[0], true,
+                transportHandler, packageBuilder, queueProvider, distributionHandler, null);
         ReplicationQueue queue = mock(ReplicationQueue.class);
         when(queueProvider.getDefaultQueue(agent)).thenReturn(queue);
         assertNotNull(agent.getQueue(null));
@@ -149,10 +143,9 @@ public class SimpleReplicationAgentTest 
         TransportHandler transportHandler = mock(TransportHandler.class);
         ReplicationPackageBuilder packageBuilder = mock(ReplicationPackageBuilder.class);
         ReplicationQueueProvider queueProvider = mock(ReplicationQueueProvider.class);
-        TransportAuthenticationProvider transportAuthenticationProvider = mock(TransportAuthenticationProvider.class);
         ReplicationQueueDistributionStrategy distributionHandler = mock(ReplicationQueueDistributionStrategy.class);
-        SimpleReplicationAgent agent = new SimpleReplicationAgent(name, endpoint, new String[0],
true,
-                transportHandler, packageBuilder, queueProvider, transportAuthenticationProvider,
distributionHandler);
+        SimpleReplicationAgent agent = new SimpleReplicationAgent(name, new String[0], true,
+                transportHandler, packageBuilder, queueProvider, distributionHandler, null);
         ReplicationQueue queue = mock(ReplicationQueue.class);
         when(queueProvider.getQueue(agent, "priority")).thenReturn(queue);
         assertNotNull(agent.getQueue("priority"));
@@ -161,14 +154,12 @@ public class SimpleReplicationAgentTest 
     @Test
     public void testGetNonExistingNamedQueue() throws Exception {
         String name = "sample-agent";
-        String endpoint = "/tmp";
         TransportHandler transportHandler = mock(TransportHandler.class);
         ReplicationPackageBuilder packageBuilder = mock(ReplicationPackageBuilder.class);
         ReplicationQueueProvider queueProvider = mock(ReplicationQueueProvider.class);
-        TransportAuthenticationProvider transportAuthenticationProvider = mock(TransportAuthenticationProvider.class);
         ReplicationQueueDistributionStrategy distributionHandler = mock(ReplicationQueueDistributionStrategy.class);
-        SimpleReplicationAgent agent = new SimpleReplicationAgent(name, endpoint, new String[0],
true,
-                transportHandler, packageBuilder, queueProvider, transportAuthenticationProvider,
distributionHandler);
+        SimpleReplicationAgent agent = new SimpleReplicationAgent(name, new String[0], true,
+                transportHandler, packageBuilder, queueProvider, distributionHandler, null);
         ReplicationQueue queue = mock(ReplicationQueue.class);
         when(queueProvider.getQueue(agent, "priority")).thenReturn(queue);
         assertNull(agent.getQueue("weird"));

Modified: sling/trunk/contrib/extensions/replication/src/test/java/org/apache/sling/replication/transport/impl/HttpTransportHandlerTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/test/java/org/apache/sling/replication/transport/impl/HttpTransportHandlerTest.java?rev=1564382&r1=1564381&r2=1564382&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/test/java/org/apache/sling/replication/transport/impl/HttpTransportHandlerTest.java
(original)
+++ sling/trunk/contrib/extensions/replication/src/test/java/org/apache/sling/replication/transport/impl/HttpTransportHandlerTest.java
Tue Feb  4 17:16:36 2014
@@ -44,33 +44,42 @@ import static org.mockito.Mockito.times;
 public class HttpTransportHandlerTest {
     @Test
     public void testHttpTransport() throws Exception {
-        HttpTransportHandler httpTransportHandler = new HttpTransportHandler();
+        TransportAuthenticationProvider<Executor, Executor> transportAuthenticationProvider
= mock(TransportAuthenticationProvider.class);
+        ReplicationEndpoint replicationEndpoint = new ReplicationEndpoint(new URI("http://localhost:8080/system/replication/receive"));
+
+
+
+        HttpTransportHandler httpTransportHandler = new HttpTransportHandler(false, null,
false, null,
+                transportAuthenticationProvider,
+                new ReplicationEndpoint[] { replicationEndpoint }, TransportEndpointStrategyType.All);
         ReplicationPackage replicationPackage = mock(ReplicationPackage.class);
         when(replicationPackage.getAction()).thenReturn(ReplicationActionType.ADD.toString());
         when(replicationPackage.getType()).thenReturn("test");
         when(replicationPackage.getPaths()).thenReturn(new String[]{"/content"});
-        ReplicationEndpoint replicationEndpoint = new ReplicationEndpoint(new URI("http://localhost:8080/system/replication/receive"));
-        TransportAuthenticationProvider<Executor, Executor> transportAuthenticationProvider
= mock(TransportAuthenticationProvider.class);
         Executor executor = mock(Executor.class);
         Response response = mock(Response.class);
         Content content = mock(Content.class);
         when(response.returnContent()).thenReturn(content);
         when(executor.execute(any(Request.class))).thenReturn(response);
         when(transportAuthenticationProvider.authenticate(any(Executor.class), any(TransportAuthenticationContext.class))).thenReturn(executor);
-        httpTransportHandler.transport(replicationPackage, replicationEndpoint, transportAuthenticationProvider);
+        httpTransportHandler.transport(replicationPackage);
     }
 
     @Test
     public void testHttpTransportWithMultipleCalls() throws Exception {
-        HttpTransportHandler httpTransportHandler = new HttpTransportHandler();
+        TransportAuthenticationProvider<Executor, Executor> transportAuthenticationProvider
= mock(TransportAuthenticationProvider.class);
+        ReplicationEndpoint replicationEndpoint = new ReplicationEndpoint(new URI("http://localhost:8080/system/replication/receive"));
+
+
+        HttpTransportHandler httpTransportHandler = new HttpTransportHandler(false, null,
false, null,
+                transportAuthenticationProvider,
+                new ReplicationEndpoint[] { replicationEndpoint }, TransportEndpointStrategyType.All);
 
         ReplicationPackage replicationPackage = mock(ReplicationPackage.class);
         when(replicationPackage.getAction()).thenReturn(ReplicationActionType.ADD.toString());
         when(replicationPackage.getType()).thenReturn("test");
         when(replicationPackage.getPaths()).thenReturn(new String[]{"/content/a", "/content/b"});
 
-        ReplicationEndpoint replicationEndpoint = new ReplicationEndpoint(new URI("http://localhost:8080/system/replication/receive"));
-        TransportAuthenticationProvider<Executor, Executor> transportAuthenticationProvider
= mock(TransportAuthenticationProvider.class);
         Executor executor = mock(Executor.class);
         Response response = mock(Response.class);
         Content content = mock(Content.class);
@@ -78,7 +87,7 @@ public class HttpTransportHandlerTest {
         when(executor.execute(any(Request.class))).thenReturn(response);
         when(transportAuthenticationProvider.authenticate(any(Executor.class), any(TransportAuthenticationContext.class))).thenReturn(executor);
 
-        httpTransportHandler.transport(replicationPackage, replicationEndpoint, transportAuthenticationProvider);
+        httpTransportHandler.transport(replicationPackage);
 
         verify(executor, times(1)).execute(any(Request.class));
     }

Modified: sling/trunk/contrib/extensions/replication/src/test/java/org/apache/sling/replication/transport/impl/PollingTransportHandlerTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/test/java/org/apache/sling/replication/transport/impl/PollingTransportHandlerTest.java?rev=1564382&r1=1564381&r2=1564382&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/test/java/org/apache/sling/replication/transport/impl/PollingTransportHandlerTest.java
(original)
+++ sling/trunk/contrib/extensions/replication/src/test/java/org/apache/sling/replication/transport/impl/PollingTransportHandlerTest.java
Tue Feb  4 17:16:36 2014
@@ -42,13 +42,17 @@ public class PollingTransportHandlerTest
 
     @Test
     public void testPollingTransport() throws Exception {
-        PollingTransportHandler pollingTransportHandler = new PollingTransportHandler();
+        TransportAuthenticationProvider<Executor, Executor> transportAuthenticationProvider
= mock(TransportAuthenticationProvider.class);
+        ReplicationEndpoint replicationEndpoint = new ReplicationEndpoint(new URI("http://localhost:8080/system/replication/agent/reverse"));
+
+
+        PollingTransportHandler pollingTransportHandler = new PollingTransportHandler(null,
-1,
+                transportAuthenticationProvider,
+                new ReplicationEndpoint[] { replicationEndpoint });
         ReplicationPackage replicationPackage = mock(ReplicationPackage.class);
         when(replicationPackage.getAction()).thenReturn(ReplicationActionType.ADD.toString());
         when(replicationPackage.getType()).thenReturn("test");
         when(replicationPackage.getPaths()).thenReturn(new String[]{"/content"});
-        ReplicationEndpoint replicationEndpoint = new ReplicationEndpoint(new URI("http://localhost:8080/system/replication/agent/reverse"));
-        TransportAuthenticationProvider<Executor, Executor> transportAuthenticationProvider
= mock(TransportAuthenticationProvider.class);
         Executor executor = mock(Executor.class);
         Response response = mock(Response.class);
         HttpEntity entity = mock(HttpEntity.class);
@@ -57,6 +61,6 @@ public class PollingTransportHandlerTest
         when(httpResponse.getEntity()).thenReturn(entity);
         when(executor.execute(any(Request.class))).thenReturn(response);
         when(transportAuthenticationProvider.authenticate(any(Executor.class), any(TransportAuthenticationContext.class))).thenReturn(executor);
-        pollingTransportHandler.transport(replicationPackage, replicationEndpoint, transportAuthenticationProvider);
+        pollingTransportHandler.transport(replicationPackage);
     }
 }

Modified: sling/trunk/contrib/extensions/replication/src/test/java/org/apache/sling/replication/transport/impl/RepositoryTransportHandlerTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/test/java/org/apache/sling/replication/transport/impl/RepositoryTransportHandlerTest.java?rev=1564382&r1=1564381&r2=1564382&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/test/java/org/apache/sling/replication/transport/impl/RepositoryTransportHandlerTest.java
(original)
+++ sling/trunk/contrib/extensions/replication/src/test/java/org/apache/sling/replication/transport/impl/RepositoryTransportHandlerTest.java
Tue Feb  4 17:16:36 2014
@@ -18,7 +18,6 @@
  */
 package org.apache.sling.replication.transport.impl;
 
-import java.lang.reflect.Field;
 import javax.jcr.Credentials;
 import javax.jcr.Node;
 import javax.jcr.Session;
@@ -43,12 +42,13 @@ public class RepositoryTransportHandlerT
 
     @Test
     public void testDeliveryWithoutAuthenticatedSession() throws Exception {
-        RepositoryTransportHandler handler = new RepositoryTransportHandler();
-        @SuppressWarnings("unchecked")
         TransportAuthenticationProvider<SlingRepository, Session> transportAuthenticationProvider
= mock(TransportAuthenticationProvider.class);
+
+        RepositoryTransportHandler handler = new RepositoryTransportHandler(null, null,
+                transportAuthenticationProvider,
+                new ReplicationEndpoint[] {  new ReplicationEndpoint("repo://var/outbox/replication/rev1")
});
         try {
-            handler.transport(null, new ReplicationEndpoint("repo://var/outbox/replication/rev1"),
-                    transportAuthenticationProvider);
+            handler.transport(null);
             fail("cannot deliver without a proper session");
         } catch (ReplicationTransportException re) {
             // failure expected
@@ -72,21 +72,18 @@ public class RepositoryTransportHandlerT
         SlingRepository repo = mock(SlingRepository.class);
         when(repo.login(any(Credentials.class))).thenReturn(session);
 
-        RepositoryTransportHandler handler = new RepositoryTransportHandler();
-        Field repositoryField = handler.getClass().getDeclaredField("repository");
-        repositoryField.setAccessible(true);
-        repositoryField.set(handler, repo);
-
         ReplicationEventFactory replicationEventFactory = mock(ReplicationEventFactory.class);
-        Field replicationEventFactoryField = handler.getClass().getDeclaredField("replicationEventFactory");
-        replicationEventFactoryField.setAccessible(true);
-        replicationEventFactoryField.set(handler, replicationEventFactory);
 
         TransportAuthenticationProvider<SlingRepository, Session> transportAuthenticationProvider
= new RepositoryTransportAuthenticationProvider("user-123", "p455w0rd");
+
+        RepositoryTransportHandler handler = new RepositoryTransportHandler(repo, replicationEventFactory,
+                transportAuthenticationProvider,
+                new ReplicationEndpoint[] { new ReplicationEndpoint("repo:/" + repoPath)
});
+
+
         ReplicationPackage replicationPackage = mock(ReplicationPackage.class);
         when(replicationPackage.getId()).thenReturn("some-id");
         when(replicationPackage.getPaths()).thenReturn(new String[]{"/apps", "/libs"});
-        handler.transport(replicationPackage, new ReplicationEndpoint("repo:/" + repoPath),
-                transportAuthenticationProvider);
+        handler.transport(replicationPackage);
     }
 }



Mime
View raw message