Skip to content
This repository has been archived by the owner on Nov 13, 2018. It is now read-only.

Commit

Permalink
Merge pull request #1747 from trevorackerman/gh-1665
Browse files Browse the repository at this point in the history
TR fixes #1665
  • Loading branch information
David Neuman authored Aug 31, 2016
2 parents b89c9c8 + 8472205 commit e7f3fed
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@

package com.comcast.cdn.traffic_control.traffic_router.core;

import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.Level;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

Expand All @@ -25,9 +29,11 @@

public class TestBase {
private static final Logger LOGGER = Logger.getLogger(TestBase.class);
public static final String monitorPropertiesPath = "src/test/conf/traffic_monitor.properties";
private static ApplicationContext context;

public static ApplicationContext getContext() {

System.setProperty("deploy.dir", "src/test");
System.setProperty("dns.zones.dir", "src/test/var/auto-zones");

Expand All @@ -38,6 +44,10 @@ public static ApplicationContext getContext() {
return context;
}

ConsoleAppender consoleAppender = new ConsoleAppender(new PatternLayout("%d{ISO8601} [%-5p] %c{4}: %m%n"));
LogManager.getRootLogger().addAppender(consoleAppender);
LogManager.getRootLogger().setLevel(Level.WARN);

LOGGER.warn("Initializing context before running integration tests");
context = new FileSystemXmlApplicationContext("src/main/webapp/WEB-INF/applicationContext.xml");
LOGGER.warn("Context initialized integration tests will now start running");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
package com.comcast.cdn.traffic_control.traffic_router.core.dns;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.collection.IsCollectionContaining.hasItem;
import static org.hamcrest.core.IsNull.nullValue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
Expand All @@ -26,6 +29,8 @@
import java.io.FileReader;
import java.math.BigInteger;
import java.net.InetAddress;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -64,11 +69,8 @@ public class ZoneManagerTest {

@BeforeClass
public static void setUpBeforeClass() throws Exception {
try {
context = TestBase.getContext();
} catch(Exception e) {
e.printStackTrace();
}
assertThat("Copy core/src/main/conf/traffic_monitor.properties to core/src/test/conf and set 'traffic_monitor.bootstrap.hosts' to a real traffic monitor", Files.exists(Paths.get(TestBase.monitorPropertiesPath)), equalTo(true));
context = TestBase.getContext();
}

@Before
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@
import com.comcast.cdn.traffic_control.traffic_router.core.TestBase;
import com.comcast.cdn.traffic_control.traffic_router.geolocation.Geolocation;

import java.nio.file.Files;
import java.nio.file.Paths;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.core.IsNull.nullValue;

@Category(IntegrationTest.class)
public class GeoTest {
private static final Logger LOGGER = Logger.getLogger(GeoTest.class);
Expand All @@ -39,11 +47,8 @@ public class GeoTest {

@BeforeClass
public static void setUpBeforeClass() throws Exception {
try {
context = TestBase.getContext();
} catch(Exception e) {
e.printStackTrace();
}
assertThat("Copy core/src/main/conf/traffic_monitor.properties to core/src/test/conf and set 'traffic_monitor.bootstrap.hosts' to a real traffic monitor", Files.exists(Paths.get(TestBase.monitorPropertiesPath)), equalTo(true));
context = TestBase.getContext();
}

@Before
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@
import com.comcast.cdn.traffic_control.traffic_router.core.request.HTTPRequest;
import com.comcast.cdn.traffic_control.traffic_router.core.router.StatTracker.Track;

import java.nio.file.Files;
import java.nio.file.Paths;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.core.IsNull.nullValue;

@Category(IntegrationTest.class)
public class StatelessTrafficRouterTest {
private static final Logger LOGGER = Logger.getLogger(StatelessTrafficRouterTest.class);
Expand All @@ -40,14 +48,8 @@ public class StatelessTrafficRouterTest {

@BeforeClass
public static void setUpBeforeClass() throws Exception {
try {
context = TestBase.getContext();
Logger root = Logger.getRootLogger();
boolean rootIsConfigured = root.getAllAppenders().hasMoreElements();
System.out.println("rootIsConfigured: "+rootIsConfigured);
} catch(Exception e) {
e.printStackTrace();
}
assertThat("Copy core/src/main/conf/traffic_monitor.properties to core/src/test/conf and set 'traffic_monitor.bootstrap.hosts' to a real traffic monitor", Files.exists(Paths.get(TestBase.monitorPropertiesPath)), equalTo(true));
context = TestBase.getContext();
}

@Before
Expand Down

0 comments on commit e7f3fed

Please sign in to comment.