init add remove
This commit is contained in:
parent
36e93f76d0
commit
d0c55a7aea
61
src/test/java/com/loafle/overflow/crawler/CrawlerTest.java
Normal file
61
src/test/java/com/loafle/overflow/crawler/CrawlerTest.java
Normal file
|
@ -0,0 +1,61 @@
|
|||
package com.loafle.overflow.crawler;
|
||||
|
||||
import com.loafle.overflow.crawler.config.Config;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 4. 13.
|
||||
*/
|
||||
public class CrawlerTest {
|
||||
|
||||
class TestCrawlerImpl extends Crawler {
|
||||
|
||||
@Override
|
||||
public Object getInternal(Config c) throws Exception {
|
||||
return c.getId();
|
||||
}
|
||||
}
|
||||
|
||||
private TestCrawlerImpl impl;
|
||||
|
||||
@Before
|
||||
public void afterInit() throws Exception {
|
||||
impl = new TestCrawlerImpl();
|
||||
ClassLoader classLoader = getClass().getClassLoader();
|
||||
impl.init(classLoader.getResource("config").getFile());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void add() throws Exception {
|
||||
assertEquals(true,impl.add("example.json"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void get() throws Exception {
|
||||
assertEquals(impl.getConfig("example.json").getId(),impl.get("example.json"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void configTest() throws Exception {
|
||||
Config c = new Config();
|
||||
c.setId("1928371092873123");
|
||||
impl.putConfig("test",c);
|
||||
c = impl.getConfig("test");
|
||||
assertEquals(c.getId(),"1928371092873123");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void remove() throws Exception {
|
||||
assertEquals(true,impl.remove("example.json"));
|
||||
assertEquals(null, impl.getConfig("example.json"));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user