Skip to content

Commit

Permalink
fix: tentative test update
Browse files Browse the repository at this point in the history
Signed-off-by: MMaiero <[email protected]>
  • Loading branch information
MMaiero committed Dec 20, 2024
1 parent 0a795d9 commit b4be270
Showing 1 changed file with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,18 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors;

import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;

import org.apache.commons.io.IOUtils;
import org.eclipse.kura.KuraException;
import org.eclipse.kura.configuration.ConfigurableComponent;
import org.eclipse.kura.configuration.ConfigurationService;
import org.eclipse.kura.core.testutil.service.ServiceUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -70,6 +74,12 @@ public void init() {
}

try {
final ConfigurationService configurationService = trackService(ConfigurationService.class);
Map<String, Object> restServiceConfiguration = initialRestServiceConfiguration();

ServiceUtil.updateComponentConfiguration(configurationService, "org.eclipse.kura.internal.rest.provider.RestService", restServiceConfiguration).get(30,
TimeUnit.SECONDS);

waitPortOpen("localhost", 8080, 3, TimeUnit.MINUTES);

ServiceUtil
Expand All @@ -78,7 +88,7 @@ public void init() {
.get(1, TimeUnit.MINUTES);

Thread.sleep(1000);

initialized = true;
} catch (final InterruptedException e) {
Thread.currentThread().interrupt();
Expand All @@ -87,6 +97,21 @@ public void init() {
throw new IllegalStateException(e);
}
}

private <T> T trackService(final Class<T> classz)
throws InterruptedException, ExecutionException, TimeoutException {
return ServiceUtil
.trackService(classz, Optional.empty()).get(30, TimeUnit.SECONDS);
}

private Map<String, Object> initialRestServiceConfiguration() throws KuraException {

final Map<String, Object> restServiceConfiguration = new HashMap<>();

restServiceConfiguration.put("allowed.ports", "[8080,443,4443]");

return restServiceConfiguration;
}

public static void waitPortOpen(final String host, final int port, final long timeout, final TimeUnit timeoutUnit)
throws InterruptedException {
Expand Down

0 comments on commit b4be270

Please sign in to comment.