// TODO(jarcec): We should parametrize those paths, version, etc...
// Source: http://cargo.codehaus.org/Functional+testing
Installer installer = new ZipURLInstaller(new URL("http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.36/bin/apache-tomcat-6.0.36.zip"));
installer.install();
LocalConfiguration configuration = (LocalConfiguration) new DefaultConfigurationFactory().createConfiguration("tomcat6x", ContainerType.INSTALLED, ConfigurationType.STANDALONE);
container = (InstalledLocalContainer) new DefaultContainerFactory().createContainer("tomcat6x", ContainerType.INSTALLED, configuration);
// Set home to our installed tomcat instance
container.setHome(installer.getHome());
// Store tomcat logs into file as they are quite handy for debugging
container.setOutput(getTemporaryPath() + "/log/tomcat.log");
// Propagate system properties to the container
Map<String, String> map = new HashMap<String, String>((Map) System.getProperties());
container.setSystemProperties(map);
// Propagate Hadoop jars to the container classpath
// In real world, they would be installed manually by user
List<String> extraClassPath = new LinkedList<String>();
String []classpath = System.getProperty("java.class.path").split(":");
for(String jar : classpath) {
if(jar.contains("hadoop-") || // Hadoop jars
jar.contains("commons-") || // Apache Commons libraries
jar.contains("log4j-") || // Log4j
jar.contains("slf4j-") || // Slf4j
jar.contains("jackson-") || // Jackson
jar.contains("derby") || // Derby drivers
jar.contains("avro-") || // Avro
jar.contains("mysql") || // MySQL JDBC driver
jar.contains("postgre") || // PostgreSQL JDBC driver
jar.contains("oracle") || // Oracle driver
jar.contains("terajdbc") || // Teradata driver
jar.contains("tdgs") || // Teradata driver
jar.contains("nzjdbc") || // Netezza driver
jar.contains("sqljdbc") || // Microsoft SQL Server driver
jar.contains("google") // Google libraries (guava, ...)
) {
extraClassPath.add(jar);
}
}
container.setExtraClasspath(extraClassPath.toArray(new String[extraClassPath.size()]));
// Finally deploy Sqoop server war file
configuration.addDeployable(new WAR("../server/target/sqoop.war"));
// Start Sqoop server
container.start();
}