Skip to content

Commit

Permalink
Exclude network devices when getting the local platform for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
pnguyen committed Oct 14, 2009
1 parent d0d54f1 commit 001eb31
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 29 deletions.
14 changes: 11 additions & 3 deletions src/org/hyperic/hq/hqapi1/test/HQApiTestBase.java
Expand Up @@ -181,15 +181,23 @@ protected Resource getLocalPlatformResource(boolean verbose,
children);
hqAssertSuccess(resourceResponse);

List<Resource> localPlatforms = resourceResponse.getResource();
if (localPlatforms.size() == 0) {
Resource localPlatform = null;

for (Resource r : resourceResponse.getResource()) {
if (!r.getResourcePrototype().getName().equals("Network Device")) {
localPlatform = r;
break;
}
}

if (localPlatform == null) {
String err = "Unable to find platform associated with agent " +
a.getAddress() + ":" + a.getPort();
getLog().error(err);
throw new Exception(err);
}

return localPlatforms.get(0);
return localPlatform;
}

public Resource createControllableResource(HQApi api)
Expand Down
10 changes: 1 addition & 9 deletions src/org/hyperic/hq/hqapi1/test/MetricDataAddData_test.java
Expand Up @@ -8,10 +8,8 @@
import org.hyperic.hq.hqapi1.types.Metric;
import org.hyperic.hq.hqapi1.types.DataPoint;
import org.hyperic.hq.hqapi1.types.StatusResponse;
import org.hyperic.hq.hqapi1.types.Agent;
import org.hyperic.hq.hqapi1.types.ResourcePrototypeResponse;
import org.hyperic.hq.hqapi1.types.ResourcePrototype;
import org.hyperic.hq.hqapi1.types.ResourcesResponse;
import org.hyperic.hq.hqapi1.types.ResourceResponse;
import org.hyperic.hq.hqapi1.types.MetricResponse;
import org.hyperic.hq.hqapi1.types.MetricDataResponse;
Expand All @@ -33,7 +31,6 @@ public void testAddDataSinglePoint() throws Exception {
ResourceApi resourceApi = getApi().getResourceApi();
MetricApi metricApi = getApi().getMetricApi();
MetricDataApi dataApi = getApi().getMetricDataApi();
Agent a = getRunningAgent();

// Find HTTP resource type
ResourcePrototypeResponse protoResponse =
Expand All @@ -42,12 +39,7 @@ public void testAddDataSinglePoint() throws Exception {
ResourcePrototype pt = protoResponse.getResourcePrototype();

// Find local platform
ResourcesResponse resourcesResponse =
resourceApi.getResources(a, false, false);
hqAssertSuccess(resourcesResponse);
assertTrue("Did not find a single platform for " + a.getAddress() + ":" +
a.getPort(), resourcesResponse.getResource().size() == 1);
Resource platform = resourcesResponse.getResource().get(0);
Resource platform = getLocalPlatformResource(false, false);

// Configure service
Map<String,String> params = new HashMap<String,String>();
Expand Down
Expand Up @@ -34,7 +34,6 @@
import org.hyperic.hq.hqapi1.types.ResourcePrototype;
import org.hyperic.hq.hqapi1.types.ResourcesResponse;
import org.hyperic.hq.hqapi1.types.ResourceResponse;
import org.hyperic.hq.hqapi1.types.Agent;

import java.util.Map;
import java.util.HashMap;
Expand Down Expand Up @@ -129,8 +128,6 @@ public void testServiceCreateInvalidDescription() throws Exception {
// this test which may cause a transaction failure
pauseTest();

Agent a = getRunningAgent();

ResourceApi api = getApi().getResourceApi();

// Find HTTP resource type
Expand All @@ -139,11 +136,7 @@ public void testServiceCreateInvalidDescription() throws Exception {
ResourcePrototype pt = protoResponse.getResourcePrototype();

// Find local platform
ResourcesResponse resourcesResponse = api.getResources(a, false, false);
hqAssertSuccess(resourcesResponse);
assertTrue("Did not find a single platform for " + a.getAddress() + ":" +
a.getPort(), resourcesResponse.getResource().size() == 1);
Resource platform = resourcesResponse.getResource().get(0);
Resource platform = getLocalPlatformResource(false, false);

String longDescription = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
Expand Down
10 changes: 1 addition & 9 deletions src/org/hyperic/hq/hqapi1/test/ResourceTestBase.java
Expand Up @@ -28,14 +28,12 @@
package org.hyperic.hq.hqapi1.test;

import org.hyperic.hq.hqapi1.ResourceApi;
import org.hyperic.hq.hqapi1.types.Agent;
import org.hyperic.hq.hqapi1.types.Resource;
import org.hyperic.hq.hqapi1.types.ResourceConfig;
import org.hyperic.hq.hqapi1.types.ResourceProperty;
import org.hyperic.hq.hqapi1.types.ResourcePrototype;
import org.hyperic.hq.hqapi1.types.ResourcePrototypeResponse;
import org.hyperic.hq.hqapi1.types.ResourceResponse;
import org.hyperic.hq.hqapi1.types.ResourcesResponse;

import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -78,8 +76,6 @@ protected void validateResource(Resource r) {

protected Resource createTestHTTPService() throws Exception {

Agent a = getRunningAgent();

ResourceApi api = getApi().getResourceApi();

// Find HTTP resource type
Expand All @@ -88,11 +84,7 @@ protected Resource createTestHTTPService() throws Exception {
ResourcePrototype pt = protoResponse.getResourcePrototype();

// Find local platform
ResourcesResponse resourcesResponse = api.getResources(a, false, false);
hqAssertSuccess(resourcesResponse);
assertTrue("Did not find a single platform for " + a.getAddress() + ":" +
a.getPort(), resourcesResponse.getResource().size() == 1);
Resource platform = resourcesResponse.getResource().get(0);
Resource platform = getLocalPlatformResource(false, false);

// Configure service
Map<String,String> params = new HashMap<String,String>();
Expand Down

0 comments on commit 001eb31

Please sign in to comment.