Added JsonPage and finished implementation of digest auth page

This commit is contained in:
Ziver Koc 2016-11-04 16:52:10 +01:00
parent 2c7a9a6eff
commit 26c09452f3
10 changed files with 244 additions and 52 deletions

View file

@ -0,0 +1,34 @@
package zutil.net.http.page;
import org.junit.Test;
import zutil.io.IOUtil;
import zutil.net.http.HttpHeader;
import zutil.net.http.HttpTestUtil;
import zutil.parser.DataNode;
import java.io.IOException;
import java.util.Map;
import static org.junit.Assert.*;
/**
* @author Ziver on 2016-11-04.
*/
public class HttpJsonPageTest {
private HttpJsonPage page = new HttpJsonPage() {
@Override
protected DataNode jsonRespond(HttpHeader headers, Map<String, Object> session, Map<String, String> cookie, Map<String, String> request) {
return new DataNode(DataNode.DataType.Map);
}
};
@Test
public void simpleResponse() throws IOException {
HttpHeader header = HttpTestUtil.makeRequest(page);
assertEquals("application/json", header.getHeader("Content-Type"));
assertEquals("{}", IOUtil.readContentAsString(header.getInputStream()));
}
}