From 83a4110d07b238f7130675eb040af74215dc5f03 Mon Sep 17 00:00:00 2001
From: Peter Hormanns <peter.hormanns@jalin.de>
Date: Thu, 02 May 2013 13:41:10 +0200
Subject: [PATCH] extend test managed hive pac

---
 hsarback/test/de/hsadmin/remote/PacTest.java |   46 +++++++++++++++++++---------------------------
 1 files changed, 19 insertions(+), 27 deletions(-)

diff --git a/hsarback/test/de/hsadmin/remote/PacTest.java b/hsarback/test/de/hsadmin/remote/PacTest.java
index 952f724..cb2957a 100644
--- a/hsarback/test/de/hsadmin/remote/PacTest.java
+++ b/hsarback/test/de/hsadmin/remote/PacTest.java
@@ -2,7 +2,6 @@
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
@@ -139,13 +138,13 @@
 		Object[] params = new Object[] { user, 
 				cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), 
 				setParams };
-		try {
-			Object execute = client.execute(MODULE + ".add", params);
-			assertTrue(execute instanceof Map<?, ?>);
-		} catch (XmlRpcException e) {
-			fail(e.getMessage());
-		}
-		assertEquals(count + 1, getPacsCount());
+//		try {
+//			Object execute = client.execute(MODULE + ".add", params);
+//			assertTrue(execute instanceof Map<?, ?>);
+//		} catch (XmlRpcException e) {
+//			fail(e.getMessage());
+//		}
+//		assertEquals(count + 1, getPacsCount());
 		Map<String, String> whereParams = new HashMap<String, String>();
 		whereParams.put("name", "aaa90");
 		params = new Object[] { user, 
@@ -156,28 +155,21 @@
 			assertTrue(execute instanceof Object[]);
 			Object[] resultArr = (Object[]) execute;
 			assertEquals(1, resultArr.length);
+			assertTrue(resultArr[0] instanceof Map<?, ?>);
+			@SuppressWarnings("unchecked")
+			Map<String, Object> pacHash = (Map<String, Object>) resultArr[0];
+			assertEquals("aaa90", pacHash.get("name"));
+			assertNotNull(pacHash.get("components"));
+			assertTrue(pacHash.get("components") instanceof Map<?, ?>);
+			@SuppressWarnings("unchecked")
+			Map<String, String> components = (Map<String, String>) pacHash.get("components");
+			assertEquals(3,  components.size());
+			assertEquals("25", components.get("DISK"));
+			assertEquals("1", components.get("CPU"));
+			assertEquals("10", components.get("TRAFFIC"));
 		} catch (XmlRpcException e) {
 			fail(e.getMessage());
 		}
-	}
-
-//	@Test
-	public void testDelete() {
-		int count = getPacsCount();
-		String user = "ad";
-		String grantingTicketURL = cas.getGrantingTicketURL(user);
-		Map<String, String> whereParams = new HashMap<String, String>();
-		whereParams.put("name", "aaa01");
-		Object[] params = new Object[] { user, 
-				cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), 
-				whereParams };
-		try {
-			Object execute = client.execute(MODULE + ".delete", params);
-			assertNull(execute);
-		} catch (XmlRpcException e) {
-			fail(e.getMessage());
-		}
-		assertEquals(count - 1, getPacsCount());
 	}
 
 	private int getPacsCount() {

--
Gitblit v1.9.1