package org.deri.any23.extractor.html;

import org.deri.any23.Helper;
import org.deri.any23.extractor.ExtractorFactory;
import org.deri.any23.extractor.html.LicenseExtractor;
import org.deri.any23.vocab.DCTERMS;
import org.openrdf.model.URI;
import org.openrdf.repository.RepositoryException;

public class LicenseExtractorTest extends AbstractMicroformatTestCase {
	private URI ccBy = Helper.uri("http://creativecommons.org/licenses/by/2.0/");
	private URI apache = Helper.uri("http://www.apache.org/licenses/LICENSE-2.0");

	public ExtractorFactory<?> getExtractorFactory() {
		return LicenseExtractor.factory;
	}
	
	public void testOnlyCc() throws RepositoryException {
		assertExtracts("ccBy");
		assertContains(baseURI, DCTERMS.license, ccBy);
		assertNotContains(baseURI, DCTERMS.license, apache);

	}
// useless
	public void testOnlyApache() throws RepositoryException {
		assertExtracts("apache");
		assertNotContains(baseURI, DCTERMS.license, ccBy);
		assertContains(baseURI, DCTERMS.license, apache);
	}

	public void testMultipleLicenses() throws RepositoryException {
		assertExtracts("multiple");
		assertContains(baseURI, DCTERMS.license, ccBy);
		assertContains(baseURI, DCTERMS.license, apache);
	}

	public void testMultipleEmptyHref() throws RepositoryException {
		assertExtracts("multiple-empty-href");
		assertNotContains(baseURI, DCTERMS.license, "");
		assertContains(baseURI, DCTERMS.license, apache);
	}

	
	public void testEmpty() throws RepositoryException {
		assertNotExtracts("empty");
		assertModelEmpty();
	}

	public void testMixedCaseTitleTag() throws RepositoryException {
		assertExtracts("multiple-mixed-case");
		assertContains(baseURI, DCTERMS.license, ccBy);
		assertContains(baseURI, DCTERMS.license, apache);
	}
}


@@ -139,76 +139,19 @@
 y23.
-extractor.html.LicenseExtractor;%0Aimport org.deri.any23.vocab.DCTERMS
+vocab.XHTML
 ;%0Aim
@@ -627,20 +627,33 @@
 tracts(%22
-ccBy
+license/ccBy.html
 %22);%0A%09%09as
@@ -666,39 +666,37 @@
 ntains(baseURI, 
-DCTERMS
+XHTML
 .license, ccBy);
@@ -717,39 +717,37 @@
 ntains(baseURI, 
-DCTERMS
+XHTML
 .license, apache
@@ -753,22 +753,11 @@
 e);%0A
-%0A
 %09%7D%0A
-// useless
 %0A%09pu
@@ -830,22 +830,35 @@
 tracts(%22
+license/
 apache
+.html
 %22);%0A%09%09as
@@ -874,39 +874,37 @@
 ntains(baseURI, 
-DCTERMS
+XHTML
 .license, ccBy);
@@ -922,39 +922,37 @@
 ntains(baseURI, 
-DCTERMS
+XHTML
 .license, apache
@@ -1041,24 +1041,32 @@
 tracts(%22
+license/
 multiple
 %22);%0A%09%09as
@@ -1057,16 +1057,21 @@
 multiple
+.html
 %22);%0A%09%09as
@@ -1084,39 +1084,37 @@
 ntains(baseURI, 
-DCTERMS
+XHTML
 .license, ccBy);
@@ -1132,39 +1132,37 @@
 ntains(baseURI, 
-DCTERMS
+XHTML
 .license, apache
@@ -1244,32 +1244,40 @@
 assertExtracts(%22
+license/
 multiple-empty-h
@@ -1279,16 +1279,21 @@
 pty-href
+.html
 %22);%0A%09%09as
@@ -1309,39 +1309,37 @@
 ntains(baseURI, 
-DCTERMS
+XHTML
 .license, %22%22);%0A%09
@@ -1355,39 +1355,37 @@
 ntains(baseURI, 
-DCTERMS
+XHTML
 .license, apache
@@ -1391,18 +1391,16 @@
 e);%0A%09%7D%0A%0A
-%09%0A
 %09public 
@@ -1453,19 +1453,16 @@
 %09%09assert
-Not
 Extracts
@@ -1463,21 +1463,34 @@
 tracts(%22
-empty
+license/empty.html
 %22);%0A%09%09as
@@ -1595,16 +1595,24 @@
 tracts(%22
+license/
 multiple
@@ -1622,16 +1622,21 @@
 xed-case
+.html
 %22);%0A%09%09as
@@ -1649,39 +1649,37 @@
 ntains(baseURI, 
-DCTERMS
+XHTML
 .license, ccBy);
@@ -1709,15 +1709,13 @@
 RI, 
-DCTERMS
+XHTML
 .lic

fix license extractor test cases