Remove use of commons-io 91/85091/2
authorRobert Varga <robert.varga@pantheon.tech>
Sun, 13 Oct 2019 07:30:16 +0000 (09:30 +0200)
committerRobert Varga <nite@hq.sk>
Sun, 13 Oct 2019 11:17:02 +0000 (11:17 +0000)
We are using commons-io only for reading a resource file, which
we can do equally well with Guava's Resources.toString(URL, Charset).

Change-Id: Ife9f9b4e7fc616156c24a86dae56cecff1c7c4ba
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
bgp/cli/pom.xml
bgp/cli/src/test/java/org/opendaylight/protocol/bgp/cli/utils/BGPOperationalStateUtilsTest.java
bgp/cli/src/test/java/org/opendaylight/protocol/bgp/cli/utils/GlobalStateCliUtilsTest.java
bgp/cli/src/test/java/org/opendaylight/protocol/bgp/cli/utils/NeighborStateCliUtilsTest.java
bgp/cli/src/test/java/org/opendaylight/protocol/bgp/cli/utils/PeerGroupStateCliUtilsTest.java
pcep/topology/cli/pom.xml
pcep/topology/cli/src/test/java/org/opendaylight/protocol/pcep/cli/utils/PcepStateUtilsTest.java

index 42709189395a1116a24b8abd1b7458872d967aa7..28e1aa8793d069106524e36d9ff88cf366aef3a9 100644 (file)
             <artifactId>guava</artifactId>
         </dependency>
         <!--Test dependencies-->
-        <dependency>
-            <groupId>commons-io</groupId>
-            <artifactId>commons-io</artifactId>
-            <scope>test</scope>
-        </dependency>
         <dependency>
             <groupId>org.opendaylight.mdsal</groupId>
             <artifactId>mdsal-binding-dom-adapter</artifactId>
index 4bfd225ccdcf2b8cc86cb6abf8ff8a5af9c63222..2eeed81e750d3b3acaace5c23de60632182286fa 100644 (file)
@@ -10,14 +10,14 @@ package org.opendaylight.protocol.bgp.cli.utils;
 import static org.junit.Assert.assertEquals;
 import static org.opendaylight.protocol.bgp.cli.utils.BGPOperationalStateUtils.PROTOCOLS_IID;
 import static org.opendaylight.protocol.bgp.cli.utils.NeighborStateCliUtilsTest.NEIGHBOR_ADDRESS;
-import static org.opendaylight.protocol.bgp.cli.utils.PeerGroupStateCliUtilsTest.UTF8;
 
+import com.google.common.io.Resources;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.PrintStream;
+import java.nio.charset.StandardCharsets;
 import java.util.Collections;
 import java.util.concurrent.ExecutionException;
-import org.apache.commons.io.IOUtils;
 import org.junit.Test;
 import org.opendaylight.mdsal.binding.api.WriteTransaction;
 import org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest;
@@ -47,8 +47,8 @@ public class BGPOperationalStateUtilsTest extends AbstractConcurrentDataBrokerTe
     public void testDisplayBgpOperationalStateFound() throws IOException, ExecutionException, InterruptedException {
         createDefaultProtocol();
         BGPOperationalStateUtils.displayBgpOperationalState(getDataBroker(), this.stream, RIB_ID, null, null);
-        final String expected = IOUtils.toString(
-                getClass().getClassLoader().getResourceAsStream("global.txt"), UTF8);
+        final String expected = Resources.toString(getClass().getClassLoader().getResource("global.txt"),
+            StandardCharsets.UTF_8);
         assertEquals(expected, this.output.toString());
     }
 
@@ -72,8 +72,8 @@ public class BGPOperationalStateUtilsTest extends AbstractConcurrentDataBrokerTe
         createDefaultProtocol();
         BGPOperationalStateUtils.displayBgpOperationalState(getDataBroker(), this.stream, RIB_ID, null,
                 NEIGHBOR_ADDRESS);
-        final String expected = IOUtils.toString(
-                getClass().getClassLoader().getResourceAsStream("empty-neighbor.txt"), UTF8);
+        final String expected = Resources.toString(getClass().getClassLoader().getResource("empty-neighbor.txt"),
+            StandardCharsets.UTF_8);
         assertEquals(expected, this.output.toString());
     }
 }
\ No newline at end of file
index 84788606651ffb50a9654f21649d2c98d75a7316..5eea7c994fa9248baceebb4165579a1d8424d77a 100644 (file)
@@ -9,13 +9,13 @@ package org.opendaylight.protocol.bgp.cli.utils;
 
 import static org.junit.Assert.assertEquals;
 import static org.opendaylight.protocol.bgp.cli.utils.BGPOperationalStateUtilsTest.RIB_ID;
-import static org.opendaylight.protocol.bgp.cli.utils.PeerGroupStateCliUtilsTest.UTF8;
 
+import com.google.common.io.Resources;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.PrintStream;
+import java.nio.charset.StandardCharsets;
 import java.util.Collections;
-import org.apache.commons.io.IOUtils;
 import org.junit.Test;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafiBuilder;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.AfiSafisBuilder;
@@ -35,8 +35,8 @@ public class GlobalStateCliUtilsTest {
         final GlobalBuilder builder = buildGlobal(false);
         GlobalStateCliUtils.displayRibOperationalState(RIB_ID, builder.build(), this.stream);
 
-        final String expected = IOUtils.toString(
-                getClass().getClassLoader().getResourceAsStream("empty-global.txt"), UTF8);
+        final String expected = Resources.toString(getClass().getClassLoader().getResource("empty-global.txt"),
+            StandardCharsets.UTF_8);
         assertEquals(expected, this.output.toString());
     }
 
@@ -45,8 +45,8 @@ public class GlobalStateCliUtilsTest {
         final GlobalBuilder builder = buildGlobal(true);
         GlobalStateCliUtils.displayRibOperationalState(RIB_ID, builder.build(), this.stream);
 
-        final String expected = IOUtils.toString(
-                getClass().getClassLoader().getResourceAsStream("global.txt"), UTF8);
+        final String expected = Resources.toString(getClass().getClassLoader().getResource("global.txt"),
+            StandardCharsets.UTF_8);
         assertEquals(expected, this.output.toString());
     }
 
index d9fa7b513af4aecded9b4a3fdcacb8825187c1de..c60d01495920a43e8ef67a5a6b15c62d7f8054be 100644 (file)
@@ -8,15 +8,15 @@
 package org.opendaylight.protocol.bgp.cli.utils;
 
 import static org.junit.Assert.assertEquals;
-import static org.opendaylight.protocol.bgp.cli.utils.PeerGroupStateCliUtilsTest.UTF8;
 
+import com.google.common.io.Resources;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.PrintStream;
 import java.math.BigDecimal;
 import java.math.BigInteger;
+import java.nio.charset.StandardCharsets;
 import java.util.Collections;
-import org.apache.commons.io.IOUtils;
 import org.junit.Test;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafi;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafiBuilder;
@@ -90,8 +90,8 @@ public class NeighborStateCliUtilsTest {
         NeighborStateCliUtils.displayNeighborOperationalState(NEIGHBOR_ADDRESS,
                 neighbor, this.stream);
 
-        final String expected = IOUtils.toString(
-                getClass().getClassLoader().getResourceAsStream("empty-neighbor.txt"), UTF8);
+        final String expected = Resources.toString(getClass().getClassLoader().getResource("empty-neighbor.txt"),
+            StandardCharsets.UTF_8);
         assertEquals(expected, this.output.toString());
     }
 
@@ -159,8 +159,8 @@ public class NeighborStateCliUtilsTest {
         NeighborStateCliUtils.displayNeighborOperationalState(NEIGHBOR_ADDRESS,
                 neighbor, this.stream);
 
-        final String expected = IOUtils.toString(
-                getClass().getClassLoader().getResourceAsStream("neighbor.txt"), UTF8);
+        final String expected = Resources.toString(getClass().getClassLoader().getResource("neighbor.txt"),
+            StandardCharsets.UTF_8);
         assertEquals(expected, this.output.toString());
     }
 }
\ No newline at end of file
index a2b67f109b7d35379de6c52c4a6e99420ba98dc9..79230af0c279175af055aa6cf06622f74eb9337f 100644 (file)
@@ -9,11 +9,12 @@ package org.opendaylight.protocol.bgp.cli.utils;
 
 import static org.junit.Assert.assertEquals;
 
+import com.google.common.io.Resources;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.PrintStream;
+import java.nio.charset.StandardCharsets;
 import java.util.Collections;
-import org.apache.commons.io.IOUtils;
 import org.junit.Test;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.peer.group.PeerGroupBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.PeerGroupStateAugmentation;
@@ -22,7 +23,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.open
 public final class PeerGroupStateCliUtilsTest {
 
     private static final String TEST_GROUP = "test-group";
-    static final String UTF8 = "UTF-8";
     private final ByteArrayOutputStream output = new ByteArrayOutputStream();
     private final PrintStream stream = new PrintStream(this.output);
 
@@ -31,8 +31,8 @@ public final class PeerGroupStateCliUtilsTest {
         final PeerGroupBuilder peerGroup = new PeerGroupBuilder().setPeerGroupName(TEST_GROUP);
         PeerGroupStateCliUtils.displayPeerOperationalState(Collections.singletonList(peerGroup.build()), this.stream);
 
-        final String expected = IOUtils.toString(
-                getClass().getClassLoader().getResourceAsStream("empty-peer-group.txt"), UTF8);
+        final String expected = Resources.toString(getClass().getClassLoader().getResource("empty-peer-group.txt"),
+            StandardCharsets.UTF_8);
         assertEquals(expected, this.output.toString());
     }
 
@@ -49,8 +49,8 @@ public final class PeerGroupStateCliUtilsTest {
                 .StateBuilder().addAugmentation(PeerGroupStateAugmentation.class, groupState).build());
         PeerGroupStateCliUtils.displayPeerOperationalState(Collections.singletonList(peerGroup.build()), this.stream);
 
-        final String expected = IOUtils.toString(
-                getClass().getClassLoader().getResourceAsStream("peer-group.txt"), UTF8);
+        final String expected = Resources.toString(getClass().getClassLoader().getResource("peer-group.txt"),
+            StandardCharsets.UTF_8);
         assertEquals(expected, this.output.toString());
     }
 }
\ No newline at end of file
index 9cc7fa6dc616608296530e44999ee91258e49fd1..e152fb3251383febdf9c802461d853a6253dfc92 100644 (file)
             <artifactId>guava</artifactId>
         </dependency>
         <!--Test dependencies-->
-        <dependency>
-            <groupId>commons-io</groupId>
-            <artifactId>commons-io</artifactId>
-            <scope>test</scope>
-        </dependency>
         <dependency>
             <groupId>org.opendaylight.mdsal</groupId>
             <artifactId>mdsal-binding-dom-adapter</artifactId>
index 51c7af13423c4549b2103543cbaaf266304cc67c..1f1fe44d1d55385c7471cbb1e9feeee2b3817828 100644 (file)
@@ -9,11 +9,12 @@ package org.opendaylight.protocol.pcep.cli.utils;
 
 import static org.junit.Assert.assertEquals;
 
+import com.google.common.io.Resources;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.PrintStream;
+import java.nio.charset.StandardCharsets;
 import java.util.concurrent.ExecutionException;
-import org.apache.commons.io.IOUtils;
 import org.junit.Test;
 import org.opendaylight.mdsal.binding.api.WriteTransaction;
 import org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest;
@@ -54,8 +55,8 @@ public class PcepStateUtilsTest extends AbstractConcurrentDataBrokerTest {
     private static final String IP_ADDRESS = "127.0.0.1";
     private static final String RIB_NOT_FOUND = "Node [pcc://" + IP_ADDRESS + "] not found\n";
     private static final String NODE_ID = "pcc://127.0.0.1";
-    private static final String UTF8 = "UTF-8";
     private static final byte[] SPEAKER_ID = {0x01, 0x02, 0x03, 0x04};
+
     private final ByteArrayOutputStream output = new ByteArrayOutputStream();
     private final PrintStream stream = new PrintStream(this.output);
 
@@ -69,8 +70,8 @@ public class PcepStateUtilsTest extends AbstractConcurrentDataBrokerTest {
     public void testDisplayNodeState() throws IOException, ExecutionException, InterruptedException {
         createDefaultProtocol();
         PcepStateUtils.displayNodeState(getDataBroker(), this.stream, PCEP_TOPOLOGY, NODE_ID);
-        final String expected = IOUtils.toString(
-                getClass().getClassLoader().getResourceAsStream("node.txt"), UTF8);
+        final String expected = Resources.toString(getClass().getClassLoader().getResource("node.txt"),
+            StandardCharsets.UTF_8);
         assertEquals(expected, this.output.toString());
     }