This is an automated email from the ASF dual-hosted git repository.
pdallig pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/zeppelin.git
The following commit(s) were added to refs/heads/master by this push:
new b1fbb8a492 [ZEPPELIN-5951] migrate bigquery to Junit5 (#4645)
b1fbb8a492 is described below
commit b1fbb8a4924d4335bb234bfec245a2c4af6887ae
Author: Philipp Dallig <[email protected]>
AuthorDate: Mon Sep 11 09:11:12 2023 +0200
[ZEPPELIN-5951] migrate bigquery to Junit5 (#4645)
---
.../zeppelin/bigquery/BigQueryInterpreterTest.java | 36 +++++++++-------------
.../src/{main => test}/resources/constants.json | 0
bigquery/src/test/resources/log4j.properties | 30 ++++++++++++++++++
3 files changed, 45 insertions(+), 21 deletions(-)
diff --git
a/bigquery/src/test/java/org/apache/zeppelin/bigquery/BigQueryInterpreterTest.java
b/bigquery/src/test/java/org/apache/zeppelin/bigquery/BigQueryInterpreterTest.java
index 9dcd9f8c61..630530aa94 100644
---
a/bigquery/src/test/java/org/apache/zeppelin/bigquery/BigQueryInterpreterTest.java
+++
b/bigquery/src/test/java/org/apache/zeppelin/bigquery/BigQueryInterpreterTest.java
@@ -16,16 +16,9 @@
package org.apache.zeppelin.bigquery;
-import static org.junit.Assert.assertEquals;
-
import com.google.gson.Gson;
-import com.google.gson.JsonIOException;
-import com.google.gson.JsonSyntaxException;
-
-import org.junit.Before;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Properties;
@@ -33,8 +26,11 @@ import java.util.Properties;
import org.apache.zeppelin.interpreter.InterpreterContext;
import org.apache.zeppelin.interpreter.InterpreterGroup;
import org.apache.zeppelin.interpreter.InterpreterResult;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-public class BigQueryInterpreterTest {
+class BigQueryInterpreterTest {
protected static class Constants {
private String projectId;
private String oneQuery;
@@ -55,12 +51,10 @@ public class BigQueryInterpreterTest {
protected static Constants constants = null;
- public BigQueryInterpreterTest()
- throws JsonSyntaxException, JsonIOException, FileNotFoundException {
- if (constants == null) {
- InputStream is = this.getClass().getResourceAsStream("/constants.json");
- constants = (new Gson()).<Constants>fromJson(new InputStreamReader(is),
Constants.class);
- }
+ @BeforeAll
+ public static void initConstants() {
+ InputStream is = ClassLoader.class.getResourceAsStream("/constants.json");
+ constants = (new Gson()).<Constants> fromJson(new InputStreamReader(is),
Constants.class);
}
private InterpreterGroup intpGroup;
@@ -68,7 +62,7 @@ public class BigQueryInterpreterTest {
private InterpreterContext context;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
Properties p = new Properties();
p.setProperty("zeppelin.bigquery.project_id", constants.getProjectId());
@@ -84,27 +78,27 @@ public class BigQueryInterpreterTest {
}
@Test
- public void sqlSuccess() {
+ void sqlSuccess() {
InterpreterResult ret = bqInterpreter.interpret(constants.getOne(),
context);
assertEquals(InterpreterResult.Code.SUCCESS, ret.code());
- assertEquals(ret.message().get(0).getType(), InterpreterResult.Type.TABLE);
+ assertEquals(InterpreterResult.Type.TABLE, ret.message().get(0).getType());
}
@Test
- public void badSqlSyntaxFails() {
+ void badSqlSyntaxFails() {
InterpreterResult ret = bqInterpreter.interpret(constants.getWrong(),
context);
assertEquals(InterpreterResult.Code.ERROR, ret.code());
}
@Test
- public void testWithQueryPrefix() {
+ void testWithQueryPrefix() {
InterpreterResult ret = bqInterpreter.interpret(
"#standardSQL\n WITH t AS (select 1) SELECT * FROM t", context);
assertEquals(InterpreterResult.Code.SUCCESS, ret.code());
}
@Test
- public void testInterpreterOutputData() {
+ void testInterpreterOutputData() {
InterpreterResult ret = bqInterpreter.interpret("SELECT 1 AS col1, 2 AS
col2", context);
String[] lines = ret.message().get(0).getData().split("\\n");
assertEquals(2, lines.length);
diff --git a/bigquery/src/main/resources/constants.json
b/bigquery/src/test/resources/constants.json
similarity index 100%
rename from bigquery/src/main/resources/constants.json
rename to bigquery/src/test/resources/constants.json
diff --git a/bigquery/src/test/resources/log4j.properties
b/bigquery/src/test/resources/log4j.properties
new file mode 100644
index 0000000000..b724845905
--- /dev/null
+++ b/bigquery/src/test/resources/log4j.properties
@@ -0,0 +1,30 @@
+#
+# 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.
+#
+
+# Direct log messages to stdout
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c:%L - %m%n
+#log4j.appender.stdout.layout.ConversionPattern=
+#%5p [%t] (%F:%L) - %m%n
+#%-4r [%t] %-5p %c %x - %m%n
+#
+
+# Root logger option
+log4j.rootLogger=INFO, stdout
+#log4j.logger.org.apache.zeppelin.interpreter=DEBUG