Coder Social home page Coder Social logo

azure / azure-notificationhubs-java-backend Goto Github PK

View Code? Open in Web Editor NEW
34.0 39.0 47.0 483 KB

Azure Notification Hubs SDK for Java

Home Page: https://docs.microsoft.com/en-us/azure/notification-hubs/

License: Apache License 2.0

Java 100.00%
gcm fcm apns azure azure-notification-hubs wns amazon-kindle push-notifications

azure-notificationhubs-java-backend's Introduction

Maven Central

Microsoft Azure Notification Hubs Java SDK

This repository contains source code for the Java SDK for Microsoft Azure Notification Hubs.

Note on FCMv1 Migration

The Azure Notification Hubs SDK has support for Firebase Cloud Messaging (FCM) via the Legacy HTTP API which is compatible with GCM. As a reminder, Google will stop supporting FCM legacy HTTP on June 20, 2024, so customer must migrate their applications and notification payloads to the new format before then. For more information, read the Azure Notification Hubs and Google Firebase Cloud Messaging migration documentation.

Building the Azure Notification Hubs Java SDK

To build, use Maven:

cd NotificationHubs
mvn source:jar javadoc:jar package

Getting Started

To get started, you can find all the classes in the com.windowsazure.messaging package, for example:

import com.windowsazure.messaging.NotificationHub;

The Azure Notification Hubs SDK for Java support both synchronous and asynchronous operations on NotificationHub/NotificationHubClient and NamespaceManager/NamespaceManagerClient. The asynchronous APIs are supported using the org.apache.http.concurrent.FutureCallback interface.

// Synchronous
NotificationHubDescription hub = new NotificationHubDescription("hubname");
hub.setWindowsCredential(new WindowsCredential("sid","key"));
NotificationHubDescription hubDescription = namespaceManager.createNotificationHub(hub);

// Asynchronous
NotificationHubDescription hub = new NotificationHubDescription("hubname");
hub.setWindowsCredential(new WindowsCredential("sid","key"));
namespaceManager.createNotificationHubAsync(hub, new FutureCallback<NotificationHubDescription>() {
    @Override
    public void completed(NotificationHubDescription result) {
        // Handle success
    }

    @Override
    public void failed(Exception ex) {
        // Handle failure
    }

    @Override
    public void cancelled() {
        // Operation has been cancelled
    }
});

Throttling and Retrying Operations

By default, the Azure Notification Hubs SDK for Java by default has a retry policy called the BasicRetryPolicy which retries based upon status codes from Azure Notification Hubs. To swap out your own HttpRequestRetryStrategy, you can use the HttpClientManager.setRetryPolicy method before calling any HTTP operation.

HttpClientManager.setRetryPolicy(new DefaultHttpRequestRetryStrategy(3, TimeValue.ofSeconds(3)));

Azure Notification Hubs Management Operations

This section details the usage of the Azure Notification Hubs SDK for Java management operations for CRUD operations on Notification Hubs and Notification Hub Namespaces.

Create a namespace manager

NamespaceManagerClient namespaceManager = new NamespaceManager("connection string");

Create an Azure Notification Hub

NotificationHubDescription hub = new NotificationHubDescription("hubname");
hub.setWindowsCredential(new WindowsCredential("sid","key"));
hub = namespaceManager.createNotificationHub(hub);

Get a Azure Notification Hub

NotificationHubDescription hub = namespaceManager.getNotificationHub("hubname")

Update an Azure Notification Hub

hub.setMpnsCredential(new MpnsCredential("mpnscert", "mpnskey"));
namespaceManager.updateNotificationHub(hub);

Delete an Azure Notification Hub

namespaceManager.deleteNotificationHub("hubname");

Azure Notification Hubs Operations

The NotificationHub class and NotificationHubClient interface is the main entry point for installations/registrations, but also sending push notifications. To create a NotificationHub, you need the connection string from your Access Policy with the desired permissions such as Listen, Manage and Send, and in addition, the hub name to use.

Create an Azure Notification Hub Client:

NotificationHubClient hub = new NotificationHub("connection string", "hubname");

Azure Notification Hubs Installation API

An Installation is an enhanced registration that includes a bag of push related properties. It is the latest and best approach to registering your devices.

The following are some key advantages to using installations:

  • Creating or updating an installation is fully idempotent. So you can retry it without any concerns about duplicate registrations.
  • The installation model supports a special tag format ($InstallationId:{INSTALLATION_ID}) that enables sending a notification directly to the specific device. For example, if the app's code sets an installation ID of joe93developer for this particular device, a developer can target this device when sending a notification to the $InstallationId:{joe93developer} tag. This enables you to target a specific device without having to do any additional coding.
  • Using installations also enables you to do partial registration updates. The partial update of an installation is requested with a PATCH method using the JSON-Patch standard. This is useful when you want to update tags on the registration. You don't have to pull down the entire registration and then resend all the previous tags again.

Using this SDK, you can do these Installation API operations. For example, we can create an installation for an Amazon Kindle Fire.

AdmInstallation installation = new AdmInstallation("installation-id", "adm-push-channel");
hub.createOrUpdateInstallation(installation);

An installation can have multiple tags and multiple templates with its own set of tags and headers.

installation.addTag("foo");
installation.addTemplate("template1", new InstallationTemplate("{\"data\":{\"key1\":\"$(value1)\"}}","tag-for-template1"));
installation.addTemplate("template2", new InstallationTemplate("{\"data\":{\"key2\":\"$(value2)\"}}","tag-for-template2"));
hub.createOrUpdateInstallation(installation);

For advanced scenarios we have partial update capability which allows to modify only particular properties of the installation object. Basically partial update is subset of JSON Patch operations you can run against Installation object.

PartialUpdateOperation addChannel = new PartialUpdateOperation(UpdateOperationType.Add, "/pushChannel", "adm-push-channel2");
PartialUpdateOperation addTag = new PartialUpdateOperation(UpdateOperationType.Add, "/tags", "bar");
PartialUpdateOperation replaceTemplate = new PartialUpdateOperation(UpdateOperationType.Replace, "/templates/template1", new InstallationTemplate("{\"data\":{\"key3\":\"$(value3)\"}}","tag-for-template1")).toJson());
hub.patchInstallation("installation-id", addChannel, addTag, replaceTemplate);

Delete an Installation:

hub.deleteInstallation(installation.getInstallationId());

Keep in mind that CreateOrUpdate, Patch and Delete are eventually consistent with Get. In fact operation just goes to the system queue during the call and will be executed in background. Moreover Get is not designed for main runtime scenario but just for debug and troubleshooting purposes, it is tightly throttled by the service.

Azure Notification Hub Registration API

A registration associates the Platform Notification Service (PNS) handle for a device with tags and possibly a template. The PNS handle could be a ChannelURI, device token, or FCMv1 registration ID. Tags are used to route notifications to the correct set of device handles. Templates are used to implement per-registration transformation. The Registration API handles requests for these operations.

Create a Windows Registration

WindowsRegistration reg = new WindowsRegistration(new URI(CHANNELURI));
reg.addTag("platform_uwp");
reg.addTag("os_windows10");
WindowsRegistration created = hub.createRegistrationAsync(reg);

Create an Apple Registration

AppleRegistration reg = new AppleRegistration(DEVICETOKEN);
reg.addTag("platform_ios");
reg.addTag("os_tvos");
AppleRegistration created = hub.createRegistrationAsync(reg);

Analogous for Android (FcmV1), Windows Phone (MPNS), and Kindle Fire (ADM).

Create Template Registrations

WindowsTemplateRegistration reg = new WindowsTemplateRegistration(new URI(CHANNELURI), WNSBODYTEMPLATE);
reg.addHeader("X-WNS-Type", "wns/toast");
WindowsTemplateRegistration created = hub.createRegistration(reg);

Create registrations using create registrationid+upsert pattern (removes duplicates deriving from lost responses if registration ids are stored on the device):

String id = hub.createRegistrationId();
WindowsRegistration reg = new WindowsRegistration(id, new URI(CHANNELURI));
WindowsRegistration upserted = hub.upsertRegistration(reg);

Update a Registration

hub.updateRegistration(reg);

Delete a Registration

hub.deleteRegistration(regid);

Get a Single Registration

Registration registration = hub.getRegistration(regid);

All collection queries support $top and continuation tokens.

Get All Registrations in an Azure Notification Hub

CollectionResult registrations = hub.getRegistrations();

Get Registrations With a Given Tag

CollectionResult registrations = hub.getRegistrationsByTag("platform_ios");

Get Registrations By Channel

CollectionResult registrations = hub.getRegistrationsByChannel("devicetoken");

Send Notifications

The Notification object is simply a body with headers, some utility methods help in building the native and template notifications objects.

Send Windows Native Notification

Notification n = Notification.createWindowsNotification("WNS body");

// broadcast
NotificationOutcome outcome = hub.sendNotification(n);

Set<String> tags = new HashSet<String>();
tags.add("platform_ios");
tags.add("platform_android");
hub.sendNotification(n, tags);

// send to tag expression
NotificationOutcome outcome = hub.sendNotification(n, "platform_ios && ! platform_android");

Send an Apple Push Notification

AppleNotification n = Notification.createAppleNotifiation("APNS body");
NotificationOutcome outcome = hub.sendNotification(n);

Analogous for Android, Windows Phone, Kindle Fire and Baidu PNS.

Send a Template Notification

Map<String, String> props =  new HashMap<String, String>();
props.put("prop1", "v1");
props.put("prop2", "v2");
TemplateNotification n = Notification.createTemplateNotification(props);

NotificationOutcome outcome = hub.sendNotification);

Send To An Installation ID

Send flow for Installations is the same as for Registrations. We've just introduced an option to target notification to the particular Installation - just use tag "$InstallationId:{desired-id}". For case above it would look like this:

WindowsNotification n = Notification.createWindowsNotification("WNS body");
NotificationOutcome outcome = hub.sendNotification(n, "$InstallationId:{installation-id}");

Send to a User ID

With the Installation API we now have a new feature that allows you to associate a user ID with an installation and then be able to target it with a send to all devices for that user. To set the user ID for the installation, set the UserId property of the Installation.

Installation installation = new Installation();
installation.setUserId("user1234");

hub.createOrUpdateInstallation(installation);

The user can then be targeted to send a notification with the tag format of $UserId:{USER_ID}, for example like the following:

String jsonPayload = "{\"aps\":{\"alert\":\"Notification Hub test notification\"}}";
Set<String> tags = new HashSet<String>();
tags.add("$UserId:user1234");

AppleNotification n = Notification.createAppleNotification(jsonPayload);
NotificationOutcome outcome = hub.sendNotification(n, tags);

Send To An Installation Template For An Installation

Map<String, String> props =  new HashMap<String, String>();
props.put("value3", "some value");
TemplateNotification n = Notification.createTemplateNotification(prop);
NotificationOutcome outcome = hub.sendNotification(n, "$InstallationId:{installation-id} && tag-for-template1");

Scheduled Send Operations

Note: This feature is only available for STANDARD Tier.

Scheduled send operations are similar to a normal send operations, with a scheduledTime parameter which says when notification should be delivered. The Azure Notification Hubs Service accepts any point of time between now + 5 minutes and now + 7 days.

Schedule Windows Native Send Operation

Calendar c = Calendar.getInstance();
c.add(Calendar.DATE, 1);

Notification n = Notification.createWindowsNotification("WNS body");

NotificationOutcome outcome = hub.scheduleNotification(n, c.getTime())

Import and Export Registrations

Note: This feature is only available for STANDARD Tier.

Sometimes it is required to perform bulk operation against registrations. Usually it is for integration with another system or just to update the tags. It is strongly not recomended to use Get/Update flow if you are modifying thousands of registrations. Import/Export capability is designed to cover the scenario. You provide an access to some blob container under your storage account as a source of incoming data and location for output.

Submit an Export Job

NotificationHubJob job = new NotificationHubJob();
job.setJobType(NotificationHubJobType.ExportRegistrations);
job.setOutputContainerUri("container uri with SAS signature");
job = hub.submitNotificationHubJob(job);

Submit an Import Job

NotificationHubJob job = new NotificationHubJob();
job.setJobType(NotificationHubJobType.ImportCreateRegistrations);
job.setImportFileUri("input file uri with SAS signature");
job.setOutputContainerUri("container uri with SAS signature");
job = hub.submitNotificationHubJob(job)

Wait for Job Completion

while(true) {
    Thread.sleep(1000);
    job = hub.getNotificationHubJob(job.getJobId());
    if(job.getJobStatus() == NotificationHubJobStatus.Completed) {
        break;
    }
}

Get All jobs

List<NotificationHubJobs> allJobs = hub.getAllNotificationHubJobs()

References

Microsoft Azure Notification Hubs Docs

Contributing

For details on contributing to this repository, see the contributing guide.

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, view Microsoft's CLA.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repositories using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Reporting security issues and security bugs

Security issues and bugs should be reported privately, via email, to the Microsoft Security Response Center (MSRC) [email protected]. You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Further information, including the MSRC PGP key, can be found in the Security TechCenter.

License

Azure SDK for Java is licensed under the Apache 2.0 license.

azure-notificationhubs-java-backend's People

Contributors

abshkd avatar aimankhan avatar alessar avatar aziztitu avatar barisakar avatar dependabot[bot] avatar doug-bassett avatar efimovandr avatar fsautomata avatar guillaumelecerf avatar itoys avatar jesshuh avatar liadlivne avatar marstr avatar mpodwysocki avatar piyushjo avatar pmngo avatar stankovski avatar zhangeugenia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

azure-notificationhubs-java-backend's Issues

GCM registration

Hi I am having difficult time registering and sending notification to android GCM.

                NotificationHub hubClient = new NotificationHub(connectionString, hubname);

		GcmRegistration regClient = new GcmRegistration();
		regClient.getTags().add(AndroidDeviceToken);
		hubClient.createRegistration(regClient);

		Notification androidNotif = Notification.createGcmNotification("Notification body");
		hubClient.sendNotification(androidNotif);

This is my sample code - and I am afraid I do not quite understand how or with what should I register to notification hub (I thought that tag should be token). How It should look like or what's flow of registering device?

[BUG] Notification Hubs incompatible with Spring? java.lang.RuntimeException: org.apache.hc.core5.http.ParseException: Invalid protocol version; error at offset 0: <[0x2e][0x2f][0x30][0x31][0x32][0x33][0x34][0x35][0x36][0x37][0x38][0x39][0x3a][0x3b][0x3c][0x3d][0x3e]>

Describe the bug
When attempting to send a simple notification using com.windowsazure:Notification-Hubs-java-sdk:1.0.3 using a brand new, empty project that does nothing else, it appears that if Spring is also a dependency in the build file, this exception occurs when we attempt to send the notification.

Exception or Stack Trace
java.lang.RuntimeException: org.apache.hc.core5.http.ParseException: Invalid protocol version; error at offset 0: <[0x2e][0x2f][0x30][0x31][0x32][0x33][0x34][0x35][0x36][0x37][0x38][0x39][0x3a][0x3b][0x3c][0x3d][0x3e]>
at com.windowsazure.messaging.SyncCallback.failed(SyncCallback.java:53)
at com.windowsazure.messaging.NotificationHubsService$1.failed(NotificationHubsService.java:78)
at org.apache.hc.core5.concurrent.BasicFuture.failed(BasicFuture.java:138)
at org.apache.hc.core5.concurrent.ComplexFuture.failed(ComplexFuture.java:86)
at org.apache.hc.client5.http.impl.async.InternalAbstractHttpAsyncClient$1$3.failed(InternalAbstractHttpAsyncClient.java:345)
at org.apache.hc.client5.http.impl.async.AsyncRedirectExec$1.failed(AsyncRedirectExec.java:246)
at org.apache.hc.client5.http.impl.async.AsyncHttpRequestRetryExec$1.failed(AsyncHttpRequestRetryExec.java:167)
at org.apache.hc.client5.http.impl.async.AsyncProtocolExec$1.failed(AsyncProtocolExec.java:281)
at org.apache.hc.client5.http.impl.async.HttpAsyncMainClientExec$1.failed(HttpAsyncMainClientExec.java:124)
at org.apache.hc.core5.http.impl.nio.ClientHttp1StreamHandler.failed(ClientHttp1StreamHandler.java:295)
at org.apache.hc.core5.http.impl.nio.ClientHttp1StreamDuplexer.terminate(ClientHttp1StreamDuplexer.java:193)
at org.apache.hc.core5.http.impl.nio.AbstractHttp1StreamDuplexer.shutdownSession(AbstractHttp1StreamDuplexer.java:164)
at org.apache.hc.core5.http.impl.nio.AbstractHttp1StreamDuplexer.onException(AbstractHttp1StreamDuplexer.java:404)
at org.apache.hc.core5.http.impl.nio.AbstractHttp1IOEventHandler.inputReady(AbstractHttp1IOEventHandler.java:66)
at org.apache.hc.core5.http.impl.nio.ClientHttp1IOEventHandler.inputReady(ClientHttp1IOEventHandler.java:41)
at org.apache.hc.core5.reactor.ssl.SSLIOSession.decryptData(SSLIOSession.java:575)
at org.apache.hc.core5.reactor.ssl.SSLIOSession.access$400(SSLIOSession.java:72)
at org.apache.hc.core5.reactor.ssl.SSLIOSession$1.inputReady(SSLIOSession.java:172)
at org.apache.hc.core5.reactor.InternalDataChannel.onIOEvent(InternalDataChannel.java:133)
at org.apache.hc.core5.reactor.InternalChannel.handleIOEvent(InternalChannel.java:51)
at org.apache.hc.core5.reactor.SingleCoreIOReactor.processEvents(SingleCoreIOReactor.java:178)
at org.apache.hc.core5.reactor.SingleCoreIOReactor.doExecute(SingleCoreIOReactor.java:127)
at org.apache.hc.core5.reactor.AbstractSingleCoreIOReactor.execute(AbstractSingleCoreIOReactor.java:85)
at org.apache.hc.core5.reactor.IOReactorWorker.run(IOReactorWorker.java:44)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: org.apache.hc.core5.http.ParseException: Invalid protocol version; error at offset 0: <[0x2e][0x2f][0x30][0x31][0x32][0x33][0x34][0x35][0x36][0x37][0x38][0x39][0x3a][0x3b][0x3c][0x3d][0x3e]>
at org.apache.hc.core5.http.message.BasicLineParser.parseProtocolVersion(BasicLineParser.java:110)
at org.apache.hc.core5.http.message.BasicLineParser.parseStatusLine(BasicLineParser.java:181)
at org.apache.hc.core5.http.impl.nio.DefaultHttpResponseParser.createMessage(DefaultHttpResponseParser.java:83)
at org.apache.hc.core5.http.impl.nio.DefaultHttpResponseParser.createMessage(DefaultHttpResponseParser.java:44)
at org.apache.hc.core5.http.impl.nio.AbstractMessageParser.parseHeadLine(AbstractMessageParser.java:115)
at org.apache.hc.core5.http.impl.nio.AbstractMessageParser.parse(AbstractMessageParser.java:167)
at org.apache.hc.core5.http.impl.nio.AbstractMessageParser.parse(AbstractMessageParser.java:51)
at org.apache.hc.core5.http.impl.nio.AbstractHttp1StreamDuplexer.parseMessageHead(AbstractHttp1StreamDuplexer.java:256)
at org.apache.hc.core5.http.impl.nio.AbstractHttp1StreamDuplexer.onInput(AbstractHttp1StreamDuplexer.java:287)
at org.apache.hc.core5.http.impl.nio.AbstractHttp1IOEventHandler.inputReady(AbstractHttp1IOEventHandler.java:64)
... 11 more

To Reproduce

  1. Create a simple Spring project with no content
  2. Add the following to the build.gradle file:
plugins {
	id 'java'
	id 'org.springframework.boot' version '3.0.1'
	id 'io.spring.dependency-management' version '1.1.0'
}

sourceCompatibility = '17'

repositories {
	mavenCentral()
	google()
}

dependencies {
	implementation 'org.springframework.boot:spring-boot-starter-web'
	testImplementation 'org.springframework.boot:spring-boot-starter-test'

	testImplementation 'junit:junit:4.13.2'

	// Azure Notification Hub
	implementation 'com.windowsazure:Notification-Hubs-java-sdk:1.0.3'
	testImplementation 'com.windowsazure:Notification-Hubs-java-sdk:1.0.3'
}

tasks.named('test') {
	useJUnitPlatform()
}

// if you omit this you will get the following exception:
// java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class org.slf4j.impl.SimpleLoggerFactory loaded from ...PATH...). If you are using WebLogic you will need to add 'org.slf4j' to prefer-application-packages in WEB-INF/weblogic.xml: org.slf4j.impl.SimpleLoggerFactory
configurations {
	all {
		exclude group: 'ch.qos.logback', module: 'logback-classic'
	}
}

  1. Create a simple unit test to confirm the project can run, e.g.
	@Test
	void testCanIRun() {
		assertEquals(4,2+2);
	}

This test should run and pass.

  1. Now create a simple unit test to send a simple notification (see snippet below)

Code Snippet

package com.foo.bar;

import com.windowsazure.messaging.Notification;
import com.windowsazure.messaging.NotificationHub;
import org.junit.jupiter.api.Test;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.test.context.SpringBootTest;
import static org.junit.Assert.assertEquals;


@SpringBootTest
public class PushnotificationsApplicationTests {

	private static final String ARBITRARY_TOKEN = "TOKENGOESHERE";
	String SANDBOX_CONNECTION_STRING = "CONNSTRINGGOESHERE";
	String SANDBOX_HUB = "HUBGOESHERE";
	
	private final Logger log = LoggerFactory.getLogger(PushnotificationsApplicationTests.class);
	String prodConnectionString;
	String prodHubName;
	String sandboxConnectionString;
	String sandboxHubName;

	@Test
	void contextLoads() {
	}

	@Test
	void testCanIRun() {
		assertEquals(4,2+2);
	}

	@Test
	public void testSendASimpleNotification() {
		try {
			
			setSandBoxHubName(SANDBOX_HUB);
			setSandboxConnectionString(SANDBOX_CONNECTION_STRING);
			boolean useSandbox = true;
			boolean result = sendSingleNotification("notification content", ARBITRARY_TOKEN, useSandbox);
			assert(result);
		} catch (Exception e) {
			log.error("Azure Push Notification failed.", e);
		}
	}

	// HELPER METHODS


	public boolean sendSingleNotification(String content, String token, boolean isSandbox) throws Exception {
		try {
			String message = "{\"notification\":{\"title\":\"This is the title\", \"body\": \"this is the body\"}, \"data\": {\"property1\": \"foo\", \"property2\": 42}}";
			NotificationHub hub = getNotificatonHub(isSandbox);
			Notification notification = getNotification(message);
			hub.sendDirectNotification(notification, token);
			return true;
		} catch (Exception e) {
			log.error("Azure Push Notification failed.", e);
		}
		return false;
	}

	private NotificationHub getNotificatonHub(boolean isSandbox) {
		return new NotificationHub(
				isSandbox ? sandboxConnectionString : prodConnectionString,
				isSandbox ? sandboxHubName : prodHubName);
	}

	private Notification getNotification(String content) {
		return Notification.createFcmNotification(content);
	}

	public void setSandBoxHubName(String s) {
		sandboxHubName = s;
	}

	public void setSandboxConnectionString(String s) {
		sandboxConnectionString = s;
	}

}

Expected behavior
Expected a notification to be sent to the device whose token corresponds with ARBITRARY_TOKEN

Screenshots
If applicable, add screenshots to help explain your problem.

Setup (please complete the following information):

  • OS: Windows 10
  • IDE : IntelliJ IDEA 2021.3.3
  • Version of the Library used:
    • Azure Notification Hub: 1.0.3
    • Spring: 3.0.1 (this has also been tested with versions down below 2.6.0 and Java versions to version 11. All combinations fail)

Additional context
This was also tried with a simple Android app project and simple notifications succeeded, suggesting that classes involved in the Android gradle plugin(s) or dependencies are possibly superseding the classes that are causing the Invalid Protocol Error in the non-android app.

Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issue as an incomplete report. Please do not provide any private information in this bug report.

  • [X ] Bug Description Added
  • [X ] Repro Steps Added
  • [X ] Setup information Added

Apple device token (64 characters) is not accepted by ANH

I tried, using this sdk, to register, for example, the following devicetoken (optained via device):
96d6bb5d 412881d3 0046f5bf 5616bead df6aa4ab e57987bc cc4b5c23 209dbb0c

I tried the following things:

  • as is; with spaces
  • remove spaces
  • dashes instead of spaces

But they all give next error in return:
com.windowsazure.messaging.NotificationHubsException: Error: HTTP/1.1 400 Bad Request - 400One or more characters in device token is not a hexadecimal digit..TrackingId:c9b0fa60-c8e7-4281-9f6c-efd7ed2b19a2_G18,TimeStamp:6/19/2018 11:57:33 AM

it seems to only accept 32 characters hexidecimal string (only first 32 characters works fine for the registration: 96d6bb5d412881d30046f5bf5616bead )

I added the library via Maven:
groupId: com.windowsazure
artifactId: NotificationHubs
version: 0.0.5

In com.windowsazure.messaging.NotificationHub next version is mentioned:
APIVERSION = "?api-version=2015-04"

Is this version too old?
What am I doing wrong?
Is this library outdated/depricated?
Is there an other/ better way to make this work?

thanks in advance for your response

[BUG] Connection closed while dispatching a push notification

Describe the bug
After updating from 'com.windowsazure:Notification-Hubs-java-sdk:0.4.2' to 'com.windowsazure:Notification-Hubs-java-sdk:1.0.4'
we noticed that sometimes we are getting azure hub failures with connection closed.
Usually the dispatching succeeds.

Exception or Stack Trace
com.dodokaa.notification.dispatcher.client.pnprovider.exception.PnProviderException: Push notification send failed: Connection is closed
at com.dodokaa.notification.dispatcher.client.pnprovider.service.AzurePushNotificationDispatcherImpl.lambda$sendDirectNotification$10(AzurePushNotificationDispatcherImpl.java:176)
at com.dodokaa.notification.dispatcher.client.pnprovider.service.AzurePushNotificationDispatcherImpl$2.failed(AzurePushNotificationDispatcherImpl.java:593)
at com.windowsazure.messaging.NotificationHubsService$1.failed(NotificationHubsService.java:78)
at datadog.trace.instrumentation.apachehttpclient5.TraceContinuedFutureCallback.failDelegate(TraceContinuedFutureCallback.java:105)
at datadog.trace.instrumentation.apachehttpclient5.TraceContinuedFutureCallback.failed(TraceContinuedFutureCallback.java:75)
at org.apache.hc.core5.concurrent.BasicFuture.failed(BasicFuture.java:138)
at org.apache.hc.core5.concurrent.ComplexFuture.failed(ComplexFuture.java:79)
at org.apache.hc.client5.http.impl.async.InternalAbstractHttpAsyncClient$1.failed(InternalAbstractHttpAsyncClient.java:326)
at org.apache.hc.client5.http.impl.async.AsyncRedirectExec$1.failed(AsyncRedirectExec.java:246)
at org.apache.hc.client5.http.impl.async.AsyncHttpRequestRetryExec$1.failed(AsyncHttpRequestRetryExec.java:168)
at org.apache.hc.client5.http.impl.async.AsyncProtocolExec$1.failed(AsyncProtocolExec.java:295)
at org.apache.hc.client5.http.impl.async.H2AsyncMainClientExec$1.failed(H2AsyncMainClientExec.java:119)
at org.apache.hc.core5.http.nio.command.RequestExecutionCommand.failed(RequestExecutionCommand.java:101)
at org.apache.hc.core5.http2.impl.nio.AbstractH2StreamMultiplexer.onDisconnect(AbstractH2StreamMultiplexer.java:580)
at org.apache.hc.core5.http2.impl.nio.AbstractH2IOEventHandler.disconnected(AbstractH2IOEventHandler.java:96)
at org.apache.hc.core5.http2.impl.nio.ClientH2IOEventHandler.disconnected(ClientH2IOEventHandler.java:39)
at org.apache.hc.core5.reactor.ssl.SSLIOSession$1.disconnected(SSLIOSession.java:247)
at org.apache.hc.core5.reactor.InternalDataChannel.disconnected(InternalDataChannel.java:204)
at org.apache.hc.core5.reactor.SingleCoreIOReactor.processClosedSessions(SingleCoreIOReactor.java:231)
at org.apache.hc.core5.reactor.SingleCoreIOReactor.doExecute(SingleCoreIOReactor.java:133)
at org.apache.hc.core5.reactor.AbstractSingleCoreIOReactor.execute(AbstractSingleCoreIOReactor.java:86)
at org.apache.hc.core5.reactor.IOReactorWorker.run(IOReactorWorker.java:44)
at java.base/java.lang.Thread.run(Thread.java:833)

To Reproduce
update from 'com.windowsazure:Notification-Hubs-java-sdk:0.4.2' to 'com.windowsazure:Notification-Hubs-java-sdk:1.0.4'

Expected behavior
We should not have connection closed issues since before the library update we received no issues.

Setup:

  • Version of the Library used: 'com.windowsazure:Notification-Hubs-java-sdk:1.0.4'

Additional context
I have noticed the following change in the sendDirectNotificationAsync functions FutureCallback parameter:
void sendDirectNotificationAsync(
Notification notification,
String deviceHandle,
FutureCallback callback
);.

import org.apache.http.concurrent.FutureCallback; <--- com.windowsazure:Notification-Hubs-java-sdk:0.4.2
import org.apache.hc.core5.concurrent.FutureCallback; <--- 'com.windowsazure:Notification-Hubs-java-sdk:1.0.4'

Information Checklist

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added

Build & Test Failure

Hi,

Please advice.

Results :

Failed tests: InstallationWnsFull(com.windowsazure.messaging.InstallationParse
Test)

Tests run: 24, Failures: 1, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.371 s
[INFO] Finished at: 2015-10-12T13:33:07+08:00
[INFO] Final Memory: 7M/16M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.
12.4:test (default-test) on project NotificationHubs: There are test failures.
[ERROR]
[ERROR] Please refer to C:\apache-maven-3.3.3\NotificationHubs\target\surefire-r
eports for the individual test results.
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal o
rg.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on proj
ect NotificationHubs: There are test failures.

Please refer to C:\apache-maven-3.3.3\NotificationHubs\target\surefire-reports f
or the individual test results.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThre
adedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(Lifecycl
eStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Laun
cher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.jav
a:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(La
uncher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:
356)
Caused by: org.apache.maven.plugin.MojoFailureException: There are test failures
.

Please refer to C:\apache-maven-3.3.3\NotificationHubs\target\surefire-reports f
or the individual test results.
at org.apache.maven.plugin.surefire.SurefireHelper.reportExecution(Suref
ireHelper.java:83)
at org.apache.maven.plugin.surefire.SurefirePlugin.writeSummary(Surefire
Plugin.java:176)
at org.apache.maven.plugin.surefire.SurefirePlugin.handleSummary(Surefir
ePlugin.java:150)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPre
conditionsChecked(AbstractSurefireMojo.java:650)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(Abstrac
tSurefireMojo.java:586)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(Default
BuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:208)
... 20 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureExc
eption

Build in jdk1.5

Hi,

May I check whether this project can build and using in jdk1.5?
If no problem, could you advice how to do it?
Thank you.

Regards,
Ted

iOS not receiving pending push after turn on Internet from Azure Notification Hub

I'm working on integrating Azure Notification Hub with a Java backend to send notifications of the latest news to Android and iOS devices.

In recent days I've identified the following issue, iOS devices don't receive notifications that were sent when the devices were off the internet. Notifications are lost and are not sent back to devices when the internet is turned on.

To overcome this problem I added the value of the expiration date, as you can see in the example below, but the problem persists.

    Date now = new Date();
    Date expiry = new Date(now.getTime() + 259200000L);

    NotificationHub hub = new NotificationHub("connectionString", "hubPath");

    String alert = "{\"aps\":{\"alert\":\""+notification.getBody()+"\",\"body\":\""+notification.getTitle()+"\",\"sound\":\"default\",\"id-news\":\""+notification.getIdNews()+"\"}}";
    Notification ios = Notification.createAppleNotification(alert,expiry);
    hub.sendNotification(ios);

A second option I added the ServiceBusNotification-Apns-Expiry values and apns-expiration directly in the header but the problem continues.

    Date now = new Date();
    Date expiry = new Date(now.getTime() + 259200000L);

    SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss");
    formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
    String expiryString = formatter.format(expiry.getTime());
    
    Map<String, String> headers = new HashMap<>();
    headers.put("ServiceBusNotification-Format", "apple");
    headers.put("apns-push-type", "alert");
    headers.put("apns-priority", "10");
    headers.put("ServiceBusNotification-Apns-Expiry", expiryString);
    headers.put("apns-expiration", "259200000");

    NotificationHub hub = new NotificationHub("connectionString", "hubPath");

    String alert = "{\"aps\":{\"alert\":\""+notification.getBody()+"\",\"body\":\""+notification.getTitle()+"\",\"sound\":\"default\",\"id-news\":\""+notification.getIdNews()+"\"}}"; 
    Notification ios = Notification.createAppleNotification(alert,headers);
    hub.sendNotification(ios);

Unable to successfully send android notification

We are trying to send a push notification on android device using GCM/FCM with the latest Notification-Hubs-java-sdk version (1.0.4).

We wrote the same code in dotnet and we can successully send a notification. Using the java sdk we see that the notification are received on notification hub but they never pass to successfull status on dashboard.

Watching the situation on firebase with the java code none of the notification are delivered to the account. Instead, the same hub, used by dotnet delivered notification successfully.

Working Dotnet code

String TOKEN = "XXXXX";
String CONNECTION_STRING = "Endpoint=sb://joinon-notificationhub-dev.servicebus.windows.net/;SharedAccessKeyName=joinon-notificationhub-dev;SharedAccessKey=YYYYY";
String HUB_NAME = "joinon-notificationhub-dev";
String BODY = "{\"data\":{\"title\": \"maco: TESTME\",\"body\" : \"Nessuna perdita d’acqua nella stanza sensori.\", \"icon\": \"notification/water_off\"}, \"notification\":{\"title\": \"maco: Nessun allarme perdita acqua rilevato\",\"body\" : \"Nessuna perdita d’acqua nella stanza sensori.\"}}";

String installationId = "installationIdTest";
NotificationHubClient _notificationHub = NotificationHubClient.CreateClientFromConnectionString(CONNECTION_STRING, HUB_NAME);

Installation installation = new Installation();
installation.InstallationId = installationId;
installation.PushChannel = TOKEN;
installation.Platform = NotificationPlatform.Fcm;
await _notificationHub.CreateOrUpdateInstallationAsync(installation);

Task<NotificationOutcome> outconme = _notificationHub.SendFcmNativeNotificationAsync(BODY, "$InstallationId:{" + installationId + "}", CancellationToken.None);

await _notificationHub.DeleteInstallationAsync(installation.InstallationId);

NOT Working Java code

String TOKEN = "XXXX";
String CONNECTION_STRING = "Endpoint=sb://joinon-notificationhub-dev.servicebus.windows.net/;SharedAccessKeyName=joinon-notificationhub-dev;SharedAccessKey=YYYYY";
String HUB_NAME = "joinon-notificationhub-dev";
String BODY = "{\"data\":{\"title\": \"maco: TESTME\",\"body\" : \"Nessuna perdita d’acqua nella stanza sensori.\", \"icon\": \"notification/water_off\"}, \"notification\":{\"title\": \"maco: Nessun allarme perdita acqua rilevato\",\"body\" : \"Nessuna perdita d’acqua nella stanza sensori.\"}}";

NotificationHub notificationHub = new NotificationHub(CONNECTION_STRING, HUB_NAME);

String installationId = "installationIdTest";
Installation installation = new Installation(UUID.randomUUID().toString(), NotificationPlatform.Gcm, TOKEN);

notificationHub.createOrUpdateInstallation(installation);
Notification n = Notification.createFcmNotification(BODY);
NotificationOutcome outcome = notificationHub.sendNotification(n, "$InstallationId:{" + installationId + "}");

notificationHub.deleteInstallation(installationId);

Java SDK deleteRegistration returning 400 Bad Request for FCM devices

I'm not been able to unregister fcm devices:

  • Registration:
    registration = new FcmRegistration(command.getDeviceId()); NotificationHub hub = new NotificationHub(connectionString, notificationHubPath); registration = hub.createRegistration(registration);

  • Unregistration:
    NotificationHub hub = new NotificationHub(connectionString, notificationHubPath); final CollectionResult result = hub.getRegistrationsByTag(tag); final List<Registration> registrations = result.getRegistrations(); registrations.stream().forEach(registration -> { hub.deleteRegistration(registration.getRegistrationId()); }

The unregistration process return a response like this:

com.windowsazure.messaging.NotificationHubsException: Error: HTTP/1.1 400 Bad Request - 400The notification hub was created with an older API version. Either re-create the notification hub or use an older API version, 2017-11, to access it.TrackingId:7c0e379b-b80e-4eb9-bb45-d808aa004908_G5,TimeStamp:2/11/2019 4:23:02 PM

Could someone point me what I'm doing wrong or if there is an issue with the API?

Value of ConnectionString To Instantiate NamespaceManager

NamespaceManager requires "connection string". What should be the value of it.
Tried below values(1&2) but got "java.lang.RuntimeException: Error: HTTP/1.1 401 Unauthorized - 401InvalidSignature: The token has an invalid signature..TrackingId:99ed6a26-42fa-471c-bfab-b7a21fa7d834_G0,TimeStamp:5/23/2016 5:36:33 PM"

1.DefaultListenSharedAccessSignature:
Endpoint=sb://{XXXXX}.servicebus.windows.net/;SharedAccessKeyName=DefaultListenSharedAccessSignature;SharedAccessKey=KKKKKKKKKKKKKKKKKKKKKKKKK
2.DefaultFullSharedAccessSignature:
Endpoint=sb://{XXXXX}.servicebus.windows.net/;SharedAccessKeyName=DefaultFullSharedAccessSignature;SharedAccessKey=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

[QUERY] Missing notifications on ios 13+ with apns

Query/Question
I have a notification hub which is able to deliver notifications for old iOS versions. I began updating gaps introduced by later releases of ios, but I can't get it to work.

My code is quite basic:

public class App {

  public static void main(String[] args) throws Exception {
    String hubId = "...";
    NotificationHub hub = new NotificationHub(
        "Endpoint=sb://...",
        hubId);

    Map<String, String> headers = new HashMap<>();
    headers.put("apns-push-type", "alert");
    headers.put("apns-priority", "10");

    String src = "{'aps': {'title': 'Alert notification', 'body': '" + LocalDateTime.now() + ", have (" + new Random().nextInt(10) + ") alerts'}}";
    String body = src.replaceAll("\'", "\"");

    Notification notification = Notification.createAppleNotification(body, headers);
    NotificationOutcome outcome = hub.sendNotification(notification, new HashSet<>(Arrays.asList("_valid_azure_device_tag_")));
    System.out.println(outcome.getNotificationId() + " " + outcome.getTrackingId());

    if (outcome.getNotificationId() != null) {
      NotificationTelemetry telemetry = hub.getNotificationTelemetry(outcome.getNotificationId());
      System.out.println(telemetry);
    }
  }

}

Why is this not a Bug or a feature Request?
I am not quite sure if above method is supported given #48 is closed. I do get a tracking id but no notification id. Repeating same operation via azure console returns "Successfully sent test message. Outcome: {0 passed, 0 failed}. Please see result section for details."

Setup (please complete the following information if applicable):

  • Notification-Hubs-java-sdk v 1.1.0
  • Java 11

Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issue as an incomplete report. Please do not provide any private information in this bug report.

  • Query Added
  • Setup information Added

Building error

Hello,
i have been trying to build the project, but i keep getting this error.

[DEBUG] file InstallationMinimal has a filtered file extension
[DEBUG] copy C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\test\com\windowsazure\messaging\InstallationMinimal to C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\target\test-classes\com
windowsazure\messaging\InstallationMinimal
[DEBUG] file InstallationMinimalNoSpaces has a filtered file extension
[DEBUG] copy C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\test\com\windowsazure\messaging\InstallationMinimalNoSpaces to C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\target\test-clas
ses\com\windowsazure\messaging\InstallationMinimalNoSpaces
[DEBUG] file InstallationWnsFull has a filtered file extension
[DEBUG] copy C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\test\com\windowsazure\messaging\InstallationWnsFull to C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\target\test-classes\com
windowsazure\messaging\InstallationWnsFull
[DEBUG] file InstallationWnsFullNoSpaces has a filtered file extension
[DEBUG] copy C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\test\com\windowsazure\messaging\InstallationWnsFullNoSpaces to C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\target\test-clas
ses\com\windowsazure\messaging\InstallationWnsFullNoSpaces
[DEBUG] file MpnsNativeRegistrationNoType has a filtered file extension
[DEBUG] copy C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\test\com\windowsazure\messaging\MpnsNativeRegistrationNoType to C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\target\test-cla
sses\com\windowsazure\messaging\MpnsNativeRegistrationNoType
[DEBUG] file MpnsTemplateRegistrationType has a filtered file extension
[DEBUG] copy C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\test\com\windowsazure\messaging\MpnsTemplateRegistrationType to C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\target\test-cla
sses\com\windowsazure\messaging\MpnsTemplateRegistrationType
[DEBUG] file NotificationHubDescriptionRealLifeFeed has a filtered file extension
[DEBUG] copy C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\test\com\windowsazure\messaging\NotificationHubDescriptionRealLifeFeed to C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\targe
t\test-classes\com\windowsazure\messaging\NotificationHubDescriptionRealLifeFeed
[DEBUG] file NotificationHubDescriptionWithAllCredentials has a filtered file extension
[DEBUG] copy C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\test\com\windowsazure\messaging\NotificationHubDescriptionWithAllCredentials to C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs
\target\test-classes\com\windowsazure\messaging\NotificationHubDescriptionWithAllCredentials
[DEBUG] file NotificationHubDescriptionWithAllCredentialsNoSpaces has a filtered file extension
[DEBUG] copy C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\test\com\windowsazure\messaging\NotificationHubDescriptionWithAllCredentialsNoSpaces to C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\Notifica
tionHubs\target\test-classes\com\windowsazure\messaging\NotificationHubDescriptionWithAllCredentialsNoSpaces
[DEBUG] file NotificationHubJobFeed has a filtered file extension
[DEBUG] copy C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\test\com\windowsazure\messaging\NotificationHubJobFeed to C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\target\test-classes\c
om\windowsazure\messaging\NotificationHubJobFeed
[DEBUG] file NotificationHubJobIncoming has a filtered file extension
[DEBUG] copy C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\test\com\windowsazure\messaging\NotificationHubJobIncoming to C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\target\test-class
es\com\windowsazure\messaging\NotificationHubJobIncoming
[DEBUG] file NotificationHubJobOutgoing has a filtered file extension
[DEBUG] copy C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\test\com\windowsazure\messaging\NotificationHubJobOutgoing to C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\target\test-class
es\com\windowsazure\messaging\NotificationHubJobOutgoing
[DEBUG] file PartialUpdatesNoSpaces has a filtered file extension
[DEBUG] copy C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\test\com\windowsazure\messaging\PartialUpdatesNoSpaces to C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\target\test-classes\c
om\windowsazure\messaging\PartialUpdatesNoSpaces
[DEBUG] file RegistrationCollection has a filtered file extension
[DEBUG] copy C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\test\com\windowsazure\messaging\RegistrationCollection to C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\target\test-classes\c
om\windowsazure\messaging\RegistrationCollection
[DEBUG] file WindowsNativeRegistrationNoType has a filtered file extension
[DEBUG] copy C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\test\com\windowsazure\messaging\WindowsNativeRegistrationNoType to C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\target\test-
classes\com\windowsazure\messaging\WindowsNativeRegistrationNoType
[DEBUG] file WindowsNativeRegistrationType has a filtered file extension
[DEBUG] copy C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\test\com\windowsazure\messaging\WindowsNativeRegistrationType to C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\target\test-cl
asses\com\windowsazure\messaging\WindowsNativeRegistrationType
[DEBUG] file WindowsTemplateRegistrationNoType has a filtered file extension
[DEBUG] copy C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\test\com\windowsazure\messaging\WindowsTemplateRegistrationNoType to C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\target\tes
t-classes\com\windowsazure\messaging\WindowsTemplateRegistrationNoType
[DEBUG] file WindowsTemplateRegistrationType has a filtered file extension
[DEBUG] copy C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\test\com\windowsazure\messaging\WindowsTemplateRegistrationType to C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\target\test-
classes\com\windowsazure\messaging\WindowsTemplateRegistrationType
[DEBUG] no use filter components
[INFO]
[INFO] --- maven-compiler-plugin:3.0:testCompile (default-testCompile) @ NotificationHubs ---
[DEBUG] Configuring mojo org.apache.maven.plugins:maven-compiler-plugin:3.0:testCompile from plugin realm ClassRealm[plugin>org.apache.maven.plugins:maven-compiler-plugin:3.0, parent: sun.misc.Launcher$AppClassLoader@5c647e05]
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-compiler-plugin:3.0:testCompile' with basic configurator -->
DEBUG basedir = C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs
DEBUG buildDirectory = C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\target
DEBUG classpathElements = [C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\target\test-classes, C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\target\classes, C:\Users\Administrat
or.m2\repository\junit\junit\4.11\junit-4.11.jar, C:\Users\Administrator.m2\repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar, C:\Users\Administrator.m2\repository\commons-codec\commons-codec\1.8\commons-codec-1.8.jar, C:\Users\Administrator.m2\repository\org\apache\commons\commons-digester3\3.2\commo
ns-digester3-3.2.jar, C:\Users\Administrator.m2\repository\cglib\cglib\2.2.2\cglib-2.2.2.jar, C:\Users\Administrator.m2\repository\asm\asm\3.3.1\asm-3.3.1.jar, C:\Users\Administrator.m2\repository\commons-beanutils\commons-beanutils\1.8.3\commons-beanutils-1.8.3.jar, C:\Users\Administrator.m2\repository\commons-log
ging\commons-logging\1.1.1\commons-logging-1.1.1.jar, C:\Users\Administrator.m2\repository\org\apache\httpcomponents\httpasyncclient\4.0.2\httpasyncclient-4.0.2.jar, C:\Users\Administrator.m2\repository\org\apache\httpcomponents\httpcore\4.3.2\httpcore-4.3.2.jar, C:\Users\Administrator.m2\repository\org\apache\httpc
omponents\httpcore-nio\4.3.2\httpcore-nio-4.3.2.jar, C:\Users\Administrator.m2\repository\org\apache\httpcomponents\httpclient\4.3.5\httpclient-4.3.5.jar, C:\Users\Administrator.m2\repository\commons-io\commons-io\2.4\commons-io-2.4.jar, C:\Users\Administrator.m2\repository\com\google\code\gson\gson\2.3.1\gson-2.3.1
.jar]
DEBUG compileSourceRoots = [C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\test]
DEBUG compilerId = javac
DEBUG debug = true
DEBUG failOnError = true
DEBUG forceJavacCompilerUse = false
DEBUG fork = false
DEBUG generatedTestSourcesDirectory = C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\target\generated-test-sources\test-annotations
DEBUG mojoExecution = org.apache.maven.plugins:maven-compiler-plugin:3.0:testCompile {execution: default-testCompile}
DEBUG optimize = false
DEBUG outputDirectory = C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\target\test-classes
DEBUG showDeprecation = false
DEBUG showWarnings = false
DEBUG skipMultiThreadWarning = false
DEBUG source = 1.7
DEBUG staleMillis = 0
DEBUG target = 1.7
DEBUG verbose = false
DEBUG mavenSession = org.apache.maven.execution.MavenSession@4c4d27c8
DEBUG session = org.apache.maven.execution.MavenSession@4c4d27c8
[DEBUG] -- end configuration --
[DEBUG] Using compiler 'javac'.
[DEBUG] Source directories: [C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\test]
[DEBUG] Classpath: [C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\target\test-classes
C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\target\classes
C:\Users\Administrator.m2\repository\junit\junit\4.11\junit-4.11.jar
C:\Users\Administrator.m2\repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar
C:\Users\Administrator.m2\repository\commons-codec\commons-codec\1.8\commons-codec-1.8.jar
C:\Users\Administrator.m2\repository\org\apache\commons\commons-digester3\3.2\commons-digester3-3.2.jar
C:\Users\Administrator.m2\repository\cglib\cglib\2.2.2\cglib-2.2.2.jar
C:\Users\Administrator.m2\repository\asm\asm\3.3.1\asm-3.3.1.jar
C:\Users\Administrator.m2\repository\commons-beanutils\commons-beanutils\1.8.3\commons-beanutils-1.8.3.jar
C:\Users\Administrator.m2\repository\commons-logging\commons-logging\1.1.1\commons-logging-1.1.1.jar
C:\Users\Administrator.m2\repository\org\apache\httpcomponents\httpasyncclient\4.0.2\httpasyncclient-4.0.2.jar
C:\Users\Administrator.m2\repository\org\apache\httpcomponents\httpcore\4.3.2\httpcore-4.3.2.jar
C:\Users\Administrator.m2\repository\org\apache\httpcomponents\httpcore-nio\4.3.2\httpcore-nio-4.3.2.jar
C:\Users\Administrator.m2\repository\org\apache\httpcomponents\httpclient\4.3.5\httpclient-4.3.5.jar
C:\Users\Administrator.m2\repository\commons-io\commons-io\2.4\commons-io-2.4.jar
C:\Users\Administrator.m2\repository\com\google\code\gson\gson\2.3.1\gson-2.3.1.jar]
[DEBUG] Output directory: C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\target\test-classes
[DEBUG] CompilerReuseStrategy: reuseCreated
[INFO] Changes detected - recompiling the module!
[DEBUG] Classpath:
[DEBUG] C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\target\test-classes
[DEBUG] C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\target\classes
[DEBUG] C:\Users\Administrator.m2\repository\junit\junit\4.11\junit-4.11.jar
[DEBUG] C:\Users\Administrator.m2\repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar
[DEBUG] C:\Users\Administrator.m2\repository\commons-codec\commons-codec\1.8\commons-codec-1.8.jar
[DEBUG] C:\Users\Administrator.m2\repository\org\apache\commons\commons-digester3\3.2\commons-digester3-3.2.jar
[DEBUG] C:\Users\Administrator.m2\repository\cglib\cglib\2.2.2\cglib-2.2.2.jar
[DEBUG] C:\Users\Administrator.m2\repository\asm\asm\3.3.1\asm-3.3.1.jar
[DEBUG] C:\Users\Administrator.m2\repository\commons-beanutils\commons-beanutils\1.8.3\commons-beanutils-1.8.3.jar
[DEBUG] C:\Users\Administrator.m2\repository\commons-logging\commons-logging\1.1.1\commons-logging-1.1.1.jar
[DEBUG] C:\Users\Administrator.m2\repository\org\apache\httpcomponents\httpasyncclient\4.0.2\httpasyncclient-4.0.2.jar
[DEBUG] C:\Users\Administrator.m2\repository\org\apache\httpcomponents\httpcore\4.3.2\httpcore-4.3.2.jar
[DEBUG] C:\Users\Administrator.m2\repository\org\apache\httpcomponents\httpcore-nio\4.3.2\httpcore-nio-4.3.2.jar
[DEBUG] C:\Users\Administrator.m2\repository\org\apache\httpcomponents\httpclient\4.3.5\httpclient-4.3.5.jar
[DEBUG] C:\Users\Administrator.m2\repository\commons-io\commons-io\2.4\commons-io-2.4.jar
[DEBUG] C:\Users\Administrator.m2\repository\com\google\code\gson\gson\2.3.1\gson-2.3.1.jar
[DEBUG] Source roots:
[DEBUG] C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\test
[DEBUG] Command line options:
[DEBUG] -d C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\target\test-classes -classpath C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\target\test-classes;C:\Users\Administrator\Documen
ts\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\target\classes;C:\Users\Administrator.m2\repository\junit\junit\4.11\junit-4.11.jar;C:\Users\Administrator.m2\repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar;C:\Users\Administrator.m2\repository\commons-codec\commons-
codec\1.8\commons-codec-1.8.jar;C:\Users\Administrator.m2\repository\org\apache\commons\commons-digester3\3.2\commons-digester3-3.2.jar;C:\Users\Administrator.m2\repository\cglib\cglib\2.2.2\cglib-2.2.2.jar;C:\Users\Administrator.m2\repository\asm\asm\3.3.1\asm-3.3.1.jar;C:\Users\Administrator.m2\repository\commons
-beanutils\commons-beanutils\1.8.3\commons-beanutils-1.8.3.jar;C:\Users\Administrator.m2\repository\commons-logging\commons-logging\1.1.1\commons-logging-1.1.1.jar;C:\Users\Administrator.m2\repository\org\apache\httpcomponents\httpasyncclient\4.0.2\httpasyncclient-4.0.2.jar;C:\Users\Administrator.m2\repository\org\a
pache\httpcomponents\httpcore\4.3.2\httpcore-4.3.2.jar;C:\Users\Administrator.m2\repository\org\apache\httpcomponents\httpcore-nio\4.3.2\httpcore-nio-4.3.2.jar;C:\Users\Administrator.m2\repository\org\apache\httpcomponents\httpclient\4.3.5\httpclient-4.3.5.jar;C:\Users\Administrator.m2\repository\commons-io\commons-
io\2.4\commons-io-2.4.jar;C:\Users\Administrator.m2\repository\com\google\code\gson\gson\2.3.1\gson-2.3.1.jar; -sourcepath C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\test; -s C:\Users\Administrator\Documents\azure push libraries\azure-notificationh
ubs-java-backend-master\NotificationHubs\target\generated-test-sources\test-annotations -g -nowarn -target 1.7 -source 1.7
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 8 source files to C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ NotificationHubs ---
[DEBUG] Dependency collection stats: {ConflictMarker.analyzeTime=0, ConflictMarker.markTime=0, ConflictMarker.nodeCount=132, ConflictIdSorter.graphTime=0, ConflictIdSorter.topsortTime=0, ConflictIdSorter.conflictIdCount=27, ConflictIdSorter.conflictIdCycleCount=0, ConflictResolver.totalTime=0, ConflictResolver.conflict
ItemCount=77, DefaultDependencyCollector.collectTime=47, DefaultDependencyCollector.transformTime=0}
[DEBUG] org.apache.maven.plugins:maven-surefire-plugin:jar:2.12.4:
[DEBUG] org.apache.maven:maven-plugin-api:jar:2.0.9:compile
[DEBUG] org.apache.maven.surefire:surefire-booter:jar:2.12.4:compile
[DEBUG] org.apache.maven.surefire:surefire-api:jar:2.12.4:compile
[DEBUG] org.apache.maven.surefire:maven-surefire-common:jar:2.12.4:compile
[DEBUG] org.apache.commons:commons-lang3:jar:3.1:compile
[DEBUG] org.apache.maven.shared:maven-common-artifact-filters:jar:1.3:compile
[DEBUG] org.codehaus.plexus:plexus-utils:jar:3.0.8:compile
[DEBUG] org.apache.maven:maven-artifact:jar:2.0.9:compile
[DEBUG] org.apache.maven:maven-project:jar:2.0.9:compile
[DEBUG] org.apache.maven:maven-settings:jar:2.0.9:compile
[DEBUG] org.apache.maven:maven-profile:jar:2.0.9:compile
[DEBUG] org.apache.maven:maven-model:jar:2.0.9:compile
[DEBUG] org.apache.maven:maven-artifact-manager:jar:2.0.9:compile
[DEBUG] org.apache.maven:maven-plugin-registry:jar:2.0.9:compile
[DEBUG] org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile
[DEBUG] junit:junit:jar:3.8.1:test
[DEBUG] org.apache.maven:maven-core:jar:2.0.9:compile
[DEBUG] org.apache.maven:maven-plugin-parameter-documenter:jar:2.0.9:compile
[DEBUG] org.apache.maven.reporting:maven-reporting-api:jar:2.0.9:compile
[DEBUG] org.apache.maven:maven-repository-metadata:jar:2.0.9:compile
[DEBUG] org.apache.maven:maven-error-diagnostics:jar:2.0.9:compile
[DEBUG] org.apache.maven:maven-plugin-descriptor:jar:2.0.9:compile
[DEBUG] org.apache.maven:maven-monitor:jar:2.0.9:compile
[DEBUG] classworlds:classworlds:jar:1.1:compile
[DEBUG] org.apache.maven:maven-toolchain:jar:2.0.9:compile
[DEBUG] org.apache.maven.plugin-tools:maven-plugin-annotations:jar:3.1:compile
[DEBUG] Created new class realm plugin>org.apache.maven.plugins:maven-surefire-plugin:2.12.4
[DEBUG] Importing foreign packages into class realm plugin>org.apache.maven.plugins:maven-surefire-plugin:2.12.4
[DEBUG] Imported: < maven.api
[DEBUG] Populating class realm plugin>org.apache.maven.plugins:maven-surefire-plugin:2.12.4
[DEBUG] Included: org.apache.maven.plugins:maven-surefire-plugin:jar:2.12.4
[DEBUG] Included: org.apache.maven.surefire:surefire-booter:jar:2.12.4
[DEBUG] Included: org.apache.maven.surefire:surefire-api:jar:2.12.4
[DEBUG] Included: org.apache.maven.surefire:maven-surefire-common:jar:2.12.4
[DEBUG] Included: org.apache.commons:commons-lang3:jar:3.1
[DEBUG] Included: org.apache.maven.shared:maven-common-artifact-filters:jar:1.3
[DEBUG] Included: org.codehaus.plexus:plexus-utils:jar:3.0.8
[DEBUG] Included: org.apache.maven.reporting:maven-reporting-api:jar:2.0.9
[DEBUG] Included: org.apache.maven.plugin-tools:maven-plugin-annotations:jar:3.1
[DEBUG] Excluded: org.apache.maven:maven-plugin-api:jar:2.0.9
[DEBUG] Excluded: org.apache.maven:maven-artifact:jar:2.0.9
[DEBUG] Excluded: org.apache.maven:maven-project:jar:2.0.9
[DEBUG] Excluded: org.apache.maven:maven-settings:jar:2.0.9
[DEBUG] Excluded: org.apache.maven:maven-profile:jar:2.0.9
[DEBUG] Excluded: org.apache.maven:maven-model:jar:2.0.9
[DEBUG] Excluded: org.apache.maven:maven-artifact-manager:jar:2.0.9
[DEBUG] Excluded: org.apache.maven:maven-plugin-registry:jar:2.0.9
[DEBUG] Excluded: org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1
[DEBUG] Excluded: junit:junit:jar:3.8.1
[DEBUG] Excluded: org.apache.maven:maven-core:jar:2.0.9
[DEBUG] Excluded: org.apache.maven:maven-plugin-parameter-documenter:jar:2.0.9
[DEBUG] Excluded: org.apache.maven:maven-repository-metadata:jar:2.0.9
[DEBUG] Excluded: org.apache.maven:maven-error-diagnostics:jar:2.0.9
[DEBUG] Excluded: org.apache.maven:maven-plugin-descriptor:jar:2.0.9
[DEBUG] Excluded: org.apache.maven:maven-monitor:jar:2.0.9
[DEBUG] Excluded: classworlds:classworlds:jar:1.1
[DEBUG] Excluded: org.apache.maven:maven-toolchain:jar:2.0.9
[DEBUG] Configuring mojo org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test from plugin realm ClassRealm[plugin>org.apache.maven.plugins:maven-surefire-plugin:2.12.4, parent: sun.misc.Launcher$AppClassLoader@5c647e05]
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test' with basic configurator -->
DEBUG basedir = C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs
DEBUG childDelegation = false
DEBUG classesDirectory = C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\target\classes
DEBUG disableXmlReport = false
DEBUG enableAssertions = true
DEBUG forkMode = once
DEBUG junitArtifactName = junit:junit
DEBUG localRepository = id: local
url: file:///C:/Users/Administrator/.m2/repository/
layout: default
snapshots: [enabled => true, update => always]
releases: [enabled => true, update => always]

DEBUG parallelMavenExecution = false
DEBUG perCoreThreadCount = true
DEBUG pluginArtifactMap = {org.apache.maven.plugins:maven-surefire-plugin=org.apache.maven.plugins:maven-surefire-plugin:maven-plugin:2.12.4:, org.apache.maven.surefire:surefire-booter=org.apache.maven.surefire:surefire-booter:jar:2.12.4:compile, org.apache.maven.surefire:surefire-api=org.apache.maven.surefire:
surefire-api:jar:2.12.4:compile, org.apache.maven.surefire:maven-surefire-common=org.apache.maven.surefire:maven-surefire-common:jar:2.12.4:compile, org.apache.commons:commons-lang3=org.apache.commons:commons-lang3:jar:3.1:compile, org.apache.maven.shared:maven-common-artifact-filters=org.apache.maven.shared:maven-comm
on-artifact-filters:jar:1.3:compile, org.codehaus.plexus:plexus-utils=org.codehaus.plexus:plexus-utils:jar:3.0.8:compile, org.apache.maven.reporting:maven-reporting-api=org.apache.maven.reporting:maven-reporting-api:jar:2.0.9:compile, org.apache.maven.plugin-tools:maven-plugin-annotations=org.apache.maven.plugin-tools:
maven-plugin-annotations:jar:3.1:compile}
DEBUG pluginDescriptor = Component Descriptor: role: 'org.apache.maven.plugin.Mojo', implementation: 'org.apache.maven.plugin.surefire.HelpMojo', role hint: 'org.apache.maven.plugins:maven-surefire-plugin:2.12.4:help'

role: 'org.apache.maven.plugin.Mojo', implementation: 'org.apache.maven.plugin.surefire.SurefirePlugin', role hint: 'org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test'

DEBUG printSummary = true
DEBUG projectArtifactMap = {junit:junit=junit:junit:jar:4.11:test, org.hamcrest:hamcrest-core=org.hamcrest:hamcrest-core:jar:1.3:test, commons-codec:commons-codec=commons-codec:commons-codec:jar:1.8:compile, org.apache.commons:commons-digester3=org.apache.commons:commons-digester3:jar:3.2:compile, cglib:cglib=c
glib:cglib:jar:2.2.2:compile, asm:asm=asm:asm:jar:3.3.1:compile, commons-beanutils:commons-beanutils=commons-beanutils:commons-beanutils:jar:1.8.3:compile, commons-logging:commons-logging=commons-logging:commons-logging:jar:1.1.1:compile, org.apache.httpcomponents:httpasyncclient=org.apache.httpcomponents:httpasyncclie
nt:jar:4.0.2:compile, org.apache.httpcomponents:httpcore=org.apache.httpcomponents:httpcore:jar:4.3.2:compile, org.apache.httpcomponents:httpcore-nio=org.apache.httpcomponents:httpcore-nio:jar:4.3.2:compile, org.apache.httpcomponents:httpclient=org.apache.httpcomponents:httpclient:jar:4.3.5:compile, commons-io:commons-
io=commons-io:commons-io:jar:2.4:compile, com.google.code.gson:gson=com.google.code.gson:gson:jar:2.3.1:compile}
DEBUG redirectTestOutputToFile = false
DEBUG remoteRepositories = [ id: central
url: https://repo.maven.apache.org/maven2
layout: default
snapshots: [enabled => false, update => daily]
releases: [enabled => true, update => never]
]
DEBUG reportFormat = brief
DEBUG reportsDirectory = C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\target\surefire-reports
DEBUG runOrder = filesystem
DEBUG skip = false
DEBUG skipTests = false
DEBUG testClassesDirectory = C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\target\test-classes
DEBUG testFailureIgnore = false
DEBUG testNGArtifactName = org.testng:testng
DEBUG testSourceDirectory = C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\test
DEBUG trimStackTrace = true
DEBUG useFile = true
DEBUG useManifestOnlyJar = true
DEBUG useSystemClassLoader = true
DEBUG useUnlimitedThreads = false
DEBUG workingDirectory = C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs
DEBUG project = MavenProject: com.windowsazure:NotificationHubs:0.0.3 @ C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\pom.xml
DEBUG session = org.apache.maven.execution.MavenSession@4c4d27c8
[DEBUG] -- end configuration --
[INFO] Surefire report directory: C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\target\surefire-reports
[DEBUG] Setting system property [user.dir]=[C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs]
[DEBUG] Setting system property [localRepository]=[C:\Users\Administrator.m2\repository]
[DEBUG] Setting system property [basedir]=[C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs]
[DEBUG] dummy:dummy:jar:1.0 (selected for null)
[DEBUG] org.apache.maven.surefire:surefire-booter:jar:2.12.4:compile (selected for compile)
[DEBUG] org.apache.maven.surefire:surefire-api:jar:2.12.4:compile (selected for compile)
[DEBUG] Adding to surefire booter test classpath: C:\Users\Administrator.m2\repository\org\apache\maven\surefire\surefire-booter\2.12.4\surefire-booter-2.12.4.jar Scope: compile
[DEBUG] Adding to surefire booter test classpath: C:\Users\Administrator.m2\repository\org\apache\maven\surefire\surefire-api\2.12.4\surefire-api-2.12.4.jar Scope: compile
[DEBUG] Using JVM: C:\Program Files\Java\jdk1.8.0_25\jre\bin\java
[DEBUG] dummy:dummy:jar:1.0 (selected for null)
[DEBUG] org.apache.maven.surefire:surefire-junit4:jar:2.12.4:test (selected for test)
[DEBUG] org.apache.maven.surefire:surefire-api:jar:2.12.4:test (selected for test)
[DEBUG] Adding to surefire test classpath: C:\Users\Administrator.m2\repository\org\apache\maven\surefire\surefire-junit4\2.12.4\surefire-junit4-2.12.4.jar Scope: test
[DEBUG] Adding to surefire test classpath: C:\Users\Administrator.m2\repository\org\apache\maven\surefire\surefire-api\2.12.4\surefire-api-2.12.4.jar Scope: test
[DEBUG] test classpath classpath:
[DEBUG] C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\target\test-classes
[DEBUG] C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\target\classes
[DEBUG] C:\Users\Administrator.m2\repository\junit\junit\4.11\junit-4.11.jar
[DEBUG] C:\Users\Administrator.m2\repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar
[DEBUG] C:\Users\Administrator.m2\repository\commons-codec\commons-codec\1.8\commons-codec-1.8.jar
[DEBUG] C:\Users\Administrator.m2\repository\org\apache\commons\commons-digester3\3.2\commons-digester3-3.2.jar
[DEBUG] C:\Users\Administrator.m2\repository\cglib\cglib\2.2.2\cglib-2.2.2.jar
[DEBUG] C:\Users\Administrator.m2\repository\asm\asm\3.3.1\asm-3.3.1.jar
[DEBUG] C:\Users\Administrator.m2\repository\commons-beanutils\commons-beanutils\1.8.3\commons-beanutils-1.8.3.jar
[DEBUG] C:\Users\Administrator.m2\repository\commons-logging\commons-logging\1.1.1\commons-logging-1.1.1.jar
[DEBUG] C:\Users\Administrator.m2\repository\org\apache\httpcomponents\httpasyncclient\4.0.2\httpasyncclient-4.0.2.jar
[DEBUG] C:\Users\Administrator.m2\repository\org\apache\httpcomponents\httpcore\4.3.2\httpcore-4.3.2.jar
[DEBUG] C:\Users\Administrator.m2\repository\org\apache\httpcomponents\httpcore-nio\4.3.2\httpcore-nio-4.3.2.jar
[DEBUG] C:\Users\Administrator.m2\repository\org\apache\httpcomponents\httpclient\4.3.5\httpclient-4.3.5.jar
[DEBUG] C:\Users\Administrator.m2\repository\commons-io\commons-io\2.4\commons-io-2.4.jar
[DEBUG] C:\Users\Administrator.m2\repository\com\google\code\gson\gson\2.3.1\gson-2.3.1.jar
[DEBUG] provider classpath classpath:
[DEBUG] C:\Users\Administrator.m2\repository\org\apache\maven\surefire\surefire-junit4\2.12.4\surefire-junit4-2.12.4.jar
[DEBUG] C:\Users\Administrator.m2\repository\org\apache\maven\surefire\surefire-api\2.12.4\surefire-api-2.12.4.jar


T E S T S

Forking command line: cmd.exe /X /C ""C:\Program Files\Java\jdk1.8.0_25\jre\bin\java" -jar "C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\target\surefire\surefirebooter2119839741480522312.jar" "C:\Users\Administrator\Documents\azure push libraries\azur
e-notificationhubs-java-backend-master\NotificationHubs\target\surefire\surefire5872780039990634795tmp" "C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\target\surefire\surefire_05628216676534866564tmp""
Running com.windowsazure.messaging.InstallationParseTest
Tests run: 3, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.125 sec <<< FAILURE!
InstallationWnsFull(com.windowsazure.messaging.InstallationParseTest) Time elapsed: 0.016 sec <<< FAILURE!
java.lang.AssertionError
at org.junit.Assert.fail(Assert.java:86)
at org.junit.Assert.assertTrue(Assert.java:41)
at org.junit.Assert.assertTrue(Assert.java:52)
at com.windowsazure.messaging.InstallationParseTest.InstallationWnsFull(InstallationParseTest.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)

Running com.windowsazure.messaging.NotificationHubJobParseTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.047 sec
Running com.windowsazure.messaging.NotificationHubParseTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.015 sec
Running com.windowsazure.messaging.RegistrationParseTest
Tests run: 17, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.031 sec

Results :

Failed tests: InstallationWnsFull(com.windowsazure.messaging.InstallationParseTest)

Tests run: 24, Failures: 1, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.838 s
[INFO] Finished at: 2015-11-24T11:19:33+01:00
[INFO] Final Memory: 17M/216M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project NotificationHubs: There are test failures.
[ERROR]
[ERROR] Please refer to C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\target\surefire-reports for the individual test results.
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project NotificationHubs: There are test failures.

Please refer to C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\target\surefire-reports for the individual test results.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:582)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoFailureException: There are test failures.

Please refer to C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs\target\surefire-reports for the individual test results.
at org.apache.maven.plugin.surefire.SurefireHelper.reportExecution(SurefireHelper.java:83)
at org.apache.maven.plugin.surefire.SurefirePlugin.writeSummary(SurefirePlugin.java:176)
at org.apache.maven.plugin.surefire.SurefirePlugin.handleSummary(SurefirePlugin.java:150)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:650)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:586)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 19 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
C:\Users\Administrator\Documents\azure push libraries\azure-notificationhubs-java-backend-master\NotificationHubs>

Bug when trying to set a HttpAsyncClient

When I call this method, I've always a RuntimeException with this message: "HttpAsyncClient was already set before or default one is being used."

public static void HttpClientManager.setHttpAsyncClient(CloseableHttpAsyncClient httpAsyncClient) {
...
}

To resolve this bug, the condition should be

 if(HttpClientManager.httpAsyncClient == null)  

not

 if(httpAsyncClient == null)

Direct_send method is not there in the SDK

According to the rest APIs there is a concept of direct send which takes the pns credentials in the header to send the push notification directly onto the specific device but right now no such method exists. In unofficial version of the API, method was there but now it is being removed.

Issues found when notification application is behind proxy

My notification application is deployed behind a proxy, I have to config http.proxyHost or https.proxyHost to access Azure NotificationHub. However I notice the HttpAsyncClients created in the HttpClientManager is a default one and it will never use system properties.

public class HttpClientManager {
	private static CloseableHttpAsyncClient httpAsyncClient;
	
	public static CloseableHttpAsyncClient getHttpAsyncClient() {
		if(httpAsyncClient == null) {
			synchronized(HttpClientManager.class) {
				if(httpAsyncClient == null) {
					CloseableHttpAsyncClient client = HttpAsyncClients.createDefault();
					client.start();

To use system properties configured in jvm, I have modify the client creation method to

CloseableHttpAsyncClient client = HttpAsyncClients.createSystem();

I looked into HttpAsyncClients source code, it is clear the difference is whether useSystemProperties

    /**
     * Creates {@link CloseableHttpAsyncClient} instance with default
     * configuration.
     */
    public static CloseableHttpAsyncClient createDefault() {
        return HttpAsyncClientBuilder.create().build();
    }

    /**
     * Creates {@link CloseableHttpAsyncClient} instance with default
     * configuration based on ssytem properties.
     */
    public static CloseableHttpAsyncClient createSystem() {
        return HttpAsyncClientBuilder.create().useSystemProperties().build();

Hope this issue can be fixed.

Support to get notification message telemetry

Standard tier notification hubs provides an additional API to get telemetry on the finished state of outgoing push notifications. This enables the user to monitor push notifications sent from the hub. Input to this API is the Notification ID that we get from the HTTP Location header included in the response of the REST API used to send the notification (i.e. NotificationOutcome in our code). More about this API here.

Through this issue, I expect this project to have support for the PMT.
Thanks!

createFcmNotification - ServiceBusNotification-Format "gcm" vs "fcm",

In a previous commit I see ServiceBusNotification-Format as "fcm", but in the recent ones it is "gcm". When I changed it to "fcm", the push notifications do not work (our client app is using FCM).

I'm not sure how this is handled by Azure Hub in the background, but the force over to FCM is in a few weeks, so just want to confirm "gcm" in the below function will still work after that date?

Thanks!

public static Notification createFcmNotifiation(String body) {
    Notification n = new Notification();
    n.body = body;
    n.contentType = ContentType.APPLICATION_JSON;
    n.headers.put("ServiceBusNotification-Format", "gcm");
    return n;
}

[BUG] Caused by: java.lang.ClassNotFoundException: org.apache.hc.client5.http.entity.mime.ContentBody with 1.0.4 of azure notificationhub sdk

Describe the bug
When making a registration for a new device against azure notification hub with sdk version 1.0.4.

Exception or Stack Trace

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'deviceLanguageUpdateRequestedEventHandler' defined in URL [jar:file:/Application.jar!/BOOT-INF/classes!/com/***/kat/azureconnector/registrations/event/in/update/DeviceLanguageUpdateRequestedEventHandler.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'registrationServiceImpl' defined in URL [jar:file:/Application.jar!/BOOT-INF/classes!/com/***/kat/azureconnector/registrations/service/RegistrationServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'azureServiceImpl' defined in URL [jar:file:/Application.jar!/BOOT-INF/classes!/com/***/kat/azureconnector/azure/service/AzureServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'notificationHubFactory' defined in class path resource [com/***/kat/azureconnector/config/NotificationHubConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.***.kat.azureconnector.azure.client.NotificationHubFactory]: Factory method 'notificationHubFactory' threw exception; nested exception is java.lang.NoClassDefFoundError: org/apache/hc/client5/http/entity/mime/ContentBody\n\tat org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800)\n\tat org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:229)\n\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1372)\n\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1222)\n\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)\n\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)\n\tat org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)\n\tat org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)\n\tat org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)\n\tat org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)\n\tat org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955)\n\tat org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)\n\tat org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)\n\tat org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147)\n\tat org.springframework.boot.SpringApplication.refresh(SpringApplication.java:731)\n\tat org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408)\n\tat org.springframework.boot.SpringApplication.run(SpringApplication.java:307)\n\tat org.springframework.boot.SpringApplication.run(SpringApplication.java:1303)\n\tat org.springframework.boot.SpringApplication.run(SpringApplication.java:1292)\n\tat com.***.kat.azureconnector.AzureNtfhubConnectorApplication.main(AzureNtfhubConnectorApplication.java:10)\n\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)\n\tat java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat java.base/java.lang.reflect.Method.invoke(Method.java:568)\n\tat org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)\n\tat org.springframework.boot.loader.Launcher.launch(Launcher.java:108)\n\tat org.springframework.boot.loader.Launcher.launch(Launcher.java:58)\n\tat org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:65)\nCaused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'registrationServiceImpl' defined in URL [jar:file:/Application.jar!/BOOT-INF/classes!/com/***/kat/azureconnector/registrations/service/RegistrationServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'azureServiceImpl' defined in URL [jar:file:/Application.jar!/BOOT-INF/classes!/com/***/kat/azureconnector/azure/service/AzureServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'notificationHubFactory' defined in class path resource [com/***/kat/azureconnector/config/NotificationHubConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.***.kat.azureconnector.azure.client.NotificationHubFactory]: Factory method 'notificationHubFactory' threw exception; nested exception is java.lang.NoClassDefFoundError: org/apache/hc/client5/http/entity/mime/ContentBody\n\tat org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800)\n\tat org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:229)\n\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1372)\n\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1222)\n\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)\n\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)\n\tat org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)\n\tat org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)\n\tat org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)\n\tat org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)\n\tat org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)\n\tat org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1391)\n\tat org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1311)\n\tat org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887)\n\tat org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791)\n\t... 27 common frames omitted\nCaused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'azureServiceImpl' defined in URL [jar:file:/Application.jar!/BOOT-INF/classes!/com/***/kat/azureconnector/azure/service/AzureServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'notificationHubFactory' defined in class path resource [com/***/kat/azureconnector/config/NotificationHubConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.***.kat.azureconnector.azure.client.NotificationHubFactory]: Factory method 'notificationHubFactory' threw exception; nested exception is java.lang.NoClassDefFoundError: org/apache/hc/client5/http/entity/mime/ContentBody\n\tat org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800)\n\tat org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:229)\n\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1372)\n\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1222)\n\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)\n\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)\n\tat org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)\n\tat org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)\n\tat org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)\n\tat org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)\n\tat org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)\n\tat org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1391)\n\tat org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1311)\n\tat org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887)\n\tat org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791)\n\t... 41 common frames omitted\nCaused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'notificationHubFactory' defined in class path resource [com/***/kat/azureconnector/config/NotificationHubConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.***.kat.azureconnector.azure.client.NotificationHubFactory]: Factory method 'notificationHubFactory' threw exception; nested exception is java.lang.NoClassDefFoundError: org/apache/hc/client5/http/entity/mime/ContentBody\n\tat org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658)\n\tat org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:638)\n\tat org.springframework.beans.factordy.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352)\n\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195)\n\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)\n\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)\n\tat org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)\n\tat org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)\n\tat org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)\n\tat org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)\n\tat org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)\n\tat org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1391)\n\tat org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1311)\n\tat org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887)\n\tat org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791)\n\t... 55 common frames omitted\nCaused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.***.kat.azureconnector.azure.client.NotificationHubFactory]: Factory method 'notificationHubFactory' threw exception; nested exception is java.lang.NoClassDefFoundError: org/apache/hc/client5/http/entity/mime/ContentBody\n\tat org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)\n\tat org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)\n\t... 69 common frames omitted\nCaused by: java.lang.NoClassDefFoundError: org/apache/hc/client5/http/entity/mime/ContentBody\n\tat com.***.kat.azureconnector.config.NotificationHubConfiguration.notificationHubFactory(NotificationHubConfiguration.java:22)\n\tat com.***.kat.azureconnector.config.NotificationHubConfiguration$$EnhancerBySpringCGLIB$$3ac5f501.CGLIB$notificationHubFactory$0(<generated>)\n\tat com.***.kat.azureconnector.config.NotificationHubConfiguration$$EnhancerBySpringCGLIB$$3ac5f501$$FastClassBySpringCGLIB$$f675f942.invoke(<generated>)\n\tat org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)\n\tat org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331)\n\tat com.***.kat.azureconnector.config.NotificationHubConfiguration$$EnhancerBySpringCGLIB$$3ac5f501.notificationHubFactory(<generated>)\n\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)\n\tat java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat java.base/java.lang.reflect.Method.invoke(Method.java:568)\n\tat org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)\n\t... 70 common frames omitted\nCaused by: java.lang.ClassNotFoundException: org.apache.hc.client5.http.entity.mime.ContentBody\n\tat java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)\n\tat java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587)\n\tat org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:151)\n\tat java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)\n\t... 81 common frames omitted\n

Removed our company related stuff with ***

To Reproduce
Use SDK version 1.0.4 and try to register a new device

Expected behavior
Device successfully registered

Setup (please complete the following information):

  • OS: Alpine Linux
  • Spring Boot 2.7.8 and
 <dependency>
      <groupId>org.apache.httpcomponents.core5</groupId>
      <artifactId>httpcore5</artifactId>
      <version>5.2</version>
 </dependency>
  • Version of the Library used: 1.0.4

Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issue as an incomplete report. Please do not provide any private information in this bug report.

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added

Missing Token-based (HTTP/2) Authentication for APNS

Configuration of token-based authentication for APNS via management API (REST) is not supported.
See documentation at
[https://docs.microsoft.com/en-us/azure/notification-hubs/notification-hubs-push-notification-http2-token-authentification#configure-via-management-api-rest]

As the documentation says, API version of 2017-04 or later is required, but this Java implementation is still at 2015-04.

[BUG] Get a notification hub by the hub path not working

Describe the bug
Gets a notification hub by the hub path suddenly stopped working.

Our application suddenly broke a few days ago. The sdk is suddenly not able get a notification hub by the hub path.
No changes done on our side on our code or our azure services.

We were still using NotificationHubs.0.0.5, so I upgraded to latest Notification-Hubs-java-sdk.1.0.4 but that has the same issue.

Exception or Stack Trace

17:02:44.562 ERROR [httpclient-dispatch-1 ]                       digester3.Digester - End event threw exception
java.lang.reflect.InvocationTargetException: null
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_345]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_345]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_345]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_345]
	at org.apache.commons.beanutils.MethodUtils.invokeMethod(MethodUtils.java:278) ~[commons-beanutils-1.9.4.jar:1.9.4]
	at org.apache.commons.digester3.CallMethodRule.end(CallMethodRule.java:500) ~[commons-digester3-3.2.jar:3.2]
	at org.apache.commons.digester3.Digester.endElement(Digester.java:1128) ~[commons-digester3-3.2.jar:3.2]
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:609) ~[?:1.8.0_345]
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1781) ~[?:1.8.0_345]
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2966) ~[?:1.8.0_345]
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:601) ~[?:1.8.0_345]
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:504) ~[?:1.8.0_345]
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:841) ~[?:1.8.0_345]
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:770) ~[?:1.8.0_345]
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141) ~[?:1.8.0_345]
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213) ~[?:1.8.0_345]
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:642) ~[?:1.8.0_345]
	at org.apache.commons.digester3.Digester.parse(Digester.java:1642) ~[commons-digester3-3.2.jar:3.2]
	at org.apache.commons.digester3.Digester.parse(Digester.java:1701) ~[commons-digester3-3.2.jar:3.2]
	at com.windowsazure.messaging.NotificationHubDescription.parseOne(NotificationHubDescription.java:170) ~[Notification-Hubs-java-sdk-1.0.4.jar:1.0.4]
	at com.windowsazure.messaging.NamespaceManager.lambda$getNotificationHubAsync$0(NamespaceManager.java:72) ~[Notification-Hubs-java-sdk-1.0.4.jar:1.0.4]
	at com.windowsazure.messaging.NotificationHubsService$1.completed(NotificationHubsService.java:73) [Notification-Hubs-java-sdk-1.0.4.jar:1.0.4]
	at com.windowsazure.messaging.NotificationHubsService$1.completed(NotificationHubsService.java:63) [Notification-Hubs-java-sdk-1.0.4.jar:1.0.4]
	at org.apache.hc.core5.concurrent.BasicFuture.completed(BasicFuture.java:123) [httpcore5-5.2.jar:5.2]
	at org.apache.hc.core5.concurrent.ComplexFuture.completed(ComplexFuture.java:72) [httpcore5-5.2.jar:5.2]
	at org.apache.hc.client5.http.impl.async.InternalAbstractHttpAsyncClient$1$1.completed(InternalAbstractHttpAsyncClient.java:280) [httpclient5-5.2.jar:5.2]
	at org.apache.hc.core5.http.nio.support.AbstractAsyncResponseConsumer$1.completed(AbstractAsyncResponseConsumer.java:101) [httpcore5-5.2.jar:5.2]
	at org.apache.hc.core5.http.nio.entity.AbstractBinAsyncEntityConsumer.completed(AbstractBinAsyncEntityConsumer.java:84) [httpcore5-5.2.jar:5.2]
	at org.apache.hc.core5.http.nio.entity.AbstractBinDataConsumer.streamEnd(AbstractBinDataConsumer.java:81) [httpcore5-5.2.jar:5.2]
	at org.apache.hc.core5.http.nio.support.AbstractAsyncResponseConsumer.streamEnd(AbstractAsyncResponseConsumer.java:142) [httpcore5-5.2.jar:5.2]
	at org.apache.hc.client5.http.impl.async.H2AsyncMainClientExec$1.streamEnd(H2AsyncMainClientExec.java:189) [httpclient5-5.2.jar:5.2]
	at org.apache.hc.core5.http2.impl.nio.ClientH2StreamHandler.consumeData(ClientH2StreamHandler.java:239) [httpcore5-h2-5.2.jar:5.2]
	at org.apache.hc.core5.http2.impl.nio.AbstractH2StreamMultiplexer$H2Stream.consumeData(AbstractH2StreamMultiplexer.java:1636) [httpcore5-h2-5.2.jar:5.2]
	at org.apache.hc.core5.http2.impl.nio.AbstractH2StreamMultiplexer.consumeDataFrame(AbstractH2StreamMultiplexer.java:1045) [httpcore5-h2-5.2.jar:5.2]
	at org.apache.hc.core5.http2.impl.nio.AbstractH2StreamMultiplexer.consumeFrame(AbstractH2StreamMultiplexer.java:734) [httpcore5-h2-5.2.jar:5.2]
	at org.apache.hc.core5.http2.impl.nio.AbstractH2StreamMultiplexer.onInput(AbstractH2StreamMultiplexer.java:445) [httpcore5-h2-5.2.jar:5.2]
	at org.apache.hc.core5.http2.impl.nio.AbstractH2IOEventHandler.inputReady(AbstractH2IOEventHandler.java:65) [httpcore5-h2-5.2.jar:5.2]
	at org.apache.hc.core5.http2.impl.nio.ClientH2IOEventHandler.inputReady(ClientH2IOEventHandler.java:39) [httpcore5-h2-5.2.jar:5.2]
	at org.apache.hc.core5.reactor.ssl.SSLIOSession.decryptData(SSLIOSession.java:600) [httpcore5-5.2.jar:5.2]
	at org.apache.hc.core5.reactor.ssl.SSLIOSession.access$200(SSLIOSession.java:74) [httpcore5-5.2.jar:5.2]
	at org.apache.hc.core5.reactor.ssl.SSLIOSession$1.inputReady(SSLIOSession.java:202) [httpcore5-5.2.jar:5.2]
	at org.apache.hc.core5.reactor.InternalDataChannel.onIOEvent(InternalDataChannel.java:142) [httpcore5-5.2.jar:5.2]
	at org.apache.hc.core5.reactor.InternalChannel.handleIOEvent(InternalChannel.java:51) [httpcore5-5.2.jar:5.2]
	at org.apache.hc.core5.reactor.SingleCoreIOReactor.processEvents(SingleCoreIOReactor.java:178) [httpcore5-5.2.jar:5.2]
	at org.apache.hc.core5.reactor.SingleCoreIOReactor.doExecute(SingleCoreIOReactor.java:127) [httpcore5-5.2.jar:5.2]
	at org.apache.hc.core5.reactor.AbstractSingleCoreIOReactor.execute(AbstractSingleCoreIOReactor.java:86) [httpcore5-5.2.jar:5.2]
	at org.apache.hc.core5.reactor.IOReactorWorker.run(IOReactorWorker.java:44) [httpcore5-5.2.jar:5.2]
	at java.lang.Thread.run(Thread.java:750) [?:1.8.0_345]
Caused by: java.lang.NoSuchMethodException: com.windowsazure.messaging.ApnsCredential.setkeyId(java.lang.String)
	at java.lang.Class.getMethod(Class.java:1786) ~[?:1.8.0_345]
	at com.windowsazure.messaging.PnsCredential.setProperty(PnsCredential.java:23) ~[Notification-Hubs-java-sdk-1.0.4.jar:1.0.4]
	... 48 more
17:02:44.592 ERROR [httpclient-dispatch-1 ]                       digester3.Digester - An error occurred while parsing XML from '(already loaded from stream)', see nested exceptions
org.xml.sax.SAXParseException: Error at line 1 char 840: com.windowsazure.messaging.ApnsCredential.setkeyId(java.lang.String)
	at org.apache.commons.digester3.Digester.createSAXException(Digester.java:3118) ~[commons-digester3-3.2.jar:3.2]
	at org.apache.commons.digester3.Digester.createSAXException(Digester.java:3146) ~[commons-digester3-3.2.jar:3.2]
	at org.apache.commons.digester3.Digester.endElement(Digester.java:1133) ~[commons-digester3-3.2.jar:3.2]
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:609) ~[?:1.8.0_345]
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1781) ~[?:1.8.0_345]
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2966) ~[?:1.8.0_345]
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:601) ~[?:1.8.0_345]
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:504) ~[?:1.8.0_345]
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:841) ~[?:1.8.0_345]
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:770) ~[?:1.8.0_345]
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141) ~[?:1.8.0_345]
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213) ~[?:1.8.0_345]
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:642) ~[?:1.8.0_345]
	at org.apache.commons.digester3.Digester.parse(Digester.java:1642) ~[commons-digester3-3.2.jar:3.2]
	at org.apache.commons.digester3.Digester.parse(Digester.java:1701) ~[commons-digester3-3.2.jar:3.2]
	at com.windowsazure.messaging.NotificationHubDescription.parseOne(NotificationHubDescription.java:170) ~[Notification-Hubs-java-sdk-1.0.4.jar:1.0.4]
	at com.windowsazure.messaging.NamespaceManager.lambda$getNotificationHubAsync$0(NamespaceManager.java:72) ~[Notification-Hubs-java-sdk-1.0.4.jar:1.0.4]
	at com.windowsazure.messaging.NotificationHubsService$1.completed(NotificationHubsService.java:73) [Notification-Hubs-java-sdk-1.0.4.jar:1.0.4]
	at com.windowsazure.messaging.NotificationHubsService$1.completed(NotificationHubsService.java:63) [Notification-Hubs-java-sdk-1.0.4.jar:1.0.4]
	at org.apache.hc.core5.concurrent.BasicFuture.completed(BasicFuture.java:123) [httpcore5-5.2.jar:5.2]
	at org.apache.hc.core5.concurrent.ComplexFuture.completed(ComplexFuture.java:72) [httpcore5-5.2.jar:5.2]
	at org.apache.hc.client5.http.impl.async.InternalAbstractHttpAsyncClient$1$1.completed(InternalAbstractHttpAsyncClient.java:280) [httpclient5-5.2.jar:5.2]
	at org.apache.hc.core5.http.nio.support.AbstractAsyncResponseConsumer$1.completed(AbstractAsyncResponseConsumer.java:101) [httpcore5-5.2.jar:5.2]
	at org.apache.hc.core5.http.nio.entity.AbstractBinAsyncEntityConsumer.completed(AbstractBinAsyncEntityConsumer.java:84) [httpcore5-5.2.jar:5.2]
	at org.apache.hc.core5.http.nio.entity.AbstractBinDataConsumer.streamEnd(AbstractBinDataConsumer.java:81) [httpcore5-5.2.jar:5.2]
	at org.apache.hc.core5.http.nio.support.AbstractAsyncResponseConsumer.streamEnd(AbstractAsyncResponseConsumer.java:142) [httpcore5-5.2.jar:5.2]
	at org.apache.hc.client5.http.impl.async.H2AsyncMainClientExec$1.streamEnd(H2AsyncMainClientExec.java:189) [httpclient5-5.2.jar:5.2]
	at org.apache.hc.core5.http2.impl.nio.ClientH2StreamHandler.consumeData(ClientH2StreamHandler.java:239) [httpcore5-h2-5.2.jar:5.2]
	at org.apache.hc.core5.http2.impl.nio.AbstractH2StreamMultiplexer$H2Stream.consumeData(AbstractH2StreamMultiplexer.java:1636) [httpcore5-h2-5.2.jar:5.2]
	at org.apache.hc.core5.http2.impl.nio.AbstractH2StreamMultiplexer.consumeDataFrame(AbstractH2StreamMultiplexer.java:1045) [httpcore5-h2-5.2.jar:5.2]
	at org.apache.hc.core5.http2.impl.nio.AbstractH2StreamMultiplexer.consumeFrame(AbstractH2StreamMultiplexer.java:734) [httpcore5-h2-5.2.jar:5.2]
	at org.apache.hc.core5.http2.impl.nio.AbstractH2StreamMultiplexer.onInput(AbstractH2StreamMultiplexer.java:445) [httpcore5-h2-5.2.jar:5.2]
	at org.apache.hc.core5.http2.impl.nio.AbstractH2IOEventHandler.inputReady(AbstractH2IOEventHandler.java:65) [httpcore5-h2-5.2.jar:5.2]
	at org.apache.hc.core5.http2.impl.nio.ClientH2IOEventHandler.inputReady(ClientH2IOEventHandler.java:39) [httpcore5-h2-5.2.jar:5.2]
	at org.apache.hc.core5.reactor.ssl.SSLIOSession.decryptData(SSLIOSession.java:600) [httpcore5-5.2.jar:5.2]
	at org.apache.hc.core5.reactor.ssl.SSLIOSession.access$200(SSLIOSession.java:74) [httpcore5-5.2.jar:5.2]
	at org.apache.hc.core5.reactor.ssl.SSLIOSession$1.inputReady(SSLIOSession.java:202) [httpcore5-5.2.jar:5.2]
	at org.apache.hc.core5.reactor.InternalDataChannel.onIOEvent(InternalDataChannel.java:142) [httpcore5-5.2.jar:5.2]
	at org.apache.hc.core5.reactor.InternalChannel.handleIOEvent(InternalChannel.java:51) [httpcore5-5.2.jar:5.2]
	at org.apache.hc.core5.reactor.SingleCoreIOReactor.processEvents(SingleCoreIOReactor.java:178) [httpcore5-5.2.jar:5.2]
	at org.apache.hc.core5.reactor.SingleCoreIOReactor.doExecute(SingleCoreIOReactor.java:127) [httpcore5-5.2.jar:5.2]
	at org.apache.hc.core5.reactor.AbstractSingleCoreIOReactor.execute(AbstractSingleCoreIOReactor.java:86) [httpcore5-5.2.jar:5.2]
	at org.apache.hc.core5.reactor.IOReactorWorker.run(IOReactorWorker.java:44) [httpcore5-5.2.jar:5.2]
	at java.lang.Thread.run(Thread.java:750) [?:1.8.0_345]
Caused by: java.lang.NoSuchMethodException: com.windowsazure.messaging.ApnsCredential.setkeyId(java.lang.String)
	at java.lang.Class.getMethod(Class.java:1786) ~[?:1.8.0_345]
	at com.windowsazure.messaging.PnsCredential.setProperty(PnsCredential.java:23) ~[Notification-Hubs-java-sdk-1.0.4.jar:1.0.4]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_345]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_345]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_345]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_345]
	at org.apache.commons.beanutils.MethodUtils.invokeMethod(MethodUtils.java:278) ~[commons-beanutils-1.9.4.jar:1.9.4]
	at org.apache.commons.digester3.CallMethodRule.end(CallMethodRule.java:500) ~[commons-digester3-3.2.jar:3.2]
	at org.apache.commons.digester3.Digester.endElement(Digester.java:1128) ~[commons-digester3-3.2.jar:3.2]
	... 41 more

java.lang.RuntimeException: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 840; Error at line 1 char 840: com.windowsazure.messaging.ApnsCredential.setkeyId(java.lang.String)

	at com.windowsazure.messaging.SyncCallback.failed(SyncCallback.java:53)
	at com.windowsazure.messaging.NamespaceManager.lambda$getNotificationHubAsync$0(NamespaceManager.java:74)
	at com.windowsazure.messaging.NotificationHubsService$1.completed(NotificationHubsService.java:73)
	at com.windowsazure.messaging.NotificationHubsService$1.completed(NotificationHubsService.java:63)
	at org.apache.hc.core5.concurrent.BasicFuture.completed(BasicFuture.java:123)
	at org.apache.hc.core5.concurrent.ComplexFuture.completed(ComplexFuture.java:72)
	at org.apache.hc.client5.http.impl.async.InternalAbstractHttpAsyncClient$1$1.completed(InternalAbstractHttpAsyncClient.java:280)
	at org.apache.hc.core5.http.nio.support.AbstractAsyncResponseConsumer$1.completed(AbstractAsyncResponseConsumer.java:101)
	at org.apache.hc.core5.http.nio.entity.AbstractBinAsyncEntityConsumer.completed(AbstractBinAsyncEntityConsumer.java:84)
	at org.apache.hc.core5.http.nio.entity.AbstractBinDataConsumer.streamEnd(AbstractBinDataConsumer.java:81)
	at org.apache.hc.core5.http.nio.support.AbstractAsyncResponseConsumer.streamEnd(AbstractAsyncResponseConsumer.java:142)
	at org.apache.hc.client5.http.impl.async.H2AsyncMainClientExec$1.streamEnd(H2AsyncMainClientExec.java:189)
	at org.apache.hc.core5.http2.impl.nio.ClientH2StreamHandler.consumeData(ClientH2StreamHandler.java:239)
	at org.apache.hc.core5.http2.impl.nio.AbstractH2StreamMultiplexer$H2Stream.consumeData(AbstractH2StreamMultiplexer.java:1636)
	at org.apache.hc.core5.http2.impl.nio.AbstractH2StreamMultiplexer.consumeDataFrame(AbstractH2StreamMultiplexer.java:1045)
	at org.apache.hc.core5.http2.impl.nio.AbstractH2StreamMultiplexer.consumeFrame(AbstractH2StreamMultiplexer.java:734)
	at org.apache.hc.core5.http2.impl.nio.AbstractH2StreamMultiplexer.onInput(AbstractH2StreamMultiplexer.java:445)
	at org.apache.hc.core5.http2.impl.nio.AbstractH2IOEventHandler.inputReady(AbstractH2IOEventHandler.java:65)
	at org.apache.hc.core5.http2.impl.nio.ClientH2IOEventHandler.inputReady(ClientH2IOEventHandler.java:39)
	at org.apache.hc.core5.reactor.ssl.SSLIOSession.decryptData(SSLIOSession.java:600)
	at org.apache.hc.core5.reactor.ssl.SSLIOSession.access$200(SSLIOSession.java:74)
	at org.apache.hc.core5.reactor.ssl.SSLIOSession$1.inputReady(SSLIOSession.java:202)
	at org.apache.hc.core5.reactor.InternalDataChannel.onIOEvent(InternalDataChannel.java:142)
	at org.apache.hc.core5.reactor.InternalChannel.handleIOEvent(InternalChannel.java:51)
	at org.apache.hc.core5.reactor.SingleCoreIOReactor.processEvents(SingleCoreIOReactor.java:178)
	at org.apache.hc.core5.reactor.SingleCoreIOReactor.doExecute(SingleCoreIOReactor.java:127)
	at org.apache.hc.core5.reactor.AbstractSingleCoreIOReactor.execute(AbstractSingleCoreIOReactor.java:86)
	at org.apache.hc.core5.reactor.IOReactorWorker.run(IOReactorWorker.java:44)
	at java.lang.Thread.run(Thread.java:750)
Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 840; Error at line 1 char 840: com.windowsazure.messaging.ApnsCredential.setkeyId(java.lang.String)
	at org.apache.commons.digester3.Digester.createSAXException(Digester.java:3118)
	at org.apache.commons.digester3.Digester.createSAXException(Digester.java:3146)
	at org.apache.commons.digester3.Digester.endElement(Digester.java:1133)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:609)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1781)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2966)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:601)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:504)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:841)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:770)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:642)
	at org.apache.commons.digester3.Digester.parse(Digester.java:1642)
	at org.apache.commons.digester3.Digester.parse(Digester.java:1701)
	at com.windowsazure.messaging.NotificationHubDescription.parseOne(NotificationHubDescription.java:170)
	at com.windowsazure.messaging.NamespaceManager.lambda$getNotificationHubAsync$0(NamespaceManager.java:72)
	... 27 more
Caused by: java.lang.NoSuchMethodException: com.windowsazure.messaging.ApnsCredential.setkeyId(java.lang.String)
	at java.lang.Class.getMethod(Class.java:1786)
	at com.windowsazure.messaging.PnsCredential.setProperty(PnsCredential.java:23)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.commons.beanutils.MethodUtils.invokeMethod(MethodUtils.java:278)
	at org.apache.commons.digester3.CallMethodRule.end(CallMethodRule.java:500)
	at org.apache.commons.digester3.Digester.endElement(Digester.java:1128)
	... 41 more

To Reproduce
Steps to reproduce the behavior:
Try to get a notification hub by the hub path.

Code Snippet

                String connectionString = "Endpoint=sb://xxx.servicebus.windows.net/;SharedAccessKeyName=DefaultFullSharedAccessSignature;SharedAccessKey=xxx";
                String hubName = "xxx";

                NamespaceManager namespaceManager = new NamespaceManager(connectionString);
                NotificationHubDescription hubInfo = namespaceManager.getNotificationHub(hubName); // error occurs

Expected behavior
NotificationHubDescription is retrieved.

Setup (please complete the following information):

  • Java version: 1.8.0_332
  • Notification-Hubs-java-sdk.1.0.4

Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issue as an incomplete report. Please do not provide any private information in this bug report.

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added

Not support to submit registration on Baidu through Installation API

According to the source code of enum NotificationPlatform:

public enum NotificationPlatform {
@SerializedName("wns")
Wns,
@SerializedName("apns")
Apns,
@SerializedName("mpns")
Mpns,
@SerializedName("gcm")
Gcm,
@SerializedName("adm")
Adm;

private NotificationPlatform() {
}

}

I do not think there is an item for Baidu channel.
so my question is that, if we try to pushing notification through Baidu, what should we do by Installation API? Thanks.

Missing .get() on HttpClientManager.getHttpAsyncClient().execute(...)

Hi,

I discovered a bug in NotificationHubs.java when using the httpAsyncClient execute() method with a Future Callback.
In my project, requests never returned anything until I found that we need to get the result of of the Future.

For example between lines 79 and 102, Handling methods for the Future result are described but never called. The request wil never respond.

Just add a ".get()" at the end of the Future body fixes the problem

HttpClientManager.getHttpAsyncClient().execute(post, new FutureCallback<HttpResponse>() {
    @Override
    public void completed(final HttpResponse response) {
        try {
            if (response.getStatusLine().getStatusCode() != 200) {
                callback.failed(new RuntimeException(getErrorString(response)));
                return;
            }

            callback.completed(Registration.parse(response.getEntity().getContent()));
        } catch (Exception e) {
            callback.failed(e);
        } finally {
            post.releaseConnection();
        }
    }

    @Override
    public void failed(final Exception ex) {
        post.releaseConnection();
        callback.failed(ex);
    }

    @Override
    public void cancelled() {
        post.releaseConnection();
        callback.cancelled();
    }
}).get();

[BUG] 400 Bad Request when exporting registrations

This is a cx reporting issue and I can reproduce the same thing. The notification hub is standard tier.
When I run the sample code, it gives me error:
Error: HTTP/1.1 400 Bad Request - 400The supplied notificationhub job payload is invalid.TrackingId:85871df2-dd9d-48d5-b435-b7539879f3d1_G14,TimeStamp:2/1/2022 1:44:36 AM

pom.xml

com.windowsazure Notification-Hubs-java-sdk 0.4.2

code:

import com.windowsazure.messaging.NotificationHub;
import com.windowsazure.messaging.NotificationHubJob;
import com.windowsazure.messaging.NotificationHubJobStatus;
import com.windowsazure.messaging.NotificationHubJobType;

public class NotificationHubTest {

public static void main(String[] args) {
	// TODO Auto-generated method stub
	// Submit an export job
	NotificationHub hub = new NotificationHub("Endpoint=sb://myhubspace2.servicebus.windows.net/;SharedAccessKeyName=DefaultFullSharedAccessSignature;SharedAccessKey=xpPzFQR9etp9/UEUi6trxUpP6IEBAixV67AnqkoI5Tc=", "myhub002");
	
	try
	
	{
		NotificationHubJob job = new NotificationHubJob();
		job.setJobType(NotificationHubJobType.ExportRegistrations);
		job.setOutputContainerUri("https://yangshendls12312.blob.core.windows.net/dir1?sv=2018-03-28&sr=c&sig=1VI51zRmC71DHo2%2Ft1SfRcXUAYde%2BloFd8Xow15Ozy8%3D&se=2022-02-01T04%3A41%3A05Z&sp=rwl");
		job = hub.submitNotificationHubJob(job);

		// Wait until the job is done
		while(true){
		    Thread.sleep(1000);
		    job = hub.getNotificationHubJob(job.getJobId());
		    if(job.getJobStatus() == NotificationHubJobStatus.Completed)
		        break;
		}
	}
	catch (Exception ex)
	{
		System.out.print(ex.getMessage());			
	}
}

}

Can't send UWP notification when toast tag with parameters

Hello.
When I try to send UWP notification like
<toast launch="test_launch">
I get
Error: HTTP/1.1 400 Bad Request body: <Error><Code>400</Code><Detail>The mandatory HTTP header 'X-WNS-Type' is missing.TrackingId:c973b157-3a55-4e2a-b0bf-2805eaac8d22_G0,

I think there is issue in createWindowsNotification method at Notification.java at code

if (body.contains("<toast>"))

Getting 401 - Invalid token

Hi,

I am trying to get Notification Telemetry. For this I have imported project in eclipse & provided endpoint, hubpath & notification id value, and i haven't changed anything else in code. But i am getting "Error: HTTP/1.1 401 40103: Invalid authorization token signature" . It seems token is not correctly generated. Kindly look into this issue.

method to get registration by Baidu ChannelId

This existing method getRegistrationsByChannelAsync internal is sending query with filter "ChannelUri eq", seems only supports for MPNS, not for APNS, GCM and Baidu.
I can follow REST API to implement corresponding methods for APNS and GCM, but no luck on Baidu with below queries. Does it not support? Or is my filter condition wrong?
• https://{namespace}.servicebus.windows.net/{NotificationHub}/registrations/?$filter= BaiduChannelId eq ‘{BaiduChannelId}’&api-version=2015-01
• https://{namespace}.servicebus.windows.net/{NotificationHub}/registrations/?$filter= Channel eq ‘{BaiduUserId-BaiduChannelId}’&api-version=2015-01
• https://{namespace}.servicebus.windows.net/{NotificationHub}/registrations/?$filter= (BaiduChannelId eq ‘{BaiduChannelId}’) and (BaiduUserId eq ‘{BaiduUserId}’)&api-version=2015-01

When trying making a new NotificationHub programmatically, it causes 401 Unauthorized Error.

Query/Question
When I follow this gcm example,


I have a 401 error.
But when I change an existing hubname; I already made it on portal; and I try get NotificatonHub, then it is ok.
I have a 401 error only when trying to create a new hub.

com.windowsazure.messaging.NotificationHubsException: Error: HTTP/1.1 401 Unauthorized - <Error><Code>401</Code><Detail>InvalidSignature: The token has an invalid signature..TrackingId:d7252e01-8545-43b6-a548-5958770c7bfd_G2,TimeStamp:10/26/2021 3:38:01 AM</Detail></Error>

Why is this not a Bug or a feature Request?
A clear explanation of why is this not a bug or a feature request?

Setup (please complete the following information if applicable):

  • OS: [macOS 11.6 BigSur]
  • IDE : [e.g. IntelliJ 2021.2 Ultimate Edition]
  • Version of the Library used
 <groupId>com.windowsazure</groupId>
 <artifactId>Notification-Hubs-java-sdk</artifactId>
 <version>0.4.2</version>

JDK 11

Following causes error.

final String HUB_PATH = "Test_" + UUID.randomUUID();

NamespaceManager namespaceManager = new NamespaceManager("My Real DefaultFullSharedAccessSignature");

// Create new Hubs
final NotificationHubDescription hubDescription = new NotificationHubDescription(HUB_PATH);
hubDescription.setGcmCredential(new GcmCredential("Real FCM API Key"));
NotificationHubDescription notificationHub = namespaceManager.createNotificationHub(hubDescription);

But this one is ok.

NamespaceManager namespaceManager = new NamespaceManager("My Real DefaultFullSharedAccessSignature");
NotificationHubDescription hub = namespaceManager.getNotificationHub("My Real Hubname");
assertNotNull(hub.getGcmCredential());

Failed tests: InstallationWnsFull(com.windowsazure.messaging.InstallationParseTest)

com.windowsazure.messaging.InstallationParseTest gives:

Tests run: 3, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.107 sec <<< FAILURE!
InstallationWnsFull(com.windowsazure.messaging.InstallationParseTest) Time elapsed: 0.014 sec <<< FAILURE!
java.lang.AssertionError
at org.junit.Assert.fail(Assert.java:86)
at org.junit.Assert.assertTrue(Assert.java:41)
at org.junit.Assert.assertTrue(Assert.java:52)
at com.windowsazure.messaging.InstallationParseTest.InstallationWnsFull(InstallationParseTest.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175)
at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68)

[BUG] Can not send message to Baidu PNS server.

Describe the bug
We are using 21v Azure China, and use Notification hub to push messages to Baidu PNS.
Now, we can use following code to push messages to Baidu PNS, and Android devices can received notifications:

        BaiduNotification messageType1 = new BaiduNotification("{\"title\":\"test title\", \"description\":\"test description\"}");
        Notification messageType2 = Notification.createBaiduNotification("{\"title\":\"test title\", \"description\":\"test description\"}");

But actually, we want to use template send, as we need to both support to push notifications to APNS.
So I write the following codes:

        Map<String, String> prop =  new HashMap<String, String>();
        prop.put("title", "测试2023");
        prop.put("description", "测试描述2023");
        Notification messageType3 = Notification.createTemplateNotification(prop);
        
        NotificationOutcome outcome = hub.sendNotification(messageType3);

But refer to my testing, can not use template to send messages to Baidu PNS.

Exception or Stack Trace
Add the exception log and stack trace if available

No error, but my device can not receive notifications.

To Reproduce
Steps to reproduce the behavior:

Please see my codes.

Expected behavior
A clear and concise description of what you expected to happen.

My android device can receive notifications.

Screenshots
If applicable, add screenshots to help explain your problem.

Setup (please complete the following information):

  • OS: [e.g. Windows 10, macOS 10.15] Win 11
  • IDE : [e.g. IntelliJ 2020.2] Android Studio + IntelliJ
  • Version of the Library used: latest 1.1.0

Additional context
Add any other context about the problem here.

Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issue as an incomplete report. Please do not provide any private information in this bug report.

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added

Release and publish on maven central

It would be really useful to release that project and publish it to maven central.

In its current state, the workflow is a no-go to me.

Thanks in advance!

Doc update for installation model

Please update the document to include "$InstallationId:{installation-Id}", without "$" the push notification doesn't work.

Regards,
Jana

Azure notification integration with java

Hi,

We have a requirement to integrate Azure notification hub, preferably using Java. I have a few questions here:-

  1. Is this project available in maven repository?
  2. Is this project production ready or still in beta stage?
  3. What are the preferred alternatives to integrate with notification hub?

Thanks,
Swagat

Assert fail in InstallationParseTest.java fails the build with Maven

Line 41 in InstallationWnsFull() shown commented out below...

@Test
public void InstallationWnsFull() throws IOException, SAXException, URISyntaxException {
    InputStream inputJson = this.getClass().getResourceAsStream("InstallationWnsFull");     
    Installation installation = Installation.fromJson(inputJson);
    assertNotNull(installation);
    assertEquals("123", installation.getInstallationId());
    assertEquals(NotificationPlatform.Wns, installation.getPlatform());
    assertEquals("wns-push-channel1", installation.getPushChannel());
    assertNotNull(installation.getTemplates());
    assertEquals("<?xml version=\"1.0\" encoding=\"utf-8\"?>", installation.getTemplates().get("template1").getBody());
    Date expiration = installation.getExpirationTime();

    //--> assertTrue(expiration.toString().equalsIgnoreCase("Wed Nov 26 15:34:01 PST 2014"));

    String expectedResultJson = IOUtils.toString(this.getClass().getResourceAsStream("InstallationWnsFullNoSpaces"));   
    String  actualResultJson = installation.toJson();
    assertEquals(expectedResultJson, actualResultJson); 

extra dependency needed: org.apache.httpcomponents.client5 httpclient5

Hi,

I am using a simple CLI project, no other dependencies besides:

        <dependency>
            <groupId>com.windowsazure</groupId>
            <artifactId>Notification-Hubs-java-sdk</artifactId>
            <version>1.0.3</version>
        </dependency>

    public static void main(String[] args) throws NotificationHubsException {
        NotificationHubClient client = new NotificationHub(HUB_CONNECTION_STRING, HUB_NAME);
    }

I am getting a class definition not found:
Exception in thread "httpclient-dispatch-1" java.lang.NoClassDefFoundError: org/apache/hc/core5/http2/impl/nio/ClientHttpProtocolNegotiator
at org.apache.hc.client5.http.impl.async.HttpAsyncClientEventHandlerFactory.createHandler(HttpAsyncClientEventHandlerFactory.java:257)

When i checked, org.apache.hc.core5.http2.impl.nio.ClientHttpProtocolNegotiator cannot be found in
org.apache.httpcomponents.client5:httpclient5:5.1.3 jar

To fix this i have to add and extra:

        <dependency>
            <groupId>org.apache.httpcomponents.client5</groupId>
            <artifactId>httpclient5</artifactId>
            <version>5.2-beta1</version>
        </dependency>

This dependency contains the missing class.

Why is this not included directly in the notification-hubs-java-sdk artifact?
I am using 1.0.3, the latest version on maven repo.

Should a new release with the upgraded http be required in order for this to work directly without any extra artifacts?

Please advise.

Thank you,
Serban

XML Injection for all registrations

All Registration XML strings are created using string manipulation. It is possible to create tag values and PNS handle values that result in XML that is not what was actually intended. The XML should be generated using an XMLStreamWriter.

[BUG] : java.lang.RuntimeException: org.apache.hc.core5.http.ParseException: Invalid protocol version; error at offset 0: <[0x2e][0x2f][0x30][0x31][0x32][0x33][0x34][0x35][0x36][0x37][0x38][0x39][0x3a][0x3b][0x3c][0x3d][0x3e]>

Describe the bug
A clear and concise description of what the bug is.
package com.windowsazure.messaging;
NotificationHub notificationHub = new NotificationHub(connUrl, hubPath);
notificationHub.sendNotification(fcmNotification);

I am sending FCM notification using above lines of code, NotificationHub is the SDK class. which in turn call below HTTPS call.

SimpleHttpRequest post = this.createRequest(uri, Method.POST).setBody(notification.getBody(), notification.getContentType()).build();

this.executeRequest(post, callback, 201, (response) -> {
this.sendNotificationOutcome(callback, post, response);
});

In NotificationHubsService class -

HttpClientManager.getHttpAsyncClient().execute(SimpleRequestProducer.create(request), SimpleResponseConsumer.create(), new FutureCallback()

In HttpClientManager class -
initializeHttpAsyncClient();
IOReactorConfig ioReactorConfig = IOReactorConfig.custom().setSoTimeout(Timeout.ofSeconds(5L)).build();
RequestConfig config = RequestConfig.custom().setConnectionRequestTimeout(Timeout.ofMilliseconds((long)connectionRequestTimeout)).setConnectTimeout(Timeout.ofMilliseconds((long)connectionTimeout)).build();
CloseableHttpAsyncClient client = HttpAsyncClients.custom().setIOReactorConfig(ioReactorConfig).setDefaultRequestConfig(config).setRetryStrategy(retryStrategy).build();
client.start();
httpAsyncClient = client;

then

HttpClientManager.getHttpAsyncClient().execute(SimpleRequestProducer.create(request), SimpleResponseConsumer.create(), new FutureCallback() {
public void completed(SimpleHttpResponse simpleHttpResponse) {
int statusCode = simpleHttpResponse.getCode();
if (Arrays.stream(statusCodes).noneMatch((x) -> {
return x == statusCode;
})) {
callback.failed(NotificationHubsException.create(simpleHttpResponse, statusCode, NotificationHubsService.this.getTrackingId(request)));
} else {
consumer.accept(simpleHttpResponse);
}
}

This piece of code produce exception, instead it should call Notification Hub and produce http status code, as 200 etc.

OS: It is failing in Cent OS
JDK Version: JDK 17

JDK 18 fails in Windows as well.
Exception or Stack Trace
java.lang.RuntimeException: org.apache.hc.core5.http.ParseException: Invalid protocol version; error at offset 0: <[0x2e][0x2f][0x30][0x31][0x32][0x33][0x34][0x35][0x36][0x37][0x38][0x39][0x3a][0x3b][0x3c][0x3d][0x3e]>

To Reproduce
I have written sample POC code and it is with Microsoft Support Engg, in Secure FTP, you can use that. Mohsin Khan.

Code Snippet
Added above.

Expected behavior
HTTP Status Code - which are valid.

Screenshots
NA

Setup (please complete the following information):

  • OS: [e.g. Windows 10, macOS 10.15] - Cent OS 8
  • IDE : [e.g. IntelliJ 2020.2] - IntelliJ 2021
  • Version of the Library used -
  • com.windowsazure Notification-Hubs-java-sdk 1.0.3

JDK 17

Additional context
Add any other context about the problem here.

Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issue as an incomplete report. Please do not provide any private information in this bug report.

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added

NotificationHub.createOrUpdateInstallation got Internal server error.

I execute the following code, I got an internal server error.
I debugged the Java SDK and compared it with the .NET SDK and found the cause.

    Installation installation = new Installation(id, NotificationPlatform.Fcm, deviceToken);
    hub.createOrUpdateInstallation(installation);

The direct cause is passing the FCM as the second argument. FCM is not allowed on the REST API. So I changed FCM to GCM, it works properly.

Create or overwrite an installation | Microsoft Docs

Platform Can be {APNS, WNS, MPNS, ADM, GCM}.

In .NET SDK, I set FCM in platform property , it is internally converted to GCM and posted to REST API. So it works correctly.
See https://github.com/Azure/azure-notificationhubs-dotnet/blob/master/src/Microsoft.Azure.NotificationHubs/NotificationPlatform.cs#L45

    var installation = new Installation();
    installation.PushChannel = deviceToken;
    installation.InstallationId = id;
    installation.Platform = NotificationPlatform.Fcm;
    client.CreateOrUpdateInstallation(installation);

I think the behavior of the Java SDK is unkind and confusing, so I think it should either be converted internally or raise an exception when FCM is specified.

Error: 400 Bad Request - notificationhub job payload is invalid

Hello I'm trying to export all registrations to a storage account but I am getting the following error:

com.windowsazure.messaging.NotificationHubsException: Error: HTTP/1.1 400 Bad Request - 400The supplied notificationhub job payload is invalid.TrackingId:f8f25bb7-75a6-4278-b8e5-9b551c689e33_G24,TimeStamp:6/23/2020 3:55:16 PM

Below the java code I am running:

package com.windowsazure.messaging;

public class App {

    public static void main(String[] args) {

        NotificationHub hub = new NotificationHub(
            "<connection string>",
            "notification hub name");

        // submit an export job
        NotificationHubJob job = new NotificationHubJob();
        job.setJobType(NotificationHubJobType.ExportRegistrations);
        job.setOutputContainerUri("<container uri with SAS signature>");

        try {
            job = hub.submitNotificationHubJob(job);
        } catch (NotificationHubsException e) {
            e.printStackTrace();
        }

        // wait until the job is done
        while (true) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e1) {
                e1.printStackTrace();
            }
            try {
                job = hub.getNotificationHubJob(job.getJobId());
            } catch (NotificationHubsException e) {
                e.printStackTrace();
            }
            if(job.getJobStatus() == NotificationHubJobStatus.Completed)
                break;
        }

	}

}

Does anyone have an idea about the reason of the error?
Thanks

[BUG] sendDirectNotification for batch of devices is returning 500 status for FCM notifications

Describe the bug
Using this SDK to send direct FCM (GCM) notifications to devices, both the sync and async methods for a single device handle are working fine.

However, the send direct notification for a list of device handles (batch) is consistently returning a 500, sync and async.

Initially the Notification hub instance was on the Free tier, so I assumed that was the problem and upgraded to Basic tier.
However it's been about 1h after the upgrade and the 500 error remains.

Exception or Stack Trace
com.windowsazure.messaging.NotificationHubsException: Tracking ID: 9137ed07-f7cf-42a7-98a3-71910413a1a4 Error: HTTP/2.0 500 Internal Server Error - 500Unknown error has occured. TrackingId:9137ed07-f7cf-42a7-98a3-71910413a1a4,TimeStamp:10/14/2022 4:10:33 PM +00:00
at com.windowsazure.messaging.NotificationHubsException.create(NotificationHubsException.java:113)
at com.windowsazure.messaging.NotificationHubsService$1.completed(NotificationHubsService.java:69)
at com.windowsazure.messaging.NotificationHubsService$1.completed(NotificationHubsService.java:63)
at org.apache.hc.core5.concurrent.BasicFuture.completed(BasicFuture.java:123)
at org.apache.hc.core5.concurrent.ComplexFuture.completed(ComplexFuture.java:72)
at org.apache.hc.client5.http.impl.async.InternalAbstractHttpAsyncClient$1$3$1.completed(InternalAbstractHttpAsyncClient.java:298)
at org.apache.hc.core5.http.nio.support.AbstractAsyncResponseConsumer$1.completed(AbstractAsyncResponseConsumer.java:101)
at org.apache.hc.core5.http.nio.entity.AbstractBinAsyncEntityConsumer.completed(AbstractBinAsyncEntityConsumer.java:84)
at org.apache.hc.core5.http.nio.entity.AbstractBinDataConsumer.streamEnd(AbstractBinDataConsumer.java:81)
at org.apache.hc.core5.http.nio.support.AbstractAsyncResponseConsumer.streamEnd(AbstractAsyncResponseConsumer.java:142)
at org.apache.hc.client5.http.impl.async.HttpAsyncMainClientExec$1.streamEnd(HttpAsyncMainClientExec.java:233)
at org.apache.hc.core5.http2.impl.nio.ClientH2StreamHandler.consumeData(ClientH2StreamHandler.java:239)
at org.apache.hc.core5.http2.impl.nio.AbstractH2StreamMultiplexer$H2Stream.consumeData(AbstractH2StreamMultiplexer.java:1604)
at org.apache.hc.core5.http2.impl.nio.AbstractH2StreamMultiplexer.consumeDataFrame(AbstractH2StreamMultiplexer.java:1010)
at org.apache.hc.core5.http2.impl.nio.AbstractH2StreamMultiplexer.consumeFrame(AbstractH2StreamMultiplexer.java:728)
at org.apache.hc.core5.http2.impl.nio.AbstractH2StreamMultiplexer.onInput(AbstractH2StreamMultiplexer.java:444)
at org.apache.hc.core5.http2.impl.nio.AbstractH2IOEventHandler.inputReady(AbstractH2IOEventHandler.java:65)
at org.apache.hc.core5.http2.impl.nio.ClientH2IOEventHandler.inputReady(ClientH2IOEventHandler.java:39)
at org.apache.hc.core5.reactor.ssl.SSLIOSession.decryptData(SSLIOSession.java:594)
at org.apache.hc.core5.reactor.ssl.SSLIOSession.access$200(SSLIOSession.java:73)
at org.apache.hc.core5.reactor.ssl.SSLIOSession$1.inputReady(SSLIOSession.java:201)
at org.apache.hc.core5.reactor.InternalDataChannel.onIOEvent(InternalDataChannel.java:140)
at org.apache.hc.core5.reactor.InternalChannel.handleIOEvent(InternalChannel.java:51)
at org.apache.hc.core5.reactor.SingleCoreIOReactor.processEvents(SingleCoreIOReactor.java:178)
at org.apache.hc.core5.reactor.SingleCoreIOReactor.doExecute(SingleCoreIOReactor.java:127)
at org.apache.hc.core5.reactor.AbstractSingleCoreIOReactor.execute(AbstractSingleCoreIOReactor.java:85)
at org.apache.hc.core5.reactor.IOReactorWorker.run(IOReactorWorker.java:44)

To Reproduce

  • Setup a notification hub
  • Register a device
  • Send a direct notification to the device handle using the batch method

Code Snippet

  final SyncCallback<NotificationOutcome> callback = new SyncCallback<>();
  client.sendDirectNotificationAsync(notification, tokens, callback);
  callback.getResult();

Expected behavior
201 response, notification sent and received in device

Setup

  • OS: macOS 12.6 with M1 Pro
  • IDE : IntelliJ IDEA 2022.2.2 (Ultimate Edition)
  • com.windowsazure Notification-Hubs-java-sdk 1.0.3
  • JDK 17 (Eclipse Temurin)

Information Checklist

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added

Push Notifications do not work for iOS 13.x

I am working on the background application to send notification to apple devices that are upgraded to the iOS version 13.1.2.
The notifications are perfectly sent to iOS 12 version but not to iOS version 13.
I have added the following statements as per the suggestions given in the stackoverflow website
notification.headers.put("apns-push-type", "alert");
notification.headers.put("apns-priority", "5");
Can you please provide the fix for this?

We have used all the classes that you provided in this github.
https://github.com/Azure/azure-notificationhubs-java-backend

The backend Java application, which we wrote the code for sending push notifications. It is sending the push notifications perfectly to iOS 12.x version devices, but not to the iOS 13.x

createWindowsNotification doesn't add X-WNS-Type header when the message body has xml prolog

This method has been changed recently to replace contains checks with regex.

However a regex like "^<toast[\s\S]*>[\s\S]+$" does not match when the message body has a xml prolog. Also noted this regex seems correct in other languages.

ex message body from test send in Azure portal


<?xml version="1.0" encoding="utf-8"?>
<toast>
<visual><binding template="ToastText01">
<text id="1">Test message</text>
</binding>
</visual>
</toast>

Tried "\s*<toast[\s\S]*>[\s\S]+$" and it seems to work with java regex.

Push notifications are not working for iOS 13 operating system

I am working on the background application to send notification to apple devices that are upgraded to the iOS version 13.1.2.

The notifications are perfectly sent to iOS 12 version but not to iOS version 13.

I have added the following statements as per the suggestions given in the stackoverflow website
notification.headers.put("apns-push-type", "alert");
notification.headers.put("apns-priority", "5");

Can you please provide the fix for this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.