// Path: arquillian-chameleon-container-model/src/main/java/org/arquillian/container/chameleon/spi/model/Target.java
// public class Target {
// 
//     private String server;
//     private String version;
//     private Type type;
// 
//     public static Target from(String source) {
//         Target target = new Target();
// 
//         String[] sections = source.split(":");
//         if (sections.length < 2 || sections.length > 3) {
//             throw new ConfigurationException("Wrong target format [" + source + "] server:version:type");
//         }
//         target.server = sections[0].toLowerCase();
//         target.version = sections[1];
//         if (sections.length > 2) {
//             for (Type type : Type.values()) {
//                 if (sections[2].toLowerCase().contains(type.name().toLowerCase())) {
//                     target.type = type;
//                     break;
//                 }
//             }
//             if (target.type == null) {
//                 throw new ConfigurationException(
//                     "Unknown target type " + sections[2] + ". Supported " + Target.Type.values());
//             }
//         } else {
//             target.type = Type.Default;
//         }
//         return target;
//     }
// 
//     public Type getType() {
//         return type;
//     }
// 
//     public String getServer() {
//         return server;
//     }
// 
//     public String getVersion() {
//         return version;
//     }
// 
//     @Override
//     public String toString() {
//         return server + ":" + version + ":" + type;
//     }
// 
//     public boolean isSupported() throws Exception {
//         Loader loader = new Loader();
//         Container[] containers =
//             loader.loadContainers(FileUtils.loadConfiguration("chameleon/default/containers.yaml", true));
// 
//         for (Container container : containers) {
//             if (container.matches(this) != null) {
//                 return true;
//             }
//         }
//         return false;
//     }
// 
//     public boolean isVersionSupported() throws Exception {
//         Loader loader = new Loader();
//         Container[] containers =
//             loader.loadContainers(FileUtils.loadConfiguration("chameleon/default/containers.yaml", true));
// 
//         for (Container container : containers) {
//             if (container.isVersionMatches(this)) {
//                 return true;
//             }
//         }
//         return false;
//     }
// 
//     public enum Type {
//         Remote, Managed, Embedded, Default;
// 
//         public static Type from(String name) {
//             for (Type type : Type.values()) {
//                 if (type.name().equalsIgnoreCase(name)) {
//                     return type;
//                 }
//             }
//             return null;
//         }
// 
//     }
// }


import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import org.arquillian.container.chameleon.spi.model.Target;
import org.jboss.arquillian.container.spi.ConfigurationException;
                        " nor classloader resource: " + resourceName);
            }
        }

        return stream;
    }

    private static InputStream loadResource(String resourceName) {
        InputStream stream = loadClassPathResource(resourceName);
        if (stream == null) {
            stream = loadFileResource(resourceName);
        }
        return stream;
    }

    private static InputStream loadFileResource(String resourceName) {
        File file = new File(resourceName);
        if (file.exists()) {
            try {
                return new FileInputStream(file);
            } catch (FileNotFoundException e) {
                // should not happen unless file has been deleted since we did
                // file.exists call
                throw new IllegalStateException("Configuration file could not be found, " + resourceName);
            }
        }
        return null;
    }

    private static InputStream loadClassPathResource(String resourceName) {
// Path: arquillian-chameleon-container-model/src/main/java/org/arquillian/container/chameleon/spi/model/Target.java
// public class Target {
// 
//     private String server;
//     private String version;
//     private Type type;
// 
//     public static Target from(String source) {
//         Target target = new Target();
// 
//         String[] sections = source.split(":");
//         if (sections.length < 2 || sections.length > 3) {
//             throw new ConfigurationException("Wrong target format [" + source + "] server:version:type");
//         }
//         target.server = sections[0].toLowerCase();
//         target.version = sections[1];
//         if (sections.length > 2) {
//             for (Type type : Type.values()) {
//                 if (sections[2].toLowerCase().contains(type.name().toLowerCase())) {
//                     target.type = type;
//                     break;
//                 }
//             }
//             if (target.type == null) {
//                 throw new ConfigurationException(
//                     "Unknown target type " + sections[2] + ". Supported " + Target.Type.values());
//             }
//         } else {
//             target.type = Type.Default;
//         }
//         return target;
//     }
// 
//     public Type getType() {
//         return type;
//     }
// 
//     public String getServer() {
//         return server;
//     }
// 
//     public String getVersion() {
//         return version;
//     }
// 
//     @Override
//     public String toString() {
//         return server + ":" + version + ":" + type;
//     }
// 
//     public boolean isSupported() throws Exception {
//         Loader loader = new Loader();
//         Container[] containers =
//             loader.loadContainers(FileUtils.loadConfiguration("chameleon/default/containers.yaml", true));
// 
//         for (Container container : containers) {
//             if (container.matches(this) != null) {
//                 return true;
//             }
//         }
//         return false;
//     }
// 
//     public boolean isVersionSupported() throws Exception {
//         Loader loader = new Loader();
//         Container[] containers =
//             loader.loadContainers(FileUtils.loadConfiguration("chameleon/default/containers.yaml", true));
// 
//         for (Container container : containers) {
//             if (container.isVersionMatches(this)) {
//                 return true;
//             }
//         }
//         return false;
//     }
// 
//     public enum Type {
//         Remote, Managed, Embedded, Default;
// 
//         public static Type from(String name) {
//             for (Type type : Type.values()) {
//                 if (type.name().equalsIgnoreCase(name)) {
//                     return type;
//                 }
//             }
//             return null;
//         }
// 
//     }
// }


// Path: arquillian-chameleon-container-model/src/main/java/org/arquillian/container/chameleon/FileUtils.java
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import org.arquillian.container.chameleon.spi.model.Target;
import org.jboss.arquillian.container.spi.ConfigurationException;

                        " nor classloader resource: " + resourceName);
            }
        }

        return stream;
    }

    private static InputStream loadResource(String resourceName) {
        InputStream stream = loadClassPathResource(resourceName);
        if (stream == null) {
            stream = loadFileResource(resourceName);
        }
        return stream;
    }

    private static InputStream loadFileResource(String resourceName) {
        File file = new File(resourceName);
        if (file.exists()) {
            try {
                return new FileInputStream(file);
            } catch (FileNotFoundException e) {
                // should not happen unless file has been deleted since we did
                // file.exists call
                throw new IllegalStateException("Configuration file could not be found, " + resourceName);
            }
        }
        return null;
    }

    private static InputStream loadClassPathResource(String resourceName) {
        ClassLoader classLoader = Target.class.getClassLoader();