usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [2/6] git commit: Fixing query-validator
Date Fri, 14 Feb 2014 16:20:41 GMT
Fixing query-validator


Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/59af2a47
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/59af2a47
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/59af2a47

Branch: refs/pull/53/merge
Commit: 59af2a4766168a6a7a9814029cbcc2b546ebc271
Parents: c5b43cf
Author: Sungju Jin <sungju@softwaregeeks.org>
Authored: Fri Feb 14 23:26:39 2014 +0900
Committer: Sungju Jin <sungju@softwaregeeks.org>
Committed: Fri Feb 14 23:26:39 2014 +0900

----------------------------------------------------------------------
 stack/query-validator/.gitignore                |   1 +
 stack/query-validator/README.md                 |   3 +
 stack/query-validator/pom.xml                   | 201 +++--
 stack/query-validator/sql.db                    | Bin 4096 -> 0 bytes
 .../query/validator/ApiServerRunner.java        |  36 +-
 .../validator/DefaultQueryResultsMatcher.java   |  32 +
 .../usergrid/query/validator/QueryEntity.java   |  29 +
 .../usergrid/query/validator/QueryRequest.java  |  29 +-
 .../usergrid/query/validator/QueryResponse.java |  20 +-
 .../query/validator/QueryResultsMatcher.java    |  29 +
 .../usergrid/query/validator/QueryRunner.java   |  21 +-
 .../validator/QueryValidationConfiguration.java |  20 +
 .../query/validator/QueryValidator.java         |  31 +-
 .../usergrid/query/validator/SqliteRunner.java  |  62 +-
 .../usergrid-query-validator-context.xml        |  12 +-
 .../query/validator/AbstractQueryIT.java        | 133 +++
 .../query/validator/CassandraRunner.java        | 199 -----
 .../usergrid/query/validator/QueryITSuite.java  |  39 +
 .../query/validator/QueryValidationTest.java    | 339 -------
 .../query/validator/QueryValidatorRunner.java   | 208 -----
 .../query/validator/users/UserQueryIT.java      | 877 +++++++++++++++++++
 .../src/test/resources/project.properties       |   1 +
 .../src/test/resources/user.json                |  15 +-
 .../resources/usergrid-custom-test.properties   |  13 +-
 .../test/resources/usergrid-test-context.xml    |  22 +-
 25 files changed, 1448 insertions(+), 924 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/59af2a47/stack/query-validator/.gitignore
----------------------------------------------------------------------
diff --git a/stack/query-validator/.gitignore b/stack/query-validator/.gitignore
new file mode 100644
index 0000000..98e6ef6
--- /dev/null
+++ b/stack/query-validator/.gitignore
@@ -0,0 +1 @@
+*.db

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/59af2a47/stack/query-validator/README.md
----------------------------------------------------------------------
diff --git a/stack/query-validator/README.md b/stack/query-validator/README.md
new file mode 100644
index 0000000..152e474
--- /dev/null
+++ b/stack/query-validator/README.md
@@ -0,0 +1,3 @@
+
+This test package verifies that the Usergrid REST API returns results and does paging and limits 
+in a style similar to that of SqlLite.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/59af2a47/stack/query-validator/pom.xml
----------------------------------------------------------------------
diff --git a/stack/query-validator/pom.xml b/stack/query-validator/pom.xml
index 13f36d3..4cdb708 100644
--- a/stack/query-validator/pom.xml
+++ b/stack/query-validator/pom.xml
@@ -14,14 +14,7 @@
     <name>Usergrid Query Validator</name>
     <description>Query validator tools for Usergrid system.</description>
     <packaging>jar</packaging>
-    <reporting>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-surefire-report-plugin</artifactId>
-            </plugin>
-        </plugins>
-    </reporting>
+
     <build>
         <resources>
             <resource>
@@ -37,9 +30,7 @@
                 <directory>src/test/resources</directory>
                 <filtering>true</filtering>
                 <includes>
-                    <include>**/*.xml</include>
-                    <include>**/*.properties</include>
-                    <include>**/*.json</include>
+                    <include>**/*</include>
                 </includes>
             </testResource>
         </testResources>
@@ -48,7 +39,16 @@
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-surefire-plugin</artifactId>
                 <configuration>
-                    <testFailureIgnore>false</testFailureIgnore>
+                    <argLine>-Xmx${ug.heapmax} -Xms${ug.heapmin} -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8</argLine>
+
+                    <includes>
+                        <include>**/*Suite.java</include>
+                    </includes>
+                    <excludes>
+                        <!-- Need to exclude Suite tests to prevent double execution -->
+                        <exclude>**/UserQueryIT.java</exclude>
+                    </excludes>
+
                 </configuration>
             </plugin>
 
@@ -77,9 +77,8 @@
                             <goal>test-jar</goal>
                         </goals>
                         <configuration>
-                            <classifier>tests</classifier>
                             <includes>
-                                <include>**/org/apache/usergrid/**</include>
+                                <include>**/org/usergrid/**</include>
                             </includes>
                         </configuration>
                     </execution>
@@ -92,123 +91,189 @@
             <groupId>org.apache.usergrid</groupId>
             <artifactId>usergrid-config</artifactId>
             <version>${project.version}</version>
-            <scope>test</scope>
-            <classifier>tests</classifier>
         </dependency>
+
         <dependency>
             <groupId>org.apache.usergrid</groupId>
-            <artifactId>usergrid-test-utils</artifactId>
+            <artifactId>usergrid-core</artifactId>
             <version>${project.version}</version>
-            <scope>test</scope>
+            <exclusions>
+                <exclusion>
+                    <artifactId>commons-logging</artifactId>
+                    <groupId>commons-logging</groupId>
+                </exclusion>
+            </exclusions>
         </dependency>
+
         <dependency>
             <groupId>org.apache.usergrid</groupId>
-            <artifactId>usergrid-core</artifactId>
+            <artifactId>usergrid-rest</artifactId>
             <version>${project.version}</version>
+            <classifier>classes</classifier>
             <exclusions>
                 <exclusion>
-                    <artifactId>commons-logging</artifactId>
-                    <groupId>commons-logging</groupId>
+                    <artifactId>servlet-api</artifactId>
+                    <groupId>javax.servlet</groupId>
                 </exclusion>
             </exclusions>
         </dependency>
+
         <dependency>
             <groupId>org.apache.usergrid</groupId>
-            <artifactId>usergrid-core</artifactId>
+            <artifactId>usergrid-rest</artifactId>
             <version>${project.version}</version>
-            <scope>test</scope>
-            <classifier>tests</classifier>
+            <classifier>compiled-jsp</classifier>
         </dependency>
+
         <dependency>
             <groupId>org.apache.usergrid</groupId>
-            <artifactId>usergrid-launcher</artifactId>
+            <artifactId>usergrid-rest</artifactId>
             <version>${project.version}</version>
-            <scope>compile</scope>
+            <classifier>tests</classifier>
+            <scope>test</scope>
         </dependency>
+
+        <!-- Apache Dependencies -->
+
         <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-api</artifactId>
+            <groupId>commons-collections</groupId>
+            <artifactId>commons-collections</artifactId>
         </dependency>
+
+        <!-- SUN, Javax Package, and Other Com Dependencies -->
+
+
         <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-log4j12</artifactId>
-            <scope>test</scope>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+            <scope>provided</scope>
         </dependency>
+
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>jstl</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-webmvc</artifactId>
+        </dependency>
+
         <dependency>
-            <groupId>log4j</groupId>
-            <artifactId>log4j</artifactId>
+            <groupId>org.apache.usergrid</groupId>
+            <artifactId>usergrid-config</artifactId>
+            <version>${project.version}</version>
             <scope>test</scope>
+            <classifier>tests</classifier>
         </dependency>
+
         <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>jcl-over-slf4j</artifactId>
+            <groupId>org.apache.usergrid</groupId>
+            <artifactId>usergrid-test-utils</artifactId>
+            <version>${project.version}</version>
             <scope>test</scope>
         </dependency>
+
         <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>jul-to-slf4j</artifactId>
+            <groupId>org.apache.usergrid</groupId>
+            <artifactId>usergrid-core</artifactId>
+            <version>${project.version}</version>
             <scope>test</scope>
+            <classifier>tests</classifier>
         </dependency>
+
         <dependency>
             <groupId>org.springframework</groupId>
-            <artifactId>spring-core</artifactId>
-            <exclusions>
-                <exclusion>
-                    <artifactId>commons-logging</artifactId>
-                    <groupId>commons-logging</groupId>
-                </exclusion>
-            </exclusions>
+            <artifactId>spring-test</artifactId>
+            <scope>test</scope>
         </dependency>
+
         <dependency>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-expression</artifactId>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
         </dependency>
+
         <dependency>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-beans</artifactId>
+            <groupId>org.jvnet.mock-javamail</groupId>
+            <artifactId>mock-javamail</artifactId>
+            <scope>test</scope>
         </dependency>
+
         <dependency>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-aop</artifactId>
+            <groupId>org.hectorclient</groupId>
+            <artifactId>hector-test</artifactId>
+            <scope>test</scope>
         </dependency>
+
         <dependency>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-context</artifactId>
+            <groupId>org.apache.tomcat.embed</groupId>
+            <artifactId>tomcat-embed-core</artifactId>
+            <scope>test</scope>
         </dependency>
+
         <dependency>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-context-support</artifactId>
+            <groupId>org.apache.tomcat.embed</groupId>
+            <artifactId>tomcat-embed-logging-juli</artifactId>
+            <scope>test</scope>
         </dependency>
+
         <dependency>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-web</artifactId>
+            <groupId>org.apache.tomcat.embed</groupId>
+            <artifactId>tomcat-embed-jasper</artifactId>
+            <scope>test</scope>
         </dependency>
+
         <dependency>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-test</artifactId>
+            <groupId>org.apache.tomcat</groupId>
+            <artifactId>tomcat-jasper-el</artifactId>
             <scope>test</scope>
         </dependency>
+
         <dependency>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-jdbc</artifactId>
-            <version>${org.springframework.version}</version>
+            <groupId>org.apache.tomcat</groupId>
+            <artifactId>tomcat-jsp-api</artifactId>
+            <scope>test</scope>
         </dependency>
+
         <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
+            <groupId>org.apache.tomcat</groupId>
+            <artifactId>juli</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <!--  use the external test client.  Just depend on the maven jetty plugin to launch jetty -->
+        <dependency>
+            <groupId>com.sun.jersey.jersey-test-framework</groupId>
+            <artifactId>jersey-test-framework-external</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>com.sun.jersey.jersey-test-framework</groupId>
+            <artifactId>jersey-test-framework-core</artifactId>
             <scope>test</scope>
         </dependency>
+
+
+
+        <dependency>
+            <groupId>org.usergrid</groupId>
+            <artifactId>usergrid-java-client</artifactId>
+        </dependency>
+
         <dependency>
             <groupId>org.xerial</groupId>
             <artifactId>sqlite-jdbc</artifactId>
             <version>3.7.2</version>
         </dependency>
+
         <dependency>
-            <groupId>org.usergrid</groupId>
-            <artifactId>usergrid-java-client</artifactId>
-            <version>0.0.3</version>
-            <scope>compile</scope>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-jdbc</artifactId>
+            <version>${org.springframework.version}</version>
         </dependency>
+
     </dependencies>
 
-</project>
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/59af2a47/stack/query-validator/sql.db
----------------------------------------------------------------------
diff --git a/stack/query-validator/sql.db b/stack/query-validator/sql.db
deleted file mode 100644
index 8c6c25f..0000000
Binary files a/stack/query-validator/sql.db and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/59af2a47/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/ApiServerRunner.java
----------------------------------------------------------------------
diff --git a/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/ApiServerRunner.java b/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/ApiServerRunner.java
index c5f28e6..57434b2 100644
--- a/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/ApiServerRunner.java
+++ b/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/ApiServerRunner.java
@@ -1,41 +1,41 @@
-/*******************************************************************************
- * Copyright 2013 baas.io
- *
- * Licensed 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
+/**
+ * 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
+ *     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.query.validator;
 
-import org.apache.commons.lang.StringUtils;
-import org.codehaus.jackson.JsonNode;
-import org.springframework.http.HttpMethod;
-import org.springframework.stereotype.Component;
-import org.apache.usergrid.persistence.Entity;
-
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
-import org.apache.usergrid.persistence.Schema;
-
 import java.util.Map;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+import org.apache.commons.lang.StringUtils;
+import org.apache.usergrid.persistence.Entity;
+import org.apache.usergrid.persistence.Schema;
+import org.codehaus.jackson.JsonNode;
+import org.springframework.http.HttpMethod;
+import org.springframework.stereotype.Component;
 import org.usergrid.java.client.Client;
 import org.usergrid.java.client.response.ApiResponse;
-
 import static org.usergrid.java.client.utils.ObjectUtils.isEmpty;
 
+
 /**
- * @author Sung-ju Jin(realbeast)
+ * @author Sungju Jin
  */
 @Component
 public class ApiServerRunner implements QueryRunner {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/59af2a47/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/DefaultQueryResultsMatcher.java
----------------------------------------------------------------------
diff --git a/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/DefaultQueryResultsMatcher.java b/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/DefaultQueryResultsMatcher.java
new file mode 100644
index 0000000..7690cce
--- /dev/null
+++ b/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/DefaultQueryResultsMatcher.java
@@ -0,0 +1,32 @@
+/**
+ * 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.query.validator;
+
+import org.apache.usergrid.persistence.Entity;
+
+import java.util.List;
+
+/**
+ * @author Sungju Jin
+ */
+public class DefaultQueryResultsMatcher implements QueryResultsMatcher {
+    @Override
+    public boolean equals(List<Entity> expectedEntities, List<Entity> actuallyEntities) {
+        return expectedEntities.equals(actuallyEntities);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/59af2a47/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/QueryEntity.java
----------------------------------------------------------------------
diff --git a/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/QueryEntity.java b/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/QueryEntity.java
index 77893bd..5790204 100644
--- a/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/QueryEntity.java
+++ b/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/QueryEntity.java
@@ -1,9 +1,29 @@
+/**
+ * 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.query.validator;
 
 import org.apache.usergrid.persistence.DynamicEntity;
 
 import java.util.Map;
 
+/**
+ * @author Sungju Jin
+ */
 public class QueryEntity extends DynamicEntity {
 
     @Override
@@ -26,6 +46,15 @@ public class QueryEntity extends DynamicEntity {
 
             Object value = properties.get(key);
             Object otherValue = otherProperties.get(key);
+
+            if(value.getClass() == Boolean.class) {
+                value = (Boolean)value ? 1 : 0;
+            }
+
+            if(otherValue.getClass() == Boolean.class) {
+                otherValue = (Boolean)otherValue ? 1 : 0;
+            }
+
             if( otherValue == null || !value.equals(otherValue) )
                 return false;
         }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/59af2a47/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/QueryRequest.java
----------------------------------------------------------------------
diff --git a/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/QueryRequest.java b/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/QueryRequest.java
index d2989c7..eecc0d2 100644
--- a/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/QueryRequest.java
+++ b/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/QueryRequest.java
@@ -1,27 +1,28 @@
-/*******************************************************************************
- * Copyright 2013 baas.io
- *
- * Licensed 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
+/**
+ * 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
+ *     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.query.validator;
 
 /**
- * @author Sung-ju Jin(realbeast)
+ * @author Sungju Jin
  */
 public class QueryRequest {
     private String dbQuery;
     private ApiQuery apiQuery;
-    private boolean ignoreOrdering;
 
     public  QueryRequest() {
         this.apiQuery = new ApiQuery();
@@ -63,12 +64,4 @@ public class QueryRequest {
             this.limit = limit;
         }
     }
-
-    public boolean isIgnoreOrdering() {
-        return ignoreOrdering;
-    }
-
-    public void setIgnoreOrdering(boolean ignoreOrdering) {
-        this.ignoreOrdering = ignoreOrdering;
-    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/59af2a47/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/QueryResponse.java
----------------------------------------------------------------------
diff --git a/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/QueryResponse.java b/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/QueryResponse.java
index aa152d5..b3669ff 100644
--- a/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/QueryResponse.java
+++ b/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/QueryResponse.java
@@ -1,18 +1,20 @@
-/*******************************************************************************
- * Copyright 2013 baas.io
- *
- * Licensed 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
+/**
+ * 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
+ *     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.query.validator;
 
 import org.apache.commons.lang.StringUtils;
@@ -21,7 +23,7 @@ import org.apache.usergrid.persistence.Entity;
 import java.util.List;
 
 /**
- * @author Sung-ju Jin(realbeast)
+ * @author Sungju Jin
  */
 public class QueryResponse {
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/59af2a47/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/QueryResultsMatcher.java
----------------------------------------------------------------------
diff --git a/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/QueryResultsMatcher.java b/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/QueryResultsMatcher.java
new file mode 100644
index 0000000..c85fa54
--- /dev/null
+++ b/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/QueryResultsMatcher.java
@@ -0,0 +1,29 @@
+/**
+ * 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.query.validator;
+
+import org.apache.usergrid.persistence.Entity;
+
+import java.util.List;
+
+/**
+ * @author Sungju Jin
+ */
+public interface QueryResultsMatcher {
+    boolean equals(List<Entity> expectedEntities, List<Entity> actuallyEntities);
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/59af2a47/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/QueryRunner.java
----------------------------------------------------------------------
diff --git a/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/QueryRunner.java b/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/QueryRunner.java
index 06341d6..84b2b51 100644
--- a/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/QueryRunner.java
+++ b/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/QueryRunner.java
@@ -1,25 +1,28 @@
-/*******************************************************************************
- * Copyright 2013 baas.io
- *
- * Licensed 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
+/**
+ * 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
+ *     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.query.validator;
 
+
 import java.util.List;
 import org.apache.usergrid.persistence.Entity;
 
 /**
- * @author Sung-ju Jin(realbeast)
+ * @author Sungju Jin
  */
 public interface QueryRunner {
     public boolean setup();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/59af2a47/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/QueryValidationConfiguration.java
----------------------------------------------------------------------
diff --git a/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/QueryValidationConfiguration.java b/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/QueryValidationConfiguration.java
index 8b14737..6f7b9e6 100644
--- a/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/QueryValidationConfiguration.java
+++ b/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/QueryValidationConfiguration.java
@@ -1,3 +1,20 @@
+/**
+ * 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.query.validator;
 
 import org.apache.usergrid.persistence.Entity;
@@ -5,6 +22,9 @@ import org.apache.usergrid.utils.InflectionUtils;
 
 import java.util.List;
 
+/**
+ * @author Sungju Jin
+ */
 public class QueryValidationConfiguration {
 
     String org;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/59af2a47/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/QueryValidator.java
----------------------------------------------------------------------
diff --git a/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/QueryValidator.java b/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/QueryValidator.java
index 180a8e5..4d46950 100644
--- a/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/QueryValidator.java
+++ b/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/QueryValidator.java
@@ -1,18 +1,20 @@
-/*******************************************************************************
- * Copyright 2013 baas.io
- *
- * Licensed 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
+/**
+ * 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
+ *     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.query.validator;
 
 import org.springframework.beans.factory.annotation.Autowired;
@@ -22,7 +24,7 @@ import org.apache.usergrid.persistence.Entity;
 import java.util.List;
 
 /**
- * @author Sung-ju Jin(realbeast)
+ * @author Sungju Jin
  */
 @Component
 public class QueryValidator {
@@ -45,14 +47,13 @@ public class QueryValidator {
     }
 
     public QueryResponse execute(QueryRequest request) {
+        return execute(request, new DefaultQueryResultsMatcher());
+    }
+
+    public QueryResponse execute(QueryRequest request, QueryResultsMatcher matcher) {
         List<Entity> sqlEntities = sql.execute(request.getDbQuery());
         List<Entity> apiEntities = api.execute(request.getApiQuery().getQuery(), request.getApiQuery().getLimit());
-        boolean equals = false;
-        if( request.isIgnoreOrdering() ) {
-            equals = sqlEntities.size() == apiEntities.size();
-        } else {
-            equals = sqlEntities.equals(apiEntities);
-        }
+        boolean equals = matcher.equals(sqlEntities, apiEntities);
 
         QueryResponse response = new QueryResponse();
         response.setResult(equals);

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/59af2a47/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/SqliteRunner.java
----------------------------------------------------------------------
diff --git a/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/SqliteRunner.java b/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/SqliteRunner.java
index a1932a0..a0ffbd6 100644
--- a/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/SqliteRunner.java
+++ b/stack/query-validator/src/main/java/org/apache/usergrid/query/validator/SqliteRunner.java
@@ -1,24 +1,24 @@
-/*******************************************************************************
- * Copyright 2013 baas.io
- *
- * Licensed 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
+/**
+ * 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
+ *     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.query.validator;
 
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.jdbc.core.RowMapper;
 import org.springframework.stereotype.Component;
 import org.apache.usergrid.persistence.Entity;
 import org.apache.usergrid.persistence.Schema;
@@ -29,9 +29,11 @@ import java.sql.SQLException;
 import java.util.List;
 import java.util.Map;
 import java.util.logging.Logger;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.core.RowMapper;
 
 /**
- * @author Sung-ju Jin(realbeast)
+ * @author Sungju Jin
  */
 @Component
 public class SqliteRunner implements QueryRunner {
@@ -65,8 +67,28 @@ public class SqliteRunner implements QueryRunner {
             feilds.append(key);
             feilds.append(",");
 
-            Object value = entity.getProperty(key);
-            Class type = value.getClass();
+            Class type = null;
+            try
+            {
+                type = entity.getProperty(key).getClass();
+            } catch (NullPointerException ne) {
+                type = entity.getDynamicProperties().get(key).getClass();
+            }
+
+            Object value = null;
+            if(StringUtils.equals("name",key)) {
+                value = entity.getName();
+            } else {
+                value = entity.getProperty(key);
+            }
+            if( type == Boolean.class ) {
+                if((Boolean)value) {
+                    value = 1;
+                } else {
+                    value = 0;
+                }
+            }
+
             String sqlType = getSqlDatatype(type);
             if( StringUtils.equals("TEXT", sqlType) ) {
                 values.append("'");
@@ -104,7 +126,14 @@ public class SqliteRunner implements QueryRunner {
             builder.append(key);
             builder.append(" ");
 
-            Class type = entity.getProperty(key).getClass();
+            Class type = null;
+            try
+            {
+                type = entity.getProperty(key).getClass();
+            } catch (NullPointerException ne) {
+                type = entity.getDynamicProperties().get(key).getClass();
+            }
+
             String sqlType = getSqlDatatype(type);
             builder.append(sqlType);
             builder.append(",");
@@ -140,10 +169,13 @@ public class SqliteRunner implements QueryRunner {
 
     // based on sqlite (http://www.sqlite.org/datatype3.html)
     private String getSqlDatatype(Class clz) {
+        if ( clz == null )
+            return "TEXT";
+
         if( clz == Integer.class || clz == Long.class || clz == Boolean.class ) {
             return "INTEGER";
         } else if( clz == Double.class ) {
-                return "REAL";
+            return "REAL";
         } else if( clz == Byte.class ) {
             return "BLOB";
         }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/59af2a47/stack/query-validator/src/main/resources/usergrid-query-validator-context.xml
----------------------------------------------------------------------
diff --git a/stack/query-validator/src/main/resources/usergrid-query-validator-context.xml b/stack/query-validator/src/main/resources/usergrid-query-validator-context.xml
index 36355a8..3a8c577 100644
--- a/stack/query-validator/src/main/resources/usergrid-query-validator-context.xml
+++ b/stack/query-validator/src/main/resources/usergrid-query-validator-context.xml
@@ -1,16 +1,14 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <beans xmlns="http://www.springframework.org/schema/beans"
-	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	xmlns:context="http://www.springframework.org/schema/context"
-	xsi:schemaLocation="
-	http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
-	http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:context="http://www.springframework.org/schema/context"
+       xsi:schemaLocation="
+        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
+        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
 
 	<context:annotation-config />
     <context:component-scan base-package="org.apache.usergrid.query.validator" />
 
-    <import resource="classpath:/usergrid-core-context.xml" />
-
     <bean id="dataSource"
           class="org.springframework.jdbc.datasource.DriverManagerDataSource">
         <property name="driverClassName" value="org.sqlite.JDBC" />

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/59af2a47/stack/query-validator/src/test/java/org/apache/usergrid/query/validator/AbstractQueryIT.java
----------------------------------------------------------------------
diff --git a/stack/query-validator/src/test/java/org/apache/usergrid/query/validator/AbstractQueryIT.java b/stack/query-validator/src/test/java/org/apache/usergrid/query/validator/AbstractQueryIT.java
new file mode 100644
index 0000000..f41a1f0
--- /dev/null
+++ b/stack/query-validator/src/test/java/org/apache/usergrid/query/validator/AbstractQueryIT.java
@@ -0,0 +1,133 @@
+/**
+ * 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.query.validator;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.StringUtils;
+import org.junit.BeforeClass;
+import org.apache.usergrid.management.ApplicationInfo;
+import org.apache.usergrid.management.ManagementService;
+import org.apache.usergrid.management.OrganizationInfo;
+import org.apache.usergrid.management.UserInfo;
+import org.apache.usergrid.persistence.Entity;
+import org.apache.usergrid.utils.JsonUtils;
+
+import java.io.IOException;
+import java.net.URL;
+import java.nio.charset.Charset;
+import java.util.*;
+
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * @author Sungju Jin
+ */
+public class AbstractQueryIT {
+
+    protected static QueryValidator validator;
+    private static Properties properties;
+    private static String fullEndpoint;
+    private static String orgName;
+    private static String appName;
+    private static String email;
+    private static String password;
+    private static int port;
+
+    @BeforeClass
+    public static void tearsup() throws Exception {
+        validator = QueryITSuite.cassandraResource.getBean(QueryValidator.class);
+        properties = QueryITSuite.cassandraResource.getBean("properties",Properties.class);
+        if( isDisableLocalServer()) {
+            return;
+        }
+        setProperties();
+        createOrganizationWithApplication();
+    }
+
+    private static void createOrganizationWithApplication() throws Exception {
+        String uuid = UUID.randomUUID().toString().replaceAll("-", "");
+        orgName = orgName + uuid;
+        appName = appName + uuid;
+        email = orgName + "@usergrid.com";
+        ManagementService managementService = QueryITSuite.serverResource.getMgmtSvc();
+        UserInfo user = managementService.createAdminUser(orgName, "Query Test", email, password, false, false);
+        OrganizationInfo org = managementService.createOrganization(orgName, user, false );
+        assertNotNull( org );
+        ApplicationInfo app = managementService.createApplication( org.getUuid(), appName);
+        assertNotNull( app );
+    }
+
+    private static void setProperties() {
+        port = QueryITSuite.serverResource.getTomcatPort();
+        fullEndpoint = (String)properties.get("usergrid.query.validator.api.endpoint") + ":" + port;
+        orgName = (String)properties.get("usergrid.query.validator.api.organization");
+        appName = (String)properties.get("usergrid.query.validator.api.app");
+        email = (String)properties.get("usergrid.query.validator.api.authorize.email");
+        password = (String)properties.get("usergrid.query.validator.api.authorize.password");
+    }
+
+    protected static void createInitializationDatas(String collection) {
+        List<Entity> entities = loadEntitiesFromResource(collection);
+        QueryValidationConfiguration configuration = new QueryValidationConfiguration();
+        configuration.setEndpointUri(fullEndpoint);
+        configuration.setOrg(orgName);
+        configuration.setEmail(email);
+        configuration.setPassword(password);
+        configuration.setApp(appName);
+        configuration.setCollection(collection);
+        configuration.setEntities(entities);
+        validator.setConfiguration(configuration);
+        validator.setup();
+    }
+
+    private static List<Entity> loadEntitiesFromResource(String collection) {
+        String json = null;
+        try {
+            URL url = Thread.currentThread().getContextClassLoader().getResource(collection + ".json");
+            json = FileUtils.readFileToString(FileUtils.toFile(url), Charset.forName("UTF-8"));
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+
+        List<Entity> entities = new ArrayList<Entity>();
+        List<Map<String, Object>> datas = (List<Map<String, Object>>) JsonUtils.parse(json);
+        int index = 0;
+        for(Map<String, Object> data : datas) {
+            long created = System.currentTimeMillis() + (index*1000);
+
+            QueryEntity entity = new QueryEntity();
+            entity.setType(collection);
+            for ( Map.Entry<String, Object> property : data.entrySet() ) {
+                if(StringUtils.equals("name", property.getKey()))
+                    entity.setName((String)property.getValue());
+                else
+                    entity.setProperty( property.getKey(), property.getValue() );
+            }
+            entity.setProperties(data);
+            entity.setCreated(created);
+            entity.setModified(created);
+            entities.add(entity);
+            index++;
+        }
+        return entities;
+    }
+
+    private static boolean isDisableLocalServer() {
+        return !StringUtils.equalsIgnoreCase("true", (String) properties.get("usergrid.query.validator.api.enablelocal"));
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/59af2a47/stack/query-validator/src/test/java/org/apache/usergrid/query/validator/CassandraRunner.java
----------------------------------------------------------------------
diff --git a/stack/query-validator/src/test/java/org/apache/usergrid/query/validator/CassandraRunner.java b/stack/query-validator/src/test/java/org/apache/usergrid/query/validator/CassandraRunner.java
deleted file mode 100644
index 802f842..0000000
--- a/stack/query-validator/src/test/java/org/apache/usergrid/query/validator/CassandraRunner.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Copyright 2014 The Apache Software Foundation.
- *
- * Licensed 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.query.validator;
-
-import org.apache.commons.io.FileUtils;
-import org.junit.runner.notification.RunNotifier;
-import org.junit.runners.BlockJUnit4ClassRunner;
-import org.junit.runners.model.InitializationError;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-import java.io.File;
-import java.lang.annotation.Annotation;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-import org.apache.cassandra.service.CassandraDaemon;
-import org.apache.usergrid.cassandra.DataControl;
-import org.apache.usergrid.cassandra.SchemaManager;
-
-public class CassandraRunner extends BlockJUnit4ClassRunner {
-
-    private static final String TMP = "tmp";
-    private static Logger logger = LoggerFactory.getLogger(CassandraRunner.class);
-    private static ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
-    private static ContextHolder contextHolder;
-    private SchemaManager schemaManager;
-
-    // TODO maybe put a 'holder' object in the executor and provide access to application context thusly?
-    // TODO assume a static 'usergrid-test-context.xml' primer/starter file
-
-    public CassandraRunner(Class<?> klass) throws InitializationError {
-        super(klass);
-        logger.info("CassandraRunner started with class {}", klass.getName());
-    }
-
-
-    public static <T> T getBean(String name, Class<T> requiredType) {
-        return contextHolder.applicationContext.getBean(name, requiredType);
-    }
-
-    public static <T> T getBean(Class<T> requiredType) {
-        return contextHolder.applicationContext.getBean(requiredType);
-    }
-
-    /**
-     * Class-level run. The order of events are as follows:
-     * - load spring (if not loaded)
-     * - init cassandra (if not started)
-     * - look for DataControl annotation on class and delegate
-     * @param notifier
-     */
-    @Override
-    public void run(RunNotifier notifier) {
-        DataControl control = preTest(notifier);
-        super.run(notifier);
-        postTest(notifier, control);
-       
-    }
-    
-    protected DataControl preTest(RunNotifier notifier){
-      maybeInit();
-
-      // check for SchemaManager annotation
-      DataControl control = null;
-      for(Annotation ann : getTestClass().getAnnotations() ) {
-          logger.info("examining annotation " + ann);
-          if ( ann instanceof DataControl ) {
-              logger.info("founda dataCOntrol annotation");
-              control = (DataControl)ann;
-          }
-      }
-      loadDataControl(control);
-      maybeCreateSchema();
-      
-      return control;
-    }
-    
-    protected void postTest(RunNotifier notifier, DataControl control){
-      if ( control == null || !control.skipTruncate() ) {
-        schemaManager.destroy();
-    }
-    logger.info("shutting down context");
-    contextHolder.applicationContext.stop();
-      
-    }
-
-   
-    private void loadDataControl(DataControl dataControl) {
-        if ( !contextHolder.applicationContext.isActive() ) {
-            logger.info("restarting context...");
-            contextHolder.applicationContext.refresh();
-        }
-
-        if ( dataControl != null ) {
-            // TODO check for classpath and go static?
-            logger.info("dataControl found - looking upma SchemaManager impl");
-            schemaManager = getBean(dataControl.schemaManager(), SchemaManager.class);
-        } else {
-            logger.info("dataControl not found - using default SchemaManager impl");
-            schemaManager = getBean(SchemaManager.class);
-        }
-
-
-    }
-
-    private boolean maybeCreateSchema() {
-        if ( schemaManager.exists() ) {
-            logger.info("Schema existed");
-            return false;
-        }
-        schemaManager.create();
-        schemaManager.populateBaseData();
-
-        return true;
-    }
-
-
-
-    private static void maybeInit() {
-        if ( contextHolder != null ) {
-            return;
-        }
-        logger.info("Initing CassandraRunner...");
-
-        // TODO these should all be passed in as config options ... via spring?
-        // TODO make sure these match up with configs
-        // TODO one cassandra config in this project!
-        // TODO log4j.properties required to be present
-
-        System.setProperty("cassandra-foreground", "true");
-        System.setProperty("log4j.defaultInitOverride","true");
-        System.setProperty("log4j.configuration", "log4j.properties");
-        //System.setProperty("cassandra.load_ring_state", "false");so
-        //System.setProperty("cassandra.join_ring","false");
-        System.setProperty("cassandra.ring_delay_ms","100");
-
-        FileUtils.deleteQuietly(new File(TMP));
-
-        contextHolder = new ContextHolder();
-        try {
-            executor.schedule(contextHolder, 3, TimeUnit.SECONDS).get();
-        } catch (Exception ex) {
-            logger.error("Could not schedule cassandra runner",ex);
-        }
-        Runtime.getRuntime().addShutdownHook(new Thread() {
-            @Override
-            public void run() {
-                try {
-                    logger.error("In shutdownHook");
-                    stopCassandra();
-                } catch (Exception ex) {
-                    ex.printStackTrace();
-                }
-            }
-        });
-    }
-
-    private static void stopCassandra() throws Exception {
-        if (contextHolder != null && contextHolder.cassandraDaemon != null) {
-            contextHolder.cassandraDaemon.deactivate();
-        }
-        executor.shutdown();
-        executor.shutdownNow();
-    }
-
-    static class ContextHolder implements Runnable {
-        ConfigurableApplicationContext applicationContext;
-        CassandraDaemon cassandraDaemon;
-
-        @Override
-        public void run() {
-            cassandraDaemon = new CassandraDaemon();
-            cassandraDaemon.activate();
-            String[] locations = {"usergrid-test-context.xml"};
-            applicationContext = new ClassPathXmlApplicationContext(locations);
-
-
-
-                    //acbf.autowire(getTestClass().getJavaClass(),AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, true);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/59af2a47/stack/query-validator/src/test/java/org/apache/usergrid/query/validator/QueryITSuite.java
----------------------------------------------------------------------
diff --git a/stack/query-validator/src/test/java/org/apache/usergrid/query/validator/QueryITSuite.java b/stack/query-validator/src/test/java/org/apache/usergrid/query/validator/QueryITSuite.java
new file mode 100644
index 0000000..8f92fc3
--- /dev/null
+++ b/stack/query-validator/src/test/java/org/apache/usergrid/query/validator/QueryITSuite.java
@@ -0,0 +1,39 @@
+/**
+ * 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.query.validator;
+
+import org.junit.ClassRule;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.apache.usergrid.cassandra.CassandraResource;
+import org.apache.usergrid.query.validator.users.UserQueryIT;
+import org.apache.usergrid.rest.ITSetup;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses(
+        {
+                UserQueryIT.class
+        })
+public class QueryITSuite {
+    @ClassRule
+    public static CassandraResource cassandraResource = CassandraResource.newWithAvailablePorts();
+
+    //TODO Detecting current path
+    @ClassRule
+    public static ITSetup serverResource = new ITSetup( cassandraResource, "../rest/src/main/webapp" );
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/59af2a47/stack/query-validator/src/test/java/org/apache/usergrid/query/validator/QueryValidationTest.java
----------------------------------------------------------------------
diff --git a/stack/query-validator/src/test/java/org/apache/usergrid/query/validator/QueryValidationTest.java b/stack/query-validator/src/test/java/org/apache/usergrid/query/validator/QueryValidationTest.java
deleted file mode 100644
index 5054e45..0000000
--- a/stack/query-validator/src/test/java/org/apache/usergrid/query/validator/QueryValidationTest.java
+++ /dev/null
@@ -1,339 +0,0 @@
-/*******************************************************************************
- * Copyright 2013 baas.io
- *
- * Licensed 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.query.validator;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.Assert;
-
-/**
- * @author Sung-ju Jin(realbeast)
- */
-@RunWith(QueryValidatorRunner.class)
-public class QueryValidationTest {
-
-    private QueryValidator validator;
-
-    @Before
-    public void setup() {
-        validator = QueryValidatorRunner.getValidator();
-    }
-
-    @Test
-    public void sexEqualAndNameEqual() {
-        String sqlite = "SELECT * FROM users WHERE sex = 'male' and name = 'judekim' LIMIT 10";
-        String api = "SELECT * WHERE sex = 'male' AND name = 'judekim'";
-
-        QueryRequest request = new QueryRequest();
-        request.setDbQuery(sqlite);
-        request.getApiQuery().setQuery(api);
-        QueryResponse response = validator.execute(request);
-        Assert.assertTrue(response.toString(), response.result());
-    }
-
-    @Test
-    public void nameEqualAndSexEqual() {
-        String sqlite = "SELECT * FROM users WHERE name = 'judekim' and sex = 'male' LIMIT 10";
-        String api = "select * where name = 'judekim' and sex = 'male'";
-
-        QueryRequest request = new QueryRequest();
-        request.setDbQuery(sqlite);
-        request.getApiQuery().setQuery(api);
-        QueryResponse response = validator.execute(request);
-        Assert.assertTrue(response.toString(), response.result());
-    }
-
-    @Test
-    public void nameEqualAndSexEqual_limitL20() {
-        String sqlite = "SELECT * FROM users WHERE name = 'judekim' and sex = 'male' LIMIT 20";
-        String api = "select * where name = 'judekim' and sex = 'male'";
-        int limit = 20;
-
-        QueryRequest request = new QueryRequest();
-        request.setDbQuery(sqlite);
-        request.getApiQuery().setQuery(api);
-        request.getApiQuery().setLimit(limit);
-        QueryResponse response = validator.execute(request);
-        Assert.assertTrue(response.toString(), response.result());
-    }
-
-    @Test
-    public void sexEqualAndNameEqualExtra1() {
-        String sqlite = "SELECT * FROM users WHERE sex = 'female' and name = 'curioe' LIMIT 10";
-        String api = "select * where sex = 'female' and name = 'curioe'";
-
-        QueryRequest request = new QueryRequest();
-        request.setDbQuery(sqlite);
-        request.getApiQuery().setQuery(api);
-        QueryResponse response = validator.execute(request);
-        Assert.assertTrue(response.toString(), response.result());
-    }
-
-    @Test
-    public void sexEqualOrNameEqual() {
-        String sqlite = "SELECT * FROM users WHERE sex = 'female' or name = 'curioe' LIMIT 10";
-        String api = "select * where sex = 'female' or name = 'curioe'";
-
-        QueryRequest request = new QueryRequest();
-        request.setDbQuery(sqlite);
-        request.getApiQuery().setQuery(api);
-        QueryResponse response = validator.execute(request);
-        Assert.assertTrue(response.toString(), response.result());
-    }
-
-    @Test
-    public void nameBeginswithAndSexEqualAndAgeGreaterthanequalOrSexEqual_sortNameDesc() {
-        String sqlite = "SELECT * FROM users WHERE name LIKE 'a%' and sex = 'male' and age >= 35 or sex = 'female' ORDER BY name desc LIMIT 10";
-        String api = "select * where name = 'a*' and sex = 'male' and age >= 35 or sex = 'female' order by name desc";
-
-        QueryRequest request = new QueryRequest();
-        request.setDbQuery(sqlite);
-        request.getApiQuery().setQuery(api);
-        QueryResponse response = validator.execute(request);
-        Assert.assertTrue(response.toString(), response.result());
-    }
-
-    @Test
-    public void nameBeginswithAndSexEqualAndAgeGreaterthanequalOrSexEqual_sortAddressAscNameDesc() {
-        String sqlite = "SELECT * FROM users WHERE name LIKE 'a%' and sex = 'male' and age >= 35 or sex = 'female' ORDER BY address asc, name desc LIMIT 4";
-        String api = "select * where name = 'a*' and sex = 'male' and age >= 35 or sex = 'female' order by address asc, name desc";
-
-        QueryRequest request = new QueryRequest();
-        request.setDbQuery(sqlite);
-        request.getApiQuery().setQuery(api);
-        QueryResponse response = validator.execute(request);
-        Assert.assertTrue(response.toString(), response.result());
-    }
-
-    @Test
-    public void nameBeginswithAndSexEqualAndAgeGreaterthanequalOrSexEqual_sortAddressAscNameDesc_limitL4() {
-        String sqlite = "SELECT * FROM users WHERE name LIKE 'a%' and sex = 'male' and age >= 35 or sex = 'female' ORDER BY address asc, name desc LIMIT 4";
-        String api = "select * where name = 'a*' and sex = 'male' and age >= 35 or sex = 'female' order by address asc, name desc";
-
-        QueryRequest request = new QueryRequest();
-        request.setDbQuery(sqlite);
-        request.getApiQuery().setQuery(api);
-        QueryResponse response = validator.execute(request);
-        Assert.assertTrue(response.toString(), response.result());
-    }
-
-    @Test
-    public void sexEqual_sortAgeDescExtra1() {
-        String sqlite = "SELECT * FROM users WHERE sex = 'male' ORDER BY age desc LIMIT 10";
-        String api = "select * where sex = 'male' order by age desc";
-
-        QueryRequest request = new QueryRequest();
-        request.setDbQuery(sqlite);
-        request.getApiQuery().setQuery(api);
-        QueryResponse response = validator.execute(request);
-        Assert.assertTrue(response.toString(), response.result());
-    }
-
-    @Test
-    public void sexEqual_sortAgeDescExtra2() {
-        String sqlite = " SELECT * FROM users WHERE sex = 'female' ORDER BY age desc LIMIT 10";
-        String api = "select * where sex = 'female' order by age desc";
-
-        QueryRequest request = new QueryRequest();
-        request.setDbQuery(sqlite);
-        request.getApiQuery().setQuery(api);
-        QueryResponse response = validator.execute(request);
-        Assert.assertTrue(response.toString(), response.result());
-    }
-
-    @Test
-    public void sexEqualAndAgeGreaterthanequal() {
-        String sqlite = " SELECT * FROM users WHERE sex = 'male' and age >= 35 LIMIT 10";
-        String api = "select * where sex = 'male' and age >= 35";
-
-        QueryRequest request = new QueryRequest();
-        request.setDbQuery(sqlite);
-        request.getApiQuery().setQuery(api);
-        QueryResponse response = validator.execute(request);
-        Assert.assertTrue(response.toString(), response.result());
-    }
-
-    @Test
-    public void sexEqualAndAgeGreaterthanequal_sortAgeDesc() {
-        String sqlite = "SELECT * FROM users WHERE sex = 'male' and age >= 35 ORDER BY age desc LIMIT 10";
-        String api = "select * where sex = 'male' and age >= 35 order by age desc";
-
-        QueryRequest request = new QueryRequest();
-        request.setDbQuery(sqlite);
-        request.getApiQuery().setQuery(api);
-        QueryResponse response = validator.execute(request);
-        Assert.assertTrue(response.toString(), response.result());
-    }
-
-    @Test
-    public void sexEqualAndAgeGreaterthanequal_sortNameDesc() {
-        String sqlite = "SELECT * FROM users WHERE sex = 'male' and age >= 35 ORDER BY name desc LIMIT 10";
-        String api = "select * where sex = 'male' and age >= 35 order by name desc";
-
-        QueryRequest request = new QueryRequest();
-        request.setDbQuery(sqlite);
-        request.getApiQuery().setQuery(api);
-        QueryResponse response = validator.execute(request);
-        Assert.assertTrue(response.toString(), response.result());
-    }
-
-    @Test
-    public void sexEqualAndAgeGreaterthanequal_sortAgeDesc_limitL100() {
-        String sqlite = "SELECT * FROM users WHERE sex = 'male' and age >= 35 ORDER BY age desc LIMIT 100";
-        String api = "select * where sex = 'male' and age >= 35 order by age desc";
-        int limit = 100;
-
-        QueryRequest request = new QueryRequest();
-        request.setDbQuery(sqlite);
-        request.getApiQuery().setQuery(api);
-        request.getApiQuery().setLimit(limit);
-        QueryResponse response = validator.execute(request);
-        Assert.assertTrue(response.toString(), response.result());
-    }
-
-    @Test
-    public void qlSexEqualAndAgeGreaterthanequal_sortNameDesc_limitL100() {
-        String sqlite = "SELECT * FROM users WHERE sex = 'male' and age >= 35 ORDER BY name desc LIMIT 100";
-        String api = "select * where sex = 'male' and age >= 35 order by name desc";
-        int limit = 100;
-
-        QueryRequest request = new QueryRequest();
-        request.setDbQuery(sqlite);
-        request.getApiQuery().setQuery(api);
-        request.getApiQuery().setLimit(limit);
-        QueryResponse response = validator.execute(request);
-        Assert.assertTrue(response.toString(), response.result());
-    }
-
-    @Test
-    public void sexEqualAndAgeGreaterthanequalOrSexEqual() {
-        String sqlite = "SELECT * FROM users WHERE sex = 'male' and age >= 35 or sex = 'female' LIMIT 10";
-        String api = "select * where sex = 'male' and age >= 35 or sex = 'female'";
-
-        QueryRequest request = new QueryRequest();
-        request.setDbQuery(sqlite);
-        request.getApiQuery().setQuery(api);
-        QueryResponse response = validator.execute(request);
-        Assert.assertTrue(response.toString(), response.result());
-    }
-
-    @Test
-    public void sexEqualAndAgeGreaterthanequalOrSexEqual_sortAgeDesc() {
-        String sqlite = "SELECT * FROM users WHERE sex = 'male' and age >= 35 or sex = 'female' ORDER BY age desc LIMIT 10";
-        String api = "select * where sex = 'male' and age >= 35 or sex = 'female' order by age desc";
-
-        QueryRequest request = new QueryRequest();
-        request.setDbQuery(sqlite);
-        request.getApiQuery().setQuery(api);
-        QueryResponse response = validator.execute(request);
-        Assert.assertTrue(response.toString(), response.result());
-    }
-
-    @Test
-    public void limitL12() {
-        String sqlite = "SELECT * FROM users LIMIT 12";
-        String api = null;
-        int limit = 12;
-
-        QueryRequest request = new QueryRequest();
-        request.setDbQuery(sqlite);
-        request.getApiQuery().setQuery(api);
-        request.getApiQuery().setLimit(limit);
-        QueryResponse response = validator.execute(request);
-        Assert.assertTrue(response.toString(), response.result());
-    }
-
-    @Test
-    public void sexEqualAndAgeGreaterthanequalOrSexEqual_sortNameDesc() {
-        String sqlite = "SELECT * FROM users WHERE sex = 'male' and age >= 35 or sex = 'female' ORDER BY name desc LIMIT 10";
-        String api = "select * where sex = 'male' and age >= 35 or sex = 'female' order by name desc";
-
-        QueryRequest request = new QueryRequest();
-        request.setDbQuery(sqlite);
-        request.getApiQuery().setQuery(api);
-        QueryResponse response = validator.execute(request);
-        Assert.assertTrue(response.toString(), response.result());
-    }
-
-    @Test
-    public void sexEqualAndAgeGreaterthanequalOrSexEqual_sortNameDesc_limitL100() {
-        String sqlite = "SELECT * FROM users WHERE sex = 'male' and age >= 35 or sex = 'female' ORDER BY name desc LIMIT 100";
-        String api = "select * where sex = 'male' and age >= 35 or sex = 'female' order by name desc";
-        int limit = 100;
-
-        QueryRequest request = new QueryRequest();
-        request.setDbQuery(sqlite);
-        request.getApiQuery().setQuery(api);
-        request.getApiQuery().setLimit(limit);
-        QueryResponse response = validator.execute(request);
-        Assert.assertTrue(response.toString(), response.result());
-    }
-
-    @Test
-    public void limitL11() {
-        String sqlite = "SELECT * FROM users LIMIT 11";
-        String api = null;
-        int limit = 11;
-
-        QueryRequest request = new QueryRequest();
-        request.setDbQuery(sqlite);
-        request.getApiQuery().setQuery(api);
-        request.getApiQuery().setLimit(limit);
-        QueryResponse response = validator.execute(request);
-        Assert.assertTrue(response.toString(), response.result());
-    }
-
-    @Test
-    public void nameBeginswithAndSexEqualAndAgeGreaterthanequalOrSexEqual() {
-        String sqlite = "SELECT * FROM users WHERE name LIKE 'a%' and sex = 'male' and age >= 20 or sex = 'female' LIMIT 10";
-        String api = "select * where name = 'a*' and sex = 'male' and age >= 20 or sex = 'female'";
-
-        QueryRequest request = new QueryRequest();
-        request.setDbQuery(sqlite);
-        request.getApiQuery().setQuery(api);
-        QueryResponse response = validator.execute(request);
-        Assert.assertTrue(response.toString(), response.result());
-    }
-
-    @Test
-    public void nameBeginswithAndSexEqualAndAgeGreaterthanequalOrSexEqual_limitL20() {
-        String sqlite = "SELECT * FROM users WHERE name LIKE 'a%' and sex = 'male' and age >= 20 or sex = 'female' LIMIT 20";
-        String api = "select * where name = 'a*' and sex = 'male' and age >= 20 or sex = 'female'";
-        int limit = 20;
-
-        QueryRequest request = new QueryRequest();
-        request.setDbQuery(sqlite);
-        request.getApiQuery().setQuery(api);
-        request.getApiQuery().setLimit(limit);
-        QueryResponse response = validator.execute(request);
-        Assert.assertTrue(response.toString(), response.result());
-    }
-
-    @Test
-    public void sexEqualAndAgeGreaterthanequal_sortAddressDesc_limitL100() {
-        String sqlite = "SELECT * FROM users WHERE sex = 'male' and age >= 35 ORDER BY address desc LIMIT 100";
-        String api = "select * where sex = 'male' and age >= 35 order by address desc";
-        int limit = 100;
-
-        QueryRequest request = new QueryRequest();
-        request.setDbQuery(sqlite);
-        request.getApiQuery().setQuery(api);
-        request.getApiQuery().setLimit(limit);
-        QueryResponse response = validator.execute(request);
-        Assert.assertTrue(response.toString(), response.result());
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/59af2a47/stack/query-validator/src/test/java/org/apache/usergrid/query/validator/QueryValidatorRunner.java
----------------------------------------------------------------------
diff --git a/stack/query-validator/src/test/java/org/apache/usergrid/query/validator/QueryValidatorRunner.java b/stack/query-validator/src/test/java/org/apache/usergrid/query/validator/QueryValidatorRunner.java
deleted file mode 100644
index 7e8143b..0000000
--- a/stack/query-validator/src/test/java/org/apache/usergrid/query/validator/QueryValidatorRunner.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*******************************************************************************
- * Copyright 2013 baas.io
- *
- * Licensed 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.query.validator;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang.StringUtils;
-import org.junit.runner.notification.RunNotifier;
-import org.junit.runners.model.InitializationError;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.usergrid.cassandra.DataControl;
-import org.apache.usergrid.persistence.Entity;
-import org.apache.usergrid.utils.JsonUtils;
-
-import java.io.IOException;
-import java.net.URL;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import org.apache.usergrid.launcher.Server;
-import org.apache.usergrid.management.ManagementService;
-
-/**
- * @author Sung-ju Jin(realbeast)
- */
-public class QueryValidatorRunner extends CassandraRunner {
-
-    private static Logger logger = LoggerFactory.getLogger(QueryValidatorRunner.class);
-    private boolean enableLocalServer;
-    private static StandaloneServer standaloneServer;
-    private Properties properties;
-    private static QueryValidator validator;
-    private static boolean initialize = false;
-
-    public QueryValidatorRunner(Class<?> klass) throws InitializationError {
-        super(klass);
-    }
-
-    @Override
-    protected DataControl preTest(RunNotifier notifier) {
-        DataControl control = super.preTest(notifier);
-        try {
-            setup();
-        } catch (InitializationError initializationError) {
-            initializationError.printStackTrace();
-        }
-        return control;
-    }
-
-    public static QueryValidator getValidator() {
-        return validator;
-    }
-
-    public synchronized void setup() throws InitializationError {
-        if(initialize)
-            return;
-
-        try {
-            logger.info("Loading initialize...");
-            Thread.sleep(20*1000);
-        } catch (InterruptedException e) {}
-
-        validator = CassandraRunner.getBean(QueryValidator.class);
-        properties = CassandraRunner.getBean("properties",Properties.class);
-
-        if( validator == null || properties == null) {
-            throw new InitializationError("Application context not loaded.");
-        }
-
-        String enableString = (String)properties.get("usergrid.query.validator.api.enablelocal");
-        enableLocalServer = StringUtils.endsWithIgnoreCase("true", enableString);
-        if( enableLocalServer ) {
-            startStandaloneServer();
-            try {
-                logger.info("Loading standalone server...");
-                Thread.sleep(20*1000);
-            } catch (InterruptedException e) {}
-        }
-        initialize = true;
-
-        String endpoint = (String)properties.get("usergrid.query.validator.api.endpoint");
-        String organization = (String)properties.get("usergrid.query.validator.api.organization");
-        String app = (String)properties.get("usergrid.query.validator.api.app");
-        String email = (String)properties.get("usergrid.query.validator.api.authorize.email");
-        String password = (String)properties.get("usergrid.query.validator.api.authorize.password");
-
-        String collection = "user";
-        List<Entity> entities = loadEntities(collection);
-        QueryValidationConfiguration configuration = new QueryValidationConfiguration();
-        configuration.setEndpointUri(endpoint);
-        configuration.setOrg(organization);
-        configuration.setEmail(email);
-        configuration.setPassword(password);
-        configuration.setApp(app);
-        configuration.setCollection(collection);
-        configuration.setEntities(entities);
-        validator.setConfiguration(configuration);
-        validator.setup();
-
-    }
-
-    private List<Entity> loadEntities(String collection) {
-        String json = null;
-        try {
-            URL url = Thread.currentThread().getContextClassLoader().getResource(collection + ".json");
-            json = FileUtils.readFileToString(FileUtils.toFile(url), Charset.forName("UTF-8"));
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-
-        List<Entity> entities = new ArrayList<Entity>();
-        List<Map<String, Object>> datas = (List<Map<String, Object>>) JsonUtils.parse(json);
-        for(Map<String, Object> data : datas) {
-            Entity entity = new QueryEntity();
-            entity.setType(collection);
-            entity.setProperties(data);
-            entity.setCreated(System.currentTimeMillis());
-            entity.setModified(entity.getCreated());
-            entities.add(entity);
-        }
-        return entities;
-    }
-
-    private void startStandaloneServer() {
-        standaloneServer = new StandaloneServer();
-        try {
-            Thread thread = new Thread(standaloneServer);
-            thread.start();
-        } catch (Exception ex) {
-            logger.error("Could not schedule standalone server runner", ex);
-        }
-        Runtime.getRuntime().addShutdownHook(new Thread() {
-            @Override
-            public void run() {
-                try {
-                    logger.error("In shutdownHook");
-                    stopServer();
-                } catch (Exception ex) {
-                    ex.printStackTrace();
-                }
-            }
-        });
-        boolean loaded = false;
-        while (!loaded) {
-            if( standaloneServer.server.isRunning() ) {
-                if( standaloneServer.server.getManagementService() != null ) {
-                    loaded = true;
-                    continue;
-                }
-            }
-            try {
-                logger.info("Loding application context...");
-                Thread.sleep(2*1000);
-            } catch (InterruptedException e) {
-                continue;
-            }
-        }
-
-        if(loaded) {
-            ManagementService managementService = standaloneServer.server.getManagementService();
-            try {
-                managementService.setup();
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
-        }
-
-        logger.info("Finish start standalone server.");
-    }
-
-    static class StandaloneServer implements Runnable {
-        public static Server server;
-
-        public StandaloneServer() {
-            server = new Server();
-        }
-
-        @Override
-        public void run() {
-            server.setInitializeDatabaseOnStart(true);
-            server.setDaemon(false);
-            server.startServer();
-        }
-
-        public void stop() {
-            server.stopServer();
-        }
-    }
-
-    private void stopServer() {
-        standaloneServer.stop();
-    }
-}


Mime
View raw message