Skip to content

Instantly share code, notes, and snippets.

@amolbrid
Created December 7, 2010 15:17
Show Gist options
  • Save amolbrid/731892 to your computer and use it in GitHub Desktop.
Save amolbrid/731892 to your computer and use it in GitHub Desktop.
request processor class for Mockito inOrder invocation
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.net.Socket;
public class RequestProcessor {
private Socket socket;
public RequestProcessor(Socket socket) {
this.socket = socket;
}
public void process() {
try {
InputStream is = socket.getInputStream();
// read request from input stream and process it.
PrintWriter pw = new PrintWriter(socket.getOutputStream());
pw.append("Ok");
pw.flush();
} catch (IOException e) {
} finally {
try {
socket.close();
} catch (IOException e) { }
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment