CVS: Tapestry/junit/src/net/sf/tapestry/junit/parse ComponentType.application,NONE,1.1.2.1 NulledPage.page,NONE,1.1.2.1 PropertyValue.page,NONE,1.1.2.1 StaticBindingValue.page,NONE,1.1.2.1 MissingDoctype.application,NONE,1.1.2.1 NulledComponent.jwc,NONE,1.1.2.1 InvalidPublicId.application,NONE,1.1.2.1 NulledApplication.application,NONE,1.1.2.1 SpecificationParserTest.java,1.9.2.2,1.9.2.3
Howard Lewis Ship <[email protected]>
| Newsgroups | gmane.comp.java.tapestry.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/tapestry/Tapestry/junit/src/net/sf/tapestry/junit/parse
In directory sc8-pr-cvs1:/tmp/cvs-serv21119/junit/src/net/sf/tapestry/junit/parse
Modified Files:
Tag: hship-2-3
SpecificationParserTest.java
Added Files:
Tag: hship-2-3
ComponentType.application NulledPage.page PropertyValue.page
StaticBindingValue.page MissingDoctype.application
NulledComponent.jwc InvalidPublicId.application
NulledApplication.application
Log Message:
Create specification DTD 1.4
Add tests for new features in DTD 1.4
Add Bean Scripting Framework to lib/ext.
--- NEW FILE: ComponentType.application ---
<?xml version="1.0"?>
<!-- $Id: ComponentType.application,v 1.1.2.1 2002/12/31 17:08:40 hship Exp $ -->
<!DOCTYPE application PUBLIC
"-//Howard Lewis Ship//Tapestry Specification 1.4//EN"
"http://tapestry.sf.net/dtd/Tapestry_1_4.dtd">
<application>
<component-type type="Fred" specification-path="/path/Fred.jwc"/>
</application>
--- NEW FILE: NulledPage.page ---
<?xml version="1.0"?>
<!-- $Id: NulledPage.page,v 1.1.2.1 2002/12/31 17:08:40 hship Exp $ -->
<!DOCTYPE page-specification PUBLIC
"-//Howard Lewis Ship//Tapestry Specification 1.4//EN"
"http://tapestry.sf.net/dtd/Tapestry_1_4.dtd">
<page-specification/>
--- NEW FILE: PropertyValue.page ---
<?xml version="1.0"?>
<!-- $Id: PropertyValue.page,v 1.1.2.1 2002/12/31 17:08:40 hship Exp $ -->
<!DOCTYPE page-specification PUBLIC
"-//Howard Lewis Ship//Tapestry Specification 1.4//EN"
"http://tapestry.sf.net/dtd/Tapestry_1_4.dtd">
<page-specification>
<property name="barney" value="rubble"/>
<property name="wilma" value="flintstone">
Ignored.
</property>
</page-specification>
--- NEW FILE: StaticBindingValue.page ---
<?xml version="1.0"?>
<!-- $Id: StaticBindingValue.page,v 1.1.2.1 2002/12/31 17:08:40 hship Exp $ -->
<!DOCTYPE page-specification PUBLIC
"-//Howard Lewis Ship//Tapestry Specification 1.4//EN"
"http://tapestry.sf.net/dtd/Tapestry_1_4.dtd">
<page-specification>
<component id="c" type="Insert">
<static-binding name="fred">flintstone</static-binding>
<static-binding name="barney" value="rubble"/>
<static-binding name="rock" value="hudson">Ignored.</static-binding>
</component>
</page-specification>
--- NEW FILE: MissingDoctype.application ---
<?xml version="1.0"?>
<!--$Id: MissingDoctype.application,v 1.1.2.1 2002/12/31 17:08:40 hship Exp $-->
<application name="Tapestry Component Workbench"
engine-class="net.sf.tapestry.engine.SimpleEngine">
</application>
--- NEW FILE: NulledComponent.jwc ---
<?xml version="1.0"?>
<!-- $Id: NulledComponent.jwc,v 1.1.2.1 2002/12/31 17:08:40 hship Exp $ -->
<!DOCTYPE component-specification PUBLIC
"-//Howard Lewis Ship//Tapestry Specification 1.4//EN"
"http://tapestry.sf.net/dtd/Tapestry_1_4.dtd">
<component-specification/>
--- NEW FILE: InvalidPublicId.application ---
<?xml version="1.0"?>
<!--$Id: InvalidPublicId.application,v 1.1.2.1 2002/12/31 17:08:41 hship Exp $-->
<!DOCTYPE application PUBLIC
"-//Howard Lewis Ship//Tapestry Specification 1.1//EN"
"http://tapestry.sf.net/dtd/Tapestry_1_3.dtd">
<application name="Tapestry Component Workbench"
engine-class="net.sf.tapestry.engine.SimpleEngine">
</application>
--- NEW FILE: NulledApplication.application ---
<?xml version="1.0"?>
<!-- $Id: NulledApplication.application,v 1.1.2.1 2002/12/31 17:08:41 hship Exp $ -->
<!DOCTYPE application PUBLIC
"-//Howard Lewis Ship//Tapestry Specification 1.4//EN"
"http://tapestry.sf.net/dtd/Tapestry_1_4.dtd">
<!-- Show that an application specification can omit
the name and engine-class attributes. -->
<application/>
Index: SpecificationParserTest.java
===================================================================
RCS file: /cvsroot/tapestry/Tapestry/junit/src/net/sf/tapestry/junit/parse/SpecificationParserTest.java,v
retrieving revision 1.9.2.2
retrieving revision 1.9.2.3
diff -C2 -d -r1.9.2.2 -r1.9.2.3
*** SpecificationParserTest.java 7 Dec 2002 13:26:10 -0000 1.9.2.2
--- SpecificationParserTest.java 31 Dec 2002 17:08:40 -0000 1.9.2.3
***************
*** 1,14 ****
package net.sf.tapestry.junit.parse;
- import junit.framework.AssertionFailedError;
-
import net.sf.tapestry.junit.TapestryTestCase;
- import net.sf.tapestry.spec.ApplicationSpecification;
import net.sf.tapestry.spec.BindingSpecification;
import net.sf.tapestry.spec.BindingType;
import net.sf.tapestry.spec.ComponentSpecification;
import net.sf.tapestry.spec.IApplicationSpecification;
import net.sf.tapestry.spec.ILibrarySpecification;
- import net.sf.tapestry.spec.LibrarySpecification;
import net.sf.tapestry.spec.ParameterSpecification;
import net.sf.tapestry.util.xml.DocumentParseException;
--- 1,11 ----
package net.sf.tapestry.junit.parse;
import net.sf.tapestry.junit.TapestryTestCase;
import net.sf.tapestry.spec.BindingSpecification;
import net.sf.tapestry.spec.BindingType;
import net.sf.tapestry.spec.ComponentSpecification;
+ import net.sf.tapestry.spec.ContainedComponent;
import net.sf.tapestry.spec.IApplicationSpecification;
import net.sf.tapestry.spec.ILibrarySpecification;
import net.sf.tapestry.spec.ParameterSpecification;
import net.sf.tapestry.util.xml.DocumentParseException;
***************
*** 33,53 ****
}
- /**
- *
- * Asserts that the exception message contains the
- * indicated substring.
- *
- * @since 2.2
- *
- **/
-
- private void checkException(DocumentParseException ex, String string)
- {
- if (ex.getMessage().indexOf(string) >= 0)
- return;
-
- throw new AssertionFailedError("Exception " + ex + " does not contain sub-string '" + string + "'.");
- }
-
/**
* Tests that the parser can handle a specification
--- 30,33 ----
***************
*** 95,99 ****
parseComponent("InvalidParameterName.jwc");
! throw new AssertionFailedError("Should not be able to parse document.");
}
catch (DocumentParseException ex)
--- 75,79 ----
parseComponent("InvalidParameterName.jwc");
! unreachable();
}
catch (DocumentParseException ex)
***************
*** 117,121 ****
parseComponent("InvalidComponentId.jwc");
! throw new AssertionFailedError("Should not be able to parse document.");
}
catch (DocumentParseException ex)
--- 97,101 ----
parseComponent("InvalidComponentId.jwc");
! unreachable();
}
catch (DocumentParseException ex)
***************
*** 139,143 ****
parseLib("InvalidLibraryId.library");
! throw new AssertionFailedError("Should not be able to parse document.");
}
catch (DocumentParseException ex)
--- 119,123 ----
parseLib("InvalidLibraryId.library");
! unreachable();
}
catch (DocumentParseException ex)
***************
*** 181,185 ****
parseComponent("InvalidAssetName.jwc");
! throw new AssertionFailedError("Should not be able to parse document.");
}
catch (DocumentParseException ex)
--- 161,165 ----
parseComponent("InvalidAssetName.jwc");
! unreachable();
}
catch (DocumentParseException ex)
***************
*** 203,208 ****
parseApp("InvalidPageName.application");
! throw new AssertionFailedError("Should not be able to parse document.");
!
}
catch (DocumentParseException ex)
--- 183,187 ----
parseApp("InvalidPageName.application");
! unreachable();
}
catch (DocumentParseException ex)
***************
*** 226,230 ****
parseApp("InvalidServiceName.application");
! throw new AssertionFailedError("Should not be able to parse document.");
}
catch (DocumentParseException ex)
--- 205,209 ----
parseApp("InvalidServiceName.application");
! unreachable();
}
catch (DocumentParseException ex)
***************
*** 248,252 ****
parseApp("InvalidComponentAlias.application");
! throw new AssertionFailedError("Should not be able to parse document.");
}
catch (DocumentParseException ex)
--- 227,231 ----
parseApp("InvalidComponentAlias.application");
! unreachable();
}
catch (DocumentParseException ex)
***************
*** 270,274 ****
parseApp("InvalidExtensionName.application");
! throw new AssertionFailedError("Should not be able to parse document.");
}
catch (DocumentParseException ex)
--- 249,253 ----
parseApp("InvalidExtensionName.application");
! unreachable();
}
catch (DocumentParseException ex)
***************
*** 279,281 ****
--- 258,390 ----
}
+ /**
+ * Test case where the document does not have a DOCTYPE
+ *
+ * @since 2.2
+ *
+ **/
+
+ public void testMissingDoctype() throws Exception
+ {
+ try
+ {
+ parseApp("MissingDoctype.application");
+
+ unreachable();
+ }
+ catch (DocumentParseException ex)
+ {
+ checkException(ex, "Valid documents must have a <!DOCTYPE");
+ }
+ }
+
+ /**
+ * Test case where the public id of the document is not known.
+ *
+ **/
+
+ public void testInvalidPublicId() throws Exception
+ {
+ try
+ {
+ parseApp("InvalidPublicId.application");
+
+ unreachable();
+ }
+ catch (DocumentParseException ex)
+ {
+ checkException(ex, "has an unexpected public id");
+ }
+ }
+
+ /**
+ * Test an an application specification can omit
+ * the name and engine-class attributes.
+ *
+ * @since 2.4
+ *
+ **/
+
+ public void testNulledApplication() throws Exception
+ {
+ IApplicationSpecification spec = parseApp("NulledApplication.application");
+
+ assertNull(spec.getEngineClassName());
+ assertNull(spec.getName());
+ }
+
+ /**
+ * Test new DTD 1.4 syntax for declaring components.
+ *
+ * @since 2.4
+ *
+ **/
+
+ public void testComponentType() throws Exception
+ {
+ IApplicationSpecification spec = parseApp("ComponentType.application");
+
+ assertEquals("/path/Fred.jwc", spec.getComponentSpecificationPath("Fred"));
+ }
+
+ /**
+ * Test omitting the class name from a component specification
+ * (new, in DTD 1.4).
+ *
+ **/
+
+ public void testNulledComponent() throws Exception
+ {
+ ComponentSpecification spec = parseComponent("NulledComponent.jwc");
+
+ assertNull(spec.getComponentClassName());
+ }
+
+ /**
+ * Test omitting the class name from a component specification
+ * (new, in DTD 1.4).
+ *
+ **/
+
+ public void testNulledPage() throws Exception
+ {
+ ComponentSpecification spec = parsePage("NulledPage.page");
+
+ assertNull(spec.getComponentClassName());
+ }
+
+ /**
+ * Test the value attribute for the property element
+ * (which is new in DTD 1.4).
+ *
+ * @since 2.4
+ *
+ **/
+
+ public void testPropertyValue() throws Exception
+ {
+ ComponentSpecification spec = parsePage("PropertyValue.page");
+
+ assertEquals("rubble", spec.getProperty("barney"));
+ assertEquals("flintstone", spec.getProperty("wilma"));
+ }
+
+ /**
+ * Tests the new (in DTD 1.4) value attribute on static-binding
+ * element.
+ *
+ * @since 2.4
+ *
+ **/
+
+ public void testStaticBindingValue() throws Exception
+ {
+ ComponentSpecification spec = parsePage("StaticBindingValue.page");
+
+ ContainedComponent c = spec.getComponent("c");
+
+ assertEquals("flintstone", c.getBinding("fred").getValue());
+ assertEquals("rubble", c.getBinding("barney").getValue());
+ assertEquals("hudson", c.getBinding("rock").getValue());
+ }
}
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf