use of com.xrtb.common.HttpPostGet in project XRTB by benmfaul.
the class TestValidBids method testSmartyadsEncoding.
@Test
public void testSmartyadsEncoding() throws Exception {
HttpPostGet http = new HttpPostGet();
String bid = Charset.defaultCharset().decode(ByteBuffer.wrap(Files.readAllBytes(Paths.get("./SampleBids/nexage.txt")))).toString();
String s = null;
long time = 0;
String xtime = null;
try {
try {
time = System.currentTimeMillis();
s = http.sendPost("http://" + Config.testHost + "/rtb/bids/smartyads", bid);
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);
int index = s.indexOf("%3C");
assertTrue(index == -1);
} catch (Exception e) {
e.printStackTrace();
fail(e.toString());
}
}
use of com.xrtb.common.HttpPostGet in project XRTB by benmfaul.
the class TestValidBids method testFyberEncoding.
@Test
public void testFyberEncoding() throws Exception {
HttpPostGet http = new HttpPostGet();
String bid = Charset.defaultCharset().decode(ByteBuffer.wrap(Files.readAllBytes(Paths.get("./SampleBids/nexage.txt")))).toString();
String s = null;
long time = 0;
String xtime = null;
try {
try {
time = System.currentTimeMillis();
s = http.sendPost("http://" + Config.testHost + "/rtb/bids/fyber", bid);
time = System.currentTimeMillis() - time;
xtime = http.getHeader("X-TIME");
} catch (Exception error) {
fail("Can't connect to test host: " + Config.testHost);
}
assertNotNull(s);
int index = s.indexOf("%3C");
assertTrue(index == -1);
} catch (Exception e) {
e.printStackTrace();
fail(e.toString());
}
}
use of com.xrtb.common.HttpPostGet in project XRTB by benmfaul.
the class TestValidBids method testGeneric.
@Test
public void testGeneric() 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 testAppNexus.
@Test
public void testAppNexus() 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/appnexus.txt")))).toString();
try {
time = System.currentTimeMillis();
s = http.sendPost("http://" + Config.testHost + "/rtb/bids/appnexus", 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("test-appnexus-id"));
list = (List) m.get("bid");
assertEquals(list.size(), 1);
m = (Map) list.get(0);
System.out.println(m);
} catch (Exception e) {
e.printStackTrace();
fail(e.toString());
}
}
use of com.xrtb.common.HttpPostGet in project XRTB by benmfaul.
the class TestValidBids method testRespondWithNoBid.
/**
* 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 testRespondWithNoBid() throws Exception {
HttpPostGet http = new HttpPostGet();
String s = Charset.defaultCharset().decode(ByteBuffer.wrap(Files.readAllBytes(Paths.get("./SampleBids/nexage50x50.txt")))).toString();
try {
// make it an odd size so there is
s = s.replaceAll("50,", "49,");
// no match
s = http.sendPost("http://" + Config.testHost + "/rtb/bids/nexage", s);
} catch (Exception error) {
fail("Network error");
}
assertTrue(http.getResponseCode() == 204);
assertTrue(http.getHeader("X-REASON").equals("No matching campaign"));
}
Aggregations