You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by tb...@apache.org on 2013/03/19 16:56:13 UTC
svn commit: r1458360 [3/3] - in /incubator/ambari/trunk: ./
ambari-server/src/main/java/org/apache/ambari/server/api/resources/
ambari-server/src/main/java/org/apache/ambari/server/api/services/
ambari-server/src/main/java/org/apache/ambari/server/cont...
Added: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/TargetClusterResourceProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/TargetClusterResourceProviderTest.java?rev=1458360&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/TargetClusterResourceProviderTest.java (added)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/TargetClusterResourceProviderTest.java Tue Mar 19 15:56:11 2013
@@ -0,0 +1,218 @@
+/**
+ * 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.ambari.server.controller.internal;
+
+
+import org.apache.ambari.server.controller.ivory.Cluster;
+import org.apache.ambari.server.controller.ivory.IvoryService;
+import org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.utilities.PredicateBuilder;
+import org.apache.ambari.server.controller.utilities.PropertyHelper;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
+/**
+ * Tests for TargetClusterResourceProvider.
+ */
+public class TargetClusterResourceProviderTest {
+ @Test
+ public void testCreateResources() throws Exception {
+ IvoryService service = createMock(IvoryService.class);
+
+ Set<Map<String, Object>> propertySet = new HashSet<Map<String, Object>>();
+
+ Map<String, Object> properties = new HashMap<String, Object>();
+
+ properties.put(TargetClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID, "Cluster1");
+ properties.put(TargetClusterResourceProvider.CLUSTER_COLO_PROPERTY_ID, "Colo");
+ properties.put(TargetClusterResourceProvider.CLUSTER_INTERFACES_PROPERTY_ID, Collections.singleton("Interface1"));
+ properties.put(TargetClusterResourceProvider.CLUSTER_LOCATIONS_PROPERTY_ID, Collections.singleton("Location1"));
+ properties.put(TargetClusterResourceProvider.CLUSTER_PROPERTIES_PROPERTY_ID, Collections.singletonMap("P1", "V1"));
+
+ // set expectations
+ service.submitCluster(TargetClusterResourceProvider.getCluster("Cluster1", properties));
+
+ // replay
+ replay(service);
+
+ propertySet.add(properties);
+
+ Request request = PropertyHelper.getCreateRequest(propertySet);
+
+ TargetClusterResourceProvider provider = new TargetClusterResourceProvider(service,
+ PropertyHelper.getPropertyIds(Resource.Type.DRTargetCluster),
+ PropertyHelper.getKeyPropertyIds(Resource.Type.DRTargetCluster));
+
+ provider.createResources(request);
+
+ // verify
+ verify(service);
+ }
+
+ @Test
+ public void testGetResources() throws Exception {
+ IvoryService service = createMock(IvoryService.class);
+
+ Set<Map<String, Object>> propertySet = new HashSet<Map<String, Object>>();
+
+ Map<String, Object> properties = new HashMap<String, Object>();
+
+ List<String> targetClusterNames = new LinkedList<String>();
+ targetClusterNames.add("Cluster1");
+ targetClusterNames.add("Cluster2");
+ targetClusterNames.add("Cluster3");
+
+ Cluster targetCluster1 = new Cluster("Cluster1", "Colo", Collections.singleton("Interface1"),
+ Collections.singleton("Location1"), Collections.singletonMap("P1", "V1"));
+ Cluster targetCluster2 = new Cluster("Cluster2", "Colo", Collections.singleton("Interface1"),
+ Collections.singleton("Location1"), Collections.singletonMap("P1", "V1"));
+ Cluster targetCluster3 = new Cluster("Cluster3", "Colo", Collections.singleton("Interface1"),
+ Collections.singleton("Location1"), Collections.singletonMap("P1", "V1"));
+
+ // set expectations
+ expect(service.getClusterNames()).andReturn(targetClusterNames);
+
+ expect(service.getCluster("Cluster1")).andReturn(targetCluster1);
+ expect(service.getCluster("Cluster2")).andReturn(targetCluster2);
+ expect(service.getCluster("Cluster3")).andReturn(targetCluster3);
+
+ // replay
+ replay(service);
+
+ propertySet.add(properties);
+
+ Request request = PropertyHelper.getCreateRequest(propertySet);
+
+ TargetClusterResourceProvider provider = new TargetClusterResourceProvider(service,
+ PropertyHelper.getPropertyIds(Resource.Type.DRTargetCluster),
+ PropertyHelper.getKeyPropertyIds(Resource.Type.DRTargetCluster));
+
+ Set<Resource> resources = provider.getResources(request, null);
+
+ Assert.assertEquals(3, resources.size());
+
+ // verify
+ verify(service);
+ }
+
+ @Test
+ public void testUpdateResources() throws Exception {
+ IvoryService service = createMock(IvoryService.class);
+
+ Set<Map<String, Object>> propertySet = new HashSet<Map<String, Object>>();
+
+ Map<String, Object> properties = new HashMap<String, Object>();
+
+ properties.put(TargetClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID, "Cluster1");
+ properties.put(TargetClusterResourceProvider.CLUSTER_COLO_PROPERTY_ID, "Colo");
+ properties.put(TargetClusterResourceProvider.CLUSTER_INTERFACES_PROPERTY_ID, Collections.singleton("Interface1"));
+ properties.put(TargetClusterResourceProvider.CLUSTER_LOCATIONS_PROPERTY_ID, Collections.singleton("Location1"));
+ properties.put(TargetClusterResourceProvider.CLUSTER_PROPERTIES_PROPERTY_ID, Collections.singletonMap("P1", "V1"));
+
+ List<String> targetClusterNames = new LinkedList<String>();
+ targetClusterNames.add("Cluster1");
+
+ Cluster targetCluster1 = new Cluster("Cluster1", "Colo", Collections.singleton("Interface1"),
+ Collections.singleton("Location1"), Collections.singletonMap("P1", "V1"));
+
+ // set expectations
+ expect(service.getClusterNames()).andReturn(targetClusterNames);
+
+ expect(service.getCluster("Cluster1")).andReturn(targetCluster1);
+
+ service.updateCluster(targetCluster1);
+
+ // replay
+ replay(service);
+
+ propertySet.add(properties);
+
+ Request request = PropertyHelper.getCreateRequest(propertySet);
+
+ TargetClusterResourceProvider provider = new TargetClusterResourceProvider(service,
+ PropertyHelper.getPropertyIds(Resource.Type.DRTargetCluster),
+ PropertyHelper.getKeyPropertyIds(Resource.Type.DRTargetCluster));
+
+ provider.updateResources(request, null);
+
+ // verify
+ verify(service);
+ }
+
+ @Test
+ public void testDeleteResources() throws Exception {
+ IvoryService service = createMock(IvoryService.class);
+
+ List<String> targetClusterNames = new LinkedList<String>();
+ targetClusterNames.add("Cluster1");
+
+ Cluster targetCluster1 = new Cluster("Cluster1", "Colo", Collections.singleton("Interface1"),
+ Collections.singleton("Location1"), Collections.singletonMap("P1", "V1"));
+
+ // set expectations
+ expect(service.getClusterNames()).andReturn(targetClusterNames);
+
+ expect(service.getCluster("Cluster1")).andReturn(targetCluster1);
+
+ service.deleteCluster("Cluster1");
+
+ // replay
+ replay(service);
+
+
+ TargetClusterResourceProvider provider = new TargetClusterResourceProvider(service,
+ PropertyHelper.getPropertyIds(Resource.Type.DRTargetCluster),
+ PropertyHelper.getKeyPropertyIds(Resource.Type.DRTargetCluster));
+
+ Predicate predicate = new PredicateBuilder().property(TargetClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID).equals("Cluster1").toPredicate();
+
+ provider.deleteResources(predicate);
+
+ // verify
+ verify(service);
+ }
+
+ @Test
+ public void testGetKeyPropertyIds() throws Exception {
+ IvoryService service = createMock(IvoryService.class);
+
+ Map<Resource.Type, String> keyPropertyIds = PropertyHelper.getKeyPropertyIds(Resource.Type.DRTargetCluster);
+
+ TargetClusterResourceProvider provider = new TargetClusterResourceProvider(service,
+ PropertyHelper.getPropertyIds(Resource.Type.DRTargetCluster),
+ keyPropertyIds);
+
+ Assert.assertEquals(keyPropertyIds, provider.getKeyPropertyIds());
+ }
+}
Modified: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/TaskResourceProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/TaskResourceProviderTest.java?rev=1458360&r1=1458359&r2=1458360&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/TaskResourceProviderTest.java (original)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/TaskResourceProviderTest.java Tue Mar 19 15:56:11 2013
@@ -56,7 +56,7 @@ public class TaskResourceProviderTest {
// replay
replay(managementController, response);
- ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+ ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
type,
PropertyHelper.getPropertyIds(type),
PropertyHelper.getKeyPropertyIds(type),
@@ -103,7 +103,7 @@ public class TaskResourceProviderTest {
// replay
replay(managementController);
- ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+ ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
type,
PropertyHelper.getPropertyIds(type),
PropertyHelper.getKeyPropertyIds(type),
@@ -139,7 +139,7 @@ public class TaskResourceProviderTest {
// replay
replay(managementController, response);
- ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+ ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
type,
PropertyHelper.getPropertyIds(type),
PropertyHelper.getKeyPropertyIds(type),
@@ -174,7 +174,7 @@ public class TaskResourceProviderTest {
// replay
replay(managementController);
- ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+ ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
type,
PropertyHelper.getPropertyIds(type),
PropertyHelper.getKeyPropertyIds(type),
Added: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/TestIvoryService.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/TestIvoryService.java?rev=1458360&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/TestIvoryService.java (added)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/TestIvoryService.java Tue Mar 19 15:56:11 2013
@@ -0,0 +1,184 @@
+package org.apache.ambari.server.controller.internal;
+
+import org.apache.ambari.server.controller.ivory.Cluster;
+import org.apache.ambari.server.controller.ivory.Feed;
+import org.apache.ambari.server.controller.ivory.Instance;
+import org.apache.ambari.server.controller.ivory.IvoryService;
+
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * An IvoryService implementation used for testing the DR related resource providers.
+ */
+public class TestIvoryService implements IvoryService{
+
+ private final Map<String, Feed> feeds = new HashMap<String, Feed>();
+ private final Map<String, Cluster> clusters = new HashMap<String, Cluster>();
+ private final Map<String, Map<String, Instance>> instanceMap = new HashMap<String, Map<String, Instance>>();
+
+ private final Map<String, String> suspendedFeedStatusMap = new HashMap<String, String>();
+ private final Map<String, String> suspendedInstanceStatusMap = new HashMap<String, String>();
+
+
+ public TestIvoryService(Map<String, Feed> feeds,
+ Map<String, Cluster> clusters,
+ HashMap<String, Map<String, Instance>> instanceMap) {
+ if (feeds != null) {
+ this.feeds.putAll(feeds);
+ }
+ if (clusters != null) {
+ this.clusters.putAll(clusters);
+ }
+ if (instanceMap != null) {
+ this.instanceMap.putAll(instanceMap);
+ }
+ }
+
+ @Override
+ public void submitFeed(Feed feed) {
+ feeds.put(feed.getName(), feed);
+ }
+
+ @Override
+ public Feed getFeed(String feedName) {
+ return feeds.get(feedName);
+ }
+
+ @Override
+ public List<String> getFeedNames() {
+ return new LinkedList<String>(feeds.keySet());
+ }
+
+ @Override
+ public void updateFeed(Feed feed) {
+ feeds.put(feed.getName(), feed);
+ }
+
+ @Override
+ public void suspendFeed(String feedName) {
+ suspendedFeedStatusMap.put(feedName, setFeedStatus(feedName, "SUSPENDED"));
+ }
+
+ @Override
+ public void resumeFeed(String feedName) {
+ String suspendedStatus = suspendedFeedStatusMap.get(feedName);
+ if (suspendedStatus != null) {
+ setFeedStatus(feedName, suspendedStatus);
+ suspendedFeedStatusMap.remove(feedName);
+ }
+ }
+
+ @Override
+ public void scheduleFeed(String feedName) {
+ setFeedStatus(feedName, "SCHEDULED");
+ }
+
+ @Override
+ public void deleteFeed(String feedName) {
+ feeds.remove(feedName);
+ }
+
+ @Override
+ public void submitCluster(Cluster cluster) {
+ clusters.put(cluster.getName(), cluster);
+ }
+
+ @Override
+ public Cluster getCluster(String clusterName) {
+ return clusters.get(clusterName);
+ }
+
+ @Override
+ public List<String> getClusterNames() {
+ return new LinkedList<String>(clusters.keySet());
+ }
+
+ @Override
+ public void updateCluster(Cluster cluster) {
+ clusters.put(cluster.getName(), cluster);
+ }
+
+ @Override
+ public void deleteCluster(String clusterName) {
+ clusters.remove(clusterName);
+ }
+
+ @Override
+ public List<Instance> getInstances(String feedName) {
+ return new LinkedList<Instance>(instanceMap.get(feedName).values());
+ }
+
+ @Override
+ public void suspendInstance(String feedName, String instanceId) {
+ String instanceKey = feedName + "/" + instanceId;
+
+ suspendedFeedStatusMap.put(instanceKey, setInstanceStatus(feedName, instanceId, "SUSPENDED"));
+ }
+
+ @Override
+ public void resumeInstance(String feedName, String instanceId) {
+ String instanceKey = feedName + "/" + instanceId;
+
+ String suspendedStatus = suspendedInstanceStatusMap.get(instanceKey);
+ if (suspendedStatus != null) {
+ setInstanceStatus(feedName, instanceId, suspendedStatus);
+ suspendedInstanceStatusMap.remove(instanceKey);
+ }
+ }
+
+ @Override
+ public void killInstance(String feedName, String instanceId) {
+ Map<String, Instance> instances = instanceMap.get(feedName);
+ if (instances != null) {
+ instances.remove(instanceId);
+ }
+ }
+
+
+ // ----- helper methods ----------------------------------------------------
+
+ private String setFeedStatus(String feedName, String status) {
+ String currentStatus = null;
+ Feed feed = feeds.get(feedName);
+
+ if (feed != null) {
+ currentStatus = feed.getStatus();
+ if (!currentStatus.equals(status)) {
+ feed = new Feed(feed.getName(),
+ feed.getDescription(),
+ status,
+ feed.getSchedule(),
+ feed.getSourceClusterName(),
+ feed.getTargetClusterName());
+ feeds.put(feed.getName(), feed);
+ }
+ }
+ return currentStatus;
+ }
+
+ private String setInstanceStatus(String feedName, String instanceId, String status) {
+ String currentStatus = null;
+ Map<String, Instance> instances = instanceMap.get(feedName);
+
+ if (instances != null) {
+ Instance instance = instances.get(instanceId);
+ if (instance != null) {
+ currentStatus = instance.getStatus();
+ if (!currentStatus.equals(status)) {
+ instance = new Instance(instance.getFeedName(),
+ instance.getId(),
+ status,
+ instance.getStartTime(),
+ instance.getEndTime(),
+ instance.getDetails(),
+ instance.getLog());
+ instances.put(instance.getId(), instance);
+ }
+ }
+ }
+ return currentStatus;
+ }
+}
Modified: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserResourceProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserResourceProviderTest.java?rev=1458360&r1=1458359&r2=1458360&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserResourceProviderTest.java (original)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserResourceProviderTest.java Tue Mar 19 15:56:11 2013
@@ -60,7 +60,7 @@ public class UserResourceProviderTest {
// replay
replay(managementController, response);
- ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+ ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
type,
PropertyHelper.getPropertyIds(type),
PropertyHelper.getKeyPropertyIds(type),
@@ -101,7 +101,7 @@ public class UserResourceProviderTest {
// replay
replay(managementController);
- ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+ ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
type,
PropertyHelper.getPropertyIds(type),
PropertyHelper.getKeyPropertyIds(type),
@@ -140,7 +140,7 @@ public class UserResourceProviderTest {
// replay
replay(managementController, response);
- ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+ ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
type,
PropertyHelper.getPropertyIds(type),
PropertyHelper.getKeyPropertyIds(type),
@@ -175,7 +175,7 @@ public class UserResourceProviderTest {
// replay
replay(managementController, response);
- ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+ ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
type,
PropertyHelper.getPropertyIds(type),
PropertyHelper.getKeyPropertyIds(type),
Added: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/ivory/ClusterTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/ivory/ClusterTest.java?rev=1458360&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/ivory/ClusterTest.java (added)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/ivory/ClusterTest.java Tue Mar 19 15:56:11 2013
@@ -0,0 +1,64 @@
+/**
+ * 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.ambari.server.controller.ivory;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.Collections;
+
+/**
+ * Cluster tests.
+ */
+public class ClusterTest {
+ @Test
+ public void testGetName() throws Exception {
+ Cluster cluster = new Cluster("Cluster1", "Colo", Collections.singleton("Interface1"),
+ Collections.singleton("Location1"), Collections.singletonMap("P1", "V1"));
+ Assert.assertEquals("Cluster1", cluster.getName());
+ }
+
+ @Test
+ public void testGetColo() throws Exception {
+ Cluster cluster = new Cluster("Cluster1", "Colo", Collections.singleton("Interface1"),
+ Collections.singleton("Location1"), Collections.singletonMap("P1", "V1"));
+ Assert.assertEquals("Colo", cluster.getColo());
+ }
+
+ @Test
+ public void testGetInterfaces() throws Exception {
+ Cluster cluster = new Cluster("Cluster1", "Colo", Collections.singleton("Interface1"),
+ Collections.singleton("Location1"), Collections.singletonMap("P1", "V1"));
+ Assert.assertEquals(Collections.singleton("Interface1"), cluster.getInterfaces());
+ }
+
+ @Test
+ public void testGetLocations() throws Exception {
+ Cluster cluster = new Cluster("Cluster1", "Colo", Collections.singleton("Interface1"),
+ Collections.singleton("Location1"), Collections.singletonMap("P1", "V1"));
+ Assert.assertEquals(Collections.singleton("Location1"), cluster.getLocations());
+ }
+
+ @Test
+ public void testGetProperties() throws Exception {
+ Cluster cluster = new Cluster("Cluster1", "Colo", Collections.singleton("Interface1"),
+ Collections.singleton("Location1"), Collections.singletonMap("P1", "V1"));
+ Assert.assertEquals(Collections.singletonMap("P1", "V1"), cluster.getProperties());
+ }
+}
Added: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/ivory/FeedTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/ivory/FeedTest.java?rev=1458360&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/ivory/FeedTest.java (added)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/ivory/FeedTest.java Tue Mar 19 15:56:11 2013
@@ -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.ambari.server.controller.ivory;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Feed tests.
+ */
+public class FeedTest {
+ @Test
+ public void testGetName() throws Exception {
+ Feed feed = new Feed("Feed1", "desc", "SUBMITTED", "sched", "source", "target");
+ Assert.assertEquals("Feed1", feed.getName());
+ }
+
+ @Test
+ public void testGetDescription() throws Exception {
+ Feed feed = new Feed("Feed1", "desc", "SUBMITTED", "sched", "source", "target");
+ Assert.assertEquals("desc", feed.getDescription());
+ }
+
+ @Test
+ public void testGetStatus() throws Exception {
+ Feed feed = new Feed("Feed1", "desc", "SUBMITTED", "sched", "source", "target");
+ Assert.assertEquals("SUBMITTED", feed.getStatus());
+ }
+
+ @Test
+ public void testGetSchedule() throws Exception {
+ Feed feed = new Feed("Feed1", "desc", "SUBMITTED", "sched", "source", "target");
+ Assert.assertEquals("sched", feed.getSchedule());
+ }
+
+ @Test
+ public void testGetSourceClusterName() throws Exception {
+ Feed feed = new Feed("Feed1", "desc", "SUBMITTED", "sched", "source", "target");
+ Assert.assertEquals("source", feed.getSourceClusterName());
+ }
+
+ @Test
+ public void testGetTargetClusterName() throws Exception {
+ Feed feed = new Feed("Feed1", "desc", "SUBMITTED", "sched", "source", "target");
+ Assert.assertEquals("target", feed.getTargetClusterName());
+ }
+}
Added: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/ivory/InstanceTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/ivory/InstanceTest.java?rev=1458360&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/ivory/InstanceTest.java (added)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/ivory/InstanceTest.java Tue Mar 19 15:56:11 2013
@@ -0,0 +1,69 @@
+/**
+ * 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.ambari.server.controller.ivory;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Instance tests.
+ */
+public class InstanceTest {
+ @Test
+ public void testGetFeedName() throws Exception {
+ Instance instance = new Instance("Feed1", "Instance1", "SUBMITTED", "start", "end", "details", "log");
+ Assert.assertEquals("Feed1", instance.getFeedName());
+ }
+
+ @Test
+ public void testGetId() throws Exception {
+ Instance instance = new Instance("Feed1", "Instance1", "SUBMITTED", "start", "end", "details", "log");
+ Assert.assertEquals("Instance1", instance.getId());
+ }
+
+ @Test
+ public void testGetStatus() throws Exception {
+ Instance instance = new Instance("Feed1", "Instance1", "SUBMITTED", "start", "end", "details", "log");
+ Assert.assertEquals("SUBMITTED", instance.getStatus());
+ }
+
+ @Test
+ public void testGetStartTime() throws Exception {
+ Instance instance = new Instance("Feed1", "Instance1", "SUBMITTED", "start", "end", "details", "log");
+ Assert.assertEquals("start", instance.getStartTime());
+ }
+
+ @Test
+ public void testGetEndTime() throws Exception {
+ Instance instance = new Instance("Feed1", "Instance1", "SUBMITTED", "start", "end", "details", "log");
+ Assert.assertEquals("end", instance.getEndTime());
+ }
+
+ @Test
+ public void testGetDetails() throws Exception {
+ Instance instance = new Instance("Feed1", "Instance1", "SUBMITTED", "start", "end", "details", "log");
+ Assert.assertEquals("details", instance.getDetails());
+ }
+
+ @Test
+ public void testGetLog() throws Exception {
+ Instance instance = new Instance("Feed1", "Instance1", "SUBMITTED", "start", "end", "details", "log");
+ Assert.assertEquals("log", instance.getLog());
+ }
+}