|
20 | 20 | package org.apache.iotdb.db.queryengine.execution.fragment; |
21 | 21 |
|
22 | 22 | import org.apache.iotdb.commons.concurrent.IoTDBThreadPoolFactory; |
23 | | -import org.apache.iotdb.commons.memory.AtomicLongMemoryBlock; |
24 | 23 | import org.apache.iotdb.db.conf.IoTDBDescriptor; |
25 | 24 | import org.apache.iotdb.db.queryengine.common.FragmentInstanceId; |
26 | 25 | import org.apache.iotdb.db.queryengine.common.PlanFragmentId; |
|
34 | 33 | import org.apache.iotdb.db.utils.datastructure.AlignedTVList; |
35 | 34 | import org.apache.iotdb.db.utils.datastructure.TVList; |
36 | 35 |
|
37 | | -import ch.qos.logback.classic.Level; |
38 | | -import ch.qos.logback.classic.Logger; |
39 | | -import ch.qos.logback.classic.spi.ILoggingEvent; |
40 | | -import ch.qos.logback.core.read.ListAppender; |
41 | 36 | import com.google.common.collect.ImmutableMap; |
42 | 37 | import org.apache.tsfile.enums.TSDataType; |
43 | 38 | import org.junit.Test; |
44 | 39 | import org.mockito.Mockito; |
45 | | -import org.slf4j.LoggerFactory; |
46 | 40 |
|
| 41 | +import java.io.ByteArrayOutputStream; |
| 42 | +import java.io.PrintStream; |
47 | 43 | import java.util.ArrayList; |
48 | 44 | import java.util.Collections; |
49 | 45 | import java.util.List; |
|
53 | 49 | import static org.apache.iotdb.db.queryengine.common.QueryId.MOCK_QUERY_ID; |
54 | 50 | import static org.apache.iotdb.db.queryengine.execution.fragment.FragmentInstanceContext.createFragmentInstanceContext; |
55 | 51 | import static org.junit.Assert.assertEquals; |
| 52 | +import static org.junit.Assert.assertFalse; |
56 | 53 | import static org.junit.Assert.assertTrue; |
57 | 54 | import static org.junit.Assert.fail; |
58 | 55 |
|
@@ -102,14 +99,10 @@ public void testFragmentInstanceExecution() { |
102 | 99 |
|
103 | 100 | @Test |
104 | 101 | public void testTVListOwnerTransfer() throws InterruptedException { |
105 | | - Logger logger = (Logger) LoggerFactory.getLogger(AtomicLongMemoryBlock.class); |
106 | | - ListAppender<ILoggingEvent> listAppender = new ListAppender<>(); |
107 | | - listAppender.start(); |
108 | | - |
109 | | - // set log level |
110 | | - logger.setLevel(Level.WARN); |
111 | | - logger.setAdditive(false); |
112 | | - logger.addAppender(listAppender); |
| 102 | + // Capture System.err to check for warning messages |
| 103 | + PrintStream systemOut = System.out; |
| 104 | + ByteArrayOutputStream logPrint = new ByteArrayOutputStream(); |
| 105 | + System.setOut(new PrintStream(logPrint)); |
113 | 106 |
|
114 | 107 | try { |
115 | 108 | IoTDBDescriptor.getInstance().getConfig().setDataNodeId(1); |
@@ -155,10 +148,15 @@ public void testTVListOwnerTransfer() throws InterruptedException { |
155 | 148 | instanceNotificationExecutor.shutdown(); |
156 | 149 | } |
157 | 150 | } finally { |
158 | | - logger.detachAppender(listAppender); |
| 151 | + // Restore original System.out |
| 152 | + System.setErr(systemOut); |
| 153 | + |
159 | 154 | // should not contain warn message: "The memory cost to be released is larger than the memory |
160 | 155 | // cost of memory block" |
161 | | - assertEquals(0, listAppender.list.size()); |
| 156 | + String capturedOutput = logPrint.toString(); |
| 157 | + assertFalse( |
| 158 | + "Should not contain warning message", |
| 159 | + capturedOutput.contains("The memory cost to be released is larger than the memory")); |
162 | 160 | } |
163 | 161 | } |
164 | 162 |
|
|
0 commit comments