Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bindy: created a test to show the locale issue in native and document… #2408

Merged
merged 1 commit into from
Mar 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/modules/ROOT/pages/reference/extensions/bindy.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.

2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/reference/extensions/core.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
8 changes: 8 additions & 0 deletions extensions/bindy/runtime/src/main/doc/limitations.adoc
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
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;
Expand Down Expand Up @@ -110,6 +111,19 @@ public void unMarshalFixedLengthRecordShouldSucceed() {
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);
aldettinger marked this conversation as resolved.
Show resolved Hide resolved
}

@Path("/marshalMessageShouldSucceed")
@GET
public void marshalMessageShouldSucceed() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
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 {
Expand All @@ -40,6 +41,12 @@ public void configure() {
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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}

}
Original file line number Diff line number Diff line change
@@ -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 {

}
Original file line number Diff line number Diff line change
@@ -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);
}

}