You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by ij...@apache.org on 2022/12/28 14:42:34 UTC

[kafka] branch trunk updated: KAFKA-14554: Move ClassLoaderAwareRemoteStorageManagerTest to storage module (#13048)

This is an automated email from the ASF dual-hosted git repository.

ijuma pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 9f026dee6b4 KAFKA-14554: Move ClassLoaderAwareRemoteStorageManagerTest to storage module (#13048)
9f026dee6b4 is described below

commit 9f026dee6b4e1475f9be0e617bb09d8ea84ad353
Author: Federico Valeri <fe...@gmail.com>
AuthorDate: Wed Dec 28 15:42:26 2022 +0100

    KAFKA-14554: Move ClassLoaderAwareRemoteStorageManagerTest to storage module (#13048)
    
    Reviewers: Ismael Juma <is...@juma.me.uk>
---
 .../ClassLoaderAwareRemoteStorageManagerTest.scala | 45 ---------------------
 .../ClassLoaderAwareRemoteStorageManagerTest.java  | 46 ++++++++++++++++++++++
 2 files changed, 46 insertions(+), 45 deletions(-)

diff --git a/core/src/test/scala/kafka/log/remote/ClassLoaderAwareRemoteStorageManagerTest.scala b/core/src/test/scala/kafka/log/remote/ClassLoaderAwareRemoteStorageManagerTest.scala
deleted file mode 100644
index 54d0aee9447..00000000000
--- a/core/src/test/scala/kafka/log/remote/ClassLoaderAwareRemoteStorageManagerTest.scala
+++ /dev/null
@@ -1,45 +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 kafka.log.remote
-
-import org.apache.kafka.server.log.remote.storage.{ClassLoaderAwareRemoteStorageManager, RemoteStorageManager}
-import org.junit.jupiter.api.Test
-import org.mockito.Mockito.mock
-import org.mockito.Mockito.when
-import org.junit.jupiter.api.Assertions.assertEquals
-import org.junit.jupiter.api.Assertions.assertNotEquals
-import org.mockito.ArgumentMatchers.any
-
-import java.util.Collections
-
-class ClassLoaderAwareRemoteStorageManagerTest {
-
-  @Test
-  def testWithClassLoader(): Unit = {
-    val dummyClassLoader = new DummyClassLoader()
-    val delegate = mock(classOf[RemoteStorageManager])
-    val rsm = new ClassLoaderAwareRemoteStorageManager(delegate, dummyClassLoader)
-    when(delegate.configure(any())).thenAnswer(_ =>
-      assertEquals(dummyClassLoader, Thread.currentThread().getContextClassLoader))
-
-    assertNotEquals(dummyClassLoader, Thread.currentThread().getContextClassLoader)
-    rsm.configure(Collections.emptyMap())
-    assertNotEquals(dummyClassLoader, Thread.currentThread().getContextClassLoader)
-  }
-
-  private class DummyClassLoader extends ClassLoader
-}
diff --git a/storage/src/test/java/org/apache/kafka/server/log/remote/storage/ClassLoaderAwareRemoteStorageManagerTest.java b/storage/src/test/java/org/apache/kafka/server/log/remote/storage/ClassLoaderAwareRemoteStorageManagerTest.java
new file mode 100644
index 00000000000..f53a511b160
--- /dev/null
+++ b/storage/src/test/java/org/apache/kafka/server/log/remote/storage/ClassLoaderAwareRemoteStorageManagerTest.java
@@ -0,0 +1,46 @@
+/*
+ * 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.kafka.server.log.remote.storage;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.Collections;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.mock;
+
+public class ClassLoaderAwareRemoteStorageManagerTest {
+    @Test
+    public void testWithClassLoader() {
+        final DummyClassLoader dummyClassLoader = new DummyClassLoader();
+        final RemoteStorageManager delegate = mock(RemoteStorageManager.class);
+        final ClassLoaderAwareRemoteStorageManager rsm = new ClassLoaderAwareRemoteStorageManager(delegate, dummyClassLoader);
+        doAnswer(invocation -> {
+            assertEquals(dummyClassLoader, Thread.currentThread().getContextClassLoader());
+            return null;
+        }).when(delegate).configure(any());
+
+        assertNotEquals(dummyClassLoader, Thread.currentThread().getContextClassLoader());
+        rsm.configure(Collections.emptyMap());
+        assertNotEquals(dummyClassLoader, Thread.currentThread().getContextClassLoader());
+    }
+
+    private static class DummyClassLoader extends ClassLoader { }
+}