From d8514c6bef58fefc2afff7f2e4b4dba3633085d1 Mon Sep 17 00:00:00 2001 From: Maros Marsalek Date: Fri, 10 Jun 2016 15:56:09 +0200 Subject: Enable checkstyle Change-Id: Icb7ba90e26294b227d0bd393183ba33d99c2660b Signed-off-by: Maros Marsalek --- common/api-parent/pom.xml | 81 +++++++++++++++++++--- common/impl-parent/pom.xml | 78 ++++++++++++++++++--- .../SubInterfaceInitializationUtils.java | 15 ++++ .../v3po/interfaces/RewriteCustomizer.java | 20 +++--- .../v3po/interfaces/SubInterfaceCustomizer.java | 25 ++++--- .../translate/v3po/interfaces/TapCustomizer.java | 2 +- .../v3po/interfaces/VxlanGpeCustomizer.java | 2 +- .../v3po/interfacesstate/InterfaceCustomizer.java | 2 +- .../v3po/interfacesstate/RewriteCustomizer.java | 2 +- .../interfaces/SubInterfaceCustomizerTest.java | 17 +---- .../v3po/interfaces/VxlanGpeCustomizerTest.java | 13 ++-- .../v3po/vpp/data/init/RestoringInitializer.java | 2 +- .../translate/v3po/util/TagRewriteOperation.java | 15 ++++ 13 files changed, 206 insertions(+), 68 deletions(-) diff --git a/common/api-parent/pom.xml b/common/api-parent/pom.xml index 0a37c7918..d4f77cd7f 100644 --- a/common/api-parent/pom.xml +++ b/common/api-parent/pom.xml @@ -30,20 +30,79 @@ api-parent 1.0.0-SNAPSHOT pom + - + + + + maven-checkstyle-plugin + + + honeycomb-checkstyle.xml + true + + + + + + + check-license + + check + + process-sources + + HONEYCOMB_LICENSE.txt + true + true + ${project.build.directory}/checkstyle-license-result.xml + + + + + + check-logging + + check + + process-sources + + true + honeycomb-checkstyle-logging.xml + true + true + ${project.basedir} + **\/*.java,**\/*.xml,**\/*.ini,**\/*.sh,**\/*.bat,**\/*.yang + **\/target\/,**\/bin\/,**\/target-ide\/,**\/src/main/yang-gen-config\/,**\/src/main/yang-gen-sal\/,**\/src/main/xtend-gen\/,**\/src/main/yang\/ + ${project.build.directory}/checkstyle-logging-result.xml + + + + + check + + process-sources + + + + + io.fd.honeycomb.common + honeycomb-checkstyle + ${project.version} + + + + org.opendaylight.yangtools + checkstyle-logging + ${yangtools.version} + + + + + + maven-checkstyle-plugin - ${checkstyle.version} - - - check-license - - check - - none - - org.apache.maven.plugins diff --git a/common/impl-parent/pom.xml b/common/impl-parent/pom.xml index b8672ef0e..b1717a202 100644 --- a/common/impl-parent/pom.xml +++ b/common/impl-parent/pom.xml @@ -35,19 +35,77 @@ + + + + maven-checkstyle-plugin + + + honeycomb-checkstyle.xml + true + + + + + + + check-license + + check + + process-sources + + HONEYCOMB_LICENSE.txt + true + true + ${project.build.directory}/checkstyle-license-result.xml + + + + + + check-logging + + check + + process-sources + + true + honeycomb-checkstyle-logging.xml + true + true + ${project.basedir} + **\/*.java,**\/*.xml,**\/*.ini,**\/*.sh,**\/*.bat,**\/*.yang + **\/target\/,**\/bin\/,**\/target-ide\/,**\/src/main/yang-gen-config\/,**\/src/main/yang-gen-sal\/,**\/src/main/xtend-gen\/,**\/src/main/yang\/ + ${project.build.directory}/checkstyle-logging-result.xml + + + + + check + + process-sources + + + + + io.fd.honeycomb.common + honeycomb-checkstyle + ${project.version} + + + + org.opendaylight.yangtools + checkstyle-logging + ${yangtools.version} + + + + + maven-checkstyle-plugin - ${checkstyle.version} - - - check-license - - check - - none - - org.apache.maven.plugins diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/initializers/SubInterfaceInitializationUtils.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/initializers/SubInterfaceInitializationUtils.java index b31545f6b..76caf16c0 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/initializers/SubInterfaceInitializationUtils.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/initializers/SubInterfaceInitializationUtils.java @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * + * Licensed 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 io.fd.honeycomb.v3po.translate.v3po.initializers; import com.google.common.collect.Lists; diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/RewriteCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/RewriteCustomizer.java index f07d163b4..eec941c1d 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/RewriteCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/RewriteCustomizer.java @@ -16,12 +16,21 @@ package io.fd.honeycomb.v3po.translate.v3po.interfaces; +import static io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils.booleanToByte; + import com.google.common.base.Optional; import com.google.common.base.Preconditions; import io.fd.honeycomb.v3po.translate.spi.write.ChildWriterCustomizer; -import io.fd.honeycomb.v3po.translate.v3po.util.*; +import io.fd.honeycomb.v3po.translate.v3po.util.FutureJVppCustomizer; +import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext; +import io.fd.honeycomb.v3po.translate.v3po.util.SubInterfaceUtils; +import io.fd.honeycomb.v3po.translate.v3po.util.TagRewriteOperation; +import io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils; import io.fd.honeycomb.v3po.translate.write.WriteContext; import io.fd.honeycomb.v3po.translate.write.WriteFailedException; +import java.util.List; +import java.util.concurrent.CompletionStage; +import javax.annotation.Nonnull; import org.apache.commons.lang3.builder.ReflectionToStringBuilder; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527._802dot1q; @@ -39,20 +48,13 @@ import org.openvpp.jvpp.future.FutureJVpp; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.annotation.Nonnull; -import java.util.List; -import java.util.concurrent.CompletionStage; - -import static io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils.booleanToByte; - /** * Writer Customizer responsible for vlan tag rewrite.
Sends {@code l2_interface_vlan_tag_rewrite} message to * VPP.
Equivalent of invoking {@code vppctl set interface l2 tag-rewrite} command. */ public class RewriteCustomizer extends FutureJVppCustomizer implements ChildWriterCustomizer { - private static final Logger LOG = LoggerFactory.getLogger( - io.fd.honeycomb.v3po.translate.v3po.interfacesstate.RewriteCustomizer.class); + private static final Logger LOG = LoggerFactory.getLogger(RewriteCustomizer.class); private final NamingContext interfaceContext; public RewriteCustomizer(@Nonnull final FutureJVpp futureJvpp, diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/SubInterfaceCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/SubInterfaceCustomizer.java index 7d24fdd7b..3b3f6f629 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/SubInterfaceCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/SubInterfaceCustomizer.java @@ -16,6 +16,10 @@ package io.fd.honeycomb.v3po.translate.v3po.interfaces; +import static com.google.common.base.Preconditions.checkState; +import static io.fd.honeycomb.v3po.translate.v3po.util.SubInterfaceUtils.getSubInterfaceName; +import static io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils.booleanToByte; + import com.google.common.base.Optional; import com.google.common.base.Preconditions; import io.fd.honeycomb.v3po.translate.spi.write.ListWriterCustomizer; @@ -24,6 +28,11 @@ import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext; import io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils; import io.fd.honeycomb.v3po.translate.write.WriteContext; import io.fd.honeycomb.v3po.translate.write.WriteFailedException; +import java.util.List; +import java.util.Objects; +import java.util.concurrent.CompletionStage; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; import org.opendaylight.yang.gen.v1.urn.ieee.params.xml.ns.yang.dot1q.types.rev150626.CVlan; import org.opendaylight.yang.gen.v1.urn.ieee.params.xml.ns.yang.dot1q.types.rev150626.Dot1qVlanId; import org.opendaylight.yang.gen.v1.urn.ieee.params.xml.ns.yang.dot1q.types.rev150626.SVlan; @@ -49,16 +58,6 @@ import org.openvpp.jvpp.future.FutureJVpp; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.util.List; -import java.util.Objects; -import java.util.concurrent.CompletionStage; - -import static com.google.common.base.Preconditions.checkState; -import static io.fd.honeycomb.v3po.translate.v3po.util.SubInterfaceUtils.getSubInterfaceName; -import static io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils.booleanToByte; - /** * Writer Customizer responsible for sub interface creation.
Sends {@code create_subif} message to VPP.
* Equivalent of invoking {@code vppclt create subif} command. @@ -213,11 +212,11 @@ public class SubInterfaceCustomizer extends FutureJVppCustomizer final CompletionStage swInterfaceSetFlagsReplyFuture = getFutureJVpp().swInterfaceSetFlags(swInterfaceSetFlags); - LOG.debug("Updating interface state for: interface if={}, enabled: {}", swIfIndex, enabled); + LOG.debug("Updating interface state for interface if={}, enabled: {}", swIfIndex, enabled); SwInterfaceSetFlagsReply reply = TranslateUtils.getReply(swInterfaceSetFlagsReplyFuture.toCompletableFuture()); - LOG.debug("Interface state updated successfully for: {}, index: {}, enabled: {}, ctxId: {}", - swIfIndex, enabled, reply.context); + LOG.debug("Interface state updated successfully for interface index: {}, enabled: {}, ctxId: {}", + swIfIndex, enabled, reply.context); } @Override diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/TapCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/TapCustomizer.java index 2046caf1f..e26ed4534 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/TapCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/TapCustomizer.java @@ -110,7 +110,7 @@ public class TapCustomizer extends AbstractInterfaceTypeCustomizer { try { deleteTap(ifcName, index, dataBefore, writeContext); } catch (VppBaseCallException e) { - LOG.warn("Failed to delete tap interface: {}, tap: {}", ifcName, e); + LOG.warn("Failed to delete tap interface: {}, tap: {}", ifcName, dataBefore.getTapName(), e); throw new WriteFailedException.DeleteFailedException(id, e); } } diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanGpeCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanGpeCustomizer.java index 216d354b4..0a6746807 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanGpeCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanGpeCustomizer.java @@ -167,7 +167,7 @@ public class VxlanGpeCustomizer extends AbstractInterfaceTypeCustomizer { - private static final Logger LOG = LoggerFactory.getLogger(SubInterfaceCustomizer.class); + private static final Logger LOG = LoggerFactory.getLogger(RewriteCustomizer.class); private final NamingContext interfaceContext; public RewriteCustomizer(@Nonnull final FutureJVpp futureJvpp, diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/SubInterfaceCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/SubInterfaceCustomizerTest.java index 5ed37aa40..7161218a0 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/SubInterfaceCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/SubInterfaceCustomizerTest.java @@ -19,6 +19,7 @@ package io.fd.honeycomb.v3po.translate.v3po.interfaces; import static io.fd.honeycomb.v3po.translate.v3po.test.ContextTestUtils.getMapping; import static io.fd.honeycomb.v3po.translate.v3po.test.ContextTestUtils.getMappingIid; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.Matchers.any; import static org.mockito.Matchers.eq; @@ -67,24 +68,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.base.attributes.tags.TagKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.openvpp.jvpp.VppBaseCallException; -import org.openvpp.jvpp.VppInvocationException; import org.openvpp.jvpp.dto.CreateSubif; import org.openvpp.jvpp.dto.CreateSubifReply; import org.openvpp.jvpp.dto.SwInterfaceSetFlags; import org.openvpp.jvpp.dto.SwInterfaceSetFlagsReply; import org.openvpp.jvpp.future.FutureJVpp; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.*; -import static org.mockito.MockitoAnnotations.initMocks; - public class SubInterfaceCustomizerTest { @Mock @@ -186,7 +175,7 @@ public class SubInterfaceCustomizerTest { private void whenCreateSubifFailedThen(final int retval) throws ExecutionException, InterruptedException, VppBaseCallException { doReturn(TestHelperUtils.createFutureException(retval)).when(api).createSubif(any(CreateSubif.class)); } - + private void whenSwInterfaceSetFlagsThen(final int retval) throws ExecutionException, InterruptedException, VppBaseCallException { final CompletableFuture replyFuture = new CompletableFuture<>(); final SwInterfaceSetFlagsReply reply = new SwInterfaceSetFlagsReply(); @@ -201,7 +190,7 @@ public class SubInterfaceCustomizerTest { private void whenCreateSubifThenFailure() throws ExecutionException, InterruptedException, VppBaseCallException { whenCreateSubifFailedThen(-1); } - + private void whenSwInterfaceSetFlagsThenSuccess() throws ExecutionException, InterruptedException, VppBaseCallException { whenSwInterfaceSetFlagsThen(0); } diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanGpeCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanGpeCustomizerTest.java index 77404aa45..2ad831f9f 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanGpeCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanGpeCustomizerTest.java @@ -19,7 +19,10 @@ package io.fd.honeycomb.v3po.translate.v3po.interfaces; import static io.fd.honeycomb.v3po.translate.v3po.test.ContextTestUtils.getMapping; import static io.fd.honeycomb.v3po.translate.v3po.test.ContextTestUtils.getMappingIid; import static java.util.Collections.singletonList; -import static org.junit.Assert.*; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import static org.mockito.Matchers.any; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doReturn; @@ -53,14 +56,12 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces. import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppInterfaceAugmentation; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VxlanGpeVni; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VxlanGpeNextProtocol; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VxlanGpeVni; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.VxlanGpe; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.VxlanGpeBuilder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.openvpp.jvpp.VppBaseCallException; -import org.openvpp.jvpp.VppInvocationException; -import org.openvpp.jvpp.dto.VxlanAddDelTunnel; import org.openvpp.jvpp.dto.VxlanAddDelTunnelReply; import org.openvpp.jvpp.dto.VxlanGpeAddDelTunnel; import org.openvpp.jvpp.dto.VxlanGpeAddDelTunnelReply; @@ -134,7 +135,7 @@ public class VxlanGpeCustomizerTest { assertEquals(vxlanGpe.getVni().getValue().intValue(), actual.vni); assertEquals(vxlanGpe.getNextProtocol().getIntValue(), actual.protocol); assertEquals(vxlanGpe.getEncapVrfId().intValue(), actual.encapVrfId); - assertEquals(vxlanGpe.getDecapVrfId().intValue(), actual.decapVrfId); + assertEquals(vxlanGpe.getDecapVrfId().intValue(), actual.decapVrfId); return actual; } private void verifyVxlanGpeAddWasInvoked(final VxlanGpe vxlanGpe) throws VppBaseCallException{ @@ -154,7 +155,7 @@ public class VxlanGpeCustomizerTest { builder.setVni(new VxlanGpeVni(Long.valueOf(vni))); builder.setNextProtocol(VxlanGpeNextProtocol.forValue(1)); builder.setEncapVrfId(Long.valueOf(123)); - builder.setDecapVrfId(Long.valueOf(456)); + builder.setDecapVrfId(Long.valueOf(456)); return builder.build(); } diff --git a/v3po/vpp-cfg-init/src/main/java/io/fd/honeycomb/v3po/vpp/data/init/RestoringInitializer.java b/v3po/vpp-cfg-init/src/main/java/io/fd/honeycomb/v3po/vpp/data/init/RestoringInitializer.java index ff3dc1087..abc3f54c0 100644 --- a/v3po/vpp-cfg-init/src/main/java/io/fd/honeycomb/v3po/vpp/data/init/RestoringInitializer.java +++ b/v3po/vpp-cfg-init/src/main/java/io/fd/honeycomb/v3po/vpp/data/init/RestoringInitializer.java @@ -38,7 +38,7 @@ import org.slf4j.LoggerFactory; public class RestoringInitializer implements DataTreeInitializer { - private static final Logger LOG = LoggerFactory.getLogger(InitializerRegistryImpl.class); + private static final Logger LOG = LoggerFactory.getLogger(RestoringInitializer.class); private final SchemaService schemaService; private final Path path; diff --git a/v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util/TagRewriteOperation.java b/v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util/TagRewriteOperation.java index 8609207b6..316d1f8e2 100644 --- a/v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util/TagRewriteOperation.java +++ b/v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util/TagRewriteOperation.java @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * + * Licensed 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 io.fd.honeycomb.v3po.translate.v3po.util; import com.google.common.base.Preconditions; -- cgit 1.2.3-korg