incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomm...@apache.org
Subject svn commit: r1558706 [2/2] - in /sling/trunk/contrib/extensions/replication: ./ src/main/java/org/apache/sling/replication/agent/ src/main/java/org/apache/sling/replication/agent/impl/ src/main/java/org/apache/sling/replication/event/ src/main/java/org...
Date Thu, 16 Jan 2014 07:29:02 GMT
Modified: sling/trunk/contrib/extensions/replication/src/test/java/org/apache/sling/replication/agent/impl/ReplicationAgentConfigurationResourceTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/test/java/org/apache/sling/replication/agent/impl/ReplicationAgentConfigurationResourceTest.java?rev=1558706&r1=1558705&r2=1558706&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/test/java/org/apache/sling/replication/agent/impl/ReplicationAgentConfigurationResourceTest.java
(original)
+++ sling/trunk/contrib/extensions/replication/src/test/java/org/apache/sling/replication/agent/impl/ReplicationAgentConfigurationResourceTest.java
Thu Jan 16 07:29:01 2014
@@ -51,13 +51,13 @@ public class ReplicationAgentConfigurati
         ResourceResolver resourceResolver = mock(ResourceResolver.class);
         ReplicationAgentConfigurationResource replicationAgentConfigurationResource = new
ReplicationAgentConfigurationResource(agentConfiguration, resourceResolver);
         assertNotNull(replicationAgentConfigurationResource.getPath());
-        assertEquals(ReplicationAgentResource.BASE_PATH + "/null/configuration", replicationAgentConfigurationResource.getPath());
+        assertEquals(ReplicationAgentConfigurationResource.BASE_PATH + "/null", replicationAgentConfigurationResource.getPath());
         assertNotNull(replicationAgentConfigurationResource.getResourceResolver());
         assertEquals(resourceResolver, replicationAgentConfigurationResource.getResourceResolver());
         assertNotNull(replicationAgentConfigurationResource.getResourceType());
         assertEquals(ReplicationAgentConfigurationResource.RESOURCE_TYPE, replicationAgentConfigurationResource.getResourceType());
         assertNotNull(replicationAgentConfigurationResource.getResourceMetadata());
-        assertEquals("/system/replication/agent/null", replicationAgentConfigurationResource.getResourceMetadata().getResolutionPath());
+        assertEquals(ReplicationAgentConfigurationResource.BASE_PATH + "/null", replicationAgentConfigurationResource.getResourceMetadata().getResolutionPath());
         assertNull(replicationAgentConfigurationResource.getResourceSuperType());
     }
 }

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=1558706&r1=1558705&r2=1558706&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
Thu Jan 16 07:29:01 2014
@@ -24,14 +24,19 @@ import org.apache.sling.replication.agen
 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;
 
@@ -51,38 +56,40 @@ 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 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 = "publish";
+        String path = ReplicationAgentConfigurationResource.BASE_PATH  + "/publish";
         BundleContext context = mock(BundleContext.class);
-        ReplicationAgent replicationAgent = createMockedReplicationAgent(path, context);
-        mockReplicationAgentConfiguration(context, replicationAgent);
+        mockReplicationAgentConfiguration(context, "publish");
         ReplicationAgentResourceProvider agentResourceProvider = new ReplicationAgentResourceProvider();
         agentResourceProvider.activate(context);
         ResourceResolver resourceResolver = mock(ResourceResolver.class);
 
-        Resource resource = agentResourceProvider.getResource(resourceResolver, path
-                        + "/configuration");
+        Session session = mock(Session.class);
+        when(session.nodeExists(ReplicationAgentResourceProvider.SECURITY_OBJECT)).thenReturn(true);
+        when(resourceResolver.adaptTo(Session.class)).thenReturn(session);
+
+        Resource resource = agentResourceProvider.getResource(resourceResolver, path);
         assertNotNull(resource);
         assertEquals(ReplicationAgentConfigurationResource.RESOURCE_TYPE, resource.getResourceType());
     }
 
     private void mockReplicationAgentConfiguration(BundleContext context,
-                    ReplicationAgent replicationAgent) throws AgentConfigurationException
{
+                    final String replicationAgent) throws AgentConfigurationException {
         ServiceReference configurationManagerServiceReference = mock(ServiceReference.class);
         when(context.getServiceReference(ReplicationAgentConfigurationManager.class.getName()))
                         .thenReturn(configurationManagerServiceReference);

Modified: sling/trunk/contrib/extensions/replication/src/test/java/org/apache/sling/replication/agent/impl/ReplicationAgentResourceTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/test/java/org/apache/sling/replication/agent/impl/ReplicationAgentResourceTest.java?rev=1558706&r1=1558705&r2=1558706&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/test/java/org/apache/sling/replication/agent/impl/ReplicationAgentResourceTest.java
(original)
+++ sling/trunk/contrib/extensions/replication/src/test/java/org/apache/sling/replication/agent/impl/ReplicationAgentResourceTest.java
Thu Jan 16 07:29:01 2014
@@ -57,7 +57,7 @@ public class ReplicationAgentResourceTes
         assertNotNull(replicationAgentResource.getResourceType());
         assertEquals(ReplicationAgentResource.RESOURCE_TYPE, replicationAgentResource.getResourceType());
         assertNotNull(replicationAgentResource.getResourceMetadata());
-        assertEquals(ReplicationAgentResource.BASE_PATH, replicationAgentResource.getResourceMetadata().getResolutionPath());
+        assertEquals(ReplicationAgentResource.BASE_PATH +"/null", replicationAgentResource.getResourceMetadata().getResolutionPath());
         assertNull(replicationAgentResource.getResourceSuperType());
     }
 }



Mime
View raw message