Skip to content

Commit 7f2859d

Browse files
author
Javen
committed
1. Always set apns_production option
2. Set apns_production to false by default (dev env)
1 parent e0de03a commit 7f2859d

File tree

3 files changed

+28
-8
lines changed

3 files changed

+28
-8
lines changed

src/cn/jpush/api/push/model/Options.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,17 @@ public JsonElement toJSON() {
6161
if (timeToLive > 0) {
6262
json.add(TIME_TO_LIVE, new JsonPrimitive(timeToLive));
6363
}
64-
if (!apnsProduction) {
65-
json.add(APNS_PRODUCTION, new JsonPrimitive(apnsProduction));
66-
}
64+
65+
json.add(APNS_PRODUCTION, new JsonPrimitive(apnsProduction));
66+
6767
return json;
6868
}
6969

7070
public static class Builder {
7171
private int sendno = 0;
7272
private long overrideMsgId = 0;
7373
private long timeToLive = 0;
74-
private boolean apnsProduction = true;
74+
private boolean apnsProduction = false;
7575

7676
public Builder setSendno(int sendno) {
7777
this.sendno = sendno;

test/cn/jpush/api/push/model/OptionsTest.java

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@ public void testIllegalTimeToLive() {
3030
public void testSendno() {
3131
JsonObject json = new JsonObject();
3232
json.add("sendno", new JsonPrimitive(111));
33-
Options optional = Options.newBuilder().setSendno(111).build();
34-
Assert.assertEquals("", json, optional.toJSON());
33+
json.add("apns_production", new JsonPrimitive(false));
34+
Options options = Options.newBuilder().setSendno(111).build();
35+
Assert.assertEquals("", json, options.toJSON());
3536
}
3637

3738
@Test
38-
public void testApnsProduction() {
39+
public void testApnsProduction_defaultFalse() {
3940
int sendno = ServiceHelper.generateSendno();
4041

4142
JsonObject json = new JsonObject();
@@ -44,10 +45,27 @@ public void testApnsProduction() {
4445

4546
Options options = Options.newBuilder()
4647
.setSendno(sendno)
47-
.setApnsProduction(false).build();
48+
.build();
49+
50+
Assert.assertEquals("", json, options.toJSON());
51+
}
52+
53+
@Test
54+
public void testApnsProduction_True() {
55+
int sendno = ServiceHelper.generateSendno();
56+
57+
JsonObject json = new JsonObject();
58+
json.add("apns_production", new JsonPrimitive(true));
59+
json.add("sendno", new JsonPrimitive(sendno));
60+
61+
Options options = Options.newBuilder()
62+
.setSendno(sendno)
63+
.setApnsProduction(true)
64+
.build();
4865

4966
Assert.assertEquals("", json, options.toJSON());
5067
}
5168

69+
5270
}
5371

test/cn/jpush/api/push/model/PushPayloadTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public void testNotification() {
6767

6868
JsonObject options = new JsonObject();
6969
options.add("sendno", new JsonPrimitive(sendno));
70+
options.add("apns_production", new JsonPrimitive(false));
7071
json.add("options", options);
7172

7273
Assert.assertEquals("", json, payload.toJSON());
@@ -91,6 +92,7 @@ public void testMessage() {
9192

9293
JsonObject options = new JsonObject();
9394
options.add("sendno", new JsonPrimitive(sendno));
95+
options.add("apns_production", new JsonPrimitive(false));
9496
json.add("options", options);
9597

9698
Assert.assertEquals("", json, payload.toJSON());

0 commit comments

Comments
 (0)