You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by to...@apache.org on 2014/10/16 06:30:48 UTC
[06/15] git commit: real tests for devices, BA
real tests for devices, BA
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/b5470f19
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/b5470f19
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/b5470f19
Branch: refs/heads/cloudformation-update
Commit: b5470f197b177822cccb828c970bc047f595de1f
Parents: 9c1c57c
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Oct 15 09:28:49 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Oct 15 09:28:49 2014 -0600
----------------------------------------------------------------------
.../AbstractServiceNotificationIT.java | 4 +-
.../apns/NotificationsServiceIT.java | 53 ++++++++++++++++++++
2 files changed, 55 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b5470f19/stack/services/src/test/java/org/apache/usergrid/services/notifications/AbstractServiceNotificationIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/notifications/AbstractServiceNotificationIT.java b/stack/services/src/test/java/org/apache/usergrid/services/notifications/AbstractServiceNotificationIT.java
index 651c94f..e16f111 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/notifications/AbstractServiceNotificationIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/notifications/AbstractServiceNotificationIT.java
@@ -103,7 +103,7 @@ public class AbstractServiceNotificationIT extends AbstractServiceIT {
protected void checkReceipts(Notification notification, int expected)
throws Exception {
List<EntityRef> receipts = getNotificationReceipts(notification);
- long timeout = System.currentTimeMillis() + 60000;
+ long timeout = System.currentTimeMillis() + 10000;
while (System.currentTimeMillis() < timeout) {
Thread.sleep(200);
receipts =getNotificationReceipts(notification);
@@ -124,7 +124,7 @@ public class AbstractServiceNotificationIT extends AbstractServiceIT {
protected void checkStatistics(Notification notification, long sent, long errors) throws Exception{
Map<String, Long> statistics = null;
- long timeout = System.currentTimeMillis() + 60000;
+ long timeout = System.currentTimeMillis() + 10000;
while (System.currentTimeMillis() < timeout) {
Thread.sleep(200);
statistics = app.getEm().get(notification.getUuid(), Notification.class).getStatistics();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b5470f19/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
index 45bd1bb..76dbed3 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
@@ -791,6 +791,59 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
List user1Devices = app.getEm().getCollection(user1,"devices",null,100, Query.Level.REFS,false).getEntities();
assertEquals(user1Devices.size(),2);
+ // create push notification //
+
+ app.getEm().refreshIndex();
+
+ // give queue manager a query for loading 100 devices from an application (why?)
+ app.clear();
+ ns.TEST_PATH_QUERY = null;
+
+ // create a "hello world" notification
+ String payload = getPayload();
+ Map<String, String> payloads = new HashMap<String, String>(1);
+ payloads.put(notifier.getName().toString(), payload);
+ app.put("payloads", payloads);
+ app.put("queued", System.currentTimeMillis());
+ app.put("debug",true);
+
+ // post notification to service manager
+ e = app.testRequest(ServiceAction.POST, 1,"users",user1.getUuid(), "notifications").getEntity();
+
+ // ensure notification it was created
+ app.testRequest(ServiceAction.GET, 1, "notifications", e.getUuid());
+
+ // ensure notification has expected name
+ Notification notification = app.getEm().get(e.getUuid(), Notification.class);
+ assertEquals(
+ notification.getPayloads().get(notifier.getName().toString()),
+ payload);
+
+ // verify Query for CREATED state
+ Query query = new Query();
+ query.addEqualityFilter("state", Notification.State.STARTED.toString());
+ Results results = app.getEm().searchCollection(
+ app.getEm().getApplicationRef(), "notifications", query);
+ Entity entity = results.getEntitiesMap().get(notification.getUuid());
+ //assertNotNull(entity);
+
+ // perform push //
+
+ notification = scheduleNotificationAndWait(notification);
+
+ app.getEm().refreshIndex();
+
+ // verify Query for FINISHED state
+ query = new Query();
+ query.addEqualityFilter("state", Notification.State.FINISHED.toString());
+ results = app.getEm().searchCollection(app.getEm().getApplicationRef(),
+ "notifications", query);
+ entity = results.getEntitiesMap().get(notification.getUuid());
+ assertNotNull(entity);
+
+ checkReceipts(notification, 2);
+ checkStatistics(notification, 2, 0);
+
}
@Test