package org.arquillian.cube.kubernetes.impl.resolver;

import java.io.IOException;
import java.net.URL;

public class ResourceResolver {

    static final String URL_PREFIX = "http";
    static final String FILE_PREFIX = "file";
    static final String CLASSPATH_PREFIX = "classpath:";

    public static URL resolve(String location) {
        try {
            if (location.startsWith(URL_PREFIX) || location.startsWith(FILE_PREFIX)) {
                return new URL(location);
            } else if (location.startsWith(CLASSPATH_PREFIX)) {
                String classPathLocation = location.substring(location.indexOf(CLASSPATH_PREFIX)
                    + CLASSPATH_PREFIX.length());
                final URL resource = Thread.currentThread().getContextClassLoader().getResource(classPathLocation);

                if (resource == null) {
                    throw new IllegalArgumentException(String.format("%s location couldn't be found inside classpath.", classPathLocation));
                }

                return resource;
            } else {
                return new URL(location);
            }
        } catch (IOException e) {
            throw new IllegalArgumentException(e);
        }
    }
}

@@ -48,16 +48,95 @@
 olver;%0A%0A
+import java.io.BufferedWriter;%0Aimport java.io.File;%0Aimport java.io.FileWriter;%0A
 import j
@@ -368,48 +368,672 @@
    p
-ublic static URL resolve(String location
+rivate static File createTemporalDefinition(String content) throws IOException %7B%0A        // In case it is not a http, file nor a classpath protocol,%0A        // we assume that this is plain text. We store it in a temporary%0A        // file and return the URL to it.%0A        File tmp = File.createTempFile(%22arquillian-cube%22, %22.res%22);%0A%0A        // Remove the temporary file after running the test%0A        tmp.deleteOnExit();%0A%0A        // Write content to temporary file%0A        BufferedWriter writer = new BufferedWriter(new FileWriter(tmp));%0A        writer.write(content);%0A        writer.close();%0A%0A        return tmp;%0A    %7D%0A%0A    public static URL resolve(String content
 ) %7B%0A
@@ -1058,32 +1058,31 @@
         if (
-location
+content
 .startsWith(
@@ -1096,24 +1096,23 @@
 FIX) %7C%7C 
-location
+content
 .startsW
@@ -1158,32 +1158,31 @@
 urn new URL(
-location
+content
 );%0A         
@@ -1195,24 +1195,23 @@
 lse if (
-location
+content
 .startsW
@@ -1278,24 +1278,23 @@
 ation = 
-location
+content
 .substri
@@ -1296,24 +1296,23 @@
 bstring(
-location
+content
 .indexOf
@@ -1771,31 +1771,112 @@
     
-return new URL(location
+File tmp = ResourceResolver.createTemporalDefinition(content);%0A                return tmp.toURI().toURL(
 );%0A 

Make @OpenShiftResource annotation work again with plain text (#1046)