Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6951747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:15:34+00:00 2026-05-27T14:15:34+00:00

I have a java server on a server socket. Clients connect to this server

  • 0

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.

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.

Some links I read, and did not work for me

Creating a JUnit testsuite with multiple instances of a Parameterized test

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 < 99; i++) {
        Class<SingleSearchTest> singleSearchTest = (Class<SingleSearchTest>) 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();
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T14:15:35+00:00Added an answer on May 27, 2026 at 2:15 pm

    You are creating many test which have one client each.

    What you need to do is have one plain test which creates many clients which are executed concurrently.


    In my unit tests;

    • start the server as a separate thread (so I can also shut it down)
    • use an ExecutorService as a Thread pool for the clients
    • have a loop to create all the tasks which each create a client and exercise them. When finished return from the task.
    • shutdown the ExecutorService.
    • go through all the tasks and check they passed. If they threw and error, the error will be thrown in the current (testing) thread.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a java socket server that sends an Animal object to the Flash
I have a Java server. Clients connect to server via TCP. Here is the
Essentially I have built a socket server that multiple clients can connect to and
Hey all. I have a server written in java using the ServerSocket and Socket
I have a java server listening on a Socket. I can send and receive
I have a java-based server that allows client applications to connect via other programming
Java Socket Server I have a Java process that is creating a listener on
Are there any examples(ready scripts) to connect to java server with socket.io library? My
I have a Java based web-application using Java Server Faces and Facelets. I am
I have created a java server, which takes screenshots, resizes them, and sends them

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.