use of com.xrtb.common.Campaign in project XRTB by benmfaul.
the class Config method setup.
/**
* JUNIT Test configuration for shards.
*
*/
public static void setup(String shard, int port) throws Exception {
try {
if (server == null) {
DbTools tools = new DbTools(redisHost);
tools.clear();
tools.loadDatabase("database.json");
server = new RTBServer("./Campaigns/payday.json", shard, port, port + 1);
int wait = 0;
while (!server.isReady() && wait < 10) {
Thread.sleep(1000);
wait++;
}
if (wait == 10) {
fail("Server never started");
}
} else {
Configuration c = Configuration.getInstance();
c.campaignsList.clear();
User u = DataBaseObject.getInstance().get("ben");
for (Campaign camp : u.campaigns) {
c.addCampaign("ben", camp.adId);
}
}
} catch (Exception e) {
e.printStackTrace();
fail(e.toString());
}
}
use of com.xrtb.common.Campaign in project XRTB by benmfaul.
the class Config method setup.
public static void setup() throws Exception {
try {
DbTools tools = new DbTools("localhost:3000");
tools.clear();
tools.loadDatabase("database.json");
if (server == null) {
server = new RTBServer("./Campaigns/payday.json");
int wait = 0;
while (!server.isReady() && wait < 10) {
Thread.sleep(1000);
wait++;
}
if (wait == 10) {
fail("Server never started");
}
if (server.getCampaigns().size() == 0) {
fail("NO CAMPAIGNS LOADED");
}
Thread.sleep(1000);
} else {
Configuration c = Configuration.getInstance();
c.campaignsList.clear();
User u = DataBaseObject.getInstance().get("ben");
for (Campaign camp : u.campaigns) {
c.addCampaign("ben", camp.adId);
}
}
} catch (Exception e) {
e.printStackTrace();
fail(e.toString());
}
}
use of com.xrtb.common.Campaign in project XRTB by benmfaul.
the class TestAdx method testSetup.
@BeforeClass
public static void testSetup() {
try {
DbTools tools = new DbTools("localhost:3000");
tools.clear();
tools.loadDatabase("database.json");
if (server == null) {
server = new RTBServer("./Campaigns/payday.json");
int wait = 0;
while (!server.isReady() && wait < 10) {
Thread.sleep(1000);
wait++;
}
if (wait == 10) {
fail("Server never started");
}
Thread.sleep(1000);
} else {
Configuration c = Configuration.getInstance();
c.campaignsList.clear();
User u = DataBaseObject.getInstance().get("ben");
for (Campaign camp : u.campaigns) {
c.addCampaign("ben", camp.adId);
}
}
} catch (Exception e) {
e.printStackTrace();
fail(e.toString());
}
}
use of com.xrtb.common.Campaign in project XRTB by benmfaul.
the class TestCampaignProcessor method testJavascriptCreative.
@Test
public void testJavascriptCreative() throws Exception {
Configuration cf = Configuration.getInstance();
cf.clear();
cf.initialize("Campaigns/payday.json");
for (Campaign c : cf.campaignsList) {
for (Creative cc : c.creatives) {
if (cc.impid.equals("iamrichmedia")) {
System.out.println(cc.forwardurl);
assertTrue((cc.forwardurl.contains("\\")));
return;
}
}
}
}
use of com.xrtb.common.Campaign in project XRTB by benmfaul.
the class TestDatabase method makeFile.
/**
* Test making the user database from scratch/
* @throws Exception on JSON parsing of the file.
*/
@Test
public void makeFile() throws Exception {
List<User> list = new ArrayList();
User u = new User("ben");
list.add(u);
String content = new String(Files.readAllBytes(Paths.get("stub.json")));
Campaign c = new Campaign(content);
c.adId = "ben:new-campaign";
u.campaigns.add(c);
assertTrue(c.date.size() == 2);
content = DbTools.mapper.writer().withDefaultPrettyPrinter().writeValueAsString(list);
System.out.println(content);
;
System.out.println("-------------------------");
List<User> x = DbTools.mapper.readValue(content, DbTools.mapper.getTypeFactory().constructCollectionType(List.class, User.class));
User z = x.get(0);
System.out.println(z);
}
Aggregations