usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mru...@apache.org
Subject [1/4] usergrid-java git commit: Initial commit of Usergrid Java SDK into its own repo
Date Fri, 02 Sep 2016 16:37:36 GMT
Repository: usergrid-java
Updated Branches:
  refs/heads/master [created] 88039badc


http://git-wip-us.apache.org/repos/asf/usergrid-java/blob/88039bad/src/test/java/org/apache/usergrid/client/UsergridResponseErrorTestCase.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/usergrid/client/UsergridResponseErrorTestCase.java b/src/test/java/org/apache/usergrid/client/UsergridResponseErrorTestCase.java
new file mode 100644
index 0000000..3533805
--- /dev/null
+++ b/src/test/java/org/apache/usergrid/client/UsergridResponseErrorTestCase.java
@@ -0,0 +1,62 @@
+/*
+ * 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.client;
+
+import org.apache.usergrid.java.client.Usergrid;
+import org.apache.usergrid.java.client.auth.UsergridAppAuth;
+import org.apache.usergrid.java.client.response.UsergridResponse;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.junit.Assert.*;
+
+public class UsergridResponseErrorTestCase {
+
+    @Before
+    public void before() {
+        Usergrid.initSharedInstance(SDKTestConfiguration.ORG_NAME, SDKTestConfiguration.APP_NAME,
SDKTestConfiguration.USERGRID_URL, SDKTestConfiguration.authFallBack);
+        UsergridAppAuth appAuth = new UsergridAppAuth(SDKTestConfiguration.APP_CLIENT_ID,
SDKTestConfiguration.APP_CLIENT_SECRET);
+        Usergrid.authenticateApp(appAuth);
+    }
+
+    @After
+    public void after() {
+        Usergrid.reset();
+    }
+
+    @Test
+    public void testEntityCreationSuccess() {
+        String collectionName = "ect" + System.currentTimeMillis();
+
+        Map<String, String> fields = new HashMap<>(3);
+        fields.put("color", "red");
+        fields.put("shape", "square");
+
+        SDKTestUtils.createEntity(collectionName, "testEntity1", fields);
+        UsergridResponse eLookUp = Usergrid.GET(collectionName, "testEntity1");
+        assertNull("The returned entity is null!", eLookUp.getResponseError());
+
+        UsergridResponse response = Usergrid.GET(collectionName, "testEntityThatShouldNotExist");
+        assertFalse("Response returned should not be ok.",response.ok());
+        assertTrue("StatusCode equals than 404", response.getStatusCode() == 404);
+        assertNotNull("The returned entity is null!", response.getResponseError());
+    }
+}

http://git-wip-us.apache.org/repos/asf/usergrid-java/blob/88039bad/src/test/java/org/apache/usergrid/client/UsergridResponseTestCase.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/usergrid/client/UsergridResponseTestCase.java b/src/test/java/org/apache/usergrid/client/UsergridResponseTestCase.java
new file mode 100644
index 0000000..e158d85
--- /dev/null
+++ b/src/test/java/org/apache/usergrid/client/UsergridResponseTestCase.java
@@ -0,0 +1,85 @@
+/*
+ * 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.client;
+
+import org.apache.usergrid.java.client.Usergrid;
+import org.apache.usergrid.java.client.UsergridEnums;
+import org.apache.usergrid.java.client.auth.UsergridUserAuth;
+import org.apache.usergrid.java.client.response.UsergridResponse;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+public class UsergridResponseTestCase {
+
+    @Before
+    public void before() {
+        Usergrid.initSharedInstance(SDKTestConfiguration.ORG_NAME, SDKTestConfiguration.APP_NAME,
SDKTestConfiguration.USERGRID_URL, UsergridEnums.UsergridAuthMode.USER);
+        Usergrid.authenticateUser(new UsergridUserAuth(SDKTestConfiguration.APP_UserName,
SDKTestConfiguration.APP_Password));
+    }
+
+    @After
+    public void after() {
+        Usergrid.reset();
+    }
+
+    @Test
+    public void testLogoutUser() {
+        String collectionName = "ect" + System.currentTimeMillis();
+
+        Map<String, String> fields = new HashMap<>(3);
+        fields.put("color", "red");
+        fields.put("shape", "square");
+
+        SDKTestUtils.createEntity(collectionName, "testEntity1", fields);
+        UsergridResponse response = Usergrid.GET(collectionName, "testEntity1");
+        Object instanceObj = response.getStatusCode();
+        assertTrue("The returned statusCode is and object of integer", instanceObj instanceof
Integer);
+        instanceObj = response.ok();
+        assertTrue("The returned statusCode is and object of boolean", instanceObj instanceof
Boolean);
+
+        UsergridResponse resp = Usergrid.logoutUser(SDKTestConfiguration.APP_UserName,null);
+
+        response = Usergrid.GET(collectionName, "testEntity1");
+        assertNotNull("The response should throw an error",response.getResponseError());
+    }
+
+    @Test
+    public void testLogoutCurrentUser() {
+        String collectionName = "ect" + System.currentTimeMillis();
+
+        Map<String, String> fields = new HashMap<>(3);
+        fields.put("color", "red");
+        fields.put("shape", "square");
+
+        SDKTestUtils.createEntity(collectionName, "testEntity12", fields);
+        UsergridResponse response = Usergrid.GET(collectionName, "testEntity12");
+        assertNull("The response should not throw an error",response.getResponseError());
+
+        Usergrid.logoutCurrentUser();
+        response = Usergrid.GET(collectionName, "testEntity1");
+        assertNotNull("The response should throw an error",response.getResponseError());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/usergrid-java/blob/88039bad/src/test/java/org/apache/usergrid/client/UsergridTestCase.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/usergrid/client/UsergridTestCase.java b/src/test/java/org/apache/usergrid/client/UsergridTestCase.java
new file mode 100644
index 0000000..5e1ab3a
--- /dev/null
+++ b/src/test/java/org/apache/usergrid/client/UsergridTestCase.java
@@ -0,0 +1,30 @@
+/*
+ * 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.client;
+
+import org.apache.usergrid.java.client.Usergrid;
+import org.apache.usergrid.java.client.auth.UsergridAppAuth;
+import org.junit.Before;
+import org.junit.Test;
+
+public class UsergridTestCase {
+
+    @Test
+    public void initialize() {
+        Usergrid.initSharedInstance(SDKTestConfiguration.ORG_NAME, SDKTestConfiguration.APP_NAME,
SDKTestConfiguration.USERGRID_URL);
+    }
+}

http://git-wip-us.apache.org/repos/asf/usergrid-java/blob/88039bad/usergrid-java-client-2.1.0.jar
----------------------------------------------------------------------
diff --git a/usergrid-java-client-2.1.0.jar b/usergrid-java-client-2.1.0.jar
new file mode 100644
index 0000000..fa90a59
Binary files /dev/null and b/usergrid-java-client-2.1.0.jar differ


Mime
View raw message