You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@any23.apache.org by an...@apache.org on 2012/08/10 02:40:22 UTC
svn commit: r1371537 [2/30] - in /incubator/any23/trunk: ./ core/
core/src/test/java/org/apache/any23/ core/src/test/java/org/apache/any23/cli/
core/src/test/java/org/apache/any23/extractor/
core/src/test/java/org/apache/any23/extractor/csv/ core/src/t...
Modified: incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/HCardExtractorTest.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/HCardExtractorTest.java?rev=1371537&r1=1371536&r2=1371537&view=diff
==============================================================================
--- incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/HCardExtractorTest.java (original)
+++ incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/HCardExtractorTest.java Fri Aug 10 00:40:13 2012
@@ -49,7 +49,7 @@ public class HCardExtractorTest extends
@Test
public void testEMailNotUriReal() throws RepositoryException {
- assertExtract("microformats/hcard/17-email-not-uri.html");
+ assertExtract("/microformats/hcard/17-email-not-uri.html");
assertDefaultVCard();
assertJohn();
assertContains(vVCARD.email, RDFUtils.uri("mailto:john@example.com"));
@@ -57,7 +57,7 @@ public class HCardExtractorTest extends
@Test
public void testTel() throws RepositoryException {
- assertExtract("microformats/hcard/21-tel.html");
+ assertExtract("/microformats/hcard/21-tel.html");
assertDefaultVCard();
String[] tels = {
"+1.415.555.1231", "+1.415.555.1235",
@@ -77,7 +77,7 @@ public class HCardExtractorTest extends
@Test
public void testAbbrTitleEverything() throws RepositoryException {
- assertExtract("microformats/hcard/23-abbr-title-everything.html");
+ assertExtract("/microformats/hcard/23-abbr-title-everything.html");
assertDefaultVCard();
assertContains(vVCARD.fn, "John Doe");
@@ -122,7 +122,7 @@ public class HCardExtractorTest extends
@Test
public void testGeoAbbr() throws RepositoryException {
- assertExtract("microformats/hcard/25-geo-abbr.html");
+ assertExtract("/microformats/hcard/25-geo-abbr.html");
assertModelNotEmpty();
assertContains(vVCARD.fn, "Paradise");
assertContains(RDF.TYPE, vVCARD.Organization);
@@ -136,7 +136,7 @@ public class HCardExtractorTest extends
@Test
public void testAncestors() throws RepositoryException {
- assertExtract("microformats/hcard/26-ancestors.html");
+ assertExtract("/microformats/hcard/26-ancestors.html");
assertModelNotEmpty();
assertContains(vVCARD.fn, "John Doe");
@@ -183,7 +183,7 @@ public class HCardExtractorTest extends
@Test
public void testfnOrg() throws RepositoryException {
- assertExtract("microformats/hcard/30-fn-org.html");
+ assertExtract("/microformats/hcard/30-fn-org.html");
assertModelNotEmpty();
assertStatementsSize(RDF.TYPE, vVCARD.VCard, 4);
RepositoryResult<Statement> repositoryResult = getStatements(null, RDF.TYPE, vVCARD.VCard);
@@ -209,7 +209,7 @@ public class HCardExtractorTest extends
@Test
public void testInclude() throws RepositoryException {
- assertExtract("microformats/hcard/31-include.html");
+ assertExtract("/microformats/hcard/31-include.html");
assertModelNotEmpty();
assertStatementsSize(RDF.TYPE, vVCARD.VCard, 3);
assertStatementsSize(vVCARD.email, (Value) null, 3);
@@ -248,7 +248,7 @@ public class HCardExtractorTest extends
@Test
public void testHeader() throws RepositoryException {
- assertExtract("microformats/hcard/32-header.html");
+ assertExtract("/microformats/hcard/32-header.html");
assertModelNotEmpty();
// check fn, name, family, nick.
assertJohn();
@@ -291,7 +291,7 @@ public class HCardExtractorTest extends
@Test
public void testAreaFull() throws RepositoryException {
- assertExtract("microformats/hcard/33-area.html");
+ assertExtract("/microformats/hcard/33-area.html");
assertModelNotEmpty();
assertStatementsSize(RDF.TYPE, vVCARD.VCard, 5);
@@ -315,7 +315,7 @@ public class HCardExtractorTest extends
@Test
public void testCategories() throws RepositoryException {
- assertExtract("microformats/hcard/36-categories.html");
+ assertExtract("/microformats/hcard/36-categories.html");
assertModelNotEmpty();
assertContains(vVCARD.given_name, "Joe");
assertContains(vVCARD.given_name, "john");
@@ -340,7 +340,7 @@ public class HCardExtractorTest extends
@Test
public void testSingleton() throws RepositoryException {
// this tests probably tests that e just get the first fn and so on
- assertExtract("microformats/hcard/37-singleton.html");
+ assertExtract("/microformats/hcard/37-singleton.html");
assertModelNotEmpty();
assertStatementsSize(vVCARD.fn, (Value) null, 1);
assertContains(vVCARD.fn, "john doe 1");
@@ -375,7 +375,7 @@ public class HCardExtractorTest extends
@Test
public void testUidFull() throws RepositoryException {
- assertExtract("microformats/hcard/38-uid.html");
+ assertExtract("/microformats/hcard/38-uid.html");
assertModelNotEmpty();
assertStatementsSize(RDF.TYPE, vVCARD.VCard, 4);
RepositoryResult<Statement> statements = getStatements(null, RDF.TYPE, vVCARD.VCard);
@@ -411,7 +411,7 @@ public class HCardExtractorTest extends
@Test
public void testRomanianWikipedia() throws RepositoryException {
- assertExtract("microformats/hcard/40-fn-inside-adr.html");
+ assertExtract("/microformats/hcard/40-fn-inside-adr.html");
assertModelNotEmpty();
assertStatementsSize(RDF.TYPE, vVCARD.VCard, 1);
RepositoryResult<Statement> statements = getStatements(null, RDF.TYPE, vVCARD.VCard);
@@ -439,13 +439,13 @@ public class HCardExtractorTest extends
@Test
public void testNoMicroformats() throws RepositoryException, IOException, ExtractionException {
- extract("html/html-without-uf.html");
+ extract("/html/html-without-uf.html");
assertModelEmpty();
}
@Test
public void testBasic() throws RepositoryException {
- assertExtract("microformats/hcard/01-tantek-basic.html");
+ assertExtract("/microformats/hcard/01-tantek-basic.html");
assertModelNotEmpty();
assertContains(RDF.TYPE, vVCARD.VCard);
// assertContains(RDF.TYPE, vVCARD.Organization);
@@ -472,7 +472,7 @@ public class HCardExtractorTest extends
@Test
public void testMultipleclassNamesOnVCard() throws RepositoryException {
- assertExtract("microformats/hcard/02-multiple-class-names-on-vcard.html");
+ assertExtract("/microformats/hcard/02-multiple-class-names-on-vcard.html");
assertModelNotEmpty();
assertStatementsSize(RDF.TYPE, vVCARD.VCard, 4);
Resource name;
@@ -531,7 +531,7 @@ public class HCardExtractorTest extends
"Thomas"
};
List<String> NAMES = Arrays.asList(ns);
- assertExtract("microformats/hcard/03-implied-n.html");
+ assertExtract("/microformats/hcard/03-implied-n.html");
assertModelNotEmpty();
RepositoryResult<Statement> statements = getStatements(null, vVCARD.fn, null);
@@ -564,7 +564,7 @@ public class HCardExtractorTest extends
@Test
public void testIgnoreUnknowns() throws RepositoryException {
- assertExtract("microformats/hcard/04-ignore-unknowns.html");
+ assertExtract("/microformats/hcard/04-ignore-unknowns.html");
assertDefaultVCard();
assertContains(vVCARD.fn, "Ryan King");
assertContains(vVCARD.n, (Resource) null);
@@ -575,7 +575,7 @@ public class HCardExtractorTest extends
@Test
public void testMailto1() throws RepositoryException {
- assertExtract("microformats/hcard/05-mailto-1.html");
+ assertExtract("/microformats/hcard/05-mailto-1.html");
assertDefaultVCard();
assertContains(vVCARD.fn, "Ryan King");
assertContains(RDF.TYPE, vVCARD.Name);
@@ -591,7 +591,7 @@ public class HCardExtractorTest extends
@Test
public void testMailto2() throws RepositoryException {
- assertExtract("microformats/hcard/06-mailto-2.html");
+ assertExtract("/microformats/hcard/06-mailto-2.html");
assertDefaultVCard();
assertContains(vVCARD.fn, "Brian Suda");
@@ -605,7 +605,7 @@ public class HCardExtractorTest extends
@Test
public void testRelativeUrl() throws RepositoryException {
- assertExtract("microformats/hcard/07-relative-url.html");
+ assertExtract("/microformats/hcard/07-relative-url.html");
assertDefaultVCard();
assertJohn();
assertContains( vVCARD.url, RDFUtils.uri(baseURI + "home/blah") );
@@ -613,7 +613,7 @@ public class HCardExtractorTest extends
@Test
public void testRelativeUrlBase() throws RepositoryException {
- assertExtract("microformats/hcard/08-relative-url-base.html");
+ assertExtract("/microformats/hcard/08-relative-url-base.html");
assertDefaultVCard();
assertContains(vVCARD.url, RDFUtils.uri(baseURI + "home/blah"));
assertJohn();
@@ -621,7 +621,7 @@ public class HCardExtractorTest extends
@Test
public void testRelativeUrlXmlBase1() throws RepositoryException {
- assertExtract("microformats/hcard/09-relative-url-xmlbase-1.html");
+ assertExtract("/microformats/hcard/09-relative-url-xmlbase-1.html");
assertDefaultVCard();
assertContains(vVCARD.url, RDFUtils.uri((baseURI + "home/blah")));
assertJohn();
@@ -629,7 +629,7 @@ public class HCardExtractorTest extends
@Test
public void testRelativeUrlXmlBase2() throws RepositoryException {
- assertExtract("microformats/hcard/10-relative-url-xmlbase-2.html");
+ assertExtract("/microformats/hcard/10-relative-url-xmlbase-2.html");
assertDefaultVCard();
assertContains(vVCARD.url, RDFUtils.uri((baseURI + "home/blah")));
assertJohn();
@@ -637,7 +637,7 @@ public class HCardExtractorTest extends
@Test
public void testMultipleUrls() throws RepositoryException {
- assertExtract("microformats/hcard/11-multiple-urls.html");
+ assertExtract("/microformats/hcard/11-multiple-urls.html");
assertDefaultVCard();
assertContains(vVCARD.url, RDFUtils.uri(("http://example.com/foo")));
assertContains(vVCARD.url, RDFUtils.uri(("http://example.com/bar")));
@@ -647,14 +647,14 @@ public class HCardExtractorTest extends
@Test
public void testImageSrc() throws RepositoryException {
- assertExtract("microformats/hcard/12-img-src-url.html");
+ assertExtract("/microformats/hcard/12-img-src-url.html");
assertDefaultVCard();
assertJohn();
}
@Test
public void testPhotoLogo() throws RepositoryException {
- assertExtract("microformats/hcard/13-photo-logo.html");
+ assertExtract("/microformats/hcard/13-photo-logo.html");
assertDefaultVCard();
assertContains(vVCARD.photo, RDFUtils.uri(("http://example.org/picture1.png")));
assertContains(vVCARD.photo, RDFUtils.uri(("http://example.org/picture2.png")));
@@ -665,7 +665,7 @@ public class HCardExtractorTest extends
@Test
public void testImgSrcDataUrl() throws RepositoryException {
- assertExtract("microformats/hcard/14-img-src-data-url.html");
+ assertExtract("/microformats/hcard/14-img-src-data-url.html");
assertDefaultVCard();
Resource data = RDFUtils.uri(
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAMAAAAp4XiDAAAABGdBTUEAAK/"
@@ -693,7 +693,7 @@ public class HCardExtractorTest extends
@Test
public void testHonorificAdditionalSingle() throws RepositoryException {
- assertExtract("microformats/hcard/15-honorific-additional-single.html");
+ assertExtract("/microformats/hcard/15-honorific-additional-single.html");
assertDefaultVCard();
assertContains(vVCARD.fn, "Mr. John Maurice Doe, Ph.D.");
@@ -707,7 +707,7 @@ public class HCardExtractorTest extends
@Test
public void testHonorificAdditionalMultiple() throws RepositoryException {
- assertExtract("microformats/hcard/16-honorific-additional-multiple.html");
+ assertExtract("/microformats/hcard/16-honorific-additional-multiple.html");
assertDefaultVCard();
assertContains(vVCARD.honorific_prefix, "Mr.");
assertContains(vVCARD.honorific_prefix, "Dr.");
@@ -728,7 +728,7 @@ public class HCardExtractorTest extends
@Test
public void testEMailNotUri() throws RepositoryException {
- assertExtract("microformats/hcard/17-email-not-uri.html");
+ assertExtract("/microformats/hcard/17-email-not-uri.html");
assertDefaultVCard();
assertJohn();
assertContains( vVCARD.email, RDFUtils.uri("mailto:john@example.com") );
@@ -736,14 +736,14 @@ public class HCardExtractorTest extends
@Test
public void testObjectDataHttpUri() throws RepositoryException {
- assertExtract("microformats/hcard/18-object-data-http-uri.html");
+ assertExtract("/microformats/hcard/18-object-data-http-uri.html");
assertDefaultVCard();
assertJohn();
}
@Test
public void testObjectDataDataUri() throws RepositoryException {
- assertExtract("microformats/hcard/19-object-data-data-uri.html");
+ assertExtract("/microformats/hcard/19-object-data-data-uri.html");
assertDefaultVCard();
assertJohn();
@@ -753,7 +753,7 @@ public class HCardExtractorTest extends
@Test
public void testImgAlt() throws RepositoryException {
- assertExtract("microformats/hcard/20-image-alt.html");
+ assertExtract("/microformats/hcard/20-image-alt.html");
assertDefaultVCard();
Resource uri = RDFUtils.uri("http://example.com/foo.png");
assertContains(vVCARD.photo, uri);
@@ -763,7 +763,7 @@ public class HCardExtractorTest extends
@Test
public void testAdr() throws RepositoryException {
- assertExtract("microformats/hcard/22-adr.html");
+ assertExtract("/microformats/hcard/22-adr.html");
assertDefaultVCard();
assertJohn();
assertStatementsSize(RDF.TYPE, vVCARD.Address, 0);
@@ -771,7 +771,7 @@ public class HCardExtractorTest extends
@Test
public void testBirthDayDate() throws RepositoryException {
- assertExtract("microformats/hcard/27-bday-date.html");
+ assertExtract("/microformats/hcard/27-bday-date.html");
assertModelNotEmpty();
assertContains(vVCARD.fn , "john doe");
assertContains(vVCARD.given_name , "john");
@@ -781,7 +781,7 @@ public class HCardExtractorTest extends
@Test
public void testBirthDayDateTime() throws RepositoryException {
- assertExtract("microformats/hcard/28-bday-datetime.html");
+ assertExtract("/microformats/hcard/28-bday-datetime.html");
assertModelNotEmpty();
assertContains(vVCARD.fn , "john doe");
assertContains(vVCARD.given_name , "john");
@@ -791,7 +791,7 @@ public class HCardExtractorTest extends
@Test
public void testBirthDayDateTimeTimeZone() throws RepositoryException {
- assertExtract("microformats/hcard/29-bday-datetime-timezone.html");
+ assertExtract("/microformats/hcard/29-bday-datetime-timezone.html");
assertModelNotEmpty();
assertContains(vVCARD.fn, "john doe");
assertContains(vVCARD.given_name, "john");
@@ -801,7 +801,7 @@ public class HCardExtractorTest extends
@Test
public void testArea() throws RepositoryException {
- assertExtract("microformats/hcard/33-area.html");
+ assertExtract("/microformats/hcard/33-area.html");
assertModelNotEmpty();
assertStatementsSize(RDF.TYPE, vVCARD.VCard, 5);
RepositoryResult<Statement> statements = getStatements(null, RDF.TYPE, vVCARD.VCard);
@@ -841,7 +841,7 @@ public class HCardExtractorTest extends
public void testNotes() throws RepositoryException {
final String[] NOTES = {"Note 1", "Note 3", "Note 4 with a ; and a , to be escaped"};
- assertExtract("microformats/hcard/34-notes.html");
+ assertExtract("/microformats/hcard/34-notes.html");
assertModelNotEmpty();
RepositoryResult<Statement> statements = getStatements(null, RDF.TYPE, vVCARD.VCard);
try {
@@ -862,7 +862,7 @@ public class HCardExtractorTest extends
@Test
public void testIncludePattern() throws RepositoryException {
- assertExtract("microformats/hcard/35-include-pattern.html");
+ assertExtract("/microformats/hcard/35-include-pattern.html");
assertModelNotEmpty();
assertStatementsSize(RDF.TYPE, vVCARD.VCard, 3);
@@ -907,7 +907,7 @@ public class HCardExtractorTest extends
@Test
public void testUid() throws RepositoryException {
- assertExtract("microformats/hcard/38-uid.html");
+ assertExtract("/microformats/hcard/38-uid.html");
assertModelNotEmpty();
assertStatementsSize(RDF.TYPE, vVCARD.VCard, 4);
RepositoryResult<Statement> iter = getStatements(null, RDF.TYPE, vVCARD.VCard);
@@ -928,7 +928,7 @@ public class HCardExtractorTest extends
@Test
public void testIgnoreChildren() throws RepositoryException {
- assertExtract("microformats/hcard/41-ignore-children.html");
+ assertExtract("/microformats/hcard/41-ignore-children.html");
assertModelNotEmpty();
assertStatementsSize(RDF.TYPE, vVCARD.VCard, 1);
assertContains(vVCARD.fn, "Melanie Kl\u00f6\u00df");
@@ -948,7 +948,7 @@ public class HCardExtractorTest extends
*/
@Test
public void testCumulativeHNames() throws RepositoryException {
- assertExtract("microformats/hcard/linkedin-michelemostarda.html");
+ assertExtract("/microformats/hcard/linkedin-michelemostarda.html");
assertModelNotEmpty();
assertStatementsSize(vVCARD.given_name, "Michele" , 7);
assertStatementsSize(vVCARD.family_name, "Mostarda", 7);
@@ -963,7 +963,7 @@ public class HCardExtractorTest extends
*/
@Test
public void testInfiniteLoop() throws IOException, ExtractionException {
- assertExtract("microformats/hcard/infinite-loop.html", false);
+ assertExtract("/microformats/hcard/infinite-loop.html", false);
assertIssue(IssueReport.IssueLevel.Warning, ".*Current node tries to include an ancestor node.*");
}
@@ -974,7 +974,7 @@ public class HCardExtractorTest extends
@Ignore
@Test(timeout = 30 * 1000)
public void testExtractionPerformance() {
- assertExtract("microformats/hcard/performance.html");
+ assertExtract("/microformats/hcard/performance.html");
}
private void assertDefaultVCard() throws RepositoryException {
Modified: incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/HListingExtractorTest.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/HListingExtractorTest.java?rev=1371537&r1=1371536&r2=1371537&view=diff
==============================================================================
--- incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/HListingExtractorTest.java (original)
+++ incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/HListingExtractorTest.java Fri Aug 10 00:40:13 2012
@@ -51,27 +51,27 @@ public class HListingExtractorTest exten
@Test
public void testNoMicroformats() throws RepositoryException {
- assertExtract("html/html-without-uf.html");
+ assertExtract("/html/html-without-uf.html");
assertModelEmpty();
}
@Test
public void testListingWithouthContent() throws RepositoryException {
- assertExtract("microformats/hlisting/empty.html");
+ assertExtract("/microformats/hlisting/empty.html");
assertModelNotEmpty();
assertStatementsSize(null, null, null, 3);
}
@Test
public void testSingleAction() throws RepositoryException {
- assertExtract("microformats/hlisting/single-action.html");
+ assertExtract("/microformats/hlisting/single-action.html");
assertModelNotEmpty();
assertContains(vHLISTING.action, vHLISTING.offer);
}
@Test
public void testMultipleActions() throws RepositoryException {
- assertExtract("microformats/hlisting/multiple-actions.html");
+ assertExtract("/microformats/hlisting/multiple-actions.html");
assertModelNotEmpty();
assertContains(vHLISTING.action, vHLISTING.offer);
assertContains(vHLISTING.action, vHLISTING.sell);
@@ -79,7 +79,7 @@ public class HListingExtractorTest exten
@Test
public void testMultipleActionsNested() throws RepositoryException {
- assertExtract("microformats/hlisting/multiple-actions-nested.html");
+ assertExtract("/microformats/hlisting/multiple-actions-nested.html");
assertModelNotEmpty();
assertContains(vHLISTING.action, vHLISTING.offer);
assertContains(vHLISTING.action, vHLISTING.sell);
@@ -88,14 +88,14 @@ public class HListingExtractorTest exten
@Test
public void testActionsOutside() throws RepositoryException {
- assertExtract("microformats/hlisting/single-action-outside.html");
+ assertExtract("/microformats/hlisting/single-action-outside.html");
assertModelNotEmpty();
assertNotContains(vHLISTING.action, vHLISTING.offer);
}
@Test
public void testListerFn() throws RepositoryException {
- assertExtract("microformats/hlisting/actions-lister-fn.html");
+ assertExtract("/microformats/hlisting/actions-lister-fn.html");
assertModelNotEmpty();
assertContains(vHLISTING.action, vHLISTING.offer);
assertContains(RDF.TYPE, vHLISTING.Lister);
@@ -104,7 +104,7 @@ public class HListingExtractorTest exten
@Test
public void testListerFnTel() throws RepositoryException {
- assertExtract("microformats/hlisting/actions-lister-fn-tel.html");
+ assertExtract("/microformats/hlisting/actions-lister-fn-tel.html");
assertModelNotEmpty();
assertContains(vHLISTING.action , vHLISTING.offer);
@@ -115,7 +115,7 @@ public class HListingExtractorTest exten
@Test
public void testItemFn() throws RepositoryException {
- assertExtract("microformats/hlisting/item-fn.html");
+ assertExtract("/microformats/hlisting/item-fn.html");
assertModelNotEmpty();
assertContains(RDF.TYPE, vHLISTING.Item);
assertContains(vHLISTING.itemName, "Parking space");
@@ -123,7 +123,7 @@ public class HListingExtractorTest exten
@Test
public void testItemFnUrl() throws RepositoryException {
- assertExtract("microformats/hlisting/item-fn-url.html");
+ assertExtract("/microformats/hlisting/item-fn-url.html");
assertModelNotEmpty();
assertContains(RDF.TYPE, vHLISTING.Item);
assertContains(vHLISTING.itemUrl, RDFUtils.uri("http://item.com/"));
@@ -132,7 +132,7 @@ public class HListingExtractorTest exten
@Test
public void testItemPhotoImg() throws RepositoryException {
- assertExtract("microformats/hlisting/item-fn-url-photo-img.html");
+ assertExtract("/microformats/hlisting/item-fn-url-photo-img.html");
assertModelNotEmpty();
assertContains(RDF.TYPE, vHLISTING.Item);
assertContains(vHLISTING.itemUrl, RDFUtils.uri("http://item.com/"));
@@ -142,7 +142,7 @@ public class HListingExtractorTest exten
@Test
public void testItemPhotoHref() throws RepositoryException {
- assertExtract("microformats/hlisting/item-fn-photo-href.html");
+ assertExtract("/microformats/hlisting/item-fn-photo-href.html");
assertModelNotEmpty();
assertContains(RDF.TYPE, vHLISTING.Item);
assertContains(vHLISTING.itemName, "Parking space");
@@ -151,7 +151,7 @@ public class HListingExtractorTest exten
@Test
public void testKelkoo() throws RepositoryException {
- assertExtract("microformats/hlisting/kelkoo.html");
+ assertExtract("/microformats/hlisting/kelkoo.html");
assertModelNotEmpty();
assertContains(RDF.TYPE, vHLISTING.Listing);
@@ -180,7 +180,7 @@ public class HListingExtractorTest exten
@Test
public void testKelkooFull() throws RepositoryException {
- assertExtract("microformats/hlisting/kelkoo-full.html");
+ assertExtract("/microformats/hlisting/kelkoo-full.html");
assertModelNotEmpty();
assertContains(RDF.TYPE, vHLISTING.Listing);
assertContains(RDF.TYPE, vHLISTING.Item);
@@ -228,7 +228,7 @@ public class HListingExtractorTest exten
@Test
public void testListerURL() throws RepositoryException {
- assertExtract("microformats/hlisting/actions-lister-url.html");
+ assertExtract("/microformats/hlisting/actions-lister-url.html");
assertModelNotEmpty();
assertContains(vHLISTING.action, vHLISTING.offer);
assertContains(vHLISTING.listerName, "John Broker");
@@ -238,7 +238,7 @@ public class HListingExtractorTest exten
@Test
public void testListerEmail() throws RepositoryException {
- assertExtract("microformats/hlisting/actions-lister-email.html");
+ assertExtract("/microformats/hlisting/actions-lister-email.html");
assertModelNotEmpty();
assertContains(vHLISTING.action, vHLISTING.offer);
assertContains(vHLISTING.listerName, "John Broker");
@@ -248,7 +248,7 @@ public class HListingExtractorTest exten
@Test
public void testListerEmailHref() throws RepositoryException {
- assertExtract("microformats/hlisting/actions-lister-email-href.html");
+ assertExtract("/microformats/hlisting/actions-lister-email-href.html");
assertModelNotEmpty();
assertContains(vHLISTING.action, vHLISTING.offer);
assertContains(RDF.TYPE, vHLISTING.Lister);
@@ -258,7 +258,7 @@ public class HListingExtractorTest exten
@Test
public void testDtListed() throws RepositoryException {
- assertExtract("microformats/hlisting/dtlisted-dtexpired.html");
+ assertExtract("/microformats/hlisting/dtlisted-dtexpired.html");
assertModelNotEmpty();
assertNotContains(vHLISTING.action, vHLISTING.offer);
assertContains(vHLISTING.dtlisted, "2006-02-02");
@@ -266,7 +266,7 @@ public class HListingExtractorTest exten
@Test
public void testDtExpired() throws RepositoryException {
- assertExtract("microformats/hlisting/dtlisted-dtexpired.html");
+ assertExtract("/microformats/hlisting/dtlisted-dtexpired.html");
assertModelNotEmpty();
assertNotContains(vHLISTING.action, vHLISTING.offer);
assertContains(vHLISTING.dtexpired, "2006-04-01");
@@ -274,14 +274,14 @@ public class HListingExtractorTest exten
@Test
public void testSummary() throws RepositoryException {
- assertExtract("microformats/hlisting/summary.html");
+ assertExtract("/microformats/hlisting/summary.html");
assertModelNotEmpty();
assertContains(vHLISTING.summary, "summary stuff");
}
@Test
public void testDtListedAndExpired() throws RepositoryException {
- assertExtract("microformats/hlisting/dtlisted-dtexpired.html");
+ assertExtract("/microformats/hlisting/dtlisted-dtexpired.html");
assertModelNotEmpty();
assertNotContains(vHLISTING.action, vHLISTING.offer);
assertContains(vHLISTING.dtlisted, "2006-02-02");
@@ -290,14 +290,14 @@ public class HListingExtractorTest exten
@Test
public void testPrice() throws RepositoryException {
- assertExtract("microformats/hlisting/price.html");
+ assertExtract("/microformats/hlisting/price.html");
assertModelNotEmpty();
assertContains(vHLISTING.price, "$215/qtr");
}
@Test
public void testPriceAndDt() throws RepositoryException {
- assertExtract("microformats/hlisting/dtlisted-dtexpired.html");
+ assertExtract("/microformats/hlisting/dtlisted-dtexpired.html");
assertModelNotEmpty();
assertContains(vHLISTING.price, "$215/qtr");
assertContains(vHLISTING.dtlisted, "2006-02-02");
@@ -306,7 +306,7 @@ public class HListingExtractorTest exten
@Test
public void testPermalink() throws RepositoryException {
- assertExtract("microformats/hlisting/summary-bookmark.html");
+ assertExtract("/microformats/hlisting/summary-bookmark.html");
assertModelNotEmpty();
assertContains(vHLISTING.permalink, "http://livre.com/book");
assertContains(vHLISTING.listerUrl, RDFUtils.uri("http://livre.com/author"));
@@ -314,7 +314,7 @@ public class HListingExtractorTest exten
@Test
public void testComplexDescription() throws RepositoryException {
- assertExtract("microformats/hlisting/description-complex.html");
+ assertExtract("/microformats/hlisting/description-complex.html");
assertModelNotEmpty();
assertContains(vHLISTING.description,
"BenQ today introduced two new additions to its renowned bus... + Show details");
@@ -322,7 +322,7 @@ public class HListingExtractorTest exten
@Test
public void testDescription() throws RepositoryException {
- assertExtract("microformats/hlisting/description.html");
+ assertExtract("/microformats/hlisting/description.html");
assertModelNotEmpty();
assertContains(vHLISTING.description, "bla bla bla");
}
Modified: incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/HRecipeExtractorTest.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/HRecipeExtractorTest.java?rev=1371537&r1=1371536&r2=1371537&view=diff
==============================================================================
--- incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/HRecipeExtractorTest.java (original)
+++ incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/HRecipeExtractorTest.java Fri Aug 10 00:40:13 2012
@@ -41,13 +41,13 @@ public class HRecipeExtractorTest extend
@Test
public void testNoMicroformats() throws RepositoryException {
- assertExtract("html/html-without-uf.html");
+ assertExtract("/html/html-without-uf.html");
assertModelEmpty();
}
@Test
public void testExtraction() throws RepositoryException {
- assertExtract("microformats/hrecipe/01-spec.html");
+ assertExtract("/microformats/hrecipe/01-spec.html");
assertModelNotEmpty();
assertStatementsSize(RDF.TYPE, vHRECIPE.Recipe , 1);
assertStatementsSize(RDF.TYPE, vHRECIPE.Ingredient, 3);
Modified: incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/HResumeExtractorTest.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/HResumeExtractorTest.java?rev=1371537&r1=1371536&r2=1371537&view=diff
==============================================================================
--- incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/HResumeExtractorTest.java (original)
+++ incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/HResumeExtractorTest.java Fri Aug 10 00:40:13 2012
@@ -56,13 +56,13 @@ public class HResumeExtractorTest extend
@Test
public void testNoMicroformats() throws RepositoryException {
- assertExtract("html/html-without-uf.html");
+ assertExtract("/html/html-without-uf.html");
assertModelEmpty();
}
@Test
public void testLinkedIn() throws RepositoryException {
- assertExtract("microformats/hresume/steveganz.html");
+ assertExtract("/microformats/hresume/steveganz.html");
assertModelNotEmpty();
assertStatementsSize(RDF.TYPE, vFOAF.Person, 1);
@@ -92,7 +92,7 @@ public class HResumeExtractorTest extend
@Test
public void testLinkedInComplete() throws RepositoryException {
- assertExtract("microformats/hresume/steveganz.html");
+ assertExtract("/microformats/hresume/steveganz.html");
assertModelNotEmpty();
assertStatementsSize(RDF.TYPE, vFOAF.Person, 1);
@@ -139,7 +139,7 @@ public class HResumeExtractorTest extend
@Test
public void testAnt() throws RepositoryException {
- assertExtract("microformats/hresume/ant.html");
+ assertExtract("/microformats/hresume/ant.html");
assertModelNotEmpty();
assertStatementsSize(RDF.TYPE, vFOAF.Person, 1);
Modified: incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/HReviewExtractorTest.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/HReviewExtractorTest.java?rev=1371537&r1=1371536&r2=1371537&view=diff
==============================================================================
--- incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/HReviewExtractorTest.java (original)
+++ incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/HReviewExtractorTest.java Fri Aug 10 00:40:13 2012
@@ -53,13 +53,13 @@ public class HReviewExtractorTest extend
@Test
public void testNoMicroformats() throws RepositoryException {
- assertExtract("html/html-without-uf.html");
+ assertExtract("/html/html-without-uf.html");
assertModelEmpty();
}
@Test
public void test01Basic() throws RepositoryException {
- assertExtract("microformats/hreview/01-spec.html");
+ assertExtract("/microformats/hreview/01-spec.html");
assertModelNotEmpty();
assertStatementsSize(RDF.TYPE, vREVIEW.Review, 1);
@@ -110,7 +110,7 @@ public class HReviewExtractorTest extend
@Test
public void test02RatedTags() throws RepositoryException {
- assertExtract("microformats/hreview/02-spec-2.html");
+ assertExtract("/microformats/hreview/02-spec-2.html");
assertModelNotEmpty();
assertStatementsSize(RDF.TYPE, vREVIEW.Review, 1);
@@ -166,7 +166,7 @@ public class HReviewExtractorTest extend
@Test
public void test03NoHcardForItem() throws RepositoryException {
- assertExtract("microformats/hreview/03-spec-3.html");
+ assertExtract("/microformats/hreview/03-spec-3.html");
assertModelNotEmpty();
assertStatementsSize(RDF.TYPE, vREVIEW.Review, 1);
@@ -219,7 +219,7 @@ public class HReviewExtractorTest extend
@Test
public void test04NoHcardForItem() throws RepositoryException {
- assertExtract("microformats/hreview/04-spec-4.html");
+ assertExtract("/microformats/hreview/04-spec-4.html");
assertModelNotEmpty();
assertStatementsSize(RDF.TYPE, vREVIEW.Review, 1);
@@ -278,7 +278,7 @@ public class HReviewExtractorTest extend
*/
@Test
public void testCaseSensitiveness() throws RepositoryException {
- assertExtract("microformats/hreview/05-spec.html");
+ assertExtract("/microformats/hreview/05-spec.html");
assertModelNotEmpty();
assertStatementsSize(RDF.TYPE, vREVIEW.Review, 1);
// reviewer, no item
Modified: incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/HTMLFixture.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/HTMLFixture.java?rev=1371537&r1=1371536&r2=1371537&view=diff
==============================================================================
--- incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/HTMLFixture.java (original)
+++ incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/HTMLFixture.java Fri Aug 10 00:40:13 2012
@@ -19,6 +19,7 @@ package org.apache.any23.extractor.html;
import org.apache.any23.source.DocumentSource;
import org.apache.any23.source.FileDocumentSource;
+import org.junit.Assert;
import org.w3c.dom.Node;
import java.io.File;
@@ -30,17 +31,15 @@ import java.io.IOException;
*/
public class HTMLFixture {
- private final String filename;
+ private final File file;
- public HTMLFixture(String filename) {
- this.filename = filename;
+ public HTMLFixture(File file) {
+ Assert.assertNotNull("Test resource file was null", file);
+ Assert.assertTrue("Test resource file does not exist", file.exists());
+ this.file = file;
}
private File getFile() {
- File file = new File(
- System.getProperty("test.data", "src/test/resources/") + filename);
- if (!file.exists())
- throw new AssertionError("the file " + file.getPath() + " does not exist");
return file;
}
Modified: incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/HTMLMetaExtractorTest.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/HTMLMetaExtractorTest.java?rev=1371537&r1=1371536&r2=1371537&view=diff
==============================================================================
--- incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/HTMLMetaExtractorTest.java (original)
+++ incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/HTMLMetaExtractorTest.java Fri Aug 10 00:40:13 2012
@@ -38,7 +38,7 @@ public class HTMLMetaExtractorTest exten
@Test
public void testExtractPageMeta() throws RepositoryException {
- assertExtract("html/html-head-meta-extractor.html");
+ assertExtract("/html/html-head-meta-extractor.html");
assertModelNotEmpty();
assertStatementsSize(null, null, null, 7);
assertContains(
@@ -87,7 +87,7 @@ public class HTMLMetaExtractorTest exten
@Test
public void testNoMeta() throws RepositoryException {
- assertExtract("html/html-head-link-extractor.html");
+ assertExtract("/html/html-head-link-extractor.html");
assertModelEmpty();
}
Modified: incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/HeadLinkExtractorTest.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/HeadLinkExtractorTest.java?rev=1371537&r1=1371536&r2=1371537&view=diff
==============================================================================
--- incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/HeadLinkExtractorTest.java (original)
+++ incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/HeadLinkExtractorTest.java Fri Aug 10 00:40:13 2012
@@ -38,7 +38,7 @@ public class HeadLinkExtractorTest exten
@Test
public void testLinkExtraction() throws RepositoryException {
- assertExtract("html/html-head-link-extractor.html");
+ assertExtract("/html/html-head-link-extractor.html");
assertModelNotEmpty();
final ValueFactory valueFactory = new ValueFactoryImpl();
final URI externalLinkURI = valueFactory.createURI("http://www.myexperiment.org/workflows/16.rdf");
Modified: incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/LicenseExtractorTest.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/LicenseExtractorTest.java?rev=1371537&r1=1371536&r2=1371537&view=diff
==============================================================================
--- incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/LicenseExtractorTest.java (original)
+++ incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/LicenseExtractorTest.java Fri Aug 10 00:40:13 2012
@@ -49,28 +49,28 @@ public class LicenseExtractorTest extend
@Test
public void testOnlyCc() throws RepositoryException {
- assertExtract("microformats/license/ccBy.html");
+ assertExtract("/microformats/license/ccBy.html");
assertContains(baseURI, vXHTML.license, ccBy);
assertNotContains(baseURI, vXHTML.license, apache);
}
@Test
public void testOnlyApache() throws RepositoryException {
- assertExtract("microformats/license/apache.html");
+ assertExtract("/microformats/license/apache.html");
assertNotContains(baseURI, vXHTML.license, ccBy);
assertContains(baseURI, vXHTML.license, apache);
}
@Test
public void testMultipleLicenses() throws RepositoryException {
- assertExtract("microformats/license/multiple.html");
+ assertExtract("/microformats/license/multiple.html");
assertContains(baseURI, vXHTML.license, ccBy);
assertContains(baseURI, vXHTML.license, apache);
}
@Test
public void testMultipleEmptyHref() throws RepositoryException {
- assertExtract("microformats/license/multiple-empty-href.html", false);
+ assertExtract("/microformats/license/multiple-empty-href.html", false);
assertNotContains(baseURI, vXHTML.license, "");
assertContains(baseURI, vXHTML.license, apache);
@@ -83,13 +83,13 @@ public class LicenseExtractorTest extend
@Test
public void testEmpty() throws RepositoryException {
- assertExtract("microformats/license/empty.html");
+ assertExtract("/microformats/license/empty.html");
assertModelEmpty();
}
@Test
public void testMixedCaseTitleTag() throws RepositoryException {
- assertExtract("microformats/license/multiple-mixed-case.html");
+ assertExtract("/microformats/license/multiple-mixed-case.html");
assertContains(baseURI, vXHTML.license, ccBy);
assertContains(baseURI, vXHTML.license, apache);
}
Modified: incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/RDFMergerTest.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/RDFMergerTest.java?rev=1371537&r1=1371536&r2=1371537&view=diff
==============================================================================
--- incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/RDFMergerTest.java (original)
+++ incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/RDFMergerTest.java Fri Aug 10 00:40:13 2012
@@ -38,9 +38,11 @@ import org.openrdf.repository.Repository
import org.openrdf.repository.RepositoryResult;
import org.w3c.dom.Document;
+import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
@@ -68,13 +70,13 @@ public class RDFMergerTest extends Abstr
@Test
public void testNoMicroformats() throws RepositoryException, ExtractionException, IOException {
- extract("html-without-uf.html");
+ extract("/html/html-without-uf.html");
assertModelEmpty();
}
@Test
public void test01XFNFoaf() throws RepositoryException {
- assertExtract("mixed/01-xfn-foaf.html", false);
+ assertExtract("/html/mixed/01-xfn-foaf.html", false);
assertModelNotEmpty();
assertStatementsSize(RDF.TYPE, vVCARD.VCard, 1);
Resource vcard = findExactlyOneBlankSubject(RDF.TYPE, vVCARD.VCard);
@@ -96,7 +98,7 @@ public class RDFMergerTest extends Abstr
@Test
public void testAbbrTitleEverything() throws ExtractionException, IOException, RepositoryException {
- extractHCardAndRelated("microformats/hcard/23-abbr-title-everything.html");
+ extractHCardAndRelated("/microformats/hcard/23-abbr-title-everything.html");
assertContains(vVCARD.fn, "John Doe");
assertContains(vVCARD.nickname, "JJ");
@@ -131,7 +133,7 @@ public class RDFMergerTest extends Abstr
@Test
public void testAdr() throws ExtractionException, IOException, RepositoryException {
- extractHRevAndRelated("microformats/hcard/22-adr.html");
+ extractHRevAndRelated("/microformats/hcard/22-adr.html");
assertStatementsSize(RDF.TYPE, vVCARD.Address, 4);
@@ -204,7 +206,7 @@ public class RDFMergerTest extends Abstr
@Test
public void testGeoAbbr() throws ExtractionException, IOException, RepositoryException {
- extractHCardAndRelated("microformats/hcard/25-geo-abbr.html");
+ extractHCardAndRelated("/microformats/hcard/25-geo-abbr.html");
assertModelNotEmpty();
assertContains(vVCARD.fn, "Paradise");
assertContains(RDF.TYPE, vVCARD.Organization);
@@ -217,7 +219,7 @@ public class RDFMergerTest extends Abstr
@Test
public void testAncestors() throws ExtractionException, IOException, RepositoryException {
- extractHCardAndRelated("microformats/hcard/26-ancestors.html");
+ extractHCardAndRelated("/microformats/hcard/26-ancestors.html");
assertModelNotEmpty();
assertContains(vVCARD.fn, "John Doe");
@@ -260,7 +262,7 @@ public class RDFMergerTest extends Abstr
@Test
public void testSingleton() throws ExtractionException, IOException, RepositoryException {
- extractHCardAndRelated("microformats/hcard/37-singleton.html");
+ extractHCardAndRelated("/microformats/hcard/37-singleton.html");
assertModelNotEmpty();
assertStatementsSize(vVCARD.fn, (Value) null, 1);
assertContains(vVCARD.fn, "john doe 1");
@@ -291,7 +293,7 @@ public class RDFMergerTest extends Abstr
@Test
public void test01Basic() throws ExtractionException, IOException, RepositoryException {
- extractHRevAndRelated("microformats/hreview/01-spec.html");
+ extractHRevAndRelated("/microformats/hreview/01-spec.html");
assertModelNotEmpty();
assertStatementsSize(RDF.TYPE, vREVIEW.Review, 1);
@@ -336,7 +338,7 @@ public class RDFMergerTest extends Abstr
@Test
public void test02RatedTags() throws ExtractionException, IOException, RepositoryException {
- extractHRevAndRelated("microformats/hreview/02-spec-2.html");
+ extractHRevAndRelated("/microformats/hreview/02-spec-2.html");
assertStatementsSize(vREVIEW.reviewer, (Value) null, 1);
assertStatementsSize(vREVIEW.hasReview, (Value) null, 1);
@@ -372,7 +374,7 @@ public class RDFMergerTest extends Abstr
@Test
public void test03NoHcardForItem() throws ExtractionException, IOException, RepositoryException {
- extractHRevAndRelated("microformats/hreview/03-spec-3.html");
+ extractHRevAndRelated("/microformats/hreview/03-spec-3.html");
assertModelNotEmpty();
assertStatementsSize(RDF.TYPE, vREVIEW.Review, 1);
@@ -431,11 +433,9 @@ public class RDFMergerTest extends Abstr
@Override
protected void extract(String filename) throws ExtractionException, IOException {
- File file = new File(
- System.getProperty("test.data", "src/test/resources") +
- "/html/" + filename);
-
- Document document = new TagSoupParser(new FileInputStream(file), baseURI.stringValue()).getDOM();
+ InputStream input = new BufferedInputStream(this.getClass().getResourceAsStream(filename));
+
+ Document document = new TagSoupParser(input, baseURI.stringValue()).getDOM();
HCardExtractor hCardExtractor = HCardExtractor.factory.createExtractor();
ExtractionContext hcExtractionContext = new ExtractionContext(
hCardExtractor.getDescription().getExtractorName(),
@@ -469,10 +469,10 @@ public class RDFMergerTest extends Abstr
}
private void extractHCardAndRelated(String filename) throws IOException, ExtractionException {
- File file = new File(
- System.getProperty("test.data", "src/test/resources/") + filename);
+
+ InputStream input = new BufferedInputStream(this.getClass().getResourceAsStream(filename));
- Document document = new TagSoupParser(new FileInputStream(file), baseURI.stringValue()).getDOM();
+ Document document = new TagSoupParser(input, baseURI.stringValue()).getDOM();
HCardExtractor hCardExtractor = HCardExtractor.factory.createExtractor();
ExtractionContext hCardExtractionContext = new ExtractionContext(
hCardExtractor.getDescription().getExtractorName(), baseURI
@@ -521,9 +521,8 @@ public class RDFMergerTest extends Abstr
private void extractHRevAndRelated(String filename) throws ExtractionException, IOException {
extractHCardAndRelated(filename);
- File file = new File(
- System.getProperty("test.data", "src/test/resources/") + filename);
- Document document = new TagSoupParser(new FileInputStream(file), baseURI.stringValue()).getDOM();
+ InputStream input = new BufferedInputStream(this.getClass().getResourceAsStream(filename));
+ Document document = new TagSoupParser(input, baseURI.stringValue()).getDOM();
HReviewExtractor hReviewExtractor = HReviewExtractor.factory.createExtractor();
ExtractionContext hreviewExtractionContext = new ExtractionContext(
hReviewExtractor.getDescription().getExtractorName(), baseURI
Modified: incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/SpeciesExtractorTest.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/SpeciesExtractorTest.java?rev=1371537&r1=1371536&r2=1371537&view=diff
==============================================================================
--- incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/SpeciesExtractorTest.java (original)
+++ incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/SpeciesExtractorTest.java Fri Aug 10 00:40:13 2012
@@ -47,7 +47,7 @@ public class SpeciesExtractorTest extend
*/
@Test
public void testSpeciesMicroformatExtractOverTaxoBox() throws RepositoryException {
- assertExtract("microformats/species/species-example-2.html");
+ assertExtract("/microformats/species/species-example-2.html");
assertModelNotEmpty();
logger.debug(dumpModelToRDFXML());
Modified: incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/TagSoupParserTest.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/TagSoupParserTest.java?rev=1371537&r1=1371536&r2=1371537&view=diff
==============================================================================
--- incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/TagSoupParserTest.java (original)
+++ incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/TagSoupParserTest.java Fri Aug 10 00:40:13 2012
@@ -27,6 +27,7 @@ import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -67,9 +68,7 @@ public class TagSoupParserTest {
public void testExplicitEncodingBehavior()
throws IOException, ExtractionException, RepositoryException {
this.tagSoupParser = new TagSoupParser(
- new FileInputStream(
- new File("src/test/resources/html/encoding-test.html")
- ),
+ new BufferedInputStream(this.getClass().getResourceAsStream("/html/encoding-test.html")),
page,
"UTF-8"
);
@@ -92,9 +91,7 @@ public class TagSoupParserTest {
@Test
public void testImplicitEncodingBehavior() throws IOException, ExtractionException, RepositoryException {
this.tagSoupParser = new TagSoupParser(
- new FileInputStream(
- new File("src/test/resources/html/encoding-test.html")
- ),
+ new BufferedInputStream(this.getClass().getResourceAsStream("/html/encoding-test.html")),
page
);
Assert.assertNotSame(
@@ -113,12 +110,12 @@ public class TagSoupParserTest {
@Test
public void testEmptySpanElements() throws IOException {
final String page = "http://example.com/test-page";
- InputStream brokenEmptySpanHtml = new FileInputStream(
- new File("src/test/resources/html/empty-span-broken.html")
- );
- InputStream worksEmptySpanHtml = new FileInputStream(
- new File("src/test/resources/html/empty-span-works.html")
- );
+ InputStream brokenEmptySpanHtml =
+ new BufferedInputStream(this.getClass().getResourceAsStream("/html/empty-span-broken.html"))
+ ;
+ InputStream worksEmptySpanHtml =
+ new BufferedInputStream(this.getClass().getResourceAsStream("/html/empty-span-works.html"))
+ ;
this.tagSoupParser = new TagSoupParser(brokenEmptySpanHtml, page);
Document brokenElementDom = this.tagSoupParser.getDOM();
this.tagSoupParser = null; // useless but force GC
Modified: incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/TitleExtractorTest.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/TitleExtractorTest.java?rev=1371537&r1=1371536&r2=1371537&view=diff
==============================================================================
--- incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/TitleExtractorTest.java (original)
+++ incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/TitleExtractorTest.java Fri Aug 10 00:40:13 2012
@@ -42,25 +42,25 @@ public class TitleExtractorTest extends
@Test
public void testExtractPageTitle() throws RepositoryException {
- assertExtract("microformats/xfn/simple-me.html");
+ assertExtract("/microformats/xfn/simple-me.html");
assertContains(baseURI, vDCTERMS.title, helloLiteral);
}
@Test
public void testStripSpacesFromTitle() throws RepositoryException {
- assertExtract("microformats/xfn/strip-spaces.html");
+ assertExtract("/microformats/xfn/strip-spaces.html");
assertContains(baseURI, vDCTERMS.title, helloLiteral);
}
@Test
public void testNoPageTitle() throws RepositoryException {
- assertExtract("microformats/xfn/tagsoup.html");
+ assertExtract("/microformats/xfn/tagsoup.html");
assertModelEmpty();
}
@Test
public void testMixedCaseTitleTag() throws RepositoryException {
- assertExtract("microformats/xfn/mixed-case.html");
+ assertExtract("/microformats/xfn/mixed-case.html");
assertContains(baseURI, vDCTERMS.title, helloLiteral);
}
@@ -71,7 +71,7 @@ public class TitleExtractorTest extends
*/
@Test
public void testTitleWithDefaultLanguage() throws RepositoryException {
- assertExtract("html/default-language.html");
+ assertExtract("/html/default-language.html");
assertContains (baseURI, vDCTERMS.title, RDFUtils.literal("Welcome to mydomain.net", "en"));
assertNotContains(baseURI, vDCTERMS.title, RDFUtils.literal("Welcome to mydomain.net",(String) null));
}
Modified: incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/TurtleHTMLExtractorTest.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/TurtleHTMLExtractorTest.java?rev=1371537&r1=1371536&r2=1371537&view=diff
==============================================================================
--- incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/TurtleHTMLExtractorTest.java (original)
+++ incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/TurtleHTMLExtractorTest.java Fri Aug 10 00:40:13 2012
@@ -50,7 +50,7 @@ public class TurtleHTMLExtractorTest ext
*/
@Test
public void testExtraction() throws IOException, ExtractionException, RepositoryException {
- assertExtract("html/html-turtle.html");
+ assertExtract("/html/html-turtle.html");
logger.debug( dumpModelToRDFXML() );
assertStatementsSize( null, (Value) null, 10);
}
Modified: incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/XFNExtractorTest.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/XFNExtractorTest.java?rev=1371537&r1=1371536&r2=1371537&view=diff
==============================================================================
--- incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/XFNExtractorTest.java (original)
+++ incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/html/XFNExtractorTest.java Fri Aug 10 00:40:13 2012
@@ -52,30 +52,30 @@ public class XFNExtractorTest extends Ab
@Test
public void testNoMicroformats() throws RepositoryException {
- assertExtract("html/html-without-uf.html");
+ assertExtract("/html/html-without-uf.html");
assertModelEmpty();
}
@Test
public void testLinkWithoutRel() throws RepositoryException {
- assertExtract("microformats/xfn/no-rel.html");
+ assertExtract("/microformats/xfn/no-rel.html");
assertModelEmpty();
}
@Test
public void testNoXFNRel() throws RepositoryException {
- assertExtract("microformats/xfn/no-valid-rel.html");
+ assertExtract("/microformats/xfn/no-valid-rel.html");
assertModelEmpty();
}
@Test
public void testDetectPresenceOfXFN() throws RepositoryException {
- assertExtract("microformats/xfn/simple-me.html");
+ assertExtract("/microformats/xfn/simple-me.html");
}
@Test
public void testSimpleMeLink() throws RepositoryException {
- assertExtract("microformats/xfn/simple-me.html");
+ assertExtract("/microformats/xfn/simple-me.html");
Resource person = findExactlyOneBlankSubject(RDF.TYPE, vFOAF.Person);
assertContains(person, vXFN.mePage, baseURI);
assertContains(person, vXFN.mePage, bobsHomepage);
@@ -83,20 +83,20 @@ public class XFNExtractorTest extends Ab
@Test
public void testRelativeURIisResolvedAgainstBase() throws RepositoryException {
- assertExtract("microformats/xfn/with-relative-uri.html");
+ assertExtract("/microformats/xfn/with-relative-uri.html");
assertContains(null, vXFN.mePage, RDFUtils.uri("http://bob.example.com/foo"));
}
@Test
public void testParseTagSoup() throws RepositoryException {
- assertExtract("microformats/xfn/tagsoup.html");
+ assertExtract("/microformats/xfn/tagsoup.html");
Resource person = findExactlyOneBlankSubject(RDF.TYPE, vFOAF.Person);
assertContains(person, vXFN.mePage, baseURI);
}
@Test
public void testSimpleFriend() throws RepositoryException {
- assertExtract("microformats/xfn/simple-friend.html");
+ assertExtract("/microformats/xfn/simple-friend.html");
Resource bob = findExactlyOneBlankSubject(vXFN.mePage, baseURI);
Resource alice = findExactlyOneBlankSubject(vXFN.mePage, alicesHomepage);
assertContains(bob, RDF.TYPE, vFOAF.Person);
@@ -108,7 +108,7 @@ public class XFNExtractorTest extends Ab
@Test
public void testFriendAndSweetheart() throws RepositoryException {
- assertExtract("microformats/xfn/multiple-rel.html");
+ assertExtract("/microformats/xfn/multiple-rel.html");
Resource bob = findExactlyOneBlankSubject(vXFN.mePage, baseURI);
Resource alice = findExactlyOneBlankSubject(vXFN.mePage, alicesHomepage);
assertContains(bob, vXFN.friend, alice);
@@ -120,7 +120,7 @@ public class XFNExtractorTest extends Ab
@Test
public void testMultipleFriends() throws RepositoryException {
- assertExtract("microformats/xfn/multiple-friends.html");
+ assertExtract("/microformats/xfn/multiple-friends.html");
Resource bob = findExactlyOneBlankSubject(vXFN.mePage, baseURI);
Resource alice = findExactlyOneBlankSubject(vXFN.mePage, alicesHomepage);
Resource charlie = findExactlyOneBlankSubject(vXFN.mePage, charliesHomepage);
@@ -133,31 +133,31 @@ public class XFNExtractorTest extends Ab
@Test
public void testSomeLinksWithoutRel() throws RepositoryException {
- assertExtract("microformats/xfn/some-links-without-rel.html");
+ assertExtract("/microformats/xfn/some-links-without-rel.html");
assertNotContains(null, null, alicesHomepage);
assertContains (null, null, charliesHomepage);
}
@Test
public void testForSomeReasonICantBeMyOwnSweetheart() throws RepositoryException {
- assertExtract("microformats/xfn/me-and-sweetheart.html");
+ assertExtract("/microformats/xfn/me-and-sweetheart.html");
assertModelEmpty();
}
@Test
public void testIgnoreExtraSpacesInRel() throws RepositoryException {
- assertExtract("microformats/xfn/strip-spaces.html");
+ assertExtract("/microformats/xfn/strip-spaces.html");
assertContains(null, vXFN.mePage, baseURI);
}
@Test
public void testMixedCaseATag() throws RepositoryException {
- assertExtract("microformats/xfn/mixed-case.html");
+ assertExtract("/microformats/xfn/mixed-case.html");
assertContains(null, vXFN.mePage, baseURI);
}
@Test
public void testUpcaseHREF() throws RepositoryException {
- assertExtract("microformats/xfn/upcase-href.html");
+ assertExtract("/microformats/xfn/upcase-href.html");
assertContains(null, vXFN.mePage, baseURI);
}
}
Modified: incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/microdata/MicrodataExtractorTest.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/microdata/MicrodataExtractorTest.java?rev=1371537&r1=1371536&r2=1371537&view=diff
==============================================================================
--- incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/microdata/MicrodataExtractorTest.java (original)
+++ incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/microdata/MicrodataExtractorTest.java Fri Aug 10 00:40:13 2012
@@ -163,10 +163,10 @@ public class MicrodataExtractorTest exte
private void extractAndVerifyAgainstNQuads(String actual, String expected)
throws RepositoryException, RDFHandlerException, IOException, RDFParseException {
- assertExtract("microdata/" + actual);
+ assertExtract("/microdata/" + actual);
assertModelNotEmpty();
logger.debug( dumpModelToNQuads() );
- List<Statement> expectedStatements = loadResultStatement("microdata/" + expected);
+ List<Statement> expectedStatements = loadResultStatement("/microdata/" + expected);
int actualStmtSize = getStatementsSize(null, null, null);
Assert.assertEquals( expectedStatements.size(), actualStmtSize);
for (Statement statement : expectedStatements) {
@@ -185,8 +185,7 @@ public class MicrodataExtractorTest exte
NQuadsParser nQuadsParser = new NQuadsParser();
TestRDFHandler rdfHandler = new TestRDFHandler();
nQuadsParser.setRDFHandler(rdfHandler);
- File file = new File(
- System.getProperty("test.data", "src/test/resources/") + resultFilePath);
+ File file = copyResourceToTempFile(resultFilePath);
nQuadsParser.parse(
new FileReader(file),
baseURI.toString()
Modified: incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/rdfa/AbstractRDFaExtractorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/rdfa/AbstractRDFaExtractorTestCase.java?rev=1371537&r1=1371536&r2=1371537&view=diff
==============================================================================
--- incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/rdfa/AbstractRDFaExtractorTestCase.java (original)
+++ incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/rdfa/AbstractRDFaExtractorTestCase.java Fri Aug 10 00:40:13 2012
@@ -45,7 +45,7 @@ public abstract class AbstractRDFaExtrac
*/
@Test
public void testBasic() throws RepositoryException {
- assertExtract("html/rdfa/basic.html");
+ assertExtract("/html/rdfa/basic.html");
System.out.println( dumpModelToNQuads() );
assertContains(null, vDCTERMS.creator, RDFUtils.literal("Alice", "en") );
assertContains(null, vDCTERMS.title , RDFUtils.literal("The trouble with Bob", "en") );
@@ -62,7 +62,7 @@ public abstract class AbstractRDFaExtrac
*/
@Test
public void testRDFa11CURIEs() throws RepositoryException {
- assertExtract("html/rdfa/rdfa-11-curies.html");
+ assertExtract("/html/rdfa/rdfa-11-curies.html");
assertModelNotEmpty();
assertContains(
RDFUtils.uri("http://dbpedia.org/resource/Albert_Einstein"),
@@ -109,7 +109,7 @@ public abstract class AbstractRDFaExtrac
*/
@Test
public void testEmptyDatatypeDeclarationWithInnerXMLTags() throws RepositoryException {
- assertExtract("html/rdfa/null-datatype-test.html");
+ assertExtract("/html/rdfa/null-datatype-test.html");
logger.debug(dumpModelToRDFXML());
assertContains(
@@ -129,7 +129,7 @@ public abstract class AbstractRDFaExtrac
*/
@Test
public void testDrupalTestPage() throws RepositoryException {
- assertExtract("html/rdfa/drupal-test-frontpage.html");
+ assertExtract("/html/rdfa/drupal-test-frontpage.html");
logger.debug(dumpModelToTurtle());
assertContains(
RDFUtils.uri("http://bob.example.com/node/3"),
@@ -145,7 +145,7 @@ public abstract class AbstractRDFaExtrac
*/
@Test
public void testIncompleteTripleManagement() throws RepositoryException {
- assertExtract("html/rdfa/incomplete-triples.html");
+ assertExtract("/html/rdfa/incomplete-triples.html");
logger.debug(dumpModelToTurtle());
assertContains(
Modified: incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/rdfa/RDFa11ExtractorTest.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/rdfa/RDFa11ExtractorTest.java?rev=1371537&r1=1371536&r2=1371537&view=diff
==============================================================================
--- incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/rdfa/RDFa11ExtractorTest.java (original)
+++ incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/rdfa/RDFa11ExtractorTest.java Fri Aug 10 00:40:13 2012
@@ -48,7 +48,7 @@ public class RDFa11ExtractorTest extends
*/
@Test
public void testObjectResourceConversion() throws RepositoryException {
- assertExtract("html/rdfa/object-resource-test.html");
+ assertExtract("/html/rdfa/object-resource-test.html");
logger.debug(dumpModelToTurtle());
assertContains(
null,
@@ -67,7 +67,7 @@ public class RDFa11ExtractorTest extends
*/
@Test
public void testExplicitDatatypeDeclaration() throws RepositoryException {
- assertExtract("html/rdfa/xmlliteral-datatype-test.html");
+ assertExtract("/html/rdfa/xmlliteral-datatype-test.html");
logger.debug(dumpModelToTurtle());
Literal literal = RDFUtils.literal(
@@ -88,7 +88,7 @@ public class RDFa11ExtractorTest extends
*/
@Test
public void testRelWithHref() throws RepositoryException {
- assertExtract("html/rdfa/rel-href.html");
+ assertExtract("/html/rdfa/rel-href.html");
logger.debug(dumpModelToTurtle());
assertContains(
@@ -110,7 +110,7 @@ public class RDFa11ExtractorTest extends
*/
@Test
public void testRelRevSupport() throws RepositoryException {
- assertExtract("html/rdfa/rel-rev.html");
+ assertExtract("/html/rdfa/rel-rev.html");
logger.debug(dumpModelToTurtle());
assertContains(
@@ -132,7 +132,7 @@ public class RDFa11ExtractorTest extends
*/
@Test
public void testVocabSupport() throws RepositoryException {
- assertExtract("html/rdfa/vocab.html");
+ assertExtract("/html/rdfa/vocab.html");
logger.debug(dumpModelToTurtle());
assertContains(
@@ -152,7 +152,7 @@ public class RDFa11ExtractorTest extends
*/
@Test
public void testTolerantParsing() {
- assertExtract("html/rdfa/oreilly-invalid-datatype.html", false);
+ assertExtract("/html/rdfa/oreilly-invalid-datatype.html", false);
assertIssue(IssueReport.IssueLevel.Warning, ".*Cannot map prefix \'mailto\'.*");
}
@@ -170,7 +170,7 @@ public class RDFa11ExtractorTest extends
throws RepositoryException, RDFHandlerException, IOException, RDFParseException {
final int EXPECTED_STATEMENTS = 33;
- assertExtract("html/rdfa/goodrelations-rdfa10.html");
+ assertExtract("/html/rdfa/goodrelations-rdfa10.html");
logger.debug(dumpModelToNQuads());
Assert.assertEquals(EXPECTED_STATEMENTS, dumpAsListOfStatements().size());
@@ -191,7 +191,7 @@ public class RDFa11ExtractorTest extends
throws RepositoryException, RDFHandlerException, IOException, RDFParseException {
final int EXPECTED_STATEMENTS = 33;
- assertExtract("html/rdfa/goodrelations-rdfa11.html");
+ assertExtract("/html/rdfa/goodrelations-rdfa11.html");
logger.debug(dumpHumanReadableTriples());
Assert.assertEquals(EXPECTED_STATEMENTS, dumpAsListOfStatements().size());
@@ -208,7 +208,7 @@ public class RDFa11ExtractorTest extends
*/
@Test
public void testOpenGraphStructuredProperties() throws IOException, ExtractionException, RepositoryException {
- assertExtract("html/rdfa/opengraph-structured-properties.html");
+ assertExtract("/html/rdfa/opengraph-structured-properties.html");
logger.info( dumpHumanReadableTriples() );
Assert.assertEquals(8, getStatementsSize(null, null, null) );
Modified: incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/rdfa/RDFaExtractorTest.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/rdfa/RDFaExtractorTest.java?rev=1371537&r1=1371536&r2=1371537&view=diff
==============================================================================
--- incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/rdfa/RDFaExtractorTest.java (original)
+++ incubator/any23/trunk/core/src/test/java/org/apache/any23/extractor/rdfa/RDFaExtractorTest.java Fri Aug 10 00:40:13 2012
@@ -48,14 +48,14 @@ public class RDFaExtractorTest extends A
throws RepositoryException, RDFHandlerException, IOException, RDFParseException {
final int EXPECTED_STATEMENTS = 31;
- assertExtract("html/rdfa/goodrelations-rdfa10.html");
+ assertExtract("/html/rdfa/goodrelations-rdfa10.html");
logger.debug("Model 1 " + dumpHumanReadableTriples());
Assert.assertEquals(EXPECTED_STATEMENTS, dumpAsListOfStatements().size());
List<Statement> rdfa10Stmts = dumpAsListOfStatements();
//assertContainsModel("/html/rdfa/goodrelations-rdfa10-expected.nq");
- assertExtract("html/rdfa/goodrelations-rdfa11.html");
+ assertExtract("/html/rdfa/goodrelations-rdfa11.html");
logger.debug("Model 2 " + dumpHumanReadableTriples());
Assert.assertTrue(dumpAsListOfStatements().size() >= EXPECTED_STATEMENTS);
@@ -69,7 +69,7 @@ public class RDFaExtractorTest extends A
*/
@Test
public void testTolerantParsing() {
- assertExtract("html/rdfa/oreilly-invalid-datatype.html");
+ assertExtract("/html/rdfa/oreilly-invalid-datatype.html");
}
@Override
Modified: incubator/any23/trunk/core/src/test/java/org/apache/any23/mime/TikaMIMETypeDetectorTest.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/test/java/org/apache/any23/mime/TikaMIMETypeDetectorTest.java?rev=1371537&r1=1371536&r2=1371537&view=diff
==============================================================================
--- incubator/any23/trunk/core/src/test/java/org/apache/any23/mime/TikaMIMETypeDetectorTest.java (original)
+++ incubator/any23/trunk/core/src/test/java/org/apache/any23/mime/TikaMIMETypeDetectorTest.java Fri Aug 10 00:40:13 2012
@@ -23,12 +23,16 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
/**
* Test case for {@link TikaMIMETypeDetector} class.
@@ -115,67 +119,119 @@ public class TikaMIMETypeDetectorTest {
@Test
public void testDetectRSS1ByContent() throws Exception {
- detectMIMEtypeByContent("application/rdf+xml", "src/test/resources/application/rss1");
+ detectMIMEtypeByContent("application/rdf+xml", manifestRss1());
+ }
+
+ private List<String> manifestRss1() {
+ return Arrays.asList("/application/rss1/test1");
}
@Test
public void testDetectRSS2ByContent() throws Exception {
- detectMIMEtypeByContent("application/rss+xml", "src/test/resources/application/rss2");
+ detectMIMEtypeByContent("application/rss+xml", manifestRss2());
+ }
+
+ private List<String> manifestRss2() {
+ return Arrays.asList("/application/rss2/index.html", "/application/rss2/rss2sample.xml", "/application/rss2/test1");
}
@Test
public void testDetectRDFN3ByContent() throws Exception {
- detectMIMEtypeByContent("text/n3", "src/test/resources/application/rdfn3");
+ detectMIMEtypeByContent("text/n3", manifestN3());
+ }
+
+ private List<String> manifestN3() {
+ return Arrays.asList("/application/rdfn3/test1", "/application/rdfn3/test2", "/application/rdfn3/test3");
}
@Test
public void testDetectRDFNQuadsByContent() throws Exception {
- detectMIMEtypeByContent("text/nq", "src/test/resources/application/nquads");
+ detectMIMEtypeByContent("text/nq", manifestNQuads());
+ }
+
+ private List<String> manifestNQuads() {
+ return Arrays.asList("/application/nquads/test1.nq", "/application/nquads/test2.nq");
}
@Test
public void testDetectRDFXMLByContent() throws Exception {
- detectMIMEtypeByContent("application/rdf+xml", "src/test/resources/application/rdfxml");
+ detectMIMEtypeByContent("application/rdf+xml", manifestRdfXml());
+ }
+
+ private List<String> manifestRdfXml() {
+ return Arrays.asList("/application/rdfxml/error.rdf", "/application/rdfxml/foaf", "/application/rdfxml/physics.owl", "/application/rdfxml/test1", "/application/rdfxml/test2", "/application/rdfxml/test3");
}
@Test
public void testDetectTriXByContent() throws Exception {
- detectMIMEtypeByContent("application/trix", "src/test/resources/application/trix");
+ detectMIMEtypeByContent("application/trix", manifestTrix());
+ }
+
+ private List<String> manifestTrix() {
+ return Arrays.asList("/application/trix/test1.trx");
}
@Test
public void testDetectAtomByContent() throws Exception {
- detectMIMEtypeByContent("application/atom+xml", "src/test/resources/application/atom");
+ detectMIMEtypeByContent("application/atom+xml", manifestAtom());
+ }
+
+ private List<String> manifestAtom() {
+ return Arrays.asList("/application/atom/atom.xml");
}
@Test
public void testDetectHTMLByContent() throws Exception {
- detectMIMEtypeByContent("text/html", "src/test/resources/text/html");
+ detectMIMEtypeByContent("text/html", manifestHtml());
+ }
+
+ private List<String> manifestHtml() {
+ return Arrays.asList("/text/html/test1");
}
@Test
public void testDetectRDFaByContent() throws Exception {
- detectMIMEtypeByContent("application/xhtml+xml", "src/test/resources/application/rdfa");
+ detectMIMEtypeByContent("application/xhtml+xml", manifestRdfa());
+ }
+
+ private List<String> manifestRdfa() {
+ return Arrays.asList("/application/rdfa/false.test", "/application/rdfa/london-gazette.html", "/application/rdfa/mic.xhtml", "/application/rdfa/test1.html");
}
@Test
public void testDetectXHTMLByContent() throws Exception {
- detectMIMEtypeByContent("application/xhtml+xml", "src/test/resources/application/xhtml");
+ detectMIMEtypeByContent("application/xhtml+xml", manifestXHtml());
+ }
+
+ private List<String> manifestXHtml() {
+ return Arrays.asList("/application/xhtml/blank-file-header.xhtml", "/application/xhtml/index.html", "/application/xhtml/test1");
}
@Test
public void testDetectWSDLByContent() throws Exception {
- detectMIMEtypeByContent("application/x-wsdl", "src/test/resources/application/wsdl");
+ detectMIMEtypeByContent("application/x-wsdl", manifestWsdl());
+ }
+
+ private List<String> manifestWsdl() {
+ return Arrays.asList("/application/wsdl/error.wsdl", "/application/wsdl/test1");
}
@Test
public void testDetectZIPByContent() throws Exception {
- detectMIMEtypeByContent("application/zip", "src/test/resources/application/zip");
+ detectMIMEtypeByContent("application/zip", manifestZip());
+ }
+
+ private List<String> manifestZip() {
+ return Arrays.asList("/application/zip/4_entries.zip", "/application/zip/test1.zip", "/application/zip/test2");
}
@Test
public void testDetectCSVByContent() throws Exception {
- detectMIMEtypeByContent("text/csv", "src/test/resources/org/apache/any23/extractor/csv/");
+ detectMIMEtypeByContent("text/csv", manifestCsv());
+ }
+
+ private List<String> manifestCsv() {
+ return Arrays.asList("/org/apache/any23/extractor/csv/test-comma.csv", "/org/apache/any23/extractor/csv/test-semicolon.csv", "/org/apache/any23/extractor/csv/test-tab.csv", "/org/apache/any23/extractor/csv/test-type.csv");
}
/* END: by content. */
@@ -258,67 +314,67 @@ public class TikaMIMETypeDetectorTest {
@Test
public void testRDFXMLByContentAndName() throws Exception {
- detectMIMETypeByContentAndName("application/rdf+xml", "src/test/resources/application/rdfxml");
+ detectMIMETypeByContentAndName("application/rdf+xml", manifestRdfXml());
}
@Test
public void testTriXByContentAndName() throws Exception {
- detectMIMETypeByContentAndName("application/trix", "src/test/resources/application/trix");
+ detectMIMETypeByContentAndName("application/trix", manifestTrix());
}
@Test
public void testRSS1ByContentAndName() throws Exception {
- detectMIMETypeByContentAndName("application/rdf+xml", "src/test/resources/application/rss1");
+ detectMIMETypeByContentAndName("application/rdf+xml", manifestRss1());
}
@Test
public void testRSS2ByContentAndName() throws Exception {
- detectMIMETypeByContentAndName("application/rss+xml", "src/test/resources/application/rss2");
+ detectMIMETypeByContentAndName("application/rss+xml", manifestRss2());
}
@Test
public void testDetectRDFN3ByContentAndName() throws Exception {
- detectMIMETypeByContentAndName("text/n3", "src/test/resources/application/rdfn3");
+ detectMIMETypeByContentAndName("text/n3", manifestN3());
}
@Test
public void testDetectRDFNQuadsByContentAndName() throws Exception {
- detectMIMETypeByContentAndName("text/rdf+nq", "src/test/resources/application/nquads");
+ detectMIMETypeByContentAndName("text/rdf+nq", manifestNQuads());
}
@Test
public void testAtomByContentAndName() throws Exception {
- detectMIMETypeByContentAndName("application/atom+xml", "src/test/resources/application/atom");
+ detectMIMETypeByContentAndName("application/atom+xml", manifestAtom());
}
@Test
public void testHTMLByContentAndName() throws Exception {
- detectMIMETypeByContentAndName("text/html", "src/test/resources/text/html");
+ detectMIMETypeByContentAndName("text/html", manifestHtml());
}
@Test
public void testXHTMLByContentAndName() throws Exception {
- detectMIMETypeByContentAndName("application/xhtml+xml", "src/test/resources/application/xhtml");
+ detectMIMETypeByContentAndName("application/xhtml+xml", manifestXHtml());
}
@Test
public void testWSDLByContentAndName() throws Exception {
- detectMIMETypeByContentAndName("application/x-wsdl", "src/test/resources/application/wsdl");
+ detectMIMETypeByContentAndName("application/x-wsdl", manifestWsdl());
}
@Test
public void testZipByContentAndName() throws Exception {
- detectMIMETypeByContentAndName("application/zip", "src/test/resources/application/zip");
+ detectMIMETypeByContentAndName("application/zip", manifestZip());
}
@Test
public void testRDFaByContentAndName() throws Exception {
- detectMIMETypeByContentAndName("application/xhtml+xml", "src/test/resources/application/rdfa");
+ detectMIMETypeByContentAndName("application/xhtml+xml", manifestRdfa());
}
@Test
public void testCSVByContentAndName() throws Exception {
- detectMIMETypeByContentAndName("text/csv","src/test/resources/org/apache/any23/extractor/csv");
+ detectMIMETypeByContentAndName("text/csv", manifestCsv());
}
/* END: by content and name. */
@@ -350,23 +406,21 @@ public class TikaMIMETypeDetectorTest {
* @param testDir the target file.
* @throws IOException
*/
- private void detectMIMEtypeByContent(String expectedMimeType, String testDir)
+ private void detectMIMEtypeByContent(String expectedMimeType, Collection<String> manifest)
throws IOException {
- File f = new File(testDir);
String detectedMimeType;
- for (File test : f.listFiles()) {
- if (test.getName().startsWith(".")) continue;
- InputStream is = getInputStream(test);
+ for (String test : manifest) {
+ InputStream is = new BufferedInputStream(this.getClass().getResourceAsStream(test));
detectedMimeType = detector.guessMIMEType(
null,
is,
null
).toString();
- if (test.getName().startsWith("error"))
+ if (test.contains("error"))
Assert.assertNotSame(expectedMimeType, detectedMimeType);
else {
Assert.assertEquals(
- String.format("Error in mimetype detection for file %s", test.getAbsolutePath()),
+ String.format("Error in mimetype detection for file %s", test),
expectedMimeType,
detectedMimeType
);
@@ -399,14 +453,12 @@ public class TikaMIMETypeDetectorTest {
* @param testDir
* @throws IOException
*/
- private void detectMIMETypeByContentAndName(String expectedMimeType, String testDir) throws IOException {
- File f = new File(testDir);
+ private void detectMIMETypeByContentAndName(String expectedMimeType, Collection<String> manifest) throws IOException {
String detectedMimeType;
- for (File test : f.listFiles()) {
- if (test.getName().startsWith(".")) continue;
- InputStream is = getInputStream(test);
- detectedMimeType = detector.guessMIMEType(test.getName(), is, null).toString();
- if (test.getName().startsWith("error"))
+ for (String test : manifest) {
+ InputStream is = new BufferedInputStream(this.getClass().getResourceAsStream(test));
+ detectedMimeType = detector.guessMIMEType(test, is, null).toString();
+ if (test.contains("error"))
Assert.assertNotSame(expectedMimeType, detectedMimeType);
else {
Assert.assertEquals(
@@ -419,22 +471,4 @@ public class TikaMIMETypeDetectorTest {
}
}
- /**
- * @param file the file to be load.
- * @return the input stream containing the file.
- * @throws IOException
- */
- private InputStream getInputStream(File file) throws IOException {
- FileInputStream fis = new FileInputStream(file);
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- byte[] buffer = new byte[4096];
- while (fis.read(buffer) != -1) {
- bos.write(buffer);
- }
- fis.close();
- InputStream bais;
- bais = new ByteArrayInputStream(bos.toByteArray());
- return bais;
- }
-
}
Modified: incubator/any23/trunk/core/src/test/java/org/apache/any23/mime/purifier/WhiteSpacesPurifierTest.java
URL: http://svn.apache.org/viewvc/incubator/any23/trunk/core/src/test/java/org/apache/any23/mime/purifier/WhiteSpacesPurifierTest.java?rev=1371537&r1=1371536&r2=1371537&view=diff
==============================================================================
--- incubator/any23/trunk/core/src/test/java/org/apache/any23/mime/purifier/WhiteSpacesPurifierTest.java (original)
+++ incubator/any23/trunk/core/src/test/java/org/apache/any23/mime/purifier/WhiteSpacesPurifierTest.java Fri Aug 10 00:40:13 2012
@@ -17,6 +17,7 @@
package org.apache.any23.mime.purifier;
+import org.apache.tika.io.IOUtils;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@@ -46,56 +47,18 @@ public class WhiteSpacesPurifierTest {
@Test
public void testPurification() throws IOException {
InputStream inputStream =
- getInputStream(new File("src/test/resources/application/xhtml/blank-file-header.xhtml"));
+ new BufferedInputStream(this.getClass().getResourceAsStream("/application/xhtml/blank-file-header.xhtml"));
this.purifier.purify(inputStream);
Assert.assertNotNull(inputStream);
Assert.assertTrue(
validatePurification(
- readInputStreamAsString(inputStream)
+ IOUtils.toString(inputStream)
)
);
}
/**
- * @param file the file to be load.
- * @return the input stream containing the file.
- * @throws java.io.IOException
- */
- private InputStream getInputStream(File file) throws IOException {
- FileInputStream fis = new FileInputStream(file);
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- byte[] buffer = new byte[4096];
- while (fis.read(buffer) != -1) {
- bos.write(buffer);
- }
- fis.close();
- InputStream bais;
- bais = new ByteArrayInputStream(bos.toByteArray());
- return bais;
- }
-
- /**
- * Reads an {@link java.io.InputStream} as a {@link String}.
- *
- * @param in
- * @return
- * @throws IOException
- */
- private String readInputStreamAsString(InputStream in)
- throws IOException {
- BufferedInputStream bis = new BufferedInputStream(in);
- ByteArrayOutputStream buf = new ByteArrayOutputStream();
- int result = bis.read();
- while (result != -1) {
- byte b = (byte) result;
- buf.write(b);
- result = bis.read();
- }
- return buf.toString();
- }
-
- /**
* Checks if a {@link String} starts with a propert character.
*
* @param string