diff --git a/lib/pom.xml b/lib/pom.xml index ba11e4a0..45e44bac 100644 --- a/lib/pom.xml +++ b/lib/pom.xml @@ -121,8 +121,12 @@ commons-cli - commons-httpclient - commons-httpclient + org.apache.httpcomponents.client5 + httpclient5 + + + org.apache.httpcomponents.client5 + httpclient5-fluent commons-io diff --git a/lib/src/main/java/gdv/xport/util/URLReader.java b/lib/src/main/java/gdv/xport/util/URLReader.java index e9f4ac9c..38c7b092 100644 --- a/lib/src/main/java/gdv/xport/util/URLReader.java +++ b/lib/src/main/java/gdv/xport/util/URLReader.java @@ -19,9 +19,9 @@ package gdv.xport.util; import gdv.xport.config.Config; -import org.apache.commons.httpclient.HttpClient; -import org.apache.commons.httpclient.methods.GetMethod; import org.apache.commons.io.FileUtils; +import org.apache.hc.client5.http.fluent.Content; +import org.apache.hc.client5.http.fluent.Request; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -64,14 +64,10 @@ public String read() throws IOException { return readFile(); } try { - HttpClient httpClient = new HttpClient(); - GetMethod get = new GetMethod(url.toString()); - httpClient.executeMethod(get); - String content = get.getResponseBodyAsString(); - get.releaseConnection(); - return content; - } catch(IllegalStateException ise) { - LOG.info(ise + " - fallback to URLConnection"); + Content content = Request.get(url).execute().returnContent(); + return content.asString(); + } catch(IOException ioe) { + LOG.info(ioe + " - fallback to URLConnection"); URLConnection connection = url.toURL().openConnection(); return read(connection); } diff --git a/lib/src/test/java/gdv/xport/demo/ImportExportTest.java b/lib/src/test/java/gdv/xport/demo/ImportExportTest.java index dcc61011..157e23a6 100644 --- a/lib/src/test/java/gdv/xport/demo/ImportExportTest.java +++ b/lib/src/test/java/gdv/xport/demo/ImportExportTest.java @@ -21,8 +21,8 @@ import gdv.xport.Datenpaket; import gdv.xport.feld.Bezeichner; import gdv.xport.satz.Satz; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.junit.Test; import patterntesting.runtime.annotation.IntegrationTest; import patterntesting.runtime.annotation.SkipTestOn; @@ -43,7 +43,7 @@ */ public class ImportExportTest { - private static final Log log = LogFactory.getLog(ImportExportTest.class); + private static final Logger LOG = LogManager.getLogger(ImportExportTest.class); /** * Test-Methode fuer {@link ImportExport#importSatz100(File)}. @@ -53,7 +53,7 @@ public class ImportExportTest { @Test public void testImportSatz100() throws IOException { File tmpFile = File.createTempFile("datensatz", ".gdv"); - log.info("file \"" + tmpFile + "\" created."); + LOG.info("file \"" + tmpFile + "\" created."); checkImportSatz100(tmpFile); } @@ -67,7 +67,7 @@ private void checkImportSatz100(File tmpFile) throws IOException { assertEquals("1", satz100.getFeld(Bezeichner.GESCHLECHT).getInhalt()); } finally { tmpFile.delete(); - log.info("file \"" + tmpFile + "\" deleted."); + LOG.info("file \"" + tmpFile + "\" deleted."); } } diff --git a/lib/src/test/java/gdv/xport/io/RecyclingInputStreamReaderTest.java b/lib/src/test/java/gdv/xport/io/RecyclingInputStreamReaderTest.java index b2743bf5..578fc822 100644 --- a/lib/src/test/java/gdv/xport/io/RecyclingInputStreamReaderTest.java +++ b/lib/src/test/java/gdv/xport/io/RecyclingInputStreamReaderTest.java @@ -18,17 +18,17 @@ package gdv.xport.io; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.junit.Test; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.nio.CharBuffer; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; /** * Unit-Test fuer {@link RecyclingInputStreamReader}. @@ -38,7 +38,7 @@ */ public class RecyclingInputStreamReaderTest { - private static Log log = LogFactory.getLog(RecyclingInputStreamReaderTest.class); + private static final Logger LOG = LogManager.getLogger(RecyclingInputStreamReaderTest.class); private static String HELLO = "hello world"; private final InputStream istream = new ByteArrayInputStream(HELLO.getBytes()); @@ -58,7 +58,7 @@ public void testRead() throws IOException { assertEquals(HELLO, new String(cbuf)); } finally { reader.close(); - log.info(reader + " was closed."); + LOG.info(reader + " was closed."); } } diff --git a/pom.xml b/pom.xml index e3953e5e..3f5dcce0 100644 --- a/pom.xml +++ b/pom.xml @@ -381,9 +381,14 @@ 1.5.0 - commons-httpclient - commons-httpclient - 3.1 + org.apache.httpcomponents.client5 + httpclient5 + 5.1.3 + + + org.apache.httpcomponents.client5 + httpclient5-fluent + 5.1.3 commons-io @@ -519,7 +524,7 @@ net.sf.oval oval - 1.90 + 3.2.1 de.jfachwert