-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
23 changed files
with
568 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 0 additions & 46 deletions
46
...t/src/main/java/org/apache/camel/quarkus/component/twilio/deployment/TwilioProcessor.java
This file was deleted.
Oops, something went wrong.
51 changes: 0 additions & 51 deletions
51
...ation-test/src/main/java/org/apache/camel/quarkus/component/twilio/it/TwilioResource.java
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
extensions-jvm/twilio/integration-test/src/main/resources/application.properties
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
...t/src/main/java/org/apache/camel/quarkus/component/twilio/deployment/TwilioProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* 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.quarkus.component.twilio.deployment; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.stream.Stream; | ||
|
||
import com.twilio.base.Creator; | ||
import com.twilio.base.Deleter; | ||
import com.twilio.base.Fetcher; | ||
import com.twilio.base.Reader; | ||
import com.twilio.base.Updater; | ||
import com.twilio.type.Endpoint; | ||
import io.quarkus.deployment.annotations.BuildProducer; | ||
import io.quarkus.deployment.annotations.BuildStep; | ||
import io.quarkus.deployment.builditem.AdditionalApplicationArchiveMarkerBuildItem; | ||
import io.quarkus.deployment.builditem.CombinedIndexBuildItem; | ||
import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; | ||
import io.quarkus.deployment.builditem.FeatureBuildItem; | ||
import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem; | ||
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; | ||
import org.jboss.jandex.DotName; | ||
import org.jboss.jandex.IndexView; | ||
import org.joda.time.DateTimeZone; | ||
|
||
class TwilioProcessor { | ||
|
||
private static final String FEATURE = "camel-twilio"; | ||
|
||
@BuildStep | ||
FeatureBuildItem feature() { | ||
return new FeatureBuildItem(FEATURE); | ||
} | ||
|
||
@BuildStep | ||
ExtensionSslNativeSupportBuildItem activateSslNativeSupport() { | ||
return new ExtensionSslNativeSupportBuildItem(FEATURE); | ||
} | ||
|
||
@BuildStep | ||
AdditionalApplicationArchiveMarkerBuildItem boxArchiveMarker() { | ||
return new AdditionalApplicationArchiveMarkerBuildItem("com/twilio"); | ||
} | ||
|
||
@BuildStep | ||
void registerForReflection(BuildProducer<ReflectiveClassBuildItem> reflectiveClass, CombinedIndexBuildItem combinedIndex) { | ||
IndexView index = combinedIndex.getIndex(); | ||
|
||
// Register Twilio API CRUD generator classes for reflection | ||
String[] reflectiveClasses = Stream.of(Creator.class, Deleter.class, Fetcher.class, Reader.class, Updater.class) | ||
.map(aClass -> aClass.getName()) | ||
.map(DotName::createSimple) | ||
.flatMap(dotName -> index.getAllKnownSubclasses(dotName).stream()) | ||
.map(classInfo -> classInfo.name().toString()) | ||
.filter(className -> className.startsWith("com.twilio.rest.api.v2010")) | ||
.toArray(String[]::new); | ||
reflectiveClass.produce(new ReflectiveClassBuildItem(true, false, reflectiveClasses)); | ||
|
||
// Register Twilio Endpoint implementors for reflection | ||
String[] endpointImplementors = index.getAllKnownImplementors(DotName.createSimple(Endpoint.class.getName())) | ||
.stream() | ||
.map(classInfo -> classInfo.name().toString()) | ||
.toArray(String[]::new); | ||
|
||
reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, endpointImplementors)); | ||
} | ||
|
||
@BuildStep | ||
NativeImageResourceBuildItem nativeImageResources() { | ||
// Add Joda timezone resources into the native image as it is required by com.twilio.converter.DateConverter | ||
List<String> timezones = new ArrayList<>(); | ||
for (String timezone : DateTimeZone.getAvailableIDs()) { | ||
String[] zoneParts = timezone.split("/"); | ||
if (zoneParts.length == 2) { | ||
timezones.add(String.format("org/joda/time/tz/data/%s/%s", zoneParts[0], zoneParts[1])); | ||
} | ||
} | ||
return new NativeImageResourceBuildItem(timezones); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
== Camel Quarkus Twilio Integration Tests | ||
|
||
By default the Twilio integration tests use WireMock to stub the API interactions. | ||
|
||
To run the `camel-quarkus-twilio` integration tests against the real API, you must first create a Twilio account https://www.twilio.com/try-twilio. | ||
|
||
Then find your API https://www.twilio.com/docs/iam/test-credentials[test credentials] and set the following environment variables: | ||
|
||
[source,shell] | ||
---- | ||
export TWILIO_USERNAME=your-user-name | ||
export TWILIO_PASSWORD=your-password | ||
export TWILIO_ACCOUNT_SID=your-account-sid | ||
---- | ||
|
||
If the WireMock stub recordings need updating, then remove the existing files from `src/test/resources/mappings` and run tests with either: | ||
|
||
System property `-Dwiremock.record=true` | ||
|
||
Or | ||
|
||
Set environment variable `WIREMOCK_RECORD=true` |
Oops, something went wrong.