flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FLINK-2477) Add test for SocketClientSink
Date Mon, 10 Aug 2015 19:18:45 GMT

    [ https://issues.apache.org/jira/browse/FLINK-2477?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14680600#comment-14680600
] 

ASF GitHub Bot commented on FLINK-2477:
---------------------------------------

Github user StephanEwen commented on a diff in the pull request:

    https://github.com/apache/flink/pull/977#discussion_r36672088
  
    --- Diff: flink-staging/flink-streaming/flink-streaming-core/src/test/java/org/apache/flink/streaming/api/functions/SocketClientSinkTest.java
---
    @@ -0,0 +1,136 @@
    +/*
    + * 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.flink.streaming.api.functions;
    +
    +import java.io.IOException;
    +import java.net.Socket;
    +
    +import org.apache.flink.configuration.Configuration;
    +import org.apache.flink.streaming.api.functions.sink.SocketClientSink;
    +import org.apache.flink.streaming.util.serialization.SerializationSchema;
    +
    +import org.junit.Test;
    +
    +import static java.lang.Thread.sleep;
    +import static org.junit.Assert.*;
    +
    +import java.io.BufferedReader;
    +import java.io.InputStreamReader;
    +import java.io.PrintWriter;
    +import java.net.ServerSocket;
    +
    +/**
    + * Tests for the {@link org.apache.flink.streaming.api.functions.sink.SocketClientSink}.
    + */
    +public class SocketClientSinkTest{
    +
    +	private final String host = "127.0.0.1";
    +	private int port = 9999;
    +	private String access;
    +	public SocketServer.ServerThread th = null;
    +
    +	class SocketServer extends Thread {
    +
    +		private ServerSocket server = null;
    +		private Socket sk = null;
    +		private BufferedReader rdr = null;
    +		private PrintWriter wtr = null;
    +
    +		private SocketServer(int port) {
    +			while (port > 0) {
    +				try {
    +					this.server = new ServerSocket(port);
    +					break;
    +				} catch (Exception e) {
    +					--port;
    +					if (port > 0) {
    +						continue;
    +					}
    +					else{
    +						e.printStackTrace();
    +					}
    +				}
    +			}
    +		}
    +
    +		public void run() {
    +			System.out.println("Listenning...");
    +			try {
    +				sk = server.accept();
    +				access = "Connected";
    +				th = new ServerThread(sk);
    +				th.start();
    +			} catch (Exception e) {
    +				e.printStackTrace();
    --- End diff --
    
    An exception here should cause the test to fail.


> Add test for SocketClientSink
> -----------------------------
>
>                 Key: FLINK-2477
>                 URL: https://issues.apache.org/jira/browse/FLINK-2477
>             Project: Flink
>          Issue Type: Test
>          Components: Streaming
>    Affects Versions: 0.10
>         Environment: win7 32bit;linux
>            Reporter: Huang Wei
>            Priority: Minor
>             Fix For: 0.10
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> Add some tests for SocketClientSink.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message