openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1766223 - in /openwebbeans/microwave/trunk: microwave-arquillian/src/main/java/org/apache/microwave/arquillian/ microwave-arquillian/src/test/java/org/apache/microwave/arquillian/ microwave-core/ microwave-core/src/main/java/org/apache/mic...
Date Sat, 22 Oct 2016 19:05:56 GMT
Author: rmannibucau
Date: Sat Oct 22 19:05:56 2016
New Revision: 1766223

URL: http://svn.apache.org/viewvc?rev=1766223&view=rev
Log:
removing comons-io

Added:
    openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/io/
    openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/io/IO.java
Modified:
    openwebbeans/microwave/trunk/microwave-arquillian/src/main/java/org/apache/microwave/arquillian/MicrowaveContainer.java
    openwebbeans/microwave/trunk/microwave-arquillian/src/test/java/org/apache/microwave/arquillian/MicrowaveContainerTest.java
    openwebbeans/microwave/trunk/microwave-core/pom.xml
    openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/Microwave.java
    openwebbeans/microwave/trunk/microwave-core/src/test/java/org/apache/microwave/MicrowaveTest.java
    openwebbeans/microwave/trunk/microwave-core/src/test/java/org/apache/microwave/runner/CliTest.java
    openwebbeans/microwave/trunk/microwave-junit/src/test/java/org/apache/microwave/junit/MicrowaveRuleTest.java
    openwebbeans/microwave/trunk/microwave-junit/src/test/java/org/apache/microwave/junit/MonoMicrowaveRuleTest.java

Modified: openwebbeans/microwave/trunk/microwave-arquillian/src/main/java/org/apache/microwave/arquillian/MicrowaveContainer.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-arquillian/src/main/java/org/apache/microwave/arquillian/MicrowaveContainer.java?rev=1766223&r1=1766222&r2=1766223&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-arquillian/src/main/java/org/apache/microwave/arquillian/MicrowaveContainer.java
(original)
+++ openwebbeans/microwave/trunk/microwave-arquillian/src/main/java/org/apache/microwave/arquillian/MicrowaveContainer.java
Sat Oct 22 19:05:56 2016
@@ -18,8 +18,8 @@
  */
 package org.apache.microwave.arquillian;
 
-import org.apache.commons.io.FileUtils;
 import org.apache.microwave.Microwave;
+import org.apache.microwave.io.IO;
 import org.jboss.arquillian.container.spi.client.container.DeployableContainer;
 import org.jboss.arquillian.container.spi.client.container.DeploymentException;
 import org.jboss.arquillian.container.spi.client.container.LifecycleException;
@@ -32,7 +32,6 @@ import org.jboss.shrinkwrap.api.exporter
 import org.jboss.shrinkwrap.descriptor.api.Descriptor;
 
 import java.io.File;
-import java.io.IOException;
 
 import static java.util.Optional.ofNullable;
 
@@ -83,24 +82,11 @@ public class MicrowaveContainer implemen
         this.container.undeploy(sanitizeName(archive));
         final File dump = toArchiveDump(archive);
         if (dump.isFile()) {
-            FileUtils.deleteQuietly(dump);
+            IO.delete(dump);
         }
         final File unpacked = new File(dump.getParentFile(), dump.getName().replace(".war",
""));
         if (unpacked.isDirectory()) {
-            try {
-                FileUtils.deleteDirectory(unpacked);
-            } catch (final IOException e) {
-                Runtime.getRuntime().addShutdownHook(new Thread() {
-                    @Override
-                    public void run() {
-                        try {
-                            FileUtils.deleteDirectory(unpacked);
-                        } catch (final IOException e1) {
-                            throw new IllegalStateException(e1);
-                        }
-                    }
-                });
-            }
+            IO.delete(unpacked);
         }
     }
 

Modified: openwebbeans/microwave/trunk/microwave-arquillian/src/test/java/org/apache/microwave/arquillian/MicrowaveContainerTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-arquillian/src/test/java/org/apache/microwave/arquillian/MicrowaveContainerTest.java?rev=1766223&r1=1766222&r2=1766223&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-arquillian/src/test/java/org/apache/microwave/arquillian/MicrowaveContainerTest.java
(original)
+++ openwebbeans/microwave/trunk/microwave-arquillian/src/test/java/org/apache/microwave/arquillian/MicrowaveContainerTest.java
Sat Oct 22 19:05:56 2016
@@ -18,7 +18,7 @@
  */
 package org.apache.microwave.arquillian;
 
-import org.apache.commons.io.IOUtils;
+import org.apache.microwave.io.IO;
 import org.app.Endpoint;
 import org.jboss.arquillian.container.test.api.Deployment;
 import org.jboss.arquillian.junit.Arquillian;
@@ -30,9 +30,11 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 
 import java.io.IOException;
+import java.io.InputStream;
 import java.net.URL;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
 
 @RunWith(Arquillian.class)
 public class MicrowaveContainerTest {
@@ -47,6 +49,15 @@ public class MicrowaveContainerTest {
 
     @Test
     public void run() throws IOException {
-        assertEquals("simple", IOUtils.toString(new URL(base.toExternalForm() + "api/test")));
+        assertEquals("simple", slurp(new URL(base.toExternalForm() + "api/test")));
+    }
+
+    private String slurp(final URL url) {
+        try (final InputStream is = url.openStream()) {
+            return IO.toString(is);
+        } catch (final IOException e) {
+            fail(e.getMessage());
+        }
+        return null;
     }
 }

Modified: openwebbeans/microwave/trunk/microwave-core/pom.xml
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-core/pom.xml?rev=1766223&r1=1766222&r2=1766223&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-core/pom.xml (original)
+++ openwebbeans/microwave/trunk/microwave-core/pom.xml Sat Oct 22 19:05:56 2016
@@ -87,12 +87,7 @@
     <dependency>
       <groupId>org.apache.commons</groupId>
       <artifactId>commons-lang3</artifactId>
-      <version>3.4</version>
-    </dependency>
-    <dependency>
-      <groupId>commons-io</groupId>
-      <artifactId>commons-io</artifactId>
-      <version>2.4</version>
+      <version>3.5</version>
     </dependency>
     <dependency>
       <groupId>org.apache.xbean</groupId>
@@ -217,9 +212,10 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-shade-plugin</artifactId>
-        <version>2.3</version>
+        <version>2.4.3</version>
         <executions>
           <execution>
+            <id>bundle</id>
             <phase>package</phase>
             <goals>
               <goal>shade</goal>
@@ -227,7 +223,7 @@
             <configuration>
               <shadedClassifierName>runner</shadedClassifierName>
               <shadedArtifactAttached>true</shadedArtifactAttached>
-              <dependencyReducedPomLocation>${project.build.directory}/reduced-pom.xml</dependencyReducedPomLocation>
+              <dependencyReducedPomLocation>${project.build.directory}/reduced-pom-bundle.xml</dependencyReducedPomLocation>
               <transformers>
                 <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                   <mainClass>org.apache.microwave.runner.Cli</mainClass>
@@ -248,6 +244,12 @@
                   </excludes>
                 </filter>
               </filters>
+              <relocations>
+                <relocation>
+                  <pattern>org.apache.commons</pattern>
+                  <shadedPattern>org.apache.microwave.shaded.commons</shadedPattern>
+                </relocation>
+              </relocations>
             </configuration>
           </execution>
         </executions>

Modified: openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/Microwave.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/Microwave.java?rev=1766223&r1=1766222&r2=1766223&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/Microwave.java
(original)
+++ openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/Microwave.java
Sat Oct 22 19:05:56 2016
@@ -36,12 +36,11 @@ import org.apache.catalina.session.Stand
 import org.apache.catalina.startup.Catalina;
 import org.apache.catalina.startup.MicrowaveContextConfig;
 import org.apache.catalina.startup.Tomcat;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.text.StrLookup;
 import org.apache.commons.lang3.text.StrSubstitutor;
 import org.apache.coyote.http2.Http2Protocol;
 import org.apache.microwave.cxf.CxfCdiAutoSetup;
+import org.apache.microwave.io.IO;
 import org.apache.microwave.logging.jul.Log4j2Logger;
 import org.apache.microwave.logging.openwebbeans.Log4j2LoggerFactory;
 import org.apache.microwave.logging.tomcat.Log4j2Log;
@@ -157,11 +156,7 @@ public class Microwave implements AutoCl
 
         final File dir = ofNullable(meta.docBase).orElseGet(() -> {
             final File d = new File(configuration.tempDir, "classpath/fake-" + meta.context.replace("/",
""));
-            try {
-                FileUtils.forceMkdir(d);
-            } catch (final IOException e) {
-                throw new IllegalArgumentException(e);
-            }
+            IO.mkdirs(d);
             return d;
         });
 
@@ -217,11 +212,7 @@ public class Microwave implements AutoCl
                 tomcat.getHost().removeChild(ctx);
             } finally {
                 if (dir != meta.docBase) {
-                    try {
-                        FileUtils.deleteDirectory(dir);
-                    } catch (final IOException e) {
-                        // no-op
-                    }
+                    IO.delete(dir);
                 }
             }
 
@@ -313,7 +304,7 @@ public class Microwave implements AutoCl
             if (!file.equals(configuration.serverXml)) {
                 try (final InputStream is = new FileInputStream(configuration.serverXml);
                      final FileOutputStream fos = new FileOutputStream(file)) {
-                    IOUtils.copy(is, fos);
+                    IO.copy(is, fos);
                 } catch (final IOException e) {
                     throw new IllegalStateException(e);
                 }
@@ -332,7 +323,7 @@ public class Microwave implements AutoCl
 
                 String serverXmlContent;
                 try (final InputStream stream = new FileInputStream(file)) {
-                    serverXmlContent = IOUtils.toString(stream, StandardCharsets.UTF_8);
+                    serverXmlContent = IO.toString(stream);
                     for (final Map.Entry<String, String> pair : replacements.entrySet())
{
                         serverXmlContent = serverXmlContent.replace(pair.getKey(), pair.getValue());
                     }
@@ -340,7 +331,7 @@ public class Microwave implements AutoCl
                     throw new IllegalStateException(e);
                 }
                 try (final OutputStream os = new FileOutputStream(file)) {
-                    IOUtils.write(serverXmlContent, os);
+                    os.write(serverXmlContent.getBytes(StandardCharsets.UTF_8));
                 } catch (final IOException e) {
                     throw new IllegalStateException(e);
                 }
@@ -490,8 +481,8 @@ public class Microwave implements AutoCl
                 ofNullable(postTask).ifPresent(Runnable::run);
                 postTask = null;
                 try {
-                    FileUtils.deleteDirectory(base);
-                } catch (final IllegalArgumentException /*does not exist from the hook*/
| IOException e) {
+                    IO.delete(base);
+                } catch (final IllegalArgumentException /*does not exist from the hook*/
e) {
                     // no-op
                 }
             }
@@ -567,7 +558,7 @@ public class Microwave implements AutoCl
                 try (final InputStream is = u.getValue().openStream()) {
                     final File to = new File(base, u.getKey());
                     try (final OutputStream os = new FileOutputStream(to)) {
-                        IOUtils.copy(is, os);
+                        IO.copy(is, os);
                     }
                     if ("server.xml".equals(u.getKey())) {
                         configuration.setServerXml(to.getAbsolutePath());
@@ -587,19 +578,11 @@ public class Microwave implements AutoCl
             final File dirFile = new File(dir);
             if (dirFile.exists()) {
                 if (base.exists() && configuration.deleteBaseOnStartup) {
-                    try {
-                        FileUtils.deleteDirectory(base);
-                    } catch (final IOException e) {
-                        throw new IllegalArgumentException(e);
-                    }
+                    IO.delete(base);
                 }
                 return dir;
             }
-            try {
-                FileUtils.forceMkdir(dirFile);
-            } catch (final IOException e) {
-                throw new IllegalArgumentException(e);
-            }
+            IO.mkdirs(dirFile);
             return dirFile.getAbsolutePath();
         }
 
@@ -607,11 +590,7 @@ public class Microwave implements AutoCl
                 .map(File::new)
                 .filter(File::isDirectory)
                 .findFirst().get(), "microwave-" + System.nanoTime());
-        try {
-            FileUtils.forceMkdir(file);
-        } catch (final IOException e) {
-            throw new IllegalArgumentException(e);
-        }
+        IO.mkdirs(file);
         return file.getAbsolutePath();
     }
 

Added: openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/io/IO.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/io/IO.java?rev=1766223&view=auto
==============================================================================
--- openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/io/IO.java
(added)
+++ openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/io/IO.java
Sat Oct 22 19:05:56 2016
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.microwave.io;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.stream.Stream;
+
+import static java.util.Optional.ofNullable;
+
+public final class IO {
+    private IO() {
+        // no-op
+    }
+
+    public static void delete(final File dir) {
+        if (dir.isFile()) {
+            retryDelete(dir);
+            return;
+        }
+
+        Stream.of(ofNullable(dir.listFiles()).orElseGet(() -> new File[0]))
+                .forEach(f -> {
+                    if (f.isFile()) {
+                        retryDelete(f);
+                    } else {
+                        delete(f);
+                    }
+                    retryDelete(f);
+                });
+    }
+
+    private static void retryDelete(final File f) {
+        for (int i = 0; i < 3; i++) {
+            if (f.isFile() && !f.delete()) {
+                System.gc(); // win
+                try {
+                    Thread.sleep(50);
+                } catch (final InterruptedException e) {
+                    Thread.interrupted();
+                }
+                continue;
+            }
+            return;
+        }
+        throw new IllegalStateException("Can't delete " + f);
+    }
+
+    public static void copy(final InputStream is, final OutputStream os) throws IOException
{
+        byte[] buffer = new byte[16384];
+        int count;
+        while (-1 != (count = is.read(buffer))) {
+            os.write(buffer, 0, count);
+        }
+    }
+
+    public static String toString(final InputStream stream) throws IOException {
+        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        copy(stream, baos);
+        return new String(baos.toByteArray(), StandardCharsets.UTF_8);
+    }
+
+    public static void mkdirs(final File d) {
+        if (!d.isDirectory() && !d.mkdirs()) {
+            throw new IllegalStateException(d + " can't be created");
+        }
+    }
+}

Modified: openwebbeans/microwave/trunk/microwave-core/src/test/java/org/apache/microwave/MicrowaveTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-core/src/test/java/org/apache/microwave/MicrowaveTest.java?rev=1766223&r1=1766222&r2=1766223&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-core/src/test/java/org/apache/microwave/MicrowaveTest.java
(original)
+++ openwebbeans/microwave/trunk/microwave-core/src/test/java/org/apache/microwave/MicrowaveTest.java
Sat Oct 22 19:05:56 2016
@@ -18,8 +18,8 @@
  */
 package org.apache.microwave;
 
-import org.apache.commons.io.IOUtils;
 import org.apache.cxf.helpers.FileUtils;
+import org.apache.microwave.io.IO;
 import org.junit.Test;
 import org.superbiz.app.Endpoint;
 import org.superbiz.app.RsApp;
@@ -48,7 +48,7 @@ public class MicrowaveTest {
             FileUtils.mkDir(targetFile.getParentFile());
             try (final InputStream from = Thread.currentThread().getContextClassLoader().getResourceAsStream(target
+ ".class");
                  final OutputStream to = new FileOutputStream(targetFile)) {
-                IOUtils.copy(from, to);
+                IO.copy(from, to);
             } catch (final IOException e) {
                 fail();
             }
@@ -59,7 +59,7 @@ public class MicrowaveTest {
             FileUtils.mkDir(targetFile.getParentFile());
             try (final InputStream from = Thread.currentThread().getContextClassLoader().getResourceAsStream("org/superbiz/app-res/"
+ name + ".class");
                  final OutputStream to = new FileOutputStream(targetFile)) {
-                IOUtils.copy(from, to);
+                IO.copy(from, to);
             } catch (final IOException e) {
                 fail();
             }
@@ -71,13 +71,13 @@ public class MicrowaveTest {
         }
         try (final Microwave microwave = new Microwave(new Microwave.Builder().randomHttpPort()).start())
{
             microwave.deployWebapp("", root);
-            assertEquals("hello", IOUtils.toString(new URL("http://localhost:" + microwave.getConfiguration().getHttpPort()
+ "/index.html")));
-            assertEquals("simple", IOUtils.toString(new URL("http://localhost:" + microwave.getConfiguration().getHttpPort()
+ "/api/test")));
-            assertEquals("simplepathinfo", IOUtils.toString(new URL("http://localhost:" +
microwave.getConfiguration().getHttpPort()
+            assertEquals("hello", slurp(new URL("http://localhost:" + microwave.getConfiguration().getHttpPort()
+ "/index.html")));
+            assertEquals("simple", slurp(new URL("http://localhost:" + microwave.getConfiguration().getHttpPort()
+ "/api/test")));
+            assertEquals("simplepathinfo", slurp(new URL("http://localhost:" + microwave.getConfiguration().getHttpPort()
                     + "/api/test?checkcustom=pathinfo#is=fine")));
-            assertEquals("simple", IOUtils.toString(new URL("http://localhost:" + microwave.getConfiguration().getHttpPort()
+ "/api/other")));
-            assertEquals("simplefiltertrue", IOUtils.toString(new URL("http://localhost:"
+ microwave.getConfiguration().getHttpPort() + "/filter")));
-            assertEquals("filtertrue", IOUtils.toString(new URL("http://localhost:" + microwave.getConfiguration().getHttpPort()
+ "/other")));
+            assertEquals("simple", slurp(new URL("http://localhost:" + microwave.getConfiguration().getHttpPort()
+ "/api/other")));
+            assertEquals("simplefiltertrue", slurp(new URL("http://localhost:" + microwave.getConfiguration().getHttpPort()
+ "/filter")));
+            assertEquals("filtertrue", slurp(new URL("http://localhost:" + microwave.getConfiguration().getHttpPort()
+ "/other")));
         } catch (final IOException e) {
             fail(e.getMessage());
         }
@@ -86,11 +86,11 @@ public class MicrowaveTest {
     @Test
     public void classpath() {
         try (final Microwave microwave = new Microwave(new Microwave.Builder().randomHttpPort()).bake())
{
-            assertEquals("simple", IOUtils.toString(new URL("http://localhost:" + microwave.getConfiguration().getHttpPort()
+ "/api/test")));
-            assertEquals("simplefiltertrue", IOUtils.toString(new URL("http://localhost:"
+ microwave.getConfiguration().getHttpPort() + "/filter")));
+            assertEquals("simple", slurp(new URL("http://localhost:" + microwave.getConfiguration().getHttpPort()
+ "/api/test")));
+            assertEquals("simplefiltertrue", slurp(new URL("http://localhost:" + microwave.getConfiguration().getHttpPort()
+ "/filter")));
             assertEquals(
                     "sci:" + Endpoint.class.getName() + RsApp.class.getName(),
-                    IOUtils.toString(new URL("http://localhost:" + microwave.getConfiguration().getHttpPort()
+ "/sci")));
+                    slurp(new URL("http://localhost:" + microwave.getConfiguration().getHttpPort()
+ "/sci")));
         } catch (final IOException e) {
             fail(e.getMessage());
         }
@@ -99,9 +99,18 @@ public class MicrowaveTest {
     @Test
     public void json() {
         try (final Microwave microwave = new Microwave(new Microwave.Builder().randomHttpPort()).bake())
{
-            assertEquals("{\"name\":\"test\"}", IOUtils.toString(new URL("http://localhost:"
+ microwave.getConfiguration().getHttpPort() + "/api/test/json")));
+            assertEquals("{\"name\":\"test\"}", slurp(new URL("http://localhost:" + microwave.getConfiguration().getHttpPort()
+ "/api/test/json")));
         } catch (final IOException e) {
             fail(e.getMessage());
         }
     }
+
+    private String slurp(final URL url) {
+        try (final InputStream is = url.openStream()) {
+            return IO.toString(is);
+        } catch (final IOException e) {
+            fail(e.getMessage());
+        }
+        return null;
+    }
 }

Modified: openwebbeans/microwave/trunk/microwave-core/src/test/java/org/apache/microwave/runner/CliTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-core/src/test/java/org/apache/microwave/runner/CliTest.java?rev=1766223&r1=1766222&r2=1766223&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-core/src/test/java/org/apache/microwave/runner/CliTest.java
(original)
+++ openwebbeans/microwave/trunk/microwave-core/src/test/java/org/apache/microwave/runner/CliTest.java
Sat Oct 22 19:05:56 2016
@@ -18,12 +18,11 @@
  */
 package org.apache.microwave.runner;
 
-import org.apache.commons.io.IOUtils;
+import org.apache.microwave.io.IO;
 import org.junit.Test;
 
-import java.io.FileNotFoundException;
 import java.io.IOException;
-import java.net.ConnectException;
+import java.io.InputStream;
 import java.net.ServerSocket;
 import java.net.Socket;
 import java.net.URL;
@@ -63,9 +62,9 @@ public class CliTest {
             runner.start();
             for (int i = 0; i < 60; i++) {
                 try {
-                    assertEquals("{\"name\":\"test\"}", IOUtils.toString(new URL("http://localhost:"
+ http + "/app/api/test/json")));
+                    assertEquals("{\"name\":\"test\"}", slurp(new URL("http://localhost:"
+ http + "/app/api/test/json")));
                     return;
-                } catch (final AssertionError | ConnectException | FileNotFoundException
notYet) {
+                } catch (final AssertionError notYet) {
                     try {
                         Thread.sleep(1000);
                     } catch (final InterruptedException e) {
@@ -89,4 +88,13 @@ public class CliTest {
             }
         }
     }
+
+    private String slurp(final URL url) {
+        try (final InputStream is = url.openStream()) {
+            return IO.toString(is);
+        } catch (final IOException e) {
+            fail(e.getMessage());
+        }
+        return null;
+    }
 }

Modified: openwebbeans/microwave/trunk/microwave-junit/src/test/java/org/apache/microwave/junit/MicrowaveRuleTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-junit/src/test/java/org/apache/microwave/junit/MicrowaveRuleTest.java?rev=1766223&r1=1766222&r2=1766223&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-junit/src/test/java/org/apache/microwave/junit/MicrowaveRuleTest.java
(original)
+++ openwebbeans/microwave/trunk/microwave-junit/src/test/java/org/apache/microwave/junit/MicrowaveRuleTest.java
Sat Oct 22 19:05:56 2016
@@ -18,14 +18,16 @@
  */
 package org.apache.microwave.junit;
 
-import org.apache.commons.io.IOUtils;
+import org.apache.microwave.io.IO;
 import org.junit.ClassRule;
 import org.junit.Test;
 
 import java.io.IOException;
+import java.io.InputStream;
 import java.net.URL;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
 
 public class MicrowaveRuleTest {
     @ClassRule
@@ -33,6 +35,15 @@ public class MicrowaveRuleTest {
 
     @Test
     public void test() throws IOException {
-        assertEquals("simple", IOUtils.toString(new URL("http://localhost:" + RULE.getConfiguration().getHttpPort()
+ "/api/test")));
+        assertEquals("simple", slurp(new URL("http://localhost:" + RULE.getConfiguration().getHttpPort()
+ "/api/test")));
+    }
+
+    private String slurp(final URL url) {
+        try (final InputStream is = url.openStream()) {
+            return IO.toString(is);
+        } catch (final IOException e) {
+            fail(e.getMessage());
+        }
+        return null;
     }
 }

Modified: openwebbeans/microwave/trunk/microwave-junit/src/test/java/org/apache/microwave/junit/MonoMicrowaveRuleTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-junit/src/test/java/org/apache/microwave/junit/MonoMicrowaveRuleTest.java?rev=1766223&r1=1766222&r2=1766223&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-junit/src/test/java/org/apache/microwave/junit/MonoMicrowaveRuleTest.java
(original)
+++ openwebbeans/microwave/trunk/microwave-junit/src/test/java/org/apache/microwave/junit/MonoMicrowaveRuleTest.java
Sat Oct 22 19:05:56 2016
@@ -18,15 +18,17 @@
  */
 package org.apache.microwave.junit;
 
-import org.apache.commons.io.IOUtils;
 import org.apache.microwave.Microwave;
+import org.apache.microwave.io.IO;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
 import java.io.IOException;
+import java.io.InputStream;
 import java.net.URL;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
 
 @RunWith(MonoMicrowave.Runner.class)
 public class MonoMicrowaveRuleTest {
@@ -40,6 +42,15 @@ public class MonoMicrowaveRuleTest {
 
     @Test
     public void test() throws IOException {
-        assertEquals("simple", IOUtils.toString(new URL("http://localhost:" + config.getHttpPort()
+ "/api/test")));
+        assertEquals("simple", slurp(new URL("http://localhost:" + config.getHttpPort() +
"/api/test")));
+    }
+
+    private String slurp(final URL url) {
+        try (final InputStream is = url.openStream()) {
+            return IO.toString(is);
+        } catch (final IOException e) {
+            fail(e.getMessage());
+        }
+        return null;
     }
 }



Mime
View raw message