You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by al...@apache.org on 2021/03/30 09:24:32 UTC
[camel-quarkus] branch master updated: bindy: created a test to
show the locale issue in native and documented #2407
This is an automated email from the ASF dual-hosted git repository.
aldettinger pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/master by this push:
new 256ecad bindy: created a test to show the locale issue in native and documented #2407
256ecad is described below
commit 256ecadace9882cf054034ace208acad66acce44
Author: aldettinger <al...@gmail.com>
AuthorDate: Mon Mar 29 18:21:44 2021 +0200
bindy: created a test to show the locale issue in native and documented #2407
---
.../ROOT/pages/reference/extensions/bindy.adoc | 12 ++++++++
.../ROOT/pages/reference/extensions/core.adoc | 2 +-
.../bindy/runtime/src/main/doc/limitations.adoc | 8 +++++
.../quarkus/component/bindy/it/BindyResource.java | 14 +++++++++
.../quarkus/component/bindy/it/BindyTestRoute.java | 7 +++++
.../bindy/it/model/FixedLengthWithLocale.java | 36 ++++++++++++++++++++++
.../bindy/it/FixedLengthWithLocaleIT.java | 26 ++++++++++++++++
.../bindy/it/FixedLengthWithLocaleTest.java | 31 +++++++++++++++++++
8 files changed, 135 insertions(+), 1 deletion(-)
diff --git a/docs/modules/ROOT/pages/reference/extensions/bindy.adoc b/docs/modules/ROOT/pages/reference/extensions/bindy.adoc
index a21a51c..63651d9 100644
--- a/docs/modules/ROOT/pages/reference/extensions/bindy.adoc
+++ b/docs/modules/ROOT/pages/reference/extensions/bindy.adoc
@@ -34,3 +34,15 @@ Please refer to the above links for usage and configuration details.
----
Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications.
+
+== Camel Quarkus limitations
+
+When using camel-quarkus-bindy in native mode, only the build machine's default locale is supported.
+
+For instance, on build machines with french default locale, the code below:
+```
+BindyDataFormat dataFormat = new BindyDataFormat();
+dataFormat.setLocale("ar");
+```
+formats numbers the arabic way in JVM mode as expected. However, it formats numbers the french way in native mode.
+
diff --git a/docs/modules/ROOT/pages/reference/extensions/core.adoc b/docs/modules/ROOT/pages/reference/extensions/core.adoc
index db75198..2879a4a 100644
--- a/docs/modules/ROOT/pages/reference/extensions/core.adoc
+++ b/docs/modules/ROOT/pages/reference/extensions/core.adoc
@@ -168,7 +168,7 @@ What to do if it is not possible to extract CSimple expressions from a route def
|icon:lock[title=Fixed at build time] [[quarkus.camel.main.enabled]]`link:#quarkus.camel.main.enabled[quarkus.camel.main.enabled]`
-If `true` all `camel-main` features are enabled; otherwise no `camel-main` features are enabled. See described the xref:user-guide/bootstrap.adoc[Bootstrap] camel-main section of the documentation for more details.
+If `true` all `camel-main` features are enabled; otherwise no `camel-main` features are enabled. See described the link:https://camel.apache.org/camel-quarkus/latest/user-guide/bootstrap.html#_camel_main[Bootstrap] section of Camel Quarkus documentation for more details.
| `boolean`
| `true`
diff --git a/extensions/bindy/runtime/src/main/doc/limitations.adoc b/extensions/bindy/runtime/src/main/doc/limitations.adoc
new file mode 100644
index 0000000..4aa54ad
--- /dev/null
+++ b/extensions/bindy/runtime/src/main/doc/limitations.adoc
@@ -0,0 +1,8 @@
+When using camel-quarkus-bindy in native mode, only the build machine's default locale is supported.
+
+For instance, on build machines with french default locale, the code below:
+```
+BindyDataFormat dataFormat = new BindyDataFormat();
+dataFormat.setLocale("ar");
+```
+formats numbers the arabic way in JVM mode as expected. However, it formats numbers the french way in native mode.
\ No newline at end of file
diff --git a/integration-tests/bindy/src/main/java/org/apache/camel/quarkus/component/bindy/it/BindyResource.java b/integration-tests/bindy/src/main/java/org/apache/camel/quarkus/component/bindy/it/BindyResource.java
index 994bf8f..f0d652c 100644
--- a/integration-tests/bindy/src/main/java/org/apache/camel/quarkus/component/bindy/it/BindyResource.java
+++ b/integration-tests/bindy/src/main/java/org/apache/camel/quarkus/component/bindy/it/BindyResource.java
@@ -29,6 +29,7 @@ import javax.ws.rs.Path;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.quarkus.component.bindy.it.model.CsvOrder;
import org.apache.camel.quarkus.component.bindy.it.model.FixedLengthOrder;
+import org.apache.camel.quarkus.component.bindy.it.model.FixedLengthWithLocale;
import org.apache.camel.quarkus.component.bindy.it.model.Header;
import org.apache.camel.quarkus.component.bindy.it.model.MessageOrder;
import org.apache.camel.quarkus.component.bindy.it.model.NameWithLengthSuffix;
@@ -110,6 +111,19 @@ public class BindyResource {
assertEquals("Spa", order.getCountry());
}
+ @Path("/marshalFixedLengthWithLocaleShouldSucceed")
+ @GET
+ public void marshalFixedLengthWithLocaleShouldSucceed() {
+ LOG.debugf("Invoking marshalFixedLengthWithLocaleShouldSucceed()");
+
+ FixedLengthWithLocale object = new FixedLengthWithLocale();
+ object.setNumber(3.2);
+
+ String marshalled = template.requestBody("direct:marshal-fixed-length-with-locale", object, String.class);
+
+ assertEquals("٣٫٢٠٠\r\n", marshalled);
+ }
+
@Path("/marshalMessageShouldSucceed")
@GET
public void marshalMessageShouldSucceed() {
diff --git a/integration-tests/bindy/src/main/java/org/apache/camel/quarkus/component/bindy/it/BindyTestRoute.java b/integration-tests/bindy/src/main/java/org/apache/camel/quarkus/component/bindy/it/BindyTestRoute.java
index d5eed75..c2da507 100644
--- a/integration-tests/bindy/src/main/java/org/apache/camel/quarkus/component/bindy/it/BindyTestRoute.java
+++ b/integration-tests/bindy/src/main/java/org/apache/camel/quarkus/component/bindy/it/BindyTestRoute.java
@@ -22,6 +22,7 @@ import org.apache.camel.model.dataformat.BindyDataFormat;
import org.apache.camel.model.dataformat.BindyType;
import org.apache.camel.quarkus.component.bindy.it.model.CsvOrder;
import org.apache.camel.quarkus.component.bindy.it.model.FixedLengthOrder;
+import org.apache.camel.quarkus.component.bindy.it.model.FixedLengthWithLocale;
import org.apache.camel.quarkus.component.bindy.it.model.MessageOrder;
public class BindyTestRoute extends RouteBuilder {
@@ -40,6 +41,12 @@ public class BindyTestRoute extends RouteBuilder {
from("direct:marshal-fixed-length-record").marshal(bindyFixedLengthDataFormat);
from("direct:unmarshal-fixed-length-record").unmarshal(bindyFixedLengthDataFormat);
+ BindyDataFormat bindyFixedLengthWithLocaleDataFormat = new BindyDataFormat();
+ bindyFixedLengthWithLocaleDataFormat.setClassType(FixedLengthWithLocale.class);
+ bindyFixedLengthWithLocaleDataFormat.setType(BindyType.Fixed.name());
+ bindyFixedLengthWithLocaleDataFormat.setLocale("ar");
+ from("direct:marshal-fixed-length-with-locale").marshal(bindyFixedLengthWithLocaleDataFormat);
+
BindyKeyValuePairDataFormat bindyMessageDataFormat = new BindyKeyValuePairDataFormat(MessageOrder.class);
from("direct:marshal-message").marshal(bindyMessageDataFormat);
from("direct:unmarshal-message").unmarshal(bindyMessageDataFormat);
diff --git a/integration-tests/bindy/src/main/java/org/apache/camel/quarkus/component/bindy/it/model/FixedLengthWithLocale.java b/integration-tests/bindy/src/main/java/org/apache/camel/quarkus/component/bindy/it/model/FixedLengthWithLocale.java
new file mode 100644
index 0000000..8bc4dce
--- /dev/null
+++ b/integration-tests/bindy/src/main/java/org/apache/camel/quarkus/component/bindy/it/model/FixedLengthWithLocale.java
@@ -0,0 +1,36 @@
+/*
+ * 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.bindy.it.model;
+
+import org.apache.camel.dataformat.bindy.annotation.DataField;
+import org.apache.camel.dataformat.bindy.annotation.FixedLengthRecord;
+
+@FixedLengthRecord(length = 5)
+public class FixedLengthWithLocale {
+
+ @DataField(pos = 1, length = 5, precision = 3)
+ private double number;
+
+ public double getNumber() {
+ return number;
+ }
+
+ public void setNumber(double number) {
+ this.number = number;
+ }
+
+}
diff --git a/integration-tests/bindy/src/test/java/org/apache/camel/quarkus/component/bindy/it/FixedLengthWithLocaleIT.java b/integration-tests/bindy/src/test/java/org/apache/camel/quarkus/component/bindy/it/FixedLengthWithLocaleIT.java
new file mode 100644
index 0000000..2e1bc7b
--- /dev/null
+++ b/integration-tests/bindy/src/test/java/org/apache/camel/quarkus/component/bindy/it/FixedLengthWithLocaleIT.java
@@ -0,0 +1,26 @@
+/*
+ * 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.bindy.it;
+
+import io.quarkus.test.junit.NativeImageTest;
+import org.junit.jupiter.api.Disabled;
+
+@Disabled("https://github.com/apache/camel-quarkus/issues/2407")
+@NativeImageTest
+class FixedLengthWithLocaleIT extends FixedLengthWithLocaleTest {
+
+}
diff --git a/integration-tests/bindy/src/test/java/org/apache/camel/quarkus/component/bindy/it/FixedLengthWithLocaleTest.java b/integration-tests/bindy/src/test/java/org/apache/camel/quarkus/component/bindy/it/FixedLengthWithLocaleTest.java
new file mode 100644
index 0000000..a6ca32d
--- /dev/null
+++ b/integration-tests/bindy/src/test/java/org/apache/camel/quarkus/component/bindy/it/FixedLengthWithLocaleTest.java
@@ -0,0 +1,31 @@
+/*
+ * 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.bindy.it;
+
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import org.junit.jupiter.api.Test;
+
+@QuarkusTest
+class FixedLengthWithLocaleTest {
+
+ @Test
+ public void marshalFixedLengthWithLocaleShouldSucceed() {
+ RestAssured.get("/bindy/marshalFixedLengthWithLocaleShouldSucceed").then().statusCode(204);
+ }
+
+}