zeppelin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zjf...@apache.org
Subject zeppelin git commit: ZEPPELIN-3149. checkstyle of beam
Date Fri, 22 Jun 2018 01:01:01 GMT
Repository: zeppelin
Updated Branches:
  refs/heads/master a7e43d600 -> fea24e228


ZEPPELIN-3149. checkstyle of beam

### What is this PR for?
Straightforward fix for the code style issue of beam module

### What type of PR is it?
[Refactoring]

### Todos
* [ ] - Task

### What is the Jira issue?
* https://issues.apache.org/jira/browse/ZEPPELIN-3149

### How should this be tested?
* CI pass

### Screenshots (if appropriate)

### Questions:
* Does the licenses files need update? No
* Is there breaking changes for older versions? No
* Does this needs documentation? No

Author: Jeff Zhang <zjffdu@apache.org>

Closes #3032 from zjffdu/ZEPPELIN-3149 and squashes the following commits:

c626bf4a9 [Jeff Zhang] ZEPPELIN-3149. checkstyle of beam


Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/fea24e22
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/fea24e22
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/fea24e22

Branch: refs/heads/master
Commit: fea24e22890b1f4d3fa84a143a3608488e79379a
Parents: a7e43d6
Author: Jeff Zhang <zjffdu@apache.org>
Authored: Tue Jun 19 10:52:28 2018 +0800
Committer: Jeff Zhang <zjffdu@apache.org>
Committed: Fri Jun 22 09:00:41 2018 +0800

----------------------------------------------------------------------
 beam/pom.xml                                    |   7 ++
 .../apache/zeppelin/beam/BeamInterpreter.java   |  15 ++-
 .../org/apache/zeppelin/beam/StaticRepl.java    |  26 ++---
 .../zeppelin/beam/BeamInterpreterTest.java      | 100 -------------------
 .../zeppelin/beam/BeamInterpreterTest.java      |  98 ++++++++++++++++++
 5 files changed, 123 insertions(+), 123 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/fea24e22/beam/pom.xml
----------------------------------------------------------------------
diff --git a/beam/pom.xml b/beam/pom.xml
index 726ec14..e82e25e 100644
--- a/beam/pom.xml
+++ b/beam/pom.xml
@@ -253,6 +253,13 @@
       <plugin>
         <artifactId>maven-resources-plugin</artifactId>
       </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-checkstyle-plugin</artifactId>
+        <configuration>
+          <skip>false</skip>
+        </configuration>
+      </plugin>
     </plugins>
   </build>
 </project>

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/fea24e22/beam/src/main/java/org/apache/zeppelin/beam/BeamInterpreter.java
----------------------------------------------------------------------
diff --git a/beam/src/main/java/org/apache/zeppelin/beam/BeamInterpreter.java b/beam/src/main/java/org/apache/zeppelin/beam/BeamInterpreter.java
index 37ccfae..24704df 100644
--- a/beam/src/main/java/org/apache/zeppelin/beam/BeamInterpreter.java
+++ b/beam/src/main/java/org/apache/zeppelin/beam/BeamInterpreter.java
@@ -17,12 +17,6 @@
 
 package org.apache.zeppelin.beam;
 
-import java.io.File;
-import java.util.Collections;
-import java.util.List;
-import java.util.Properties;
-import java.util.UUID;
-
 import org.apache.zeppelin.interpreter.Interpreter;
 import org.apache.zeppelin.interpreter.InterpreterContext;
 import org.apache.zeppelin.interpreter.InterpreterResult;
@@ -30,9 +24,14 @@ import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.File;
+import java.util.Collections;
+import java.util.List;
+import java.util.Properties;
+import java.util.UUID;
+
 /**
  * Beam interpreter
- * 
  */
 public class BeamInterpreter extends Interpreter {
 
@@ -93,7 +92,7 @@ public class BeamInterpreter extends Interpreter {
 
   @Override
   public List<InterpreterCompletion> completion(String buf, int cursor,
-      InterpreterContext interpreterContext) {
+                                                InterpreterContext interpreterContext) {
     return Collections.emptyList();
   }
 

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/fea24e22/beam/src/main/java/org/apache/zeppelin/beam/StaticRepl.java
----------------------------------------------------------------------
diff --git a/beam/src/main/java/org/apache/zeppelin/beam/StaticRepl.java b/beam/src/main/java/org/apache/zeppelin/beam/StaticRepl.java
index ed81146..b5d8356 100644
--- a/beam/src/main/java/org/apache/zeppelin/beam/StaticRepl.java
+++ b/beam/src/main/java/org/apache/zeppelin/beam/StaticRepl.java
@@ -17,6 +17,12 @@
 
 package org.apache.zeppelin.beam;
 
+import com.thoughtworks.qdox.JavaProjectBuilder;
+import com.thoughtworks.qdox.model.JavaClass;
+import com.thoughtworks.qdox.model.JavaSource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import javax.tools.Diagnostic;
 import javax.tools.DiagnosticCollector;
 import javax.tools.JavaCompiler;
@@ -24,14 +30,6 @@ import javax.tools.JavaCompiler.CompilationTask;
 import javax.tools.JavaFileObject;
 import javax.tools.SimpleJavaFileObject;
 import javax.tools.ToolProvider;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.thoughtworks.qdox.JavaProjectBuilder;
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaSource;
-
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.PrintStream;
@@ -44,9 +42,7 @@ import java.util.Arrays;
 import java.util.List;
 
 /**
- * 
  * StaticRepl for compling the java code in memory
- * 
  */
 public class StaticRepl {
   static Logger logger = LoggerFactory.getLogger(StaticRepl.class);
@@ -70,7 +66,7 @@ public class StaticRepl {
 
       for (int j = 0; j < classes.get(i).getMethods().size(); j++) {
         if (classes.get(i).getMethods().get(j).getName().equals("main") && classes.get(i)
-            .getMethods().get(j).isStatic()) {          
+            .getMethods().get(j).isStatic()) {
           mainClassName = classes.get(i).getName();
           hasMain = true;
           break;
@@ -133,12 +129,12 @@ public class StaticRepl {
       try {
 
         // creating new class loader
-        URLClassLoader classLoader = URLClassLoader.newInstance(new URL[] { new File("").toURI()
-            .toURL() });
+        URLClassLoader classLoader = URLClassLoader.newInstance(new URL[]{new File("").toURI()
+            .toURL()});
         // execute the Main method
         Class.forName(generatedClassName, true, classLoader)
-            .getDeclaredMethod("main", new Class[] { String[].class })
-            .invoke(null, new Object[] { null });
+            .getDeclaredMethod("main", new Class[]{String[].class})
+            .invoke(null, new Object[]{null});
 
         System.out.flush();
         System.err.flush();

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/fea24e22/beam/src/main/test/org/apache/zeppelin/beam/BeamInterpreterTest.java
----------------------------------------------------------------------
diff --git a/beam/src/main/test/org/apache/zeppelin/beam/BeamInterpreterTest.java b/beam/src/main/test/org/apache/zeppelin/beam/BeamInterpreterTest.java
deleted file mode 100644
index 1fef7a6..0000000
--- a/beam/src/main/test/org/apache/zeppelin/beam/BeamInterpreterTest.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * 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.zeppelin.beam;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.Properties;
-import org.apache.zeppelin.interpreter.InterpreterContext;
-import org.apache.zeppelin.interpreter.InterpreterResult;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * 
- * BeamInterpreterTest
- *
- */
-public class BeamInterpreterTest {
-
-  private static BeamInterpreter beam;
-  private static InterpreterContext context;
-
-  @BeforeClass
-  public static void setUp() {
-    Properties p = new Properties();
-    beam = new BeamInterpreter(p);
-    beam.open();
-    context = new InterpreterContext(null, null, null, null, null, null, null, null, null,
null, null,
-        null);
-  }
-
-  @AfterClass
-  public static void tearDown() {
-    beam.close();
-  }
-
-  @Test
-  public void testStaticRepl() {
-
-    StringWriter writer = new StringWriter();
-    PrintWriter out = new PrintWriter(writer);
-    out.println("public class HelloWorld {");
-    out.println("  public static void main(String args[]) {");
-    out.println("    System.out.println(\"This is in another java file\");");
-    out.println("  }");
-    out.println("}");
-    out.close();
-
-    InterpreterResult res = beam.interpret(writer.toString(), context);
-
-    assertEquals(InterpreterResult.Code.SUCCESS, res.code());
-  }
-
-  @Test
-  public void testStaticReplWithoutMain() {
-
-    StringBuffer sourceCode = new StringBuffer();
-    sourceCode.append("package org.mdkt;\n");
-    sourceCode.append("public class HelloClass {\n");
-    sourceCode.append("   public String hello() { return \"hello\"; }");
-    sourceCode.append("}");
-    InterpreterResult res = beam.interpret(sourceCode.toString(), context);
-    assertEquals(InterpreterResult.Code.ERROR, res.code());
-  }
-
-  @Test
-  public void testStaticReplWithSyntaxError() {
-
-    StringWriter writer = new StringWriter();
-    PrintWriter out = new PrintWriter(writer);
-    out.println("public class HelloWorld {");
-    out.println("  public static void main(String args[]) {");
-    out.println("    System.out.prin(\"This is in another java file\");");
-    out.println("  }");
-    out.println("}");
-    out.close();
-    InterpreterResult res = beam.interpret(writer.toString(), context);
-
-    assertEquals(InterpreterResult.Code.ERROR, res.code());
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/fea24e22/beam/src/test/org/apache/zeppelin/beam/BeamInterpreterTest.java
----------------------------------------------------------------------
diff --git a/beam/src/test/org/apache/zeppelin/beam/BeamInterpreterTest.java b/beam/src/test/org/apache/zeppelin/beam/BeamInterpreterTest.java
new file mode 100644
index 0000000..d1c56ee
--- /dev/null
+++ b/beam/src/test/org/apache/zeppelin/beam/BeamInterpreterTest.java
@@ -0,0 +1,98 @@
+/*
+ * 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.zeppelin.beam;
+
+import org.apache.zeppelin.interpreter.InterpreterContext;
+import org.apache.zeppelin.interpreter.InterpreterResult;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Properties;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * BeamInterpreterTest
+ */
+public class BeamInterpreterTest {
+
+  private static BeamInterpreter beam;
+  private static InterpreterContext context;
+
+  @BeforeClass
+  public static void setUp() {
+    Properties p = new Properties();
+    beam = new BeamInterpreter(p);
+    beam.open();
+    context = InterpreterContext.builder().build();
+  }
+
+  @AfterClass
+  public static void tearDown() {
+    beam.close();
+  }
+
+  @Test
+  public void testStaticRepl() {
+
+    StringWriter writer = new StringWriter();
+    PrintWriter out = new PrintWriter(writer);
+    out.println("public class HelloWorld {");
+    out.println("  public static void main(String args[]) {");
+    out.println("    System.out.println(\"This is in another java file\");");
+    out.println("  }");
+    out.println("}");
+    out.close();
+
+    InterpreterResult res = beam.interpret(writer.toString(), context);
+
+    assertEquals(InterpreterResult.Code.SUCCESS, res.code());
+  }
+
+  @Test
+  public void testStaticReplWithoutMain() {
+
+    StringBuffer sourceCode = new StringBuffer();
+    sourceCode.append("package org.mdkt;\n");
+    sourceCode.append("public class HelloClass {\n");
+    sourceCode.append("   public String hello() { return \"hello\"; }");
+    sourceCode.append("}");
+    InterpreterResult res = beam.interpret(sourceCode.toString(), context);
+    assertEquals(InterpreterResult.Code.ERROR, res.code());
+  }
+
+  @Test
+  public void testStaticReplWithSyntaxError() {
+
+    StringWriter writer = new StringWriter();
+    PrintWriter out = new PrintWriter(writer);
+    out.println("public class HelloWorld {");
+    out.println("  public static void main(String args[]) {");
+    out.println("    System.out.prin(\"This is in another java file\");");
+    out.println("  }");
+    out.println("}");
+    out.close();
+    InterpreterResult res = beam.interpret(writer.toString(), context);
+
+    assertEquals(InterpreterResult.Code.ERROR, res.code());
+  }
+
+}


Mime
View raw message