mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[mielecloud] Run integration tests on random unoccupied port (#11448)
Signed-off-by: Björn Lange <bjoern.lange@tu-dortmund.de>
This commit is contained in:
parent
fbdecad174
commit
a1f2e236e1
@ -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.json',\
|
||||||
bnd.identity;id='org.openhab.core.storage.mapdb'
|
bnd.identity;id='org.openhab.core.storage.mapdb'
|
||||||
|
|
||||||
|
-runvm: -Dorg.osgi.service.http.port=${org.osgi.service.http.port}
|
||||||
|
|
||||||
#
|
#
|
||||||
# done
|
# done
|
||||||
#
|
#
|
||||||
|
@ -22,4 +22,27 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>build-helper-maven-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>reserve-network-port</id>
|
||||||
|
<goals>
|
||||||
|
<goal>reserve-network-port</goal>
|
||||||
|
</goals>
|
||||||
|
<phase>process-resources</phase>
|
||||||
|
<configuration>
|
||||||
|
<portNames>
|
||||||
|
<portName>org.osgi.service.http.port</portName>
|
||||||
|
</portNames>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -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.MieleCloudBindingIntegrationTestConstants;
|
||||||
import org.openhab.binding.mielecloud.internal.util.ReflectionUtil;
|
import org.openhab.binding.mielecloud.internal.util.ReflectionUtil;
|
||||||
import org.openhab.binding.mielecloud.internal.util.Website;
|
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.MieleWebservice;
|
||||||
import org.openhab.binding.mielecloud.internal.webservice.MieleWebserviceFactory;
|
import org.openhab.binding.mielecloud.internal.webservice.MieleWebserviceFactory;
|
||||||
import org.openhab.core.thing.Thing;
|
import org.openhab.core.thing.Thing;
|
||||||
@ -87,7 +88,8 @@ public class ConfigFlowTest extends AbstractConfigFlowTest {
|
|||||||
+ ForwardToLoginServlet.BRIDGE_ID_PARAMETER_NAME + "="
|
+ ForwardToLoginServlet.BRIDGE_ID_PARAMETER_NAME + "="
|
||||||
+ MieleCloudBindingIntegrationTestConstants.BRIDGE_ID + "&" + ForwardToLoginServlet.EMAIL_PARAMETER_NAME
|
+ MieleCloudBindingIntegrationTestConstants.BRIDGE_ID + "&" + ForwardToLoginServlet.EMAIL_PARAMETER_NAME
|
||||||
+ "=" + MieleCloudBindingIntegrationTestConstants.EMAIL);
|
+ "=" + 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");
|
String state = mieleLoginSite.getValueOfInput("state");
|
||||||
|
|
||||||
Website resultSite = getCrawler().doGetRelative(redirectionUrl + "?code="
|
Website resultSite = getCrawler().doGetRelative(redirectionUrl + "?code="
|
||||||
|
@ -40,8 +40,16 @@ public final class WebsiteCrawler {
|
|||||||
* @throws Exception if anything goes wrong.
|
* @throws Exception if anything goes wrong.
|
||||||
*/
|
*/
|
||||||
public Website doGetRelative(String relativeUrl) throws Exception {
|
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());
|
assertEquals(200, response.getStatus());
|
||||||
return new Website(response.getContentAsString());
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user