mirror of https://github.com/apache/jclouds.git
Using jboss-as-embedded for integration testing of OpenShift Express
This commit is contained in:
parent
fdc9bd4691
commit
ccc86123ca
|
@ -32,8 +32,9 @@
|
||||||
<description>jclouds TweetStore for RedHat's OpenShift Express using Guice for Dependency Injection</description>
|
<description>jclouds TweetStore for RedHat's OpenShift Express using Guice for Dependency Injection</description>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<test.rhcloud.address>localhost</test.rhcloud.address>
|
<rhcloud.jboss.version>7.0.2.Final</rhcloud.jboss.version>
|
||||||
<test.rhcloud.port>8088</test.rhcloud.port>
|
<rhcloud.jboss.address>localhost</rhcloud.jboss.address>
|
||||||
|
<rhcloud.jboss.port>8088</rhcloud.jboss.port>
|
||||||
<jclouds.tweetstore.container>jclouds-rhcloud-tweetstore</jclouds.tweetstore.container>
|
<jclouds.tweetstore.container>jclouds-rhcloud-tweetstore</jclouds.tweetstore.container>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
@ -45,28 +46,22 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- OpenShift Express uses JBoss AS 7 -->
|
<!-- OpenShift Express uses JBoss AS 7 -->
|
||||||
<!--dependency>
|
<dependency>
|
||||||
<groupId>org.jboss.embedded</groupId>
|
<groupId>org.jboss.as</groupId>
|
||||||
<artifactId>jboss-embedded</artifactId>
|
<artifactId>jboss-as-embedded</artifactId>
|
||||||
<version>beta3.SP12</version>
|
<version>${rhcloud.jboss.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency-->
|
<exclusions>
|
||||||
|
<!-- loading the LogManager here leads to ClassCastExceptions because
|
||||||
|
the server uses a different classloader -->
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>jboss-logmanager</artifactId>
|
||||||
|
<groupId>org.jboss.logmanager</groupId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<!--repositories>
|
|
||||||
<!- - net.stax:stax-appserver is not in central - ->
|
|
||||||
<repository>
|
|
||||||
<id>bees-snapshots</id>
|
|
||||||
<url>http://repository-cloudbees.forge.cloudbees.com/public-snapshot</url>
|
|
||||||
<releases>
|
|
||||||
<enabled>false</enabled>
|
|
||||||
</releases>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
</snapshots>
|
|
||||||
</repository>
|
|
||||||
</repositories-->
|
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
<profile>
|
<profile>
|
||||||
<id>live</id>
|
<id>live</id>
|
||||||
|
@ -97,12 +92,19 @@
|
||||||
<test.cloudonestorage.credential>${test.cloudonestorage.credential}</test.cloudonestorage.credential>
|
<test.cloudonestorage.credential>${test.cloudonestorage.credential}</test.cloudonestorage.credential>
|
||||||
<test.ninefold-storage.identity>${test.ninefold-storage.identity}</test.ninefold-storage.identity>
|
<test.ninefold-storage.identity>${test.ninefold-storage.identity}</test.ninefold-storage.identity>
|
||||||
<test.ninefold-storage.credential>${test.ninefold-storage.credential}</test.ninefold-storage.credential>
|
<test.ninefold-storage.credential>${test.ninefold-storage.credential}</test.ninefold-storage.credential>
|
||||||
<rhcloud.address>${test.rhcloud.address}</rhcloud.address>
|
<rhcloud.jboss.home>${rhcloud.jboss.home}</rhcloud.jboss.home>
|
||||||
<rhcloud.port>${test.rhcloud.port}</rhcloud.port>
|
<rhcloud.jboss.address>${rhcloud.jboss.address}</rhcloud.jboss.address>
|
||||||
|
<rhcloud.jboss.port>${rhcloud.jboss.port}</rhcloud.jboss.port>
|
||||||
<jclouds.tweetstore.blobstores>${jclouds.tweetstore.blobstores}</jclouds.tweetstore.blobstores>
|
<jclouds.tweetstore.blobstores>${jclouds.tweetstore.blobstores}</jclouds.tweetstore.blobstores>
|
||||||
<jclouds.tweetstore.container>test.${jclouds.tweetstore.container}</jclouds.tweetstore.container>
|
<jclouds.tweetstore.container>test.${jclouds.tweetstore.container}</jclouds.tweetstore.container>
|
||||||
<warfile>${project.build.directory}/${project.artifactId}</warfile>
|
<jboss.embedded.root>${project.build.directory}/rhcloud-jboss</jboss.embedded.root>
|
||||||
|
<jboss.server.config.dir>${project.basedir}/src/test/resources/jbossas7/configuration</jboss.server.config.dir>
|
||||||
|
<warfile>${project.build.directory}/${project.build.finalName}</warfile>
|
||||||
</systemPropertyVariables>
|
</systemPropertyVariables>
|
||||||
|
<environmentVariables>
|
||||||
|
<OPENSHIFT_INTERNAL_IP>${rhcloud.jboss.address}</OPENSHIFT_INTERNAL_IP>
|
||||||
|
<OPENSHIFT_INTERNAL_PORT>${rhcloud.jboss.port}</OPENSHIFT_INTERNAL_PORT>
|
||||||
|
</environmentVariables>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
|
|
|
@ -0,0 +1,96 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jboss.as.embedded;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
import java.util.logging.LogManager;
|
||||||
|
|
||||||
|
import org.jboss.modules.Module;
|
||||||
|
import org.jboss.modules.ModuleClassLoader;
|
||||||
|
import org.jboss.modules.ModuleIdentifier;
|
||||||
|
import org.jboss.modules.ModuleLoadException;
|
||||||
|
import org.jboss.modules.ModuleLoader;
|
||||||
|
import org.jboss.modules.log.JDKModuleLogger;
|
||||||
|
import org.jclouds.demo.tweetstore.integration.util.ObjectFields;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A variant of {@link EmbeddedServerFactory} that resets JDK logging for JBoss,
|
||||||
|
* which requires its own settings in this area.
|
||||||
|
*
|
||||||
|
* Needs to be in the org.jboss.as.embedded package to be able to use
|
||||||
|
* {@code InitialModuleLoaderFactory}.
|
||||||
|
*
|
||||||
|
* @author Andrew Phillips
|
||||||
|
* @see EmbeddedServerFactory
|
||||||
|
*/
|
||||||
|
public class EmbeddedServerFactory2 {
|
||||||
|
|
||||||
|
// mainly copied from EmbeddedServerFactory
|
||||||
|
public static StandaloneServer create(final File jbossHomeDir, final Properties systemProps, final Map<String, String> systemEnv, String...systemPackages) {
|
||||||
|
if (jbossHomeDir == null || jbossHomeDir.isDirectory() == false)
|
||||||
|
throw new IllegalStateException("Invalid jboss.home.dir: " + jbossHomeDir);
|
||||||
|
|
||||||
|
if (systemProps.getProperty(ServerEnvironment.HOME_DIR) == null)
|
||||||
|
systemProps.setProperty(ServerEnvironment.HOME_DIR, jbossHomeDir.getAbsolutePath());
|
||||||
|
|
||||||
|
File modulesDir = new File(jbossHomeDir + "/modules");
|
||||||
|
final ModuleLoader moduleLoader = InitialModuleLoaderFactory.getModuleLoader(modulesDir, systemPackages);
|
||||||
|
|
||||||
|
try {
|
||||||
|
Module.registerURLStreamHandlerFactoryModule(moduleLoader.loadModule(ModuleIdentifier.create("org.jboss.vfs")));
|
||||||
|
|
||||||
|
// Initialize the Logging system
|
||||||
|
ModuleIdentifier logModuleId = ModuleIdentifier.create("org.jboss.logmanager");
|
||||||
|
ModuleClassLoader logModuleClassLoader = moduleLoader.loadModule(logModuleId).getClassLoader();
|
||||||
|
try {
|
||||||
|
/*
|
||||||
|
* The original code simply sets the thread context classloader and lets LogManager
|
||||||
|
* load the class. This causes problems in tests because any other component that
|
||||||
|
* also happens to use JDK logging will have potentially loaded a *different*
|
||||||
|
* LogManager.
|
||||||
|
* If you force the JBoss LogManager to be loaded (by setting the 'java.util.logging.manager'
|
||||||
|
* system property) earlier in the test run, it will not be loaded by the correct
|
||||||
|
* classloader and cause ClassCastExceptions.
|
||||||
|
*/
|
||||||
|
LogManager jbossLogManager = (LogManager) logModuleClassLoader.loadClass("org.jboss.logmanager.LogManager").newInstance();
|
||||||
|
ObjectFields.set("manager", null, jbossLogManager, LogManager.class);
|
||||||
|
ObjectFields.set("readPrimordialConfiguration", jbossLogManager, false, LogManager.class);
|
||||||
|
|
||||||
|
if (LogManager.getLogManager().getClass() == LogManager.class) {
|
||||||
|
System.err.println("WARNING: Failed to load the specified logmodule " + logModuleId);
|
||||||
|
} else {
|
||||||
|
Module.setModuleLogger(new JDKModuleLogger());
|
||||||
|
}
|
||||||
|
} catch (Exception exception) {
|
||||||
|
// copied from LogManager
|
||||||
|
System.err.println("Could not load Logmanager \"org.jboss.logmanager.LogManager\"");
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
__redirected.__JAXPRedirected.changeAll(ModuleIdentifier.fromString("javax.xml.jaxp-provider"), moduleLoader);
|
||||||
|
|
||||||
|
return EmbeddedServerFactory.create(moduleLoader, jbossHomeDir, systemProps, systemEnv);
|
||||||
|
}
|
||||||
|
catch (ModuleLoadException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,38 +18,92 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.demo.tweetstore.integration;
|
package org.jclouds.demo.tweetstore.integration;
|
||||||
|
|
||||||
|
import static com.google.common.collect.Iterables.find;
|
||||||
|
import static com.google.common.io.Closeables.closeQuietly;
|
||||||
|
import static java.lang.String.format;
|
||||||
|
import static org.jclouds.demo.tweetstore.integration.util.Zips.zipFile;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import org.jboss.as.controller.client.helpers.standalone.DeploymentAction;
|
||||||
|
import org.jboss.as.controller.client.helpers.standalone.DeploymentPlan;
|
||||||
|
import org.jboss.as.controller.client.helpers.standalone.ServerDeploymentActionResult;
|
||||||
|
import org.jboss.as.controller.client.helpers.standalone.ServerDeploymentManager;
|
||||||
|
import org.jboss.as.controller.client.helpers.standalone.ServerDeploymentPlanResult;
|
||||||
|
import org.jboss.as.embedded.EmbeddedServerFactory2;
|
||||||
|
import org.jboss.as.embedded.ServerStartException;
|
||||||
|
import org.jboss.as.embedded.StandaloneServer;
|
||||||
|
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
|
import com.google.common.io.Files;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic functionality to start a local JBoss 7 AS (as used by OpenShift Express) instance.
|
* Basic functionality to start a local JBoss AS 7 instance.
|
||||||
*
|
*
|
||||||
* @author Andrew Phillips
|
* @author Andrew Phillips
|
||||||
*/
|
*/
|
||||||
public class RhcloudServer {
|
public class RhcloudServer {
|
||||||
//protected StaxSdkAppServer2 server;
|
private static final byte[] CONTEXT_ROOT_XML_BYTES =
|
||||||
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><jboss-web><context-root>/</context-root></jboss-web>".getBytes();
|
||||||
|
|
||||||
public void writePropertiesAndStartServer(final String address, final String port,
|
protected StandaloneServer server;
|
||||||
final String warfile, final String environments,
|
protected ServerDeploymentManager manager;
|
||||||
final String serverBaseDirectory, Properties props) throws IOException, InterruptedException, ServletException {
|
|
||||||
String filename = String.format(
|
public void writePropertiesAndStartServer(String warfile,
|
||||||
"%1$s/WEB-INF/jclouds.properties", warfile);
|
String serverHome, Properties props) throws IOException,
|
||||||
System.err.println("file: " + filename);
|
ServerStartException, InterruptedException, ExecutionException {
|
||||||
props.store(new FileOutputStream(filename), "test");
|
String propsfile = String.format("%1$s/WEB-INF/jclouds.properties", warfile);
|
||||||
assert new File(filename).exists();
|
System.err.println("file: " + propsfile);
|
||||||
// server = StaxSdkAppServer2.createServer(new String[] { "-web", warfile, "-port", port, "-env", environments,
|
storeProperties(propsfile, props);
|
||||||
// "-dir", serverBaseDirectory }, new String[0], Thread.currentThread().getContextClassLoader());
|
assert new File(propsfile).exists();
|
||||||
// server.start();
|
|
||||||
|
// in OpenShift, TweetStore runs at the server root
|
||||||
|
String ctxrootfile = String.format("%1$s/WEB-INF/jboss-web.xml", warfile);
|
||||||
|
System.err.println("file: " + ctxrootfile);
|
||||||
|
Files.write(CONTEXT_ROOT_XML_BYTES, new File(ctxrootfile));
|
||||||
|
assert new File(ctxrootfile).exists();
|
||||||
|
|
||||||
|
server = EmbeddedServerFactory2.create(new File(serverHome), System.getProperties(), System.getenv());
|
||||||
|
server.start();
|
||||||
TimeUnit.SECONDS.sleep(30);
|
TimeUnit.SECONDS.sleep(30);
|
||||||
|
manager = ServerDeploymentManager.Factory.create(server.getModelControllerClient());
|
||||||
|
ServerDeploymentActionResult deploymentResult = deploy(warfile);
|
||||||
|
System.err.println("deployment result: " + deploymentResult.getResult());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void storeProperties(String filename, Properties props)
|
||||||
|
throws IOException {
|
||||||
|
FileOutputStream targetFile = new FileOutputStream(filename);
|
||||||
|
try {
|
||||||
|
props.store(targetFile, "test");
|
||||||
|
} finally {
|
||||||
|
closeQuietly(targetFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ServerDeploymentActionResult deploy(String explodedWar)
|
||||||
|
throws IOException, InterruptedException, ExecutionException {
|
||||||
|
File war = zipFile(explodedWar, format("%s-rhcloud.war", explodedWar), true);
|
||||||
|
final String deploymentName = war.getName();
|
||||||
|
|
||||||
|
DeploymentPlan plan =
|
||||||
|
manager.newDeploymentPlan().add(deploymentName, war).andDeploy().build();
|
||||||
|
ServerDeploymentPlanResult deploymentResult = manager.execute(plan).get();
|
||||||
|
return deploymentResult.getDeploymentActionResult(find(
|
||||||
|
plan.getDeploymentActions(), new Predicate<DeploymentAction>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(DeploymentAction input) {
|
||||||
|
return input.getDeploymentUnitUniqueName().equals(deploymentName);
|
||||||
|
}
|
||||||
|
}).getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop() throws Exception {
|
public void stop() throws Exception {
|
||||||
// server.stop();
|
server.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -62,10 +62,10 @@ import com.google.common.collect.Maps;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts up the Google App Engine for Java Development environment and deploys an application which
|
* Starts up a JBoss AS 7 server (simulating OpenShift Express) and deploys
|
||||||
* tests accesses twitter and blobstores.
|
* an application which tests accesses twitter and blobstores.
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Andrew Phillips
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", singleThreaded = true)
|
@Test(groups = "live", singleThreaded = true)
|
||||||
public class TweetStoreLiveTest {
|
public class TweetStoreLiveTest {
|
||||||
|
@ -170,28 +170,28 @@ public class TweetStoreLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeTest(dependsOnMethods = "clearAndCreateContainers")
|
@BeforeTest(dependsOnMethods = "clearAndCreateContainers")
|
||||||
@Parameters({ "warfile", "rhcloud.address", "rhcloud.port" })
|
@Parameters({ "warfile", "rhcloud.jboss.address", "rhcloud.jboss.port", "rhcloud.jboss.home" })
|
||||||
public void startDevAppServer(final String warfile, final String address, final String port) throws Exception {
|
public void startDevAppServer(final String warfile, final String address, final String port,
|
||||||
|
String serverHome) throws Exception {
|
||||||
url = new URL(String.format("http://%s:%s", address, port));
|
url = new URL(String.format("http://%s:%s", address, port));
|
||||||
|
|
||||||
server = new RhcloudServer();
|
server = new RhcloudServer();
|
||||||
// server.writePropertiesAndStartServer(address, port, warfile, "itest",
|
server.writePropertiesAndStartServer(warfile, serverHome, props);
|
||||||
// serverBaseDirectory, props);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = false)
|
@Test
|
||||||
public void shouldPass() throws InterruptedException, IOException {
|
public void shouldPass() throws InterruptedException, IOException {
|
||||||
InputStream i = url.openStream();
|
InputStream i = url.openStream();
|
||||||
String string = Strings2.toStringAndClose(i);
|
String string = Strings2.toStringAndClose(i);
|
||||||
assert string.indexOf("Welcome") >= 0 : string;
|
assert string.indexOf("Welcome") >= 0 : string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "shouldPass", expectedExceptions = IOException.class, enabled = false)
|
@Test(dependsOnMethods = "shouldPass", expectedExceptions = IOException.class)
|
||||||
public void shouldFail() throws InterruptedException, IOException {
|
public void shouldFail() throws InterruptedException, IOException {
|
||||||
new URL(url, "/store/do").openStream();
|
new URL(url, "/store/do").openStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "shouldFail", enabled = false)
|
@Test(dependsOnMethods = "shouldFail")
|
||||||
public void testPrimeContainers() throws IOException, InterruptedException {
|
public void testPrimeContainers() throws IOException, InterruptedException {
|
||||||
URL gurl = new URL(url, "/store/do");
|
URL gurl = new URL(url, "/store/do");
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ public class TweetStoreLiveTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(invocationCount = 5, dependsOnMethods = "testPrimeContainers", enabled = false)
|
@Test(invocationCount = 5, dependsOnMethods = "testPrimeContainers")
|
||||||
public void testSerial() throws InterruptedException, IOException {
|
public void testSerial() throws InterruptedException, IOException {
|
||||||
URL gurl = new URL(url, "/tweets/get");
|
URL gurl = new URL(url, "/tweets/get");
|
||||||
InputStream i = gurl.openStream();
|
InputStream i = gurl.openStream();
|
||||||
|
@ -221,7 +221,7 @@ public class TweetStoreLiveTest {
|
||||||
assert string.indexOf("Tweets in Clouds") >= 0 : string;
|
assert string.indexOf("Tweets in Clouds") >= 0 : string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(invocationCount = 10, dependsOnMethods = "testPrimeContainers", threadPoolSize = 3, enabled = false)
|
@Test(invocationCount = 10, dependsOnMethods = "testPrimeContainers", threadPoolSize = 3)
|
||||||
public void testParallel() throws InterruptedException, IOException {
|
public void testParallel() throws InterruptedException, IOException {
|
||||||
URL gurl = new URL(url, "/tweets/get");
|
URL gurl = new URL(url, "/tweets/get");
|
||||||
InputStream i = gurl.openStream();
|
InputStream i = gurl.openStream();
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.demo.tweetstore.integration.util;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
|
public class ObjectFields {
|
||||||
|
|
||||||
|
private static Field getAccessibleField(String name, Class<?> declaringClass) throws SecurityException, NoSuchFieldException {
|
||||||
|
Field field = declaringClass.getDeclaredField(name);
|
||||||
|
field.setAccessible(true);
|
||||||
|
return field;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void set(String fieldName, Object target, Object value) {
|
||||||
|
set(fieldName, target, value, target.getClass());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void set(String fieldName, Object target, Object value,
|
||||||
|
Class<?> fieldDeclaringClass) {
|
||||||
|
try {
|
||||||
|
getAccessibleField(fieldName, fieldDeclaringClass).set(target, value);
|
||||||
|
} catch (Exception exception) {
|
||||||
|
throw new IllegalArgumentException(exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,73 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.demo.tweetstore.integration.util;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
|
public class Zips {
|
||||||
|
private static final int DEFAULT_BUFFER_SIZE = 1024 * 4;
|
||||||
|
|
||||||
|
public static File zipFile(String fileToZip, String zipFile,
|
||||||
|
boolean excludeToplevelFolder) throws IOException {
|
||||||
|
ZipOutputStream zipOut = new ZipOutputStream(new FileOutputStream(zipFile));
|
||||||
|
try {
|
||||||
|
File srcFile = new File(fileToZip);
|
||||||
|
if (excludeToplevelFolder && srcFile.isDirectory()) {
|
||||||
|
for (String fileName : srcFile.list()) {
|
||||||
|
addToZip("", fileToZip + "/" + fileName, zipOut);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
addToZip("", fileToZip, zipOut);
|
||||||
|
}
|
||||||
|
zipOut.flush();
|
||||||
|
} finally {
|
||||||
|
zipOut.close();
|
||||||
|
}
|
||||||
|
return new File(zipFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void addToZip(String path, String srcFile,
|
||||||
|
ZipOutputStream zipOut) throws IOException {
|
||||||
|
File file = new File(srcFile);
|
||||||
|
String filePath = ("".equals(path) ? file.getName()
|
||||||
|
: path + "/" + file.getName());
|
||||||
|
if (file.isDirectory()) {
|
||||||
|
for (String fileName : file.list()) {
|
||||||
|
addToZip(filePath, srcFile + "/" + fileName, zipOut);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
zipOut.putNextEntry(new ZipEntry(filePath));
|
||||||
|
FileInputStream in = new FileInputStream(srcFile);
|
||||||
|
try {
|
||||||
|
byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
|
||||||
|
int len;
|
||||||
|
while ((len = in.read(buffer)) != -1) {
|
||||||
|
zipOut.write(buffer, 0, len);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
in.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,208 @@
|
||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<!--
|
||||||
|
|
||||||
|
Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
contributor license agreements. See the NOTICE file
|
||||||
|
distributed with this work for additional information
|
||||||
|
regarding copyright ownership. jclouds licenses this file
|
||||||
|
to you under the Apache License, Version 2.0 (the
|
||||||
|
"License"); you may not use this file except in compliance
|
||||||
|
with the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
software distributed under the License is distributed on an
|
||||||
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
KIND, either express or implied. See the License for the
|
||||||
|
specific language governing permissions and limitations
|
||||||
|
under the License.
|
||||||
|
|
||||||
|
-->
|
||||||
|
|
||||||
|
<server xmlns="urn:jboss:domain:1.0">
|
||||||
|
|
||||||
|
<extensions>
|
||||||
|
<extension module="org.jboss.as.clustering.infinispan"/>
|
||||||
|
<extension module="org.jboss.as.connector"/>
|
||||||
|
<extension module="org.jboss.as.deployment-scanner"/>
|
||||||
|
<extension module="org.jboss.as.ee"/>
|
||||||
|
<extension module="org.jboss.as.ejb3"/>
|
||||||
|
<extension module="org.jboss.as.jaxrs"/>
|
||||||
|
<extension module="org.jboss.as.jmx"/>
|
||||||
|
<extension module="org.jboss.as.jpa"/>
|
||||||
|
<extension module="org.jboss.as.logging"/>
|
||||||
|
<extension module="org.jboss.as.naming"/>
|
||||||
|
<extension module="org.jboss.as.sar"/>
|
||||||
|
<extension module="org.jboss.as.security"/>
|
||||||
|
<extension module="org.jboss.as.threads"/>
|
||||||
|
<extension module="org.jboss.as.transactions"/>
|
||||||
|
<extension module="org.jboss.as.web" />
|
||||||
|
<extension module="org.jboss.as.weld" />
|
||||||
|
</extensions>
|
||||||
|
|
||||||
|
<profile>
|
||||||
|
<subsystem xmlns="urn:jboss:domain:logging:1.0">
|
||||||
|
<console-handler name="CONSOLE">
|
||||||
|
<level name="INFO"/>
|
||||||
|
<formatter>
|
||||||
|
<pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
|
||||||
|
</formatter>
|
||||||
|
</console-handler>
|
||||||
|
|
||||||
|
<periodic-rotating-file-handler name="FILE">
|
||||||
|
<level name="INFO"/>
|
||||||
|
<formatter>
|
||||||
|
<pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
|
||||||
|
</formatter>
|
||||||
|
<file relative-to="jboss.server.log.dir" path="server.log"/>
|
||||||
|
<suffix value=".yyyy-MM-dd"/>
|
||||||
|
</periodic-rotating-file-handler>
|
||||||
|
|
||||||
|
<logger category="com.arjuna">
|
||||||
|
<level name="WARN"/>
|
||||||
|
</logger>
|
||||||
|
<logger category="org.apache.tomcat.util.modeler">
|
||||||
|
<level name="WARN"/>
|
||||||
|
</logger>
|
||||||
|
<logger category="sun.rmi">
|
||||||
|
<level name="WARN"/>
|
||||||
|
</logger>
|
||||||
|
|
||||||
|
<root-logger>
|
||||||
|
<level name="INFO"/>
|
||||||
|
<handlers>
|
||||||
|
<handler name="CONSOLE"/>
|
||||||
|
<handler name="FILE"/>
|
||||||
|
</handlers>
|
||||||
|
</root-logger>
|
||||||
|
</subsystem>
|
||||||
|
<subsystem xmlns="urn:jboss:domain:datasources:1.0">
|
||||||
|
<datasources>
|
||||||
|
<datasource jndi-name="java:jboss/datasources/ExampleDS" enabled="true" use-java-context="true" pool-name="H2DS">
|
||||||
|
<connection-url>jdbc:h2:${jboss.server.data.dir}/test;DB_CLOSE_DELAY=-1</connection-url>
|
||||||
|
<driver>h2</driver>
|
||||||
|
<pool></pool>
|
||||||
|
<security>
|
||||||
|
<user-name>sa</user-name>
|
||||||
|
<password>sa</password>
|
||||||
|
</security>
|
||||||
|
<validation></validation>
|
||||||
|
<timeout></timeout>
|
||||||
|
<statement></statement>
|
||||||
|
</datasource>
|
||||||
|
<datasource jndi-name="java:jboss/datasources/MysqlDS" enabled="${mysql.enabled}" use-java-context="true" pool-name="MysqlDS">
|
||||||
|
<connection-url>jdbc:mysql://${OPENSHIFT_DB_HOST}:${OPENSHIFT_DB_PORT}/${OPENSHIFT_APP_NAME}</connection-url>
|
||||||
|
<driver>mysql</driver>
|
||||||
|
<security>
|
||||||
|
<user-name>${OPENSHIFT_DB_USERNAME}</user-name>
|
||||||
|
<password>${OPENSHIFT_DB_PASSWORD}</password>
|
||||||
|
</security>
|
||||||
|
</datasource>
|
||||||
|
<drivers>
|
||||||
|
<driver name="h2" module="com.h2database.h2">
|
||||||
|
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
|
||||||
|
</driver>
|
||||||
|
<driver name="mysql" module="com.mysql.jdbc">
|
||||||
|
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
|
||||||
|
</driver>
|
||||||
|
</drivers>
|
||||||
|
</datasources>
|
||||||
|
</subsystem>
|
||||||
|
<subsystem xmlns="urn:jboss:domain:deployment-scanner:1.0">
|
||||||
|
<deployment-scanner scan-interval="5000" relative-to="jboss.server.base.dir" path="deployments" />
|
||||||
|
</subsystem>
|
||||||
|
<subsystem xmlns="urn:jboss:domain:ee:1.0" />
|
||||||
|
<subsystem xmlns="urn:jboss:domain:ejb3:1.0" />
|
||||||
|
<subsystem xmlns="urn:jboss:domain:infinispan:1.0" default-cache-container="hibernate">
|
||||||
|
<cache-container name="hibernate" default-cache="local-query">
|
||||||
|
<local-cache name="entity">
|
||||||
|
<eviction strategy="LRU" max-entries="10000"/>
|
||||||
|
<expiration max-idle="100000"/>
|
||||||
|
</local-cache>
|
||||||
|
<local-cache name="local-query">
|
||||||
|
<eviction strategy="LRU" max-entries="10000"/>
|
||||||
|
<expiration max-idle="100000"/>
|
||||||
|
</local-cache>
|
||||||
|
<local-cache name="timestamps">
|
||||||
|
<eviction strategy="NONE"/>
|
||||||
|
</local-cache>
|
||||||
|
</cache-container>
|
||||||
|
</subsystem>
|
||||||
|
<subsystem xmlns="urn:jboss:domain:jaxrs:1.0"/>
|
||||||
|
<subsystem xmlns="urn:jboss:domain:jca:1.0">
|
||||||
|
<archive-validation enabled="false" />
|
||||||
|
<bean-validation enabled="false" />
|
||||||
|
<default-workmanager>
|
||||||
|
<short-running-threads blocking="true">
|
||||||
|
<core-threads count="5" per-cpu="10"/>
|
||||||
|
<queue-length count="5" per-cpu="10"/>
|
||||||
|
<max-threads count="5" per-cpu="10"/>
|
||||||
|
<keepalive-time time="10" unit="seconds"/>
|
||||||
|
</short-running-threads>
|
||||||
|
<long-running-threads blocking="true">
|
||||||
|
<core-threads count="5" per-cpu="10"/>
|
||||||
|
<queue-length count="5" per-cpu="10"/>
|
||||||
|
<max-threads count="5" per-cpu="10"/>
|
||||||
|
<keepalive-time time="10" unit="seconds"/>
|
||||||
|
</long-running-threads>
|
||||||
|
</default-workmanager>
|
||||||
|
</subsystem>
|
||||||
|
<subsystem xmlns="urn:jboss:domain:jpa:1.0">
|
||||||
|
<jpa default-datasource=""/>
|
||||||
|
</subsystem>
|
||||||
|
<subsystem xmlns="urn:jboss:domain:naming:1.0" />
|
||||||
|
<subsystem xmlns="urn:jboss:domain:resource-adapters:1.0" />
|
||||||
|
<subsystem xmlns="urn:jboss:domain:sar:1.0"/>
|
||||||
|
<subsystem xmlns="urn:jboss:domain:security:1.0">
|
||||||
|
<security-domains>
|
||||||
|
<security-domain name="other" cache-type="default">
|
||||||
|
<authentication>
|
||||||
|
<login-module code="UsersRoles" flag="required"/>
|
||||||
|
</authentication>
|
||||||
|
</security-domain>
|
||||||
|
</security-domains>
|
||||||
|
</subsystem>
|
||||||
|
<subsystem xmlns="urn:jboss:domain:threads:1.0"/>
|
||||||
|
<subsystem xmlns="urn:jboss:domain:transactions:1.0">
|
||||||
|
<recovery-environment socket-binding="txn-recovery-environment" status-socket-binding="txn-status-manager"/>
|
||||||
|
<core-environment>
|
||||||
|
<process-id>
|
||||||
|
<uuid />
|
||||||
|
</process-id>
|
||||||
|
</core-environment>
|
||||||
|
<coordinator-environment default-timeout="300"/>
|
||||||
|
</subsystem>
|
||||||
|
<subsystem xmlns="urn:jboss:domain:web:1.0" default-virtual-server="default-host">
|
||||||
|
<connector name="http" scheme="http" protocol="HTTP/1.1" socket-binding="http"/>
|
||||||
|
<virtual-server name="default-host">
|
||||||
|
<alias name="localhost" />
|
||||||
|
</virtual-server>
|
||||||
|
</subsystem>
|
||||||
|
<subsystem xmlns="urn:jboss:domain:weld:1.0" />
|
||||||
|
</profile>
|
||||||
|
|
||||||
|
<interfaces>
|
||||||
|
<interface name="management">
|
||||||
|
<!-- the "original" (i.e. as provided by OpenShift) uses loopback-address -->
|
||||||
|
<inet-address value="${rhcloud.jboss.address:127.0.0.1}"/>
|
||||||
|
</interface>
|
||||||
|
<interface name="public">
|
||||||
|
<!-- the "original" uses loopback-address -->
|
||||||
|
<inet-address value="${rhcloud.jboss.address:127.0.0.1}"/>
|
||||||
|
</interface>
|
||||||
|
</interfaces>
|
||||||
|
|
||||||
|
<socket-binding-group name="standard-sockets" default-interface="public">
|
||||||
|
<socket-binding name="http" port="${rhcloud.jboss.port:8080}"/>
|
||||||
|
<socket-binding name="https" port="8443"/>
|
||||||
|
<socket-binding name="jmx-connector-registry" port="1090"/>
|
||||||
|
<socket-binding name="jmx-connector-server" port="1091"/>
|
||||||
|
<socket-binding name="jndi" port="1099"/>
|
||||||
|
<socket-binding name="osgi-http" port="8090"/>
|
||||||
|
<socket-binding name="remoting" port="4447"/>
|
||||||
|
<socket-binding name="txn-recovery-environment" port="4712"/>
|
||||||
|
<socket-binding name="txn-status-manager" port="4713"/>
|
||||||
|
</socket-binding-group>
|
||||||
|
|
||||||
|
</server>
|
Loading…
Reference in New Issue