Author: rareddy
Date: 2012-09-14 11:57:37 -0400 (Fri, 14 Sep 2012)
New Revision: 4445
Modified:
trunk/test-integration/common/src/test/java/org/teiid/arquillian/AdminUtil.java
trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestRestWebserviceGeneration.java
Log:
TEIID-2158: further refinement of test
Modified: trunk/test-integration/common/src/test/java/org/teiid/arquillian/AdminUtil.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/arquillian/AdminUtil.java 2012-09-14
15:30:26 UTC (rev 4444)
+++
trunk/test-integration/common/src/test/java/org/teiid/arquillian/AdminUtil.java 2012-09-14
15:57:37 UTC (rev 4445)
@@ -22,11 +22,13 @@
package org.teiid.arquillian;
+import java.util.List;
import java.util.Properties;
import org.teiid.adminapi.Admin;
import org.teiid.adminapi.AdminException;
import org.teiid.adminapi.VDB;
+import org.teiid.adminapi.AdminFactory.AdminImpl;
import org.teiid.adminapi.VDB.Status;
@SuppressWarnings("nls")
@@ -78,5 +80,30 @@
} while (System.currentTimeMillis() < waitUntil);
return false;
}
+
+ static boolean waitForDeployment(Admin admin, String deploymentName,
+ int timeoutInSecs) {
+ long waitUntil = System.currentTimeMillis() + timeoutInSecs*1000;
+ if (timeoutInSecs < 0) {
+ waitUntil = Long.MAX_VALUE;
+ }
+ boolean first = true;
+ do {
+ if (!first) {
+ try {
+ Thread.sleep(2000);
+ } catch (InterruptedException e) {
+ break;
+ }
+ } else {
+ first = false;
+ }
+ List<String> deployments = ((AdminImpl)admin).getDeployments();
+ if (deployments.contains(deploymentName)) {
+ return true;
+ }
+ } while (System.currentTimeMillis() < waitUntil);
+ return false;
+ }
}
Modified:
trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestRestWebserviceGeneration.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestRestWebserviceGeneration.java 2012-09-14
15:30:26 UTC (rev 4444)
+++
trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestRestWebserviceGeneration.java 2012-09-14
15:57:37 UTC (rev 4445)
@@ -74,11 +74,11 @@
execute("SELECT * FROM Txns.G1"); //$NON-NLS-1$
this.internalResultSet.next();
- assertTrue(((AdminImpl)admin).getDeployments().contains("sample_1.war"));
+ assertTrue("sample_1.war not found", AdminUtil.waitForDeployment(admin,
"sample_1.war", 5));
// get based call
String response = httpCall("http://localhost:8080/sample_1/view/g1/123",
"GET", null);
- assertEquals("<rows
p1=\"123\"><row><e1>ABCDEFGHIJ</e1><e2>0</e2></row></rows>",
response);
+ assertEquals("response did not match expected", "<rows
p1=\"123\"><row><e1>ABCDEFGHIJ</e1><e2>0</e2></row></rows>",
response);
}
@Test
@@ -91,18 +91,18 @@
execute("SELECT * FROM Txns.G1"); //$NON-NLS-1$
this.internalResultSet.next();
- assertTrue(((AdminImpl)admin).getDeployments().contains("sample_1.war"));
+ assertTrue("sample_1.war not found", AdminUtil.waitForDeployment(admin,
"sample_1.war", 5));
String params = URLEncoder.encode("p1", "UTF-8") + "=" +
URLEncoder.encode("456", "UTF-8");
// post based call
String response = httpCall("http://localhost:8080/sample_1/view/g1post",
"POST", params);
- assertEquals("<rows
p1=\"456\"><row><e1>ABCDEFGHIJ</e1><e2>0</e2></row></rows>",
response);
+ assertEquals("response did not match expected", "<rows
p1=\"456\"><row><e1>ABCDEFGHIJ</e1><e2>0</e2></row></rows>",
response);
// ad-hoc procedure
params = URLEncoder.encode("sql", "UTF-8") + "=" +
URLEncoder.encode("SELECT XMLELEMENT(NAME \"rows\", XMLAGG(XMLELEMENT(NAME
\"row\", XMLFOREST(e1, e2)))) AS xml_out FROM Txns.G1",
"UTF-8");
response = httpCall("http://localhost:8080/sample_1/view/query",
"POST", params);
- assertEquals("<rows><row><e1>ABCDEFGHIJ</e1><e2>0</e2></row></rows>",
response);
+ assertEquals("response did not match expected",
"<rows><row><e1>ABCDEFGHIJ</e1><e2>0</e2></row></rows>",
response);
}
Show replies by date