use of com.xrtb.common.HttpPostGet in project XRTB by benmfaul.
the class TestDeals method testPrivateResponse.
@Test
public void testPrivateResponse() throws Exception {
HttpPostGet http = new HttpPostGet();
String bid = Charset.defaultCharset().decode(ByteBuffer.wrap(Files.readAllBytes(Paths.get("./SampleBids/nexagePrivateAuction1.txt")))).toString();
String s = null;
long time = 0;
String xtime = null;
try {
time = System.currentTimeMillis();
s = http.sendPost("http://" + Config.testHost + "/rtb/bids/nexage", bid, 300000, 300000);
time = System.currentTimeMillis() - time;
xtime = http.getHeader("X-TIME");
} catch (Exception error) {
fail("Can't connect to test host: " + Config.testHost);
}
assertTrue(s.contains("ThisShouldBid"));
assertNotNull(s);
int code = http.getResponseCode();
assertEquals(code, 200);
}
use of com.xrtb.common.HttpPostGet in project XRTB by benmfaul.
the class TestDeals method testPrivateBidNoResponse.
/**
* Test a private auction with a deal not present in the campaigns.
* @throws Exception
*/
@Test
public void testPrivateBidNoResponse() throws Exception {
HttpPostGet http = new HttpPostGet();
String bid = Charset.defaultCharset().decode(ByteBuffer.wrap(Files.readAllBytes(Paths.get("./SampleBids/nexagePrivateAuction.txt")))).toString();
String s = null;
long time = 0;
String xtime = null;
try {
time = System.currentTimeMillis();
s = http.sendPost("http://" + Config.testHost + "/rtb/bids/nexage", bid, 300000, 300000);
time = System.currentTimeMillis() - time;
xtime = http.getHeader("X-TIME");
} catch (Exception error) {
fail("Can't connect to test host: " + Config.testHost);
}
assertNull(s);
int code = http.getResponseCode();
assertEquals(code, 204);
}
use of com.xrtb.common.HttpPostGet in project XRTB by benmfaul.
the class TestSmaato method testRichMedia.
/**
* Don't bid on richmedia (campaign is banner)
* @throws Exception on network errors.
*/
//@Test RichMedia test file has wrong w X h
public void testRichMedia() throws Exception {
HttpPostGet http = new HttpPostGet();
String xtime = null;
long time = 0;
String s = Charset.defaultCharset().decode(ByteBuffer.wrap(Files.readAllBytes(Paths.get("./SampleBids/smaatoRICHMEDIA.json")))).toString();
time = System.currentTimeMillis();
s = http.sendPost("http://" + Config.testHost + "/rtb/bids/smaato?testbid=bid", s, 100000, 100000);
time = System.currentTimeMillis() - time;
xtime = http.getHeader("X-TIME");
assertTrue(http.getResponseCode() != 204);
assertNotNull(s);
}
use of com.xrtb.common.HttpPostGet in project XRTB by benmfaul.
the class TestValidBids method testSuspect.
@Test
public void testSuspect() throws Exception {
HttpPostGet http = new HttpPostGet();
String bid = Charset.defaultCharset().decode(ByteBuffer.wrap(Files.readAllBytes(Paths.get("./SampleBids/suspect.txt")))).toString();
String s = null;
long time = 0;
String xtime = null;
try {
try {
time = System.currentTimeMillis();
s = http.sendPost("http://" + Config.testHost + "/rtb/bids/nexage", bid, 300000, 300000);
time = System.currentTimeMillis() - time;
xtime = http.getHeader("X-TIME");
} catch (Exception error) {
fail("Can't connect to test host: " + Config.testHost);
}
} catch (Exception e) {
e.printStackTrace();
fail(e.toString());
}
}
use of com.xrtb.common.HttpPostGet in project XRTB by benmfaul.
the class TestValidBids method testC1xMulti.
@Test
public void testC1xMulti() throws Exception {
HttpPostGet http = new HttpPostGet();
String bid = Charset.defaultCharset().decode(ByteBuffer.wrap(Files.readAllBytes(Paths.get("./SampleBids/c1xMulti.txt")))).toString();
String s = null;
long time = 0;
String xtime = null;
try {
time = System.currentTimeMillis();
s = http.sendPost("http://" + Config.testHost + "/rtb/bids/c1x", bid, 300000, 300000);
time = System.currentTimeMillis() - time;
xtime = http.getHeader("X-TIME");
} catch (Exception error) {
fail("Can't connect to test host: " + Config.testHost);
}
assertNotNull(s);
System.out.println(s + "\n----------");
Map m = null;
try {
m = DbTools.mapper.readValue(s, Map.class);
} catch (Exception error) {
fail("Bad JSON for bid");
}
}
Aggregations