while (true)
{
try
{
int localPort = random.nextInt() & 0xffff;
VirtualSocket socket1 = new VirtualSocket();
socket1.bind(new InetSocketAddress(localPort));
socket1.connect(basicBehaviorServerSocketAddress);
assertTrue(doOneConstructorTest(socket1, localPort));
break;
}
catch (BindException e)
{
log.info("looking for a free socket");
}
}
}
catch (Exception e)
{
log.error(e);
e.printStackTrace();
fail();
}
try
{
VirtualSocket socket2 = new VirtualSocket(basicBehaviorServerHost , basicBehaviorServerPort);
assertTrue(doOneConstructorTest(socket2, socket2.getLocalPort()));
}
catch (Exception e)
{
log.error(e);
e.printStackTrace();
fail();
}
try
{
VirtualSocket socket3 = new VirtualSocket(basicBehaviorServerHost , basicBehaviorServerPort, false);
fail();
}
catch (SocketException e)
{
assertTrue(e.getMessage().equals("Deprecated: use DataGramSocket instead of stream = false"));
}
catch (Exception e)
{
log.error(e);
e.printStackTrace();
fail();
}
try
{
VirtualSocket socket4 = new VirtualSocket(basicBehaviorServerHost , basicBehaviorServerPort, true);
assertTrue(doOneConstructorTest(socket4, socket4.getLocalPort()));
}
catch (Exception e)
{
log.error(e);
e.printStackTrace();
fail();
}
try
{
InetAddress inetAddress = InetAddress.getByName(basicBehaviorServerHost);
VirtualSocket socket5 = new VirtualSocket(inetAddress , basicBehaviorServerPort);
assertTrue(doOneConstructorTest(socket5, socket5.getLocalPort()));
}
catch (Exception e)
{
log.error(e);
e.printStackTrace();
fail();
}
try
{
InetAddress inetAddress = InetAddress.getByName(basicBehaviorServerHost);
VirtualSocket socket6 = new VirtualSocket(inetAddress , basicBehaviorServerPort, false);
fail();
}
catch (SocketException e)
{
assertTrue(e.getMessage().equals("Deprecated: use DataGramSocket instead of stream = false"));
}
catch (Exception e)
{
log.error(e);
e.printStackTrace();
fail();
}
try
{
InetAddress inetAddress = InetAddress.getByName(basicBehaviorServerHost);
VirtualSocket socket7 = new VirtualSocket(inetAddress , basicBehaviorServerPort, true);
assertTrue(doOneConstructorTest(socket7, socket7.getLocalPort()));
}
catch (Exception e)
{
log.error(e);
e.printStackTrace();
fail();
}
try
{
while (true)
{
try
{
int localPort = random.nextInt() & 0xffff;
InetAddress inetAddress = InetAddress.getByName("localhost");
VirtualSocket socket8 = new VirtualSocket(basicBehaviorServerHost, basicBehaviorServerPort, inetAddress , localPort);
assertTrue(doOneConstructorTest(socket8, localPort));
break;
}
catch (BindException e)
{
log.info("looking for a free socket");
}
}
}
catch (Exception e)
{
log.error(e);
e.printStackTrace();
fail();
}
try
{
while (true)
{
try
{
int localPort = random.nextInt() & 0xffff;
InetAddress remoteAddress = InetAddress.getByName(basicBehaviorServerHost);
InetAddress localAddress = InetAddress.getByName("localhost");
VirtualSocket socket9 = new VirtualSocket(remoteAddress, basicBehaviorServerPort, localAddress , localPort);
assertTrue(doOneConstructorTest(socket9, localPort));
break;
}
catch (BindException e)
{