Fix checkstyle/spotbugs violations 64/84164/1
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 3 Sep 2019 07:34:01 +0000 (09:34 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 3 Sep 2019 08:46:07 +0000 (10:46 +0200)
Enabling checkstyle/spotbugs by default finds these, fix them up.

Change-Id: Ib407830f0a15cb4c04492f3c694fb463cdb30bad
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
22 files changed:
benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/DsbenchmarkProvider.java
benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/simpletx/SimpletxBaDelete.java
benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/simpletx/SimpletxBaWrite.java
benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/simpletx/SimpletxDomDelete.java
benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainBaDelete.java
benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainBaRead.java
benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainBaWrite.java
benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainDomDelete.java
benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainDomRead.java
benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainDomWrite.java
benchmark/ntfbenchmark/src/main/java/ntfbenchmark/impl/NtfbenchNonblockingProducer.java
benchmark/ntfbenchmark/src/main/java/ntfbenchmark/impl/NtfbenchmarkProvider.java
benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/GlobalBindingRTCClient.java
benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/RTCClient.java
benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/RoutedBindingRTClient.java
benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/RpcbenchmarkProvider.java
opendaylight/md-sal/mdsal-it-base/src/main/java/org/opendaylight/controller/mdsal/it/base/AbstractMdsalTestBase.java
opendaylight/md-sal/sal-binding-it/src/main/java/org/opendaylight/controller/test/sal/binding/it/TestHelper.java
opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/DataServiceIT.java
opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/NotificationIT.java
opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/RoutedServiceIT.java
opendaylight/md-sal/samples/toaster-it/src/test/java/org/opendaylight/controller/sample/toaster/it/ToasterTest.java

index c5232a2..1547f2b 100644 (file)
@@ -77,7 +77,7 @@ public class DsbenchmarkProvider implements DsbenchmarkService, AutoCloseable {
             setTestOperData(this.execStatus.get(), testsCompleted);
         } catch (final Exception e) {
             // TODO: Use a singleton service to make sure the initial write is performed only once.
-            LOG.warn("Working around Bugs 8829 and 6793 by ignoring exception from setTestOperData: {}", e);
+            LOG.warn("Working around Bugs 8829 and 6793 by ignoring exception from setTestOperData", e);
         }
 
         LOG.info("DsbenchmarkProvider initiated");
index f41cb1f..be52c40 100644 (file)
@@ -64,7 +64,7 @@ public class SimpletxBaDelete extends DatastoreAbstractWriter {
                     tx.commit().get();
                     txOk++;
                 } catch (final InterruptedException | ExecutionException e) {
-                    LOG.error("Transaction failed: {}", e);
+                    LOG.error("Transaction failed", e);
                     txError++;
                 }
                 tx = dataBroker.newWriteOnlyTransaction();
@@ -75,7 +75,7 @@ public class SimpletxBaDelete extends DatastoreAbstractWriter {
             try {
                 tx.commit().get();
             } catch (final InterruptedException | ExecutionException e) {
-                LOG.error("Transaction failed: {}", e);
+                LOG.error("Transaction failed", e);
             }
         }
     }
index 80e42d0..8893a70 100644 (file)
@@ -63,7 +63,7 @@ public class SimpletxBaWrite extends DatastoreAbstractWriter {
                     tx.commit().get();
                     txOk++;
                 } catch (final InterruptedException | ExecutionException e) {
-                    LOG.error("Transaction failed: {}", e);
+                    LOG.error("Transaction failed", e);
                     txError++;
                 }
                 tx = dataBroker.newWriteOnlyTransaction();
@@ -76,7 +76,7 @@ public class SimpletxBaWrite extends DatastoreAbstractWriter {
             try {
                 tx.commit().get();
             } catch (final InterruptedException | ExecutionException e) {
-                LOG.error("Transaction failed: {}", e);
+                LOG.error("Transaction failed", e);
             }
         }
     }
index ce70d4d..4f29cdc 100644 (file)
@@ -69,7 +69,7 @@ public class SimpletxDomDelete extends DatastoreAbstractWriter {
                     tx.commit().get();
                     txOk++;
                 } catch (final  InterruptedException | ExecutionException e) {
-                    LOG.error("Transaction failed: {}", e);
+                    LOG.error("Transaction failed", e);
                     txError++;
                 }
                 tx = domDataBroker.newWriteOnlyTransaction();
@@ -80,7 +80,7 @@ public class SimpletxDomDelete extends DatastoreAbstractWriter {
             try {
                 tx.commit().get();
             } catch (final InterruptedException | ExecutionException e) {
-                LOG.error("Transaction failed: {}", e);
+                LOG.error("Transaction failed", e);
             }
         }
     }
index 75fb892..bd947ac 100644 (file)
@@ -98,7 +98,7 @@ public class TxchainBaDelete extends DatastoreAbstractWriter implements Transact
         try {
             chain.close();
         } catch (final IllegalStateException e) {
-            LOG.error("Transaction close failed,", e);
+            LOG.error("Transaction close failed", e);
         }
         LOG.debug("Transactions: submitted {}, completed {}", txSubmitted, txOk + txError);
     }
@@ -106,8 +106,7 @@ public class TxchainBaDelete extends DatastoreAbstractWriter implements Transact
     @Override
     public void onTransactionChainFailed(final TransactionChain chain, final Transaction transaction,
             final Throwable cause) {
-        LOG.error("Broken chain {} in TxchainBaDelete, transaction {}, cause {}", chain, transaction.getIdentifier(),
-            cause);
+        LOG.error("Broken chain {} in TxchainBaDelete, transaction {}", chain, transaction.getIdentifier(), cause);
     }
 
     @Override
index 4394daa..101ae39 100644 (file)
@@ -96,8 +96,7 @@ public class TxchainBaRead extends DatastoreAbstractWriter implements Transactio
     @Override
     public void onTransactionChainFailed(final TransactionChain chain, final Transaction transaction,
             final Throwable cause) {
-        LOG.error("Broken chain {} in TxchainBaDelete, transaction {}, cause {}", chain, transaction.getIdentifier(),
-            cause);
+        LOG.error("Broken chain {} in TxchainBaDelete, transaction {}", chain, transaction.getIdentifier(), cause);
     }
 
     @Override
index b0ee4b4..b96c176 100644 (file)
@@ -108,8 +108,8 @@ public class TxchainBaWrite extends DatastoreAbstractWriter implements Transacti
     @Override
     public void onTransactionChainFailed(final TransactionChain chain, final Transaction transaction,
             final Throwable cause) {
-        LOG.error("Broken chain {} in DatastoreBaAbstractWrite, transaction {}, cause {}", chain,
-            transaction.getIdentifier(), cause);
+        LOG.error("Broken chain {} in DatastoreBaAbstractWrite, transaction {}", chain, transaction.getIdentifier(),
+            cause);
     }
 
     @Override
index 8f04c0a..75dee62 100644 (file)
@@ -29,7 +29,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class TxchainDomDelete extends DatastoreAbstractWriter implements DOMTransactionChainListener {
-    private static final Logger LOG = LoggerFactory.getLogger(TxchainBaWrite.class);
+    private static final Logger LOG = LoggerFactory.getLogger(TxchainDomDelete.class);
     private final DOMDataBroker domDataBroker;
 
     public TxchainDomDelete(final DOMDataBroker domDataBroker, final int outerListElem, final int innerListElem,
@@ -110,8 +110,7 @@ public class TxchainDomDelete extends DatastoreAbstractWriter implements DOMTran
     @Override
     public void onTransactionChainFailed(final DOMTransactionChain chain, final DOMDataTreeTransaction transaction,
             final Throwable cause) {
-        LOG.error("Broken chain {} in TxchainDomDelete, transaction {}, cause {}", chain, transaction.getIdentifier(),
-            cause);
+        LOG.error("Broken chain {} in TxchainDomDelete, transaction {}", chain, transaction.getIdentifier(), cause);
     }
 
     @Override
index 84eca17..4ff133d 100644 (file)
@@ -79,8 +79,7 @@ public class TxchainDomRead extends DatastoreAbstractWriter implements DOMTransa
     @Override
     public void onTransactionChainFailed(final DOMTransactionChain chain, final DOMDataTreeTransaction transaction,
             final Throwable cause) {
-        LOG.error("Broken chain {} in TxchainDomDelete, transaction {}, cause {}", chain, transaction.getIdentifier(),
-            cause);
+        LOG.error("Broken chain {} in TxchainDomDelete, transaction {}", chain, transaction.getIdentifier(), cause);
     }
 
     @Override
index 01f6065..4f254a2 100644 (file)
@@ -114,8 +114,7 @@ public class TxchainDomWrite extends DatastoreAbstractWriter implements DOMTrans
     @Override
     public void onTransactionChainFailed(final DOMTransactionChain chain, final DOMDataTreeTransaction transaction,
             final Throwable cause) {
-        LOG.error("Broken chain {} in TxchainDomWrite, transaction {}, cause {}", chain, transaction.getIdentifier(),
-            cause);
+        LOG.error("Broken chain {} in TxchainDomWrite, transaction {}", chain, transaction.getIdentifier(), cause);
     }
 
     @Override
index c6e2e8a..b0e239c 100644 (file)
@@ -8,14 +8,13 @@
 package ntfbenchmark.impl;
 
 import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.SettableFuture;
 import java.util.concurrent.ExecutionException;
 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class NtfbenchNonblockingProducer extends AbstractNtfbenchProducer {
-
-    private final SettableFuture<?> lastDeliveryFuture = SettableFuture.create();
-
+    private static final Logger LOG = LoggerFactory.getLogger(NtfbenchNonblockingProducer.class);
 
     public NtfbenchNonblockingProducer(final NotificationPublishService publishService, final int iterations,
             final int payloadSize) {
@@ -39,6 +38,7 @@ public class NtfbenchNonblockingProducer extends AbstractNtfbenchProducer {
                     lastOkFuture = result;
                 }
             } catch (final Exception e) {
+                LOG.debug("Failed to publish notification", e);
                 ntfError++;
             }
         }
index 5ea3b0f..39e8273 100644 (file)
@@ -7,6 +7,8 @@
  */
 package ntfbenchmark.impl;
 
+import static com.google.common.base.Verify.verifyNotNull;
+
 import com.google.common.util.concurrent.ListenableFuture;
 import java.util.ArrayList;
 import java.util.List;
@@ -83,7 +85,8 @@ public class NtfbenchmarkProvider implements AutoCloseable, NtfbenchmarkService
             final long startTime = System.nanoTime();
 
             for (int i = 0; i < input.getProducers().intValue(); i++) {
-                executor.submit(producers.get(i));
+                // FIXME: fools RV_RETURN_VALUE_IGNORED_BAD_PRACTICE for now, but we should check some more
+                verifyNotNull(executor.submit(producers.get(i)));
             }
             executor.shutdown();
             try {
@@ -106,7 +109,6 @@ public class NtfbenchmarkProvider implements AutoCloseable, NtfbenchmarkService
                 allListeners += listenerRegistration.getInstance().getReceived();
             }
 
-            final long listenerEndTime = System.nanoTime();
             final long listenerElapsedTime = producerEndTime - startTime;
 
             LOG.info("Test Done");
index f03c064..f09bd7f 100644 (file)
@@ -12,7 +12,6 @@ import java.util.List;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import java.util.concurrent.atomic.AtomicLong;
-
 import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
 import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.GlobalRpcBenchInput;
 import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.GlobalRpcBenchInputBuilder;
@@ -25,18 +24,20 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class GlobalBindingRTCClient implements RTCClient {
-
     private static final Logger LOG = LoggerFactory.getLogger(GlobalBindingRTCClient.class);
+
     private final RpcbenchPayloadService service;
     private final AtomicLong rpcOk = new AtomicLong(0);
     private final AtomicLong rpcError = new AtomicLong(0);
     private final GlobalRpcBenchInput inVal;
     private final int inSize;
 
+    @Override
     public long getRpcOk() {
         return rpcOk.get();
     }
 
+    @Override
     public long getRpcError() {
         return rpcError.get();
     }
@@ -56,9 +57,10 @@ public class GlobalBindingRTCClient implements RTCClient {
         inVal = new GlobalRpcBenchInputBuilder().setPayload(listVals).build();
     }
 
+    @Override
     public void runTest(final int iterations) {
-        int rpcOk = 0;
-        int rpcError = 0;
+        int ok = 0;
+        int error = 0;
 
         for (int i = 0; i < iterations; i++) {
             Future<RpcResult<GlobalRpcBenchOutput>> output = service.globalRpcBench(inVal);
@@ -68,20 +70,20 @@ public class GlobalBindingRTCClient implements RTCClient {
                 if (rpcResult.isSuccessful()) {
                     List<Payload> retVal = rpcResult.getResult().getPayload();
                     if (retVal.size() == inSize) {
-                        rpcOk++;
+                        ok++;
                     }
                     else {
-                        rpcError++;
+                        error++;
                     }
                 }
             } catch (InterruptedException | ExecutionException e) {
-                rpcError++;
+                error++;
                 LOG.error("Execution failed: ", e);
             }
         }
 
-        this.rpcOk.addAndGet(rpcOk);
-        this.rpcError.addAndGet(rpcError);
+        rpcOk.addAndGet(ok);
+        rpcError.addAndGet(error);
     }
 
     @Override
index 5565e03..d1b5edd 100644 (file)
@@ -5,12 +5,14 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package rpcbenchmark.impl;
 
 public interface RTCClient {
     long getRpcOk();
+
     long getRpcError();
+
     void runTest(int iterations);
+
     void close();
 }
index 1c44b98..cc388a3 100644 (file)
@@ -14,7 +14,6 @@ import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import java.util.concurrent.ThreadLocalRandom;
 import java.util.concurrent.atomic.AtomicLong;
-
 import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
 import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.RoutedRpcBenchInput;
 import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.RoutedRpcBenchInputBuilder;
@@ -28,22 +27,25 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class RoutedBindingRTClient implements RTCClient {
-    private static final Logger LOG = LoggerFactory.getLogger(GlobalBindingRTCClient.class);
+    private static final Logger LOG = LoggerFactory.getLogger(RoutedBindingRTClient.class);
     private final RpcbenchPayloadService service;
     private final AtomicLong rpcOk = new AtomicLong(0);
     private final AtomicLong rpcError = new AtomicLong(0);
     private final List<RoutedRpcBenchInput> inVal;
     private final int inSize;
 
+    @Override
     public long getRpcOk() {
         return rpcOk.get();
     }
 
+    @Override
     public long getRpcError() {
         return rpcError.get();
     }
 
-    public RoutedBindingRTClient(final RpcConsumerRegistry registry, final int inSize, final List<InstanceIdentifier<?>> routeIid) {
+    public RoutedBindingRTClient(final RpcConsumerRegistry registry, final int inSize,
+            final List<InstanceIdentifier<?>> routeIid) {
         if (registry != null) {
             this.service = registry.getRpcService(RpcbenchPayloadService.class);
         } else {
@@ -63,9 +65,10 @@ public class RoutedBindingRTClient implements RTCClient {
 
     }
 
+    @Override
     public void runTest(final int iterations) {
-        int rpcOk = 0;
-        int rpcError = 0;
+        int ok = 0;
+        int error = 0;
 
         int rpcServerCnt = inVal.size();
         for (int i = 0; i < iterations; i++) {
@@ -77,20 +80,20 @@ public class RoutedBindingRTClient implements RTCClient {
                 if (rpcResult.isSuccessful()) {
                     List<Payload> retVal = rpcResult.getResult().getPayload();
                     if (retVal.size() == inSize) {
-                        rpcOk++;
+                        ok++;
                     }
                     else {
-                        rpcError++;
+                        error++;
                     }
                 }
             } catch (InterruptedException | ExecutionException e) {
-                rpcError++;
+                error++;
                 LOG.error("Execution failed: ", e);
             }
         }
 
-        this.rpcOk.addAndGet(rpcOk);
-        this.rpcError.addAndGet(rpcError);
+        rpcOk.addAndGet(ok);
+        rpcError.addAndGet(error);
     }
 
     @Override
@@ -98,5 +101,4 @@ public class RoutedBindingRTClient implements RTCClient {
         // TODO Auto-generated method stub
 
     }
-
 }
index 8e8e31e..ddcf254 100644 (file)
@@ -7,6 +7,8 @@
  */
 package rpcbenchmark.impl;
 
+import static com.google.common.base.Verify.verifyNotNull;
+
 import com.google.common.util.concurrent.ListenableFuture;
 import java.util.ArrayList;
 import java.util.List;
@@ -39,7 +41,7 @@ import org.slf4j.LoggerFactory;
 public class RpcbenchmarkProvider implements AutoCloseable, RpcbenchmarkService {
 
     private static final Logger LOG = LoggerFactory.getLogger(RpcbenchmarkProvider.class);
-    private static final int testTimeout = 5;
+    private static final int TEST_TIMEOUT = 5;
 
     private final GlobalBindingRTCServer globalServer;
     private final AtomicReference<ExecStatus> execStatus = new AtomicReference<>(ExecStatus.Idle);
@@ -67,32 +69,32 @@ public class RpcbenchmarkProvider implements AutoCloseable, RpcbenchmarkService
         final List<RoutedRpcRegistration<?>> rpcRegs = new ArrayList<>();
 
         switch (input.getOperation()) {
-        case ROUTEDRTC:
-            List<InstanceIdentifier<?>> routeIid = new ArrayList<>();
-            for (int i = 0; i < input.getNumServers().intValue(); i++) {
-                GlobalBindingRTCServer server = new GlobalBindingRTCServer();
-                RoutedRpcRegistration<RpcbenchPayloadService> routedReg =
-                        providerRegistry.addRoutedRpcImplementation(RpcbenchPayloadService.class, server);
-
-                KeyedInstanceIdentifier<RpcRoute, RpcRouteKey> iid =
-                        InstanceIdentifier
+            case ROUTEDRTC:
+                List<InstanceIdentifier<?>> routeIid = new ArrayList<>();
+                for (int i = 0; i < input.getNumServers().intValue(); i++) {
+                    GlobalBindingRTCServer server = new GlobalBindingRTCServer();
+                    RoutedRpcRegistration<RpcbenchPayloadService> routedReg =
+                            providerRegistry.addRoutedRpcImplementation(RpcbenchPayloadService.class, server);
+
+                    KeyedInstanceIdentifier<RpcRoute, RpcRouteKey> iid =
+                            InstanceIdentifier
                             .create(RpcbenchRpcRoutes.class)
                             .child(RpcRoute.class, new RpcRouteKey(Integer.toString(i)));
-                routeIid.add(iid);
-                routedReg.registerPath(NodeContext.class, iid);
-                rpcRegs.add(routedReg);
-            }
+                    routeIid.add(iid);
+                    routedReg.registerPath(NodeContext.class, iid);
+                    rpcRegs.add(routedReg);
+                }
 
-            client = new RoutedBindingRTClient(providerRegistry, input.getPayloadSize().intValue(), routeIid);
-            break;
+                client = new RoutedBindingRTClient(providerRegistry, input.getPayloadSize().intValue(), routeIid);
+                break;
 
-        case GLOBALRTC:
-            client = new GlobalBindingRTCClient(providerRegistry, input.getPayloadSize().intValue());
-            break;
+            case GLOBALRTC:
+                client = new GlobalBindingRTCClient(providerRegistry, input.getPayloadSize().intValue());
+                break;
 
-        default:
-            LOG.error("Unsupported server/client type {}", input.getOperation());
-            throw new IllegalArgumentException("Unsupported server/client type" + input.getOperation());
+            default:
+                LOG.error("Unsupported server/client type {}", input.getOperation());
+                throw new IllegalArgumentException("Unsupported server/client type" + input.getOperation());
         }
 
         try {
@@ -101,17 +103,18 @@ public class RpcbenchmarkProvider implements AutoCloseable, RpcbenchmarkService
             final Runnable testRun = () -> client.runTest(input.getIterations().intValue());
 
             LOG.info("Test Started");
-            long startTime = System.nanoTime();
+            final long startTime = System.nanoTime();
 
-            for (int i = 0; i < input.getNumClients().intValue(); i++ ) {
-                executor.submit(testRun);
+            for (int i = 0; i < input.getNumClients().intValue(); i++) {
+                // FIXME: fools RV_RETURN_VALUE_IGNORED_BAD_PRACTICE, but we should check more
+                verifyNotNull(executor.submit(testRun));
             }
 
             executor.shutdown();
             try {
-                executor.awaitTermination(testTimeout, TimeUnit.MINUTES);
+                executor.awaitTermination(TEST_TIMEOUT, TimeUnit.MINUTES);
             } catch (final InterruptedException e) {
-                LOG.error("Out of time: test did not finish within the {} min deadline ", testTimeout);
+                LOG.error("Out of time: test did not finish within the {} min deadline ", TEST_TIMEOUT);
             }
 
             long endTime = System.nanoTime();
@@ -124,7 +127,8 @@ public class RpcbenchmarkProvider implements AutoCloseable, RpcbenchmarkService
                                             .setGlobalRtcClientError(client.getRpcError())
                                             .setGlobalRtcClientOk(client.getRpcOk())
                                             .setExecTime(TimeUnit.NANOSECONDS.toMillis(elapsedTime))
-                                            .setRate((client.getRpcOk() + client.getRpcError()) * 1000000000 / elapsedTime)
+                                            .setRate(
+                                                (client.getRpcOk() + client.getRpcError()) * 1000000000 / elapsedTime)
                                             .build();
             return RpcResultBuilder.success(output).buildFuture();
         } finally {
index ad09341..b8cabad 100644 (file)
@@ -91,7 +91,7 @@ public abstract class AbstractMdsalTestBase {
      * @return An array of additional config options
      */
     protected Option[] getAdditionalOptions() {
-        return null;
+        return new Option[0];
     }
 
     /**
index c073619..bea912a 100644 (file)
@@ -18,10 +18,12 @@ import org.ops4j.pax.exam.options.DefaultCompositeOption;
 import org.ops4j.pax.exam.util.PathUtils;
 
 /**
+ * Helper utility for running IT tests.
+ *
  * @deprecated Use config-it and/or mdsal-it instead.
  */
 @Deprecated
-public class TestHelper {
+public final class TestHelper {
 
     public static final String CONTROLLER = "org.opendaylight.controller";
     public static final String MDSAL = "org.opendaylight.mdsal";
@@ -30,19 +32,23 @@ public class TestHelper {
     public static final String CONTROLLER_MODELS = "org.opendaylight.controller.model";
     public static final String MDSAL_MODELS = "org.opendaylight.mdsal.model";
 
+    private TestHelper() {
+
+    }
+
     public static Option mdSalCoreBundles() {
-        return new DefaultCompositeOption( //
-                mavenBundle(YANGTOOLS, "concepts").versionAsInProject(), // //
-                mavenBundle(YANGTOOLS, "util").versionAsInProject(), // //
-                mavenBundle(MDSAL, "yang-binding").versionAsInProject(), // //
-                mavenBundle(YANGTOOLS, "yang-common").versionAsInProject(), // //
-                mavenBundle(YANGTOOLS, "object-cache-api").versionAsInProject(), // //
-                mavenBundle(YANGTOOLS, "object-cache-guava").versionAsInProject(), // //
-                mavenBundle("tech.pantheon", "triemap").versionAsInProject(), // //
-                mavenBundle(CONTROLLER, "sal-common-api").versionAsInProject(), // //
-                mavenBundle(CONTROLLER, "sal-common-impl").versionAsInProject(), // //
-
-                mavenBundle("org.apache.commons", "commons-lang3").versionAsInProject(), //
+        return new DefaultCompositeOption(
+                mavenBundle(YANGTOOLS, "concepts").versionAsInProject(),
+                mavenBundle(YANGTOOLS, "util").versionAsInProject(),
+                mavenBundle(MDSAL, "yang-binding").versionAsInProject(),
+                mavenBundle(YANGTOOLS, "yang-common").versionAsInProject(),
+                mavenBundle(YANGTOOLS, "object-cache-api").versionAsInProject(),
+                mavenBundle(YANGTOOLS, "object-cache-guava").versionAsInProject(),
+                mavenBundle("tech.pantheon", "triemap").versionAsInProject(),
+                mavenBundle(CONTROLLER, "sal-common-api").versionAsInProject(),
+                mavenBundle(CONTROLLER, "sal-common-impl").versionAsInProject(),
+
+                mavenBundle("org.apache.commons", "commons-lang3").versionAsInProject(),
                 mavenBundle("com.google.guava", "guava").versionAsInProject(),
                 mavenBundle("com.github.romix", "java-concurrent-hash-trie-map").versionAsInProject()
         );
@@ -50,20 +56,20 @@ public class TestHelper {
 
     public static Option configMinumumBundles() {
         return new DefaultCompositeOption(
-                mavenBundle(CONTROLLER, "config-api").versionAsInProject(), // //
+                mavenBundle(CONTROLLER, "config-api").versionAsInProject(),
                 bindingAwareSalBundles(),
                 mavenBundle("commons-codec", "commons-codec").versionAsInProject(),
 
                 systemPackages("sun.nio.ch", "sun.misc"),
 
-                mavenBundle(CONTROLLER, "config-manager").versionAsInProject(), // //
-                mavenBundle(CONTROLLER, "config-util").versionAsInProject(), // //
-                mavenBundle("commons-io", "commons-io").versionAsInProject(), //
-                mavenBundle(CONTROLLER, "config-manager-facade-xml").versionAsInProject(), //
-                mavenBundle(CONTROLLER, "yang-jmx-generator").versionAsInProject(), //
-                mavenBundle(CONTROLLER, "config-persister-api").versionAsInProject(), //
+                mavenBundle(CONTROLLER, "config-manager").versionAsInProject(),
+                mavenBundle(CONTROLLER, "config-util").versionAsInProject(),
+                mavenBundle("commons-io", "commons-io").versionAsInProject(),
+                mavenBundle(CONTROLLER, "config-manager-facade-xml").versionAsInProject(),
+                mavenBundle(CONTROLLER, "yang-jmx-generator").versionAsInProject(),
+                mavenBundle(CONTROLLER, "config-persister-api").versionAsInProject(),
 
-                mavenBundle(CONTROLLER, "config-persister-impl").versionAsInProject(), //
+                mavenBundle(CONTROLLER, "config-persister-impl").versionAsInProject(),
 
                 mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.xerces", "2.11.0_1"),
                 mavenBundle("org.eclipse.birt.runtime.3_7_1", "org.apache.xml.resolver", "1.2.0"),
@@ -75,93 +81,90 @@ public class TestHelper {
     }
 
     public static Option bindingAwareSalBundles() {
-        return new DefaultCompositeOption( //
+        return new DefaultCompositeOption(
                 mdSalCoreBundles(),
 
-                mavenBundle("org.javassist", "javassist").versionAsInProject(), // //
-
-                mavenBundle(YANGTOOLS, "yang-data-api").versionAsInProject(), // //
-                mavenBundle(YANGTOOLS, "yang-data-util").versionAsInProject(), // //
-                mavenBundle(YANGTOOLS, "yang-data-impl").versionAsInProject(), // //
-                mavenBundle(YANGTOOLS, "yang-model-api").versionAsInProject(), // //
-                mavenBundle(YANGTOOLS, "yang-model-util").versionAsInProject(), // //
-                mavenBundle(YANGTOOLS, "yang-parser-api").versionAsInProject(), //
-                mavenBundle(YANGTOOLS, "yang-parser-impl").versionAsInProject(), //
-                mavenBundle(MDSAL, "mdsal-binding-generator-api").versionAsInProject(), //
-                mavenBundle(MDSAL, "mdsal-binding-generator-util").versionAsInProject(), //
+                mavenBundle("org.javassist", "javassist").versionAsInProject(),
+
+                mavenBundle(YANGTOOLS, "yang-data-api").versionAsInProject(),
+                mavenBundle(YANGTOOLS, "yang-data-util").versionAsInProject(),
+                mavenBundle(YANGTOOLS, "yang-data-impl").versionAsInProject(),
+                mavenBundle(YANGTOOLS, "yang-model-api").versionAsInProject(),
+                mavenBundle(YANGTOOLS, "yang-model-util").versionAsInProject(),
+                mavenBundle(YANGTOOLS, "yang-parser-api").versionAsInProject(),
+                mavenBundle(YANGTOOLS, "yang-parser-impl").versionAsInProject(),
+                mavenBundle(MDSAL, "mdsal-binding-generator-api").versionAsInProject(),
+                mavenBundle(MDSAL, "mdsal-binding-generator-util").versionAsInProject(),
                 mavenBundle(MDSAL, "mdsal-binding-generator-impl").versionAsInProject(),
                 mavenBundle(MDSAL, "mdsal-binding-dom-codec").versionAsInProject(),
-                mavenBundle("org.antlr", "antlr4-runtime").versionAsInProject(), // //
+                mavenBundle("org.antlr", "antlr4-runtime").versionAsInProject(),
 
-                mavenBundle(CONTROLLER, "sal-binding-util").versionAsInProject(), //
-                mavenBundle(CONTROLLER, "sal-common-util").versionAsInProject(), // //
+                mavenBundle(CONTROLLER, "sal-binding-util").versionAsInProject(),
+                mavenBundle(CONTROLLER, "sal-common-util").versionAsInProject(),
 
 
-                mavenBundle(CONTROLLER, "sal-core-api").versionAsInProject().update(), //
-                mavenBundle(CONTROLLER, "sal-binding-api").versionAsInProject(), // //
+                mavenBundle(CONTROLLER, "sal-core-api").versionAsInProject().update(),
+                mavenBundle(CONTROLLER, "sal-binding-api").versionAsInProject(),
 
-                mavenBundle("com.lmax", "disruptor").versionAsInProject(), //
-                mavenBundle(CONTROLLER, "sal-broker-impl").versionAsInProject(), // //
-                mavenBundle(CONTROLLER, "sal-dom-config").versionAsInProject(), // //
+                mavenBundle("com.lmax", "disruptor").versionAsInProject(),
+                mavenBundle(CONTROLLER, "sal-broker-impl").versionAsInProject(),
+                mavenBundle(CONTROLLER, "sal-dom-config").versionAsInProject(),
 
-                mavenBundle(CONTROLLER, "sal-inmemory-datastore").versionAsInProject(), //
-                mavenBundle(CONTROLLER, "sal-dom-broker-config").versionAsInProject(), // //
+                mavenBundle(CONTROLLER, "sal-inmemory-datastore").versionAsInProject(),
+                mavenBundle(CONTROLLER, "sal-dom-broker-config").versionAsInProject(),
 
-                mavenBundle(CONTROLLER, "sal-core-spi").versionAsInProject().update(), //
+                mavenBundle(CONTROLLER, "sal-core-spi").versionAsInProject().update(),
 
-                mavenBundle(CONTROLLER, "sal-binding-broker-impl").versionAsInProject(), // //
-                mavenBundle(CONTROLLER, "sal-binding-config").versionAsInProject(), //
+                mavenBundle(CONTROLLER, "sal-binding-broker-impl").versionAsInProject(),
+                mavenBundle(CONTROLLER, "sal-binding-config").versionAsInProject(),
 
-                systemProperty("netconf.config.persister.active").value("1"), //
+                systemProperty("netconf.config.persister.active").value("1"),
                 systemProperty("netconf.config.persister.1.storageAdapterClass").value(
-                        "org.opendaylight.controller.config.persist.storage.file.xml.XmlFileStorageAdapter"), //
+                        "org.opendaylight.controller.config.persist.storage.file.xml.XmlFileStorageAdapter"),
                 systemProperty("netconf.config.persister.1.properties.fileStorage")
-                        .value(PathUtils.getBaseDir() + "/src/test/resources/controller.xml"), //
-                systemProperty("netconf.config.persister.1.properties.numberOfBackups").value("1") //
+                        .value(PathUtils.getBaseDir() + "/src/test/resources/controller.xml"),
+                systemProperty("netconf.config.persister.1.properties.numberOfBackups").value("1")
 
         );
-
     }
 
     public static Option bindingIndependentSalBundles() {
         return new DefaultCompositeOption(
 
         );
-
     }
 
     public static Option protocolFrameworkBundles() {
         return new DefaultCompositeOption(
-            mavenBundle("io.netty", "netty-common").versionAsInProject(), //
-            mavenBundle("io.netty", "netty-buffer").versionAsInProject(), //
-            mavenBundle("io.netty", "netty-handler").versionAsInProject(), //
-            mavenBundle("io.netty", "netty-codec").versionAsInProject(), //
-            mavenBundle("io.netty", "netty-transport").versionAsInProject(), //
-            mavenBundle(CONTROLLER, "netty-config-api").versionAsInProject(), //
+            mavenBundle("io.netty", "netty-common").versionAsInProject(),
+            mavenBundle("io.netty", "netty-buffer").versionAsInProject(),
+            mavenBundle("io.netty", "netty-handler").versionAsInProject(),
+            mavenBundle("io.netty", "netty-codec").versionAsInProject(),
+            mavenBundle("io.netty", "netty-transport").versionAsInProject(),
+            mavenBundle(CONTROLLER, "netty-config-api").versionAsInProject(),
             mavenBundle(CONTROLLER, "protocol-framework").versionAsInProject()
         );
-
     }
 
     public static Option flowCapableModelBundles() {
-        return new DefaultCompositeOption( //
-                mavenBundle(CONTROLLER_MODELS, "model-inventory").versionAsInProject() //
+        return new DefaultCompositeOption(
+                mavenBundle(CONTROLLER_MODELS, "model-inventory").versionAsInProject()
         );
-
     }
 
     /**
+     * Return an option containing models for testing purposes.
+     *
      * @return option containing models for testing purposes
      */
     public static Option salTestModelBundles() {
-        return new DefaultCompositeOption( //
+        return new DefaultCompositeOption(
                 mavenBundle(CONTROLLER, "sal-test-model").versionAsInProject()
         );
-
     }
 
     public static Option baseModelBundles() {
-        return new DefaultCompositeOption( //
+        return new DefaultCompositeOption(
                 mavenBundle(MDSAL + ".model", "yang-ext").versionAsInProject(),
                 mavenBundle(MDSAL_MODELS, "ietf-type-util").versionAsInProject(),
                 mavenBundle(MDSAL_MODELS, "ietf-inet-types").versionAsInProject(),
index e10eb0c..53d88ae 100644 (file)
@@ -28,7 +28,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.ops4j.pax.exam.util.Filter;
 
 /**
- * covers creating, reading and deleting of an item in dataStore
+ * Covers creating, reading and deleting of an item in dataStore.
  */
 public class DataServiceIT extends AbstractIT {
     @Inject
@@ -36,12 +36,8 @@ public class DataServiceIT extends AbstractIT {
     DataBroker dataBroker;
 
     /**
-     *
-     * Ignored this, because classes here are constructed from
-     * very different class loader as MD-SAL is run into,
+     * Ignored this, because classes here are constructed from very different class loader as MD-SAL is run into,
      * this is code is run from different classloader.
-     *
-     * @throws Exception
      */
     @Test
     public void test() throws Exception {
@@ -74,7 +70,6 @@ public class DataServiceIT extends AbstractIT {
         assertFalse(readedData2.isPresent());
     }
 
-
     private static InstanceIdentifier<UnorderedList> createNodeRef(final String string) {
         UnorderedListKey key = new UnorderedListKey(string);
         return InstanceIdentifier.builder(Lists.class).child(UnorderedContainer.class).child(UnorderedList.class, key)
index 468fc1b..9654ebf 100644 (file)
@@ -36,8 +36,7 @@ public class NotificationIT extends AbstractIT {
     NotificationProviderService notificationService;
 
     /**
-     * test of delivering of notification
-     * @throws Exception
+     * Test of delivering of notification.
      */
     @Test
     public void notificationTest() throws Exception {
@@ -53,7 +52,6 @@ public class NotificationIT extends AbstractIT {
 
         /**
          * Check that one notification was delivered and has correct cookie.
-         *
          */
         assertEquals(1, listener1.notificationBag.size());
         assertEquals("rainy day", listener1.notificationBag.get(0).getReason());
@@ -80,7 +78,6 @@ public class NotificationIT extends AbstractIT {
         /**
          * Check that 3 notification was delivered to both listeners (first one
          * received 4 in total, second 3 in total).
-         *
          */
         assertEquals(4, listener1.notificationBag.size());
         assertEquals(3, listener2.notificationBag.size());
@@ -108,18 +105,14 @@ public class NotificationIT extends AbstractIT {
          */
         assertEquals(5, listener1.notificationBag.size());
         assertEquals(3, listener2.notificationBag.size());
-
     }
 
     /**
-     * Creates instance of the type OutOfPixieDustNotification. It is
-     * used only for testing purpose.
+     * Creates instance of the type OutOfPixieDustNotification. It is used only for testing purpose.
      *
-     * @param reason
-     * @param days
      * @return instance of the type OutOfPixieDustNotification
      */
-    public static OutOfPixieDustNotification noDustNotification(String reason, int days) {
+    public static OutOfPixieDustNotification noDustNotification(final String reason, final int days) {
         OutOfPixieDustNotificationBuilder ret = new OutOfPixieDustNotificationBuilder();
         ret.setReason(reason).setDaysTillNewDust(days);
         return ret.build();
@@ -131,13 +124,11 @@ public class NotificationIT extends AbstractIT {
      * the type {@link OutOfFairyDustNotification}.
      */
     public static class NotificationTestListener implements OpendaylightTestNotificationListener {
-
         List<OutOfPixieDustNotification> notificationBag = new ArrayList<>();
 
         @Override
-        public void onOutOfPixieDustNotification(OutOfPixieDustNotification arg0) {
+        public void onOutOfPixieDustNotification(final OutOfPixieDustNotification arg0) {
             notificationBag.add(arg0);
         }
-
     }
 }
index 7bd2802..91e53d0 100644 (file)
@@ -37,7 +37,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * covers routed rpc creation, registration, invocation, unregistration
+ * Covers routed rpc creation, registration, invocation, unregistration.
  */
 public class RoutedServiceIT extends AbstractIT {
 
@@ -52,7 +52,7 @@ public class RoutedServiceIT extends AbstractIT {
     RpcProviderRegistry rpcProviderRegistry;
 
     /**
-     * prepare mocks
+     * Prepare mocks.
      */
     @Before
     public void setUp() {
@@ -93,15 +93,13 @@ public class RoutedServiceIT extends AbstractIT {
         firstReg.registerPath(TestContext.class, nodeOnePath);
 
         /**
-         * Consumer creates addFlow message for node one and sends it to the
-         * MD-SAL
+         * Consumer creates addFlow message for node one and sends it to the MD-SAL.
          */
         final RoutedSimpleRouteInput simpleRouteFirstFoo = createSimpleRouteInput(nodeOnePath);
         consumerService.routedSimpleRoute(simpleRouteFirstFoo);
 
         /**
-         * Verifies that implementation of the first provider received the same
-         * message from MD-SAL.
+         * Verifies that implementation of the first provider received the same message from MD-SAL.
          */
         verify(odlRoutedService1).routedSimpleRoute(simpleRouteFirstFoo);
         /**
@@ -114,8 +112,7 @@ public class RoutedServiceIT extends AbstractIT {
         secondReg.registerPath(TestContext.class, nodeTwo);
 
         /**
-         * Consumer sends message to nodeTwo for three times. Should be
-         * processed by second instance.
+         * Consumer sends message to nodeTwo for three times. Should be processed by second instance.
          */
         final RoutedSimpleRouteInput simpleRouteSecondFoo = createSimpleRouteInput(nodeTwo);
         consumerService.routedSimpleRoute(simpleRouteSecondFoo);
@@ -123,9 +120,7 @@ public class RoutedServiceIT extends AbstractIT {
         consumerService.routedSimpleRoute(simpleRouteSecondFoo);
 
         /**
-         * Verifies that second instance was invoked 3 times with second message
-         * and first instance wasn't invoked.
-         *
+         * Verifies that second instance was invoked 3 times with second message and first instance wasn't invoked.
          */
         verify(odlRoutedService2, times(3)).routedSimpleRoute(simpleRouteSecondFoo);
         verify(odlRoutedService1, times(0)).routedSimpleRoute(simpleRouteSecondFoo);
@@ -137,43 +132,36 @@ public class RoutedServiceIT extends AbstractIT {
         secondReg.registerPath(TestContext.class, nodeOnePath);
 
         /**
-         * A consumer sends third message to node 1
+         * A consumer sends third message to node 1.
          */
         final RoutedSimpleRouteInput simpleRouteThirdFoo = createSimpleRouteInput(nodeOnePath);
         consumerService.routedSimpleRoute(simpleRouteThirdFoo);
 
         /**
-         * Verifies that provider 1 wasn't invoked and provider 2 was invoked 1
-         * time.
+         * Verifies that provider 1 wasn't invoked and provider 2 was invoked 1 time.
          * TODO: fix unregister path
          */
         //verify(odlRoutedService1, times(0)).routedSimpleRoute(simpleRouteThirdFoo);
         verify(odlRoutedService2).routedSimpleRoute(simpleRouteThirdFoo);
-
     }
 
     /**
-     * Returns node reference from string which represents path
+     * Returns node reference from string which represents path.
      *
-     * @param string
-     *            string with key(path)
+     * @param string string with key(path)
      * @return instance identifier to {@link UnorderedList}
      */
     private static InstanceIdentifier<UnorderedList> createNodeRef(final String string) {
-        final UnorderedListKey key = new UnorderedListKey(string);
-        final InstanceIdentifier<UnorderedList> path = InstanceIdentifier.builder(Lists.class)
+        return InstanceIdentifier.builder(Lists.class)
                 .child(UnorderedContainer.class)
-                .child(UnorderedList.class, key)
+                .child(UnorderedList.class, new UnorderedListKey(string))
                 .build();
-
-        return path;
     }
 
     /**
-     * Creates flow AddFlowInput for which only node and cookie are set
+     * Creates flow AddFlowInput for which only node and cookie are set.
      *
-     * @param node
-     *            NodeRef value
+     * @param node NodeRef value
      * @return simpleRouteInput instance
      */
     static RoutedSimpleRouteInput createSimpleRouteInput(final InstanceIdentifier<UnorderedList> node) {
index 63d1842..15beb2d 100644 (file)
@@ -29,7 +29,7 @@ import org.ops4j.pax.exam.util.Filter;
 @RunWith(PaxExam.class)
 public class ToasterTest extends AbstractMdsalTestBase {
     @Inject
-    @Filter(timeout = 60*1000)
+    @Filter(timeout = 60 * 1000)
     KitchenService kitchenService;
 
     @Override
@@ -56,7 +56,7 @@ public class ToasterTest extends AbstractMdsalTestBase {
 
         // Make toasts using OSGi service
         success &= kitchenService.makeBreakfast(EggsType.SCRAMBLED, HashBrown.class, 4).get().isSuccessful();
-        success &= kitchenService.makeBreakfast(EggsType.POACHED, WhiteBread.class, 8 ).get().isSuccessful();
+        success &= kitchenService.makeBreakfast(EggsType.POACHED, WhiteBread.class, 8).get().isSuccessful();
 
         assertTrue("Not all breakfasts succeeded", success);
 

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.