creator
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package org.redkale.test.sncp;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import org.junit.jupiter.api.*;
|
||||
@@ -62,7 +64,7 @@ public class SncpSleepTest {
|
||||
CompletableFuture.allOf(futures).join();
|
||||
long e = System.currentTimeMillis() - s;
|
||||
System.out.println("耗时: " + e + " ms");
|
||||
//remoteCService.test(333L, new String[] {"aaa", "bbb"}, List.of(new File("D:/a.txt"), new File("D:/b.txt")));
|
||||
remoteCService.test(333L, new String[] {"aaa", "bbb"}, List.of(new File("D:/a.txt"), new File("D:/b.txt")));
|
||||
server.shutdown();
|
||||
workExecutor.shutdown();
|
||||
Assertions.assertTrue(e < 600);
|
||||
|
||||
@@ -5,11 +5,8 @@
|
||||
*/
|
||||
package org.redkale.test.util;
|
||||
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.redkale.annotation.ConstructorParameters;
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
import org.redkale.util.Creator;
|
||||
|
||||
/** @author zhangjx */
|
||||
public class CreatorRecord {
|
||||
@@ -32,6 +29,8 @@ public class CreatorRecord {
|
||||
|
||||
private double dval;
|
||||
|
||||
public CreatorRecord() {}
|
||||
|
||||
@ConstructorParameters({"id", "name", "lval", "tval", "bval", "sval", "cval", "fval", "dval"})
|
||||
public CreatorRecord(
|
||||
int id, String name, long lval, boolean tval, byte bval, short sval, char cval, float fval, double dval) {
|
||||
@@ -46,17 +45,40 @@ public class CreatorRecord {
|
||||
this.dval = dval;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void run1() {
|
||||
Creator<CreatorRecord> creator = Creator.create(CreatorRecord.class);
|
||||
System.out.println(Arrays.toString(creator.paramTypes()));
|
||||
CreatorRecord record =
|
||||
creator.create(new Object[] {null, "ss", null, true, null, (short) 45, null, 4.3f, null});
|
||||
String json = record.toString();
|
||||
System.out.println(json);
|
||||
String json2 = JsonConvert.root().convertFrom(CreatorRecord.class, json).toString();
|
||||
System.out.println(json2);
|
||||
Assertions.assertEquals(json, json2);
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setLval(long lval) {
|
||||
this.lval = lval;
|
||||
}
|
||||
|
||||
public void setTval(boolean tval) {
|
||||
this.tval = tval;
|
||||
}
|
||||
|
||||
public void setBval(byte bval) {
|
||||
this.bval = bval;
|
||||
}
|
||||
|
||||
public void setSval(short sval) {
|
||||
this.sval = sval;
|
||||
}
|
||||
|
||||
public void setCval(char cval) {
|
||||
this.cval = cval;
|
||||
}
|
||||
|
||||
public void setFval(float fval) {
|
||||
this.fval = fval;
|
||||
}
|
||||
|
||||
public void setDval(double dval) {
|
||||
this.dval = dval;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
38
src/test/java/org/redkale/test/util/CreatorTest.java
Normal file
38
src/test/java/org/redkale/test/util/CreatorTest.java
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2116 Redkale
|
||||
* All rights reserved.
|
||||
*/
|
||||
package org.redkale.test.util;
|
||||
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
import org.redkale.util.Creator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author zhangjx
|
||||
*/
|
||||
public class CreatorTest {
|
||||
|
||||
public static void main(String[] args) throws Throwable {
|
||||
CreatorTest test = new CreatorTest();
|
||||
test.run1();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void run1() throws Throwable {
|
||||
Creator<CreatorRecord> creator = Creator.create(CreatorRecord.class, 9);
|
||||
Creator.load(CreatorRecord.class);
|
||||
System.out.println(Arrays.toString(creator.paramTypes()));
|
||||
CreatorRecord record =
|
||||
creator.create(new Object[] {null, "ss", null, true, null, (short) 45, null, 4.3f, null});
|
||||
String json = record.toString();
|
||||
System.out.println(json);
|
||||
String json2 = JsonConvert.root().convertFrom(CreatorRecord.class, json).toString();
|
||||
System.out.println(json2);
|
||||
Assertions.assertEquals("ss", record.getName());
|
||||
Assertions.assertEquals(json, json2);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user