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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:22:54+00:00 2026-05-27T08:22:54+00:00

I have some code in a test as follows: @Test public void testRetrieveMongoDBFailUnkownHost() {

  • 0

I have some code in a test as follows:

    @Test
public void testRetrieveMongoDBFailUnkownHost()
{   
    //Set up test port and host on DSMongo
    MyMongo mongoTest = new MyMongo();
    mongoTest.setHost("failure");
    mongoTest.setPort("0");

    //attempt to make the connection
    try
    {
        mongoTest.attemptMongoConnection();
        assertTrue(false);
    }
    catch (Exception e) 
    {
        assertEquals("Incorrect error message received: " + e.getMessage(),"Error (3013) : Unknown database host.", e.getMessage());
    }

}

And the attempt MongoConnection() method runs the new Mongo(host, port) method which should fail with an unknown host exception. It isn’t failing on my machine (no matter what string I put in instead of failure) but it is failing on my colleagues machine. So the test fails on my machine and passes on his (i.e. he gets the exception). Any ideas cause I am stumped!

Thanks

Paul

EDIT: The code in the attempt Connection Method is

 */
public static void attemptMongoConnection() throws MYException 
{
    try {           
        singleMongo = new Mongo(getHost(), getPort());
        Logger.debug("Retrieved Mongo database from " + host);
    } catch (UnknownHostException e) {
        Logger.error("Unknown Host Exception", e);
        throw new MYException(MYMessage.MY_UNKNOWN_HOST);
    } catch (MongoException e) {
        Logger.error("Mongo error", e);
        throw new MYException(MYMessage.DS_MONGO_ERROR);
    }
}

where singleMOngo is a Mongo variable and the getHost and getPort are the ones we have set (.e. failure and 0).

  • 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-27T08:22:55+00:00Added an answer on May 27, 2026 at 8:22 am

    I have found this was a problem with the DNS somewhere. When I ran it at home (from where I originally made the post) it failed and seems to hav been resolving the name of “failure” so when I instead entered something like “localhost_123” it works perfectly.

    I have come into the office this morning and it works with “failure” again. Doing some further digging it seems therefore that my router or something at home is resolving “failure” to an address it is aware of which is not present on the network here in the office.

    Thanks for all those who looked at this. Very bizarre.

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

Sidebar

Related Questions

I have some code which gets resources as follows: public static final String CONVERTER_FILE
I have some code that attempts to test whether my application is running with
I have some code in my error handler I need to test against a
Does anyone have some good hints for writing test code for database-backend development where
I have some basic PHP code: $raceramps56[short] = My Test Product; $leftMenu = '<div
This is a minimal test case of some code that I actually have. It
I have written a C DLL and some C# code to test including this
I have some code for starting a thread on the .NET CF 2.0: ThreadStart
I have some code like this in a winforms app I was writing to
I have some code which collects points (consed integers) from a loop which looks

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.