sling-commits mailing list archives

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

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

Added:
    sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/
    sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/DistributionPackageMBeanTest.java
  (with props)
    sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/DistributionQueueMBeanTest.java
  (with props)
    sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/ForwardDistributionAgentMBeanTest.java
  (with props)
    sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/QueueDistributionAgentMBeanTest.java
  (with props)
    sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/ReverseDistributionAgentMBeanTest.java
  (with props)
    sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/SimpleDistributionAgentMBeanTest.java
  (with props)
    sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/SyncDistributionAgentMBeanTest.java
  (with props)
    sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/UserCredentialsDistributionTransportSecretMBeanTest.java
  (with props)

Added: sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/DistributionPackageMBeanTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/DistributionPackageMBeanTest.java?rev=1770384&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/DistributionPackageMBeanTest.java
(added)
+++ sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/DistributionPackageMBeanTest.java
Fri Nov 18 14:17:30 2016
@@ -0,0 +1,68 @@
+/*
+ * 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.distribution.monitor.impl;
+
+import static org.apache.sling.distribution.packaging.DistributionPackageInfo.*;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.sling.distribution.DistributionRequestType;
+import org.apache.sling.distribution.packaging.DistributionPackage;
+import org.apache.sling.distribution.packaging.DistributionPackageInfo;
+import org.junit.Test;
+
+/**
+ * Test case for {@link DistributionPackageMBean}
+ */
+public class DistributionPackageMBeanTest {
+
+    @Test
+    public void verifyMBeanExposedValues() {
+        String type = "jcrvlt";
+        long processingTime = 2000L;
+
+        Map<String, Object> base = new HashMap<String, Object>();
+        base.put(PROPERTY_REQUEST_PATHS, new String[]{ "a", "b", "c" });
+        base.put(PROPERTY_REQUEST_TYPE, DistributionRequestType.ADD);
+        DistributionPackageInfo distributionPackageInfo = new DistributionPackageInfo(type,
base);
+
+        DistributionPackage distributionPackage = mock(DistributionPackage.class);
+        when(distributionPackage.getId()).thenReturn("#distributionPackage");
+        when(distributionPackage.getSize()).thenReturn(1000L);
+        when(distributionPackage.getInfo()).thenReturn(distributionPackageInfo);
+
+        DistributionPackageMBean mBean = new DistributionPackageMBeanImpl(distributionPackage,
+                                                                          type,
+                                                                          processingTime);
+
+        assertEquals(distributionPackage.getId(), mBean.getId());
+        assertEquals(type, mBean.getType());
+        assertArrayEquals(distributionPackageInfo.getPaths(), mBean.getPaths());
+        assertEquals(distributionPackageInfo.getRequestType().name().toLowerCase(), mBean.getRequestType());
+        assertEquals(distributionPackage.getSize(), mBean.getSize());
+        assertEquals(processingTime, mBean.getProcessingTime());
+    }
+
+}

Propchange: sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/DistributionPackageMBeanTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/DistributionQueueMBeanTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/DistributionQueueMBeanTest.java?rev=1770384&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/DistributionQueueMBeanTest.java
(added)
+++ sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/DistributionQueueMBeanTest.java
Fri Nov 18 14:17:30 2016
@@ -0,0 +1,96 @@
+/*
+ * 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.distribution.monitor.impl;
+
+import static org.apache.sling.distribution.queue.DistributionQueueItemState.QUEUED;
+import static org.apache.sling.distribution.queue.DistributionQueueState.PAUSED;
+import static org.apache.sling.distribution.queue.DistributionQueueState.RUNNING;
+import static org.apache.sling.distribution.queue.DistributionQueueType.ORDERED;
+import static org.apache.sling.distribution.queue.DistributionQueueType.PARALLEL;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.Calendar;
+import java.util.HashMap;
+
+import org.apache.sling.distribution.queue.DistributionQueue;
+import org.apache.sling.distribution.queue.DistributionQueueEntry;
+import org.apache.sling.distribution.queue.DistributionQueueItem;
+import org.apache.sling.distribution.queue.DistributionQueueItemStatus;
+import org.apache.sling.distribution.queue.DistributionQueueStatus;
+import org.junit.Test;
+
+/**
+ * Test case for {@link DistributionQueueMBean}
+ */
+public class DistributionQueueMBeanTest {
+
+    @Test
+    public void verifyMBeanExposedValuesWhenHeadIsNull() {
+        DistributionQueueStatus status = new DistributionQueueStatus(0, PAUSED);
+
+        DistributionQueue distributionQueue = mock(DistributionQueue.class);
+        when(distributionQueue.getName()).thenReturn("#distributionQueue");
+        when(distributionQueue.getHead()).thenReturn(null);
+        when(distributionQueue.getType()).thenReturn(ORDERED);
+        when(distributionQueue.getStatus()).thenReturn(status);
+
+        DistributionQueueMBean mBean = new DistributionQueueMBeanImpl(distributionQueue);
+
+        assertEquals(distributionQueue.getName(), mBean.getName());
+        assertEquals(distributionQueue.getType().name().toLowerCase(), mBean.getType());
+        assertEquals(0, mBean.getSize());
+        assertTrue(mBean.isEmpty());
+        assertNull(mBean.getHeadId());
+        assertEquals(-1, mBean.getHeadDequeuingAttempts());
+        assertNull(mBean.getHeadStatus());
+        assertNull(mBean.getHeadEnqueuingDate());
+    }
+
+    @Test
+    public void verifyMBeanExposedValuesWhenHeadIsNotNull() {
+        DistributionQueueStatus status = new DistributionQueueStatus(1, RUNNING);
+        Calendar joined = Calendar.getInstance();
+        DistributionQueueEntry entry = new DistributionQueueEntry("#entry",
+                                                                  new DistributionQueueItem("#package",
1000L, new HashMap<String, Object>()),
+                                                                  new DistributionQueueItemStatus(joined,
QUEUED, 1, "#queue"));
+
+        DistributionQueue distributionQueue = mock(DistributionQueue.class);
+        when(distributionQueue.getName()).thenReturn("#distributionQueue");
+        when(distributionQueue.getHead()).thenReturn(entry);
+        when(distributionQueue.getType()).thenReturn(PARALLEL);
+        when(distributionQueue.getStatus()).thenReturn(status);
+
+        DistributionQueueMBean mBean = new DistributionQueueMBeanImpl(distributionQueue);
+
+        assertEquals(distributionQueue.getName(), mBean.getName());
+        assertEquals(distributionQueue.getType().name().toLowerCase(), mBean.getType());
+        assertEquals(1, mBean.getSize());
+        assertFalse(mBean.isEmpty());
+        assertEquals("#entry", mBean.getHeadId());
+        assertEquals(1, mBean.getHeadDequeuingAttempts());
+        assertEquals(QUEUED.name().toLowerCase(), mBean.getHeadStatus());
+        assertEquals(joined, mBean.getHeadEnqueuingDate());
+    }
+
+}

Propchange: sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/DistributionQueueMBeanTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/ForwardDistributionAgentMBeanTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/ForwardDistributionAgentMBeanTest.java?rev=1770384&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/ForwardDistributionAgentMBeanTest.java
(added)
+++ sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/ForwardDistributionAgentMBeanTest.java
Fri Nov 18 14:17:30 2016
@@ -0,0 +1,79 @@
+/*
+ * 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.distribution.monitor.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.sling.distribution.agent.DistributionAgent;
+import org.apache.sling.distribution.agent.DistributionAgentState;
+import org.junit.Test;
+
+/**
+ * Test case for {@link ForwardDistributionAgentMBean}
+ */
+public class ForwardDistributionAgentMBeanTest {
+
+    @Test
+    public void verifyMBeanExposedValues() {
+        DistributionAgent agent = mock(DistributionAgent.class);
+        when(agent.getState()).thenReturn(DistributionAgentState.RUNNING);
+
+        Map<String, Object> osgiConfiguration = new HashMap<String, Object>();
+        osgiConfiguration.put("name", "#distributionagent");
+        osgiConfiguration.put("title", "Just a test title");
+        osgiConfiguration.put("details", "Just test details");
+        osgiConfiguration.put("enabled", true);
+        osgiConfiguration.put("serviceName", "@distributionagent");
+        osgiConfiguration.put("log.level", "error");
+        osgiConfiguration.put("allowed.roots", "admin");
+        osgiConfiguration.put("queue.processing.enabled", true);
+        osgiConfiguration.put("packageImporter.endpoints", "endpoints");
+        osgiConfiguration.put("passiveQueues", "passiveQueues");
+        osgiConfiguration.put("priorityQueues", "priorityQueues");
+        osgiConfiguration.put("retry.strategy", "none");
+        osgiConfiguration.put("retry.attempts", 30);
+        osgiConfiguration.put("queue.provider", "jobsProvider");
+        osgiConfiguration.put("async.delivery", true);
+
+        ForwardDistributionAgentMBean mBean = new ForwardDistributionAgentMBeanImpl(agent,
osgiConfiguration);
+
+        assertEquals(osgiConfiguration.get("name"), mBean.getName());
+        assertEquals(osgiConfiguration.get("title"), mBean.getTitle());
+        assertEquals(osgiConfiguration.get("details"), mBean.getDetails());
+        assertEquals(osgiConfiguration.get("enabled"), mBean.isEnabled());
+        assertEquals(osgiConfiguration.get("serviceName"), mBean.getServiceName());
+        assertEquals(osgiConfiguration.get("log.level"), mBean.getLogLevel());
+        assertEquals(osgiConfiguration.get("allowed.roots"), mBean.getAllowedRoots());
+        assertEquals(osgiConfiguration.get("queue.processing.enabled"), mBean.isQueueProcessingEnabled());
+        assertEquals(osgiConfiguration.get("packageImporter.endpoints"), mBean.getPackageImporterEndpoints());
+        assertEquals(osgiConfiguration.get("passiveQueues"), mBean.getPassiveQueues());
+        assertEquals(osgiConfiguration.get("priorityQueues"), mBean.getPriorityQueues());
+        assertEquals(osgiConfiguration.get("retry.strategy"), mBean.getRetryStrategy());
+        assertEquals(osgiConfiguration.get("retry.attempts"), mBean.getRetryAttempts());
+        assertEquals(osgiConfiguration.get("queue.provider"), mBean.getQueueProvider());
+        assertEquals(osgiConfiguration.get("async.delivery"), mBean.isAsyncDelivery());
+        assertEquals(agent.getState().name().toLowerCase(), mBean.getStatus());
+    }
+
+}

Propchange: sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/ForwardDistributionAgentMBeanTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/QueueDistributionAgentMBeanTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/QueueDistributionAgentMBeanTest.java?rev=1770384&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/QueueDistributionAgentMBeanTest.java
(added)
+++ sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/QueueDistributionAgentMBeanTest.java
Fri Nov 18 14:17:30 2016
@@ -0,0 +1,63 @@
+/*
+ * 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.distribution.monitor.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.sling.distribution.agent.DistributionAgent;
+import org.apache.sling.distribution.agent.DistributionAgentState;
+import org.junit.Test;
+
+/**
+ * Test case for {@link QueueDistributionAgentMBean}
+ */
+public class QueueDistributionAgentMBeanTest {
+
+    @Test
+    public void verifyMBeanExposedValues() {
+        DistributionAgent agent = mock(DistributionAgent.class);
+        when(agent.getState()).thenReturn(DistributionAgentState.RUNNING);
+
+        Map<String, Object> osgiConfiguration = new HashMap<String, Object>();
+        osgiConfiguration.put("name", "#queueagent");
+        osgiConfiguration.put("title", "Just a test title");
+        osgiConfiguration.put("details", "Just test details");
+        osgiConfiguration.put("enabled", true);
+        osgiConfiguration.put("serviceName", "@queueagent");
+        osgiConfiguration.put("log.level", "error");
+        osgiConfiguration.put("allowed.roots", "admin");
+
+        QueueDistributionAgentMBean mBean = new QueueDistributionAgentMBeanImpl(agent, osgiConfiguration);
+
+        assertEquals(osgiConfiguration.get("name"), mBean.getName());
+        assertEquals(osgiConfiguration.get("title"), mBean.getTitle());
+        assertEquals(osgiConfiguration.get("details"), mBean.getDetails());
+        assertEquals(osgiConfiguration.get("enabled"), mBean.isEnabled());
+        assertEquals(osgiConfiguration.get("serviceName"), mBean.getServiceName());
+        assertEquals(osgiConfiguration.get("log.level"), mBean.getLogLevel());
+        assertEquals(osgiConfiguration.get("allowed.roots"), mBean.getAllowedRoots());
+        assertEquals(agent.getState().name().toLowerCase(), mBean.getStatus());
+    }
+
+}

Propchange: sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/QueueDistributionAgentMBeanTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/ReverseDistributionAgentMBeanTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/ReverseDistributionAgentMBeanTest.java?rev=1770384&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/ReverseDistributionAgentMBeanTest.java
(added)
+++ sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/ReverseDistributionAgentMBeanTest.java
Fri Nov 18 14:17:30 2016
@@ -0,0 +1,63 @@
+/*
+ * 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.distribution.monitor.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.sling.distribution.agent.DistributionAgent;
+import org.apache.sling.distribution.agent.DistributionAgentState;
+import org.junit.Test;
+
+/**
+ * Test case for {@link ReverseDistributionAgentMBean}
+ */
+public class ReverseDistributionAgentMBeanTest {
+
+    @Test
+    public void verifyMBeanExposedValues() {
+        DistributionAgent agent = mock(DistributionAgent.class);
+        when(agent.getState()).thenReturn(DistributionAgentState.RUNNING);
+
+        Map<String, Object> osgiConfiguration = new HashMap<String, Object>();
+        osgiConfiguration.put("name", "#distributionagent");
+        osgiConfiguration.put("title", "Just a test title");
+        osgiConfiguration.put("details", "Just test details");
+        osgiConfiguration.put("enabled", true);
+        osgiConfiguration.put("serviceName", "@distributionagent");
+        osgiConfiguration.put("log.level", "error");
+        osgiConfiguration.put("queue.processing.enabled", true);
+
+        ReverseDistributionAgentMBean mBean = new ReverseDistributionAgentMBeanImpl(agent,
osgiConfiguration);
+
+        assertEquals(osgiConfiguration.get("name"), mBean.getName());
+        assertEquals(osgiConfiguration.get("title"), mBean.getTitle());
+        assertEquals(osgiConfiguration.get("details"), mBean.getDetails());
+        assertEquals(osgiConfiguration.get("enabled"), mBean.isEnabled());
+        assertEquals(osgiConfiguration.get("serviceName"), mBean.getServiceName());
+        assertEquals(osgiConfiguration.get("log.level"), mBean.getLogLevel());
+        assertEquals(osgiConfiguration.get("queue.processing.enabled"), mBean.isQueueProcessingEnabled());
+        assertEquals(agent.getState().name().toLowerCase(), mBean.getStatus());
+    }
+
+}

Propchange: sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/ReverseDistributionAgentMBeanTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/SimpleDistributionAgentMBeanTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/SimpleDistributionAgentMBeanTest.java?rev=1770384&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/SimpleDistributionAgentMBeanTest.java
(added)
+++ sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/SimpleDistributionAgentMBeanTest.java
Fri Nov 18 14:17:30 2016
@@ -0,0 +1,63 @@
+/*
+ * 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.distribution.monitor.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.sling.distribution.agent.DistributionAgent;
+import org.apache.sling.distribution.agent.DistributionAgentState;
+import org.junit.Test;
+
+/**
+ * Test case for {@link SimpleDistributionAgentMBean}
+ */
+public class SimpleDistributionAgentMBeanTest {
+
+    @Test
+    public void verifyMBeanExposedValues() {
+        DistributionAgent agent = mock(DistributionAgent.class);
+        when(agent.getState()).thenReturn(DistributionAgentState.RUNNING);
+
+        Map<String, Object> osgiConfiguration = new HashMap<String, Object>();
+        osgiConfiguration.put("name", "#distributionagent");
+        osgiConfiguration.put("title", "Just a test title");
+        osgiConfiguration.put("details", "Just test details");
+        osgiConfiguration.put("enabled", true);
+        osgiConfiguration.put("serviceName", "@distributionagent");
+        osgiConfiguration.put("log.level", "error");
+        osgiConfiguration.put("queue.processing.enabled", true);
+
+        SimpleDistributionAgentMBean mBean = new SimpleDistributionAgentMBeanImpl(agent,
osgiConfiguration);
+
+        assertEquals(osgiConfiguration.get("name"), mBean.getName());
+        assertEquals(osgiConfiguration.get("title"), mBean.getTitle());
+        assertEquals(osgiConfiguration.get("details"), mBean.getDetails());
+        assertEquals(osgiConfiguration.get("enabled"), mBean.isEnabled());
+        assertEquals(osgiConfiguration.get("serviceName"), mBean.getServiceName());
+        assertEquals(osgiConfiguration.get("log.level"), mBean.getLogLevel());
+        assertEquals(osgiConfiguration.get("queue.processing.enabled"), mBean.isQueueProcessingEnabled());
+        assertEquals(agent.getState().name().toLowerCase(), mBean.getStatus());
+    }
+
+}

Propchange: sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/SimpleDistributionAgentMBeanTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/SyncDistributionAgentMBeanTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/SyncDistributionAgentMBeanTest.java?rev=1770384&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/SyncDistributionAgentMBeanTest.java
(added)
+++ sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/SyncDistributionAgentMBeanTest.java
Fri Nov 18 14:17:30 2016
@@ -0,0 +1,71 @@
+/*
+ * 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.distribution.monitor.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.sling.distribution.agent.DistributionAgent;
+import org.apache.sling.distribution.agent.DistributionAgentState;
+import org.junit.Test;
+
+/**
+ * Test case for {@link SyncDistributionAgentMBean}
+ */
+public class SyncDistributionAgentMBeanTest {
+
+    @Test
+    public void verifyMBeanExposedValues() {
+        DistributionAgent agent = mock(DistributionAgent.class);
+        when(agent.getState()).thenReturn(DistributionAgentState.RUNNING);
+
+        Map<String, Object> osgiConfiguration = new HashMap<String, Object>();
+        osgiConfiguration.put("name", "#distributionagent");
+        osgiConfiguration.put("title", "Just a test title");
+        osgiConfiguration.put("details", "Just test details");
+        osgiConfiguration.put("enabled", true);
+        osgiConfiguration.put("serviceName", "@distributionagent");
+        osgiConfiguration.put("log.level", "error");
+        osgiConfiguration.put("queue.processing.enabled", true);
+        osgiConfiguration.put("packageImporter.endpoints", "endpoints");
+        osgiConfiguration.put("priorityQueues", "priorityQueues");
+        osgiConfiguration.put("retry.strategy", "none");
+        osgiConfiguration.put("retry.attempts", 30);
+
+        SyncDistributionAgentMBean mBean = new SyncDistributionAgentMBeanImpl(agent, osgiConfiguration);
+
+        assertEquals(osgiConfiguration.get("name"), mBean.getName());
+        assertEquals(osgiConfiguration.get("title"), mBean.getTitle());
+        assertEquals(osgiConfiguration.get("details"), mBean.getDetails());
+        assertEquals(osgiConfiguration.get("enabled"), mBean.isEnabled());
+        assertEquals(osgiConfiguration.get("serviceName"), mBean.getServiceName());
+        assertEquals(osgiConfiguration.get("log.level"), mBean.getLogLevel());
+        assertEquals(osgiConfiguration.get("queue.processing.enabled"), mBean.isQueueProcessingEnabled());
+        assertEquals(osgiConfiguration.get("packageImporter.endpoints"), mBean.getPackageImporterEndpoints());
+        assertEquals(osgiConfiguration.get("passiveQueues"), mBean.getPassiveQueues());
+        assertEquals(osgiConfiguration.get("retry.strategy"), mBean.getRetryStrategy());
+        assertEquals(osgiConfiguration.get("retry.attempts"), mBean.getRetryAttempts());
+        assertEquals(agent.getState().name().toLowerCase(), mBean.getStatus());
+    }
+
+}

Propchange: sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/SyncDistributionAgentMBeanTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/UserCredentialsDistributionTransportSecretMBeanTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/UserCredentialsDistributionTransportSecretMBeanTest.java?rev=1770384&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/UserCredentialsDistributionTransportSecretMBeanTest.java
(added)
+++ sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/UserCredentialsDistributionTransportSecretMBeanTest.java
Fri Nov 18 14:17:30 2016
@@ -0,0 +1,40 @@
+/*
+ * 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.distribution.monitor.impl;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+/**
+ * Test case for {@link UserCredentialsDistributionTransportSecretMBean}
+ */
+public class UserCredentialsDistributionTransportSecretMBeanTest {
+
+    @Test
+    public void verifyMBeanExposedValues() {
+        UserCredentialsDistributionTransportSecretMBean mBean = new UserCredentialsDistributionTransportSecretMBeanImpl("user");
+        assertFalse(mBean.useAdministrativeTransport());
+
+        mBean = new UserCredentialsDistributionTransportSecretMBeanImpl("admin");
+        assertTrue(mBean.useAdministrativeTransport());
+    }
+
+}

Propchange: sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/monitor/impl/UserCredentialsDistributionTransportSecretMBeanTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message