/*
 * Copyright (c) 2017 Stephan D. Cote' - All rights reserved.
 * 
 * This program and the accompanying materials are made available under the 
 * terms of the MIT License which accompanies this distribution, and is 
 * available at http://creativecommons.org/licenses/MIT/
 *
 * Contributors:
 *   Stephan D. Cote 
 *      - Initial concept and initial implementation
 */
package coyote.commons.network.http;

//import static org.junit.Assert.*;
import static org.junit.Assert.assertNotNull;

import java.io.IOException;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;


/**
 * 
 */
public class TestHttpd {

  private static HTTPD server = null;




  /**
   * @throws java.lang.Exception
   */
  @BeforeClass
  public static void setUpBeforeClass() throws Exception {

    server = new TestingServer( 62300 );

    try {
      server.start( HTTPD.SOCKET_READ_TIMEOUT, true );
    } catch ( IOException ioe ) {
      System.err.println( "Couldn't start server:\n" + ioe );
      server.stop();
      server = null;
    }

  }




  /**
   * @throws java.lang.Exception
   */
  @AfterClass
  public static void tearDownAfterClass() throws Exception {
    server.stop();
  }




  @Test
  public void test() {
    assertNotNull( server );
  }

}

@@ -473,29 +473,17 @@
 .Assert.
-assertNotNull
+*
 ;%0A%0Aimpor
@@ -589,16 +589,48 @@
 .Test;%0A%0A
+import coyote.commons.NetUtil;%0A%0A
 %0A/**%0A * 
@@ -698,16 +698,51 @@
 = null;%0A
+  private static int port = 54321;%0A
 %0A%0A%0A%0A  /*
@@ -857,16 +857,65 @@
 tion %7B%0A%0A
+    port = NetUtil.getNextAvailablePort( port );%0A
     serv
@@ -942,13 +942,12 @@
 er( 
-62300
+port
  );%0A
@@ -1339,24 +1339,24 @@
 id test() %7B%0A
-
     assertNo
@@ -1372,15 +1372,59 @@
 rver );%0A
+    assertTrue( port == server.getPort() );%0A
   %7D%0A%0A%7D%0A

Use NetUtil.getNextAvailablePort to get a testing port