first overflow dao commit
This commit is contained in:
118
src/test/java/com/loafle/TestClient.java
Normal file
118
src/test/java/com/loafle/TestClient.java
Normal file
@@ -0,0 +1,118 @@
|
||||
package com.loafle;
|
||||
|
||||
|
||||
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.dao.member.model.Member;
|
||||
import com.loafle.overflow.dao.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;
|
||||
|
||||
public class TestClient {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(TestClient.class.getName());
|
||||
|
||||
private final ManagedChannel channel;
|
||||
private final DBGrpc.DBBlockingStub dbStub;
|
||||
|
||||
public TestClient() {
|
||||
channel = ManagedChannelBuilder.forAddress("127.0.0.1", 50006).usePlaintext(true).build();
|
||||
dbStub = DBGrpc.newBlockingStub(channel);
|
||||
}
|
||||
|
||||
|
||||
public void shutdown() throws InterruptedException {
|
||||
channel.shutdown().awaitTermination(5, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
|
||||
public void execute() {
|
||||
|
||||
try {
|
||||
Member m = new Member();
|
||||
m.setId(Long.parseLong("2"));
|
||||
m.setName("geek");
|
||||
m.setCompany("loafle");
|
||||
m.setDigest("bbbbbbbbb");
|
||||
m.setPwSalt("salktttt");
|
||||
m.setEmail("insanity@loafle.com");
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
DBInput request = DBInput.newBuilder()
|
||||
.setTargetDao("member")
|
||||
.setMethod("findByEmail")
|
||||
.putParams("com.loafle.overflow.member.model.Member", mapper.writeValueAsString(m))
|
||||
//.putParams("id", "1")
|
||||
.build();
|
||||
DBOutput response;
|
||||
try {
|
||||
response = dbStub.exec(request);
|
||||
} catch (StatusRuntimeException e) {
|
||||
logger.log(Level.WARNING, "RPC failed: {0}", e.getStatus());
|
||||
return;
|
||||
}
|
||||
logger.log(Level.INFO, response.getResult());
|
||||
}catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRPCServer() {
|
||||
TestClient client = new TestClient();
|
||||
try {
|
||||
client.execute();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
client.shutdown();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@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<com.loafle.overflow.target.model.Target>");
|
||||
|
||||
Object obj = mapper.readValue(testRes, cls);
|
||||
|
||||
|
||||
List<Object> aa = Arrays.asList((Object[])obj);
|
||||
|
||||
System.out.println(aa.getClass());
|
||||
// List<Target> tl = (List<Target>)aa;
|
||||
|
||||
|
||||
// List<Target> aaa = (List<Target>)obj.;
|
||||
//
|
||||
//
|
||||
// for( Target t : aaa) {
|
||||
// System.out.println(t);
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.loafle.overflow.agent.dao;
|
||||
|
||||
import com.loafle.overflow.dao.agent.dao.JPAAgentDAO;
|
||||
import com.loafle.overflow.dao.agent.model.Agent;
|
||||
import com.loafle.overflow.dao.member.model.Member;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 4.
|
||||
*/
|
||||
@Ignore
|
||||
public class JPAAgentDAOTest {
|
||||
|
||||
private JPAAgentDAO jpaAgentDAO = null;
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
this.jpaAgentDAO = new JPAAgentDAO();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void createAgent() {
|
||||
Member m = new Member();
|
||||
m.setId(Long.valueOf(1));
|
||||
Agent agent = new Agent();
|
||||
agent.setDescription("test agent");
|
||||
agent.setMember(m);
|
||||
Agent savedAgent = jpaAgentDAO.create(agent);
|
||||
|
||||
System.out.println(savedAgent.getDescription());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.loafle.overflow.apikey.dao;
|
||||
|
||||
import com.loafle.overflow.dao.apikey.dao.JPAApiKeyDao;
|
||||
import com.loafle.overflow.dao.apikey.model.Apikey;
|
||||
import com.loafle.overflow.dao.member.model.Member;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 4.
|
||||
*/
|
||||
public class JPAApiKeyDaoTest {
|
||||
|
||||
private JPAApiKeyDao jpaApiKeyDao;
|
||||
|
||||
@Before
|
||||
public void Before() {
|
||||
this.jpaApiKeyDao = new JPAApiKeyDao();
|
||||
}
|
||||
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void findByApiKey() throws Exception {
|
||||
|
||||
Apikey apikey = new Apikey();
|
||||
|
||||
apikey.setApiKey("1111111");
|
||||
|
||||
Apikey a = this.jpaApiKeyDao.findByApiKey(apikey);
|
||||
|
||||
System.out.println(a.getId());
|
||||
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void createApiKey() {
|
||||
Apikey apikey = new Apikey();
|
||||
|
||||
apikey.setApiKey("1111111");
|
||||
apikey.setCreateDate(new Date());
|
||||
Member member = new Member();
|
||||
member.setId((long)2);
|
||||
apikey.setMember(member);
|
||||
|
||||
|
||||
jpaApiKeyDao.create(apikey);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.loafle.overflow.crawler.dao;
|
||||
|
||||
|
||||
import com.loafle.overflow.dao.crawler.dao.JPACrawlerDAO;
|
||||
import com.loafle.overflow.dao.crawler.model.Crawler;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by geek@loafle.com on 17. 6. 8.
|
||||
*/
|
||||
@Ignore
|
||||
public class JPACrawlerDAOTest {
|
||||
|
||||
private JPACrawlerDAO jpaCrawlerDAO = null;
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
this.jpaCrawlerDAO = new JPACrawlerDAO();
|
||||
|
||||
}
|
||||
|
||||
// TODO Crawler Meta Data Insert
|
||||
@Test
|
||||
public void TestInsertList() {
|
||||
List<Crawler> crawlers = new ArrayList<Crawler>();
|
||||
|
||||
Crawler crawler1 = new Crawler();
|
||||
crawler1.setName("SNMP Crawler");
|
||||
crawler1.setDescription("SNMP Crawler");
|
||||
crawler1.setCrawlerType("SNMP");
|
||||
|
||||
Crawler crawler2 = new Crawler();
|
||||
crawler2.setName("WMI Crawler");
|
||||
crawler2.setDescription("WMI Crawler");
|
||||
crawler2.setCrawlerType("WMI");
|
||||
|
||||
Crawler crawler3 = new Crawler();
|
||||
crawler3.setName("HTTP Crawler");
|
||||
crawler3.setDescription("HTTP Crawler");
|
||||
crawler3.setCrawlerType("Network");
|
||||
|
||||
Crawler crawler4 = new Crawler();
|
||||
crawler4.setName("FTP Crawler");
|
||||
crawler4.setDescription("FTP Crawler");
|
||||
crawler4.setCrawlerType("Network");
|
||||
|
||||
crawlers.add(crawler1);
|
||||
crawlers.add(crawler2);
|
||||
crawlers.add(crawler3);
|
||||
crawlers.add(crawler4);
|
||||
|
||||
this.jpaCrawlerDAO.createAll(crawlers);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void TestInsert() {
|
||||
Crawler crawler = new Crawler();
|
||||
crawler.setName("Mysql Crawler");
|
||||
crawler.setDescription("Mysql Crawler");
|
||||
crawler.setCrawlerType("MysqlCrawler");
|
||||
this.jpaCrawlerDAO.create(crawler);
|
||||
}
|
||||
// TODO Crawler Select Test
|
||||
|
||||
@Test
|
||||
public void TestListAll() {
|
||||
List<Crawler> ls = this.jpaCrawlerDAO.findAll();
|
||||
System.out.println(ls.size());
|
||||
}
|
||||
// TODO Crawler Update Test
|
||||
|
||||
// TODO Crawler Delete Test
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.loafle.overflow.crawler.dao;
|
||||
|
||||
import com.loafle.overflow.dao.crawler.dao.JPACrawlerInputItemDAO;
|
||||
import com.loafle.overflow.dao.crawler.model.CrawlerInputItem;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by geek@loafle.com on 17. 6. 8.
|
||||
*/
|
||||
@Ignore
|
||||
public class JPACrawlerInputItemDAOTest {
|
||||
|
||||
private JPACrawlerInputItemDAO inputItemDAO = null;
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
this.inputItemDAO = new JPACrawlerInputItemDAO();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void TestInsertList() {
|
||||
List<CrawlerInputItem> cris = new ArrayList<CrawlerInputItem>();
|
||||
|
||||
CrawlerInputItem item1 = new CrawlerInputItem();
|
||||
item1.setName("ID");
|
||||
item1.setDataType("String");
|
||||
item1.setDescription("Auth ID");
|
||||
|
||||
CrawlerInputItem item2 = new CrawlerInputItem();
|
||||
item2.setName("PW");
|
||||
item2.setDataType("String");
|
||||
item2.setDescription("Auth PW");
|
||||
|
||||
CrawlerInputItem item3 = new CrawlerInputItem();
|
||||
item3.setName("AuthType");
|
||||
item3.setDataType("Select");
|
||||
item3.setDescription("MD5||SHA");
|
||||
|
||||
CrawlerInputItem item4 = new CrawlerInputItem();
|
||||
item4.setName("community");
|
||||
item4.setDataType("String");
|
||||
item4.setDescription("community");
|
||||
|
||||
CrawlerInputItem item5 = new CrawlerInputItem();
|
||||
item5.setName("textfield");
|
||||
item5.setDataType("String");
|
||||
item5.setDescription("User ID");
|
||||
|
||||
cris.add(item1);
|
||||
cris.add(item2);
|
||||
cris.add(item3);
|
||||
cris.add(item4);
|
||||
cris.add(item5);
|
||||
|
||||
this.inputItemDAO.createAll(cris);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.loafle.overflow.crawler.dao;
|
||||
|
||||
import com.loafle.overflow.dao.crawler.dao.JPACrawlerInputItemMappingDAO;
|
||||
import com.loafle.overflow.dao.crawler.model.Crawler;
|
||||
import com.loafle.overflow.dao.crawler.model.CrawlerInputItem;
|
||||
import com.loafle.overflow.dao.crawler.model.CrawlerInputItemMapping;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by geek@loafle.com on 17. 6. 8.
|
||||
*/
|
||||
@Ignore
|
||||
public class JPACrawlerInputItemMappingDAOTest {
|
||||
|
||||
private JPACrawlerInputItemMappingDAO mappingDAO = null;
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
this.mappingDAO = new JPACrawlerInputItemMappingDAO();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void TestInsert() {
|
||||
CrawlerInputItemMapping itemMapping = new CrawlerInputItemMapping();
|
||||
itemMapping.setCrawler(new Crawler((long)5));
|
||||
itemMapping.setCrawlerInputItem(new CrawlerInputItem((long)1));
|
||||
itemMapping.setPriority((short) 1);
|
||||
itemMapping.setRequiredType(true);
|
||||
|
||||
CrawlerInputItemMapping itemMapping1 = new CrawlerInputItemMapping();
|
||||
itemMapping1.setCrawler(new Crawler((long)5));
|
||||
itemMapping1.setCrawlerInputItem(new CrawlerInputItem((long)2));
|
||||
itemMapping1.setPriority((short) 2);
|
||||
itemMapping1.setRequiredType(true);
|
||||
|
||||
CrawlerInputItemMapping itemMapping2 = new CrawlerInputItemMapping();
|
||||
itemMapping2.setCrawler(new Crawler((long)1));
|
||||
itemMapping2.setCrawlerInputItem(new CrawlerInputItem((long)1));
|
||||
itemMapping2.setPriority((short) 1);
|
||||
itemMapping2.setRequiredType(true);
|
||||
|
||||
CrawlerInputItemMapping itemMapping3 = new CrawlerInputItemMapping();
|
||||
itemMapping3.setCrawler(new Crawler((long)1));
|
||||
itemMapping3.setCrawlerInputItem(new CrawlerInputItem((long)2));
|
||||
itemMapping3.setPriority((short) 2);
|
||||
itemMapping3.setRequiredType(true);
|
||||
|
||||
CrawlerInputItemMapping itemMapping4 = new CrawlerInputItemMapping();
|
||||
itemMapping4.setCrawler(new Crawler((long)1));
|
||||
itemMapping4.setCrawlerInputItem(new CrawlerInputItem((long)3));
|
||||
itemMapping4.setPriority((short) 3);
|
||||
itemMapping4.setRequiredType(true);
|
||||
|
||||
CrawlerInputItemMapping itemMapping5 = new CrawlerInputItemMapping();
|
||||
itemMapping5.setCrawler(new Crawler((long)2));
|
||||
itemMapping5.setCrawlerInputItem(new CrawlerInputItem((long)1));
|
||||
itemMapping5.setPriority((short) 1);
|
||||
itemMapping5.setRequiredType(true);
|
||||
|
||||
CrawlerInputItemMapping itemMapping6 = new CrawlerInputItemMapping();
|
||||
itemMapping6.setCrawler(new Crawler((long)2));
|
||||
itemMapping6.setCrawlerInputItem(new CrawlerInputItem((long)2));
|
||||
itemMapping6.setPriority((short) 2);
|
||||
itemMapping6.setRequiredType(true);
|
||||
|
||||
List<CrawlerInputItemMapping> crs = new ArrayList<CrawlerInputItemMapping>();
|
||||
crs.add(itemMapping);
|
||||
crs.add(itemMapping1);
|
||||
crs.add(itemMapping2);
|
||||
crs.add(itemMapping3);
|
||||
crs.add(itemMapping4);
|
||||
crs.add(itemMapping5);
|
||||
crs.add(itemMapping6);
|
||||
|
||||
this.mappingDAO.createAll(crs);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void TestFindByCrawlerId() {
|
||||
List<CrawlerInputItemMapping> ls = this.mappingDAO.findByCrawlerId(new Crawler((long)5));
|
||||
System.out.println(ls.size());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.loafle.overflow.email.dao;
|
||||
|
||||
import com.loafle.overflow.dao.email.dao.JPAEmailAuthDAO;
|
||||
import com.loafle.overflow.dao.email.model.EmailAuth;
|
||||
import com.loafle.overflow.dao.member.model.Member;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by geek@loafle.com on 17. 6. 6.
|
||||
*/
|
||||
@Ignore
|
||||
public class JPAEmailAuthDAOTest {
|
||||
|
||||
private JPAEmailAuthDAO emailAuthDAO = null;
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
|
||||
this.emailAuthDAO = new JPAEmailAuthDAO();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void createEmailAuth() {
|
||||
EmailAuth auth = new EmailAuth();
|
||||
|
||||
auth.setAuthToken("0F2003A6-83B0-40F5-B56A-0485F458CA911");
|
||||
auth.setMember(new Member(Long.valueOf(1)));
|
||||
auth.setIsInvalid(false);
|
||||
// auth.setUpdateDate(new Date());
|
||||
auth.setIsConfirm(false);
|
||||
EmailAuth ret = emailAuthDAO.create(auth);
|
||||
System.out.println(ret.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void updateEmailAuth() {
|
||||
EmailAuth auth = this.emailAuthDAO.find("1");
|
||||
|
||||
auth.setIsInvalid(true);
|
||||
auth.setUpdateDate(new Date());
|
||||
auth.setConfirmDate(new Date());
|
||||
|
||||
this.emailAuthDAO.update(auth);
|
||||
System.out.println(auth.getConfirmDate());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void TestFindByAuthToken() {
|
||||
EmailAuth auth = new EmailAuth();
|
||||
auth.setAuthToken("3C03F8AB-1D4D-4C8A-8C36-EE2D644988B5");
|
||||
|
||||
EmailAuth temp = this.emailAuthDAO.findByAuthToken(auth);
|
||||
|
||||
System.out.println(temp.getId());
|
||||
Assert.assertNotNull(temp);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void TestFindByMemberId() {
|
||||
EmailAuth auth = new EmailAuth();
|
||||
auth.setMember(new Member((long)4));
|
||||
List<EmailAuth> ems = this.emailAuthDAO.findByMemberId(auth);
|
||||
|
||||
System.out.println(ems.get(0).getMember().getEmail());
|
||||
Assert.assertEquals((long)1, (long)ems.size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.loafle.overflow.member.dao;
|
||||
|
||||
import com.loafle.overflow.dao.member.dao.JPAMemberDAO;
|
||||
import com.loafle.overflow.dao.member.model.Member;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 4.
|
||||
*/
|
||||
@Ignore
|
||||
public class JPAMemberDAOTest {
|
||||
|
||||
private JPAMemberDAO jpaMemberDAO = null;
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
|
||||
this.jpaMemberDAO = new JPAMemberDAO();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findByEmail() throws Exception {
|
||||
}
|
||||
|
||||
// @Ignore
|
||||
@Test
|
||||
public void createMember() {
|
||||
Member m = new Member();
|
||||
|
||||
m.setName("geek");
|
||||
m.setCompany("loafle");
|
||||
m.setDigest("bbbbbbbbb");
|
||||
m.setPwSalt("salktttt");
|
||||
m.setPhone("000-000-0000");
|
||||
m.setEmail("geek@loafle.com");
|
||||
|
||||
this.jpaMemberDAO.create(m);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.loafle.overflow.noauthagent.dao;
|
||||
|
||||
import com.loafle.overflow.dao.noauthagent.dao.JPANoAuthAgentDAO;
|
||||
import com.loafle.overflow.dao.noauthagent.model.NoAuthAgent;
|
||||
import com.loafle.overflow.dao.noauthagent.type.AuthType;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 4.
|
||||
*/
|
||||
public class JPANoAuthAgentDAOTest {
|
||||
|
||||
private JPANoAuthAgentDAO jpaNoAuthAgentDAO = null;
|
||||
|
||||
@Before
|
||||
public void Before() {
|
||||
this.jpaNoAuthAgentDAO = new JPANoAuthAgentDAO();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findByTempKey() throws Exception {
|
||||
|
||||
NoAuthAgent noAuthAgent = new NoAuthAgent();
|
||||
noAuthAgent.setTempKey("3398473-90847903874");
|
||||
|
||||
NoAuthAgent aa = this.jpaNoAuthAgentDAO.findByTempKey(noAuthAgent);
|
||||
|
||||
System.out.println(aa.getAuthStatus());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findAllByNoAuth() throws Exception {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void createNoAuthAgent() {
|
||||
NoAuthAgent noAuthAgent = new NoAuthAgent();
|
||||
|
||||
|
||||
noAuthAgent.setApiKey("aaaaaaa");
|
||||
noAuthAgent.setDate(new Date());
|
||||
noAuthAgent.setHostName("Snoop pc");
|
||||
noAuthAgent.setLocalIP(4123);
|
||||
noAuthAgent.setTempKey("3398473-90847903874");
|
||||
noAuthAgent.setAuthStatus(AuthType.WAIT);
|
||||
|
||||
this.jpaNoAuthAgentDAO.create(noAuthAgent);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.loafle.overflow.sensor.dao;
|
||||
|
||||
import com.loafle.overflow.dao.crawler.model.Crawler;
|
||||
import com.loafle.overflow.dao.sensor.dao.JPASensorDao;
|
||||
import com.loafle.overflow.dao.sensor.dao.SensorDao;
|
||||
import com.loafle.overflow.dao.sensor.model.Sensor;
|
||||
import com.loafle.overflow.dao.target.model.Target;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 9.
|
||||
*/
|
||||
public class JPASensorDaoTest {
|
||||
|
||||
private SensorDao sensorDao = null;
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
this.sensorDao = new JPASensorDao();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findAllByAgentID() throws Exception {
|
||||
}
|
||||
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void create() {
|
||||
|
||||
|
||||
Sensor sensor = new Sensor();
|
||||
|
||||
Crawler crawler = new Crawler();
|
||||
crawler.setId(1L);
|
||||
|
||||
Target target = new Target();
|
||||
target.setId(1L);
|
||||
|
||||
sensor.setCrawler(crawler);
|
||||
sensor.setInterval(1);
|
||||
sensor.setNotification("nothing");
|
||||
sensor.setTarget(target);
|
||||
|
||||
this.sensorDao.create(sensor);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void list() {
|
||||
|
||||
// this.sensorDao.findAllByAgentID()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.loafle.overflow.sensor.dao;
|
||||
|
||||
import com.loafle.overflow.dao.sensor.dao.JPASensorItemCategoryDao;
|
||||
import com.loafle.overflow.dao.sensor.dao.SensorItemCategoryDao;
|
||||
import com.loafle.overflow.dao.sensor.model.SensorItemCategory;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 9.
|
||||
*/
|
||||
public class JPASensorItemCategoryDaoTest {
|
||||
|
||||
private SensorItemCategoryDao sensorItemCategoryDao = null;
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
|
||||
this.sensorItemCategoryDao = new JPASensorItemCategoryDao();
|
||||
}
|
||||
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void create() {
|
||||
|
||||
SensorItemCategory sensorItemCategory = new SensorItemCategory();
|
||||
|
||||
sensorItemCategory.setName("count");
|
||||
sensorItemCategory.setDescription("count !!!!");
|
||||
|
||||
this.sensorItemCategoryDao.create(sensorItemCategory);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.loafle.overflow.sensor.dao;
|
||||
|
||||
import com.loafle.overflow.dao.crawler.model.Crawler;
|
||||
import com.loafle.overflow.dao.sensor.dao.JPASensorItemDao;
|
||||
import com.loafle.overflow.dao.sensor.dao.SensorItemDao;
|
||||
import com.loafle.overflow.dao.sensor.model.SensorItem;
|
||||
import com.loafle.overflow.dao.sensor.model.SensorItemCategory;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 9.
|
||||
*/
|
||||
public class JPASensorItemDaoTest {
|
||||
|
||||
private SensorItemDao sensorItemDao = null;
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
this.sensorItemDao = new JPASensorItemDao();
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void create() {
|
||||
|
||||
|
||||
SensorItem sensorItem = new SensorItem();
|
||||
|
||||
Crawler crawler = new Crawler();
|
||||
crawler.setId(1L);
|
||||
|
||||
SensorItemCategory category = new SensorItemCategory();
|
||||
category.setId(1L);
|
||||
|
||||
sensorItem.setCrawler(crawler);
|
||||
sensorItem.setDataType("int");
|
||||
sensorItem.setDescription("count getget");
|
||||
sensorItem.setName("net.mysql.connection_count");
|
||||
sensorItem.setSensorItemCategory(category);
|
||||
|
||||
this.sensorItemDao.create(sensorItem);
|
||||
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void list() {
|
||||
|
||||
Crawler crawler = new Crawler();
|
||||
crawler.setId(1L);
|
||||
|
||||
List<SensorItem> is = this.sensorItemDao.findAllByCrawlerId(crawler);
|
||||
|
||||
|
||||
System.out.println(is.size());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.loafle.overflow.sensor.dao;
|
||||
|
||||
import com.loafle.overflow.dao.sensor.dao.JPASensorItemMappingDao;
|
||||
import com.loafle.overflow.dao.sensor.dao.SensorItemMappingDao;
|
||||
import com.loafle.overflow.dao.sensor.model.Sensor;
|
||||
import com.loafle.overflow.dao.sensor.model.SensorItem;
|
||||
import com.loafle.overflow.dao.sensor.model.SensorItemMapping;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 9.
|
||||
*/
|
||||
public class JPASensorItemMappingDaoTest {
|
||||
|
||||
private SensorItemMappingDao sensorItemMappingDao = null;
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
this.sensorItemMappingDao = new JPASensorItemMappingDao();
|
||||
}
|
||||
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void create() {
|
||||
|
||||
SensorItemMapping mapping = new SensorItemMapping();
|
||||
|
||||
Sensor sensor = new Sensor();
|
||||
|
||||
sensor.setId(1L);
|
||||
|
||||
SensorItem sensorItem = new SensorItem();
|
||||
|
||||
sensorItem.setId(1L);
|
||||
|
||||
mapping.setSensor(sensor);
|
||||
|
||||
mapping.setSensorItem(sensorItem);
|
||||
|
||||
this.sensorItemMappingDao.create(mapping);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void list() {
|
||||
|
||||
Sensor sensor = new Sensor();
|
||||
|
||||
sensor.setId(1L);
|
||||
|
||||
List<SensorItemMapping> ml = this.sensorItemMappingDao.findAllBySensorId(sensor);
|
||||
|
||||
System.out.println(ml.size());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
17
src/test/resources/logback.xml
Normal file
17
src/test/resources/logback.xml
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="3 seconds">
|
||||
<contextName>overflow_proxy_db</contextName>
|
||||
<!-- TRACE > DEBUG > INFO > WARN > ERROR -->
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>
|
||||
%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{32} - %msg%n
|
||||
</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="DEBUG">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
<logger name="com.loafle" level="ALL" />
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user