assertTrue( true );
}
// real proxy
ProxyServer proxyServer = null;
AuthAsyncProxyServlet proxyServlet = null;
try
{
proxyServlet = new AuthAsyncProxyServlet();
proxyServer = new ProxyServer( proxyServlet );
proxyServer.start();
settings = new Settings();
assertTrue( JavadocUtil.isValidPackageList( url, settings, true ) );
try
{
JavadocUtil.isValidPackageList( wrongUrl, settings, false );
fail();
}
catch ( IOException e )
{
assertTrue( true );
}
}
finally
{
if ( proxyServer != null )
{
proxyServer.stop();
}
}
Map<String, String> authentications = new HashMap<String, String>();
authentications.put( "foo", "bar" );
// wrong auth
try
{
proxyServlet = new AuthAsyncProxyServlet( authentications );
proxyServer = new ProxyServer( proxyServlet );
proxyServer.start();
settings = new Settings();
proxy = new Proxy();
proxy.setActive( true );
proxy.setHost( proxyServer.getHostName() );
proxy.setPort( proxyServer.getPort() );
proxy.setProtocol( "http" );
settings.addProxy( proxy );
JavadocUtil.isValidPackageList( url, settings, false );
fail();
}
catch ( FileNotFoundException e )
{
assertTrue( true );
}
finally
{
if ( proxyServer != null )
{
proxyServer.stop();
}
}
// auth proxy
try
{
proxyServlet = new AuthAsyncProxyServlet( authentications );
proxyServer = new ProxyServer( proxyServlet );
proxyServer.start();
settings = new Settings();
proxy = new Proxy();
proxy.setActive( true );
proxy.setHost( proxyServer.getHostName() );
proxy.setPort( proxyServer.getPort() );
proxy.setProtocol( "http" );
proxy.setUsername( "foo" );
proxy.setPassword( "bar" );
settings.addProxy( proxy );
assertTrue( JavadocUtil.isValidPackageList( url, settings, true ) );
try
{
JavadocUtil.isValidPackageList( wrongUrl, settings, false );
fail();
}
catch ( IOException e )
{
assertTrue( true );
}
}
finally
{
if ( proxyServer != null )
{
proxyServer.stop();
}
}
// timeout
try
{
proxyServlet = new AuthAsyncProxyServlet( authentications, 3000 ); // more than 2000, see fetchURL
proxyServer = new ProxyServer( proxyServlet );
proxyServer.start();
settings = new Settings();
proxy = new Proxy();
proxy.setActive( true );
proxy.setHost( proxyServer.getHostName() );
proxy.setPort( proxyServer.getPort() );
proxy.setProtocol( "http" );
proxy.setUsername( "foo" );
proxy.setPassword( "bar" );
settings.addProxy( proxy );
JavadocUtil.isValidPackageList( url, settings, true );
fail();
}
catch ( SocketTimeoutException e )
{
assertTrue( true );
}
finally
{
if ( proxyServer != null )
{
proxyServer.stop();
}
}
// nonProxyHosts
try
{
proxyServlet = new AuthAsyncProxyServlet( authentications );
proxyServer = new ProxyServer( proxyServlet );
proxyServer.start();
settings = new Settings();
proxy = new Proxy();