Skip to content

Commit c1ccff9

Browse files
committed
Adding support for camelCase PNSCredential properties
1 parent 6a83ec4 commit c1ccff9

File tree

4 files changed

+110
-5
lines changed

4 files changed

+110
-5
lines changed

NotificationHubs/.classpath

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<attribute name="test" value="true"/>
1414
</attributes>
1515
</classpathentry>
16-
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
16+
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
1717
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
1818
<attributes>
1919
<attribute name="maven.pomderived" value="true"/>

NotificationHubs/src/com/windowsazure/messaging/PnsCredential.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ public abstract class PnsCredential {
2020
private static final String PROPERTIES_END = "</Properties>";
2121

2222
public void setProperty(String propertyName, String propertyValue) throws Exception {
23-
this.getClass().getMethod("set" + propertyName, String.class).invoke(this, propertyValue);
23+
var setterName = "set" + propertyName.substring(0, 1).toUpperCase() + propertyName.substring(1);
24+
this.getClass().getMethod(setterName, String.class).invoke(this, propertyValue);
2425
}
2526

2627
public static void setupDigester(Digester digester) {
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<entry xmlns="http://www.w3.org/2005/Atom">
3+
<title type="text">test-hub</title>
4+
<content type="application/xml">
5+
<NotificationHubDescription xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect">
6+
<ApnsCredential>
7+
<Properties>
8+
<Property>
9+
<Name>endpoint</Name>
10+
<Value>ApnsEndpointValue</Value>
11+
</Property>
12+
<Property>
13+
<Name>apnsCertificate</Name>
14+
<Value>ApnsCertificateValue</Value>
15+
</Property>
16+
<Property>
17+
<Name>certificateKey</Name>
18+
<Value>ApnsCertificateKeyValue</Value>
19+
</Property>
20+
<Property>
21+
<Name>Thumbprint</Name>
22+
<Value>ApnsThumbprintValue</Value>
23+
</Property>
24+
<Property>
25+
<Name>token</Name>
26+
<Value>ApnsTokenValue</Value>
27+
</Property>
28+
<Property>
29+
<Name>keyId</Name>
30+
<Value>ApnsKeyIdValue</Value>
31+
</Property>
32+
<Property>
33+
<Name>appName</Name>
34+
<Value>ApnsAppNameValue</Value>
35+
</Property>
36+
<Property>
37+
<Name>appId</Name>
38+
<Value>ApnsAppIdValue</Value>
39+
</Property>
40+
</Properties>
41+
</ApnsCredential>
42+
<RegistrationTtl>P39D</RegistrationTtl>
43+
<WnsCredential>
44+
<Properties>
45+
<Property>
46+
<Name>packageSid</Name>
47+
<Value>WnsPackageSidValue</Value>
48+
</Property>
49+
<Property>
50+
<Name>secretKey</Name>
51+
<Value>WnsSecretKeyValue</Value>
52+
</Property>
53+
</Properties>
54+
</WnsCredential>
55+
<GcmCredential>
56+
<Properties>
57+
<Property>
58+
<Name>googleApiKey</Name>
59+
<Value>GoogleApiKeyValue</Value>
60+
</Property>
61+
</Properties>
62+
</GcmCredential>
63+
<MpnsCredential>
64+
<Properties>
65+
<Property>
66+
<Name>mpnsCertificate</Name>
67+
<Value>MpnsCertificateValue</Value>
68+
</Property>
69+
<Property>
70+
<Name>certificateKey</Name>
71+
<Value>MpnsCertificateKeyValue</Value>
72+
</Property>
73+
</Properties>
74+
</MpnsCredential>
75+
<AdmCredential>
76+
<Properties>
77+
<Property>
78+
<Name>clientId</Name>
79+
<Value>AdmClientIdValue</Value>
80+
</Property>
81+
<Property>
82+
<Name>clientSecret</Name>
83+
<Value>AdmClientSecretValue</Value>
84+
</Property>
85+
</Properties>
86+
</AdmCredential>
87+
<BaiduCredential>
88+
<Properties>
89+
<Property>
90+
<Name>baiduApiKey</Name>
91+
<Value>BaiduApiKeyValue</Value>
92+
</Property>
93+
<Property>
94+
<Name>baiduSecretKey</Name>
95+
<Value>BaiduSecretKeyValue</Value>
96+
</Property>
97+
</Properties>
98+
</BaiduCredential>
99+
</NotificationHubDescription>
100+
</content>
101+
</entry>

NotificationHubs/test/com/windowsazure/messaging/NotificationHubParseTest.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
import org.apache.commons.io.IOUtils;
88
import org.junit.Test;
9+
import org.junit.jupiter.params.ParameterizedTest;
10+
import org.junit.jupiter.params.provider.ValueSource;
911
import org.xml.sax.SAXException;
1012

1113
import java.io.IOException;
@@ -18,10 +20,11 @@
1820

1921
public class NotificationHubParseTest {
2022

21-
@Test
22-
public void testParseNotificationHubWithAllCredentials() throws IOException, SAXException {
23+
@ParameterizedTest
24+
@ValueSource(strings = {"NotificationHubDescriptionWithAllCredentials", "NotificationHubDescriptionWithAllCredentialsLowercaseNames"})
25+
public void testParseNotificationHubWithAllCredentials(String inputFileName) throws IOException, SAXException {
2326
InputStream inputXml = this.getClass()
24-
.getResourceAsStream("NotificationHubDescriptionWithAllCredentials");
27+
.getResourceAsStream(inputFileName);
2528
NotificationHubDescription hub = NotificationHubDescription.parseOne(inputXml);
2629
assertNotNull(hub);
2730
assertEquals("test-hub", hub.getPath());

0 commit comments

Comments
 (0)