Skip to content

Commit

Permalink
1.1.2 extend
Browse files Browse the repository at this point in the history
  • Loading branch information
teaey committed Nov 22, 2016
1 parent 5640b3d commit 579d32f
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 87 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<groupId>cn.teaey.apns4j</groupId>
<artifactId>apns4j</artifactId>
<version>1.1.1</version>
<version>1.1.2</version>
<packaging>jar</packaging>
<url>https://github.com/teaey/apns4j.git</url>
<name>Apns4j</name>
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/cn/teaey/apns4j/protocol/ApnsPayload.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,9 @@ public ApnsPayload silent() {
addDictionary(ATTR_CONTENT_AVAILABLE, 1);
return this;
}

public ApnsPayload extend(String k, Object v) {
apsDict.put(k, v);
return this;
}
}
14 changes: 3 additions & 11 deletions src/test/java/cn/teaey/apns4j/ActionButtonTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,13 @@
* @author teaey(xiaofei.wxf)
* @since 1.0.3
*/
public class ActionButtonTest extends ApnsBaseTestCase {
public class ActionButtonTest {

// @Test
@Test
public void actionLocKey() {
ApnsPayload apnsPayload = Apns4j.newPayload()
.alertBody("Push by apns4j")
.alertActionLocKey("FixMe");

apnsChannel.send(TestConts.deviceToken, apnsPayload);


}

@After
public void destory() {
apnsChannel.close();
System.out.println(apnsPayload.toJsonString());
}
}
20 changes: 4 additions & 16 deletions src/test/java/cn/teaey/apns4j/AlertTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,16 @@
* @author teaey(xiaofei.wxf)
* @since 1.0.3
*/
public class AlertTest extends ApnsBaseTestCase {
public class AlertTest {

// @Test
@Test
public void alert() throws InterruptedException {

//create & init notify payload
ApnsPayload apnsPayload = Apns4j.newPayload()
.alertTitle("Title")
.alertBody("Pushed by apns4j")
.extend("k", "v")
.sound("default");

//send via channel
apnsChannel.send(TestConts.deviceToken, apnsPayload);

//in the end
apnsChannel.close();

}


@After
public void destory() {
apnsChannel.close();
System.out.println(apnsPayload.toJsonString());
}
}
17 changes: 0 additions & 17 deletions src/test/java/cn/teaey/apns4j/ApnsBaseTestCase.java

This file was deleted.

33 changes: 0 additions & 33 deletions src/test/java/cn/teaey/apns4j/ApnsServiceTest.java

This file was deleted.

12 changes: 3 additions & 9 deletions src/test/java/cn/teaey/apns4j/BadgeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,13 @@
* @author teaey(xiaofei.wxf)
* @since 1.0.3
*/
public class BadgeTest extends ApnsBaseTestCase {
public class BadgeTest {

// @Test
@Test
public void badge() {
ApnsPayload payload = Apns4j.newPayload()
.badge(4);

apnsChannel.send(TestConts.deviceToken, payload);
}

@After
public void destory() {
apnsChannel.close();
System.out.println(payload.toJsonString());
}

}
34 changes: 34 additions & 0 deletions src/test/java/cn/teaey/apns4j/MainTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package cn.teaey.apns4j;

import cn.teaey.apns4j.network.ApnsChannel;
import cn.teaey.apns4j.network.ApnsChannelFactory;
import cn.teaey.apns4j.network.async.ApnsFuture;
import cn.teaey.apns4j.network.async.ApnsService;
import cn.teaey.apns4j.protocol.ApnsPayload;
import org.junit.After;
import org.junit.Test;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;

/**
* @author teaey(xiaofei.wxf)
* @since 1.0.3
*/
public class MainTest {
static final ApnsChannelFactory apnsChannelFactory = Apns4j.newChannelFactoryBuilder().keyStoreMeta(TestConts.keyStorePath).keyStorePwd(TestConts.keyStorePwd).build();
static final ApnsChannel apnsChannel = apnsChannelFactory.newChannel();
static final ApnsService apnsService = new ApnsService(3, apnsChannelFactory, 3);
public static void main(String[] args) {
ApnsPayload apnsPayload = Apns4j.newPayload()
.alertTitle("Title")
.alertBody("Pushed by apns4j")
.extend("k", "v")
.sound("default");
//send via channel
apnsChannel.send(TestConts.deviceToken, apnsPayload);
//send async via service
ApnsFuture apnsFuture = apnsService.send(TestConts.deviceToken, apnsPayload);
apnsService.shutdown(3, TimeUnit.SECONDS);
}
}

0 comments on commit 579d32f

Please sign in to comment.