ppalaga commented on a change in pull request #353: Camel quarkus netty URL: https://github.com/apache/camel-quarkus/pull/353#discussion_r340796295
########## File path: integration-tests/netty/src/test/java/org/apache/camel/quarkus/component/netty/it/NettyTest.java ########## @@ -0,0 +1,57 @@ +/* + * 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.netty.it; + +import io.quarkus.test.junit.QuarkusTest; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + + + +import java.io.*; +import java.net.Socket; + + +@QuarkusTest +class NettyTest { + + @Test + public void testPoem() { + //simulate https://github.com/apache/camel/blob/master/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyTCPSyncTest.java + final String poem = "Epitaph in Kohima, India marking the WWII Battle of Kohima and Imphal, Burma Campaign - Attributed to John Maxwell Edmonds"; + final String expectedResponse = "When You Go Home, Tell Them Of Us And Say, For Your Tomorrow, We Gave Our Today."; + try{ + final Socket socket = new Socket("localhost", 8999); + socket.setSoLinger(true, 0); + final PrintWriter outputWriter = new PrintWriter(socket.getOutputStream(),true); + //we'll use a reader and take advantage of the .readLine() + final BufferedReader inputReader = new BufferedReader(new InputStreamReader(socket.getInputStream())); + + outputWriter.println(poem); + + String response = inputReader.readLine(); + + Assertions.assertTrue(response.equalsIgnoreCase(expectedResponse), "Response did not match expected response"); + socket.close(); //NOTE this is causing the server to warn java.io.IOException: Connection reset by peer + }catch(Exception ex){ + System.out.println(ex); Review comment: Maybe better throw all exceptions out of the test. I assume we want to fail if there is an exception, do we not? ---------------------------------------------------------------- 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: [email protected] With regards, Apache Git Services
