commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1808381 [25/25] - in /commons/proper/vfs/trunk/commons-vfs2/src: main/java/org/apache/commons/vfs2/ main/java/org/apache/commons/vfs2/auth/ main/java/org/apache/commons/vfs2/cache/ main/java/org/apache/commons/vfs2/events/ main/java/org/ap...
Date Thu, 14 Sep 2017 19:26:44 GMT
Modified: commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/UrlTests.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/UrlTests.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/UrlTests.java
(original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/UrlTests.java
Thu Sep 14 19:26:39 2017
@@ -28,38 +28,29 @@ import org.apache.commons.vfs2.FileSyste
 /**
  * URL test cases for providers.
  */
-public class UrlTests
-    extends AbstractProviderTestCase
-{
+public class UrlTests extends AbstractProviderTestCase {
     /**
-     * Returns the capabilities required by the tests of this test case.  The
-     * tests are not run if the provider being tested does not support all
-     * the required capabilities.  Return null or an empty array to always
-     * run the tests.
+     * Returns the capabilities required by the tests of this test case. The tests are not
run if the provider being
+     * tested does not support all the required capabilities. Return null or an empty array
to always run the tests.
      */
     @Override
-    protected Capability[] getRequiredCaps()
-    {
-        return new Capability[]{Capability.URI};
+    protected Capability[] getRequiredCaps() {
+        return new Capability[] { Capability.URI };
     }
 
     /**
      * Tests url.
      */
-    public void testURL() throws Exception
-    {
+    public void testURL() throws Exception {
         final FileObject file = getReadFolder().resolveFile("some-dir/");
         final URL url = file.getURL();
 
         assertEquals(file.getName().getURI(), url.toExternalForm());
 
         final URL parentURL;
-        try
-        {
+        try {
             parentURL = new URL(url, "..");
-        }
-        catch (final MalformedURLException e)
-        {
+        } catch (final MalformedURLException e) {
             throw e;
         }
         assertEquals(file.getParent().getURL(), parentURL);
@@ -71,8 +62,7 @@ public class UrlTests
     /**
      * Tests content.
      */
-    public void testURLContent() throws Exception
-    {
+    public void testURLContent() throws Exception {
         // Test non-empty file
         FileObject file = getReadFolder().resolveFile("file1.txt");
         assertTrue(file.exists());
@@ -91,8 +81,7 @@ public class UrlTests
     /**
      * Tests content.
      */
-    public void testURLContentProvider() throws Exception
-    {
+    public void testURLContentProvider() throws Exception {
         // Test non-empty file
         final FileObject file = getReadFolder().resolveFile("file1.txt");
         assertTrue(file.exists());
@@ -103,27 +92,24 @@ public class UrlTests
         final FileObject f1 = getManager().resolveFile(uri, options);
         final FileObject f2 = getManager().resolveFile(uri, options);
 
-        assertEquals("Two files resolved by URI must be equals on " + uri,  f1, f2);
-        assertSame("Resolving two times should not produce new filesystem on " + uri, f1.getFileSystem(),
f2.getFileSystem());
+        assertEquals("Two files resolved by URI must be equals on " + uri, f1, f2);
+        assertSame("Resolving two times should not produce new filesystem on " + uri, f1.getFileSystem(),
+                f2.getFileSystem());
     }
 
     /**
      * Tests that unknown files have no content.
      */
-    public void testUnknownURL() throws Exception
-    {
+    public void testUnknownURL() throws Exception {
         // Try getting the content of an unknown file
         final FileObject unknownFile = getReadFolder().resolveFile("unknown-file");
         assertFalse(unknownFile.exists());
 
         final URLConnection connection = unknownFile.getURL().openConnection();
-        try
-        {
+        try {
             connection.getInputStream();
             fail();
-        }
-        catch (final IOException e)
-        {
+        } catch (final IOException e) {
             assertSameMessage("vfs.provider/read-not-file.error", unknownFile, e);
         }
         assertEquals(-1, connection.getContentLength());

Modified: commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/VerifyingFileSelector.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/VerifyingFileSelector.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/VerifyingFileSelector.java
(original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/VerifyingFileSelector.java
Thu Sep 14 19:26:39 2017
@@ -31,13 +31,9 @@ import org.apache.commons.vfs2.util.File
 import org.junit.Assert;
 
 /**
- * A file selector that asserts that all files are visited, in the correct
- * order.
+ * A file selector that asserts that all files are visited, in the correct order.
  */
-public class VerifyingFileSelector
-    extends Assert
-    implements FileSelector
-{
+public class VerifyingFileSelector extends Assert implements FileSelector {
     private final FileInfo rootFile;
     private final List<FileObject> files = new ArrayList<>();
 
@@ -46,8 +42,7 @@ public class VerifyingFileSelector
     private Set<String> children;
     private final List<Set<String>> stack = new ArrayList<>();
 
-    public VerifyingFileSelector(final FileInfo fileInfo)
-    {
+    public VerifyingFileSelector(final FileInfo fileInfo) {
         this.rootFile = fileInfo;
         children = new HashSet<>();
         children.add(rootFile.baseName);
@@ -57,12 +52,9 @@ public class VerifyingFileSelector
      * Determines if a file or folder should be selected.
      */
     @Override
-    public boolean includeFile(final FileSelectInfo fileInfo)
-        throws FileSystemException
-    {
+    public boolean includeFile(final FileSelectInfo fileInfo) throws FileSystemException
{
         final FileObject file = fileInfo.getFile();
-        if (file == currentFolder)
-        {
+        if (file == currentFolder) {
             // Pop current folder
             assertEquals(0, children.size());
             currentFolder = currentFolder.getParent();
@@ -86,9 +78,7 @@ public class VerifyingFileSelector
      * Determines whether a folder should be traversed.
      */
     @Override
-    public boolean traverseDescendents(final FileSelectInfo fileInfo)
-        throws FileSystemException
-    {
+    public boolean traverseDescendents(final FileSelectInfo fileInfo) throws FileSystemException
{
         // Check that the given file is a folder
         final FileObject folder = FileObjectUtils.getAbstractFileObject(fileInfo.getFile());
         assertSame(FileType.FOLDER, folder.getType());
@@ -96,13 +86,10 @@ public class VerifyingFileSelector
 
         // Locate the info for the folder
         final String baseName = folder.getName().getBaseName();
-        if (currentFolder == null)
-        {
+        if (currentFolder == null) {
             assertEquals(rootFile.baseName, baseName);
             currentFolderInfo = rootFile;
-        }
-        else
-        {
+        } else {
             final AbstractFileObject parent = FileObjectUtils.getAbstractFileObject(folder.getParent());
             assertSame(currentFolder, parent);
 
@@ -122,10 +109,8 @@ public class VerifyingFileSelector
     /**
      * Finds a child of the current folder.
      */
-    private FileInfo getChild(final String baseName)
-    {
-        if (currentFolderInfo == null)
-        {
+    private FileInfo getChild(final String baseName) {
+        if (currentFolderInfo == null) {
             assertEquals(rootFile.baseName, baseName);
             return rootFile;
         }
@@ -139,8 +124,7 @@ public class VerifyingFileSelector
      *
      * @return The files in the order they where visited.
      */
-    public List<FileObject> finish()
-    {
+    public List<FileObject> finish() {
         assertEquals(0, children.size());
         return files;
     }

Modified: commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/util/DelegatingFileSystemOptionsBuilderTest.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/util/DelegatingFileSystemOptionsBuilderTest.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/util/DelegatingFileSystemOptionsBuilderTest.java
(original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/util/DelegatingFileSystemOptionsBuilderTest.java
Thu Sep 14 19:26:39 2017
@@ -37,37 +37,27 @@ import org.junit.Test;
 /**
  * Some tests for the DelegatingFileSystemOptionsBuilder
  */
-public class DelegatingFileSystemOptionsBuilderTest
-{
+public class DelegatingFileSystemOptionsBuilderTest {
     private StandardFileSystemManager fsm = null;
 
     @Before
-    public void setUp() throws Exception
-    {
+    public void setUp() throws Exception {
 
         // get a full blown, fully functional manager
         fsm = new StandardFileSystemManager();
         fsm.init();
     }
 
-
     @After
-    public void tearDown() throws Exception
-    {
-        if (fsm != null)
-        {
+    public void tearDown() throws Exception {
+        if (fsm != null) {
             fsm.close();
         }
     }
 
     @Test
-    public void testDelegatingGood() throws Throwable
-    {
-        final String[] identityPaths = new String[]
-        {
-            "/file1",
-            "/file2",
-        };
+    public void testDelegatingGood() throws Throwable {
+        final String[] identityPaths = new String[] { "/file1", "/file2", };
 
         final FileSystemOptions opts = new FileSystemOptions();
         final DelegatingFileSystemOptionsBuilder delgate = new DelegatingFileSystemOptionsBuilder(fsm);
@@ -79,57 +69,46 @@ public class DelegatingFileSystemOptions
 
         assertEquals("http.proxyHost", HttpFileSystemConfigBuilder.getInstance().getProxyHost(opts),
"proxy");
         assertEquals("http.proxyPort", HttpFileSystemConfigBuilder.getInstance().getProxyPort(opts),
8080);
-        assertEquals("sftp.userInfo", SftpFileSystemConfigBuilder.getInstance().getUserInfo(opts).getClass(),
TrustEveryoneUserInfo.class);
+        assertEquals("sftp.userInfo", SftpFileSystemConfigBuilder.getInstance().getUserInfo(opts).getClass(),
+                TrustEveryoneUserInfo.class);
 
         final File identities[] = SftpFileSystemConfigBuilder.getInstance().getIdentities(opts);
         assertNotNull("sftp.identities", identities);
         assertEquals("sftp.identities size", identities.length, identityPaths.length);
-        for (int iterIdentities = 0; iterIdentities < identities.length; iterIdentities++)
-        {
-            assertEquals("sftp.identities #" + iterIdentities,
-                identities[iterIdentities].getAbsolutePath(),
-                new File(identityPaths[iterIdentities]).getAbsolutePath());
+        for (int iterIdentities = 0; iterIdentities < identities.length; iterIdentities++)
{
+            assertEquals("sftp.identities #" + iterIdentities, identities[iterIdentities].getAbsolutePath(),
+                    new File(identityPaths[iterIdentities]).getAbsolutePath());
         }
     }
 
     @Test
-    public void testDelegatingBad() throws Throwable
-    {
+    public void testDelegatingBad() throws Throwable {
         final FileSystemOptions opts = new FileSystemOptions();
         final DelegatingFileSystemOptionsBuilder delgate = new DelegatingFileSystemOptionsBuilder(fsm);
 
-        try
-        {
+        try {
             delgate.setConfigString(opts, "http", "proxyPort", "wrong_port");
             fail();
-        }
-        catch (final FileSystemException e)
-        {
+        } catch (final FileSystemException e) {
             assertEquals(e.getCause().getClass(), InvocationTargetException.class);
-            assertEquals(((InvocationTargetException) e.getCause()).getTargetException().getClass(),
NumberFormatException.class);
+            assertEquals(((InvocationTargetException) e.getCause()).getTargetException().getClass(),
+                    NumberFormatException.class);
         }
 
-        try
-        {
+        try {
             delgate.setConfigClass(opts, "sftp", "userinfo", String.class);
             fail();
-        }
-        catch (final FileSystemException e)
-        {
+        } catch (final FileSystemException e) {
             assertEquals(e.getCode(), "vfs.provider/config-value-invalid.error");
         }
     }
 
-    private static String[] schemes = new String[]
-    {
-        "webdav", "http", "ftp", "file", "zip", "tar", "tgz", "bz2", "gz", "jar", "tmp",
"ram"
-    };
+    private static String[] schemes = new String[] { "webdav", "http", "ftp", "file", "zip",
"tar", "tgz", "bz2", "gz",
+            "jar", "tmp", "ram" };
 
     @Test
-    public void testConfiguration() throws Exception
-    {
-        for (final String scheme : schemes)
-        {
+    public void testConfiguration() throws Exception {
+        for (final String scheme : schemes) {
             assertTrue("Missing " + scheme + " provider", fsm.hasProvider(scheme));
         }
     }

Modified: commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/util/EncryptDecryptTest.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/util/EncryptDecryptTest.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/util/EncryptDecryptTest.java
(original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/util/EncryptDecryptTest.java
Thu Sep 14 19:26:39 2017
@@ -22,12 +22,10 @@ import org.junit.Test;
 
 /**
  */
-public class EncryptDecryptTest
-{
+public class EncryptDecryptTest {
 
     @Test
-    public void testEncryptDecrypt() throws Exception
-    {
+    public void testEncryptDecrypt() throws Exception {
         final String source = "Qryp2!t&tpR59";
         final String expected = "914589F049CE3E8E3BB1A41BEAE12A9C";
 

Modified: commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/util/NHttpServer.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/util/NHttpServer.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/util/NHttpServer.java
(original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/util/NHttpServer.java
Thu Sep 14 19:26:39 2017
@@ -105,52 +105,45 @@ import org.apache.http.protocol.Response
  * @version $Id$
  * @since 2.1
  */
-public class NHttpServer
-{
+public class NHttpServer {
 
-    static class HttpFileHandler implements HttpAsyncRequestHandler<HttpRequest>
-    {
+    static class HttpFileHandler implements HttpAsyncRequestHandler<HttpRequest> {
 
         private final File docRoot;
 
-        public HttpFileHandler(final File docRoot)
-        {
+        public HttpFileHandler(final File docRoot) {
             super();
             this.docRoot = docRoot;
         }
 
         @Override
         public void handle(final HttpRequest request, final HttpAsyncExchange httpexchange,
final HttpContext context)
-                throws HttpException, IOException
-        {
+                throws HttpException, IOException {
             final HttpResponse response = httpexchange.getResponse();
             this.handleInternal(request, response, context);
             httpexchange.submitResponse(new BasicAsyncResponseProducer(response));
         }
 
         private void handleInternal(final HttpRequest request, final HttpResponse response,
final HttpContext context)
-                throws HttpException, IOException
-        {
+                throws HttpException, IOException {
 
             final String method = request.getRequestLine().getMethod().toUpperCase(Locale.ENGLISH);
-            if (!method.equals("GET") && !method.equals("HEAD") && !method.equals("POST"))
-            {
+            if (!method.equals("GET") && !method.equals("HEAD") && !method.equals("POST"))
{
                 throw new MethodNotSupportedException(method + " method not supported");
             }
 
             final String target = request.getRequestLine().getUri();
             final File file = new File(this.docRoot, URLDecoder.decode(target, "UTF-8"));
-            if (!file.exists())
-            {
+            if (!file.exists()) {
 
                 response.setStatusCode(HttpStatus.SC_NOT_FOUND);
-                final NStringEntity entity = new NStringEntity("<html><body><h1>File"
+ file.getPath()
-                        + " not found</h1></body></html>", ContentType.create("text/html",
"UTF-8"));
+                final NStringEntity entity = new NStringEntity(
+                        "<html><body><h1>File" + file.getPath() + " not
found</h1></body></html>",
+                        ContentType.create("text/html", "UTF-8"));
                 response.setEntity(entity);
                 NHttpServer.debug("File " + file.getPath() + " not found");
 
-            } else if (!file.canRead())
-            {
+            } else if (!file.canRead()) {
 
                 response.setStatusCode(HttpStatus.SC_FORBIDDEN);
                 final NStringEntity entity = new NStringEntity("<html><body><h1>Access
denied</h1></body></html>",
@@ -158,14 +151,12 @@ public class NHttpServer
                 response.setEntity(entity);
                 NHttpServer.debug("Cannot read file " + file.getPath());
 
-            } else
-            {
+            } else {
                 final NHttpConnection conn = (NHttpConnection) context.getAttribute(ExecutionContext.HTTP_CONNECTION);
                 response.setStatusCode(HttpStatus.SC_OK);
                 final NFileEntity body = new NFileEntity(file, ContentType.create("text/html"));
                 response.setEntity(body);
-                if (!response.containsHeader(HttpHeaders.LAST_MODIFIED))
-                {
+                if (!response.containsHeader(HttpHeaders.LAST_MODIFIED)) {
                     response.addHeader(HttpHeaders.LAST_MODIFIED, DateUtil.formatDate(new
Date(file.lastModified())));
                 }
                 NHttpServer.debug(conn + ": serving file " + file.getPath());
@@ -173,8 +164,8 @@ public class NHttpServer
         }
 
         @Override
-        public HttpAsyncRequestConsumer<HttpRequest> processRequest(final HttpRequest
request, final HttpContext context)
-        {
+        public HttpAsyncRequestConsumer<HttpRequest> processRequest(final HttpRequest
request,
+                final HttpContext context) {
             // Buffer request content in memory for simplicity
             return new BasicAsyncRequestConsumer();
         }
@@ -183,52 +174,38 @@ public class NHttpServer
 
     static final boolean Debug = false;
 
-    private static void debug(final String s)
-    {
-        if (Debug)
-        {
+    private static void debug(final String s) {
+        if (Debug) {
             System.out.println(s);
         }
     }
 
-    public static void main(final String[] args) throws Exception
-    {
+    public static void main(final String[] args) throws Exception {
         new NHttpServer().run(Integer.valueOf(args[0]), new File(args[1]), 0);
     }
 
     volatile ListeningIOReactor ioReactor;
 
-    public boolean run(final int port, final File docRoot, final long waitMillis) throws
IOReactorException,
-            InterruptedException
-    {
-        Executors.newSingleThreadExecutor().execute(new Runnable()
-        {
+    public boolean run(final int port, final File docRoot, final long waitMillis)
+            throws IOReactorException, InterruptedException {
+        Executors.newSingleThreadExecutor().execute(new Runnable() {
             @Override
-            public void run()
-            {
-                try
-                {
+            public void run() {
+                try {
                     NHttpServer.this.runBlock(port, docRoot);
-                } catch (final IOReactorException e)
-                {
+                } catch (final IOReactorException e) {
                     throw new IllegalStateException(e);
-                } catch (final UnrecoverableKeyException e)
-                {
+                } catch (final UnrecoverableKeyException e) {
                     throw new IllegalStateException(e);
-                } catch (final KeyStoreException e)
-                {
+                } catch (final KeyStoreException e) {
                     throw new IllegalStateException(e);
-                } catch (final NoSuchAlgorithmException e)
-                {
+                } catch (final NoSuchAlgorithmException e) {
                     throw new IllegalStateException(e);
-                } catch (final CertificateException e)
-                {
+                } catch (final CertificateException e) {
                     throw new IllegalStateException(e);
-                } catch (final IOException e)
-                {
+                } catch (final IOException e) {
                     throw new IllegalStateException(e);
-                } catch (final KeyManagementException e)
-                {
+                } catch (final KeyManagementException e) {
                     throw new IllegalStateException(e);
                 }
             }
@@ -237,10 +214,8 @@ public class NHttpServer
     }
 
     public void runBlock(final int port, final File docRoot) throws KeyStoreException, NoSuchAlgorithmException,
-            CertificateException, IOException, UnrecoverableKeyException, KeyManagementException
-    {
-        if (docRoot == null)
-        {
+            CertificateException, IOException, UnrecoverableKeyException, KeyManagementException
{
+        if (docRoot == null) {
             throw new IllegalArgumentException("No doc root specified.");
         }
         // HTTP parameters for the server
@@ -250,32 +225,25 @@ public class NHttpServer
                 .setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true)
                 .setParameter(CoreProtocolPNames.ORIGIN_SERVER, "HttpTest/1.1");
         // Create HTTP protocol processing chain
-        final HttpProcessor httpproc = new ImmutableHttpProcessor(new HttpResponseInterceptor[]
-        {
+        final HttpProcessor httpproc = new ImmutableHttpProcessor(new HttpResponseInterceptor[]
{
                 // Use standard server-side protocol interceptors
-                new ResponseDate(),
-                new ResponseServer(),
-                new ResponseContent(),
-                new ResponseConnControl() });
+                new ResponseDate(), new ResponseServer(), new ResponseContent(), new ResponseConnControl()
});
         // Create request handler registry
         final HttpAsyncRequestHandlerRegistry reqistry = new HttpAsyncRequestHandlerRegistry();
         // Register the default handler for all URIs
         reqistry.register("*", new HttpFileHandler(docRoot));
         // Create server-side HTTP protocol handler
         final HttpAsyncService protocolHandler = new HttpAsyncService(httpproc, new DefaultConnectionReuseStrategy(),
-                reqistry, params)
-        {
+                reqistry, params) {
 
             @Override
-            public void closed(final NHttpServerConnection conn)
-            {
+            public void closed(final NHttpServerConnection conn) {
                 NHttpServer.debug(conn + ": connection closed");
                 super.closed(conn);
             }
 
             @Override
-            public void connected(final NHttpServerConnection conn)
-            {
+            public void connected(final NHttpServerConnection conn) {
                 NHttpServer.debug(conn + ": connection open");
                 super.connected(conn);
             }
@@ -283,13 +251,11 @@ public class NHttpServer
         };
         // Create HTTP connection factory
         NHttpConnectionFactory<DefaultNHttpServerConnection> connFactory;
-        if (port == 8443)
-        {
+        if (port == 8443) {
             // Initialize SSL context
             final ClassLoader cl = NHttpServer.class.getClassLoader();
             final URL url = cl.getResource("my.keystore");
-            if (url == null)
-            {
+            if (url == null) {
                 NHttpServer.debug("Keystore not found");
                 System.exit(1);
             }
@@ -301,66 +267,53 @@ public class NHttpServer
             final SSLContext sslcontext = SSLContext.getInstance("TLS");
             sslcontext.init(keymanagers, null, null);
             connFactory = new SSLNHttpServerConnectionFactory(sslcontext, null, params);
-        } else
-        {
+        } else {
             connFactory = new DefaultNHttpServerConnectionFactory(params);
         }
         // Create server-side I/O event dispatch
         final IOEventDispatch ioEventDispatch = new DefaultHttpServerIODispatch(protocolHandler,
connFactory);
         // Create server-side I/O reactor
         this.ioReactor = new DefaultListeningIOReactor();
-        try
-        {
+        try {
             // Listen of the given port
             this.ioReactor.listen(new InetSocketAddress(port));
             // Ready to go!
             this.ioReactor.execute(ioEventDispatch);
-        } catch (final InterruptedIOException ex)
-        {
+        } catch (final InterruptedIOException ex) {
             System.err.println("Interrupted");
-        } catch (final IOException e)
-        {
+        } catch (final IOException e) {
             System.err.println("I/O error: " + e.getMessage());
         }
         NHttpServer.debug("Shutdown");
     }
 
-    public void stop() throws IOException
-    {
-        if (this.ioReactor != null)
-        {
+    public void stop() throws IOException {
+        if (this.ioReactor != null) {
             this.ioReactor.shutdown(2000);
         }
     }
 
-    private boolean waitForServerStartup(final int port, final long waitMillis) throws InterruptedException
-    {
+    private boolean waitForServerStartup(final int port, final long waitMillis) throws InterruptedException
{
         final long endWait = System.currentTimeMillis() + waitMillis;
         final String urlSpec = "http://localhost:" + port;
-        try
-        {
+        try {
             final URL url = new URL(urlSpec);
             InputStream inputStream = null;
-            while (System.currentTimeMillis() < endWait && inputStream == null)
-            {
-                try
-                {
+            while (System.currentTimeMillis() < endWait && inputStream == null)
{
+                try {
                     inputStream = url.openStream();
-                    if (inputStream != null)
-                    {
+                    if (inputStream != null) {
                         IOUtils.closeQuietly(inputStream);
                         return true;
                     }
-                } catch (final IOException e)
-                {
+                } catch (final IOException e) {
                     // ignore
                     // debug("While waiting: " + e);
                     // e.printStackTrace();
                 }
                 Thread.sleep(100);
             }
-        } catch (final MalformedURLException e)
-        {
+        } catch (final MalformedURLException e) {
             throw new IllegalStateException("Error in test code for URL " + urlSpec);
         }
         return false;



Mime
View raw message