killbill-uncached

catalog: remove hardcoded URI in tests Signed-off-by: Pierre-Alexandre

10/31/2011 10:20:43 PM

Details

catalog/pom.xml 4(+4 -0)

diff --git a/catalog/pom.xml b/catalog/pom.xml
index 690f6d7..9516e77 100644
--- a/catalog/pom.xml
+++ b/catalog/pom.xml
@@ -21,6 +21,10 @@
     <packaging>jar</packaging>
     <dependencies>
         <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+        </dependency>
+        <dependency>
             <groupId>com.ning.billing</groupId>
             <artifactId>killbill-api</artifactId>
         </dependency>
diff --git a/catalog/src/test/java/com/ning/billing/catalog/io/TestVersionedCatalogLoader.java b/catalog/src/test/java/com/ning/billing/catalog/io/TestVersionedCatalogLoader.java
index c8efd11..46188af 100644
--- a/catalog/src/test/java/com/ning/billing/catalog/io/TestVersionedCatalogLoader.java
+++ b/catalog/src/test/java/com/ning/billing/catalog/io/TestVersionedCatalogLoader.java
@@ -27,6 +27,7 @@ import java.util.List;
 
 import javax.xml.bind.JAXBException;
 
+import com.google.common.io.Resources;
 import org.joda.time.DateTime;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXException;
@@ -41,7 +42,7 @@ public class TestVersionedCatalogLoader {
 
 	@Test(enabled=true)
 	public void testPullContentsFrom() throws MalformedURLException, IOException {
-		String contents = loader.pullContentsFrom(new File("src/test/resources/WeaponsHireSmall.xml").toURI().toURL());
+		String contents = loader.pullContentsFrom(Resources.getResource("WeaponsHireSmall.xml"));
 
 		assertTrue(contents.length() > 0);
 		
@@ -126,7 +127,7 @@ public class TestVersionedCatalogLoader {
 	
 	@Test(enabled=true)
 	public void testLoad() throws MalformedURLException, IOException, SAXException, InvalidConfigException, JAXBException {
-		VersionedCatalog c = loader.load(new File("src/test/resources/versionedCatalog").toURI().toURL());
+		VersionedCatalog c = loader.load(Resources.getResource("versionedCatalog"));
 		assertEquals(4, c.size());
 		Iterator<Catalog> it = c.iterator();
 		it.next(); //discard the baseline
diff --git a/catalog/src/test/java/com/ning/billing/catalog/io/TestXMLReader.java b/catalog/src/test/java/com/ning/billing/catalog/io/TestXMLReader.java
index c2add84..97dbc3b 100644
--- a/catalog/src/test/java/com/ning/billing/catalog/io/TestXMLReader.java
+++ b/catalog/src/test/java/com/ning/billing/catalog/io/TestXMLReader.java
@@ -22,6 +22,7 @@ import java.io.IOException;
 import javax.xml.bind.JAXBException;
 import javax.xml.transform.TransformerException;
 
+import com.google.common.io.Resources;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXException;
 
@@ -31,8 +32,8 @@ public class TestXMLReader {
 
 	@Test(enabled=true)
 	public void testCatalogLoad() throws IOException, TransformerException, JAXBException, SAXException, InvalidConfigException {
-		XMLReader.getCatalogFromName(new File("src/test/resources/WeaponsHire.xml").toURI().toURL());
-		XMLReader.getCatalogFromName(new File("src/test/resources/WeaponsHireSmall.xml").toURI().toURL());
+		XMLReader.getCatalogFromName(Resources.getResource("WeaponsHire.xml"));
+		XMLReader.getCatalogFromName(Resources.getResource("WeaponsHireSmall.xml"));
 	}
 	
 }
diff --git a/catalog/src/test/java/com/ning/billing/catalog/TestVersionedCatalog.java b/catalog/src/test/java/com/ning/billing/catalog/TestVersionedCatalog.java
index a9a9cca..8a7b07f 100644
--- a/catalog/src/test/java/com/ning/billing/catalog/TestVersionedCatalog.java
+++ b/catalog/src/test/java/com/ning/billing/catalog/TestVersionedCatalog.java
@@ -23,6 +23,7 @@ import java.util.Date;
 
 import javax.xml.bind.JAXBException;
 
+import com.google.common.io.Resources;
 import org.joda.time.DateTime;
 import org.testng.annotations.Test;
 import org.xml.sax.SAXException;
@@ -38,14 +39,14 @@ public class TestVersionedCatalog {
 
 	@Test(enabled=true)
 	public void testAddCatalog() throws MalformedURLException, IOException, SAXException, InvalidConfigException, JAXBException {
-		VersionedCatalog vc = loader.load(new File("src/test/resources/versionedCatalog").toURI().toURL());
+		VersionedCatalog vc = loader.load(Resources.getResource("versionedCatalog"));
 		vc.add(new Catalog(new Date()));
 		assertEquals(5, vc.size());
 	}
 	
 	@Test(enabled=true)
 	public void testApplyEffectiveDate() throws MalformedURLException, IOException, SAXException, InvalidConfigException, JAXBException {
-		VersionedCatalog vc = loader.load(new File("src/test/resources/versionedCatalog").toURI().toURL());
+		VersionedCatalog vc = loader.load(Resources.getResource("versionedCatalog"));
 		Date d = new Date(1L);
 		vc.configureEffectiveDate(d);
 		assertEquals(new Date(0), vc.getEffectiveDate()); // Start at the begining of time