You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sf...@apache.org on 2015/02/16 19:18:37 UTC
[2/4] incubator-usergrid git commit: First pass at embedded tomcat.
Experiencing classloading issues.
First pass at embedded tomcat. Experiencing classloading issues.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/75a8361c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/75a8361c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/75a8361c
Branch: refs/heads/USERGRID-365
Commit: 75a8361cd425608a70ae325cde1f62cb179cfbed
Parents: 9b11860
Author: Todd Nine <tn...@apigee.com>
Authored: Thu Feb 12 20:55:31 2015 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Thu Feb 12 20:55:31 2015 -0700
----------------------------------------------------------------------
.../org/apache/usergrid/batch/service/App.java | 86 ------
.../batch/job/AbstractSchedulerRuntimeIT.java | 3 +-
stack/corepersistence/pom.xml | 2 +-
stack/pom.xml | 10 +-
stack/rest/pom.xml | 274 +++++++++----------
.../resources/usergrid-rest-deploy-context.xml | 6 +-
.../apache/usergrid/rest/AbstractRestIT.java | 25 ++
.../apache/usergrid/rest/TomcatResource.java | 135 ---------
.../endpoints/mgmt/ApplicationResource.java | 10 +-
stack/rest/src/test/resources/arquillian.xml | 43 +++
.../apache/usergrid/services/ServiceInfo.java | 5 +-
11 files changed, 221 insertions(+), 378 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/75a8361c/stack/core/src/main/java/org/apache/usergrid/batch/service/App.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/batch/service/App.java b/stack/core/src/main/java/org/apache/usergrid/batch/service/App.java
deleted file mode 100644
index d339c4c..0000000
--- a/stack/core/src/main/java/org/apache/usergrid/batch/service/App.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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.apache.usergrid.batch.service;
-
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-import org.springframework.context.support.FileSystemXmlApplicationContext;
-
-import com.google.common.base.CharMatcher;
-
-
-/**
- * Entry point for CLI functions of Usergrid batch framework
- * <p/>
- * To run this with the built-in examples, invoke it thusly from the top level of the project directory:
- * <p/>
- * mvn -e exec:java -Dexec.mainClass="org.apache.usergrid.batch.App" -Dexec.args="-appContext
- * src/test/resources/appContext.xml"
- *
- * @author zznate
- */
-public class App {
-
- private static Logger logger = LoggerFactory.getLogger( App.class );
-
- private ApplicationContext appContext;
- private final org.apache.usergrid.batch.AppArgs appArgs;
-
-
- public static void main( String[] args ) {
- org.apache.usergrid.batch.AppArgs appArgs = org.apache.usergrid.batch.AppArgs.parseArgs( args );
- if ( logger.isDebugEnabled() ) {
- logger.debug( "Invoked App with appArgs: {}", appArgs.toString() );
- }
-
- App app = new App( appArgs );
-
- app.loadContext();
-
- logger.info( "Context loaded, invoking execute() ..." );
- app.doExecute();
- }
-
-
- App( org.apache.usergrid.batch.AppArgs appArgs ) {
- this.appArgs = appArgs;
- }
-
-
- private void loadContext() {
- logger.info( "loading context" );
- // spring context
- int index = CharMatcher.is( ':' ).indexIn( appArgs.getAppContext() );
- if ( index > 0 ) {
- appContext = new ClassPathXmlApplicationContext( appArgs.getAppContext().substring( ++index ) );
- }
- else {
- appContext = new FileSystemXmlApplicationContext( appArgs.getAppContext() );
- }
- }
-
-
- private void doExecute() {
- JobSchedulerService bjss = appContext.getBean( "bulkJobScheduledService", JobSchedulerService.class );
- logger.info( "starting scheduledService..." );
- bjss.startAndWait();
- logger.info( "scheduledService started." );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/75a8361c/stack/core/src/test/java/org/apache/usergrid/batch/job/AbstractSchedulerRuntimeIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/batch/job/AbstractSchedulerRuntimeIT.java b/stack/core/src/test/java/org/apache/usergrid/batch/job/AbstractSchedulerRuntimeIT.java
index 8825497..534689c 100644
--- a/stack/core/src/test/java/org/apache/usergrid/batch/job/AbstractSchedulerRuntimeIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/batch/job/AbstractSchedulerRuntimeIT.java
@@ -96,7 +96,8 @@ public class AbstractSchedulerRuntimeIT {
JobSchedulerService jobScheduler = springResource.getBean( JobSchedulerService.class );
jobScheduler.setJobListener( listener );
if ( jobScheduler.state() != State.RUNNING ) {
- jobScheduler.startAndWait();
+ jobScheduler.startAsync();
+ jobScheduler.awaitRunning();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/75a8361c/stack/corepersistence/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/pom.xml b/stack/corepersistence/pom.xml
index 9bd53fa..c89e62f 100644
--- a/stack/corepersistence/pom.xml
+++ b/stack/corepersistence/pom.xml
@@ -61,7 +61,7 @@ limitations under the License.
<commons.lang.version>3.1</commons.lang.version>
<elasticsearch.version>1.3.2</elasticsearch.version>
<fasterxml-uuid.version>3.1.3</fasterxml-uuid.version>
- <guava.version>15.0</guava.version>
+ <guava.version>18.0</guava.version>
<guice.version>4.0-beta5</guice.version>
<guicyfig.version>3.2</guicyfig.version>
<hystrix.version>1.3.16</hystrix.version>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/75a8361c/stack/pom.xml
----------------------------------------------------------------------
diff --git a/stack/pom.xml b/stack/pom.xml
index 2a08f91..27bd1bb 100644
--- a/stack/pom.xml
+++ b/stack/pom.xml
@@ -89,7 +89,6 @@
<ug.heapmin>2048m</ug.heapmin>
<ug.argline>-Djava.awt.headless=true</ug.argline>
- <usergrid-custom-spring-properties>classpath:/usergrid-deployment.properties</usergrid-custom-spring-properties>
<usergrid-custom-spring-test-properties>classpath:/usergrid-custom-test.properties</usergrid-custom-spring-test-properties>
<!-- =================================================================== -->
@@ -816,7 +815,7 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
- <version>15.0</version>
+ <version>18.0</version>
</dependency>
<dependency>
@@ -944,6 +943,13 @@
<version>${jackson-version}</version>
</dependency>
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-xc</artifactId>
+ <version>${jackson-version}</version>
+ </dependency>
+
+
<dependency>
<groupId>org.codehaus.jettison</groupId>
<artifactId>jettison</artifactId>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/75a8361c/stack/rest/pom.xml
----------------------------------------------------------------------
diff --git a/stack/rest/pom.xml b/stack/rest/pom.xml
index 7fa0abe..1c2e3ba 100644
--- a/stack/rest/pom.xml
+++ b/stack/rest/pom.xml
@@ -32,9 +32,56 @@
<!-- Override these properties in an active profile within your settings.xml -->
<properties>
<cargo.servlet.port>8081</cargo.servlet.port>
- <usergrid.rest.threads>1C</usergrid.rest.threads>
+ <usergrid.rest.threads>8</usergrid.rest.threads>
+ <guice.version>4.0-beta5</guice.version>
</properties>
+ <!-- profile that arquillian uses when it builds/starts tomcat -->
+ <profiles>
+ <profile>
+ <id>arquillian-tomcat</id>
+ <dependencies>
+
+
+ <dependency>
+ <groupId>org.apache.tomcat.embed</groupId>
+ <artifactId>tomcat-embed-core</artifactId>
+ <version>7.0.59</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tomcat.embed</groupId>
+ <artifactId>tomcat-embed-jasper</artifactId>
+ <version>7.0.59</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tomcat.embed</groupId>
+ <artifactId>tomcat-embed-logging-juli</artifactId>
+ <version>7.0.59</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jdt.core.compiler</groupId>
+ <artifactId>ecj</artifactId>
+ <version>3.7</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- Weld servlet for testing CDI injections -->
+ <dependency>
+ <groupId>org.jboss.weld.servlet</groupId>
+ <artifactId>weld-servlet</artifactId>
+ <version>2.2.9.Final</version>
+ </dependency>
+
+ </dependencies>
+
+
+ </profile>
+
+
+ </profiles>
<build>
<finalName>ROOT</finalName>
@@ -60,6 +107,7 @@
</testResource>
</testResources>
+
<plugins>
<plugin>
@@ -67,24 +115,21 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.plugin.version}</version>
<configuration>
- <skipTests>true</skipTests>
- <!--<systemPropertyVariables>-->
- <!--<storage-config>${basedir}/src/test/conf</storage-config>-->
- <!--<target.directory>${project.build.directory}</target.directory>-->
- <!--</systemPropertyVariables>-->
- <!--<parallel>methods</parallel>-->
- <!--<forkCount>${usergrid.it.forkCount}</forkCount>-->
- <!--<threadCount>${usergrid.it.threads}</threadCount>-->
- <!--<reuseForks>true</reuseForks>-->
- <!--<argLine>-Dtest.barrier.timestamp=${maven.build.timestamp} -Dtest.clean.storage=true-->
- <!---Xmx${ug.heapmax} -Xms${ug.heapmin} -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8-->
- <!---javaagent:${settings.localRepository}/com/github/stephenc/jamm/0.2.5/jamm-0.2.5.jar-->
- <!--${ug.argline}-->
- <!--</argLine>-->
- <!--<includes>-->
- <!--<include>**/*IT.java</include>-->
- <!--<include>**/*Test.java</include>-->
- <!--</includes>-->
+ <!--<skipTests>true</skipTests>-->
+ <systemPropertyVariables>
+ <storage-config>${basedir}/src/test/conf</storage-config>
+ <target.directory>${project.build.directory}</target.directory>
+ </systemPropertyVariables>
+ <parallel>methods</parallel>
+ <forkCount>1</forkCount>
+ <threadCount>${usergrid.rest.threads}</threadCount>
+ <reuseForks>true</reuseForks>
+ <argLine>-Dtest.barrier.timestamp=${maven.build.timestamp} -Dtest.clean.storage=true -Xmx${ug.heapmax} -Xms${ug.heapmin} -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 -javaagent:${settings.localRepository}/com/github/stephenc/jamm/0.2.5/jamm-0.2.5.jar ${ug.argline}
+ </argLine>
+ <includes>
+ <include>**/*IT.java</include>
+ <include>**/*Test.java</include>
+ </includes>
</configuration>
@@ -97,46 +142,6 @@
</dependencies>
</plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-failsafe-plugin</artifactId>
- <version>${surefire.plugin.version}</version>
- <configuration>
- <includes>
- <include>**/*IT.java</include>
- <include>**/*Test.java</include>
- </includes>
-
- <systemPropertyVariables>
- <storage-config>${basedir}/src/test/conf</storage-config>
- <target.directory>${project.build.directory}</target.directory>
- </systemPropertyVariables>
- <parallel>methods</parallel>
- <forkCount>1</forkCount>
- <threadCount>${usergrid.rest.threads}</threadCount>
- <reuseForks>true</reuseForks>
- <argLine>-Dtest.barrier.timestamp=${maven.build.timestamp} -Dtest.clean.storage=true -Xmx${ug.heapmax} -Xms${ug.heapmin} -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 -javaagent:${settings.localRepository}/com/github/stephenc/jamm/0.2.5/jamm-0.2.5.jar ${ug.argline}</argLine>
- </configuration>
- <dependencies>
- <dependency>
- <groupId>org.apache.maven.surefire</groupId>
- <artifactId>surefire-junit47</artifactId>
- <version>${surefire.plugin.version}</version>
- </dependency>
- </dependencies>
-
- <!-- run the integration tests then verify the results -->
- <executions>
- <execution>
- <id>failsafe-integration-tests</id>
- <phase>integration-test</phase>
- <goals>
- <goal>integration-test</goal>
- <goal>verify</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -204,77 +209,6 @@
</execution>
</executions>
</plugin>
-
- <plugin>
- <groupId>org.codehaus.cargo</groupId>
- <artifactId>cargo-maven2-plugin</artifactId>
- <version>1.4.12</version>
- <executions>
- <execution>
- <id>start-container</id>
- <phase>pre-integration-test</phase>
- <goals>
- <goal>start</goal>
- </goals>
- </execution>
- <execution>
- <id>stop-container</id>
- <phase>post-integration-test</phase>
- <goals>
- <goal>stop</goal>
- </goals>
- </execution>
- </executions>
-
- <configuration>
- <container>
- <containerId>tomcat7x</containerId>
- <!-- Run the latest version of to tomcat 7 -->
- <zipUrlInstaller>
- <url>http://mirror.tcpdiag.net/apache/tomcat/tomcat-7/v7.0.57/bin/apache-tomcat-7.0.57.zip</url>
- </zipUrlInstaller>
-
- </container>
- <configuration>
- <configfiles>
- <configfile>
- <file>${project.basedir}/target/test-classes/usergrid-deployment.properties</file>
- <todir>lib</todir>
- </configfile>
- </configfiles>
- <!--If you're getting port conflicts, override the ports here-->
- <properties>
- <cargo.jvmargs>-Xmx1G -Xms500m -server -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000</cargo.jvmargs>
- <!--<cargo.rmi.port>10200</cargo.rmi.port>-->
- <!--<cargo.servlet.port>${cargo.servlet.port}</cargo.servlet.port>-->
- <!--<cargo.tomcat.ajp.port>10201</cargo.tomcat.ajp.port>-->
- </properties>
-
-
- </configuration>
-
- <deployables>
- <!-- This deployable specifies the webapp you want to deploy -->
- <deployable>
- <groupId>${project.groupId}</groupId>
- <artifactId>${project.artifactId}</artifactId>
- <type>war</type>
- </deployable>
-
- </deployables>
-
-
-
-
- <!--<configFiles>-->
- <!--<configfile>-->
- <!--<file>${project.basedir}/src/main/config/jetty-env.xml</file>-->
- <!--<todir>webapps/datasource-war/WEB-INF</todir>-->
- <!--</configfile>-->
- </configuration>
- </plugin>
-
-
</plugins>
</build>
@@ -434,35 +368,91 @@
<scope>test</scope>
</dependency>
-<!-- <dependency>
- <groupId>org.apache.tomcat.embed</groupId>
- <artifactId>tomcat-embed-core</artifactId>
+ <!-- arquillian deps -->
+
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-xc</artifactId>
+ <version>${jackson-version}</version>
+ <scope>test</scope>
+ </dependency>
+
+
+
+ <!--<dependency>-->
+ <!--<groupId>org.jboss.arquillian.container</groupId>-->
+ <!--<artifactId>arquillian-tomcat-embedded-7</artifactId>-->
+ <!--<version>1.1.7.Final</version>-->
+ <!--<scope>test</scope>-->
+ <!--</dependency>-->
+
+ <dependency>
+ <groupId>org.jboss.arquillian</groupId>
+ <artifactId>arquillian-bom</artifactId>
+ <version>1.1.7.Final</version>
+ <scope>import</scope>
+ <type>pom</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.arquillian.junit</groupId>
+ <artifactId>arquillian-junit-container</artifactId>
+ <version>1.1.7.Final</version>
<scope>test</scope>
</dependency>
+
+
+ <!-- Some arquillian dependency runs and old version of guice. We're overridding it here so that we include
+ the right value into the test scope -->
<dependency>
- <groupId>org.apache.tomcat.embed</groupId>
- <artifactId>tomcat-embed-logging-juli</artifactId>
+ <groupId>com.google.inject</groupId>
+ <artifactId>guice</artifactId>
+ <version>${guice.version}</version>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.apache.tomcat.embed</groupId>
- <artifactId>tomcat-embed-jasper</artifactId>
+ <groupId>com.google.inject.extensions</groupId>
+ <artifactId>guice-multibindings</artifactId>
+ <version>${guice.version}</version>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.apache.tomcat</groupId>
- <artifactId>tomcat-jasper-el</artifactId>
+ <groupId>com.google.inject.extensions</groupId>
+ <artifactId>guice-assistedinject</artifactId>
+ <version>${guice.version}</version>
<scope>test</scope>
</dependency>
+
+ <!-- documentation here
+ https://github.com/shrinkwrap/resolver
+ -->
+
+ <dependency>
+ <groupId>org.jboss.shrinkwrap.resolver</groupId>
+ <artifactId>shrinkwrap-resolver-depchain</artifactId>
+ <version>2.1.1</version>
+ <scope>test</scope>
+ <type>pom</type>
+ </dependency>
+
+ <!--<dependency>-->
+ <!--<groupId>org.jboss.shrinkwrap.resolver</groupId>-->
+ <!--<artifactId>shrinkwrap-resolver-impl-maven</artifactId>-->
+ <!--<scope>test</scope>-->
+ <!--<version>2.1.1</version>-->
+ <!--</dependency>-->
+
+
<dependency>
- <groupId>org.apache.tomcat</groupId>
- <artifactId>tomcat-jsp-api</artifactId>
+ <groupId>org.jboss.arquillian.container</groupId>
+ <artifactId>arquillian-tomcat-embedded-7</artifactId>
+ <version>1.0.0.CR7</version>
<scope>test</scope>
- </dependency>-->
+ </dependency>
<!-- use the external test client. Just depend on the maven jetty plugin to launch jetty -->
<dependency>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/75a8361c/stack/rest/src/main/resources/usergrid-rest-deploy-context.xml
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/resources/usergrid-rest-deploy-context.xml b/stack/rest/src/main/resources/usergrid-rest-deploy-context.xml
index 73a4bd2..d240231 100644
--- a/stack/rest/src/main/resources/usergrid-rest-deploy-context.xml
+++ b/stack/rest/src/main/resources/usergrid-rest-deploy-context.xml
@@ -24,8 +24,8 @@
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<import resource="classpath:/usergrid-rest-context.xml" />
-
-
+
+
<bean id="properties"
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="singleton" value="true" />
@@ -33,7 +33,7 @@
<property name="locations">
<list>
<value>classpath:/usergrid-default.properties</value>
- <value>${usergrid-custom-spring-properties}</value>
+ <value>classpath:/usergrid-deployment.properties</value>
</list>
</property>
</bean>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/75a8361c/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
index 202e500..41b3be5 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
@@ -39,11 +39,20 @@ import javax.ws.rs.core.UriBuilder;
import org.apache.usergrid.java.client.Client;
import static org.apache.usergrid.utils.JsonUtils.mapToFormattedJsonString;
import static org.apache.usergrid.utils.MapUtils.hashMap;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.shrinkwrap.resolver.api.maven.Maven;
+import org.jboss.shrinkwrap.resolver.api.maven.archive.importer.MavenImporter;
import org.junit.AfterClass;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.ClassRule;
+import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -56,6 +65,7 @@ import org.slf4j.LoggerFactory;
* failure condition if multiple]
*/
//
+@RunWith( Arquillian.class )
public abstract class AbstractRestIT extends JerseyTest {
private static final Logger LOG = LoggerFactory.getLogger( AbstractRestIT.class );
private static boolean usersSetup = false;
@@ -91,6 +101,21 @@ public abstract class AbstractRestIT extends JerseyTest {
}
+ @Deployment(testable = false)
+ public static WebArchive createTestArchive() {
+
+ //we use the MavenImporter from shrinkwrap to just produce whatever maven would build then test with it
+
+ //set maven to be in offline mode
+ System.setProperty( "org.apache.maven.offline", "true" );
+
+ return ShrinkWrap.create(MavenImporter.class)
+ .loadPomFromFile("pom.xml", "arquillian-tomcat" ).importBuildOutput().as(WebArchive.class);
+
+ }
+
+
+
@AfterClass
public static void teardown() {
access_token = null;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/75a8361c/stack/rest/src/test/java/org/apache/usergrid/rest/TomcatResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/TomcatResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/TomcatResource.java
deleted file mode 100644
index 0446ef1..0000000
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/TomcatResource.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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.apache.usergrid.rest;
-
-import com.google.common.io.Files;
-import java.io.File;
-
-import org.junit.rules.ExternalResource;
-import org.apache.usergrid.cassandra.AvailablePortFinder;
-
-import org.apache.commons.lang.math.RandomUtils;
-
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.WebResource;
-import java.io.BufferedReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.atomic.AtomicInteger;
-import javax.servlet.ServletException;
-import org.apache.catalina.LifecycleException;
-import org.apache.catalina.startup.Tomcat;
-import org.apache.commons.lang.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-
-/**
- * Simple singleton to get tests running again. A temporary solution until we start using
- * Arquillian
- *
- */
-public class TomcatResource {
- private static final Logger log = LoggerFactory.getLogger(TomcatResource.class);
-
- public static TomcatResource instance;
-
-
- private Tomcat tomcat = null;
- private int port;
-
-
-
- public static synchronized TomcatResource getInstance(){
- if(instance == null){
- instance = new TomcatResource();
- }
-
- return instance;
- }
-
- private TomcatResource(){
- try {
- startTomcatEmbedded();
- }
- catch ( Exception e ) {
- throw new RuntimeException( "Unable to delete tomcat" );
- }
- }
-
- private void waitForTomcat() throws RuntimeException {
- String url = "http://localhost:" + port + "/status";
- int count = 0;
- while (count++ < 30) {
- try {
- Thread.sleep(1000);
- Client c = Client.create();
- WebResource wr = c.resource( url );
- wr.get( String.class );
- log.info("Tomcat is started.");
- return;
-
- } catch (Exception e) {
- log.info("Waiting for Tomcat on url {}", url);
- }
- }
-
-
- throw new RuntimeException("Tomcat process never started.");
-
- }
-
-
- private void startTomcatEmbedded() throws ServletException, LifecycleException {
-
- File dataDir = Files.createTempDir();
- dataDir.deleteOnExit();
-
- port = AvailablePortFinder.getNextAvailable( 9998 + RandomUtils.nextInt( 10 ) );
-
-
- tomcat = new Tomcat();
- tomcat.setBaseDir( dataDir.getAbsolutePath() );
- tomcat.setPort( port );
- tomcat.getConnector().setAttribute( "maxThreads", "2000" );
- tomcat.addWebapp( "/", new File( "target/ROOT" ).getAbsolutePath() );
-
- log.info( "-----------------------------------------------------------------" );
- log.info( "Starting Tomcat embedded port {} dir {}", port, dataDir.getAbsolutePath() );
- log.info( "-----------------------------------------------------------------" );
- tomcat.start();
-
- waitForTomcat();
- }
-
-
- /**
- * Get the port Tomcat runs on.
- */
- public int getPort() {
- return port;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/75a8361c/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ApplicationResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ApplicationResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ApplicationResource.java
index 4ee8055..a820a7b 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ApplicationResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ApplicationResource.java
@@ -20,18 +20,14 @@
package org.apache.usergrid.rest.test.resource2point0.endpoints.mgmt;
-import org.apache.usergrid.batch.service.App;
+
+import javax.ws.rs.core.MediaType;
+
import org.apache.usergrid.rest.test.resource2point0.endpoints.NamedResource;
import org.apache.usergrid.rest.test.resource2point0.endpoints.UrlResource;
-import org.apache.usergrid.rest.test.resource2point0.model.ApiResponse;
import org.apache.usergrid.rest.test.resource2point0.model.Application;
-import org.apache.usergrid.rest.test.resource2point0.model.Organization;
-import org.apache.usergrid.rest.test.resource2point0.model.Token;
import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
-import javax.ws.rs.core.MediaType;
-import java.util.Map;
-
/**
* Classy class class.
*/
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/75a8361c/stack/rest/src/test/resources/arquillian.xml
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/resources/arquillian.xml b/stack/rest/src/test/resources/arquillian.xml
new file mode 100644
index 0000000..a208aeb
--- /dev/null
+++ b/stack/rest/src/test/resources/arquillian.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF 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.
+ -->
+
+<arquillian
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://jboss.org/schema/arquillian"
+ xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
+
+ <!--<container qualifier="tomcat" default="true">-->
+ <!--<configuration>-->
+ <!--<property name="unpackArchive">true</property>-->
+ <!--</configuration>-->
+ <!--</container>-->
+
+
+ <container qualifier="tomcat" default="true">
+ <configuration>
+ <property name="tomcatHome">target/tomcat-embedded-7</property>
+ <property name="workDir">work</property>
+ <property name="bindHttpPort">8888</property>
+ <property name="unpackArchive">true</property>
+ <property name="serverName">arquillian-tomcat-embedded-7</property>
+ </configuration>
+ </container>
+</arquillian>
+
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/75a8361c/stack/services/src/main/java/org/apache/usergrid/services/ServiceInfo.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/ServiceInfo.java b/stack/services/src/main/java/org/apache/usergrid/services/ServiceInfo.java
index ea85686..0d34e1e 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/ServiceInfo.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/ServiceInfo.java
@@ -17,6 +17,7 @@
package org.apache.usergrid.services;
+import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
@@ -44,6 +45,8 @@ import static org.apache.usergrid.utils.StringUtils.stringOrSubstringBeforeLast;
public class ServiceInfo {
+ public static final Charset UTF_8 = Charset.forName( "UTF-8" );
+
private final String name;
private final boolean rootService;
private final String rootType;
@@ -71,7 +74,7 @@ public class ServiceInfo {
Hasher hasher = Hashing.md5().newHasher();
for ( String pattern : patterns ) {
- hasher.putString( pattern );
+ hasher.putString( pattern, UTF_8 );
}
hashCode = hasher.hash().asInt();