From 8fe158238d695e1822febf044f1e78153cd9078f Mon Sep 17 00:00:00 2001 From: snoop Date: Wed, 7 Jun 2017 21:48:45 +0900 Subject: [PATCH] added class for name list --- src/test/java/com/loafle/TestClient.java | 34 ++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/test/java/com/loafle/TestClient.java b/src/test/java/com/loafle/TestClient.java index 199223a..04f6066 100644 --- a/src/test/java/com/loafle/TestClient.java +++ b/src/test/java/com/loafle/TestClient.java @@ -5,12 +5,17 @@ import com.loafle.overflow.db.api.DBGrpc; import com.loafle.overflow.db.api.DBInput; import com.loafle.overflow.db.api.DBOutput; import com.loafle.overflow.member.model.Member; +import com.loafle.overflow.target.model.Target; import io.grpc.ManagedChannel; import io.grpc.ManagedChannelBuilder; import io.grpc.StatusRuntimeException; import org.codehaus.jackson.map.ObjectMapper; import org.junit.Test; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import java.util.concurrent.TimeUnit; import java.util.logging.Level; import java.util.logging.Logger; @@ -81,4 +86,33 @@ public class TestClient { } } } + + + + @Test + public void testClassName() throws ClassNotFoundException, IOException { + + String testRes = "[{\"ip\":3232235882,\"port\":5432,\"targetType\":\"DATABASE\",\"vendorName\":\"PostgreSQL 9.5.0\",\"kinds\":\"PostgreSQL2222\",\"version\":\"9.5.0\",\"createDate\":-62135596800000,\"portType\":\"TCP\",\"member\":{\"id\":1,\"email\":\"\",\"pwSalt\":\"\",\"digest\":\"\",\"name\":\"\",\"company\":\"\",\"phone\":\"\",\"authorizedDate\":0}},{\"ip\":3232235882,\"port\":5432,\"targetType\":\"DATABASE\",\"vendorName\":\"PostgreSQL 9.5.0\",\"kinds\":\"PostgreSQL3333\",\"version\":\"9.5.0\",\"createDate\":-62135596800000,\"portType\":\"TCP\",\"member\":{\"id\":1,\"email\":\"\",\"pwSalt\":\"\",\"digest\":\"\",\"name\":\"\",\"company\":\"\",\"phone\":\"\",\"authorizedDate\":0}},{\"ip\":3232235882,\"port\":5432,\"targetType\":\"DATABASE\",\"vendorName\":\"PostgreSQL 9.5.0\",\"kinds\":\"PostgreSQL4444\",\"version\":\"9.5.0\",\"createDate\":-62135596800000,\"portType\":\"TCP\",\"member\":{\"id\":1,\"email\":\"\",\"pwSalt\":\"\",\"digest\":\"\",\"name\":\"\",\"company\":\"\",\"phone\":\"\",\"authorizedDate\":0}},{\"ip\":3232235882,\"port\":5432,\"targetType\":\"DATABASE\",\"vendorName\":\"PostgreSQL 9.5.0\",\"kinds\":\"PostgreSQL5555\",\"version\":\"9.5.0\",\"createDate\":-62135596800000,\"portType\":\"TCP\",\"member\":{\"id\":1,\"email\":\"\",\"pwSalt\":\"\",\"digest\":\"\",\"name\":\"\",\"company\":\"\",\"phone\":\"\",\"authorizedDate\":0}},{\"ip\":3232235882,\"port\":5432,\"targetType\":\"DATABASE\",\"vendorName\":\"PostgreSQL 9.5.0\",\"kinds\":\"PostgreSQL6666\",\"version\":\"9.5.0\",\"createDate\":-62135596800000,\"portType\":\"TCP\",\"member\":{\"id\":1,\"email\":\"\",\"pwSalt\":\"\",\"digest\":\"\",\"name\":\"\",\"company\":\"\",\"phone\":\"\",\"authorizedDate\":0}}]"; + + ObjectMapper mapper = new ObjectMapper(); + Class cls = Class.forName("[L" + "com.loafle.overflow.target.model.Target" + ";"); +// Class cls = Class.forName("java.util.List"); + + Object obj = mapper.readValue(testRes, cls); + + + List aa = Arrays.asList((Object[])obj); + + System.out.println(aa.getClass()); +// List tl = (List)aa; + + +// List aaa = (List)obj.; +// +// +// for( Target t : aaa) { +// System.out.println(t); +// } + + } } \ No newline at end of file