[FOray-commit] SF.net SVN: foray:[12975] trunk/foray/foray-fotree/src
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2022-12-29 13:01:48
|
Revision: 12975
http://sourceforge.net/p/foray/code/12975
Author: victormote
Date: 2022-12-29 13:01:44 +0000 (Thu, 29 Dec 2022)
Log Message:
-----------
Activate tests.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/NamespaceFo.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/prop/PdDominantBaseline.java
trunk/foray/foray-fotree/src/test/java/org/foray/fotree/fo/prop/DominantBaselineTests.java
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/NamespaceFo.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/NamespaceFo.java 2022-12-28 22:18:53 UTC (rev 12974)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/NamespaceFo.java 2022-12-29 13:01:44 UTC (rev 12975)
@@ -1058,7 +1058,7 @@
return new PdDisplayAlign(attributeValue);
}
case DOMINANT_BASELINE: {
- return PdDominantBaseline.getInstance(attributeValue);
+ return PdDominantBaseline.procureInstance(attributeValue);
}
case ELEVATION: {
return new PdElevation(attributeValue);
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/prop/PdDominantBaseline.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/prop/PdDominantBaseline.java 2022-12-28 22:18:53 UTC (rev 12974)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/prop/PdDominantBaseline.java 2022-12-29 13:01:44 UTC (rev 12975)
@@ -127,11 +127,12 @@
/**
* Converts the unparsed property value into its parsed, storable value.
- * @param value The unparsed property value.
- * @return The instance of this property whose value is {@code value}, or null if it is not valid.
+ * @param unparsedValue The unparsed property value.
+ * @return The instance of this property whose value is {@code unparsedValue}.
+ * @throws PropertyException For errors parsing {@code unparsedValue}.
*/
- public static PdDominantBaseline getInstance(final String value) {
- switch (value) {
+ public static PdDominantBaseline procureInstance(final String unparsedValue) throws PropertyException {
+ switch (unparsedValue) {
case "auto":
return PdDominantBaseline.AUTO;
case "use-script":
@@ -158,26 +159,16 @@
return PdDominantBaseline.TEXT_BEFORE_EDGE;
case "inherit":
return PdDominantBaseline.INHERIT;
- default:
- try {
- final PropertyValue parsedValue =
- PropertyParser.getInstance().parse(value, FoPropertyId.DOMINANT_BASELINE);
- if (parsedValue == null) {
- return null;
- }
- if (! (parsedValue instanceof FnAbstractNamedProperty)) {
- return null;
- }
+ default: {
+ final PropertyValue parsedValue =
+ PropertyParser.getInstance().parse(unparsedValue, FoPropertyId.DOMINANT_BASELINE);
+ if (parsedValue instanceof FnAbstractNamedProperty) {
final FnAbstractNamedProperty named = (FnAbstractNamedProperty) parsedValue;
- if (! (named.getPropertyType() == FoPropertyId.DOMINANT_BASELINE)
- && ! (named.getPropertyType() == null)) {
- return null;
- }
return new PdDominantBaseline(named);
- } catch (final PropertyException e) {
- return null;
}
+ throw new PropertyException("Unable to parse expression: " + unparsedValue);
}
+ }
}
/**
Modified: trunk/foray/foray-fotree/src/test/java/org/foray/fotree/fo/prop/DominantBaselineTests.java
===================================================================
--- trunk/foray/foray-fotree/src/test/java/org/foray/fotree/fo/prop/DominantBaselineTests.java 2022-12-28 22:18:53 UTC (rev 12974)
+++ trunk/foray/foray-fotree/src/test/java/org/foray/fotree/fo/prop/DominantBaselineTests.java 2022-12-29 13:01:44 UTC (rev 12975)
@@ -30,12 +30,9 @@
import org.foray.fotree.AbstractPropertyTests;
import org.foray.fotree.PropertyException;
-import org.foray.fotree.value.FnInheritedPropertyValue;
-import org.foray.fotree.value.PropertyValue;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.jupiter.api.Disabled;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.jupiter.api.Test;
/**
@@ -45,7 +42,7 @@
@Override
protected PdDominantBaseline createProperty(final String attributeValue) throws PropertyException {
- final PdDominantBaseline property = PdDominantBaseline.getInstance(attributeValue);
+ final PdDominantBaseline property = PdDominantBaseline.procureInstance(attributeValue);
checkNullProperty(property, attributeValue);
return property;
}
@@ -181,19 +178,27 @@
}
/**
- * Test of {@code dominant-baseline="inherited-property-value('dominant-baseline')"}.
- * @throws PropertyException Not expected here.
+ * Test of a property value of "inherited-property-value(the-property-name)".
*/
@Test
- @Disabled("Waiting for FnInheritedPropertyValue to be completed.")
- public void inheritedPropertyValueParseTest() throws PropertyException {
- final PdDominantBaseline property = createProperty("inherited-property-value(\"dominant-baseline\")");
- final PropertyValue actualOutside = property.value();
- assertTrue(actualOutside instanceof FnInheritedPropertyValue);
- final FnInheritedPropertyValue ipv = (FnInheritedPropertyValue) actualOutside;
- final PropertyValue actualInside = ipv.eval(property, makeTestFObj());
- /* For this test, the initial value should be returned. */
- assertEquals(PdDominantBaseline.AUTO, actualInside);
+ public void inheritedPropertyValueParseTest1() {
+ final PropertyException exception = assertThrows(PropertyException.class, () -> {
+ createProperty("inherited-property-value(dominant-baseline)");
+ });
+ assertEquals("Function inherited-property-value() must operate on an inherited property.",
+ exception.getMessage());
}
+ /**
+ * Test of {@code dominant-baseline="inherited-property-value()"}.
+ */
+ @Test
+ public void inheritedPropertyValueParseTest2() {
+ final PropertyException exception = assertThrows(PropertyException.class, () -> {
+ createProperty("inherited-property-value()");
+ });
+ assertEquals("Function inherited-property-value() must operate on an inherited property.",
+ exception.getMessage());
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|