You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by xi...@apache.org on 2022/07/01 08:41:02 UTC

[incubator-shenyu] branch master updated: [type:refactor] optimize logging-elasticsearch&rocketmq unit test (#3642)

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

xiaoyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-shenyu.git


The following commit(s) were added to refs/heads/master by this push:
     new 8d89424ad [type:refactor] optimize logging-elasticsearch&rocketmq unit test (#3642)
8d89424ad is described below

commit 8d89424ad6cc45c67cd98360894938dd904c25ad
Author: qinghai777 <80...@users.noreply.github.com>
AuthorDate: Fri Jul 1 16:40:55 2022 +0800

    [type:refactor] optimize logging-elasticsearch&rocketmq unit test (#3642)
    
    * optimize logging-elasticsearch&rocketmq unit test
    
    * optimize logging-elasticsearch&rocketmq unit test again
---
 .../shenyu-plugin-logging-elasticsearch/pom.xml    |   5 +
 .../logging/elasticsearch/body/BodyWriterTest.java |   8 +-
 ...LoggingElasticSearchServerHttpResponseTest.java | 108 ++++++++++++++++-----
 .../elasticsearch/config/LogCollectConfigTest.java |  15 +++
 .../elasticsearch/entity/ShenyuRequestLogTest.java |  42 ++++++++
 .../LoggingElasticSearchPluginDataHandlerTest.java |   8 --
 .../utils/LogCollectConfigUtilsTest.java           |  36 ++++---
 .../logging/rocketmq/body/BodyWriterTest.java      |   8 +-
 .../body/LoggingServerHttpResponseTest.java        | 106 ++++++++++++++++----
 .../client/RocketMQLogCollectClientTest.java       |  90 -----------------
 .../rocketmq/config/LogCollectConfigTest.java      |  15 +++
 .../rocketmq/entity/ShenyuRequestLogTest.java      |  42 ++++++++
 .../LoggingRocketMQPluginDataHandlerTest.java      |   8 --
 .../rocketmq/utils/LogCollectConfigUtilsTest.java  |  47 ++++-----
 14 files changed, 354 insertions(+), 184 deletions(-)

diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/pom.xml b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/pom.xml
index 23897f460..07b24d15b 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/pom.xml
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/pom.xml
@@ -61,6 +61,11 @@
             <artifactId>jakarta.json-api</artifactId>
             <version>${jakarta.json-api.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-test</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
 </project>
\ No newline at end of file
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/src/test/java/org/apache/shenyu/plugin/logging/elasticsearch/body/BodyWriterTest.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/src/test/java/org/apache/shenyu/plugin/logging/elasticsearch/body/BodyWriterTest.java
index 2277e34f9..3eaff9e8c 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/src/test/java/org/apache/shenyu/plugin/logging/elasticsearch/body/BodyWriterTest.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/src/test/java/org/apache/shenyu/plugin/logging/elasticsearch/body/BodyWriterTest.java
@@ -22,7 +22,9 @@ import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
 import java.io.UnsupportedEncodingException;
+import java.lang.reflect.Field;
 import java.nio.ByteBuffer;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 /**
  * The Test Case For BodyWriter.
@@ -43,11 +45,15 @@ public final class BodyWriterTest {
     }
 
     @Test
-    public void testWrite() throws UnsupportedEncodingException {
+    public void testWrite() throws Exception {
         ByteBuffer byteBuffer = ByteBuffer.wrap(sendString.getBytes("UTF-8"));
+        Field field = writer.getClass().getDeclaredField("isClosed");
+        field.setAccessible(true);
+        AtomicBoolean isClosed = (AtomicBoolean) field.get(writer);
         writer.write(byteBuffer.asReadOnlyBuffer());
         String res = writer.output();
         Assertions.assertEquals(res, "hello, shenyu");
+        Assertions.assertEquals(isClosed.toString(), "true");
     }
 
     @Test
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/src/test/java/org/apache/shenyu/plugin/logging/elasticsearch/body/LoggingElasticSearchServerHttpResponseTest.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/src/test/java/org/apache/shenyu/plugin/logging/elasticsearch/body/LoggingElasticSearchServerHttpResponseTest.java
index 1ac65003e..a7934fe8d 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/src/test/java/org/apache/shenyu/plugin/logging/elasticsearch/body/LoggingElasticSearchServerHttpResponseTest.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/src/test/java/org/apache/shenyu/plugin/logging/elasticsearch/body/LoggingElasticSearchServerHttpResponseTest.java
@@ -34,17 +34,20 @@ import org.mockito.Mockito;
 import org.springframework.context.ConfigurableApplicationContext;
 import org.springframework.http.server.reactive.ServerHttpRequest;
 import org.springframework.mock.http.server.reactive.MockServerHttpRequest;
+import org.springframework.mock.http.server.reactive.MockServerHttpResponse;
 import org.springframework.mock.web.server.MockServerWebExchange;
 import org.springframework.web.server.ServerWebExchange;
 
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.net.InetSocketAddress;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.nio.ByteBuffer;
 import java.time.LocalDateTime;
 
 /**
- * The Test Case For LoggingServerHttpResponse.
+ * The Test Case For LoggingElasticSearchServerHttpResponse.
  */
 public final class LoggingElasticSearchServerHttpResponseTest {
 
@@ -62,8 +65,10 @@ public final class LoggingElasticSearchServerHttpResponseTest {
 
     private LocalDateTime startDateTime = LocalDateTime.now();
 
+    private MockServerHttpResponse response;
+
     @BeforeEach
-    public void setUp() {
+    public void setUp() throws URISyntaxException {
         MockServerHttpRequest request = MockServerHttpRequest
                 .post("localhost")
                 .remoteAddress(new InetSocketAddress(8090))
@@ -79,11 +84,11 @@ public final class LoggingElasticSearchServerHttpResponseTest {
         this.exchange = Mockito.spy(MockServerWebExchange.from(request));
         Mockito.lenient().when(context.getBean(RemoteAddressResolver.class)).thenReturn(remoteAddressResolver);
         Mockito.lenient().when(context.getBean(ShenyuResult.class)).thenReturn(shenyuResult);
-        ShenyuContext shenyuContext = new ShenyuContext();
-        shenyuContext.setStartDateTime(startDateTime);
-        exchange.getAttributes().put(Constants.CONTEXT, shenyuContext);
+        ShenyuContext shenyuContext1 = new ShenyuContext();
+        shenyuContext1.setStartDateTime(startDateTime);
+        shenyuContext1.setMethod("test");
+        exchange.getAttributes().put(Constants.CONTEXT, shenyuContext1);
         exchange.getAttributes().put(LoggingConstant.SHENYU_AGENT_TRACE_ID, "shenyu-agent-trace-id");
-        exchange.getAttributes().put(Constants.HTTP_DOMAIN, "http://localhost:9195/http/order/path/123/name");
         this.serverHttpRequest = exchange.getRequest();
         requestInfo.setRequestUri(serverHttpRequest.getURI().toString());
         requestInfo.setMethod(serverHttpRequest.getMethodValue());
@@ -94,10 +99,21 @@ public final class LoggingElasticSearchServerHttpResponseTest {
         requestInfo.setHost(serverHttpRequest.getHeaders().getFirst(host));
         requestInfo.setPath(serverHttpRequest.getURI().getPath());
         this.loggingElasticSearchServerResponse = new LoggingElasticSearchServerResponse(exchange.getResponse(), requestInfo, DefaultLogCollector.getInstance());
+        response = new MockServerHttpResponse();
     }
 
     @Test
-    public void testSetExchange() throws NoSuchFieldException, IllegalAccessException {
+    public void testWriteWith() throws Exception {
+        loggingElasticSearchServerResponse.setExchange(exchange);
+        loggingElasticSearchServerResponse.writeWith(response.getBody());
+        Field field = loggingElasticSearchServerResponse.getClass().getDeclaredField("logInfo");
+        field.setAccessible(true);
+        ShenyuRequestLog logInfo = (ShenyuRequestLog) field.get(loggingElasticSearchServerResponse);
+        Assertions.assertEquals(logInfo.getResponseHeader(), "{}");
+    }
+
+    @Test
+    public void testSetExchange() throws Exception {
         loggingElasticSearchServerResponse.setExchange(exchange);
         Field field = loggingElasticSearchServerResponse.getClass().getDeclaredField("exchange");
         field.setAccessible(true);
@@ -117,23 +133,58 @@ public final class LoggingElasticSearchServerHttpResponseTest {
     @Test
     public void testGetUpstreamIp() throws Exception {
         loggingElasticSearchServerResponse.setExchange(exchange);
-        Method method = loggingElasticSearchServerResponse.getClass().getDeclaredMethod("getUpstreamIp");
-        method.setAccessible(true);
-        String upstreamIp = (String) method.invoke(loggingElasticSearchServerResponse);
-        Assertions.assertEquals(upstreamIp, "localhost");
+        Method method1 = loggingElasticSearchServerResponse.getClass().getDeclaredMethod("getUpstreamIp");
+        method1.setAccessible(true);
+        String upstreamIp1 = (String) method1.invoke(loggingElasticSearchServerResponse);
+        Assertions.assertEquals(upstreamIp1, "");
+        exchange.getAttributes().put(Constants.HTTP_DOMAIN, "http://localhost:9195/http/order/path/123/name");
+        loggingElasticSearchServerResponse.setExchange(exchange);
+        Method method2 = loggingElasticSearchServerResponse.getClass().getDeclaredMethod("getUpstreamIp");
+        method2.setAccessible(true);
+        String upstreamIp2 = (String) method2.invoke(loggingElasticSearchServerResponse);
+        Assertions.assertEquals(upstreamIp2, "localhost");
+        ShenyuContext shenyuContext2 = new ShenyuContext();
+        shenyuContext2.setRpcType("http");
+        exchange.getAttributes().put(Constants.CONTEXT, shenyuContext2);
+        loggingElasticSearchServerResponse.setExchange(exchange);
+        Method method3 = loggingElasticSearchServerResponse.getClass().getDeclaredMethod("getUpstreamIp");
+        method3.setAccessible(true);
+        String upstreamIp3 = (String) method3.invoke(loggingElasticSearchServerResponse);
+        Assertions.assertEquals(upstreamIp3, "localhost");
+        exchange.getAttributes().put(Constants.HTTP_URI, new URI("test", "localhost", "/test", "test"));
+        loggingElasticSearchServerResponse.setExchange(exchange);
+        Method method4 = loggingElasticSearchServerResponse.getClass().getDeclaredMethod("getUpstreamIp");
+        method4.setAccessible(true);
+        String uri = (String) method4.invoke(loggingElasticSearchServerResponse);
+        Assertions.assertEquals(uri, "localhost");
     }
 
     @Test
     public void testGetUpstreamIpFromHttpDomain() throws Exception {
+        exchange.getAttributes().put(Constants.HTTP_DOMAIN, "http://localhost:9195/http/order/path/123/name");
         loggingElasticSearchServerResponse.setExchange(exchange);
-        Method method = loggingElasticSearchServerResponse.getClass().getDeclaredMethod("getUpstreamIpFromHttpDomain");
-        method.setAccessible(true);
-        String upstreamIpFromHttpDomain = (String) method.invoke(loggingElasticSearchServerResponse);
-        Assertions.assertEquals(upstreamIpFromHttpDomain, "localhost");
+        Method method1 = loggingElasticSearchServerResponse.getClass().getDeclaredMethod("getUpstreamIpFromHttpDomain");
+        method1.setAccessible(true);
+        String upstreamIpFromHttpDomain1 = (String) method1.invoke(loggingElasticSearchServerResponse);
+        Assertions.assertEquals(upstreamIpFromHttpDomain1, "localhost");
+        exchange = Mockito.mock(ServerWebExchange.class);
+        ShenyuContext shenyuContext2 = new ShenyuContext();
+        shenyuContext2.setRpcType("http");
+        shenyuContext2.setStartDateTime(startDateTime);
+        exchange.getAttributes().put(Constants.CONTEXT, shenyuContext2);
+        loggingElasticSearchServerResponse.setExchange(exchange);
+        Method method2 = loggingElasticSearchServerResponse.getClass().getDeclaredMethod("getUpstreamIpFromHttpDomain");
+        method2.setAccessible(true);
+        String upstreamIpFromHttpDomain2 = (String) method2.invoke(loggingElasticSearchServerResponse);
+        Assertions.assertEquals(upstreamIpFromHttpDomain2, "");
     }
 
     @Test
     public void testLogError() throws NoSuchFieldException, IllegalAccessException {
+        ShenyuContext shenyuContext2 = new ShenyuContext();
+        shenyuContext2.setRpcType("http");
+        shenyuContext2.setStartDateTime(startDateTime);
+        exchange.getAttributes().put(Constants.CONTEXT, shenyuContext2);
         loggingElasticSearchServerResponse.setExchange(exchange);
         Throwable throwable = new Throwable("error");
         DefaultLogCollector.getInstance().start();
@@ -152,12 +203,25 @@ public final class LoggingElasticSearchServerHttpResponseTest {
         String sendString = "hello, shenyu";
         ByteBuffer byteBuffer = ByteBuffer.wrap(sendString.getBytes("UTF-8"));
         writer.write(byteBuffer.asReadOnlyBuffer());
-        Method method = loggingElasticSearchServerResponse.getClass().getDeclaredMethod("logResponse", ShenyuContext.class, BodyWriter.class);
-        method.setAccessible(true);
-        method.invoke(loggingElasticSearchServerResponse, exchange.getAttribute(Constants.CONTEXT), writer);
-        Field field = loggingElasticSearchServerResponse.getClass().getDeclaredField("logInfo");
-        field.setAccessible(true);
-        ShenyuRequestLog log = (ShenyuRequestLog) field.get(loggingElasticSearchServerResponse);
-        Assertions.assertEquals(log.getResponseBody(), "hello, shenyu");
+        Method method1 = loggingElasticSearchServerResponse.getClass().getDeclaredMethod("logResponse", ShenyuContext.class, BodyWriter.class);
+        method1.setAccessible(true);
+        method1.invoke(loggingElasticSearchServerResponse, exchange.getAttribute(Constants.CONTEXT), writer);
+        Field field1 = loggingElasticSearchServerResponse.getClass().getDeclaredField("logInfo");
+        field1.setAccessible(true);
+        ShenyuRequestLog log1 = (ShenyuRequestLog) field1.get(loggingElasticSearchServerResponse);
+        Assertions.assertEquals(log1.getResponseBody(), "hello, shenyu");
+        ShenyuContext shenyuContext2 = new ShenyuContext();
+        shenyuContext2.setRpcType("http");
+        shenyuContext2.setStartDateTime(startDateTime);
+        exchange.getAttributes().put(Constants.CONTEXT, shenyuContext2);
+        exchange.getAttributes().put(Constants.HTTP_DOMAIN, "http://localhost:9195/http/order/path/123/name");
+        loggingElasticSearchServerResponse.setExchange(exchange);
+        Method method2 = loggingElasticSearchServerResponse.getClass().getDeclaredMethod("logResponse", ShenyuContext.class, BodyWriter.class);
+        method2.setAccessible(true);
+        method2.invoke(loggingElasticSearchServerResponse, exchange.getAttribute(Constants.CONTEXT), writer);
+        Field field2 = loggingElasticSearchServerResponse.getClass().getDeclaredField("logInfo");
+        field2.setAccessible(true);
+        ShenyuRequestLog log2 = (ShenyuRequestLog) field2.get(loggingElasticSearchServerResponse);
+        Assertions.assertEquals(log2.getUpstreamIp(), "localhost");
     }
 }
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/src/test/java/org/apache/shenyu/plugin/logging/elasticsearch/config/LogCollectConfigTest.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/src/test/java/org/apache/shenyu/plugin/logging/elasticsearch/config/LogCollectConfigTest.java
index 20bc4f442..6653932f3 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/src/test/java/org/apache/shenyu/plugin/logging/elasticsearch/config/LogCollectConfigTest.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/src/test/java/org/apache/shenyu/plugin/logging/elasticsearch/config/LogCollectConfigTest.java
@@ -17,6 +17,7 @@
 
 package org.apache.shenyu.plugin.logging.elasticsearch.config;
 
+import org.apache.shenyu.plugin.logging.elasticsearch.config.LogCollectConfig.LogApiConfig;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 
@@ -75,4 +76,18 @@ public final class LogCollectConfigTest {
         logCollectConfig.setGlobalLogConfig(globalLogConfig);
         Assertions.assertEquals(logCollectConfig.getGlobalLogConfig(), globalLogConfig);
     }
+
+    @Test
+    public void testtCompressAlg() {
+        LogCollectConfig.GlobalLogConfig globalLogConfig = new LogCollectConfig.GlobalLogConfig();
+        globalLogConfig.setCompressAlg("LZ4");
+        Assertions.assertEquals(globalLogConfig.getCompressAlg(), "LZ4");
+    }
+
+    @Test
+    public void testIndex() {
+        LogCollectConfig.LogApiConfig logApiConfig = new LogApiConfig();
+        logApiConfig.setIndex("shenyu-access-logging");
+        Assertions.assertEquals(logApiConfig.getIndex(), "shenyu-access-logging");
+    }
 }
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/src/test/java/org/apache/shenyu/plugin/logging/elasticsearch/entity/ShenyuRequestLogTest.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/src/test/java/org/apache/shenyu/plugin/logging/elasticsearch/entity/ShenyuRequestLogTest.java
index 8f5cd327b..5064ff12c 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/src/test/java/org/apache/shenyu/plugin/logging/elasticsearch/entity/ShenyuRequestLogTest.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/src/test/java/org/apache/shenyu/plugin/logging/elasticsearch/entity/ShenyuRequestLogTest.java
@@ -83,4 +83,46 @@ public final class ShenyuRequestLogTest {
         shenyuRequestLog.setUpstreamIp("0.0.0.0");
         Assertions.assertEquals(shenyuRequestLog.getUpstreamIp(), "0.0.0.0");
     }
+
+    @Test
+    public void testRequestHeader() {
+        shenyuRequestLog.setRequestHeader("{}");
+        Assertions.assertEquals(shenyuRequestLog.getRequestHeader(), "{}");
+    }
+
+    @Test
+    public void testQueryParams() {
+        shenyuRequestLog.setQueryParams("{\"id\"=\"1\"}");
+        Assertions.assertEquals(shenyuRequestLog.getQueryParams(), "{\"id\"=\"1\"}");
+    }
+
+    @Test
+    public void testRequestUri() {
+        shenyuRequestLog.setRequestUri("/http/post/hi");
+        Assertions.assertEquals(shenyuRequestLog.getRequestUri(), "/http/post/hi");
+    }
+
+    @Test
+    public void testRpcType() {
+        shenyuRequestLog.setRpcType("Dubbo");
+        Assertions.assertEquals(shenyuRequestLog.getRpcType(), "Dubbo");
+    }
+
+    @Test
+    public void testUpstreamResponseTime() {
+        shenyuRequestLog.setUpstreamResponseTime(111111);
+        Assertions.assertEquals(shenyuRequestLog.getUpstreamResponseTime(), 111111);
+    }
+
+    @Test
+    public void testTraceId() {
+        shenyuRequestLog.setTraceId("shenyu-agent-trace-id");
+        Assertions.assertEquals(shenyuRequestLog.getTraceId(), "shenyu-agent-trace-id");
+    }
+
+    @Test
+    public void testPath() {
+        shenyuRequestLog.setPath("/shenyu/plugin");
+        Assertions.assertEquals(shenyuRequestLog.getPath(), "/shenyu/plugin");
+    }
 }
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/src/test/java/org/apache/shenyu/plugin/logging/elasticsearch/handler/LoggingElasticSearchPluginDataHandlerTest.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/src/test/java/org/apache/shenyu/plugin/logging/elasticsearch/handler/LoggingElasticSearchPluginDataHandlerTest.java
index c8254400b..5ab6b88e2 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/src/test/java/org/apache/shenyu/plugin/logging/elasticsearch/handler/LoggingElasticSearchPluginDataHandlerTest.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/src/test/java/org/apache/shenyu/plugin/logging/elasticsearch/handler/LoggingElasticSearchPluginDataHandlerTest.java
@@ -60,14 +60,6 @@ public final class LoggingElasticSearchPluginDataHandlerTest {
         pluginData.setConfig("{\"host\":\"localhost\", \"port\":\"9200\"}");
     }
 
-    @Test
-    public void testHandlerPlugin() throws NoSuchFieldException, IllegalAccessException {
-        loggingElasticSearchPluginDataHandler.handlerPlugin(pluginData);
-        Field field = loggingElasticSearchPluginDataHandler.getClass().getDeclaredField("ELASTICSEARCH_LOG_COLLECT_CLIENT");
-        field.setAccessible(true);
-        Assertions.assertEquals(field.get(loggingElasticSearchPluginDataHandler).getClass(), ElasticSearchLogCollectClient.class);
-    }
-
     @Test
     public void testHandlerSelector() throws NoSuchFieldException, IllegalAccessException {
         loggingElasticSearchPluginDataHandler.handlerSelector(selectorData);
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/src/test/java/org/apache/shenyu/plugin/logging/elasticsearch/utils/LogCollectConfigUtilsTest.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/src/test/java/org/apache/shenyu/plugin/logging/elasticsearch/utils/LogCollectConfigUtilsTest.java
index 5f2c0bdc7..ff5a074cb 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/src/test/java/org/apache/shenyu/plugin/logging/elasticsearch/utils/LogCollectConfigUtilsTest.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-elasticsearch/src/test/java/org/apache/shenyu/plugin/logging/elasticsearch/utils/LogCollectConfigUtilsTest.java
@@ -49,16 +49,11 @@ public final class LogCollectConfigUtilsTest {
 
     private ServerHttpRequest request;
 
-    private Map<String, String> uriSampleMap = new HashMap<>();
-
     private Map<String, String> apiTopicMap = new HashMap<>();
 
     @BeforeEach
     public void setUp() {
         config.setBufferQueueSize(5000);
-        LogCollectConfigUtils.setGlobalConfig(config);
-        uriSampleMap.put("const", "1");
-        apiTopicMap.put("topic", "shenyu-access-logging");
         MockServerHttpRequest request = MockServerHttpRequest
                 .get("localhost")
                 .remoteAddress(new InetSocketAddress(8090))
@@ -84,34 +79,53 @@ public final class LogCollectConfigUtilsTest {
 
     @Test
     public void testSetSampler() throws IllegalAccessException, NoSuchFieldException {
+        Map<String, String> uriSampleMap = new HashMap<>();
+        uriSampleMap.put("const", "");
         LogCollectConfigUtils.setSampler(uriSampleMap);
-        Field field = LogCollectConfigUtils.class.getDeclaredField("apiSamplerMap");
-        field.setAccessible(true);
-        Assertions.assertEquals(field.get("const").toString(), "{const=" + Sampler.ALWAYS_SAMPLE + "}");
+        Field field1 = LogCollectConfigUtils.class.getDeclaredField("apiSamplerMap");
+        field1.setAccessible(true);
+        Assertions.assertEquals(field1.get("const").toString(), "{const=" + Sampler.ALWAYS_SAMPLE + "}");
+        uriSampleMap.put("const", "1");
+        LogCollectConfigUtils.setSampler(uriSampleMap);
+        Field field2 = LogCollectConfigUtils.class.getDeclaredField("apiSamplerMap");
+        field2.setAccessible(true);
+        Assertions.assertEquals(field2.get("const").toString(), "{const=" + Sampler.ALWAYS_SAMPLE + "}");
     }
 
     @Test
     public void testIsSampled() {
-        assertEquals(LogCollectConfigUtils.isSampled(request), false);
+        assertEquals(LogCollectConfigUtils.isSampled(request), true);
+        Map<String, String> uriSampleMap = new HashMap<>();
+        uriSampleMap.put("localhost", "1");
+        LogCollectConfigUtils.setSampler(uriSampleMap);
+        assertEquals(LogCollectConfigUtils.isSampled(request), true);
     }
 
     @Test
     public void testIsRequestBodyTooLarge() {
+        LogCollectConfigUtils.setGlobalConfig(null);
+        assertEquals(LogCollectConfigUtils.isRequestBodyTooLarge(524289), false);
+        assertEquals(LogCollectConfigUtils.isRequestBodyTooLarge(524288), false);
+        LogCollectConfigUtils.setGlobalConfig(config);
         assertEquals(LogCollectConfigUtils.isRequestBodyTooLarge(524289), true);
         assertEquals(LogCollectConfigUtils.isRequestBodyTooLarge(524288), false);
     }
 
     @Test
     public void testIsResponseBodyTooLarge() {
+        LogCollectConfigUtils.setGlobalConfig(null);
+        assertEquals(LogCollectConfigUtils.isResponseBodyTooLarge(524289), false);
+        assertEquals(LogCollectConfigUtils.isResponseBodyTooLarge(524288), false);
+        LogCollectConfigUtils.setGlobalConfig(config);
         assertEquals(LogCollectConfigUtils.isResponseBodyTooLarge(524289), true);
         assertEquals(LogCollectConfigUtils.isResponseBodyTooLarge(524288), false);
     }
 
     @Test
     public void testSetGlobalSampler() throws NoSuchFieldException, IllegalAccessException {
-        LogCollectConfigUtils.setGlobalSampler("0");
+        LogCollectConfigUtils.setGlobalSampler("1");
         Field field = LogCollectConfigUtils.class.getDeclaredField("globalSampler");
         field.setAccessible(true);
-        assertEquals(field.get("const"), Sampler.NEVER_SAMPLE);
+        assertEquals(field.get("const"), Sampler.ALWAYS_SAMPLE);
     }
 }
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-rocketmq/src/test/java/org/apache/shenyu/plugin/logging/rocketmq/body/BodyWriterTest.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-rocketmq/src/test/java/org/apache/shenyu/plugin/logging/rocketmq/body/BodyWriterTest.java
index 8482997f4..9e0169a2b 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-rocketmq/src/test/java/org/apache/shenyu/plugin/logging/rocketmq/body/BodyWriterTest.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-rocketmq/src/test/java/org/apache/shenyu/plugin/logging/rocketmq/body/BodyWriterTest.java
@@ -22,7 +22,9 @@ import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
 import java.io.UnsupportedEncodingException;
+import java.lang.reflect.Field;
 import java.nio.ByteBuffer;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 /**
  * The Test Case For BodyWriter.
@@ -43,11 +45,15 @@ public class BodyWriterTest {
     }
 
     @Test
-    public void testWrite() throws UnsupportedEncodingException {
+    public void testWrite() throws Exception {
         ByteBuffer byteBuffer = ByteBuffer.wrap(sendString.getBytes("UTF-8"));
+        Field field = writer.getClass().getDeclaredField("isClosed");
+        field.setAccessible(true);
+        AtomicBoolean isClosed = (AtomicBoolean) field.get(writer);
         writer.write(byteBuffer.asReadOnlyBuffer());
         String res = writer.output();
         Assertions.assertEquals(res, "hello, shenyu");
+        Assertions.assertEquals(isClosed.toString(), "true");
     }
 
     @Test
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-rocketmq/src/test/java/org/apache/shenyu/plugin/logging/rocketmq/body/LoggingServerHttpResponseTest.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-rocketmq/src/test/java/org/apache/shenyu/plugin/logging/rocketmq/body/LoggingServerHttpResponseTest.java
index 90bdbd43b..a5a43d420 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-rocketmq/src/test/java/org/apache/shenyu/plugin/logging/rocketmq/body/LoggingServerHttpResponseTest.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-rocketmq/src/test/java/org/apache/shenyu/plugin/logging/rocketmq/body/LoggingServerHttpResponseTest.java
@@ -34,12 +34,15 @@ import org.mockito.Mockito;
 import org.springframework.context.ConfigurableApplicationContext;
 import org.springframework.http.server.reactive.ServerHttpRequest;
 import org.springframework.mock.http.server.reactive.MockServerHttpRequest;
+import org.springframework.mock.http.server.reactive.MockServerHttpResponse;
 import org.springframework.mock.web.server.MockServerWebExchange;
 import org.springframework.web.server.ServerWebExchange;
 
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.net.InetSocketAddress;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.nio.ByteBuffer;
 import java.time.LocalDateTime;
 
@@ -62,8 +65,10 @@ public class LoggingServerHttpResponseTest {
 
     private LocalDateTime startDateTime = LocalDateTime.now();
 
+    private MockServerHttpResponse response;
+
     @BeforeEach
-    public void setUp() {
+    public void setUp() throws URISyntaxException {
         MockServerHttpRequest request = MockServerHttpRequest
                 .post("localhost")
                 .remoteAddress(new InetSocketAddress(8090))
@@ -79,11 +84,11 @@ public class LoggingServerHttpResponseTest {
         this.exchange = Mockito.spy(MockServerWebExchange.from(request));
         Mockito.lenient().when(context.getBean(RemoteAddressResolver.class)).thenReturn(remoteAddressResolver);
         Mockito.lenient().when(context.getBean(ShenyuResult.class)).thenReturn(shenyuResult);
-        ShenyuContext shenyuContext = new ShenyuContext();
-        shenyuContext.setStartDateTime(startDateTime);
-        exchange.getAttributes().put(Constants.CONTEXT, shenyuContext);
+        ShenyuContext shenyuContext1 = new ShenyuContext();
+        shenyuContext1.setStartDateTime(startDateTime);
+        shenyuContext1.setMethod("test");
+        exchange.getAttributes().put(Constants.CONTEXT, shenyuContext1);
         exchange.getAttributes().put(LoggingConstant.SHENYU_AGENT_TRACE_ID, "shenyu-agent-trace-id");
-        exchange.getAttributes().put(Constants.HTTP_DOMAIN, "http://localhost:9195/http/order/path/123/name");
         this.serverHttpRequest = exchange.getRequest();
         requestInfo.setRequestUri(serverHttpRequest.getURI().toString());
         requestInfo.setMethod(serverHttpRequest.getMethodValue());
@@ -94,10 +99,21 @@ public class LoggingServerHttpResponseTest {
         requestInfo.setHost(serverHttpRequest.getHeaders().getFirst(host));
         requestInfo.setPath(serverHttpRequest.getURI().getPath());
         this.loggingServerHttpResponse = new LoggingServerHttpResponse(exchange.getResponse(), requestInfo, DefaultLogCollector.getInstance());
+        response = new MockServerHttpResponse();
     }
 
     @Test
-    public void testSetExchange() throws NoSuchFieldException, IllegalAccessException {
+    public void testWriteWith() throws Exception {
+        loggingServerHttpResponse.setExchange(exchange);
+        loggingServerHttpResponse.writeWith(response.getBody());
+        Field field = loggingServerHttpResponse.getClass().getDeclaredField("logInfo");
+        field.setAccessible(true);
+        ShenyuRequestLog logInfo = (ShenyuRequestLog) field.get(loggingServerHttpResponse);
+        Assertions.assertEquals(logInfo.getResponseHeader(), "{}");
+    }
+
+    @Test
+    public void testSetExchange() throws Exception {
         loggingServerHttpResponse.setExchange(exchange);
         Field field = loggingServerHttpResponse.getClass().getDeclaredField("exchange");
         field.setAccessible(true);
@@ -117,23 +133,58 @@ public class LoggingServerHttpResponseTest {
     @Test
     public void testGetUpstreamIp() throws Exception {
         loggingServerHttpResponse.setExchange(exchange);
-        Method method = loggingServerHttpResponse.getClass().getDeclaredMethod("getUpstreamIp");
-        method.setAccessible(true);
-        String upstreamIp = (String) method.invoke(loggingServerHttpResponse);
-        Assertions.assertEquals(upstreamIp, "localhost");
+        Method method1 = loggingServerHttpResponse.getClass().getDeclaredMethod("getUpstreamIp");
+        method1.setAccessible(true);
+        String upstreamIp1 = (String) method1.invoke(loggingServerHttpResponse);
+        Assertions.assertEquals(upstreamIp1, "");
+        exchange.getAttributes().put(Constants.HTTP_DOMAIN, "http://localhost:9195/http/order/path/123/name");
+        loggingServerHttpResponse.setExchange(exchange);
+        Method method2 = loggingServerHttpResponse.getClass().getDeclaredMethod("getUpstreamIp");
+        method2.setAccessible(true);
+        String upstreamIp2 = (String) method2.invoke(loggingServerHttpResponse);
+        Assertions.assertEquals(upstreamIp2, "localhost");
+        ShenyuContext shenyuContext2 = new ShenyuContext();
+        shenyuContext2.setRpcType("http");
+        exchange.getAttributes().put(Constants.CONTEXT, shenyuContext2);
+        loggingServerHttpResponse.setExchange(exchange);
+        Method method3 = loggingServerHttpResponse.getClass().getDeclaredMethod("getUpstreamIp");
+        method3.setAccessible(true);
+        String upstreamIp3 = (String) method3.invoke(loggingServerHttpResponse);
+        Assertions.assertEquals(upstreamIp3, "localhost");
+        exchange.getAttributes().put(Constants.HTTP_URI, new URI("test", "localhost", "/test", "test"));
+        loggingServerHttpResponse.setExchange(exchange);
+        Method method4 = loggingServerHttpResponse.getClass().getDeclaredMethod("getUpstreamIp");
+        method4.setAccessible(true);
+        String uri = (String) method4.invoke(loggingServerHttpResponse);
+        Assertions.assertEquals(uri, "localhost");
     }
 
     @Test
     public void testGetUpstreamIpFromHttpDomain() throws Exception {
+        exchange.getAttributes().put(Constants.HTTP_DOMAIN, "http://localhost:9195/http/order/path/123/name");
         loggingServerHttpResponse.setExchange(exchange);
-        Method method = loggingServerHttpResponse.getClass().getDeclaredMethod("getUpstreamIpFromHttpDomain");
-        method.setAccessible(true);
-        String upstreamIpFromHttpDomain = (String) method.invoke(loggingServerHttpResponse);
-        Assertions.assertEquals(upstreamIpFromHttpDomain, "localhost");
+        Method method1 = loggingServerHttpResponse.getClass().getDeclaredMethod("getUpstreamIpFromHttpDomain");
+        method1.setAccessible(true);
+        String upstreamIpFromHttpDomain1 = (String) method1.invoke(loggingServerHttpResponse);
+        Assertions.assertEquals(upstreamIpFromHttpDomain1, "localhost");
+        exchange = Mockito.mock(ServerWebExchange.class);
+        ShenyuContext shenyuContext2 = new ShenyuContext();
+        shenyuContext2.setRpcType("http");
+        shenyuContext2.setStartDateTime(startDateTime);
+        exchange.getAttributes().put(Constants.CONTEXT, shenyuContext2);
+        loggingServerHttpResponse.setExchange(exchange);
+        Method method2 = loggingServerHttpResponse.getClass().getDeclaredMethod("getUpstreamIpFromHttpDomain");
+        method2.setAccessible(true);
+        String upstreamIpFromHttpDomain2 = (String) method2.invoke(loggingServerHttpResponse);
+        Assertions.assertEquals(upstreamIpFromHttpDomain2, "");
     }
 
     @Test
     public void testLogError() throws NoSuchFieldException, IllegalAccessException {
+        ShenyuContext shenyuContext2 = new ShenyuContext();
+        shenyuContext2.setRpcType("http");
+        shenyuContext2.setStartDateTime(startDateTime);
+        exchange.getAttributes().put(Constants.CONTEXT, shenyuContext2);
         loggingServerHttpResponse.setExchange(exchange);
         Throwable throwable = new Throwable("error");
         DefaultLogCollector.getInstance().start();
@@ -152,12 +203,25 @@ public class LoggingServerHttpResponseTest {
         String sendString = "hello, shenyu";
         ByteBuffer byteBuffer = ByteBuffer.wrap(sendString.getBytes("UTF-8"));
         writer.write(byteBuffer.asReadOnlyBuffer());
-        Method method = loggingServerHttpResponse.getClass().getDeclaredMethod("logResponse", ShenyuContext.class, BodyWriter.class);
-        method.setAccessible(true);
-        method.invoke(loggingServerHttpResponse, exchange.getAttribute(Constants.CONTEXT), writer);
-        Field field = loggingServerHttpResponse.getClass().getDeclaredField("logInfo");
-        field.setAccessible(true);
-        ShenyuRequestLog log = (ShenyuRequestLog) field.get(loggingServerHttpResponse);
-        Assertions.assertEquals(log.getResponseBody(), "hello, shenyu");
+        Method method1 = loggingServerHttpResponse.getClass().getDeclaredMethod("logResponse", ShenyuContext.class, BodyWriter.class);
+        method1.setAccessible(true);
+        method1.invoke(loggingServerHttpResponse, exchange.getAttribute(Constants.CONTEXT), writer);
+        Field field1 = loggingServerHttpResponse.getClass().getDeclaredField("logInfo");
+        field1.setAccessible(true);
+        ShenyuRequestLog log1 = (ShenyuRequestLog) field1.get(loggingServerHttpResponse);
+        Assertions.assertEquals(log1.getResponseBody(), "hello, shenyu");
+        ShenyuContext shenyuContext2 = new ShenyuContext();
+        shenyuContext2.setRpcType("http");
+        shenyuContext2.setStartDateTime(startDateTime);
+        exchange.getAttributes().put(Constants.CONTEXT, shenyuContext2);
+        exchange.getAttributes().put(Constants.HTTP_DOMAIN, "http://localhost:9195/http/order/path/123/name");
+        loggingServerHttpResponse.setExchange(exchange);
+        Method method2 = loggingServerHttpResponse.getClass().getDeclaredMethod("logResponse", ShenyuContext.class, BodyWriter.class);
+        method2.setAccessible(true);
+        method2.invoke(loggingServerHttpResponse, exchange.getAttribute(Constants.CONTEXT), writer);
+        Field field2 = loggingServerHttpResponse.getClass().getDeclaredField("logInfo");
+        field2.setAccessible(true);
+        ShenyuRequestLog log2 = (ShenyuRequestLog) field2.get(loggingServerHttpResponse);
+        Assertions.assertEquals(log2.getUpstreamIp(), "localhost");
     }
 }
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-rocketmq/src/test/java/org/apache/shenyu/plugin/logging/rocketmq/client/RocketMQLogCollectClientTest.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-rocketmq/src/test/java/org/apache/shenyu/plugin/logging/rocketmq/client/RocketMQLogCollectClientTest.java
deleted file mode 100644
index a3c2ba662..000000000
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-rocketmq/src/test/java/org/apache/shenyu/plugin/logging/rocketmq/client/RocketMQLogCollectClientTest.java
+++ /dev/null
@@ -1,90 +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.shenyu.plugin.logging.rocketmq.client;
-
-import org.apache.shenyu.common.dto.PluginData;
-import org.apache.shenyu.common.utils.GsonUtils;
-import org.apache.shenyu.plugin.logging.rocketmq.constant.LoggingConstant;
-import org.apache.shenyu.plugin.logging.rocketmq.entity.ShenyuRequestLog;
-import org.apache.shenyu.plugin.logging.rocketmq.config.LogCollectConfig.GlobalLogConfig;
-import org.apache.shenyu.plugin.logging.rocketmq.utils.LogCollectConfigUtils;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-
-/**
- * The Test Case For RocketMQLogCollectClient.
- */
-public class RocketMQLogCollectClientTest {
-
-    private RocketMQLogCollectClient rocketMQLogCollectClient;
-
-    private Properties props = new Properties();
-
-    private PluginData pluginData = new PluginData();
-
-    private GlobalLogConfig globalLogConfig;
-
-    private List<ShenyuRequestLog> logs = new ArrayList<>();
-
-    private ShenyuRequestLog shenyuRequestLog = new ShenyuRequestLog();
-
-    @BeforeEach
-    public void setUp() {
-        this.rocketMQLogCollectClient = new RocketMQLogCollectClient();
-        pluginData.setEnabled(true);
-        pluginData.setConfig("{\"topic\":\"shenyu-access-logging\", \"namesrvAddr\":\"localhost:9876\", \"producerGroup\":\"shenyu-plugin-logging-rocketmq\"}");
-        globalLogConfig = GsonUtils.getInstance().fromJson(pluginData.getConfig(),
-                GlobalLogConfig.class);
-        globalLogConfig.setCompressAlg("LZ4");
-        props.setProperty(LoggingConstant.TOPIC, globalLogConfig.getTopic());
-        props.setProperty(LoggingConstant.NAMESERVER_ADDRESS, globalLogConfig.getNamesrvAddr());
-        props.setProperty(LoggingConstant.PRODUCER_GROUP, globalLogConfig.getProducerGroup());
-        shenyuRequestLog.setClientIp("0.0.0.0");
-        shenyuRequestLog.setPath("org/apache/shenyu/plugin/logging");
-        logs.add(shenyuRequestLog);
-    }
-
-    @Test
-    public void testInitProducer() throws NoSuchFieldException, IllegalAccessException {
-        rocketMQLogCollectClient.initProducer(props);
-        Field field = rocketMQLogCollectClient.getClass().getDeclaredField("topic");
-        field.setAccessible(true);
-        Assertions.assertEquals(field.get(rocketMQLogCollectClient), "shenyu-access-logging");
-        rocketMQLogCollectClient.close();
-    }
-
-    @Test
-    public void testConsume() {
-        String msg = "";
-        LogCollectConfigUtils.setGlobalConfig(globalLogConfig);
-        rocketMQLogCollectClient.initProducer(props);
-        try {
-            rocketMQLogCollectClient.consume(logs);
-        } catch (Exception e) {
-            msg = "false";
-        }
-        Assertions.assertEquals(msg, "");
-        rocketMQLogCollectClient.close();
-    }
-}
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-rocketmq/src/test/java/org/apache/shenyu/plugin/logging/rocketmq/config/LogCollectConfigTest.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-rocketmq/src/test/java/org/apache/shenyu/plugin/logging/rocketmq/config/LogCollectConfigTest.java
index 6e43a877a..ccbdbdd2c 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-rocketmq/src/test/java/org/apache/shenyu/plugin/logging/rocketmq/config/LogCollectConfigTest.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-rocketmq/src/test/java/org/apache/shenyu/plugin/logging/rocketmq/config/LogCollectConfigTest.java
@@ -17,6 +17,7 @@
 
 package org.apache.shenyu.plugin.logging.rocketmq.config;
 
+import org.apache.shenyu.plugin.logging.rocketmq.config.LogCollectConfig.GlobalLogConfig;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 
@@ -89,4 +90,18 @@ public class LogCollectConfigTest {
         logCollectConfig.setGlobalLogConfig(globalLogConfig);
         Assertions.assertEquals(logCollectConfig.getGlobalLogConfig(), globalLogConfig);
     }
+
+    @Test
+    public void testtCompressAlg() {
+        LogCollectConfig.GlobalLogConfig globalLogConfig = new LogCollectConfig.GlobalLogConfig();
+        globalLogConfig.setCompressAlg("LZ4");
+        Assertions.assertEquals(globalLogConfig.getCompressAlg(), "LZ4");
+    }
+
+    @Test
+    public void testBufferQueueSize() {
+        GlobalLogConfig globalLogConfig = new GlobalLogConfig();
+        globalLogConfig.setBufferQueueSize(50000);
+        Assertions.assertEquals(globalLogConfig.getBufferQueueSize(), 50000);
+    }
 }
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-rocketmq/src/test/java/org/apache/shenyu/plugin/logging/rocketmq/entity/ShenyuRequestLogTest.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-rocketmq/src/test/java/org/apache/shenyu/plugin/logging/rocketmq/entity/ShenyuRequestLogTest.java
index 6589fbfad..d4f73401f 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-rocketmq/src/test/java/org/apache/shenyu/plugin/logging/rocketmq/entity/ShenyuRequestLogTest.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-rocketmq/src/test/java/org/apache/shenyu/plugin/logging/rocketmq/entity/ShenyuRequestLogTest.java
@@ -83,4 +83,46 @@ public class ShenyuRequestLogTest {
         shenyuRequestLog.setUpstreamIp("0.0.0.0");
         Assertions.assertEquals(shenyuRequestLog.getUpstreamIp(), "0.0.0.0");
     }
+
+    @Test
+    public void testRequestHeader() {
+        shenyuRequestLog.setRequestHeader("{}");
+        Assertions.assertEquals(shenyuRequestLog.getRequestHeader(), "{}");
+    }
+
+    @Test
+    public void testQueryParams() {
+        shenyuRequestLog.setQueryParams("{\"id\"=\"1\"}");
+        Assertions.assertEquals(shenyuRequestLog.getQueryParams(), "{\"id\"=\"1\"}");
+    }
+
+    @Test
+    public void testRequestUri() {
+        shenyuRequestLog.setRequestUri("/http/post/hi");
+        Assertions.assertEquals(shenyuRequestLog.getRequestUri(), "/http/post/hi");
+    }
+
+    @Test
+    public void testRpcType() {
+        shenyuRequestLog.setRpcType("Dubbo");
+        Assertions.assertEquals(shenyuRequestLog.getRpcType(), "Dubbo");
+    }
+
+    @Test
+    public void testUpstreamResponseTime() {
+        shenyuRequestLog.setUpstreamResponseTime(111111);
+        Assertions.assertEquals(shenyuRequestLog.getUpstreamResponseTime(), 111111);
+    }
+
+    @Test
+    public void testTraceId() {
+        shenyuRequestLog.setTraceId("shenyu-agent-trace-id");
+        Assertions.assertEquals(shenyuRequestLog.getTraceId(), "shenyu-agent-trace-id");
+    }
+
+    @Test
+    public void testPath() {
+        shenyuRequestLog.setPath("/shenyu/plugin");
+        Assertions.assertEquals(shenyuRequestLog.getPath(), "/shenyu/plugin");
+    }
 }
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-rocketmq/src/test/java/org/apache/shenyu/plugin/logging/rocketmq/handler/LoggingRocketMQPluginDataHandlerTest.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-rocketmq/src/test/java/org/apache/shenyu/plugin/logging/rocketmq/handler/LoggingRocketMQPluginDataHandlerTest.java
index 702ba7c5f..d6ff191b5 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-rocketmq/src/test/java/org/apache/shenyu/plugin/logging/rocketmq/handler/LoggingRocketMQPluginDataHandlerTest.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-rocketmq/src/test/java/org/apache/shenyu/plugin/logging/rocketmq/handler/LoggingRocketMQPluginDataHandlerTest.java
@@ -60,14 +60,6 @@ public class LoggingRocketMQPluginDataHandlerTest {
         pluginData.setConfig("{\"topic\":\"test\", \"namesrvAddr\":\"test\", \"producerGroup\":\"test\"}");
     }
 
-    @Test
-    public void testHandlerPlugin() throws NoSuchFieldException, IllegalAccessException {
-        loggingRocketMQPluginDataHandler.handlerPlugin(pluginData);
-        Field field = loggingRocketMQPluginDataHandler.getClass().getDeclaredField("ROCKET_MQ_LOG_COLLECT_CLIENT");
-        field.setAccessible(true);
-        Assertions.assertEquals(field.get(loggingRocketMQPluginDataHandler).getClass(), RocketMQLogCollectClient.class);
-    }
-
     @Test
     public void testHandlerSelector() throws NoSuchFieldException, IllegalAccessException {
         loggingRocketMQPluginDataHandler.handlerSelector(selectorData);
diff --git a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-rocketmq/src/test/java/org/apache/shenyu/plugin/logging/rocketmq/utils/LogCollectConfigUtilsTest.java b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-rocketmq/src/test/java/org/apache/shenyu/plugin/logging/rocketmq/utils/LogCollectConfigUtilsTest.java
index 9e33430b6..4ed41ccd9 100644
--- a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-rocketmq/src/test/java/org/apache/shenyu/plugin/logging/rocketmq/utils/LogCollectConfigUtilsTest.java
+++ b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-rocketmq/src/test/java/org/apache/shenyu/plugin/logging/rocketmq/utils/LogCollectConfigUtilsTest.java
@@ -49,16 +49,11 @@ public class LogCollectConfigUtilsTest {
 
     private ServerHttpRequest request;
 
-    private Map<String, String> uriSampleMap = new HashMap<>();
-
     private Map<String, String> apiTopicMap = new HashMap<>();
 
     @BeforeEach
     public void setUp() {
         config.setBufferQueueSize(5000);
-        LogCollectConfigUtils.setGlobalConfig(config);
-        uriSampleMap.put("const", "1");
-        apiTopicMap.put("topic", "shenyu-access-logging");
         MockServerHttpRequest request = MockServerHttpRequest
                 .get("localhost")
                 .remoteAddress(new InetSocketAddress(8090))
@@ -84,45 +79,53 @@ public class LogCollectConfigUtilsTest {
 
     @Test
     public void testSetSampler() throws IllegalAccessException, NoSuchFieldException {
+        Map<String, String> uriSampleMap = new HashMap<>();
+        uriSampleMap.put("const", "");
         LogCollectConfigUtils.setSampler(uriSampleMap);
-        Field field = LogCollectConfigUtils.class.getDeclaredField("apiSamplerMap");
-        field.setAccessible(true);
-        Assertions.assertEquals(field.get("const").toString(), "{const=" + Sampler.ALWAYS_SAMPLE + "}");
+        Field field1 = LogCollectConfigUtils.class.getDeclaredField("apiSamplerMap");
+        field1.setAccessible(true);
+        Assertions.assertEquals(field1.get("const").toString(), "{const=" + Sampler.ALWAYS_SAMPLE + "}");
+        uriSampleMap.put("const", "1");
+        LogCollectConfigUtils.setSampler(uriSampleMap);
+        Field field2 = LogCollectConfigUtils.class.getDeclaredField("apiSamplerMap");
+        field2.setAccessible(true);
+        Assertions.assertEquals(field2.get("const").toString(), "{const=" + Sampler.ALWAYS_SAMPLE + "}");
     }
 
     @Test
     public void testIsSampled() {
-        assertEquals(LogCollectConfigUtils.isSampled(request), false);
+        assertEquals(LogCollectConfigUtils.isSampled(request), true);
+        Map<String, String> uriSampleMap = new HashMap<>();
+        uriSampleMap.put("localhost", "1");
+        LogCollectConfigUtils.setSampler(uriSampleMap);
+        assertEquals(LogCollectConfigUtils.isSampled(request), true);
     }
 
     @Test
     public void testIsRequestBodyTooLarge() {
+        LogCollectConfigUtils.setGlobalConfig(null);
+        assertEquals(LogCollectConfigUtils.isRequestBodyTooLarge(524289), false);
+        assertEquals(LogCollectConfigUtils.isRequestBodyTooLarge(524288), false);
+        LogCollectConfigUtils.setGlobalConfig(config);
         assertEquals(LogCollectConfigUtils.isRequestBodyTooLarge(524289), true);
         assertEquals(LogCollectConfigUtils.isRequestBodyTooLarge(524288), false);
     }
 
     @Test
     public void testIsResponseBodyTooLarge() {
+        LogCollectConfigUtils.setGlobalConfig(null);
+        assertEquals(LogCollectConfigUtils.isResponseBodyTooLarge(524289), false);
+        assertEquals(LogCollectConfigUtils.isResponseBodyTooLarge(524288), false);
+        LogCollectConfigUtils.setGlobalConfig(config);
         assertEquals(LogCollectConfigUtils.isResponseBodyTooLarge(524289), true);
         assertEquals(LogCollectConfigUtils.isResponseBodyTooLarge(524288), false);
     }
 
-    @Test
-    public void testGetTopic() {
-        assertEquals(LogCollectConfigUtils.getTopic("topic"), "");
-    }
-
-    @Test
-    public void testSetTopic() {
-        LogCollectConfigUtils.setTopic(apiTopicMap);
-        assertEquals(LogCollectConfigUtils.getTopic("topic"), "shenyu-access-logging");
-    }
-
     @Test
     public void testSetGlobalSampler() throws NoSuchFieldException, IllegalAccessException {
-        LogCollectConfigUtils.setGlobalSampler("0");
+        LogCollectConfigUtils.setGlobalSampler("1");
         Field field = LogCollectConfigUtils.class.getDeclaredField("globalSampler");
         field.setAccessible(true);
-        assertEquals(field.get("const"), Sampler.NEVER_SAMPLE);
+        assertEquals(field.get("const"), Sampler.ALWAYS_SAMPLE);
     }
 }