This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new f4e34c33907 Remove ClassLoaderContextTest (#37468)
f4e34c33907 is described below
commit f4e34c33907ccc5241bc251930a39f0821d6fae4
Author: Liang Zhang <[email protected]>
AuthorDate: Tue Dec 23 14:49:26 2025 +0800
Remove ClassLoaderContextTest (#37468)
---
.../plugin/classloader/ClassLoaderContextTest.java | 64 ----------------------
1 file changed, 64 deletions(-)
diff --git
a/agent/core/src/test/java/org/apache/shardingsphere/agent/core/plugin/classloader/ClassLoaderContextTest.java
b/agent/core/src/test/java/org/apache/shardingsphere/agent/core/plugin/classloader/ClassLoaderContextTest.java
deleted file mode 100644
index ab2685941b8..00000000000
---
a/agent/core/src/test/java/org/apache/shardingsphere/agent/core/plugin/classloader/ClassLoaderContextTest.java
+++ /dev/null
@@ -1,64 +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.shardingsphere.agent.core.plugin.classloader;
-
-import lombok.SneakyThrows;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.Test;
-import org.mockito.internal.configuration.plugins.Plugins;
-
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.Collections;
-import java.util.Map;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class ClassLoaderContextTest {
-
- @AfterEach
- void cleanAgentClassLoaders() {
- getAgentClassLoaders().clear();
- }
-
- @Test
- void assertCreatePluginClassLoaderWhenAbsent() {
- ClassLoader appClassLoader = new URLClassLoader(new URL[0], null);
- AgentPluginClassLoader actual = new ClassLoaderContext(appClassLoader,
Collections.emptyList()).getPluginClassLoader();
- Map<ClassLoader, AgentPluginClassLoader> agentClassLoaders =
getAgentClassLoaders();
- assertThat(agentClassLoaders.size(), is(1));
- assertThat(actual, is(agentClassLoaders.get(appClassLoader)));
- }
-
- @Test
- void assertReuseExistingPluginClassLoader() {
- ClassLoader appClassLoader = new URLClassLoader(new URL[0], null);
- AgentPluginClassLoader expected = new
AgentPluginClassLoader(appClassLoader, Collections.emptyList());
- Map<ClassLoader, AgentPluginClassLoader> agentClassLoaders =
getAgentClassLoaders();
- agentClassLoaders.put(appClassLoader, expected);
- AgentPluginClassLoader actual = new ClassLoaderContext(appClassLoader,
Collections.emptyList()).getPluginClassLoader();
- assertThat(actual, is(expected));
- }
-
- @SuppressWarnings("unchecked")
- @SneakyThrows(ReflectiveOperationException.class)
- private Map<ClassLoader, AgentPluginClassLoader> getAgentClassLoaders() {
- return (Map<ClassLoader, AgentPluginClassLoader>)
Plugins.getMemberAccessor().get(ClassLoaderContext.class.getDeclaredField("AGENT_CLASS_LOADERS"),
null);
- }
-}