Package com.relayrides.pushy.apns.util

Examples of com.relayrides.pushy.apns.util.SimpleApnsPushNotification


      }

      final String payloadString = new String(this.payloadBytes, Charset.forName("UTF-8"));

      return new SendableApnsPushNotification<SimpleApnsPushNotification>(
          new SimpleApnsPushNotification(this.token, payloadString, this.deliveryInvalidation, this.priority),
          this.sequenceNumber);
    }
View Full Code Here


  public SimpleApnsPushNotification createTestNotification() {
    final byte[] token = new byte[MockApnsServer.EXPECTED_TOKEN_SIZE];
    new Random().nextBytes(token);

    return new SimpleApnsPushNotification(token, "{\"aps\":{\"alert\":\"Hello\"}}");
  }
View Full Code Here

  private SimpleApnsPushNotification testNotification;

  @Before
  public void setUp() throws Exception {
    this.testNotification = new SimpleApnsPushNotification(
        new byte[] { 0x12, 0x34, 0x56, 0x78 },
        "This is an invalid payload, but that's okay.",
        new Date());
  }
View Full Code Here

    for (final SendableApnsPushNotification<SimpleApnsPushNotification> notification : this.generateSequentialNotifications(10, 0)) {
      buffer.addSentNotification(notification);
    }

    final SendableApnsPushNotification<SimpleApnsPushNotification> needle =
        new SendableApnsPushNotification<SimpleApnsPushNotification>(new SimpleApnsPushNotification(
            new byte[] { 0x17 }, "This is the notification we're looking for."), 10);

    buffer.addSentNotification(needle);

    for (final SendableApnsPushNotification<SimpleApnsPushNotification> notification : this.generateSequentialNotifications(10, 11)) {
View Full Code Here

    assertTrue(listener.connectionSucceeded);

    final byte[] token = new byte[32];
    new Random().nextBytes(token);

    final SimpleApnsPushNotification nullPriorityNotification = new SimpleApnsPushNotification(
        token, "This is a bogus payload, but that's okay.", null, null);

    apnsConnection.sendNotification(nullPriorityNotification);
    this.waitForLatch(latch);
  }
View Full Code Here

      }
    }

    assertTrue(listener.connectionSucceeded);

    final SimpleApnsPushNotification bogusNotification =
        new SimpleApnsPushNotification(new byte[] {}, "This is a bogus notification and should be rejected.");

    synchronized (mutex) {
      apnsConnection.sendNotification(bogusNotification);

      while (!listener.connectionClosed) {
View Full Code Here

      final byte[] token = new byte[32];
      random.nextBytes(token);

      builder.setAlertBody(new BigInteger(1024, new Random()).toString(16));

      this.notifications.add(new SimpleApnsPushNotification(token, builder.buildWithDefaultMaximumLength()));
    }
  }
View Full Code Here

    assertNotNull(pushManager.getName());
  }

  @Test
  public void testRegisterRejectedNotificationListener() throws InterruptedException {
    final SimpleApnsPushNotification notification = this.createTestNotification();

    final TestRejectedNotificationListener listener = new TestRejectedNotificationListener();
    this.getPushManager().registerRejectedNotificationListener(listener);

    assertEquals(0, listener.getRejectedNotificationCount());

    final int iterations = 100;

    // We expect one less because one notification should be rejected
    final CountDownLatch latch = this.getApnsServer().getAcceptedNotificationCountDownLatch(iterations - 1);

    for (int i = 0; i < iterations; i++) {
      if (i == iterations / 2) {
        this.getPushManager().getQueue().add(
            new SimpleApnsPushNotification(new byte[] {}, "This is a deliberately malformed notification."));
      } else {
        this.getPushManager().getQueue().add(notification);
      }
    }
View Full Code Here

    final ArrayList<SimpleApnsPushNotification> notificationsToSend = new ArrayList<SimpleApnsPushNotification>(iterations);

    for (int i = 0; i < iterations; i++) {
      if (i == iterations / 2) {
        notificationsToSend.add(
            new SimpleApnsPushNotification(new byte[] {}, "This is a deliberately malformed notification."));
      } else {
        notificationsToSend.add(this.createTestNotification());
      }
    }
View Full Code Here

    final CountDownLatch latch = this.getApnsServer().getAcceptedNotificationCountDownLatch(iterations - 1);

    for (int i = 0; i < iterations; i++) {
      if (i == iterations / 2) {
        this.getPushManager().getQueue().add(
            new SimpleApnsPushNotification(new byte[] {}, "This is a deliberately malformed notification."));
      } else {
        this.getPushManager().getQueue().add(this.createTestNotification());
      }
    }
View Full Code Here

TOP

Related Classes of com.relayrides.pushy.apns.util.SimpleApnsPushNotification

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.