You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@zeppelin.apache.org by "ParkGyeongTae (via GitHub)" <gi...@apache.org> on 2025/06/14 14:50:40 UTC
[PR] [ZEPPELIN-6201] Add unit tests for utils classes: ServerUtils, ExceptionUtils, CommandLineUtils, AnyOfRolesUserAuthorizationFilter [zeppelin]
ParkGyeongTae opened a new pull request, #4946:
URL: https://github.com/apache/zeppelin/pull/4946
### What is this PR for?
This PR adds missing unit test coverage for several utility classes in the `org.apache.zeppelin.utils` package.
Previously, these classes had no dedicated test cases, which limited maintainability and regression detection.
The following classes are now covered with JUnit 5 and Mockito-based tests:
- `ServerUtils`
- `ExceptionUtils`
- `CommandLineUtils`
- `AnyOfRolesUserAuthorizationFilter`
All tests follow the “Given – When – Then” format for clarity and consistency.
### What type of PR is it?
Improvement
### Todos
* [x] - Add `ServerUtilsTest`
* [x] - Add `ExceptionUtilsTest`
* [x] - Add `CommandLineUtilsTest`
* [x] - Add `AnyOfRolesUserAuthorizationFilterTest`
### What is the Jira issue?
* Jira : https://issues.apache.org/jira/browse/ZEPPELIN/ZEPPELIN-6201
### How should this be tested?
Run the following command:
```bash
./mvnw -pl zeppelin-server \
-Dtest=AnyOfRolesUserAuthorizationFilterTest,CommandLineUtilsTest,ExceptionUtilsTest,ServerUtilsTest \
test
```
### Screenshots (if appropriate)

### Questions:
* Does the license files need to update? No.
* Is there breaking changes for older versions? No.
* Does this needs documentation? No.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@zeppelin.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ZEPPELIN-6201] Add unit tests for utils classes: ServerUtils, ExceptionUtils, CommandLineUtils, AnyOfRolesUserAuthorizationFilter [zeppelin]
Posted by "Reamer (via GitHub)" <gi...@apache.org>.
Reamer commented on PR #4946:
URL: https://github.com/apache/zeppelin/pull/4946#issuecomment-3020106330
Merged into master and branch-0.12
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@zeppelin.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ZEPPELIN-6201] Add unit tests for utils classes: ServerUtils, ExceptionUtils, CommandLineUtils, AnyOfRolesUserAuthorizationFilter [zeppelin]
Posted by "ParkGyeongTae (via GitHub)" <gi...@apache.org>.
ParkGyeongTae commented on code in PR #4946:
URL: https://github.com/apache/zeppelin/pull/4946#discussion_r2175266047
##########
zeppelin-server/src/test/java/org/apache/zeppelin/utils/CommandLineUtilsTest.java:
##########
@@ -0,0 +1,91 @@
+/*
+ * 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.utils;
+
+import org.apache.zeppelin.util.Util;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * Unit tests for {@link CommandLineUtils} written in Given-When-Then style.
+ */
+class CommandLineUtilsTest {
+
+ /**
+ * Captures standard output during test execution.
+ */
+ private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
+
+ /**
+ * Original System.out kept for restoration.
+ */
+ private final PrintStream originalOut = System.out;
+
+ @AfterEach
+ void restoreStdout() {
+ // Restore the original System.out after each test
+ System.setOut(originalOut);
Review Comment:
@Reamer
I have force-pushed to remove the commit that deletes `CommandLineUtils.java`.
Once this PR is merged, I will proceed with the removal of `CommandLineUtils.java` in a separate PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@zeppelin.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ZEPPELIN-6201] Add unit tests for utils classes: ServerUtils, ExceptionUtils, CommandLineUtils, AnyOfRolesUserAuthorizationFilter [zeppelin]
Posted by "ParkGyeongTae (via GitHub)" <gi...@apache.org>.
ParkGyeongTae commented on code in PR #4946:
URL: https://github.com/apache/zeppelin/pull/4946#discussion_r2173570745
##########
zeppelin-server/src/test/java/org/apache/zeppelin/utils/CommandLineUtilsTest.java:
##########
@@ -0,0 +1,91 @@
+/*
+ * 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.utils;
+
+import org.apache.zeppelin.util.Util;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * Unit tests for {@link CommandLineUtils} written in Given-When-Then style.
+ */
+class CommandLineUtilsTest {
+
+ /**
+ * Captures standard output during test execution.
+ */
+ private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
+
+ /**
+ * Original System.out kept for restoration.
+ */
+ private final PrintStream originalOut = System.out;
+
+ @AfterEach
+ void restoreStdout() {
+ // Restore the original System.out after each test
+ System.setOut(originalOut);
Review Comment:
@Reamer
Since `CommandLineUtils.java` is not used anywhere, it has been removed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@zeppelin.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ZEPPELIN-6201] Add unit tests for utils classes: ServerUtils, ExceptionUtils, CommandLineUtils, AnyOfRolesUserAuthorizationFilter [zeppelin]
Posted by "Reamer (via GitHub)" <gi...@apache.org>.
Reamer commented on code in PR #4946:
URL: https://github.com/apache/zeppelin/pull/4946#discussion_r2175203507
##########
zeppelin-server/src/test/java/org/apache/zeppelin/utils/CommandLineUtilsTest.java:
##########
@@ -0,0 +1,91 @@
+/*
+ * 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.utils;
+
+import org.apache.zeppelin.util.Util;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * Unit tests for {@link CommandLineUtils} written in Given-When-Then style.
+ */
+class CommandLineUtilsTest {
+
+ /**
+ * Captures standard output during test execution.
+ */
+ private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
+
+ /**
+ * Original System.out kept for restoration.
+ */
+ private final PrintStream originalOut = System.out;
+
+ @AfterEach
+ void restoreStdout() {
+ // Restore the original System.out after each test
+ System.setOut(originalOut);
Review Comment:
Can you submit the removal of the `CommandLineUtils.java` class to another PR, this will result in a clean Git history.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@zeppelin.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ZEPPELIN-6201] Add unit tests for utils classes: ServerUtils, ExceptionUtils, CommandLineUtils, AnyOfRolesUserAuthorizationFilter [zeppelin]
Posted by "Reamer (via GitHub)" <gi...@apache.org>.
Reamer commented on code in PR #4946:
URL: https://github.com/apache/zeppelin/pull/4946#discussion_r2147434255
##########
zeppelin-server/src/test/java/org/apache/zeppelin/utils/CommandLineUtilsTest.java:
##########
@@ -0,0 +1,91 @@
+/*
+ * 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.utils;
+
+import org.apache.zeppelin.util.Util;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * Unit tests for {@link CommandLineUtils} written in Given-When-Then style.
+ */
+class CommandLineUtilsTest {
+
+ /**
+ * Captures standard output during test execution.
+ */
+ private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
+
+ /**
+ * Original System.out kept for restoration.
+ */
+ private final PrintStream originalOut = System.out;
+
+ @AfterEach
+ void restoreStdout() {
+ // Restore the original System.out after each test
+ System.setOut(originalOut);
Review Comment:
I don't like the use of System.out within the test at all.
##########
zeppelin-server/src/test/java/org/apache/zeppelin/utils/CommandLineUtilsTest.java:
##########
@@ -0,0 +1,91 @@
+/*
+ * 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.utils;
+
+import org.apache.zeppelin.util.Util;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * Unit tests for {@link CommandLineUtils} written in Given-When-Then style.
+ */
+class CommandLineUtilsTest {
+
+ /**
+ * Captures standard output during test execution.
+ */
+ private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
+
+ /**
+ * Original System.out kept for restoration.
+ */
+ private final PrintStream originalOut = System.out;
+
+ @AfterEach
+ void restoreStdout() {
+ // Restore the original System.out after each test
+ System.setOut(originalOut);
Review Comment:
I can't think of any use for the class `CommandLineUtils.java`. I think we should remove it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@zeppelin.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ZEPPELIN-6201] Add unit tests for utils classes: ServerUtils, ExceptionUtils, CommandLineUtils, AnyOfRolesUserAuthorizationFilter [zeppelin]
Posted by "Reamer (via GitHub)" <gi...@apache.org>.
Reamer merged PR #4946:
URL: https://github.com/apache/zeppelin/pull/4946
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@zeppelin.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ZEPPELIN-6201] Add unit tests for utils classes: ServerUtils, ExceptionUtils, CommandLineUtils, AnyOfRolesUserAuthorizationFilter [zeppelin]
Posted by "ParkGyeongTae (via GitHub)" <gi...@apache.org>.
ParkGyeongTae commented on code in PR #4946:
URL: https://github.com/apache/zeppelin/pull/4946#discussion_r2175266047
##########
zeppelin-server/src/test/java/org/apache/zeppelin/utils/CommandLineUtilsTest.java:
##########
@@ -0,0 +1,91 @@
+/*
+ * 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.utils;
+
+import org.apache.zeppelin.util.Util;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * Unit tests for {@link CommandLineUtils} written in Given-When-Then style.
+ */
+class CommandLineUtilsTest {
+
+ /**
+ * Captures standard output during test execution.
+ */
+ private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
+
+ /**
+ * Original System.out kept for restoration.
+ */
+ private final PrintStream originalOut = System.out;
+
+ @AfterEach
+ void restoreStdout() {
+ // Restore the original System.out after each test
+ System.setOut(originalOut);
Review Comment:
@Reamer
I have force-pushed to remove the commit that deletes CommandLineUtils.java.
Once this PR is merged, I will proceed with the removal of CommandLineUtils.java in a separate PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@zeppelin.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org