-
Notifications
You must be signed in to change notification settings - Fork 365
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #301 from zimmi/module-resource-loading
Make loading resources from classpath work when openhtmltopdf is a named module
- Loading branch information
Showing
10 changed files
with
134 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,4 @@ release.properties | |
tags | ||
maven-eclipse.xml | ||
Maven_Ant_Builder.launch | ||
/openhtmltopdf-core/nbproject/ |
52 changes: 0 additions & 52 deletions
52
openhtmltopdf-core/src/main/java/com/openhtmltopdf/DefaultCSSMarker.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
openhtmltopdf-core/src/test/java/com/openhtmltopdf/resource/FSCatalogTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.openhtmltopdf.resource; | ||
|
||
import java.util.Map; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class FSCatalogTest { | ||
|
||
@Test | ||
public void testParseCatalog() { | ||
FSCatalog instance = new FSCatalog(); | ||
String catalogUri = "/resources/schema/openhtmltopdf/catalog-special.xml"; | ||
Map<String, String> catalog = instance.parseCatalog(catalogUri); | ||
String publicId = "-//OPENHTMLTOPDF//DOC XHTML Character Entities Only 1.0//EN"; | ||
Assert.assertTrue(catalog.containsKey(publicId)); | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
openhtmltopdf-core/src/test/java/com/openhtmltopdf/resource/FSEntityResolverTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.openhtmltopdf.resource; | ||
|
||
import java.io.InputStream; | ||
import java.util.Map; | ||
import static org.hamcrest.CoreMatchers.notNullValue; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.xml.sax.InputSource; | ||
|
||
public class FSEntityResolverTest { | ||
|
||
@Test | ||
public void testResolveEntity() throws Exception { | ||
FSEntityResolver instance = FSEntityResolver.instance(); | ||
String publicId = "-//OPENHTMLTOPDF//DOC XHTML Character Entities Only 1.0//EN"; | ||
InputSource resolvedEntity = instance.resolveEntity(publicId, null); | ||
try (InputStream in = resolvedEntity.getByteStream()) { | ||
Assert.assertThat(in, notNullValue()); | ||
} | ||
} | ||
|
||
@Test | ||
public void testGetEntities() { | ||
FSEntityResolver instance = FSEntityResolver.instance(); | ||
Map<String, String> entities = instance.getEntities(); | ||
String publicId = "-//OPENHTMLTOPDF//DOC XHTML Character Entities Only 1.0//EN"; | ||
Assert.assertTrue(entities.containsKey(publicId)); | ||
} | ||
|
||
} |
72 changes: 72 additions & 0 deletions
72
openhtmltopdf-core/src/test/java/com/openhtmltopdf/util/ConfigurationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package com.openhtmltopdf.util; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import org.junit.Test; | ||
import static org.junit.Assert.*; | ||
|
||
public class ConfigurationTest { | ||
|
||
@Test | ||
public void testValueFor() { | ||
String key = "xr.test-config-byte"; | ||
String value = Configuration.valueFor(key); | ||
assertThat(value, is("8")); | ||
} | ||
|
||
@Test | ||
public void testValueAsByte() { | ||
String key = "xr.test-config-byte"; | ||
int value = Configuration.valueAsByte(key, (byte) 0); | ||
assertThat(value, is(8)); | ||
} | ||
|
||
@Test | ||
public void testValueAsShort() { | ||
String key = "xr.test-config-short"; | ||
int value = Configuration.valueAsShort(key, (short) 0); | ||
assertThat(value, is(16)); | ||
} | ||
|
||
@Test | ||
public void testValueAsInt() { | ||
String key = "xr.test-config-int"; | ||
int value = Configuration.valueAsInt(key, (int) 0); | ||
assertThat(value, is(100)); | ||
} | ||
|
||
@Test | ||
public void testValueAsLong() { | ||
String key = "xr.test-config-long"; | ||
long value = Configuration.valueAsLong(key, (long) 0); | ||
assertThat(value, is(2000L)); | ||
} | ||
|
||
@Test | ||
public void testValueAsFloat() { | ||
String key = "xr.test-config-float"; | ||
float value = Configuration.valueAsFloat(key, (float) 0); | ||
assertThat(value, is(3000.25F)); | ||
} | ||
|
||
@Test | ||
public void testValueAsDouble() { | ||
String key = "xr.test-config-double"; | ||
double value = Configuration.valueAsDouble(key, (double) 0); | ||
assertThat(value, is(4000.50D)); | ||
} | ||
|
||
@Test | ||
public void testIsTrue() { | ||
String key = "xr.test-config-boolean"; | ||
boolean value = Configuration.isTrue(key, false); | ||
assertThat(value, is(true)); | ||
} | ||
|
||
@Test | ||
public void testIsFalse() { | ||
String key = "xr.test-config-boolean"; | ||
boolean value = Configuration.isFalse(key, true); | ||
assertThat(value, is(false)); | ||
} | ||
|
||
} |