mardi 19 mars 2019

Need Junit Test for ServerSocket in java

I know asking for basic things is not that good but I really need help on this;

I need to write the Junit Test for following method can anybody help me out please;

private ServerSocket createServerSocket() throws IOException
{
    if (socketFactory == null)
    {
        if (factoryName == null)
        {
            socketFactory = new PlainAdaptorServerSocketFactory();
            return socketFactory.createServerSocket(port, 50, host);
        }
        else
        {
            try
            {
                return (ServerSocket)server.invoke(factoryName, "createServerSocket", new Object[]{ Integer.valueOf(port), Integer.valueOf(50), host}, new String[]{"int", "int", "java.lang.String"});
            }
            catch (Exception x)
            {
                Logger log = getLogger();
                log.error("Exception invoking AdaptorServerSocketFactory via MBeanServer", x);
            }
        }
    }
    else
    {
        return socketFactory.createServerSocket(port, 50, host);
    }

    return null;
}

Aucun commentaire:

Enregistrer un commentaire