test: поправлена конфигурация теста
This commit is contained in:
@@ -4,12 +4,10 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import kinosearch.core.SpringConfig;
|
||||
import kinosearch.core.browser.Browser;
|
||||
import kinosearch.core.browser.ApacheHttpBrowser;
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@@ -22,11 +20,7 @@ public class TestBrowser {
|
||||
private final String data = "login=123&password=456";
|
||||
private final String header_name = "Mytestheader";
|
||||
@Autowired
|
||||
private ApplicationContext context;
|
||||
|
||||
private Browser getBrowser() {
|
||||
return context.getBean(Browser.class);
|
||||
}
|
||||
private Browser browser;
|
||||
|
||||
private void setup_headers(Browser browser) {
|
||||
browser.setHeader(header_name, "true");
|
||||
@@ -39,7 +33,6 @@ public class TestBrowser {
|
||||
|
||||
@Test
|
||||
public void testGet() throws IOException {
|
||||
Browser browser = getBrowser();
|
||||
setup_headers(browser);
|
||||
|
||||
String result = browser.get("https://httpbin.org/get?" + data);
|
||||
@@ -56,7 +49,6 @@ public class TestBrowser {
|
||||
|
||||
@Test
|
||||
public void testPost() throws IOException {
|
||||
Browser browser = getBrowser();
|
||||
setup_headers(browser);
|
||||
|
||||
String result = browser.post("https://httpbin.org/post", data);
|
||||
|
||||
@@ -3,16 +3,13 @@ package core.warez;
|
||||
import kinosearch.core.Kino;
|
||||
import kinosearch.core.SpringConfig;
|
||||
import kinosearch.core.warez.KinoWarez;
|
||||
import kinosearch.core.warez.Onlinelife;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
@@ -21,14 +18,9 @@ import static org.junit.Assert.*;
|
||||
@ContextConfiguration(classes = {SpringConfig.class})
|
||||
public class TestOnlinelife {
|
||||
@Autowired
|
||||
private ApplicationContext context;
|
||||
@Qualifier("onlinelife")
|
||||
private KinoWarez kinoWarez;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
this.kinoWarez = context.getBean(Onlinelife.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNormal() {
|
||||
search(false);
|
||||
|
||||
Reference in New Issue
Block a user