mirror of
https://gitee.com/BDWare/cp.git
synced 2025-01-10 01:44:08 +00:00
feat: update PrintMemory in tests
use JUnit to update PrintMemory in tests and add test resources
This commit is contained in:
parent
9244bd768c
commit
6673cedf0f
@ -1,6 +1,7 @@
|
|||||||
package org.bdware.sc.test.synctest;
|
package org.bdware.sc.memory.test;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
public class MemoryDumpRecoverTest {
|
public class MemoryDumpRecoverTest {
|
||||||
@ -14,7 +15,7 @@ public class MemoryDumpRecoverTest {
|
|||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
try {
|
try {
|
||||||
Scanner sc = new Scanner(new FileInputStream(file));
|
Scanner sc = new Scanner(new FileInputStream(file));
|
||||||
for (; sc.hasNextLine();) {
|
while (sc.hasNextLine()) {
|
||||||
sb.append(sc.nextLine()).append("\n");
|
sb.append(sc.nextLine()).append("\n");
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
@ -1,6 +1,6 @@
|
|||||||
package org.bdware.sc.test.synctest;
|
package org.bdware.sc.memory.test;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class MemoryDumpTest {
|
public class MemoryDumpTest {
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
32
src/test/java/org/bdware/sc/memory/test/PrintMemory.java
Normal file
32
src/test/java/org/bdware/sc/memory/test/PrintMemory.java
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
package org.bdware.sc.memory.test;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.bdware.sc.memory.MemoryDumpUtil;
|
||||||
|
import org.bdware.sc.util.HashUtil;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
public class PrintMemory {
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger(PrintMemory.class);
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void printBDCoin() {
|
||||||
|
printMemory("/memory/BDCoin.ckpt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void printCounter() {
|
||||||
|
printMemory("/memory/Counter.ckpt");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void printMemory(String path) {
|
||||||
|
URL resource = this.getClass().getResource(path);
|
||||||
|
assert null != resource;
|
||||||
|
String content = MemoryDumpUtil.getContentFromFile(resource.getFile());
|
||||||
|
assert null != content;
|
||||||
|
LOGGER.info(content.length());
|
||||||
|
LOGGER.info(HashUtil.sha3(content));
|
||||||
|
}
|
||||||
|
}
|
@ -1,18 +0,0 @@
|
|||||||
package org.bdware.sc.test.synctest;
|
|
||||||
|
|
||||||
import org.bdware.sc.memory.MemoryDumpUtil;
|
|
||||||
|
|
||||||
public class PrintMemory {
|
|
||||||
|
|
||||||
public static void main(String[] args){
|
|
||||||
printMemory();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void printMemory(){
|
|
||||||
String path = "/Users/zhangyixuan/Lab/new/BDContract/front-agent/BDWareProjectDir/ADSPDir/-1676897265/memory/2020-08-15-22:04:17_175580150";
|
|
||||||
|
|
||||||
String path2 = "/Users/zhangyixuan/Lab/new/BDContract/front-agent/BDWareProjectDir/memory/mathOperation/2021-01-30.15:38:13";
|
|
||||||
String content = MemoryDumpUtil.getContentFromFile(path2);
|
|
||||||
System.out.println(content);
|
|
||||||
}
|
|
||||||
}
|
|
BIN
src/test/resources/memory/BDCoin.ckpt
Normal file
BIN
src/test/resources/memory/BDCoin.ckpt
Normal file
Binary file not shown.
BIN
src/test/resources/memory/Counter.ckpt
Normal file
BIN
src/test/resources/memory/Counter.ckpt
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user