[BEAM-1651] Test code style
Project: http://git-wip-us.apache.org/repos/asf/beam/repo Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/329d1652 Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/329d1652 Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/329d1652 Branch: refs/heads/master Commit: 329d165253d9d3dff1069aa5f1a48144735969eb Parents: 79c9b8e Author: Aviem Zur <[email protected]> Authored: Fri Mar 10 08:04:03 2017 +0200 Committer: Davor Bonaci <[email protected]> Committed: Mon Mar 13 14:53:53 2017 -0700 ---------------------------------------------------------------------- sdks/java/build-tools/pom.xml | 31 +++++++++++++- .../beam/codestyle/CodeStyleTestClass.java | 45 ++++++++++++++++++++ 2 files changed, 75 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/beam/blob/329d1652/sdks/java/build-tools/pom.xml ---------------------------------------------------------------------- diff --git a/sdks/java/build-tools/pom.xml b/sdks/java/build-tools/pom.xml index bc4cff7..391367a 100644 --- a/sdks/java/build-tools/pom.xml +++ b/sdks/java/build-tools/pom.xml @@ -28,5 +28,34 @@ <artifactId>beam-sdks-java-build-tools</artifactId> <name>Apache Beam :: SDKs :: Java :: Build Tools</name> - + + <build> + <plugins> + <plugin> + <groupId>net.revelc.code.formatter</groupId> + <artifactId>formatter-maven-plugin</artifactId> + <version>2.0.1</version> + <executions> + <execution> + <id>test-code-style</id> + <phase>process-test-sources</phase> + <goals> + <goal>format</goal> + </goals> + <configuration> + <configFile>${project.basedir}/src/main/resources/beam/beam-codestyle.xml</configFile> + <directories> + <directory>${project.build.testSourceDirectory}</directory> + </directories> + </configuration> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-checkstyle-plugin</artifactId> + </plugin> + </plugins> + </build> </project> http://git-wip-us.apache.org/repos/asf/beam/blob/329d1652/sdks/java/build-tools/src/test/java/org/apache/beam/codestyle/CodeStyleTestClass.java ---------------------------------------------------------------------- diff --git a/sdks/java/build-tools/src/test/java/org/apache/beam/codestyle/CodeStyleTestClass.java b/sdks/java/build-tools/src/test/java/org/apache/beam/codestyle/CodeStyleTestClass.java new file mode 100644 index 0000000..15aeb4a --- /dev/null +++ b/sdks/java/build-tools/src/test/java/org/apache/beam/codestyle/CodeStyleTestClass.java @@ -0,0 +1,45 @@ +/* + * 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.beam.codestyle; + +import java.util.List; + +/** + * Class to be formatted using beam-codestyle.xml to test it is configured correctly. + */ +public class CodeStyleTestClass { + + public static MyClass withSideInputs(List<?>... sideInputs) { + return new MyClass().myMethod(sideInputs); + } + + /** + * Fake Class. + */ + public static class MyClass { + + private static final String MY_CONSTANT = ""; + + MyClass() { + } + + public MyClass myMethod(List<?>... sideInputs) { + return null; + } + } +}
