I'm in the process of writing two Junit testcases for testing the timemouts

```
@Test
    public void connectionTimeoutTest()
    {
        String myurl = "http://serverip:serverport/context";
        URL url = new URL(myurl);
        URLConnection con = url.openConnection();

        //how to check connectionTimeout but not socket time out

        //what I think
        //is it good enough to check with a server ip that does not exist ?
    }

    @Test
    public void socketTimeoutTest()
    {
        String myurl = "http://localhost:serverport/context";
        URL url = new URL(myurl);
        URLConnection con = url.openConnection();

        //how to check successful connection and timesout at socket (or port)

        //what I think
        //IP should exist (so it is localhost) but should not be listening on the port
    }

```

I'm confused here because I'm not sure if my approach is right. What are the exceptions in each case ? Also, is it possible to differentiate based on Exceptions ?

Are there any other time outs that I have missed ?

Thanks in advance