You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2020/08/19 10:07:07 UTC

[GitHub] [camel-quarkus] aldettinger commented on a change in pull request #1542: Added support for flatpack dataformat fixes #796

aldettinger commented on a change in pull request #1542:
URL: https://github.com/apache/camel-quarkus/pull/1542#discussion_r472914568



##########
File path: integration-tests/flatpack/src/test/java/org/apache/camel/quarkus/component/flatpack/it/FlatpackTest.java
##########
@@ -0,0 +1,90 @@
+/*
+ * 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.flatpack.it;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.http.ContentType;
+import org.apache.camel.converter.IOConverter;
+import org.junit.jupiter.api.Test;
+
+import static io.restassured.RestAssured.given;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.startsWith;
+
+@QuarkusTest
+class FlatpackTest {
+
+    @Test
+    public void delimitedUnmarshalShouldSucceed() throws IOException {
+        String data = IOConverter.toString(new File("src/test/data/delim/INVENTORY-CommaDelimitedWithQualifier.txt"), null);

Review comment:
       Thanks for catching @ppalaga :+1 I've aligned on other tests in this [commit](https://github.com/apache/camel-quarkus/commit/cc863ae1b2b9be61135f7195dde737e9ee544798).

##########
File path: integration-tests/flatpack/src/test/java/org/apache/camel/quarkus/component/flatpack/it/FlatpackTest.java
##########
@@ -0,0 +1,90 @@
+/*
+ * 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.flatpack.it;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.http.ContentType;
+import org.apache.camel.converter.IOConverter;
+import org.junit.jupiter.api.Test;
+
+import static io.restassured.RestAssured.given;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.startsWith;
+
+@QuarkusTest
+class FlatpackTest {
+
+    @Test
+    public void delimitedUnmarshalShouldSucceed() throws IOException {
+        String data = IOConverter.toString(new File("src/test/data/delim/INVENTORY-CommaDelimitedWithQualifier.txt"), null);
+
+        given().body(data).when().get("/flatpack/delimited-unmarshal").then().statusCode(200).body(is("4-SOME VALVE"));
+    }
+
+    @Test
+    public void delimitedMarshalShouldSucceed() {
+        List<Map<String, String>> data = new ArrayList<>();
+        Map<String, String> firstRow = new LinkedHashMap<>();
+        firstRow.put("ITEM_DESC", "SOME VALVE");
+        firstRow.put("IN_STOCK", "2");
+        firstRow.put("PRICE", "5.00");
+        firstRow.put("LAST_RECV_DT", "20050101");
+        data.add(firstRow);
+
+        Map<String, String> secondRow = new LinkedHashMap<>();
+        secondRow.put("ITEM_DESC", "AN ENGINE");
+        secondRow.put("IN_STOCK", "100");
+        secondRow.put("PRICE", "1000.00");
+        secondRow.put("LAST_RECV_DT", "20040601");
+        data.add(secondRow);
+
+        String expected = "ITEM_DESC,IN_STOCK,PRICE,LAST_RECV_DT\nAN ENGINE,100,1000.00,20040601\n";
+        given().contentType(ContentType.JSON).body(data).when().get("/flatpack/delimited-marshal").then().statusCode(200)
+                .body(is(expected));
+    }
+
+    @Test
+    public void fixedLengthUnmarshalShouldSucceed() throws IOException {
+        String data = IOConverter.toString(new File("src/test/data/fixed/PEOPLE-FixedLength.txt"), null);

Review comment:
       Same as above.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org