Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed unsupported APNS and replaced it with pushy
- Loading branch information
Showing
9 changed files
with
267 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
jpasskit/src/test/java/de/brendamour/jpasskit/apns/PKSendPushNotificationUtilTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/** | ||
* Copyright (C) 2017 Patrice Brend'amour <patrice@brendamour.net> | ||
* | ||
* Licensed 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 de.brendamour.jpasskit.apns; | ||
|
||
import java.io.InputStream; | ||
|
||
import com.turo.pushy.apns.ApnsClient; | ||
import com.turo.pushy.apns.ApnsClientBuilder; | ||
import com.turo.pushy.apns.PushNotificationResponse; | ||
import com.turo.pushy.apns.server.AcceptAllPushNotificationHandlerFactory; | ||
import com.turo.pushy.apns.server.MockApnsServer; | ||
import com.turo.pushy.apns.server.MockApnsServerBuilder; | ||
import com.turo.pushy.apns.util.SimpleApnsPushNotification; | ||
|
||
import org.testng.Assert; | ||
import org.testng.annotations.AfterClass; | ||
import org.testng.annotations.BeforeClass; | ||
import org.testng.annotations.BeforeMethod; | ||
import org.testng.annotations.Test; | ||
|
||
public class PKSendPushNotificationUtilTest { | ||
|
||
private PKSendPushNotificationUtil util; | ||
private static final String keyStorePath = "passbook/jpasskittest.p12"; | ||
private static final String keyStorePassword = "password"; | ||
private static final String CA_CERTIFICATE_FILENAME = "/ca.pem"; | ||
private static final String SERVER_CERTIFICATES_FILENAME = "/server-certs.pem"; | ||
private static final String SERVER_KEY_FILENAME = "/server-key.pem"; | ||
private static final String HOST = "localhost"; | ||
private static final int PORT = 8443; | ||
|
||
private MockApnsServer apnsServer; | ||
|
||
@BeforeClass | ||
public void prepareTest() throws Exception { | ||
util = new PKSendPushNotificationUtil(keyStorePath, keyStorePassword); | ||
InputStream certificateStream = util.getStreamOfP12File(keyStorePath); | ||
ApnsClient client = new ApnsClientBuilder().setApnsServer(HOST,PORT) | ||
.setClientCredentials(certificateStream,keyStorePassword) | ||
.setTrustedServerCertificateChain(getClass().getResourceAsStream(CA_CERTIFICATE_FILENAME)) | ||
.build(); | ||
util.setClient(client); | ||
apnsServer = new MockApnsServerBuilder().setHandlerFactory(new AcceptAllPushNotificationHandlerFactory()).setServerCredentials(getClass().getResourceAsStream(SERVER_CERTIFICATES_FILENAME), getClass().getResourceAsStream(SERVER_KEY_FILENAME), null) | ||
.build(); | ||
apnsServer.start(PORT).await(); | ||
} | ||
|
||
@Test | ||
public void sendPushNotification() throws Exception { | ||
final PushNotificationResponse<SimpleApnsPushNotification> response = util.sendPushNotificationAsync("ABC1234").get(); | ||
Assert.assertTrue(response.isAccepted()); | ||
} | ||
|
||
@AfterClass | ||
public void shutDownTest() throws Exception { | ||
apnsServer.shutdown(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIDGDCCAgCgAwIBAgIJAPS2GZT4oi8cMA0GCSqGSIb3DQEBDQUAMBgxFjAUBgNV | ||
BAMMDVB1c2h5VGVzdFJvb3QwIBcNMTcwNDE3MDA1MzMwWhgPMjExNzAzMjQwMDUz | ||
MzBaMBgxFjAUBgNVBAMMDVB1c2h5VGVzdFJvb3QwggEiMA0GCSqGSIb3DQEBAQUA | ||
A4IBDwAwggEKAoIBAQDF3Y3kV01ojXWbpZsww9yALoZibzZNOV91ft7DgTqFkHPz | ||
p9J35NHsFSAXF1yHgl/xRnJqP8JC8eqjg/bPE0zzF6ErEaj7zGxDYN3+v0+k6gdL | ||
s+hFWbi38h11lEwj+AejAoOihgHCHjguuhFejGsphFI0HWmR3wXsUIsowzlgmWA6 | ||
SUR15gFXbktaPl+XtGxyWcwO5anAUBrwEbChPGNCeLL0fAbBUjKqfw7mhY1OFlv/ | ||
LAceM1GdEDvK6mQR4vw+aqypWCX2WPv948rVXegy7VM/lt2YFYEGogtjdrOsT4nd | ||
s/N0/gboq4ebU4mLmsFgJxv0iYU0DFXLw/8hlNHPAgMBAAGjYzBhMB0GA1UdDgQW | ||
BBSxqubF1u3WRgfvF1iaFsKwixZzszAfBgNVHSMEGDAWgBSxqubF1u3WRgfvF1ia | ||
FsKwixZzszAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG | ||
9w0BAQ0FAAOCAQEAJ1E2peRR58svomV3gYulC67ktuByiqpJkMBs9AJBzUtQWf/v | ||
s+RUxpRqJawqvfgAtIVuIZAy0zTNkdasQOjSvTkmibQSV61kmyZx0stzwqdKdXfJ | ||
2NbLqfWPd+UyVBKJp+oSGJe7EM/lG1OChDPid57Fn+Vm4SUnv4ly4r0P80buntbk | ||
OWkx3YeCTe6mWa55z+IH7P2Ef0j3V5ui4p7dZ1hOiU2zsIeuGb9jX0h/Tbqyt+mu | ||
93Mgig3e+hgVhNwYEWXzen2SbxzOP2KkRvIjFTNbPuiK8eSPp8RKSME+bc6CY3ZN | ||
UzV5ZWwUxxqk6jHrxrnBt0PxFFGY5gKurTR3+w== | ||
-----END CERTIFICATE----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIC8TCCAdmgAwIBAgICbE8wDQYJKoZIhvcNAQENBQAwGDEWMBQGA1UEAwwNUHVz | ||
aHlUZXN0Um9vdDAgFw0xNzA0MTcwMDUzMzBaGA8yMTE3MDMyNDAwNTMzMFowHzEd | ||
MBsGA1UEAwwUY29tLnJlbGF5cmlkZXMucHVzaHkwggEiMA0GCSqGSIb3DQEBAQUA | ||
A4IBDwAwggEKAoIBAQDHZkZBnDKM4Gt+WZwTc5h2GuT1Di7TfUE8SxDhw5wn3c36 | ||
41/6lnrTj1Sh5tAsed8N2FDrD+Hp9zTkKljDGe8tuDncT1qSrp/UuikgdIAAiCXA | ||
/vClWPYqZcHAUc9/OcfRiyK5AmJdzz+UbY803ArSPHjz3+Mk6C9tnzBXzG8oJq9o | ||
EKJhwUYX+7l8+m0omtZXhMCOrbmZ2s69m6hTwHJKdC0mEngdyeiYIsbHaoSwxR7U | ||
j8wRstdr2xWhPg1fdIVHzudYubJ7M/h95JQFKtwqEevtLUa4BJgi8SKvRX5NnkGE | ||
QMui1ercRuklVURTeoGDQYENiFnzTyI0J2tw3T+dAgMBAAGjPDA6MAkGA1UdEwQC | ||
MAAwDgYDVR0PAQH/BAQDAgWgMB0GA1UdJQQWMBQGCCsGAQUFBwMCBggrBgEFBQcD | ||
ATANBgkqhkiG9w0BAQ0FAAOCAQEAnHHYMvBWglQLOUmNOalCMopmk9yKHM7+Sc9h | ||
KsTWJW+YohF5zkRhnwUFxW85Pc63rRVA0qyI5zHzRtwYlcZHU57KttJyDGe1rm/0 | ||
ZUqXharurJzyI09jcwRpDY8EGktrGirE1iHDqQTHNDHyS8iMVU6aPCo0xur63G5y | ||
XzoIVhQXsBuwoU4VKb3n5CrxKEVcmE/nYF/Tk0rTtCrZF7TR3y/oxrp359goJ1b2 | ||
/OjXN4dlqND41SbVTTL0FyXU3ebaS4DALA3pyVa1Rijw7vgEbFabsuMaAbdvlprn | ||
RwUjsrRVu3Tx7sp/NqmeBLVru5nH/yHStDjSdvQtI2ipNGK/9w== | ||
-----END CERTIFICATE----- |
Oops, something went wrong.