Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/1.0.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
waileong committed Sep 18, 2024
2 parents 135da47 + b2dd6dc commit 6096205
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 27 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
}

group = 'io.github.waileong'
version = '1.0.3'
version = '1.0.4'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ org.gradle.workers.max=4
org.gradle.jvmargs=-Xmx1024M


spring_boot_version=3.2.3
spring_boot_version=3.3.3
jjwt_version=0.11.5
commons_pool2_version=2.12.0
6 changes: 3 additions & 3 deletions readme.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
= Spring Boot and Firebase Cloud Messaging (FCM) Integration via REST API for Push Notifications

image:https://img.shields.io/badge/Spring%20Boot-3.2.x-brightgreen.svg[link="https://spring.io/projects/spring-boot"]
image:https://img.shields.io/badge/Spring%20Boot-3.3.x-brightgreen.svg[link="https://spring.io/projects/spring-boot"]
image:https://img.shields.io/badge/Java-17-blue.svg[link="https://adoptopenjdk.net/?variant=openjdk17&jvmVariant=hotspot"]
image:https://img.shields.io/badge/Java-21-blue.svg[link="https://adoptopenjdk.net/?variant=openjdk21&jvmVariant=hotspot"]

Expand Down Expand Up @@ -61,7 +61,7 @@ Add the following to your `build.gradle`:

----
dependencies {
implementation 'io.github.waileong:spring-boot-fcm:1.0.3'
implementation 'io.github.waileong:spring-boot-fcm:1.0.4'
}
----

Expand All @@ -74,7 +74,7 @@ Insert this dependency in your `pom.xml`:
<dependency>
<groupId>io.github.waileong</groupId>
<artifactId>spring-boot-fcm</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
</dependency>
</dependencies>
----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import org.apache.commons.pool2.BasePooledObjectFactory;
import org.apache.commons.pool2.PooledObject;
import org.apache.commons.pool2.impl.DefaultPooledObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.time.Instant;
import java.util.Date;
Expand All @@ -29,7 +27,6 @@
* @author Wai Leong
*/
public class FcmJwtTokenPooledObjectFactory extends BasePooledObjectFactory<FcmJwtToken> {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
private final FcmProperties.Credential credential;
private static final String FCM_ENDPOINT_URL = "https://fcm.googleapis.com/";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
public class FcmRestClientException extends RuntimeException {
private final int httpStatus;
private final FcmError error;
private final transient FcmError error;

/**
* Constructs a new FcmRestClientException with specified HTTP status code and FCM error details.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.waileong.fcm.service.domain.FcmErrorResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatusCode;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.web.client.DefaultResponseErrorHandler;
Expand All @@ -18,7 +16,6 @@
* @author Wai Leong
**/
public class FcmRestClientResponseErrorHandler extends DefaultResponseErrorHandler {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
private final ObjectMapper objectMapper;

public FcmRestClientResponseErrorHandler(ObjectMapper objectMapper) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import io.github.waileong.fcm.service.domain.FcmMessage;
import io.github.waileong.fcm.service.domain.FcmSendRequest;
import org.apache.commons.pool2.impl.GenericObjectPool;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.aot.hint.annotation.RegisterReflectionForBinding;
import org.springframework.web.client.RestClient;

Expand All @@ -28,7 +26,6 @@
*/
@RegisterReflectionForBinding({FcmSendRequest.class, FcmMessage.class, FcmError.class, FcmErrorResponse.class})
public class FcmServiceImpl implements FcmService {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
private final RestClient fcmRestClient;
private final GenericObjectPool<FcmJwtToken> fcmJwtTokenPool;

Expand Down Expand Up @@ -61,7 +58,7 @@ private String getAccessToken(GenericObjectPool<FcmJwtToken> pool) {
fcmJwtToken = pool.borrowObject();
return fcmJwtToken.token();
} catch (Exception e) {
throw new RuntimeException(e);
throw new IllegalStateException(e);
} finally {
if (fcmJwtToken != null) {
pool.returnObject(fcmJwtToken);
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/io/github/waileong/fcm/util/RSAKeyPairUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
*/
public class RSAKeyPairUtil {

private RSAKeyPairUtil() {
throw new IllegalStateException("Utility class");
}

/**
* Converts a base64 encoded string representation of an RSA private key into an {@link RSAPrivateKey} object.
* <p>
Expand Down
19 changes: 8 additions & 11 deletions src/test/java/io/github/waileong/fcm/service/FcmServiceTest.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package io.github.waileong.fcm.service;

import jakarta.validation.Validator;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import io.github.waileong.fcm.config.FcmAutoConfiguration;
import io.github.waileong.fcm.service.domain.FcmMessage;
import io.github.waileong.fcm.service.domain.FcmNotification;
import io.github.waileong.fcm.service.domain.FcmSendRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import jakarta.validation.Validator;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
Expand Down Expand Up @@ -37,8 +35,7 @@
webEnvironment = SpringBootTest.WebEnvironment.NONE)
@ActiveProfiles("test")
@Disabled
public class FcmServiceTest {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
class FcmServiceTest {

static {
// Enable detailed HTTP client logging for debugging purposes
Expand All @@ -49,7 +46,7 @@ public class FcmServiceTest {
private FcmService fcmService;

@Test
public void testSendNotification() throws Exception {
void testSendNotification() {
String deviceToken = "";
String title = "FCM Title";
String message = "FCM Message";
Expand All @@ -75,14 +72,14 @@ public void testSendNotification() throws Exception {
*/
@Configuration(proxyBeanMethods = false)
@Import({FcmAutoConfiguration.class, TaskExecutionAutoConfiguration.class})
public static class ContextConfiguration {
static class ContextConfiguration {
@Bean
public Validator validator() {
Validator validator() {
return new LocalValidatorFactoryBean();
}

@Bean
public MethodValidationPostProcessor methodValidationPostProcessor() {
MethodValidationPostProcessor methodValidationPostProcessor() {
return new MethodValidationPostProcessor();
}
}
Expand Down

0 comments on commit 6096205

Please sign in to comment.