This is an automated email from the ASF dual-hosted git repository.

ppalaga pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git


The following commit(s) were added to refs/heads/main by this push:
     new e5e768a  Fixup 5cf60953 SolrTest failure when using CloundContainer 
#2967 - do not assume the class path resource is accessible via filesystem
e5e768a is described below

commit e5e768acd680b0d78122fb7eee30b0a70947f3f9
Author: Peter Palaga <[email protected]>
AuthorDate: Thu Aug 26 23:54:57 2021 +0200

    Fixup 5cf60953 SolrTest failure when using CloundContainer #2967 - do not 
assume the class path resource is accessible via filesystem
---
 .../component/solr/it/SolrTestResource.java        | 23 +++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git 
a/integration-tests/solr/src/test/java/org/apache/camel/quarkus/component/solr/it/SolrTestResource.java
 
b/integration-tests/solr/src/test/java/org/apache/camel/quarkus/component/solr/it/SolrTestResource.java
index 2891aa1..a335f48 100644
--- 
a/integration-tests/solr/src/test/java/org/apache/camel/quarkus/component/solr/it/SolrTestResource.java
+++ 
b/integration-tests/solr/src/test/java/org/apache/camel/quarkus/component/solr/it/SolrTestResource.java
@@ -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;
@@ -113,19 +116,21 @@ public class SolrTestResource implements 
QuarkusTestResourceLifecycleManager {
      * 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);
         }
 
     }

Reply via email to