From: <rm...@hy...> - 2008-11-13 22:04:58
|
Author: rmorgan Date: 2008-11-13 14:04:54 -0800 (Thu, 13 Nov 2008) New Revision: 251 URL: http://svn.hyperic.org/?view=rev&root=HQApi&revision=251 Added: trunk/src/org/hyperic/hq/hqapi1/test/ResourceTestBase.java Modified: trunk/src/org/hyperic/hq/hqapi1/test/ResourceFind_test.java trunk/src/org/hyperic/hq/hqapi1/test/ResourceGet_test.java Log: Add base class for handling resource validation. Modified: trunk/src/org/hyperic/hq/hqapi1/test/ResourceFind_test.java =================================================================== --- trunk/src/org/hyperic/hq/hqapi1/test/ResourceFind_test.java 2008-11-13 22:00:16 UTC (rev 250) +++ trunk/src/org/hyperic/hq/hqapi1/test/ResourceFind_test.java 2008-11-13 22:04:54 UTC (rev 251) @@ -3,18 +3,12 @@ import org.hyperic.hq.hqapi1.ResourceApi; import org.hyperic.hq.hqapi1.types.*; -public class ResourceFind_test extends HQApiTestBase { +public class ResourceFind_test extends ResourceTestBase { public ResourceFind_test(String name) { super(name); } - private void validateResource(Resource r) { - assertNotNull(r); - assertNotNull(r.getId()); - assertNotNull(r.getName()); - } - public void testFindByAgent() throws Exception { ResourceApi api = getApi().getResourceApi(); Modified: trunk/src/org/hyperic/hq/hqapi1/test/ResourceGet_test.java =================================================================== --- trunk/src/org/hyperic/hq/hqapi1/test/ResourceGet_test.java 2008-11-13 22:00:16 UTC (rev 250) +++ trunk/src/org/hyperic/hq/hqapi1/test/ResourceGet_test.java 2008-11-13 22:04:54 UTC (rev 251) @@ -6,7 +6,7 @@ import org.hyperic.hq.hqapi1.types.FindResourcesResponse; import org.hyperic.hq.hqapi1.types.Resource; -public class ResourceGet_test extends HQApiTestBase { +public class ResourceGet_test extends ResourceTestBase { public ResourceGet_test(String name) { super(name); @@ -45,10 +45,7 @@ GetResourceResponse getResponse = api.getResource(rid); hqAssertSuccess(getResponse); Resource resource = getResponse.getResource(); - assertNotNull(resource); - assertTrue("Invalid resource id " + r.getId(), - r.getId() > 0); - assertNotNull(resource.getName()); + validateResource(resource); } } @@ -62,6 +59,7 @@ GetResourceResponse resp = api.getResourceByPlatform(ID_10001); hqAssertSuccess(resp); + validateResource(resp.getResource()); } public void testGetResourceByInvalidPlatform() throws Exception { @@ -78,6 +76,7 @@ GetResourceResponse resp = api.getResourceByServer(ID_10001); hqAssertSuccess(resp); + validateResource(resp.getResource()); } public void testGetResourceByInvalidServer() throws Exception { @@ -94,6 +93,7 @@ GetResourceResponse resp = api.getResourceByService(ID_10001); hqAssertSuccess(resp); + validateResource(resp.getResource()); } public void testGetResourceByInvalidService() throws Exception { Added: trunk/src/org/hyperic/hq/hqapi1/test/ResourceTestBase.java =================================================================== --- trunk/src/org/hyperic/hq/hqapi1/test/ResourceTestBase.java (rev 0) +++ trunk/src/org/hyperic/hq/hqapi1/test/ResourceTestBase.java 2008-11-13 22:04:54 UTC (rev 251) @@ -0,0 +1,19 @@ +package org.hyperic.hq.hqapi1.test; + +import org.hyperic.hq.hqapi1.types.Resource; + +public class ResourceTestBase extends HQApiTestBase { + + public ResourceTestBase(String name) { + super(name); + } + + protected void validateResource(Resource r) { + assertNotNull(r); + assertNotNull(r.getId()); + assertNotNull(r.getName()); + + assertTrue("No configuration properties found for resource id " + + r.getId(), r.getResourceConfig().size() > 0); + } +} |