use of com.xrtb.pojo.Bid in project XRTB by benmfaul.
the class TestWinProcessing method testWinProcessingInvalidHttp.
@Test
public void testWinProcessingInvalidHttp() throws Exception {
HttpPostGet http = new HttpPostGet();
// Make the bid
String s = Charset.defaultCharset().decode(ByteBuffer.wrap(Files.readAllBytes(Paths.get("./SampleBids/nexage.txt")))).toString();
s = s.replaceAll("35c22289-06e2-48e9-a0cd-94aeb79fab4", "ADM#ssp#1023#56425#1490316943.792#68738174.223.128.39-1490316943883-130-0-0-6808053509727162318");
if (s.indexOf("ADM#") == -1) {
s = s.replaceAll("123", "ADM#ssp#1023#56425#1490316943.792#68738174.223.128.39-1490316943883-130-0-0-6808053509727162318");
}
/**
* Send the bid
*/
try {
s = http.sendPost("http://" + Config.testHost + "/rtb/bids/nexage", s, 3000000, 3000000);
} catch (Exception error) {
fail("Can't connect to test host: " + Config.testHost);
}
int code = http.getResponseCode();
assertTrue(code == 200);
Bid bid = null;
System.out.println(s);
try {
bid = new Bid(s);
} catch (Exception error) {
error.printStackTrace();
fail();
}
/**
* Send the win notification
*/
try {
String repl = bid.nurl.replaceAll("\\$", "");
bid.nurl = repl.replace("{AUCTION_PRICE}", ".05");
s = http.sendPost(bid.nurl, "", 300000, 300000);
} catch (Exception error) {
error.printStackTrace();
fail();
}
System.out.println("---->" + s);
;
assertTrue(s.length() > 10);
}
use of com.xrtb.pojo.Bid in project XRTB by benmfaul.
the class TestWinProcessing method testCappingTimes3.
/**
* 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 testCappingTimes3() throws Exception {
redisson.del("capped_blocker166.137.138.18");
for (Campaign c : Configuration.getInstance().campaignsList) {
if (c.adId.equals("ben:payday")) {
for (Creative cc : c.creatives) {
if (cc.impid.equals("blocker")) {
cc.capFrequency = 3;
break;
}
}
}
}
HttpPostGet http = new HttpPostGet();
String bid = Charset.defaultCharset().decode(ByteBuffer.wrap(Files.readAllBytes(Paths.get("./SampleBids/nexage50x50.txt")))).toString();
// Get 3 times is ok, but 4th is a no bid
String s = http.sendPost("http://" + Config.testHost + "/rtb/bids/nexage", bid, 100000, 100000);
assertNotNull(s);
int rc = http.getResponseCode();
assertTrue(rc == 200);
String value = redisson.get("capped_blocker166.137.138.18");
assertTrue(value == null);
Bid win = new Bid(s);
String repl = win.nurl.replaceAll("\\$", "");
win.nurl = repl.replace("{AUCTION_PRICE}", ".05");
s = http.sendPost(win.nurl, "");
value = redisson.get("capped_blocker166.137.138.18");
assertTrue(value.equals("1"));
s = http.sendPost("http://" + Config.testHost + "/rtb/bids/nexage", bid, 100000, 100000);
assertNotNull(s);
rc = http.getResponseCode();
assertTrue(rc == 200);
s = http.sendPost(win.nurl, "");
value = redisson.get("capped_blocker166.137.138.18");
assertTrue(value.equals("2"));
s = http.sendPost("http://" + Config.testHost + "/rtb/bids/nexage", bid, 100000, 100000);
assertNotNull(s);
rc = http.getResponseCode();
assertTrue(rc == 200);
s = http.sendPost(win.nurl, "");
value = redisson.get("capped_blocker166.137.138.18");
assertTrue(value.equals("3"));
// better no bid.
s = http.sendPost("http://" + Config.testHost + "/rtb/bids/nexage", bid, 100000, 100000);
rc = http.getResponseCode();
assertTrue(rc == 204);
assertNull(s);
rc = http.getResponseCode();
value = redisson.get("capped_blocker166.137.138.18");
assertTrue(value.equals("3"));
System.out.println("DONE!");
}
use of com.xrtb.pojo.Bid in project XRTB by benmfaul.
the class TestWinProcessing method testWinProcessingEpom.
@Test
public void testWinProcessingEpom() throws Exception {
HttpPostGet http = new HttpPostGet();
redisson.del("35c22289-06e2-48e9-a0cd-94aeb79fab43");
// Make the bid
String s = Charset.defaultCharset().decode(ByteBuffer.wrap(Files.readAllBytes(Paths.get("./SampleBids/nexage.txt")))).toString();
/**
* Send the bid
*/
try {
s = http.sendPost("http://" + Config.testHost + "/rtb/bids/epomx", s, 3000000, 3000000);
} catch (Exception error) {
fail("Can't connect to test host: " + Config.testHost);
}
int code = http.getResponseCode();
assertTrue(code == 200);
Bid bid = null;
System.out.println(s);
int x = s.indexOf("{bid_id");
assertTrue(x == -1);
x = s.indexOf("%7Bbid_id");
assertTrue(x == -1);
try {
bid = new Bid(s);
} catch (Exception error) {
error.printStackTrace();
fail();
}
// Now retrieve the bid information from the cache
Map m = redisson.hgetAll(bid.id);
assertTrue(!m.isEmpty());
String price = (String) m.get("PRICE");
System.out.println("PRICE: " + price);
assertNotNull(price);
assertTrue(!price.equals("0.0"));
/**
* Send the win notification
*/
try {
String repl = bid.nurl.replaceAll("\\$", "");
bid.nurl = repl.replace("{AUCTION_PRICE}", ".05");
s = http.sendPost(bid.nurl, "");
} catch (Exception error) {
error.printStackTrace();
fail();
}
System.out.println(s);
x = s.indexOf("{creative_");
assertTrue(x == -1);
/*
* Make sure the returned adm is not crap html
*/
DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
InputSource is = new InputSource();
is.setCharacterStream(new StringReader(s));
// Document doc = db.parse(is);
// Check to see the bid was removed from the cache
m = redisson.hgetAll(bid.id);
assertNull(m);
}
use of com.xrtb.pojo.Bid in project XRTB by benmfaul.
the class TestWinProcessing method testWinProcessingCappture.
@Test
public void testWinProcessingCappture() throws Exception {
HttpPostGet http = new HttpPostGet();
redisson.del("35c22289-06e2-48e9-a0cd-94aeb79fab43");
// Make the bid
String s = Charset.defaultCharset().decode(ByteBuffer.wrap(Files.readAllBytes(Paths.get("./SampleBids/nexage.txt")))).toString();
/**
* Send the bid
*/
try {
s = http.sendPost("http://" + Config.testHost + "/rtb/bids/cappture", s, 3000000, 3000000);
} catch (Exception error) {
error.printStackTrace();
fail("Can't connect to test host: " + Config.testHost);
}
int code = http.getResponseCode();
assertTrue(code == 200);
Bid bid = null;
System.out.println(s);
int x = s.indexOf("{bid_id");
assertTrue(x == -1);
x = s.indexOf("%7Bbid_id");
assertTrue(x == -1);
try {
bid = new Bid(s);
} catch (Exception error) {
error.printStackTrace();
fail();
}
// Now retrieve the bid information from the cache
Map m = redisson.hgetAll(bid.id);
assertTrue(!m.isEmpty());
String price = (String) m.get("PRICE");
assertNotNull(price);
assertTrue(!price.equals("0"));
/**
* Send the win notification
*/
try {
String repl = bid.nurl.replaceAll("\\$", "");
bid.nurl = repl.replace("{AUCTION_PRICE}", ".05");
s = http.sendPost(bid.nurl, "");
} catch (Exception error) {
error.printStackTrace();
fail();
}
System.out.println(s);
x = s.indexOf("{creative_");
assertTrue(x == -1);
/*
* Make sure the returned adm is not crap html
*/
DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
InputSource is = new InputSource();
is.setCharacterStream(new StringReader(s));
// Document doc = db.parse(is);
// Check to see the bid was removed from the cache
m = redisson.hgetAll(bid.id);
assertNull(m);
}
Aggregations