You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2014/02/14 16:20:40 UTC
[1/7] Fixing query-validator
Updated Branches:
refs/heads/master c5b43cf12 -> 459472a3c
refs/heads/two-dot-o 185cebe30 -> c5fbce67e
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/59af2a47/stack/query-validator/src/test/java/org/apache/usergrid/query/validator/users/UserQueryIT.java
----------------------------------------------------------------------
diff --git a/stack/query-validator/src/test/java/org/apache/usergrid/query/validator/users/UserQueryIT.java b/stack/query-validator/src/test/java/org/apache/usergrid/query/validator/users/UserQueryIT.java
new file mode 100644
index 0000000..bf76c8a
--- /dev/null
+++ b/stack/query-validator/src/test/java/org/apache/usergrid/query/validator/users/UserQueryIT.java
@@ -0,0 +1,877 @@
+/**
+ * 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.users;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.apache.usergrid.persistence.Entity;
+import org.apache.usergrid.query.validator.AbstractQueryIT;
+import org.apache.usergrid.query.validator.QueryRequest;
+import org.apache.usergrid.query.validator.QueryResponse;
+import org.apache.usergrid.query.validator.QueryResultsMatcher;
+import org.apache.usergrid.utils.StringUtils;
+
+import java.util.List;
+
+/**
+ * @author Sungju Jin
+ */
+public class UserQueryIT extends AbstractQueryIT {
+
+ @BeforeClass
+ public static void setDatas() {
+ createInitializationDatas("user");
+ }
+
+ @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);
+ request.getApiQuery().setLimit(4);
+ 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);
+ request.getApiQuery().setLimit(4);
+ 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, new QueryResultsMatcher() {
+ @Override
+ public boolean equals(List<Entity> expectedEntities, List<Entity> actuallyEntities) {
+ boolean equals = expectedEntities.size() == expectedEntities.size();
+ if( !equals )
+ return false;
+
+ for(Entity entity : actuallyEntities) {
+ String sex = (String)entity.getProperty("sex");
+
+ if((StringUtils.equals("male",sex)) == false) {
+ return false;
+ }
+ }
+ return equals;
+ }
+ });
+ 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_limitL20() {
+ String sqlite = "SELECT * FROM users WHERE sex = 'male' and age >= 35 ORDER BY age desc LIMIT 20";
+ String api = "select * where sex = 'male' and age >= 35 order by age desc";
+ 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 qlSexEqualAndAgeGreaterthanequal_sortNameDesc_limitL20() {
+ String sqlite = "SELECT * FROM users WHERE sex = 'male' and age >= 35 ORDER BY name desc LIMIT 20";
+ String api = "select * where sex = 'male' and age >= 35 order by name desc";
+ 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 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, new QueryResultsMatcher() {
+ @Override
+ public boolean equals(List<Entity> expectedEntities, List<Entity> actuallyEntities) {
+ boolean equals = expectedEntities.size() == expectedEntities.size();
+ if( !equals )
+ return false;
+
+ for(Entity entity : actuallyEntities) {
+ int age = (Integer)entity.getProperty("age");
+ String sex = (String)entity.getProperty("sex");
+
+ if(((StringUtils.equals("male",sex) && age >= 35) || StringUtils.equals("female",sex)) == false) {
+ return false;
+ }
+ }
+ return equals;
+ }
+ });
+ 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_limitL20() {
+ String sqlite = "SELECT * FROM users WHERE sex = 'male' and age >= 35 or sex = 'female' ORDER BY name desc LIMIT 20";
+ String api = "select * where sex = 'male' and age >= 35 or sex = 'female' order by name desc";
+ 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 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());
+ }
+
+ @Test
+ public void qlNameEqual() {
+ String sqlite = "SELECT * FROM users WHERE name = 'judekim' LIMIT 10";
+ String api = "select * where 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 qlAgeEqual() {
+ String sqlite = "SELECT * FROM users WHERE age = 16 LIMIT 10";
+ String api = "select * where age = 16";
+
+ 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 qlNameEqualAndAgeEqual() {
+ String sqlite = "SELECT * FROM users WHERE name = 'askagirl' and age = 16 LIMIT 10";
+ String api = "select * where name = 'askagirl' and age = 16";
+
+ QueryRequest request = new QueryRequest();
+ request.setDbQuery(sqlite);
+ request.getApiQuery().setQuery(api);
+ QueryResponse response = validator.execute(request, new QueryResultsMatcher() {
+ @Override
+ public boolean equals(List<Entity> expectedEntities, List<Entity> actuallyEntities) {
+ boolean equals = expectedEntities.size() == expectedEntities.size();
+ if( !equals )
+ return false;
+
+ for(Entity entity : actuallyEntities) {
+ String name = entity.getName();
+ int age = (Integer)entity.getProperty("age");
+ if ((StringUtils.equals("askagirl", name) && age == 16) == false) {
+ return false;
+ }
+ }
+ return equals;
+ }
+ });
+ Assert.assertTrue(response.toString(), response.result());
+ }
+
+ @Test
+ public void qlAgeLessthan() {
+ String sqlite = "SELECT * FROM users WHERE age < 16 LIMIT 10";
+ String api = "select * where age < 16";
+
+ QueryRequest request = new QueryRequest();
+ request.setDbQuery(sqlite);
+ request.getApiQuery().setQuery(api);
+ QueryResponse response = validator.execute(request, new QueryResultsMatcher() {
+ @Override
+ public boolean equals(List<Entity> expectedEntities, List<Entity> actuallyEntities) {
+ boolean equals = expectedEntities.size() == expectedEntities.size();
+ if( !equals )
+ return false;
+
+ for(Entity entity : actuallyEntities) {
+ int age = (Integer)entity.getProperty("age");
+ if((age < 16) == false) {
+ return false;
+ }
+ }
+ return equals;
+ }
+ });
+ Assert.assertTrue(response.toString(), response.result());
+ }
+
+ @Test
+ public void qlAgeLessthanequal() {
+ String sqlite = "SELECT * FROM users WHERE age <= 16 LIMIT 20";
+ String api = "select * where age <= 16";
+ int limit = 20;
+
+ QueryRequest request = new QueryRequest();
+ request.setDbQuery(sqlite);
+ request.getApiQuery().setQuery(api);
+ request.getApiQuery().setLimit(limit);
+ QueryResponse response = validator.execute(request, new QueryResultsMatcher() {
+ @Override
+ public boolean equals(List<Entity> expectedEntities, List<Entity> actuallyEntities) {
+ boolean equals = expectedEntities.size() == expectedEntities.size();
+ if( !equals )
+ return false;
+
+ for(Entity entity : actuallyEntities) {
+ int age = (Integer)entity.getProperty("age");
+ if((age <= 16) == false) {
+ return false;
+ }
+ }
+ return equals;
+ }
+ });
+ Assert.assertTrue(response.toString(), response.result());
+ }
+
+ @Test
+ public void qlAgeGreaterthan() {
+ String sqlite = "SELECT * FROM users WHERE age > 16 LIMIT 10";
+ String api = "select * where age > 16";
+
+ QueryRequest request = new QueryRequest();
+ request.setDbQuery(sqlite);
+ request.getApiQuery().setQuery(api);
+ QueryResponse response = validator.execute(request, new QueryResultsMatcher() {
+ @Override
+ public boolean equals(List<Entity> expectedEntities, List<Entity> actuallyEntities) {
+ boolean equals = expectedEntities.size() == expectedEntities.size();
+ if( !equals )
+ return false;
+
+ for(Entity entity : actuallyEntities) {
+ int age = (Integer)entity.getProperty("age");
+ if((age > 16) == false) {
+ return false;
+ }
+ }
+ return equals;
+ }
+ });
+ Assert.assertTrue(response.toString(), response.result());
+ }
+
+ @Test
+ public void qlAgeGreaterthanequal() {
+ String sqlite = "SELECT * FROM users WHERE age >= 16 LIMIT 10";
+ String api = "select * where age >= 16";
+
+ QueryRequest request = new QueryRequest();
+ request.setDbQuery(sqlite);
+ request.getApiQuery().setQuery(api);
+ QueryResponse response = validator.execute(request, new QueryResultsMatcher() {
+ @Override
+ public boolean equals(List<Entity> expectedEntities, List<Entity> actuallyEntities) {
+ boolean equals = expectedEntities.size() == expectedEntities.size();
+ if( !equals )
+ return false;
+
+ for(Entity entity : actuallyEntities) {
+ int age = (Integer)entity.getProperty("age");
+ if((age >= 16) == false) {
+ return false;
+ }
+ }
+ return equals;
+ }
+ });
+ Assert.assertTrue(response.toString(), response.result());
+ }
+
+ @Test
+ public void qlAgeGreaterthanequalAndAgeLessthan() {
+ String sqlite = "SELECT * FROM users WHERE age >= 32 and age < 40 LIMIT 10";
+ String api = "select * where age >= 32 and age < 40";
+
+ QueryRequest request = new QueryRequest();
+ request.setDbQuery(sqlite);
+ request.getApiQuery().setQuery(api);
+ QueryResponse response = validator.execute(request, new QueryResultsMatcher() {
+ @Override
+ public boolean equals(List<Entity> expectedEntities, List<Entity> actuallyEntities) {
+ boolean equals = expectedEntities.size() == expectedEntities.size();
+ if( !equals )
+ return false;
+
+ for(Entity entity : actuallyEntities) {
+ int age = (Integer)entity.getProperty("age");
+ if((age >= 32 && age < 40) == false) {
+ return false;
+ }
+ }
+ return equals;
+ }
+ });
+ Assert.assertTrue(response.toString(), response.result());
+ }
+
+ @Test
+ public void qlAgeGreaterthanequalAndAgeLessthanAndSexEqual() {
+ String sqlite = "SELECT * FROM users WHERE age >= 32 and age < 40 and sex = 'female' LIMIT 10";
+ String api = "select * where age >= 32 and age < 40 and sex = 'female'";
+
+ QueryRequest request = new QueryRequest();
+ request.setDbQuery(sqlite);
+ request.getApiQuery().setQuery(api);
+ QueryResponse response = validator.execute(request, new QueryResultsMatcher() {
+ @Override
+ public boolean equals(List<Entity> expectedEntities, List<Entity> actuallyEntities) {
+ boolean equals = expectedEntities.size() == expectedEntities.size();
+ if( !equals )
+ return false;
+
+ for(Entity entity : actuallyEntities) {
+ int age = (Integer)entity.getProperty("age");
+ String sex = (String)entity.getProperty("sex");
+
+ if((age >= 32 && age < 40 && StringUtils.equals("female",sex)) == false) {
+ return false;
+ }
+ }
+ return equals;
+ }
+ });
+ Assert.assertTrue(response.toString(), response.result());
+ }
+
+ @Test
+ public void qlAddressFulltext() {
+ String sqlite = "SELECT * FROM users WHERE address LIKE '%서울시%' LIMIT 10";
+ String api = "select * where address contains '서울시'";
+
+ QueryRequest request = new QueryRequest();
+ request.setDbQuery(sqlite);
+ request.getApiQuery().setQuery(api);
+ QueryResponse response = validator.execute(request, new QueryResultsMatcher() {
+ @Override
+ public boolean equals(List<Entity> expectedEntities, List<Entity> actuallyEntities) {
+ boolean equals = expectedEntities.size() == expectedEntities.size();
+ if( !equals )
+ return false;
+
+ for(Entity entity : actuallyEntities) {
+ String address = (String)entity.getProperty("address");
+
+ if((StringUtils.contains(address,"서울시")) == false) {
+ return false;
+ }
+ }
+ return equals;
+ }
+ });
+ Assert.assertTrue(response.toString(), response.result());
+ }
+
+ @Test
+ public void qlAddressFulltextstartswith() {
+ String sqlite = " SELECT * FROM users WHERE address LIKE 'A%' LIMIT 10";
+ String api = "select * where address contains 'A*'";
+
+ QueryRequest request = new QueryRequest();
+ request.setDbQuery(sqlite);
+ request.getApiQuery().setQuery(api);
+ QueryResponse response = validator.execute(request, new QueryResultsMatcher() {
+ @Override
+ public boolean equals(List<Entity> expectedEntities, List<Entity> actuallyEntities) {
+ boolean equals = expectedEntities.size() == expectedEntities.size();
+ if( !equals )
+ return false;
+
+ for(Entity entity : actuallyEntities) {
+ String address = (String)entity.getProperty("address");
+
+ if((StringUtils.startsWith(address,"A")) == false) {
+ return false;
+ }
+ }
+ return equals;
+ }
+ });
+ Assert.assertTrue(response.toString(), response.result());
+ }
+
+ @Test
+ public void qlAddressBeginswith() {
+ String sqlite = "SELECT * FROM users WHERE address LIKE 'B%' LIMIT 10";
+ String api = "select * where address = 'B*'";
+
+ QueryRequest request = new QueryRequest();
+ request.setDbQuery(sqlite);
+ request.getApiQuery().setQuery(api);
+ QueryResponse response = validator.execute(request, new QueryResultsMatcher() {
+ @Override
+ public boolean equals(List<Entity> expectedEntities, List<Entity> actuallyEntities) {
+ boolean equals = expectedEntities.size() == expectedEntities.size();
+ if( !equals )
+ return false;
+
+ for(Entity entity : actuallyEntities) {
+ String address = (String)entity.getProperty("address");
+
+ if((StringUtils.startsWith(address,"B")) == false) {
+ return false;
+ }
+ }
+ return equals;
+ }
+ });
+ Assert.assertTrue(response.toString(), response.result());
+ }
+
+ @Test
+ public void qlAddressBeginswithAndSexFulltextstartswith() {
+ String sqlite = "SELECT * FROM users WHERE address LIKE 'C%' and sex LIKE 'ma%' LIMIT 10";
+ String api = "select * where address = 'C*' and sex contains 'ma*'";
+
+ QueryRequest request = new QueryRequest();
+ request.setDbQuery(sqlite);
+ request.getApiQuery().setQuery(api);
+ QueryResponse response = validator.execute(request, new QueryResultsMatcher() {
+ @Override
+ public boolean equals(List<Entity> expectedEntities, List<Entity> actuallyEntities) {
+ boolean equals = expectedEntities.size() == expectedEntities.size();
+ if( !equals )
+ return false;
+
+ for(Entity entity : actuallyEntities) {
+ String address = (String)entity.getProperty("address");
+
+ if((StringUtils.startsWith(address,"C")) == false) {
+ return false;
+ }
+ }
+ return equals;
+ }
+ });
+ Assert.assertTrue(response.toString(), response.result());
+ }
+
+ @Test
+ public void qlAddressBeginswithAndSexFulltext() {
+ String sqlite = "SELECT * FROM users WHERE (address LIKE 'D%' and sex LIKE '%male%') LIMIT 10";
+ String api = "select * where address = 'D*' and sex contains 'male'";
+
+ QueryRequest request = new QueryRequest();
+ request.setDbQuery(sqlite);
+ request.getApiQuery().setQuery(api);
+ QueryResponse response = validator.execute(request, new QueryResultsMatcher() {
+ @Override
+ public boolean equals(List<Entity> expectedEntities, List<Entity> actuallyEntities) {
+ boolean equals = expectedEntities.size() == expectedEntities.size();
+ if( !equals )
+ return false;
+
+ for(Entity entity : actuallyEntities) {
+ String address = (String)entity.getProperty("address");
+
+ if((StringUtils.startsWith(address,"D")) == false) {
+ return false;
+ }
+ }
+ return equals;
+ }
+ });
+ Assert.assertTrue(response.toString(), response.result());
+ }
+
+ @Test
+ public void qlSexEqualOrAgeGreaterthanequalAndAgeLessthan_limitL20() {
+ String sqlite = "SELECT * FROM users WHERE sex = 'female' or age >= 12 and age < 20 LIMIT 20";
+ String api = "select * where sex = 'female' or age >= 12 and age < 20";
+ int limit = 20;
+
+ QueryRequest request = new QueryRequest();
+ request.setDbQuery(sqlite);
+ request.getApiQuery().setQuery(api);
+ request.getApiQuery().setLimit(limit);
+ QueryResponse response = validator.execute(request, new QueryResultsMatcher() {
+ @Override
+ public boolean equals(List<Entity> expectedEntities, List<Entity> actuallyEntities) {
+ boolean equals = expectedEntities.size() == expectedEntities.size();
+ if( !equals )
+ return false;
+
+ for(Entity entity : actuallyEntities) {
+ int age = (Integer)entity.getProperty("age");
+ String sex = (String)entity.getProperty("sex");
+
+ if(((StringUtils.equals("female",sex) || age >= 12) && age < 20) == false) {
+ return false;
+ }
+ }
+ return equals;
+ }
+ });
+ Assert.assertTrue(response.toString(), response.result());
+ }
+
+ @Test
+ public void sortNameAsc() {
+ String sqlite = "SELECT * FROM users ORDER BY name asc LIMIT 10";
+ String api = "select * order by name asc";
+
+ 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 sortNameDesc() {
+ String sqlite = "SELECT * FROM users ORDER BY name desc LIMIT 10";
+ String api = "select * 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 sortNameAscAgeDesc() {
+ String sqlite = "SELECT * FROM users ORDER BY name asc, age desc LIMIT 10";
+ String api = "select * order by name asc, 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 sortNameAscAddressAsc() {
+ String sqlite = "SELECT * FROM users ORDER BY name asc, address asc LIMIT 10";
+ String api = "select * order by name asc, address asc";
+
+ 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 sortCreatedAsc() {
+ String sqlite = "SELECT * FROM users ORDER BY created asc LIMIT 10";
+ String api = "select * order by created asc";
+
+ 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 sortCreatedDesc() {
+ String sqlite = "SELECT * FROM users ORDER BY created desc LIMIT 10";
+ String api = "select * order by created 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 sortModifiedAsc() {
+ String sqlite = "SELECT * FROM users ORDER BY modified asc LIMIT 10";
+ String api = "select * order by modified asc";
+
+ 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 sortCreatedDescNameAsc() {
+ String sqlite = "SELECT * FROM users ORDER BY created desc, name asc LIMIT 10";
+ String api = "select * order by created desc, name asc";
+
+ 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 sortNameAscCreatedDesc() {
+ String sqlite = "SELECT * FROM users ORDER BY name asc, created desc LIMIT 10";
+ String api = "select * order by name asc, created desc";
+
+ QueryRequest request = new QueryRequest();
+ request.setDbQuery(sqlite);
+ request.getApiQuery().setQuery(api);
+ QueryResponse response = validator.execute(request);
+ Assert.assertTrue(response.toString(), response.result());
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/59af2a47/stack/query-validator/src/test/resources/project.properties
----------------------------------------------------------------------
diff --git a/stack/query-validator/src/test/resources/project.properties b/stack/query-validator/src/test/resources/project.properties
new file mode 100644
index 0000000..c0bf364
--- /dev/null
+++ b/stack/query-validator/src/test/resources/project.properties
@@ -0,0 +1 @@
+target.directory=${project.build.directory}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/59af2a47/stack/query-validator/src/test/resources/user.json
----------------------------------------------------------------------
diff --git a/stack/query-validator/src/test/resources/user.json b/stack/query-validator/src/test/resources/user.json
index b1dbc80..19beef1 100644
--- a/stack/query-validator/src/test/resources/user.json
+++ b/stack/query-validator/src/test/resources/user.json
@@ -10,14 +10,14 @@
"name":"zoozooz",
"username":"zoozooz",
"address":"서울시 관악구 봉천동",
- "age":16,
+ "age":76,
"sex":"male"
},
{
"name":"r2fresh",
"username":"r2fresh",
"address":"경기도 고양시 일산",
- "age":16,
+ "age":36,
"sex":"male"
},
{
@@ -38,14 +38,14 @@
"name":"izakaya",
"username":"izakaya",
"address":"인천광역시 어디어디",
- "age":16,
+ "age":28,
"sex":"male"
},
{
"name":"aksagirl",
"username":"aksagirl",
"address":"부산광역시 어딘가",
- "age":16,
+ "age":26,
"sex":"male"
},
{
@@ -70,13 +70,6 @@
"sex":"male"
},
{
- "name":"akaia75",
- "username":"akaia75",
- "address":"서울시 구로구",
- "age":13,
- "sex":"male"
- },
- {
"name":"curioe",
"username":"curioe",
"address":"서울시 어디인가",
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/59af2a47/stack/query-validator/src/test/resources/usergrid-custom-test.properties
----------------------------------------------------------------------
diff --git a/stack/query-validator/src/test/resources/usergrid-custom-test.properties b/stack/query-validator/src/test/resources/usergrid-custom-test.properties
index 39050d9..6ba10b0 100644
--- a/stack/query-validator/src/test/resources/usergrid-custom-test.properties
+++ b/stack/query-validator/src/test/resources/usergrid-custom-test.properties
@@ -1,6 +1,13 @@
usergrid.query.validator.api.enablelocal=true
-usergrid.query.validator.api.endpoint=http://localhost:8080
+usergrid.query.validator.api.endpoint=http://localhost
+usergrid.query.validator.api.endpoint.port=8080
usergrid.query.validator.api.organization=test-organization
usergrid.query.validator.api.app=test-app
-usergrid.query.validator.api.authorize.email=test@usergrid.com
-usergrid.query.validator.api.authorize.password=test
\ No newline at end of file
+usergrid.query.validator.api.authorize.email=test22
+usergrid.query.validator.api.authorize.password=test
+
+# SysAdmin login
+usergrid.sysadmin.login.name=superuser
+usergrid.sysadmin.login.email=superuser@usergrid.com
+usergrid.sysadmin.login.password=superpassword
+usergrid.sysadmin.login.allowed=true
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/59af2a47/stack/query-validator/src/test/resources/usergrid-test-context.xml
----------------------------------------------------------------------
diff --git a/stack/query-validator/src/test/resources/usergrid-test-context.xml b/stack/query-validator/src/test/resources/usergrid-test-context.xml
index 5df1815..d1f50e5 100644
--- a/stack/query-validator/src/test/resources/usergrid-test-context.xml
+++ b/stack/query-validator/src/test/resources/usergrid-test-context.xml
@@ -1,8 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
+ xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
+ http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<bean id="properties"
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
@@ -12,12 +15,20 @@
<list>
<value>classpath:/usergrid-default.properties</value>
<value>classpath:/usergrid-test.properties</value>
- <value>${usergrid-custom-spring-test-properties}</value>
+ <value>classpath:/usergrid-custom-test.properties</value>
</list>
</property>
</bean>
- <import resource="classpath:/usergrid-query-validator-context.xml" />
+ <import resource="usergrid-rest-context.xml"/>
+
+ <bean id="traceTagManager" class="org.apache.usergrid.persistence.cassandra.util.TraceTagManager">
+ <property name="reportUnattached" value="false"/>
+ <property name="traceEnabled" value="false"/>
+ </bean>
+
+
+ <bean id="binaryStore" class="org.apache.usergrid.services.assets.data.LocalFileBinaryStore"/>
<bean id="setup" class="org.apache.usergrid.persistence.cassandra.Setup">
<constructor-arg ref="entityManagerFactory"/>
@@ -30,5 +41,6 @@
<constructor-arg ref="cassandraCluster"/>
</bean>
+ <import resource="usergrid-query-validator-context.xml"/>
</beans>
[4/7] git commit: Simple port finder test
Posted by sn...@apache.org.
Simple port finder test
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/175ddf4e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/175ddf4e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/175ddf4e
Branch: refs/heads/two-dot-o
Commit: 175ddf4e8296df4785e7fb215b71f0b0373fb4b5
Parents: 03e7bc4
Author: Dave Johnson <dm...@apigee.com>
Authored: Fri Feb 14 09:29:23 2014 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Fri Feb 14 09:29:23 2014 -0500
----------------------------------------------------------------------
.../cassandra/AvailablePortFinder.java | 1 -
.../cassandra/AvailablePortFinderTest.java | 73 ++++++++++++++++++++
2 files changed, 73 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/175ddf4e/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/cassandra/AvailablePortFinder.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/cassandra/AvailablePortFinder.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/cassandra/AvailablePortFinder.java
index f18d728..ebc32dc 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/cassandra/AvailablePortFinder.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/cassandra/AvailablePortFinder.java
@@ -15,7 +15,6 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *
*/
package org.apache.usergrid.persistence.collection.cassandra;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/175ddf4e/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/cassandra/AvailablePortFinderTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/cassandra/AvailablePortFinderTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/cassandra/AvailablePortFinderTest.java
new file mode 100644
index 0000000..24e4708
--- /dev/null
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/cassandra/AvailablePortFinderTest.java
@@ -0,0 +1,73 @@
+/*
+ * 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.persistence.collection.cassandra;
+
+import java.util.Set;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+public class AvailablePortFinderTest {
+
+ /**
+ * Test of getAvailablePorts method, of class AvailablePortFinder.
+ */
+ @Test
+ public void testGetAvailablePorts_0args() {
+ Set<Integer> result = AvailablePortFinder.getAvailablePorts();
+ assertTrue( !result.isEmpty() );
+ }
+
+ /**
+ * Test of getNextAvailable method, of class AvailablePortFinder.
+ */
+ @Test
+ public void testGetNextAvailable_0args() {
+ int result = AvailablePortFinder.getNextAvailable();
+ assertTrue( result > 0 );
+ }
+
+ /**
+ * Test of getNextAvailable method, of class AvailablePortFinder.
+ */
+ @Test
+ public void testGetNextAvailable_int() {
+ int result = AvailablePortFinder.getNextAvailable( 2000 );
+ assertTrue( result > 2000 );
+ }
+
+ /**
+ * Test of available method, of class AvailablePortFinder.
+ */
+ @Test
+ public void testAvailable() {
+ int port = AvailablePortFinder.getNextAvailable();
+ boolean result = AvailablePortFinder.available( port );
+ assertTrue( result );
+ }
+
+ /**
+ * Test of getAvailablePorts method, of class AvailablePortFinder.
+ */
+ @Test
+ public void testGetAvailablePorts_int_int() {
+ Set<Integer> result = AvailablePortFinder.getAvailablePorts( 1000, 2000 );
+ assertTrue( !result.isEmpty() );
+ }
+
+}
[2/7] git commit: Fixing query-validator
Posted by sn...@apache.org.
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/heads/master
Commit: 59af2a4766168a6a7a9814029cbcc2b546ebc271
Parents: c5b43cf
Author: Sungju Jin <su...@softwaregeeks.org>
Authored: Fri Feb 14 23:26:39 2014 +0900
Committer: Sungju Jin <su...@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();
- }
-}
[7/7] git commit: Enable query-validator module
Posted by sn...@apache.org.
Enable query-validator module
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/459472a3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/459472a3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/459472a3
Branch: refs/heads/master
Commit: 459472a3cc708c03c1b6935e32af1f78ab0fd8b7
Parents: 9b45171
Author: Sungju Jin <su...@softwaregeeks.org>
Authored: Fri Feb 14 23:53:18 2014 +0900
Committer: Sungju Jin <su...@softwaregeeks.org>
Committed: Fri Feb 14 23:53:18 2014 +0900
----------------------------------------------------------------------
stack/pom.xml | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/459472a3/stack/pom.xml
----------------------------------------------------------------------
diff --git a/stack/pom.xml b/stack/pom.xml
index 52dbaa8..e5f6db9 100644
--- a/stack/pom.xml
+++ b/stack/pom.xml
@@ -177,6 +177,7 @@
<module>rest</module>
<module>launcher</module>
<module>test-utils</module>
+ <module>query-validator</module>
<module>build-tools</module>
</modules>
[3/7] git commit: Support Java7 on Mac
Posted by sn...@apache.org.
Support Java7 on Mac
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/524defb6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/524defb6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/524defb6
Branch: refs/heads/master
Commit: 524defb680f3d0d9e3ed9c3ba3c066ca8e777157
Parents: 59af2a4
Author: Sungju Jin <su...@softwaregeeks.org>
Authored: Tue Jan 21 21:26:27 2014 +0900
Committer: Sungju Jin <su...@softwaregeeks.org>
Committed: Fri Feb 14 23:28:49 2014 +0900
----------------------------------------------------------------------
stack/rest/pom.xml | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/524defb6/stack/rest/pom.xml
----------------------------------------------------------------------
diff --git a/stack/rest/pom.xml b/stack/rest/pom.xml
index 901b009..bedd4bc 100644
--- a/stack/rest/pom.xml
+++ b/stack/rest/pom.xml
@@ -271,9 +271,9 @@
</plugin>
<plugin>
- <groupId>org.codehaus.mojo.jspc</groupId>
+ <groupId>org.jasig.mojo.jspc</groupId>
<artifactId>jspc-maven-plugin</artifactId>
- <version>2.0-alpha-3</version>
+ <version>2.0.0</version>
<configuration>
<includeInProject>false</includeInProject>
<webFragmentFile>${project.build.directory}/web-fragment.xml.txt</webFragmentFile>
@@ -288,9 +288,9 @@
</executions>
<dependencies>
<dependency>
- <groupId>org.codehaus.mojo.jspc</groupId>
+ <groupId>org.jasig.mojo.jspc</groupId>
<artifactId>jspc-compiler-tomcat6</artifactId>
- <version>2.0-alpha-3</version>
+ <version>2.0.0</version>
</dependency>
</dependencies>
</plugin>
[5/7] git commit: Merge branch 'two-dot-o' of
https://github.com/usergrid/usergrid into two-dot-o
Posted by sn...@apache.org.
Merge branch 'two-dot-o' of https://github.com/usergrid/usergrid into two-dot-o
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/c5fbce67
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/c5fbce67
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/c5fbce67
Branch: refs/heads/two-dot-o
Commit: c5fbce67e2130076f9def4f93f36b7b885aab3cf
Parents: 175ddf4 185cebe
Author: Dave Johnson <dm...@apigee.com>
Authored: Fri Feb 14 09:29:28 2014 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Fri Feb 14 09:29:28 2014 -0500
----------------------------------------------------------------------
stack/pom.xml | 1 +
stack/query-validator/pom.xml | 205 +++++++----
.../query/validator/CassandraRunner.java | 199 -----------
.../usergrid/query/validator/QueryITSuite.java | 3 +-
.../query/validator/QueryValidationTest.java | 339 -------------------
.../query/validator/QueryValidatorRunner.java | 208 ------------
.../java/org/apache/usergrid/rest/ITSetup.java | 10 +-
7 files changed, 140 insertions(+), 825 deletions(-)
----------------------------------------------------------------------
[6/7] git commit: Extending TomcatResource
Posted by sn...@apache.org.
Extending TomcatResource
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/9b451716
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/9b451716
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/9b451716
Branch: refs/heads/master
Commit: 9b4517161f7217bd4702a7d3d497b56163b9d72d
Parents: 524defb
Author: Sungju Jin <su...@softwaregeeks.org>
Authored: Thu Jan 16 22:52:54 2014 +0900
Committer: Sungju Jin <su...@softwaregeeks.org>
Committed: Fri Feb 14 23:46:52 2014 +0900
----------------------------------------------------------------------
.../java/org/apache/usergrid/rest/ITSetup.java | 8 +++++--
.../apache/usergrid/rest/TomcatResource.java | 25 ++++++++------------
2 files changed, 16 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9b451716/stack/rest/src/test/java/org/apache/usergrid/rest/ITSetup.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/ITSetup.java b/stack/rest/src/test/java/org/apache/usergrid/rest/ITSetup.java
index 626c175..6356225 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/ITSetup.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/ITSetup.java
@@ -53,10 +53,14 @@ public class ITSetup extends ExternalResource {
public ITSetup( CassandraResource cassandraResource ) {
this.cassandraResource = cassandraResource;
tomcatResource = TomcatResource.instance;
-
-
+ tomcatResource.setWebAppsPath("src/main/webapp");
}
+ public ITSetup( CassandraResource cassandraResource, String webAppsPath ) {
+ this.cassandraResource = cassandraResource;
+ tomcatResource = TomcatResource.instance;
+ tomcatResource.setWebAppsPath(webAppsPath);
+ }
private boolean setupCalled = false;
private boolean ready = false;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9b451716/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
index 677b384..b5436c7 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/TomcatResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/TomcatResource.java
@@ -15,20 +15,14 @@ import com.google.common.io.Files;
/** @author tnine */
public class TomcatResource extends ExternalResource {
+ public static final TomcatResource instance = new TomcatResource();
private static Object mutex = new Object();
-
private static final String CONTEXT = "/";
-
+ private String webAppsPath;
private int port;
-
-
-
-
private Tomcat tomcat;
protected TomcatResource(){
-
-
}
@Override
@@ -51,9 +45,7 @@ public class TomcatResource extends ExternalResource {
tomcat = new Tomcat();
tomcat.setBaseDir( dataDir.getAbsolutePath() );
tomcat.setPort( port );
- tomcat.addWebapp( CONTEXT, new File( "src/main/webapp" ).getAbsolutePath() );
-
-
+ tomcat.addWebapp( CONTEXT, new File( getWebAppsPath() ).getAbsolutePath() );
tomcat.start();
}
}
@@ -67,8 +59,11 @@ public class TomcatResource extends ExternalResource {
return port;
}
+ public String getWebAppsPath() {
+ return webAppsPath;
+ }
- public static final TomcatResource instance = new TomcatResource();
-
-
-}
+ public void setWebAppsPath(String webAppsPath) {
+ this.webAppsPath = webAppsPath;
+ }
+}
\ No newline at end of file