This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit 79faebfd76045c4f454c24ded891ab79a8dd4535 Author: Andrea Cosentino <[email protected]> AuthorDate: Tue Jun 8 14:04:30 2021 +0200 CAMEL-16519 - Remove Camel-APNS --- components/camel-apns/pom.xml | 133 --------- .../component/apns/ApnsComponentConfigurer.java | 67 ----- .../component/apns/ApnsEndpointConfigurer.java | 166 ----------- .../component/apns/ApnsEndpointUriFactory.java | 82 ------ .../services/org/apache/camel/component.properties | 7 - .../services/org/apache/camel/component/apns | 2 - .../org/apache/camel/configurer/apns-component | 2 - .../org/apache/camel/configurer/apns-endpoint | 2 - .../org/apache/camel/urifactory/apns-endpoint | 2 - .../org/apache/camel/component/apns/apns.json | 54 ---- .../camel-apns/src/main/docs/apns-component.adoc | 323 --------------------- .../apache/camel/component/apns/ApnsComponent.java | 65 ----- .../apache/camel/component/apns/ApnsConsumer.java | 104 ------- .../apache/camel/component/apns/ApnsEndpoint.java | 95 ------ .../apache/camel/component/apns/ApnsProducer.java | 145 --------- .../component/apns/factory/ApnsServiceFactory.java | 273 ----------------- .../camel/component/apns/model/ApnsConstants.java | 28 -- .../component/apns/model/ConnectionStrategy.java | 25 -- .../camel/component/apns/model/InactiveDevice.java | 53 ---- .../camel/component/apns/model/MessageType.java | 25 -- .../component/apns/model/ReconnectionPolicy.java | 41 --- .../camel/component/apns/util/AssertUtils.java | 36 --- .../camel/component/apns/util/ParamUtils.java | 40 --- .../camel/component/apns/util/ResourceUtils.java | 73 ----- .../camel/component/apns/util/StringUtils.java | 42 --- .../internal/ApnsFeedbackParsingUtilsAcessor.java | 28 -- .../apns/ApnsConsumerIdleMessageTest.java | 94 ------ .../camel/component/apns/ApnsConsumerTest.java | 104 ------- .../camel/component/apns/ApnsProducerTest.java | 114 -------- .../apns/ApnsProducerWithoutTokensHeaderTest.java | 93 ------ .../apns/factory/ApnsServiceFactoryTest.java | 82 ------ .../factory/ConfiguredApnsServiceFactoryTest.java | 57 ---- .../apns/spring/SpringApnsConsumerTest.java | 87 ------ .../camel/component/apns/util/ApnsUtils.java | 155 ---------- .../camel/component/apns/util/AssertUtilsTest.java | 56 ---- .../camel/component/apns/util/StringUtilsTest.java | 56 ---- .../camel/component/apns/util/TestConstants.java | 30 -- .../src/test/resources/log4j2.properties | 30 -- .../apns/spring/SpringApnsConsumerTest-context.xml | 53 ---- 39 files changed, 2924 deletions(-) diff --git a/components/camel-apns/pom.xml b/components/camel-apns/pom.xml deleted file mode 100644 index 5478dd7..0000000 --- a/components/camel-apns/pom.xml +++ /dev/null @@ -1,133 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.camel</groupId> - <artifactId>components</artifactId> - <version>3.11.0-SNAPSHOT</version> - </parent> - - <artifactId>camel-apns</artifactId> - <packaging>jar</packaging> - - <name>Camel :: APNS (deprecated)</name> - <description>A Camel Apple Push Notification Server Component</description> - - <properties> - </properties> - - <dependencies> - - <!-- Camel --> - <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-support</artifactId> - </dependency> - - <!-- Apns --> - <dependency> - <groupId>com.notnoop.apns</groupId> - <artifactId>apns</artifactId> - <version>${java-apns-version}</version> - <exclusions> - <exclusion> - <groupId>ch.qos.logback</groupId> - <artifactId>logback-classic</artifactId> - </exclusion> - <exclusion> - <groupId>org.codehaus.jackson</groupId> - <artifactId>jackson-core-asl</artifactId> - </exclusion> - <exclusion> - <groupId>org.codehaus.jackson</groupId> - <artifactId>jackson-mapper-asl</artifactId> - </exclusion> - </exclusions> - </dependency> - - <!-- Jackson --> - <dependency> - <groupId>com.fasterxml.jackson.core</groupId> - <artifactId>jackson-core</artifactId> - <version>${jackson2-version}</version> - </dependency> - <dependency> - <groupId>com.fasterxml.jackson.core</groupId> - <artifactId>jackson-annotations</artifactId> - <version>${jackson2-version}</version> - </dependency> - <dependency> - <groupId>com.fasterxml.jackson.core</groupId> - <artifactId>jackson-databind</artifactId> - </dependency> - - <!-- Camel for test --> - <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-test-junit5</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-spring-xml</artifactId> - <scope>test</scope> - </dependency> - - <!-- Spring --> - <!-- Use of Spring for tests --> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-test</artifactId> - <scope>test</scope> - </dependency> - - <!-- Logging --> - <!-- Use logging for test --> - <dependency> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-slf4j-impl</artifactId> - <scope>test</scope> - </dependency> - - <!-- Junit --> - <dependency> - <groupId>org.junit.jupiter</groupId> - <artifactId>junit-jupiter</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-junit-jupiter</artifactId> - <scope>test</scope> - </dependency> - - <!-- for testing apns --> - <dependency> - <groupId>com.notnoop.apns</groupId> - <artifactId>apns</artifactId> - <version>${java-apns-version}</version> - <type>test-jar</type> - <scope>test</scope> - </dependency> - - </dependencies> -</project> diff --git a/components/camel-apns/src/generated/java/org/apache/camel/component/apns/ApnsComponentConfigurer.java b/components/camel-apns/src/generated/java/org/apache/camel/component/apns/ApnsComponentConfigurer.java deleted file mode 100644 index 572dd12..0000000 --- a/components/camel-apns/src/generated/java/org/apache/camel/component/apns/ApnsComponentConfigurer.java +++ /dev/null @@ -1,67 +0,0 @@ -/* Generated by camel build tools - do NOT edit this file! */ -package org.apache.camel.component.apns; - -import java.util.Map; - -import org.apache.camel.CamelContext; -import org.apache.camel.spi.ExtendedPropertyConfigurerGetter; -import org.apache.camel.spi.PropertyConfigurerGetter; -import org.apache.camel.spi.ConfigurerStrategy; -import org.apache.camel.spi.GeneratedPropertyConfigurer; -import org.apache.camel.util.CaseInsensitiveMap; -import org.apache.camel.support.component.PropertyConfigurerSupport; - -/** - * Generated by camel build tools - do NOT edit this file! - */ -@SuppressWarnings("unchecked") -public class ApnsComponentConfigurer extends PropertyConfigurerSupport implements GeneratedPropertyConfigurer, PropertyConfigurerGetter { - - @Override - public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) { - ApnsComponent target = (ApnsComponent) obj; - switch (ignoreCase ? name.toLowerCase() : name) { - case "apnsservice": - case "apnsService": target.setApnsService(property(camelContext, com.notnoop.apns.ApnsService.class, value)); return true; - case "autowiredenabled": - case "autowiredEnabled": target.setAutowiredEnabled(property(camelContext, boolean.class, value)); return true; - case "bridgeerrorhandler": - case "bridgeErrorHandler": target.setBridgeErrorHandler(property(camelContext, boolean.class, value)); return true; - case "lazystartproducer": - case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true; - default: return false; - } - } - - @Override - public Class<?> getOptionType(String name, boolean ignoreCase) { - switch (ignoreCase ? name.toLowerCase() : name) { - case "apnsservice": - case "apnsService": return com.notnoop.apns.ApnsService.class; - case "autowiredenabled": - case "autowiredEnabled": return boolean.class; - case "bridgeerrorhandler": - case "bridgeErrorHandler": return boolean.class; - case "lazystartproducer": - case "lazyStartProducer": return boolean.class; - default: return null; - } - } - - @Override - public Object getOptionValue(Object obj, String name, boolean ignoreCase) { - ApnsComponent target = (ApnsComponent) obj; - switch (ignoreCase ? name.toLowerCase() : name) { - case "apnsservice": - case "apnsService": return target.getApnsService(); - case "autowiredenabled": - case "autowiredEnabled": return target.isAutowiredEnabled(); - case "bridgeerrorhandler": - case "bridgeErrorHandler": return target.isBridgeErrorHandler(); - case "lazystartproducer": - case "lazyStartProducer": return target.isLazyStartProducer(); - default: return null; - } - } -} - diff --git a/components/camel-apns/src/generated/java/org/apache/camel/component/apns/ApnsEndpointConfigurer.java b/components/camel-apns/src/generated/java/org/apache/camel/component/apns/ApnsEndpointConfigurer.java deleted file mode 100644 index 84f9414..0000000 --- a/components/camel-apns/src/generated/java/org/apache/camel/component/apns/ApnsEndpointConfigurer.java +++ /dev/null @@ -1,166 +0,0 @@ -/* Generated by camel build tools - do NOT edit this file! */ -package org.apache.camel.component.apns; - -import java.util.Map; - -import org.apache.camel.CamelContext; -import org.apache.camel.spi.ExtendedPropertyConfigurerGetter; -import org.apache.camel.spi.PropertyConfigurerGetter; -import org.apache.camel.spi.ConfigurerStrategy; -import org.apache.camel.spi.GeneratedPropertyConfigurer; -import org.apache.camel.util.CaseInsensitiveMap; -import org.apache.camel.support.component.PropertyConfigurerSupport; - -/** - * Generated by camel build tools - do NOT edit this file! - */ -@SuppressWarnings("unchecked") -public class ApnsEndpointConfigurer extends PropertyConfigurerSupport implements GeneratedPropertyConfigurer, PropertyConfigurerGetter { - - @Override - public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) { - ApnsEndpoint target = (ApnsEndpoint) obj; - switch (ignoreCase ? name.toLowerCase() : name) { - case "backofferrorthreshold": - case "backoffErrorThreshold": target.setBackoffErrorThreshold(property(camelContext, int.class, value)); return true; - case "backoffidlethreshold": - case "backoffIdleThreshold": target.setBackoffIdleThreshold(property(camelContext, int.class, value)); return true; - case "backoffmultiplier": - case "backoffMultiplier": target.setBackoffMultiplier(property(camelContext, int.class, value)); return true; - case "bridgeerrorhandler": - case "bridgeErrorHandler": target.setBridgeErrorHandler(property(camelContext, boolean.class, value)); return true; - case "delay": target.setDelay(property(camelContext, long.class, value)); return true; - case "exceptionhandler": - case "exceptionHandler": target.setExceptionHandler(property(camelContext, org.apache.camel.spi.ExceptionHandler.class, value)); return true; - case "exchangepattern": - case "exchangePattern": target.setExchangePattern(property(camelContext, org.apache.camel.ExchangePattern.class, value)); return true; - case "greedy": target.setGreedy(property(camelContext, boolean.class, value)); return true; - case "initialdelay": - case "initialDelay": target.setInitialDelay(property(camelContext, long.class, value)); return true; - case "lazystartproducer": - case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true; - case "pollstrategy": - case "pollStrategy": target.setPollStrategy(property(camelContext, org.apache.camel.spi.PollingConsumerPollStrategy.class, value)); return true; - case "repeatcount": - case "repeatCount": target.setRepeatCount(property(camelContext, long.class, value)); return true; - case "runlogginglevel": - case "runLoggingLevel": target.setRunLoggingLevel(property(camelContext, org.apache.camel.LoggingLevel.class, value)); return true; - case "scheduledexecutorservice": - case "scheduledExecutorService": target.setScheduledExecutorService(property(camelContext, java.util.concurrent.ScheduledExecutorService.class, value)); return true; - case "scheduler": target.setScheduler(property(camelContext, java.lang.Object.class, value)); return true; - case "schedulerproperties": - case "schedulerProperties": target.setSchedulerProperties(property(camelContext, java.util.Map.class, value)); return true; - case "sendemptymessagewhenidle": - case "sendEmptyMessageWhenIdle": target.setSendEmptyMessageWhenIdle(property(camelContext, boolean.class, value)); return true; - case "startscheduler": - case "startScheduler": target.setStartScheduler(property(camelContext, boolean.class, value)); return true; - case "timeunit": - case "timeUnit": target.setTimeUnit(property(camelContext, java.util.concurrent.TimeUnit.class, value)); return true; - case "tokens": target.setTokens(property(camelContext, java.lang.String.class, value)); return true; - case "usefixeddelay": - case "useFixedDelay": target.setUseFixedDelay(property(camelContext, boolean.class, value)); return true; - default: return false; - } - } - - @Override - public Class<?> getOptionType(String name, boolean ignoreCase) { - switch (ignoreCase ? name.toLowerCase() : name) { - case "backofferrorthreshold": - case "backoffErrorThreshold": return int.class; - case "backoffidlethreshold": - case "backoffIdleThreshold": return int.class; - case "backoffmultiplier": - case "backoffMultiplier": return int.class; - case "bridgeerrorhandler": - case "bridgeErrorHandler": return boolean.class; - case "delay": return long.class; - case "exceptionhandler": - case "exceptionHandler": return org.apache.camel.spi.ExceptionHandler.class; - case "exchangepattern": - case "exchangePattern": return org.apache.camel.ExchangePattern.class; - case "greedy": return boolean.class; - case "initialdelay": - case "initialDelay": return long.class; - case "lazystartproducer": - case "lazyStartProducer": return boolean.class; - case "pollstrategy": - case "pollStrategy": return org.apache.camel.spi.PollingConsumerPollStrategy.class; - case "repeatcount": - case "repeatCount": return long.class; - case "runlogginglevel": - case "runLoggingLevel": return org.apache.camel.LoggingLevel.class; - case "scheduledexecutorservice": - case "scheduledExecutorService": return java.util.concurrent.ScheduledExecutorService.class; - case "scheduler": return java.lang.Object.class; - case "schedulerproperties": - case "schedulerProperties": return java.util.Map.class; - case "sendemptymessagewhenidle": - case "sendEmptyMessageWhenIdle": return boolean.class; - case "startscheduler": - case "startScheduler": return boolean.class; - case "timeunit": - case "timeUnit": return java.util.concurrent.TimeUnit.class; - case "tokens": return java.lang.String.class; - case "usefixeddelay": - case "useFixedDelay": return boolean.class; - default: return null; - } - } - - @Override - public Object getOptionValue(Object obj, String name, boolean ignoreCase) { - ApnsEndpoint target = (ApnsEndpoint) obj; - switch (ignoreCase ? name.toLowerCase() : name) { - case "backofferrorthreshold": - case "backoffErrorThreshold": return target.getBackoffErrorThreshold(); - case "backoffidlethreshold": - case "backoffIdleThreshold": return target.getBackoffIdleThreshold(); - case "backoffmultiplier": - case "backoffMultiplier": return target.getBackoffMultiplier(); - case "bridgeerrorhandler": - case "bridgeErrorHandler": return target.isBridgeErrorHandler(); - case "delay": return target.getDelay(); - case "exceptionhandler": - case "exceptionHandler": return target.getExceptionHandler(); - case "exchangepattern": - case "exchangePattern": return target.getExchangePattern(); - case "greedy": return target.isGreedy(); - case "initialdelay": - case "initialDelay": return target.getInitialDelay(); - case "lazystartproducer": - case "lazyStartProducer": return target.isLazyStartProducer(); - case "pollstrategy": - case "pollStrategy": return target.getPollStrategy(); - case "repeatcount": - case "repeatCount": return target.getRepeatCount(); - case "runlogginglevel": - case "runLoggingLevel": return target.getRunLoggingLevel(); - case "scheduledexecutorservice": - case "scheduledExecutorService": return target.getScheduledExecutorService(); - case "scheduler": return target.getScheduler(); - case "schedulerproperties": - case "schedulerProperties": return target.getSchedulerProperties(); - case "sendemptymessagewhenidle": - case "sendEmptyMessageWhenIdle": return target.isSendEmptyMessageWhenIdle(); - case "startscheduler": - case "startScheduler": return target.isStartScheduler(); - case "timeunit": - case "timeUnit": return target.getTimeUnit(); - case "tokens": return target.getTokens(); - case "usefixeddelay": - case "useFixedDelay": return target.isUseFixedDelay(); - default: return null; - } - } - - @Override - public Object getCollectionValueType(Object target, String name, boolean ignoreCase) { - switch (ignoreCase ? name.toLowerCase() : name) { - case "schedulerproperties": - case "schedulerProperties": return java.lang.Object.class; - default: return null; - } - } -} - diff --git a/components/camel-apns/src/generated/java/org/apache/camel/component/apns/ApnsEndpointUriFactory.java b/components/camel-apns/src/generated/java/org/apache/camel/component/apns/ApnsEndpointUriFactory.java deleted file mode 100644 index 65b78bc..0000000 --- a/components/camel-apns/src/generated/java/org/apache/camel/component/apns/ApnsEndpointUriFactory.java +++ /dev/null @@ -1,82 +0,0 @@ -/* Generated by camel build tools - do NOT edit this file! */ -package org.apache.camel.component.apns; - -import java.net.URISyntaxException; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.camel.spi.EndpointUriFactory; - -/** - * Generated by camel build tools - do NOT edit this file! - */ -public class ApnsEndpointUriFactory extends org.apache.camel.support.component.EndpointUriFactorySupport implements EndpointUriFactory { - - private static final String BASE = ":name"; - - private static final Set<String> PROPERTY_NAMES; - private static final Set<String> SECRET_PROPERTY_NAMES; - static { - Set<String> props = new HashSet<>(22); - props.add("backoffMultiplier"); - props.add("sendEmptyMessageWhenIdle"); - props.add("schedulerProperties"); - props.add("exchangePattern"); - props.add("initialDelay"); - props.add("backoffIdleThreshold"); - props.add("scheduler"); - props.add("lazyStartProducer"); - props.add("bridgeErrorHandler"); - props.add("delay"); - props.add("useFixedDelay"); - props.add("pollStrategy"); - props.add("runLoggingLevel"); - props.add("startScheduler"); - props.add("backoffErrorThreshold"); - props.add("name"); - props.add("greedy"); - props.add("tokens"); - props.add("scheduledExecutorService"); - props.add("exceptionHandler"); - props.add("repeatCount"); - props.add("timeUnit"); - PROPERTY_NAMES = Collections.unmodifiableSet(props); - SECRET_PROPERTY_NAMES = Collections.emptySet(); - } - - @Override - public boolean isEnabled(String scheme) { - return "apns".equals(scheme); - } - - @Override - public String buildUri(String scheme, Map<String, Object> properties, boolean encode) throws URISyntaxException { - String syntax = scheme + BASE; - String uri = syntax; - - Map<String, Object> copy = new HashMap<>(properties); - - uri = buildPathParameter(syntax, uri, "name", null, false, copy); - uri = buildQueryParameters(uri, copy, encode); - return uri; - } - - @Override - public Set<String> propertyNames() { - return PROPERTY_NAMES; - } - - @Override - public Set<String> secretPropertyNames() { - return SECRET_PROPERTY_NAMES; - } - - @Override - public boolean isLenientProperties() { - return false; - } -} - diff --git a/components/camel-apns/src/generated/resources/META-INF/services/org/apache/camel/component.properties b/components/camel-apns/src/generated/resources/META-INF/services/org/apache/camel/component.properties deleted file mode 100644 index 54343a9..0000000 --- a/components/camel-apns/src/generated/resources/META-INF/services/org/apache/camel/component.properties +++ /dev/null @@ -1,7 +0,0 @@ -# Generated by camel build tools - do NOT edit this file! -components=apns -groupId=org.apache.camel -artifactId=camel-apns -version=3.11.0-SNAPSHOT -projectName=Camel :: APNS (deprecated) -projectDescription=A Camel Apple Push Notification Server Component diff --git a/components/camel-apns/src/generated/resources/META-INF/services/org/apache/camel/component/apns b/components/camel-apns/src/generated/resources/META-INF/services/org/apache/camel/component/apns deleted file mode 100644 index d9a58d2..0000000 --- a/components/camel-apns/src/generated/resources/META-INF/services/org/apache/camel/component/apns +++ /dev/null @@ -1,2 +0,0 @@ -# Generated by camel build tools - do NOT edit this file! -class=org.apache.camel.component.apns.ApnsComponent diff --git a/components/camel-apns/src/generated/resources/META-INF/services/org/apache/camel/configurer/apns-component b/components/camel-apns/src/generated/resources/META-INF/services/org/apache/camel/configurer/apns-component deleted file mode 100644 index e90fe58..0000000 --- a/components/camel-apns/src/generated/resources/META-INF/services/org/apache/camel/configurer/apns-component +++ /dev/null @@ -1,2 +0,0 @@ -# Generated by camel build tools - do NOT edit this file! -class=org.apache.camel.component.apns.ApnsComponentConfigurer diff --git a/components/camel-apns/src/generated/resources/META-INF/services/org/apache/camel/configurer/apns-endpoint b/components/camel-apns/src/generated/resources/META-INF/services/org/apache/camel/configurer/apns-endpoint deleted file mode 100644 index ed38f89..0000000 --- a/components/camel-apns/src/generated/resources/META-INF/services/org/apache/camel/configurer/apns-endpoint +++ /dev/null @@ -1,2 +0,0 @@ -# Generated by camel build tools - do NOT edit this file! -class=org.apache.camel.component.apns.ApnsEndpointConfigurer diff --git a/components/camel-apns/src/generated/resources/META-INF/services/org/apache/camel/urifactory/apns-endpoint b/components/camel-apns/src/generated/resources/META-INF/services/org/apache/camel/urifactory/apns-endpoint deleted file mode 100644 index 25e689c..0000000 --- a/components/camel-apns/src/generated/resources/META-INF/services/org/apache/camel/urifactory/apns-endpoint +++ /dev/null @@ -1,2 +0,0 @@ -# Generated by camel build tools - do NOT edit this file! -class=org.apache.camel.component.apns.ApnsEndpointUriFactory diff --git a/components/camel-apns/src/generated/resources/org/apache/camel/component/apns/apns.json b/components/camel-apns/src/generated/resources/org/apache/camel/component/apns/apns.json deleted file mode 100644 index 2bce4ae..0000000 --- a/components/camel-apns/src/generated/resources/org/apache/camel/component/apns/apns.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "component": { - "kind": "component", - "name": "apns", - "title": "APNS", - "description": "Send notifications to Apple iOS devices.", - "deprecated": true, - "firstVersion": "2.8.0", - "label": "eventbus,mobile", - "javaType": "org.apache.camel.component.apns.ApnsComponent", - "supportLevel": "Stable", - "groupId": "org.apache.camel", - "artifactId": "camel-apns", - "version": "3.11.0-SNAPSHOT", - "scheme": "apns", - "extendsScheme": "", - "syntax": "apns:name", - "async": false, - "api": false, - "consumerOnly": false, - "producerOnly": false, - "lenientProperties": false - }, - "componentProperties": { - "apnsService": { "kind": "property", "displayName": "Apns Service", "group": "common", "label": "", "required": true, "type": "object", "javaType": "com.notnoop.apns.ApnsService", "deprecated": false, "autowired": false, "secret": false, "description": "The ApnsService to use. The org.apache.camel.component.apns.factory.ApnsServiceFactory can be used to build a ApnsService" }, - "bridgeErrorHandler": { "kind": "property", "displayName": "Bridge Error Handler", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a me [...] - "lazyStartProducer": { "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during star [...] - "autowiredEnabled": { "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which t [...] - }, - "properties": { - "name": { "kind": "path", "displayName": "Name", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Name of the endpoint" }, - "tokens": { "kind": "parameter", "displayName": "Tokens", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Configure this property in case you want to statically declare tokens related to devices you want to notify. Tokens are separated by comma." }, - "bridgeErrorHandler": { "kind": "parameter", "displayName": "Bridge Error Handler", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a m [...] - "sendEmptyMessageWhenIdle": { "kind": "parameter", "displayName": "Send Empty Message When Idle", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If the polling consumer did not poll any files, you can enable this option to send an empty message (no body) instead." }, - "exceptionHandler": { "kind": "parameter", "displayName": "Exception Handler", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.spi.ExceptionHandler", "optionalPrefix": "consumer.", "deprecated": false, "autowired": false, "secret": false, "description": "To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the con [...] - "exchangePattern": { "kind": "parameter", "displayName": "Exchange Pattern", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.ExchangePattern", "enum": [ "InOnly", "InOut", "InOptionalOut" ], "deprecated": false, "autowired": false, "secret": false, "description": "Sets the exchange pattern when the consumer creates an exchange." }, - "pollStrategy": { "kind": "parameter", "displayName": "Poll Strategy", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.spi.PollingConsumerPollStrategy", "deprecated": false, "autowired": false, "secret": false, "description": "A pluggable org.apache.camel.PollingConsumerPollingStrategy allowing you to provide your custom implementation to control error handling usually occurred during the poll operation [...] - "lazyStartProducer": { "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during sta [...] - "backoffErrorThreshold": { "kind": "parameter", "displayName": "Backoff Error Threshold", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "description": "The number of subsequent error polls (failed due some error) that should happen before the backoffMultipler should kick-in." }, - "backoffIdleThreshold": { "kind": "parameter", "displayName": "Backoff Idle Threshold", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "description": "The number of subsequent idle polls that should happen before the backoffMultipler should kick-in." }, - "backoffMultiplier": { "kind": "parameter", "displayName": "Backoff Multiplier", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "description": "To let the scheduled polling consumer backoff if there has been a number of subsequent idles\/errors in a row. The multiplier is then the number of polls that will be skipped before the next actual attempt is happening agai [...] - "delay": { "kind": "parameter", "displayName": "Delay", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 500, "description": "Milliseconds before the next poll." }, - "greedy": { "kind": "parameter", "displayName": "Greedy", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If greedy is enabled, then the ScheduledPollConsumer will run immediately again, if the previous run polled 1 or more messages." }, - "initialDelay": { "kind": "parameter", "displayName": "Initial Delay", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 1000, "description": "Milliseconds before the first poll starts." }, - "repeatCount": { "kind": "parameter", "displayName": "Repeat Count", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 0, "description": "Specifies a maximum limit of number of fires. So if you set it to 1, the scheduler will only fire once. If you set it to 5, it will only fire five times. A value of zero or negative means fire forever." }, - "runLoggingLevel": { "kind": "parameter", "displayName": "Run Logging Level", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "object", "javaType": "org.apache.camel.LoggingLevel", "enum": [ "TRACE", "DEBUG", "INFO", "WARN", "ERROR", "OFF" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "TRACE", "description": "The consumer logs a start\/complete log line when it polls. This option allows you to configure the logging level [...] - "scheduledExecutorService": { "kind": "parameter", "displayName": "Scheduled Executor Service", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "object", "javaType": "java.util.concurrent.ScheduledExecutorService", "deprecated": false, "autowired": false, "secret": false, "description": "Allows for configuring a custom\/shared thread pool to use for the consumer. By default each consumer has its own single threaded thread pool." }, - "scheduler": { "kind": "parameter", "displayName": "Scheduler", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "object", "javaType": "java.lang.Object", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "none", "description": "To use a cron scheduler from either camel-spring or camel-quartz component. Use value spring or quartz for built in scheduler" }, - "schedulerProperties": { "kind": "parameter", "displayName": "Scheduler Properties", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "object", "javaType": "java.util.Map<java.lang.String, java.lang.Object>", "prefix": "scheduler.", "multiValue": true, "deprecated": false, "autowired": false, "secret": false, "description": "To configure additional properties when using a custom scheduler or any of the Quartz, Spring based scheduler." }, - "startScheduler": { "kind": "parameter", "displayName": "Start Scheduler", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether the scheduler should be auto started." }, - "timeUnit": { "kind": "parameter", "displayName": "Time Unit", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "object", "javaType": "java.util.concurrent.TimeUnit", "enum": [ "NANOSECONDS", "MICROSECONDS", "MILLISECONDS", "SECONDS", "MINUTES", "HOURS", "DAYS" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "MILLISECONDS", "description": "Time unit for initialDelay and delay options." }, - "useFixedDelay": { "kind": "parameter", "displayName": "Use Fixed Delay", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Controls if fixed delay or fixed rate is used. See ScheduledExecutorService in JDK for details." } - } -} diff --git a/components/camel-apns/src/main/docs/apns-component.adoc b/components/camel-apns/src/main/docs/apns-component.adoc deleted file mode 100644 index 3d3fdf4..0000000 --- a/components/camel-apns/src/main/docs/apns-component.adoc +++ /dev/null @@ -1,323 +0,0 @@ -[[apns-component]] -= APNS Component (deprecated) -:docTitle: APNS -:artifactId: camel-apns -:description: Send notifications to Apple iOS devices. -:since: 2.8 -:supportLevel: Stable-deprecated -:deprecated: *deprecated* -:component-header: Both producer and consumer are supported -include::{cq-version}@camel-quarkus:ROOT:partial$reference/components/apns.adoc[opts=optional] - -*Since Camel {since}* - -*{component-header}* - -The APNS component is used for sending notifications to iOS devices. -The APNS components use https://github.com/notnoop/java-apns[javapns] -library. + - The component supports sending notifications to Apple Push Notification -Servers (APNS) and consuming feedback from the servers. - -The consumer is configured with 3600 seconds for polling by default -because it is a best practice to consume feedback stream from Apple Push -Notification Servers only from time to time. For example: every 1 hour -to avoid flooding the servers. - -The feedback stream gives informations about inactive devices. You only -need to get this informations every some hours if your mobile -application is not a heavily used one. - -Maven users will need to add the following dependency to their `pom.xml` -for this component: - -[source,xml] ------------------------------------------------------------- -<dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-apns</artifactId> - <version>x.x.x</version> - <!-- use the same version as your Camel core version --> -</dependency> ------------------------------------------------------------- - -== URI format - -To send notifications: - -[source,java] ---------------------- -apns:notify[?options] ---------------------- - -To consume feedback: - -[source,java] ------------------------ -apns:consumer[?options] ------------------------ - -== Options - - - -// component options: START -The APNS component supports 4 options, which are listed below. - - - -[width="100%",cols="2,5,^1,2",options="header"] -|=== -| Name | Description | Default | Type -| *apnsService* (common) | *Required* The ApnsService to use. The org.apache.camel.component.apns.factory.ApnsServiceFactory can be used to build a ApnsService | | ApnsService -| *bridgeErrorHandler* (consumer) | Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | boolean -| *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and [...] -| *autowiredEnabled* (advanced) | Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc. | true | boolean -|=== -// component options: END - - - - -// endpoint options: START -The APNS endpoint is configured using URI syntax: - ----- -apns:name ----- - -with the following path and query parameters: - -=== Path Parameters (1 parameters): - - -[width="100%",cols="2,5,^1,2",options="header"] -|=== -| Name | Description | Default | Type -| *name* | Name of the endpoint | | String -|=== - - -=== Query Parameters (21 parameters): - - -[width="100%",cols="2,5,^1,2",options="header"] -|=== -| Name | Description | Default | Type -| *tokens* (common) | Configure this property in case you want to statically declare tokens related to devices you want to notify. Tokens are separated by comma. | | String -| *bridgeErrorHandler* (consumer) | Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | boolean -| *sendEmptyMessageWhenIdle* (consumer) | If the polling consumer did not poll any files, you can enable this option to send an empty message (no body) instead. | false | boolean -| *exceptionHandler* (consumer) | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored. | | ExceptionHandler -| *exchangePattern* (consumer) | Sets the exchange pattern when the consumer creates an exchange. There are 3 enums and the value can be one of: InOnly, InOut, InOptionalOut | | ExchangePattern -| *pollStrategy* (consumer) | A pluggable org.apache.camel.PollingConsumerPollingStrategy allowing you to provide your custom implementation to control error handling usually occurred during the poll operation before an Exchange have been created and being routed in Camel. | | PollingConsumerPollStrategy -| *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and [...] -| *backoffErrorThreshold* (scheduler) | The number of subsequent error polls (failed due some error) that should happen before the backoffMultipler should kick-in. | | int -| *backoffIdleThreshold* (scheduler) | The number of subsequent idle polls that should happen before the backoffMultipler should kick-in. | | int -| *backoffMultiplier* (scheduler) | To let the scheduled polling consumer backoff if there has been a number of subsequent idles/errors in a row. The multiplier is then the number of polls that will be skipped before the next actual attempt is happening again. When this option is in use then backoffIdleThreshold and/or backoffErrorThreshold must also be configured. | | int -| *delay* (scheduler) | Milliseconds before the next poll. | 500 | long -| *greedy* (scheduler) | If greedy is enabled, then the ScheduledPollConsumer will run immediately again, if the previous run polled 1 or more messages. | false | boolean -| *initialDelay* (scheduler) | Milliseconds before the first poll starts. | 1000 | long -| *repeatCount* (scheduler) | Specifies a maximum limit of number of fires. So if you set it to 1, the scheduler will only fire once. If you set it to 5, it will only fire five times. A value of zero or negative means fire forever. | 0 | long -| *runLoggingLevel* (scheduler) | The consumer logs a start/complete log line when it polls. This option allows you to configure the logging level for that. There are 6 enums and the value can be one of: TRACE, DEBUG, INFO, WARN, ERROR, OFF | TRACE | LoggingLevel -| *scheduledExecutorService* (scheduler) | Allows for configuring a custom/shared thread pool to use for the consumer. By default each consumer has its own single threaded thread pool. | | ScheduledExecutorService -| *scheduler* (scheduler) | To use a cron scheduler from either camel-spring or camel-quartz component. Use value spring or quartz for built in scheduler | none | Object -| *schedulerProperties* (scheduler) | To configure additional properties when using a custom scheduler or any of the Quartz, Spring based scheduler. | | Map -| *startScheduler* (scheduler) | Whether the scheduler should be auto started. | true | boolean -| *timeUnit* (scheduler) | Time unit for initialDelay and delay options. There are 7 enums and the value can be one of: NANOSECONDS, MICROSECONDS, MILLISECONDS, SECONDS, MINUTES, HOURS, DAYS | MILLISECONDS | TimeUnit -| *useFixedDelay* (scheduler) | Controls if fixed delay or fixed rate is used. See ScheduledExecutorService in JDK for details. | true | boolean -|=== -// endpoint options: END - - - -You can append query options to the URI in the following format, -`?option=value&option=value&...` - -=== Component - -The `ApnsComponent` must be configured with a -`com.notnoop.apns.ApnsService`. The service can be created and -configured using the -`org.apache.camel.component.apns.factory.ApnsServiceFactory`. See -further below for an example. And as well in the -https://github.com/apache/camel/tree/main/components/camel-apns[test -source code]. - -==== SSL Setting -In order to use secure connection, an instance of `org.apache.camel.support.jsse.SSLContextParameters` - should be injected to `org.apache.camel.component.apns.factory.ApnsServiceFactory` which is - used to configure the component. See the test resources for an example. - https://github.com/apache/camel/blob/main/components/camel-apns/src/test/resources/org/apache/camel/component/apns/spring/SpringApnsConsumerTest-context.xml[ssl example] - -== Exchange data format - -When Camel will fetch feedback data corresponding to inactive devices, -it will retrieve a List of InactiveDevice objects. Each InactiveDevice -object of the retrieved list will be setted as the In body, and then -processed by the consumer endpoint. - -== Message Headers - -Camel Apns uses these headers. - -[width="100%",cols="10%,10%,80%",options="header",] -|======================================================================= -|Property |Default |Description -|`CamelApnsTokens` | |Empty by default. -|`CamelApnsMessageType` |`STRING, PAYLOAD, APNS_NOTIFICATION` |In case you choose PAYLOAD for the message type, then the message will -be considered as a APNS payload and sent as is. In case you choose -STRING, message will be converted as a APNS payload. From *Camel 2.16* -onwards APNS_NOTIFICATION is used for sending message body as -com.notnoop.apns.ApnsNotification types. -|======================================================================= - -== ApnsServiceFactory builder callback - -`ApnsServiceFactory` comes with the empty callback method that could be -used to configure (or even replace) the default `ApnsServiceBuilder` -instance. The signature of the method could look as follows: - -[source,java] ----------------------------------------------------------------------------------------- -protected ApnsServiceBuilder configureServiceBuilder(ApnsServiceBuilder serviceBuilder); ----------------------------------------------------------------------------------------- - -And could be used like as follows: - -[source,java] -------------------------------------------------------------------------------------------- -ApnsServiceFactory proxiedApnsServiceFactory = new ApnsServiceFactory(){ - - @Override - protected ApnsServiceBuilder configureServiceBuilder(ApnsServiceBuilder serviceBuilder) { - return serviceBuilder.withSocksProxy("my.proxy.com", 6666); - } - -}; -------------------------------------------------------------------------------------------- - -== Samples - -=== Camel Xml route - -[source,xml] --------------------------------------------------------------------------------------------------------------------------------------------------------------------- -<beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:camel="http://camel.apache.org/schema/spring" - xsi:schemaLocation=" - http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd - http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"> - - <!-- Replace by desired values --> - <bean id="apnsServiceFactory" class="org.apache.camel.component.apns.factory.ApnsServiceFactory"> - - <!-- Optional configuration of feedback host and port --> - <!-- <property name="feedbackHost" value="localhost" /> --> - <!-- <property name="feedbackPort" value="7843" /> --> - - <!-- Optional configuration of gateway host and port --> - <!-- <property name="gatewayHost" value="localhost" /> --> - <!-- <property name="gatewayPort" value="7654" /> --> - - <!-- Declaration of certificate used --> - <!-- from Camel 2.11 onwards you can use prefix: classpath:, file: to refer to load the certificate from classpath or file. Default it classpath --> - <property name="certificatePath" value="certificate.p12" /> - <property name="certificatePassword" value="MyCertPassword" /> - - <!-- Optional connection strategy - By Default: No need to configure --> - <!-- Possible options: NON_BLOCKING, QUEUE, POOL or Nothing --> - <!-- <property name="connectionStrategy" value="POOL" /> --> - <!-- Optional pool size --> - <!-- <property name="poolSize" value="15" /> --> - - <!-- Optional connection strategy - By Default: No need to configure --> - <!-- Possible options: EVERY_HALF_HOUR, EVERY_NOTIFICATION or Nothing (Corresponds to NEVER javapns option) --> - <!-- <property name="reconnectionPolicy" value="EVERY_HALF_HOUR" /> --> - </bean> - - <bean id="apnsService" factory-bean="apnsServiceFactory" factory-method="getApnsService" /> - - <!-- Replace this declaration by wanted configuration --> - <bean id="apns" class="org.apache.camel.component.apns.ApnsComponent"> - <property name="apnsService" ref="apnsService" /> - </bean> - - <camelContext id="camel-apns-test" xmlns="http://camel.apache.org/schema/spring"> - <route id="apns-test"> - <from uri="apns:consumer?initialDelay=10&delay=3600&timeUnit=SECONDS" /> - <to uri="log:org.apache.camel.component.apns?showAll=true&multiline=true" /> - <to uri="mock:result" /> - </route> - </camelContext> - -</beans> --------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -=== Camel Java route - -[[APNS-Createcamelcontextanddeclareapnscomponentprogrammatically]] -Create camel context and declare apns component programmatically - -[source,java] ----------------------------------------------------------------------------------- - protected CamelContext createCamelContext() throws Exception { - CamelContext camelContext = super.createCamelContext(); - - ApnsServiceFactory apnsServiceFactory = new ApnsServiceFactory(); - apnsServiceFactory.setCertificatePath("classpath:/certificate.p12"); - apnsServiceFactory.setCertificatePassword("MyCertPassword"); - - ApnsService apnsService = apnsServiceFactory.getApnsService(camelContext); - - ApnsComponent apnsComponent = new ApnsComponent(apnsService); - camelContext.addComponent("apns", apnsComponent); - - return camelContext; - } ----------------------------------------------------------------------------------- - -[[APNS-ApnsProducer-iOStargetdevicedynamicallyconfiguredviaheader:CamelApnsTokens]] -ApnsProducer - iOS target device dynamically configured via header: -`"CamelApnsTokens"` - -[source,java] ---------------------------------------------------------------------------------------- - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - public void configure() throws Exception { - from("direct:test") - .setHeader(ApnsConstants.HEADER_TOKENS, constant(IOS_DEVICE_TOKEN)) - .to("apns:notify"); - } - } - } ---------------------------------------------------------------------------------------- - -[[APNS-ApnsProducer-iOStargetdevicestaticallyconfiguredviauri]] -ApnsProducer - iOS target device statically configured via uri - -[source,java] ------------------------------------------------------------------- - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - public void configure() throws Exception { - from("direct:test"). - to("apns:notify?tokens=" + IOS_DEVICE_TOKEN); - } - }; - } ------------------------------------------------------------------- - -[[APNS-ApnsConsumer]] -ApnsConsumer - -[source,java] --------------------------------------------------------------------------- -from("apns:consumer?initialDelay=10&delay=3600&timeUnit=SECONDS") - .to("log:com.apache.camel.component.apns?showAll=true&multiline=true") - .to("mock:result"); --------------------------------------------------------------------------- - - -include::{page-component-version}@camel-spring-boot::page$apns-starter.adoc[] diff --git a/components/camel-apns/src/main/java/org/apache/camel/component/apns/ApnsComponent.java b/components/camel-apns/src/main/java/org/apache/camel/component/apns/ApnsComponent.java deleted file mode 100644 index 611dac3..0000000 --- a/components/camel-apns/src/main/java/org/apache/camel/component/apns/ApnsComponent.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.component.apns; - -import java.util.Map; - -import com.notnoop.apns.ApnsService; -import org.apache.camel.Endpoint; -import org.apache.camel.spi.Metadata; -import org.apache.camel.spi.annotations.Component; -import org.apache.camel.support.DefaultComponent; - -/** - * For sending notifications to Apple iOS devices - */ -@Component("apns") -public class ApnsComponent extends DefaultComponent { - - @Metadata(required = true) - private ApnsService apnsService; - - public ApnsComponent() { - } - - public ApnsComponent(ApnsService apnsService) { - this(); - this.apnsService = apnsService; - } - - @Override - protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { - ApnsEndpoint endpoint = new ApnsEndpoint(uri, this); - endpoint.setName(remaining); - setProperties(endpoint, parameters); - return endpoint; - } - - public ApnsService getApnsService() { - return apnsService; - } - - /** - * The ApnsService to use. - * <p/> - * The {@link org.apache.camel.component.apns.factory.ApnsServiceFactory} can be used to build a {@link ApnsService} - */ - public void setApnsService(ApnsService apnsService) { - this.apnsService = apnsService; - } - -} diff --git a/components/camel-apns/src/main/java/org/apache/camel/component/apns/ApnsConsumer.java b/components/camel-apns/src/main/java/org/apache/camel/component/apns/ApnsConsumer.java deleted file mode 100644 index 5d45e70..0000000 --- a/components/camel-apns/src/main/java/org/apache/camel/component/apns/ApnsConsumer.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.component.apns; - -import java.util.ArrayList; -import java.util.Date; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import org.apache.camel.Exchange; -import org.apache.camel.Processor; -import org.apache.camel.component.apns.model.InactiveDevice; -import org.apache.camel.support.ScheduledPollConsumer; - -public class ApnsConsumer extends ScheduledPollConsumer { - - private static final int DEFAULT_CONSUME_INITIAL_DELAY = 10; - private static final int DEFAULT_CONSUME_DELAY = 3600; - private static final boolean DEFAULT_APNS_FIXED_DELAY = true; - - public ApnsConsumer(ApnsEndpoint apnsEndpoint, Processor processor) { - super(apnsEndpoint, processor); - - setInitialDelay(DEFAULT_CONSUME_INITIAL_DELAY); - setDelay(DEFAULT_CONSUME_DELAY); - setUseFixedDelay(DEFAULT_APNS_FIXED_DELAY); - } - - @Override - protected int poll() throws Exception { - List<InactiveDevice> inactiveDeviceList = getInactiveDevices(); - - Iterator<InactiveDevice> it = inactiveDeviceList.iterator(); - - while (it.hasNext()) { - InactiveDevice inactiveDevice = it.next(); - - Exchange e = createExchange(true); - e.getIn().setBody(inactiveDevice); - getProcessor().process(e); - } - - return inactiveDeviceList.size(); - } - - private List<InactiveDevice> getInactiveDevices() { - ApnsEndpoint ae = getEndpoint(); - - Map<String, Date> inactiveDeviceMap = ae.getApnsService().getInactiveDevices(); - - List<InactiveDevice> inactiveDeviceList = new ArrayList<>(); - for (Entry<String, Date> inactiveDeviceEntry : inactiveDeviceMap.entrySet()) { - String deviceToken = inactiveDeviceEntry.getKey(); - Date date = inactiveDeviceEntry.getValue(); - - InactiveDevice inactiveDevice = new InactiveDevice(deviceToken, date); - inactiveDeviceList.add(inactiveDevice); - } - - return inactiveDeviceList; - } - - @Override - public ApnsEndpoint getEndpoint() { - return (ApnsEndpoint) super.getEndpoint(); - } - - @Override - protected void doStart() throws Exception { - // only add as consumer if not already registered - if (!getEndpoint().getConsumers().contains(this)) { - if (!getEndpoint().getConsumers().isEmpty()) { - throw new IllegalStateException( - "Endpoint " + getEndpoint().getEndpointUri() - + " only allows 1 active consumer but you attempted to start a 2nd consumer."); - } - getEndpoint().getConsumers().add(this); - } - super.doStart(); - } - - @Override - protected void doStop() throws Exception { - super.doStop(); - getEndpoint().getConsumers().remove(this); - } - -} diff --git a/components/camel-apns/src/main/java/org/apache/camel/component/apns/ApnsEndpoint.java b/components/camel-apns/src/main/java/org/apache/camel/component/apns/ApnsEndpoint.java deleted file mode 100644 index 6884bd4..0000000 --- a/components/camel-apns/src/main/java/org/apache/camel/component/apns/ApnsEndpoint.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.component.apns; - -import java.util.Set; -import java.util.concurrent.CopyOnWriteArraySet; - -import com.notnoop.apns.ApnsService; -import org.apache.camel.Category; -import org.apache.camel.Consumer; -import org.apache.camel.Processor; -import org.apache.camel.Producer; -import org.apache.camel.spi.UriEndpoint; -import org.apache.camel.spi.UriParam; -import org.apache.camel.spi.UriPath; -import org.apache.camel.support.DefaultConsumer; -import org.apache.camel.support.ScheduledPollEndpoint; - -/** - * Send notifications to Apple iOS devices. - */ -@UriEndpoint(firstVersion = "2.8.0", scheme = "apns", title = "APNS", syntax = "apns:name", - category = { Category.EVENTBUS, Category.MOBILE }) -public class ApnsEndpoint extends ScheduledPollEndpoint { - - private final CopyOnWriteArraySet<DefaultConsumer> consumers = new CopyOnWriteArraySet<>(); - - @UriPath(description = "Name of the endpoint") - private String name; - @UriParam - private String tokens; - - public ApnsEndpoint(String uri, ApnsComponent component) { - super(uri, component); - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getTokens() { - return tokens; - } - - /** - * Configure this property in case you want to statically declare tokens related to devices you want to notify. - * Tokens are separated by comma. - */ - public void setTokens(String tokens) { - this.tokens = tokens; - } - - private ApnsComponent getApnsComponent() { - return (ApnsComponent) getComponent(); - } - - public ApnsService getApnsService() { - return getApnsComponent().getApnsService(); - } - - protected Set<DefaultConsumer> getConsumers() { - return consumers; - } - - @Override - public Consumer createConsumer(Processor processor) throws Exception { - ApnsConsumer apnsConsumer = new ApnsConsumer(this, processor); - configureConsumer(apnsConsumer); - return apnsConsumer; - } - - @Override - public Producer createProducer() throws Exception { - return new ApnsProducer(this); - } - -} diff --git a/components/camel-apns/src/main/java/org/apache/camel/component/apns/ApnsProducer.java b/components/camel-apns/src/main/java/org/apache/camel/component/apns/ApnsProducer.java deleted file mode 100644 index be04b09..0000000 --- a/components/camel-apns/src/main/java/org/apache/camel/component/apns/ApnsProducer.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.component.apns; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Date; -import java.util.List; - -import com.notnoop.apns.APNS; -import com.notnoop.apns.ApnsNotification; -import com.notnoop.exceptions.ApnsException; -import org.apache.camel.Exchange; -import org.apache.camel.component.apns.model.ApnsConstants; -import org.apache.camel.component.apns.model.MessageType; -import org.apache.camel.component.apns.util.StringUtils; -import org.apache.camel.support.DefaultProducer; -import org.apache.camel.util.ObjectHelper; - -public class ApnsProducer extends DefaultProducer { - - private List<String> tokenList; - - public ApnsProducer(ApnsEndpoint endpoint) { - super(endpoint); - initiate(endpoint); - } - - @Override - public ApnsEndpoint getEndpoint() { - return (ApnsEndpoint) super.getEndpoint(); - } - - private void initiate(ApnsEndpoint apnsEndpoint) { - configureTokens(apnsEndpoint); - } - - private void configureTokens(ApnsEndpoint apnsEndpoint) { - if (ObjectHelper.isNotEmpty(apnsEndpoint.getTokens())) { - this.tokenList = extractTokensFromString(apnsEndpoint.getTokens()); - } - } - - public boolean isTokensConfiguredUsingUri() { - return tokenList != null; - } - - @Override - public void process(Exchange exchange) throws Exception { - notify(exchange); - } - - private void notify(Exchange exchange) throws ApnsException { - MessageType messageType = getHeaderMessageType(exchange, MessageType.STRING); - - if (messageType == MessageType.APNS_NOTIFICATION) { - ApnsNotification apnsNotification = exchange.getIn().getBody(ApnsNotification.class); - getEndpoint().getApnsService().push(apnsNotification); - } else { - constructNotificationAndNotify(exchange, messageType); - } - } - - private void constructNotificationAndNotify(Exchange exchange, MessageType messageType) { - String payload; - Collection<String> tokens; - if (isTokensConfiguredUsingUri()) { - if (hasTokensHeader(exchange)) { - throw new IllegalArgumentException("Tokens already configured on endpoint " + ApnsConstants.HEADER_TOKENS); - } - tokens = new ArrayList<>(tokenList); - } else { - String tokensHeader = getHeaderTokens(exchange); - tokens = extractTokensFromString(tokensHeader); - } - if (messageType == MessageType.STRING) { - String message = exchange.getIn().getBody(String.class); - payload = APNS.newPayload().alertBody(message).build(); - } else { - String message = exchange.getIn().getBody(String.class); - payload = message; - } - Date expiry = exchange.getIn().getHeader(ApnsConstants.HEADER_EXPIRY, Date.class); - if (expiry != null) { - getEndpoint().getApnsService().push(tokens, payload, expiry); - } else { - getEndpoint().getApnsService().push(tokens, payload); - } - } - - public String getHeaderTokens(Exchange exchange) { - return exchange.getIn().getHeader(ApnsConstants.HEADER_TOKENS, String.class); - } - - public MessageType getHeaderMessageType(Exchange exchange, MessageType defaultMessageType) { - String messageTypeStr = (String) exchange.getIn().getHeader(ApnsConstants.HEADER_MESSAGE_TYPE); - - if (messageTypeStr == null) { - return defaultMessageType; - } - - MessageType messageType = MessageType.valueOf(messageTypeStr); - return messageType; - } - - private boolean hasTokensHeader(Exchange exchange) { - return getHeaderTokens(exchange) != null; - } - - private List<String> extractTokensFromString(String tokensStr) { - tokensStr = StringUtils.trim(tokensStr); - if (tokensStr.isEmpty()) { - throw new IllegalArgumentException("No token specified"); - } - - String[] tokenArray = tokensStr.split(";"); - int tokenArrayLength = tokenArray.length; - for (int i = 0; i < tokenArrayLength; i++) { - String token = tokenArray[i]; - tokenArray[i] = token.trim(); - int tokenLength = token.length(); - if (tokenLength != 64) { - throw new IllegalArgumentException("Token has wrong size['" + tokenLength + "']: " + token); - } - } - List<String> tokens = Arrays.asList(tokenArray); - return tokens; - } - -} diff --git a/components/camel-apns/src/main/java/org/apache/camel/component/apns/factory/ApnsServiceFactory.java b/components/camel-apns/src/main/java/org/apache/camel/component/apns/factory/ApnsServiceFactory.java deleted file mode 100644 index 74949fa..0000000 --- a/components/camel-apns/src/main/java/org/apache/camel/component/apns/factory/ApnsServiceFactory.java +++ /dev/null @@ -1,273 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.component.apns.factory; - -import java.io.IOException; -import java.io.InputStream; -import java.security.GeneralSecurityException; - -import com.notnoop.apns.APNS; -import com.notnoop.apns.ApnsDelegate; -import com.notnoop.apns.ApnsService; -import com.notnoop.apns.ApnsServiceBuilder; -import com.notnoop.apns.ReconnectPolicy; -import com.notnoop.apns.internal.Utilities; -import org.apache.camel.CamelContext; -import org.apache.camel.CamelContextAware; -import org.apache.camel.RuntimeCamelException; -import org.apache.camel.component.apns.model.ConnectionStrategy; -import org.apache.camel.component.apns.model.ReconnectionPolicy; -import org.apache.camel.component.apns.util.AssertUtils; -import org.apache.camel.component.apns.util.ParamUtils; -import org.apache.camel.component.apns.util.ResourceUtils; -import org.apache.camel.support.ResourceHelper; -import org.apache.camel.support.jsse.SSLContextParameters; -import org.apache.camel.util.ObjectHelper; -import org.apache.camel.util.StringHelper; - -public class ApnsServiceFactory implements CamelContextAware { - - private static final int DEFAULT_POOL_SIZE = 10; - private static final int MIN_POOL_SIZE = 1; - private static final int MAX_POOL_SIZE = 30; - - private CamelContext camelContext; - private String certificatePath; - private String certificatePassword; - private ConnectionStrategy connectionStrategy; - private ReconnectionPolicy reconnectionPolicy; - private SSLContextParameters sslContextParameters; - private int poolSize = DEFAULT_POOL_SIZE; - private String gatewayHost; - private int gatewayPort; - private String feedbackHost; - private int feedbackPort; - private ApnsDelegate apnsDelegate; - - public ApnsServiceFactory() { - this.gatewayHost = Utilities.PRODUCTION_GATEWAY_HOST; - this.gatewayPort = Utilities.PRODUCTION_GATEWAY_PORT; - - this.feedbackHost = Utilities.PRODUCTION_FEEDBACK_HOST; - this.feedbackPort = Utilities.PRODUCTION_FEEDBACK_PORT; - } - - public ApnsServiceFactory(CamelContext camelContext) { - this(); - this.camelContext = camelContext; - } - - @Override - public CamelContext getCamelContext() { - return camelContext; - } - - @Override - public void setCamelContext(CamelContext camelContext) { - this.camelContext = camelContext; - } - - public String getFeedbackHost() { - return feedbackHost; - } - - public void setFeedbackHost(String feedbackHost) { - this.feedbackHost = feedbackHost; - } - - public String getGatewayHost() { - return gatewayHost; - } - - public void setGatewayHost(String gatewayHost) { - this.gatewayHost = gatewayHost; - } - - public int getGatewayPort() { - return gatewayPort; - } - - public void setGatewayPort(int gatewayPort) { - this.gatewayPort = gatewayPort; - } - - public int getFeedbackPort() { - return feedbackPort; - } - - public void setFeedbackPort(int feedbackPort) { - this.feedbackPort = feedbackPort; - } - - public int getPoolSize() { - return poolSize; - } - - public void setPoolSize(int poolSize) { - this.poolSize = poolSize; - } - - public String getCertificatePath() { - return certificatePath; - } - - public void setCertificatePath(String certificatePath) { - this.certificatePath = certificatePath; - } - - public String getCertificatePassword() { - return certificatePassword; - } - - public void setCertificatePassword(String certificatePassword) { - this.certificatePassword = certificatePassword; - } - - public ReconnectionPolicy getReconnectionPolicy() { - return reconnectionPolicy; - } - - public void setReconnectionPolicy(ReconnectionPolicy reconnectionPolicy) { - this.reconnectionPolicy = reconnectionPolicy; - } - - public ConnectionStrategy getConnectionStrategy() { - return connectionStrategy; - } - - public void setConnectionStrategy(ConnectionStrategy connectionStrategy) { - this.connectionStrategy = connectionStrategy; - } - - public SSLContextParameters getSslContextParameters() { - return sslContextParameters; - } - - public void setSslContextParameters(SSLContextParameters sslContextParameters) { - this.sslContextParameters = sslContextParameters; - } - - public ApnsDelegate getApnsDelegate() { - return apnsDelegate; - } - - public void setApnsDelegate(ApnsDelegate apnsDelegate) { - this.apnsDelegate = apnsDelegate; - } - - public ApnsService getApnsService() { - ApnsServiceBuilder builder = APNS.newService(); - builder = configureServiceBuilder(builder); - - configureConnectionStrategy(builder); - configureReconnectionPolicy(builder); - configureApnsDelegate(builder); - configureApnsDestinations(builder); - try { - configureApnsCertificate(builder); - } catch (IOException e) { - throw RuntimeCamelException.wrapRuntimeCamelException(e); - } catch (GeneralSecurityException e) { - throw RuntimeCamelException.wrapRuntimeCamelException(e); - } - - ApnsService apnsService = builder.build(); - return apnsService; - } - - protected ApnsServiceBuilder configureServiceBuilder(ApnsServiceBuilder serviceBuilder) { - return serviceBuilder; - } - - private void configureApnsCertificate(ApnsServiceBuilder builder) throws IOException, GeneralSecurityException { - if (getSslContextParameters() != null) { - builder.withSSLContext(getSslContextParameters().createSSLContext(getCamelContext())); - return; - } - - ObjectHelper.notNull(getCamelContext(), "camelContext"); - StringHelper.notEmpty(getCertificatePath(), "certificatePath"); - StringHelper.notEmpty(getCertificatePassword(), "certificatePassword"); - - InputStream certificateInputStream = null; - try { - certificateInputStream = ResourceHelper.resolveMandatoryResourceAsInputStream(camelContext, getCertificatePath()); - builder.withCert(certificateInputStream, getCertificatePassword()); - } finally { - ResourceUtils.close(certificateInputStream); - } - } - - private void configureApnsDestinations(ApnsServiceBuilder builder) { - ParamUtils.checkDestination(getGatewayHost(), getGatewayPort(), "gateway"); - ParamUtils.checkDestination(getFeedbackHost(), getFeedbackPort(), "feedback"); - - if (ObjectHelper.isNotEmpty(getGatewayHost())) { - builder.withGatewayDestination(getGatewayHost(), getGatewayPort()); - } - if (ObjectHelper.isNotEmpty(getFeedbackHost())) { - builder.withFeedbackDestination(getFeedbackHost(), getFeedbackPort()); - } - } - - private void configureApnsDelegate(ApnsServiceBuilder builder) { - if (apnsDelegate != null) { - builder.withDelegate(apnsDelegate); - } - } - - private void configureConnectionStrategy(ApnsServiceBuilder builder) { - if (getConnectionStrategy() == ConnectionStrategy.POOL) { - AssertUtils.isTrue(poolSize >= MIN_POOL_SIZE, "Pool size needs to be greater than: " + MIN_POOL_SIZE); - AssertUtils.isTrue(poolSize <= MAX_POOL_SIZE, "Pool size needs to be lower than: " + MAX_POOL_SIZE); - } - - if (getConnectionStrategy() == null) { - return; - } - - switch (getConnectionStrategy()) { - case QUEUE: - builder.asQueued(); - break; - case POOL: - builder.asPool(getPoolSize()); - break; - default: - break; - } - } - - private void configureReconnectionPolicy(ApnsServiceBuilder builder) { - if (getReconnectionPolicy() == null) { - return; - } - - switch (getReconnectionPolicy()) { - case EVERY_HALF_HOUR: - builder.withReconnectPolicy(ReconnectPolicy.Provided.EVERY_HALF_HOUR); - break; - case EVERY_NOTIFICATION: - builder.withReconnectPolicy(ReconnectPolicy.Provided.EVERY_NOTIFICATION); - break; - default: - builder.withReconnectPolicy(ReconnectPolicy.Provided.NEVER); - break; - } - } - -} diff --git a/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/ApnsConstants.java b/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/ApnsConstants.java deleted file mode 100644 index 85b690c..0000000 --- a/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/ApnsConstants.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.component.apns.model; - -public final class ApnsConstants { - - public static final String HEADER_TOKENS = "CamelApnsTokens"; - public static final String HEADER_MESSAGE_TYPE = "CamelApnsMessageType"; - public static final String HEADER_EXPIRY = "CamelApnsExpiry"; - - private ApnsConstants() { - } - -} diff --git a/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/ConnectionStrategy.java b/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/ConnectionStrategy.java deleted file mode 100644 index f21c194..0000000 --- a/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/ConnectionStrategy.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.component.apns.model; - -public enum ConnectionStrategy { - - SIMPLE, - QUEUE, - POOL - -} diff --git a/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/InactiveDevice.java b/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/InactiveDevice.java deleted file mode 100644 index f4ced94..0000000 --- a/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/InactiveDevice.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.component.apns.model; - -import java.io.Serializable; -import java.util.Date; - -public class InactiveDevice implements Serializable { - private static final long serialVersionUID = 1L; - - private String deviceToken; - private Date date; - - public InactiveDevice(String deviceToken, Date date) { - this.deviceToken = deviceToken; - this.date = date; - } - - public String getDeviceToken() { - return deviceToken; - } - - public void setDeviceToken(String deviceToken) { - this.deviceToken = deviceToken; - } - - public Date getDate() { - return date; - } - - public void setDate(Date date) { - this.date = date; - } - - @Override - public String toString() { - return "InactiveDevice[" + deviceToken + ", " + date + "]"; - } -} diff --git a/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/MessageType.java b/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/MessageType.java deleted file mode 100644 index 2f5c266..0000000 --- a/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/MessageType.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.component.apns.model; - -public enum MessageType { - - STRING, - PAYLOAD, - APNS_NOTIFICATION; - -} diff --git a/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/ReconnectionPolicy.java b/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/ReconnectionPolicy.java deleted file mode 100644 index 7b091ce..0000000 --- a/components/camel-apns/src/main/java/org/apache/camel/component/apns/model/ReconnectionPolicy.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.component.apns.model; - -public enum ReconnectionPolicy { - - /** - * Only reconnect if absolutely needed, e.g. when the connection is dropped. This is the recommended mode. Apple - * recommends using a persistent connection. This improves the latency of sending push notification messages. The - * down-side is that once the connection is closed ungracefully (e.g. because Apple server drops it), the library - * wouldn't detect such failure and not warn against the messages sent after the drop before the detection. - */ - NEVER, - - /** - * Makes a new connection if the current connection has lasted for more than half an hour. This is the sweat-spot in - * my experiments between dropped connections while minimizing latency. - */ - EVERY_HALF_HOUR, - - /** - * Makes a new connection for every message being sent. This option ensures that each message is actually delivered - * to Apple. If you send <strong>a lot</strong> of messages though, Apple may consider your requests to be a DoS - * attack. - */ - EVERY_NOTIFICATION; -} diff --git a/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/AssertUtils.java b/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/AssertUtils.java deleted file mode 100644 index cfda251..0000000 --- a/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/AssertUtils.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.component.apns.util; - -public final class AssertUtils { - - private AssertUtils() { - } - - public static void notNull(Object object, String message) { - if (object == null) { - throw new IllegalArgumentException("[Assert not null] " + message); - } - } - - public static void isTrue(boolean booleanValue, String message) { - if (!booleanValue) { - throw new IllegalArgumentException("[Assert is true] " + message); - } - } - -} diff --git a/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/ParamUtils.java b/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/ParamUtils.java deleted file mode 100644 index 2680711..0000000 --- a/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/ParamUtils.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.component.apns.util; - -public final class ParamUtils { - - private ParamUtils() { - } - - public static void checkNotNull(Object param, String paramValue) { - AssertUtils.notNull(paramValue, param + " cannot be null"); - } - - public static void checkNotEmpty(String paramValue, String paramName) { - AssertUtils.notNull(paramValue, paramName + " cannot be null"); - AssertUtils.isTrue(StringUtils.isNotEmpty(paramValue), paramName + " cannot be empty"); - } - - public static void checkDestination(String host, int port, String paramName) { - if ((StringUtils.isEmpty(host) && port != 0) || (StringUtils.isNotEmpty(host) && port == 0)) { - throw new IllegalArgumentException( - paramName + "host and port parameters are not coherent: host=" + host + ", port=" + port); - } - } - -} diff --git a/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/ResourceUtils.java b/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/ResourceUtils.java deleted file mode 100644 index b8a4c7c..0000000 --- a/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/ResourceUtils.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.component.apns.util; - -import java.io.Closeable; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; - -import com.notnoop.exceptions.RuntimeIOException; -import org.apache.camel.util.IOHelper; - -public final class ResourceUtils { - - private static final String CLASSPATH_PREFIX = "classpath:"; - - private ResourceUtils() { - } - - public static boolean isClasspathResource(String path) { - return path.startsWith(CLASSPATH_PREFIX); - } - - public static String getClasspathResourcePath(String path) { - return path.substring(CLASSPATH_PREFIX.length()); - } - - public static InputStream getInputStream(String path) { - - InputStream is = null; - - if (isClasspathResource(path)) { - String classpathResourcePath = ResourceUtils.getClasspathResourcePath(path); - is = ResourceUtils.class.getResourceAsStream(classpathResourcePath); - if (is == null) { - throw new RuntimeIOException("Certificate stream is null: '" + classpathResourcePath + "'"); - } - } else { - try { - is = IOHelper.buffered(new FileInputStream(path)); - } catch (FileNotFoundException e) { - throw new RuntimeIOException(e); - } - } - - return is; - } - - public static void close(Closeable closeable) { - if (closeable != null) { - try { - closeable.close(); - } catch (IOException e) { /* Nothing to do */ - } - } - } - -} diff --git a/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/StringUtils.java b/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/StringUtils.java deleted file mode 100644 index e1fc1d8..0000000 --- a/components/camel-apns/src/main/java/org/apache/camel/component/apns/util/StringUtils.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.component.apns.util; - -public final class StringUtils { - - private StringUtils() { - } - - public static boolean isNotEmpty(String stringValue) { - if (stringValue == null) { - return false; - } - return stringValue.length() > 0; - } - - public static boolean isEmpty(String stringValue) { - return !isNotEmpty(stringValue); - } - - public static String trim(String stringValue) { - if (stringValue == null) { - return stringValue; - } - return stringValue.trim(); - } - -} diff --git a/components/camel-apns/src/test/java/com/notnoop/apns/internal/ApnsFeedbackParsingUtilsAcessor.java b/components/camel-apns/src/test/java/com/notnoop/apns/internal/ApnsFeedbackParsingUtilsAcessor.java deleted file mode 100644 index e3d3add..0000000 --- a/components/camel-apns/src/test/java/com/notnoop/apns/internal/ApnsFeedbackParsingUtilsAcessor.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.notnoop.apns.internal; - -public final class ApnsFeedbackParsingUtilsAcessor { - - private ApnsFeedbackParsingUtilsAcessor() { - } - - public static byte[] pack(byte[]... args) { - return ApnsFeedbackParsingUtils.pack(args); - } - -} diff --git a/components/camel-apns/src/test/java/org/apache/camel/component/apns/ApnsConsumerIdleMessageTest.java b/components/camel-apns/src/test/java/org/apache/camel/component/apns/ApnsConsumerIdleMessageTest.java deleted file mode 100644 index f9220d2..0000000 --- a/components/camel-apns/src/test/java/org/apache/camel/component/apns/ApnsConsumerIdleMessageTest.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.component.apns; - -import com.notnoop.apns.ApnsService; -import com.notnoop.apns.utils.ApnsServerStub; -import org.apache.camel.CamelContext; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.apns.factory.ApnsServiceFactory; -import org.apache.camel.component.apns.util.ApnsUtils; -import org.apache.camel.component.apns.util.TestConstants; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.test.junit5.CamelTestSupport; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertNull; - -/** - * Test to verify that the polling consumer delivers an empty Exchange when the sendEmptyMessageWhenIdle property is set - * and a polling event yields no results. - */ -@Disabled // TODO Figure out why this test is failing and fix it. -public class ApnsConsumerIdleMessageTest extends CamelTestSupport { - - ApnsServerStub server; - - @BeforeEach - public void startup() throws InterruptedException { - server = ApnsUtils.prepareAndStartServer(TestConstants.TEST_GATEWAY_PORT, TestConstants.TEST_FEEDBACK_PORT); - } - - @AfterEach - public void stop() { - server.stop(); - } - - @Test - public void testConsumeIdleMessages() throws Exception { - MockEndpoint mock = getMockEndpoint("mock:result"); - mock.expectedMinimumMessageCount(2); - - Thread.sleep(1100); - // cycling the server after first polling cycle because it can not handle reconnects for fast-cycle polling - server.stop(); - server.start(); - Thread.sleep(1100); - server.stop(); - assertMockEndpointsSatisfied(); - assertNull(mock.getExchanges().get(0).getIn().getBody()); - assertNull(mock.getExchanges().get(1).getIn().getBody()); - } - - @Override - protected CamelContext createCamelContext() throws Exception { - CamelContext camelContext = super.createCamelContext(); - - ApnsServiceFactory apnsServiceFactory = ApnsUtils.createDefaultTestConfiguration(camelContext); - ApnsService apnsService = apnsServiceFactory.getApnsService(); - - ApnsComponent apnsComponent = new ApnsComponent(apnsService); - camelContext.addComponent("apns", apnsComponent); - - return camelContext; - } - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - public void configure() throws Exception { - from("apns:consumer?initialDelay=1&delay=1&timeUnit=SECONDS&useFixedDelay=true" - + "&sendEmptyMessageWhenIdle=true") - .to("log:com.apache.camel.component.apns?showAll=true&multiline=true") - .to("mock:result"); - } - }; - } -} diff --git a/components/camel-apns/src/test/java/org/apache/camel/component/apns/ApnsConsumerTest.java b/components/camel-apns/src/test/java/org/apache/camel/component/apns/ApnsConsumerTest.java deleted file mode 100644 index 6a7f178..0000000 --- a/components/camel-apns/src/test/java/org/apache/camel/component/apns/ApnsConsumerTest.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.component.apns; - -import com.notnoop.apns.ApnsService; -import com.notnoop.apns.utils.ApnsServerStub; -import org.apache.camel.CamelContext; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.apns.factory.ApnsServiceFactory; -import org.apache.camel.component.apns.model.InactiveDevice; -import org.apache.camel.component.apns.util.ApnsUtils; -import org.apache.camel.component.apns.util.TestConstants; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.test.junit5.CamelTestSupport; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.Timeout; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -/** - * Unit test that we can produce JMS message from files - */ -public class ApnsConsumerTest extends CamelTestSupport { - - ApnsServerStub server; - - @BeforeEach - public void startup() throws InterruptedException { - server = ApnsUtils.prepareAndStartServer(TestConstants.TEST_GATEWAY_PORT, TestConstants.TEST_FEEDBACK_PORT); - } - - @AfterEach - public void stop() { - server.stop(); - } - - @Test - @Timeout(15) - public void testConsumer() throws Exception { - - byte[] deviceTokenBytes = ApnsUtils.createRandomDeviceTokenBytes(); - String deviceToken = ApnsUtils.encodeHexToken(deviceTokenBytes); - - MockEndpoint mock = getMockEndpoint("mock:result"); - mock.expectedMessageCount(1); - mock.message(0).body().isInstanceOf(InactiveDevice.class); - - byte[] feedBackBytes = ApnsUtils.generateFeedbackBytes(deviceTokenBytes); - server.getToSend().write(feedBackBytes); - - Thread.sleep(1000); - - assertMockEndpointsSatisfied(); - - InactiveDevice inactiveDevice = (InactiveDevice) mock.getExchanges().get(0).getIn().getBody(); - assertNotNull(inactiveDevice); - assertNotNull(inactiveDevice.getDate()); - assertNotNull(inactiveDevice.getDeviceToken()); - assertEquals(deviceToken, inactiveDevice.getDeviceToken()); - } - - @Override - protected CamelContext createCamelContext() throws Exception { - CamelContext camelContext = super.createCamelContext(); - - ApnsServiceFactory apnsServiceFactory = ApnsUtils.createDefaultTestConfiguration(camelContext); - ApnsService apnsService = apnsServiceFactory.getApnsService(); - - ApnsComponent apnsComponent = new ApnsComponent(apnsService); - - camelContext.addComponent("apns", apnsComponent); - - return camelContext; - } - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - public void configure() throws Exception { - from("apns:consumer?initialDelay=500&delay=500&timeUnit=MILLISECONDS") - .to("log:apns?showAll=true&multiline=true") - .to("mock:result"); - } - }; - } - -} diff --git a/components/camel-apns/src/test/java/org/apache/camel/component/apns/ApnsProducerTest.java b/components/camel-apns/src/test/java/org/apache/camel/component/apns/ApnsProducerTest.java deleted file mode 100644 index 6a91b9a..0000000 --- a/components/camel-apns/src/test/java/org/apache/camel/component/apns/ApnsProducerTest.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.component.apns; - -import com.notnoop.apns.APNS; -import com.notnoop.apns.ApnsService; -import com.notnoop.apns.EnhancedApnsNotification; -import com.notnoop.apns.utils.ApnsServerStub; -import org.apache.camel.CamelContext; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.apns.factory.ApnsServiceFactory; -import org.apache.camel.component.apns.model.ApnsConstants; -import org.apache.camel.component.apns.model.MessageType; -import org.apache.camel.component.apns.util.ApnsUtils; -import org.apache.camel.component.apns.util.TestConstants; -import org.apache.camel.test.junit5.CamelTestSupport; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.Timeout; - -import static org.junit.jupiter.api.Assertions.assertArrayEquals; - -/** - * Unit test that we can produce JMS message from files - */ -public class ApnsProducerTest extends CamelTestSupport { - - private static final String FAKE_TOKEN = "19308314834701ACD8313AEBD92AEFDE192120371FE13982392831701318B943"; - - private ApnsServerStub server; - - @BeforeEach - public void startup() { - server = ApnsUtils.prepareAndStartServer(TestConstants.TEST_GATEWAY_PORT, TestConstants.TEST_FEEDBACK_PORT); - } - - @AfterEach - public void stop() { - server.stop(); - } - - @Test - @Timeout(5) - public void testProducer() throws Exception { - String message = "Hello World"; - String messagePayload = APNS.newPayload().alertBody(message).build(); - - EnhancedApnsNotification apnsNotification - = new EnhancedApnsNotification(1, EnhancedApnsNotification.MAXIMUM_EXPIRY, FAKE_TOKEN, messagePayload); - server.stopAt(apnsNotification.length()); - - template.sendBody("direct:test", message); - - server.getMessages().acquire(); - assertArrayEquals(apnsNotification.marshall(), server.getReceived().toByteArray()); - } - - @Test - @Timeout(5) - public void testProducerWithApnsNotification() throws InterruptedException { - String message = "Hello World"; - String messagePayload = APNS.newPayload().alertBody(message).build(); - - final EnhancedApnsNotification apnsNotification - = new EnhancedApnsNotification(14, EnhancedApnsNotification.MAXIMUM_EXPIRY, FAKE_TOKEN, messagePayload); - server.stopAt(apnsNotification.length()); - - template.sendBody("direct:testWithApnsNotification", apnsNotification); - - server.getMessages().acquire(); - assertArrayEquals(apnsNotification.marshall(), server.getReceived().toByteArray()); - - } - - @Override - protected CamelContext createCamelContext() throws Exception { - CamelContext camelContext = super.createCamelContext(); - - ApnsServiceFactory apnsServiceFactory = ApnsUtils.createDefaultTestConfiguration(camelContext); - ApnsService apnsService = apnsServiceFactory.getApnsService(); - - ApnsComponent apnsComponent = new ApnsComponent(apnsService); - camelContext.addComponent("apns", apnsComponent); - - return camelContext; - } - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - public void configure() throws Exception { - from("direct:test").setHeader(ApnsConstants.HEADER_TOKENS, constant(FAKE_TOKEN)).to("apns:notify"); - from("direct:testWithApnsNotification") - .setHeader(ApnsConstants.HEADER_MESSAGE_TYPE, constant(MessageType.APNS_NOTIFICATION.name())) - .to("apns:notify"); - } - }; - } -} diff --git a/components/camel-apns/src/test/java/org/apache/camel/component/apns/ApnsProducerWithoutTokensHeaderTest.java b/components/camel-apns/src/test/java/org/apache/camel/component/apns/ApnsProducerWithoutTokensHeaderTest.java deleted file mode 100644 index ae699ec..0000000 --- a/components/camel-apns/src/test/java/org/apache/camel/component/apns/ApnsProducerWithoutTokensHeaderTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.component.apns; - -import com.notnoop.apns.APNS; -import com.notnoop.apns.ApnsService; -import com.notnoop.apns.EnhancedApnsNotification; -import com.notnoop.apns.utils.ApnsServerStub; -import org.apache.camel.CamelContext; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.apns.factory.ApnsServiceFactory; -import org.apache.camel.component.apns.util.ApnsUtils; -import org.apache.camel.component.apns.util.TestConstants; -import org.apache.camel.test.junit5.CamelTestSupport; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.Timeout; - -import static org.junit.jupiter.api.Assertions.assertArrayEquals; - -/** - * Unit test that we can produce JMS message from files - */ -public class ApnsProducerWithoutTokensHeaderTest extends CamelTestSupport { - - private static final String FAKE_TOKEN = "19308314834701ACD8313AEBD92AEFDE192120371FE13982392831701318B943"; - - private ApnsServerStub server; - - @BeforeEach - public void startup() { - server = ApnsUtils.prepareAndStartServer(TestConstants.TEST_GATEWAY_PORT, TestConstants.TEST_FEEDBACK_PORT); - } - - @AfterEach - public void stop() { - server.stop(); - } - - @Test - @Timeout(5) - public void testProducerWithoutTokenHeader() throws Exception { - String message = "Hello World"; - String messagePayload = APNS.newPayload().alertBody(message).build(); - - EnhancedApnsNotification apnsNotification - = new EnhancedApnsNotification(1, EnhancedApnsNotification.MAXIMUM_EXPIRY, FAKE_TOKEN, messagePayload); - server.stopAt(apnsNotification.length()); - - template.sendBody("direct:test", message); - - server.getMessages().acquire(); - assertArrayEquals(apnsNotification.marshall(), server.getReceived().toByteArray()); - } - - @Override - protected CamelContext createCamelContext() throws Exception { - CamelContext camelContext = super.createCamelContext(); - - ApnsServiceFactory apnsServiceFactory = ApnsUtils.createDefaultTestConfiguration(camelContext); - ApnsService apnsService = apnsServiceFactory.getApnsService(); - - ApnsComponent apnsComponent = new ApnsComponent(apnsService); - camelContext.addComponent("apns", apnsComponent); - - return camelContext; - } - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - public void configure() throws Exception { - from("direct:test") - .to("apns:notify?tokens=" + FAKE_TOKEN); - } - }; - } -} diff --git a/components/camel-apns/src/test/java/org/apache/camel/component/apns/factory/ApnsServiceFactoryTest.java b/components/camel-apns/src/test/java/org/apache/camel/component/apns/factory/ApnsServiceFactoryTest.java deleted file mode 100644 index ac8ee38..0000000 --- a/components/camel-apns/src/test/java/org/apache/camel/component/apns/factory/ApnsServiceFactoryTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.component.apns.factory; - -import com.notnoop.apns.ApnsService; -import org.apache.camel.component.apns.model.ConnectionStrategy; -import org.apache.camel.component.apns.util.ApnsUtils; -import org.apache.camel.component.apns.util.TestConstants; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class ApnsServiceFactoryTest { - - @Test - public void testApnsServiceFactoryWithFixedCertificates() throws Exception { - ApnsServiceFactory apnsServiceFactory = createApnsServiceFactoryWithFixedCertificates(); - ApnsService apnsService = apnsServiceFactory.getApnsService(); - - doBasicAsserts(apnsService); - } - - @Test - public void testApnsServiceFactoryAsPool0() throws Exception { - ApnsServiceFactory apnsServiceFactory = createApnsServiceFactoryWithFixedCertificatesAsPool(0); - assertThrows(IllegalArgumentException.class, - () -> apnsServiceFactory.getApnsService()); - } - - @Test - public void testApnsServiceFactoryAsPool1() throws Exception { - ApnsServiceFactory apnsServiceFactory = createApnsServiceFactoryWithFixedCertificatesAsPool(1); - ApnsService apnsService = apnsServiceFactory.getApnsService(); - - doBasicAsserts(apnsService); - } - - private void doBasicAsserts(Object apnsService) { - assertNotNull(apnsService); - assertTrue(apnsService instanceof ApnsService); - } - - public static ApnsServiceFactory createApnsServiceFactoryWithFixedCertificates() - throws Exception { - ApnsServiceFactory apnsServiceFactory = new ApnsServiceFactory(); - - apnsServiceFactory.setFeedbackHost(TestConstants.TEST_HOST); - apnsServiceFactory.setFeedbackPort(TestConstants.TEST_FEEDBACK_PORT); - apnsServiceFactory.setGatewayHost(TestConstants.TEST_HOST); - apnsServiceFactory.setGatewayPort(TestConstants.TEST_GATEWAY_PORT); - apnsServiceFactory.setSslContextParameters(ApnsUtils.clientContext()); - - return apnsServiceFactory; - } - - private ApnsServiceFactory createApnsServiceFactoryWithFixedCertificatesAsPool(int poolSize) - throws Exception { - ApnsServiceFactory apnsServiceFactory = createApnsServiceFactoryWithFixedCertificates(); - apnsServiceFactory.setConnectionStrategy(ConnectionStrategy.POOL); - - apnsServiceFactory.setPoolSize(poolSize); - - return apnsServiceFactory; - } - -} diff --git a/components/camel-apns/src/test/java/org/apache/camel/component/apns/factory/ConfiguredApnsServiceFactoryTest.java b/components/camel-apns/src/test/java/org/apache/camel/component/apns/factory/ConfiguredApnsServiceFactoryTest.java deleted file mode 100644 index dbb2ac8..0000000 --- a/components/camel-apns/src/test/java/org/apache/camel/component/apns/factory/ConfiguredApnsServiceFactoryTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.component.apns.factory; - -import java.io.IOException; - -import com.notnoop.apns.ApnsServiceBuilder; -import org.apache.camel.support.jsse.SSLContextParameters; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import static org.mockito.ArgumentMatchers.anyInt; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - -public class ConfiguredApnsServiceFactoryTest { - - ApnsServiceBuilder apnsServiceBuilder = mock(ApnsServiceBuilder.class); - - ApnsServiceFactory apnsServiceFactory = new ApnsServiceFactory() { - @Override - protected ApnsServiceBuilder configureServiceBuilder(ApnsServiceBuilder serviceBuilder) { - apnsServiceBuilder.withSocksProxy("my.proxy.com", 6666); - return apnsServiceBuilder; - } - }; - - @BeforeEach - public void setUp() throws IOException { - apnsServiceFactory.setSslContextParameters(mock(SSLContextParameters.class)); - } - - @Test - public void shouldSetProxyOnDefaultServiceBuilder() { - // When - apnsServiceFactory.getApnsService(); - - // Then - verify(apnsServiceBuilder).withSocksProxy(anyString(), anyInt()); - } - -} diff --git a/components/camel-apns/src/test/java/org/apache/camel/component/apns/spring/SpringApnsConsumerTest.java b/components/camel-apns/src/test/java/org/apache/camel/component/apns/spring/SpringApnsConsumerTest.java deleted file mode 100644 index de213ba..0000000 --- a/components/camel-apns/src/test/java/org/apache/camel/component/apns/spring/SpringApnsConsumerTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.component.apns.spring; - -import com.notnoop.apns.utils.ApnsServerStub; -import org.apache.camel.CamelContext; -import org.apache.camel.EndpointInject; -import org.apache.camel.component.apns.model.InactiveDevice; -import org.apache.camel.component.apns.util.ApnsUtils; -import org.apache.camel.component.apns.util.TestConstants; -import org.apache.camel.component.mock.MockEndpoint; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.Timeout; -import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -/** - * Unit test that we can produce JMS message from files - */ -@ContextConfiguration -@ExtendWith(SpringExtension.class) -public class SpringApnsConsumerTest { - - @Autowired - protected CamelContext camelContext; - - @EndpointInject("mock:result") - protected MockEndpoint mock; - - private ApnsServerStub server; - - @BeforeEach - public void startup() throws InterruptedException { - server = ApnsUtils.prepareAndStartServer(TestConstants.TEST_GATEWAY_PORT, TestConstants.TEST_FEEDBACK_PORT); - } - - @AfterEach - public void stop() { - server.stop(); - } - - @Test - @Timeout(5) - public void testConsumer() throws Exception { - - byte[] deviceTokenBytes = ApnsUtils.createRandomDeviceTokenBytes(); - String deviceToken = ApnsUtils.encodeHexToken(deviceTokenBytes); - - mock.expectedMessageCount(1); - mock.message(0).body().isInstanceOf(InactiveDevice.class); - - byte[] feedBackBytes = ApnsUtils.generateFeedbackBytes(deviceTokenBytes); - server.getToSend().write(feedBackBytes); - - Thread.sleep(1000); - - mock.assertIsSatisfied(); - - InactiveDevice inactiveDevice = (InactiveDevice) mock.getExchanges().get(0).getIn().getBody(); - assertNotNull(inactiveDevice); - assertNotNull(inactiveDevice.getDate()); - assertNotNull(inactiveDevice.getDeviceToken()); - assertEquals(deviceToken, inactiveDevice.getDeviceToken()); - } - -} diff --git a/components/camel-apns/src/test/java/org/apache/camel/component/apns/util/ApnsUtils.java b/components/camel-apns/src/test/java/org/apache/camel/component/apns/util/ApnsUtils.java deleted file mode 100644 index 043b93b..0000000 --- a/components/camel-apns/src/test/java/org/apache/camel/component/apns/util/ApnsUtils.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.component.apns.util; - -import java.io.IOException; -import java.io.InputStream; -import java.security.GeneralSecurityException; -import java.security.Provider; -import java.security.Provider.Service; -import java.security.SecureRandom; -import java.security.Security; -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; -import java.util.LinkedList; -import java.util.List; - -import javax.net.ssl.SSLContext; -import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; - -import com.notnoop.apns.internal.ApnsFeedbackParsingUtilsAcessor; -import com.notnoop.apns.internal.Utilities; -import com.notnoop.apns.utils.ApnsServerStub; -import com.notnoop.apns.utils.FixedCertificates; -import org.apache.camel.CamelContext; -import org.apache.camel.component.apns.factory.ApnsServiceFactory; -import org.apache.camel.support.jsse.KeyManagersParameters; -import org.apache.camel.support.jsse.KeyStoreParameters; -import org.apache.camel.support.jsse.SSLContextParameters; -import org.apache.camel.support.jsse.TrustManagersParameters; - -public final class ApnsUtils { - - private static SecureRandom random = new SecureRandom(); - - private ApnsUtils() { - } - - public static byte[] createRandomDeviceTokenBytes() { - byte[] deviceTokenBytes = new byte[32]; - random.nextBytes(deviceTokenBytes); - - return deviceTokenBytes; - } - - public static String encodeHexToken(byte[] deviceTokenBytes) { - String deviceToken = Utilities.encodeHex(deviceTokenBytes); - - return deviceToken; - } - - public static ApnsServerStub prepareAndStartServer(int gatePort, int feedPort) { - InputStream stream = ClassLoader.getSystemResourceAsStream(FixedCertificates.SERVER_STORE); - SSLContext context = Utilities.newSSLContext(stream, FixedCertificates.SERVER_PASSWORD, - "PKCS12", getAlgorithm()); - - ApnsServerStub server = new ApnsServerStub( - context.getServerSocketFactory(), - gatePort, feedPort); - server.start(); - return server; - } - - public static String getAlgorithm() { - List<String> keys = new LinkedList<>(); - List<String> trusts = new LinkedList<>(); - for (Provider p : Security.getProviders()) { - for (Service s : p.getServices()) { - if ("KeyManagerFactory".equals(s.getType()) - && s.getAlgorithm().endsWith("509")) { - keys.add(s.getAlgorithm()); - } else if ("TrustManagerFactory".equals(s.getType()) - && s.getAlgorithm().endsWith("509")) { - trusts.add(s.getAlgorithm()); - } - } - } - keys.retainAll(trusts); - return keys.get(0); - } - - public static SSLContextParameters clientContext() throws Exception { - final KeyStoreParameters ksp = new KeyStoreParameters(); - ksp.setResource(ClassLoader.getSystemResource(FixedCertificates.CLIENT_STORE).toString()); - ksp.setType("PKCS12"); - - final KeyManagersParameters kmp = new KeyManagersParameters(); - kmp.setKeyStore(ksp); - kmp.setKeyPassword(FixedCertificates.CLIENT_PASSWORD); - kmp.setAlgorithm(getAlgorithm()); - - final SSLContextParameters contextParameters = new SSLContextParameters(); - contextParameters.setKeyManagers(kmp); - contextParameters.setTrustManagers(new TrustManagersParameters() { - @Override - public TrustManager[] createTrustManagers() throws GeneralSecurityException, IOException { - return new TrustManager[] { new X509TrustManager() { - public void checkClientTrusted(X509Certificate[] chain, String authType) - throws CertificateException { - } - - public void checkServerTrusted(X509Certificate[] chain, String authType) - throws CertificateException { - } - - public X509Certificate[] getAcceptedIssuers() { - return new X509Certificate[0]; - } - - } }; - } - }); - - return contextParameters; - } - - public static ApnsServiceFactory createDefaultTestConfiguration(CamelContext camelContext) - throws Exception { - ApnsServiceFactory apnsServiceFactory = new ApnsServiceFactory(camelContext); - - apnsServiceFactory.setFeedbackHost(TestConstants.TEST_HOST); - apnsServiceFactory.setFeedbackPort(TestConstants.TEST_FEEDBACK_PORT); - apnsServiceFactory.setGatewayHost(TestConstants.TEST_HOST); - apnsServiceFactory.setGatewayPort(TestConstants.TEST_GATEWAY_PORT); - // apnsServiceFactory.setCertificatePath("classpath:/" + - // FixedCertificates.CLIENT_STORE); - // apnsServiceFactory.setCertificatePassword(FixedCertificates.CLIENT_PASSWD); - apnsServiceFactory.setSslContextParameters(clientContext()); - return apnsServiceFactory; - } - - public static byte[] generateFeedbackBytes(byte[] deviceTokenBytes) { - byte[] feedbackBytes = ApnsFeedbackParsingUtilsAcessor.pack( - /* time_t */new byte[] { 0, 0, 0, 0 }, - /* length */new byte[] { 0, 32 }, - /* device token */deviceTokenBytes); - - return feedbackBytes; - } - -} diff --git a/components/camel-apns/src/test/java/org/apache/camel/component/apns/util/AssertUtilsTest.java b/components/camel-apns/src/test/java/org/apache/camel/component/apns/util/AssertUtilsTest.java deleted file mode 100644 index f71dbf5..0000000 --- a/components/camel-apns/src/test/java/org/apache/camel/component/apns/util/AssertUtilsTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.component.apns.util; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.fail; - -public class AssertUtilsTest { - - @Test - public void testAssertIsTrueValid() { - AssertUtils.isTrue(true, " message"); - } - - @Test - public void testAssertIsTrueInvalid() { - try { - AssertUtils.isTrue(false, "message"); - fail("Should have thrown exception"); - } catch (IllegalArgumentException e) { - assertEquals("[Assert is true] message", e.getMessage()); - } - } - - @Test - public void testAssertNoNullValid() { - AssertUtils.notNull(new Object(), " message"); - } - - @Test - public void testAssertNotNullInvalid() { - try { - AssertUtils.notNull(null, "message"); - fail("Should have thrown exception"); - } catch (IllegalArgumentException e) { - assertEquals("[Assert not null] message", e.getMessage()); - } - } - -} diff --git a/components/camel-apns/src/test/java/org/apache/camel/component/apns/util/StringUtilsTest.java b/components/camel-apns/src/test/java/org/apache/camel/component/apns/util/StringUtilsTest.java deleted file mode 100644 index 5217f29..0000000 --- a/components/camel-apns/src/test/java/org/apache/camel/component/apns/util/StringUtilsTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.component.apns.util; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class StringUtilsTest { - - @Test - public void testIsEmpty() { - assertFalse(StringUtils.isEmpty("test")); - assertFalse(StringUtils.isEmpty("a")); - assertTrue(StringUtils.isEmpty("")); - assertTrue(StringUtils.isEmpty(null)); - } - - @Test - public void testIsNotEmpty() { - assertTrue(StringUtils.isNotEmpty("test")); - assertTrue(StringUtils.isNotEmpty("a")); - assertFalse(StringUtils.isNotEmpty("")); - assertFalse(StringUtils.isNotEmpty(null)); - } - - @Test - public void testTrim() { - assertEquals("", StringUtils.trim("")); - assertEquals("", StringUtils.trim(" ")); - - assertEquals("test", StringUtils.trim("test")); - assertEquals("test", StringUtils.trim("test ")); - assertEquals("test", StringUtils.trim(" test")); - assertEquals("test", StringUtils.trim(" test ")); - - assertEquals(null, StringUtils.trim(null)); - } - -} diff --git a/components/camel-apns/src/test/java/org/apache/camel/component/apns/util/TestConstants.java b/components/camel-apns/src/test/java/org/apache/camel/component/apns/util/TestConstants.java deleted file mode 100644 index ebc12c4..0000000 --- a/components/camel-apns/src/test/java/org/apache/camel/component/apns/util/TestConstants.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.component.apns.util; - -/** - * Interface with address and port to point inside tests - */ -public final class TestConstants { - - public static final int TEST_GATEWAY_PORT = 7654; - public static final int TEST_FEEDBACK_PORT = 7843; - public static final String TEST_HOST = "localhost"; - - private TestConstants() { - } -} diff --git a/components/camel-apns/src/test/resources/log4j2.properties b/components/camel-apns/src/test/resources/log4j2.properties deleted file mode 100644 index 29c8c01..0000000 --- a/components/camel-apns/src/test/resources/log4j2.properties +++ /dev/null @@ -1,30 +0,0 @@ -## --------------------------------------------------------------------------- -## Licensed to the Apache Software Foundation (ASF) under one or more -## contributor license agreements. See the NOTICE file distributed with -## this work for additional information regarding copyright ownership. -## The ASF licenses this file to You under the Apache License, Version 2.0 -## (the "License"); you may not use this file except in compliance with -## the License. You may obtain a copy of the License at -## -## http://www.apache.org/licenses/LICENSE-2.0 -## -## Unless required by applicable law or agreed to in writing, software -## distributed under the License is distributed on an "AS IS" BASIS, -## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -## See the License for the specific language governing permissions and -## limitations under the License. -## --------------------------------------------------------------------------- - -appender.file.type = File -appender.file.name = file -appender.file.fileName = target/camel-apns-test.log -appender.file.layout.type = PatternLayout -appender.file.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n -appender.out.type = Console -appender.out.name = out -appender.out.layout.type = PatternLayout -appender.out.layout.pattern = [%30.30t] %-30.30c{1} %-5p %m%n -logger.apns.name = org.apache.camel.component.apns -logger.apns.level = DEBUG -rootLogger.level = INFO -rootLogger.appenderRef.file.ref = file diff --git a/components/camel-apns/src/test/resources/org/apache/camel/component/apns/spring/SpringApnsConsumerTest-context.xml b/components/camel-apns/src/test/resources/org/apache/camel/component/apns/spring/SpringApnsConsumerTest-context.xml deleted file mode 100644 index 409fec2..0000000 --- a/components/camel-apns/src/test/resources/org/apache/camel/component/apns/spring/SpringApnsConsumerTest-context.xml +++ /dev/null @@ -1,53 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ---> -<!-- Configures the Camel Context--> -<beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:camel="http://camel.apache.org/schema/spring" - xsi:schemaLocation=" - http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd - http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"> - - <bean id="apnsServiceFactory" class="org.apache.camel.component.apns.factory.ApnsServiceFactory"> - <property name="camelContext" ref="camel-apns-test"/> - <property name="feedbackHost" value="localhost"/> - <property name="feedbackPort" value="7843"/> - <property name="gatewayHost" value="localhost"/> - <property name="gatewayPort" value="7654"/> - <property name="sslContextParameters" ref="sslContextParameters"/> - </bean> - - <bean id="apnsService" factory-bean="apnsServiceFactory" factory-method="getApnsService"/> - - <bean id="sslContextParameters" class="org.apache.camel.component.apns.util.ApnsUtils" factory-method="clientContext"/> - - <bean id="apns" class="org.apache.camel.component.apns.ApnsComponent"> - <property name="apnsService" ref="apnsService"/> - </bean> - - <camelContext id="camel-apns-test" xmlns="http://camel.apache.org/schema/spring"> - <route id="apns-test"> - <from uri="apns:consumer?initialDelay=500&delay=500&timeUnit=MILLISECONDS"/> - <to uri="log:apns?showAll=true&multiline=true"/> - <to uri="mock:result"/> - </route> - </camelContext> - -</beans>
