This discussion is archived
0 Replies Latest reply: Feb 13, 2007 6:19 AM by 807597 RSS

Sockets and TestNG

807597 Newbie
Currently Being Moderated
This problem relates to Testing a client/server program that uses Sockets.
I have some code which basically involves transmitting some Strings from client to server over sockets.
The code worked fine when dealing with jEdit and terminals.
I ran the Server and then had some main methods which I ran manually in the right order for each thing I wanted to send to the server.

Now I have set the code up in Eclipse and have written some TestNG tests. The problem is that the server seems to block as soon as it is set up and no other tests get the chance to run, notably, those that are supposed to send the stuff to the server.

I tried a few things. First I tried to get the tests to run in parallel. That didn't work. Secondly I put the tests in two test classes, that didn't work either.

If anyone had any suggestions of how to deal with this I would be very grateful.

Some of the code I have is as follows:

This is my Server socket code:
ServerSocket serverSocket = new ServerSocket(PORT) ;
Socket socket = serverSocket.accept();
BufferedReader incomingFileBuffer = new BufferedReader(new InputStreamReader(socket.getInputStream()));
This is my client code:
socket = new Socket(HOST, PORT);
PrintWriter toServer = new PrintWriter(socket.getOutputStream()) ;