diff --git a/itests/org.openhab.binding.mielecloud.tests/itest.bndrun b/itests/org.openhab.binding.mielecloud.tests/itest.bndrun index 47773da6de7..0fa85e225e0 100644 --- a/itests/org.openhab.binding.mielecloud.tests/itest.bndrun +++ b/itests/org.openhab.binding.mielecloud.tests/itest.bndrun @@ -12,6 +12,8 @@ Fragment-Host: org.openhab.binding.mielecloud bnd.identity;id='org.openhab.core.storage.json',\ bnd.identity;id='org.openhab.core.storage.mapdb' +-runvm: -Dorg.osgi.service.http.port=${org.osgi.service.http.port} + # # done # diff --git a/itests/org.openhab.binding.mielecloud.tests/pom.xml b/itests/org.openhab.binding.mielecloud.tests/pom.xml index a21efcf275a..bc399d0d5a9 100644 --- a/itests/org.openhab.binding.mielecloud.tests/pom.xml +++ b/itests/org.openhab.binding.mielecloud.tests/pom.xml @@ -22,4 +22,27 @@ + + + + org.codehaus.mojo + build-helper-maven-plugin + + + reserve-network-port + + reserve-network-port + + process-resources + + + org.osgi.service.http.port + + + + + + + + diff --git a/itests/org.openhab.binding.mielecloud.tests/src/main/java/org/openhab/binding/mielecloud/internal/config/ConfigFlowTest.java b/itests/org.openhab.binding.mielecloud.tests/src/main/java/org/openhab/binding/mielecloud/internal/config/ConfigFlowTest.java index 70f545ca9b4..ecb396aef40 100644 --- a/itests/org.openhab.binding.mielecloud.tests/src/main/java/org/openhab/binding/mielecloud/internal/config/ConfigFlowTest.java +++ b/itests/org.openhab.binding.mielecloud.tests/src/main/java/org/openhab/binding/mielecloud/internal/config/ConfigFlowTest.java @@ -29,6 +29,7 @@ import org.openhab.binding.mielecloud.internal.util.AbstractConfigFlowTest; import org.openhab.binding.mielecloud.internal.util.MieleCloudBindingIntegrationTestConstants; import org.openhab.binding.mielecloud.internal.util.ReflectionUtil; import org.openhab.binding.mielecloud.internal.util.Website; +import org.openhab.binding.mielecloud.internal.util.WebsiteCrawler; import org.openhab.binding.mielecloud.internal.webservice.MieleWebservice; import org.openhab.binding.mielecloud.internal.webservice.MieleWebserviceFactory; import org.openhab.core.thing.Thing; @@ -87,7 +88,8 @@ public class ConfigFlowTest extends AbstractConfigFlowTest { + ForwardToLoginServlet.BRIDGE_ID_PARAMETER_NAME + "=" + MieleCloudBindingIntegrationTestConstants.BRIDGE_ID + "&" + ForwardToLoginServlet.EMAIL_PARAMETER_NAME + "=" + MieleCloudBindingIntegrationTestConstants.EMAIL); - String redirectionUrl = mieleLoginSite.getValueOfInput("redirect_uri").replace("http://127.0.0.1:8080", ""); + String redirectionUrl = mieleLoginSite.getValueOfInput("redirect_uri") + .replace("http://127.0.0.1:" + WebsiteCrawler.getServerPort(), ""); String state = mieleLoginSite.getValueOfInput("state"); Website resultSite = getCrawler().doGetRelative(redirectionUrl + "?code=" diff --git a/itests/org.openhab.binding.mielecloud.tests/src/main/java/org/openhab/binding/mielecloud/internal/util/WebsiteCrawler.java b/itests/org.openhab.binding.mielecloud.tests/src/main/java/org/openhab/binding/mielecloud/internal/util/WebsiteCrawler.java index 50ab0ccaafb..c2801d79279 100644 --- a/itests/org.openhab.binding.mielecloud.tests/src/main/java/org/openhab/binding/mielecloud/internal/util/WebsiteCrawler.java +++ b/itests/org.openhab.binding.mielecloud.tests/src/main/java/org/openhab/binding/mielecloud/internal/util/WebsiteCrawler.java @@ -40,8 +40,16 @@ public final class WebsiteCrawler { * @throws Exception if anything goes wrong. */ public Website doGetRelative(String relativeUrl) throws Exception { - ContentResponse response = httpClient.GET("http://127.0.0.1:8080" + relativeUrl); + ContentResponse response = httpClient.GET("http://127.0.0.1:" + getServerPort() + relativeUrl); assertEquals(200, response.getStatus()); return new Website(response.getContentAsString()); } + + /** + * Gets the port the webserver for this integration test instance is running on. The port is reserved in the pom.xml + * by the build-helper-maven-plugin. + */ + public static int getServerPort() { + return Integer.getInteger("org.osgi.service.http.port", 8080); + } }