Skip to content

Commit

Permalink
Fixup 5cf6095 SolrTest failure when using CloundContainer #2967 - do …
Browse files Browse the repository at this point in the history
…not assume the class path resource is accessible via filesystem
  • Loading branch information
ppalaga committed Aug 27, 2021
1 parent 6224538 commit e5e768a
Showing 1 changed file with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
package org.apache.camel.quarkus.component.solr.it;

import java.io.File;
import java.net.URI;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.Map;

import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
Expand Down Expand Up @@ -113,19 +116,21 @@ private void createSslContainer() {
* creates a cloud container with zookeeper
*/
private void createCloudContainer() {
URI uri = null;
final String resource = SystemUtils.IS_OS_LINUX ? "cloud-docker-compose.yml" : "cloud-docker-compose_nonlinux.yml";
try {
if (SystemUtils.IS_OS_LINUX) {
uri = this.getClass().getClassLoader().getResource("cloud-docker-compose.yml").toURI();
} else {
uri = this.getClass().getClassLoader().getResource("cloud-docker-compose_nonlinux.yml").toURI();
final File file = File.createTempFile(SolrTestResource.class.getSimpleName() + "-", resource);
file.deleteOnExit();
try (InputStream in = this.getClass().getClassLoader().getResourceAsStream(resource)) {
Files.copy(in, file.toPath(), StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e) {
throw new RuntimeException("Could not copy class path resource " + resource + " to " + file, e);
}
cloudContainer = new DockerComposeContainer(new File(uri))
cloudContainer = new DockerComposeContainer(file)
.withExposedService("solr1", SOLR_PORT)
.withExposedService("zoo1", ZOOKEEPER_PORT)
.waitingFor("create-collection", Wait.forLogMessage(".*Created collection 'collection1'.*", 1));
} catch (Exception e) {
LOGGER.warn("can't create Cloud Container", e);
} catch (IOException e) {
throw new RuntimeException("Could not create temporary file", e);
}

}
Expand Down

0 comments on commit e5e768a

Please sign in to comment.