title: Multiple Instances test using junit
body: <p>I have a java server on a server socket. Clients connect to this server socket, and exchange over input/output object streams. Now I need to test the app for scalability. Which means I need to run the same test making requests, and test if the server is able to handle requests from random clients.</p>
  
  <p>Is the below junit based test case the right way to test random connections/requests. I get a feeling that the below code is testing clients sequencially.</p>
  
  <p>Some links I read, and did not work for me </p>
  
  <p><a href="https://stackoverflow.com/questions/2227827/creating-a-junit-testsuite-with-multiple-instances-of-a-parameterized-test">Creating a JUnit testsuite with multiple instances of a Parameterized test</a></p>
  
  <pre><code>public class ScalePostiveTestCases {
  SendQueue sendQueue;
  Socket clientSocket = null;
  
  public static void main(String[] args) throws Throwable {       
      testSearching() ;
  }
  
  @SuppressWarnings("unchecked")
  private static void testSearching() throws ClassNotFoundException, InstantiationException, IllegalAccessException {
      TestSuite tests = new TestSuite();
      for (int i = 0; i &lt; 99; i++) {
          Class&lt;SingleSearchTest&gt; singleSearchTest = (Class&lt;SingleSearchTest&gt;) ClassLoader
                  .getSystemClassLoader().loadClass(
                          "SingleSearchTest");
  
          SingleSearchTest singleSearch = singleSearchTest.newInstance();
          tests.addTest(singleSearch);
      }
      TestRunner.run(tests);
  }
  public class SingleSearchTest extends TestCase {
      static SingleSearchTest singleSearch    = null;
      private String          device, connection, user;
      private ClientSession   clientSession;
      private SendQueue       sendQueue;
  
      public static SingleSearchTest main(String args[]) {
          singleSearch = new SingleSearchTest();
          return singleSearch;
      }
  
      public SingleSearchTest() {
         super("testSingleSearch");
         Random rand = new Random();
      }
  }
  </code></pre>