use of com.xrtb.common.HttpPostGet in project XRTB by benmfaul.
the class TestValidBids method testAdIdSubInBannerAndJavascript.
@Test
public void testAdIdSubInBannerAndJavascript() throws Exception {
HttpPostGet http = new HttpPostGet();
String bid = Charset.defaultCharset().decode(ByteBuffer.wrap(Files.readAllBytes(Paths.get("./SampleBids/nexageJavaScript.txt")))).toString();
String s = null;
long time = 0;
String xtime = null;
try {
try {
time = System.currentTimeMillis();
s = http.sendPost("http://" + Config.testHost + "/rtb/bids/smaato", 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);
assertFalse(s.contains("app_id"));
assertFalse(s.contains("{bid}"));
} catch (Exception e) {
e.printStackTrace();
fail(e.toString());
}
}
use of com.xrtb.common.HttpPostGet in project XRTB by benmfaul.
the class TestValidBids method testVideoRespondWithBid.
/**
* Test a valid bid response.
*
* @throws Exception
* on networking errors.
*/
@Test
public void testVideoRespondWithBid() throws Exception {
HttpPostGet http = new HttpPostGet();
String s = Charset.defaultCharset().decode(ByteBuffer.wrap(Files.readAllBytes(Paths.get("./SampleBids/nexageVideo.txt")))).toString();
long time = 0;
/******** Make one bid to prime the pump */
try {
http.sendPost("http://" + Config.testHost + "/rtb/bids/nexage", s);
} catch (Exception error) {
fail("Network error");
}
/*********************************/
String xtime = null;
try {
s = Charset.defaultCharset().decode(ByteBuffer.wrap(Files.readAllBytes(Paths.get("./SampleBids/nexageVideo.txt")))).toString();
try {
time = System.currentTimeMillis();
s = http.sendPost("http://" + Config.testHost + "/rtb/bids/nexage", s);
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");
}
List list = (List) m.get("seatbid");
m = (Map) list.get(0);
assertNotNull(m);
String test = (String) m.get("seat");
assertTrue(test.equals("99999999"));
list = (List) m.get("bid");
assertEquals(list.size(), 1);
m = (Map) list.get(0);
assertNotNull(m);
test = (String) m.get("impid");
assertTrue(test.equals("35c22289-06e2-48e9-a0cd-94aeb79fab43-1"));
test = (String) m.get("id");
assertTrue(test.equals("35c22289-06e2-48e9-a0cd-94aeb79fab43") || test.equals("123"));
double d = (Double) m.get("price");
test = (String) m.get("adid");
assertTrue(test.equals("ben:payday"));
test = (String) m.get("cid");
assertTrue(test.equals("ben:payday"));
test = (String) m.get("crid");
assertTrue(test.equals("iAmVideo"));
list = (List) m.get("adomain");
test = (String) list.get(0);
assertTrue(test.equals("originator.com"));
System.out.println("XTIME: " + xtime);
System.out.println("RTTIME: " + time);
System.out.println(s);
assertFalse(s.contains("pub"));
assertFalse(s.contains("ad_id"));
assertFalse(s.contains("bid_id"));
assertFalse(s.contains("site_id"));
} catch (Exception e) {
e.printStackTrace();
fail(e.toString());
}
}
use of com.xrtb.common.HttpPostGet in project XRTB by benmfaul.
the class TestValidBids method testJavaScriptAppId.
/**
* Test a valid bid response with no bid, the campaign doesn't match width
* or height of the bid request
*
* @throws Exception
* on network errors.
*/
@Test
public void testJavaScriptAppId() throws Exception {
response = null;
latch = new CountDownLatch(1);
HttpPostGet http = new HttpPostGet();
String s = Charset.defaultCharset().decode(ByteBuffer.wrap(Files.readAllBytes(Paths.get("./SampleBids/apptest.txt")))).toString();
try {
s = http.sendPost("http://" + Config.testHost + "/rtb/bids/smaato", s, 1000000, 1000000);
} catch (Exception error) {
fail("Network error");
}
System.out.println(s);
int rc = http.getResponseCode();
assertTrue(rc == 200);
assertFalse(s.contains("{app_id}"));
}
use of com.xrtb.common.HttpPostGet in project XRTB by benmfaul.
the class TestValidBids method testC1x.
@Test
public void testC1x() throws Exception {
HttpPostGet http = new HttpPostGet();
String bid = Charset.defaultCharset().decode(ByteBuffer.wrap(Files.readAllBytes(Paths.get("./SampleBids/c1x.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");
}
}
use of com.xrtb.common.HttpPostGet in project XRTB by benmfaul.
the class TestValidBids method testStroer.
@Test
public void testStroer() throws Exception {
HttpPostGet http = new HttpPostGet();
String s = null;
long time = 0;
String xtime = null;
try {
s = Charset.defaultCharset().decode(ByteBuffer.wrap(Files.readAllBytes(Paths.get("./SampleBids/nexage.txt")))).toString();
try {
time = System.currentTimeMillis();
s = http.sendPost("http://" + Config.testHost + "/rtb/bids/stroer", s, 100000, 100000);
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);
Map m = null;
try {
m = DbTools.mapper.readValue(s, Map.class);
} catch (Exception error) {
fail("Bad JSON for bid");
}
List list = (List) m.get("seatbid");
m = (Map) list.get(0);
assertNotNull(m);
String test = (String) m.get("seat");
assertTrue(test.equals("stroer-id"));
list = (List) m.get("bid");
assertEquals(list.size(), 1);
m = (Map) list.get(0);
Map x = (Map) m.get("ext");
assertNotNull(x);
s = (String) x.get("avr");
assertNotNull(s);
assertTrue(s.equals("the-avr"));
s = (String) x.get("avn");
assertNotNull(s);
assertTrue(s.equals("the-avn"));
} catch (Exception e) {
e.printStackTrace();
fail(e.toString());
}
}
Aggregations