Search in sources :

Example 6 with Configuration

use of com.xrtb.common.Configuration in project XRTB by benmfaul.

the class MyReader 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());
    }
}
Also used : RTBServer(com.xrtb.bidder.RTBServer) User(com.xrtb.db.User) Campaign(com.xrtb.common.Campaign) Configuration(com.xrtb.common.Configuration) DbTools(com.xrtb.tools.DbTools) BeforeClass(org.junit.BeforeClass)

Example 7 with Configuration

use of com.xrtb.common.Configuration in project XRTB by benmfaul.

the class BidResponse method createSmaatoTemplate.

/**
	 * Creates a template for the smaato exchange, which has an XML format for
	 * the ADM
	 */
private void createSmaatoTemplate() {
    if (creat.smaatoTemplate == null) {
        if (creat.forwardurl.contains("<SCRIPT") || creat.forwardurl.contains("<script")) {
            creat.smaatoTemplate = new StringBuilder(SmaatoTemplate.RICHMEDIA_TEMPLATE);
        } else {
            creat.smaatoTemplate = new StringBuilder(SmaatoTemplate.IMAGEAD_TEMPLATE);
        }
        System.out.println("New smaato template = " + new String(creat.smaatoTemplate));
        Configuration config = Configuration.getInstance();
        replaceAll(creat.smaatoTemplate, "__IMAGEURL__", config.SMAATOimageurl);
        replaceAll(creat.smaatoTemplate, "__TOOLTIP__", config.SMAATOtooltip);
        replaceAll(creat.smaatoTemplate, "__ADDITIONALTEXT__", config.SMAATOadditionaltext);
        replaceAll(creat.smaatoTemplate, "__PIXELURL__", config.SMAATOpixelurl);
        replaceAll(creat.smaatoTemplate, "__CLICKURL__", config.SMAATOclickurl);
        replaceAll(creat.smaatoTemplate, "__TEXT__", config.SMAATOtext);
        replaceAll(creat.smaatoTemplate, "__JAVASCRIPT__", config.SMAATOscript);
    }
}
Also used : Configuration(com.xrtb.common.Configuration)

Example 8 with Configuration

use of com.xrtb.common.Configuration 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());
    }
}
Also used : RTBServer(com.xrtb.bidder.RTBServer) User(com.xrtb.db.User) Campaign(com.xrtb.common.Campaign) Configuration(com.xrtb.common.Configuration) DbTools(com.xrtb.tools.DbTools)

Example 9 with Configuration

use of com.xrtb.common.Configuration 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());
    }
}
Also used : RTBServer(com.xrtb.bidder.RTBServer) User(com.xrtb.db.User) Campaign(com.xrtb.common.Campaign) Configuration(com.xrtb.common.Configuration) DbTools(com.xrtb.tools.DbTools)

Example 10 with Configuration

use of com.xrtb.common.Configuration in project XRTB by benmfaul.

the class TestAdx method testCleanup.

@AfterClass
public static void testCleanup() {
    Configuration c = Configuration.getInstance();
    c.campaignsList.clear();
}
Also used : Configuration(com.xrtb.common.Configuration) AfterClass(org.junit.AfterClass)

Aggregations

Configuration (com.xrtb.common.Configuration)15 Campaign (com.xrtb.common.Campaign)7 RTBServer (com.xrtb.bidder.RTBServer)5 User (com.xrtb.db.User)5 DbTools (com.xrtb.tools.DbTools)5 SelectedCreative (com.xrtb.bidder.SelectedCreative)2 AfterClass (org.junit.AfterClass)2 BeforeClass (org.junit.BeforeClass)2 AbortableCountDownLatch (com.xrtb.bidder.AbortableCountDownLatch)1 CampaignProcessor (com.xrtb.bidder.CampaignProcessor)1 Creative (com.xrtb.common.Creative)1 BidRequest (com.xrtb.pojo.BidRequest)1 InputStream (java.io.InputStream)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Test (org.junit.Test)1