steveloughran commented on code in PR #7005:
URL: https://github.com/apache/hadoop/pull/7005#discussion_r1723150705
##########
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/protocol/datatransfer/sasl/TestCustomizedCallbackHandler.java:
##########
@@ -20,25 +20,43 @@
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hdfs.client.HdfsClientConfigKeys;
import
org.apache.hadoop.hdfs.protocol.datatransfer.sasl.SaslDataTransferServer.SaslServerCallbackHandler;
+import org.apache.hadoop.test.LambdaTestUtils;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.UnsupportedCallbackException;
-import java.util.Arrays;
+import java.io.IOException;
import java.util.List;
+import java.util.concurrent.atomic.AtomicReference;
public class TestCustomizedCallbackHandler {
public static final Logger LOG =
LoggerFactory.getLogger(TestCustomizedCallbackHandler.class);
+ static final AtomicReference<List<Callback>> LAST_CALLBACKS = new
AtomicReference<>();
+
+ static void runHandleCallbacks(Object caller, List<Callback> callbacks,
String name) {
+ LOG.info("{}: handling {} for {}", caller.getClass().getSimpleName(),
callbacks, name);
+ LAST_CALLBACKS.set(callbacks);
+ }
+
+ static void assertCallbacks(Callback[] expected) {
Review Comment:
add a javadoc explaining what it does
##########
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/protocol/datatransfer/sasl/TestCustomizedCallbackHandler.java:
##########
@@ -20,25 +20,43 @@
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hdfs.client.HdfsClientConfigKeys;
import
org.apache.hadoop.hdfs.protocol.datatransfer.sasl.SaslDataTransferServer.SaslServerCallbackHandler;
+import org.apache.hadoop.test.LambdaTestUtils;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.UnsupportedCallbackException;
-import java.util.Arrays;
+import java.io.IOException;
import java.util.List;
+import java.util.concurrent.atomic.AtomicReference;
public class TestCustomizedCallbackHandler {
public static final Logger LOG =
LoggerFactory.getLogger(TestCustomizedCallbackHandler.class);
+ static final AtomicReference<List<Callback>> LAST_CALLBACKS = new
AtomicReference<>();
+
+ static void runHandleCallbacks(Object caller, List<Callback> callbacks,
String name) {
+ LOG.info("{}: handling {} for {}", caller.getClass().getSimpleName(),
callbacks, name);
+ LAST_CALLBACKS.set(callbacks);
+ }
+
+ static void assertCallbacks(Callback[] expected) {
+ final List<Callback> computed = LAST_CALLBACKS.getAndSet(null);
+ Assert.assertNotNull(computed);
Review Comment:
I think you could do this in a single AssertJ assertion, especially lines
49-51, provides `expected` was actually a list.
```java
AssertJ.assertThat(computed)
.describedAs("computed callbacks")
.isNotNull()
.hasSameElementsAs(expected)
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]