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 1024845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:50:19+00:00 2026-05-16T11:50:19+00:00

Imagine two servers (each within an own jvm process) which communicate using some form

  • 0

Imagine two servers (each within an own jvm process) which communicate using some form of messages (e.g. simple producer/consumer)

I’d like to write unit tests that will test the behaviour of these two servers.
My questions are:

  1. Are there some frameworks (or a junit addon) for this problem?
    I’d like to run a junit test class (or even a single test) in a different process?
    It would be cool if one unit test can easily access the variables of the other test (in a different process) using some sort of inter-process communication.
    E.g. I’d like to check if the producer really produced the things i expected, and afterwards, if the consumer consumed them. (and maybe do some fuzzing to detect some race-condition-related problems)

  2. Are there some best practice for this kind of testing?

  3. If there isn’t a unit-like testing approach, how would you test such things during continous integration?

Note:
I don’t want to use threads, because this may alter the behaviour (if you think of thread-safety issues)

  • 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-16T11:50:19+00:00Added an answer on May 16, 2026 at 11:50 am

    I would describe what you are looking to do as an integration test, and beyond the scope of JUnit as a framework (JUnit is only now dipping its toe into multi-thread testing, multi-process is certainly not in the feature set).

    You could of course use JUnit to run such tests, but they would really be limited to a runner, the rest you have to do yourself.

    Others have already pointed to the fact that you would usually mock or otherwise send artificially constructed methods to the consumer, and test what the producer produces independently at the “unit test” level.

    In terms of actually testing the interaction between the producer and the consumer, one approach is to forget about the inter-process testing, and test it intra-process on one thread via some sort of Dependency Injection where the producer sends the message via some fake way that just passes it on the the consumer without anything more under the hood than in-thread method calls.

    However, it seems that you want to test things that can happen with the actual inter-process stuff on top of it (race conditions and the like), which makes this all-the-more an integration test.

    To approach this problem, you need to start the process and wait for it to accept a message, then your test would tell the producer what message to create and it would send it to the consumer. Then your test would ask the consumer what it got (with suitable delay).

    The need here would have to be compelling for me to do it. I would go for full blown automated acceptance testing and let that encompass this level of integration.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Imagine two simple java applications. Both of them are implementing the same JAR file
Imagine that I have a form in a flash application with two fields, input1
Let's imagine really simple game... We have a labirinth and two players trying to
We have two machines which need to communicate: a Linux based gateway, and a
The Situation: Imagine two servers A and B. Server B just outputs a PDF
I am writing a simple server (publisher) and client (subscriber) application to imagine inter-process
I imagine two, but I would like to confirm if I am making sense
Imagine you have two views with code like the following: controller_a/a.html.erb <%= content_tag(:div) do
Imagine you have two images A and B, and a third grayscale image T.
Imagine we have two tables in the database, user (FK id_role) and role (PK

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.