Skip to content

Commit

Permalink
Register atlasmap.properties as a native image resource
Browse files Browse the repository at this point in the history
Fixes #4633
  • Loading branch information
jamesnetherton committed Mar 14, 2023
1 parent c336bdb commit 64adb6a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ List<ReflectiveClassBuildItem> registerReflectiveClasses() {
}

@BuildStep
NativeImageResourceBuildItem resource() {
return new NativeImageResourceBuildItem("META-INF/services/atlas/module/atlas.module");
void nativeImageResources(BuildProducer<NativeImageResourceBuildItem> nativeImageResource) {
nativeImageResource.produce(new NativeImageResourceBuildItem("META-INF/services/atlas/module/atlas.module"));
nativeImageResource.produce(new NativeImageResourceBuildItem("atlasmap.properties"));
}

@BuildStep
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
*/
package org.apache.camel.quarkus.component.atlasmap.it;

import java.util.Map;

import io.atlasmap.core.DefaultAtlasContextFactory;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.ws.rs.Consumes;
Expand All @@ -26,6 +29,8 @@
import org.apache.camel.ProducerTemplate;
import org.apache.camel.quarkus.component.atlasmap.it.model.Person;

import static io.atlasmap.api.AtlasContextFactory.PROPERTY_ATLASMAP_CORE_VERSION;

@Path("/atlasmap")
@ApplicationScoped
@Produces(MediaType.APPLICATION_JSON)
Expand Down Expand Up @@ -131,4 +136,12 @@ public String convertXml2CsvWithJson(String xml) {
return producerTemplate.requestBody("atlasmap:mapping/json/atlasmapping-xml-to-csv.json", xml, String.class);
}

@GET
@Path("version")
@Produces(MediaType.TEXT_PLAIN)
public String version() {
DefaultAtlasContextFactory factory = DefaultAtlasContextFactory.getInstance();
Map<String, String> properties = factory.getProperties();
return properties.get(PROPERTY_ATLASMAP_CORE_VERSION);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
*/
package org.apache.camel.quarkus.component.atlasmap.it;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.quarkus.test.common.http.TestHTTPEndpoint;
Expand All @@ -25,6 +29,7 @@
import org.apache.camel.quarkus.component.atlasmap.it.model.Person;
import org.junit.jupiter.api.Test;

import static io.atlasmap.api.AtlasContextFactory.PROPERTY_ATLASMAP_CORE_VERSION;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.jupiter.api.Assertions.assertEquals;
Expand Down Expand Up @@ -285,4 +290,16 @@ void testJava2CsvWithJson() {
.body(equalTo(expectedResult));
}

@Test
void testGetAtlasMapVersion() throws IOException {
try (InputStream stream = getClass().getResourceAsStream("/atlasmap.properties")) {
Properties properties = new Properties();
properties.load(stream);
String version = properties.getProperty(PROPERTY_ATLASMAP_CORE_VERSION);

given().get("/version")
.then()
.body(equalTo(version));
}
}
}

0 comments on commit 64adb6a

Please sign in to comment.