use of com.xrtb.bidder.AbortableCountDownLatch in project XRTB by benmfaul.
the class TestCampaignProcessor method testNoCampaigns.
/**
* Test the situation where no campaigns are loaded in the system.
* @throws Exception when the bid JSON file fails to load or has a JSON error in it.
*/
@Test
public void testNoCampaigns() throws Exception {
InputStream is = Configuration.getInputStream("SampleBids/nexage.txt");
BidRequest request = new BidRequest(is);
AbortableCountDownLatch latch = new AbortableCountDownLatch(1, 1);
CountDownLatch flag = new CountDownLatch(1);
CampaignProcessor proc = new CampaignProcessor(null, request, flag, latch);
flag.countDown();
proc.run();
SelectedCreative resp = proc.getSelectedCreative();
// flag.countDown(); // back when proc was a thread
try {
latch.await();
fail("This latch should have aborted");
} catch (Exception e) {
}
assertNull(resp);
}
use of com.xrtb.bidder.AbortableCountDownLatch in project XRTB by benmfaul.
the class TestCampaignProcessor method testOneMatching.
/**
* Load a campaign and then use the bidder's campaign processor to make a bid response.
* @throws Exception if the config file or the sample bid file fails to load, or they contain JSON errors.
*/
// @Test
public void testOneMatching() throws Exception {
InputStream is = Configuration.getInputStream("SampleBids/nexage.txt");
BidRequest request = new BidRequest(is);
Configuration cf = Configuration.getInstance();
cf.clear();
cf.initialize("Campaigns/payday.json");
Campaign c = cf.campaignsList.get(0);
AbortableCountDownLatch latch = new AbortableCountDownLatch(1, 1);
CountDownLatch flag = new CountDownLatch(1);
CampaignProcessor proc = new CampaignProcessor(c, request, flag, latch);
flag.countDown();
latch.await();
SelectedCreative resp = proc.getSelectedCreative();
assertNotNull(resp);
assertTrue(resp.getCreative().dimensions.get(0).getLeftX() == 320);
}
Aggregations