mirror of https://github.com/apache/activemq.git
Fixed the karaf webconsole test.
This commit is contained in:
parent
b8d5ca8383
commit
92ee5c6bab
|
@ -22,6 +22,7 @@ import org.apache.commons.httpclient.UsernamePasswordCredentials;
|
||||||
import org.apache.commons.httpclient.auth.AuthScope;
|
import org.apache.commons.httpclient.auth.AuthScope;
|
||||||
import org.apache.commons.httpclient.methods.GetMethod;
|
import org.apache.commons.httpclient.methods.GetMethod;
|
||||||
import org.apache.commons.httpclient.methods.PostMethod;
|
import org.apache.commons.httpclient.methods.PostMethod;
|
||||||
|
import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.ops4j.pax.exam.CoreOptions;
|
import org.ops4j.pax.exam.CoreOptions;
|
||||||
import org.ops4j.pax.exam.Option;
|
import org.ops4j.pax.exam.Option;
|
||||||
|
@ -46,28 +47,45 @@ public class ActiveMQBrokerNdWebConsoleFeatureTest extends ActiveMQBrokerFeature
|
||||||
@Override
|
@Override
|
||||||
protected void produceMessage(String nameAndPayload) throws Exception {
|
protected void produceMessage(String nameAndPayload) throws Exception {
|
||||||
HttpClient client = new HttpClient();
|
HttpClient client = new HttpClient();
|
||||||
|
client.getHttpConnectionManager().getParams().setConnectionTimeout(30000);
|
||||||
|
|
||||||
System.err.println(executeCommand("activemq:bstat").trim());
|
System.err.println(executeCommand("activemq:bstat").trim());
|
||||||
|
System.err.println("attempting to access web console..");
|
||||||
|
|
||||||
|
GetMethod get = new GetMethod(WEB_CONSOLE_URL + "index.jsp");
|
||||||
|
|
||||||
|
// Give console some time to start
|
||||||
|
boolean done = false;
|
||||||
|
int loop = 0;
|
||||||
|
while (!done && loop < 30) {
|
||||||
|
loop++;
|
||||||
|
try {
|
||||||
|
int code = client.executeMethod(get);
|
||||||
|
if (code > 399 && code < 500) {
|
||||||
|
// code 4xx we should retry
|
||||||
|
System.err.println("web console not accessible yet - status code " + code);
|
||||||
|
TimeUnit.SECONDS.sleep(1);
|
||||||
|
} else {
|
||||||
|
done = true;
|
||||||
|
}
|
||||||
|
} catch (Exception ignored) {}
|
||||||
|
}
|
||||||
|
assertEquals("get succeeded on " + get, 200, get.getStatusCode());
|
||||||
|
|
||||||
System.err.println("attempting publish via web console..");
|
System.err.println("attempting publish via web console..");
|
||||||
|
|
||||||
|
// need to first get the secret
|
||||||
|
get = new GetMethod(WEB_CONSOLE_URL + "send.jsp");
|
||||||
|
get.setDoAuthentication(true);
|
||||||
|
|
||||||
// set credentials
|
// set credentials
|
||||||
client.getState().setCredentials(
|
client.getState().setCredentials(
|
||||||
new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT),
|
new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT),
|
||||||
new UsernamePasswordCredentials(USER, PASSWORD)
|
new UsernamePasswordCredentials(USER, PASSWORD)
|
||||||
);
|
);
|
||||||
|
|
||||||
// need to first get the secret
|
int code = client.executeMethod(get);
|
||||||
GetMethod get = new GetMethod(WEB_CONSOLE_URL + "send.jsp");
|
assertEquals("get succeeded on " + get, 200, code);
|
||||||
get.setDoAuthentication(true);
|
|
||||||
|
|
||||||
// Give console some time to start
|
|
||||||
for (int i=0; i<20; i++) {
|
|
||||||
TimeUnit.SECONDS.sleep(1);
|
|
||||||
try {
|
|
||||||
i = client.executeMethod(get);
|
|
||||||
} catch (java.net.ConnectException ignored) {}
|
|
||||||
}
|
|
||||||
assertEquals("get succeeded on " + get, 200, get.getStatusCode());
|
|
||||||
|
|
||||||
String response = get.getResponseBodyAsString();
|
String response = get.getResponseBodyAsString();
|
||||||
final String secretMarker = "<input type=\"hidden\" name=\"secret\" value=\"";
|
final String secretMarker = "<input type=\"hidden\" name=\"secret\" value=\"";
|
||||||
|
|
Loading…
Reference in New Issue