package io.hawt.embedded;

import org.apache.http.HttpResponse;
import org.apache.http.client.fluent.Request;
import org.junit.Test;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;

public class MainTest {

    @Test
    public void run() throws Exception {
        System.setProperty("hawtio.authenticationEnabled", "false");

        Main main = new Main();
        main.setWarLocation("../hawtio-default/target/");
        main.run();

        HttpResponse response = Request.Get("http://localhost:8080/hawtio/jolokia/version")
            .execute().returnResponse();
        assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
    }

}

@@ -364,16 +364,42 @@
 false%22);
+%0A        int port = 12345;
 %0A%0A      
@@ -478,24 +478,52 @@
 /target/%22);%0A
+        main.setPort(port);%0A
         main
@@ -575,16 +575,30 @@
 est.Get(
+String.format(
 %22http://
@@ -611,12 +611,10 @@
 ost:
-8080
+%25s
 /haw
@@ -633,16 +633,23 @@
 version%22
+, port)
 )%0A      

Change port number in hawtio-embedded test from 8080 to avoid potential port conflicts