feat: update PrintMemory in tests

use JUnit to update PrintMemory in tests and add test resources
This commit is contained in:
Frank.R.Wu 2021-11-11 16:07:14 +08:00
parent 9244bd768c
commit 6673cedf0f
6 changed files with 38 additions and 23 deletions

View File

@ -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;
public class MemoryDumpRecoverTest {
@ -14,7 +15,7 @@ public class MemoryDumpRecoverTest {
StringBuilder sb = new StringBuilder();
try {
Scanner sc = new Scanner(new FileInputStream(file));
for (; sc.hasNextLine();) {
while (sc.hasNextLine()) {
sb.append(sc.nextLine()).append("\n");
}
} catch (Exception e) {

View File

@ -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 static void main(String[] args) throws IOException {

View 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));
}
}

View File

@ -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);
}
}

Binary file not shown.

Binary file not shown.