01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package org.apache.cocoon.forms.datatype;
19:
20: import java.util.Locale;
21:
22: import org.apache.cocoon.forms.FormsConstants;
23: import org.apache.cocoon.xml.dom.DOMBuilder;
24:
25: import org.apache.excalibur.source.impl.ResourceSource;
26:
27: import org.w3c.dom.Document;
28: import org.w3c.dom.Element;
29:
30: /**
31: * Test case for CForms's DynamicSelectionList datatype.
32: * @version $Id: DynamicSelectionListTestCase.java 518026 2007-03-14 05:25:54Z antonio $
33: */
34: public class DynamicSelectionListTestCase extends
35: AbstractSelectionListTestCase {
36:
37: /**
38: * Test the generateSaxFragment method.
39: * @throws MalformedURLException
40: * @throws ParserConfigurationException
41: */
42: public void testGenerateSaxFragment() throws Exception {
43: DOMBuilder dest = new DOMBuilder();
44: ResourceSource source = new ResourceSource(
45: "resource://org/apache/cocoon/forms/datatype/DynamicSelectionListTestCase.source.xml");
46: Document sourceDoc = this .parser.parse(source.getInputStream());
47: Element datatypeElement = (Element) sourceDoc
48: .getElementsByTagNameNS(FormsConstants.DEFINITION_NS,
49: "convertor").item(0);
50: Datatype datatype = this .datatypeManager.createDatatype(
51: datatypeElement, false);
52: DynamicSelectionList list = new DynamicSelectionList(datatype,
53: null, this .getManager());
54: list.generateSaxFragment(dest, Locale.ENGLISH, source);
55: ResourceSource expectedSource = new ResourceSource(
56: "resource://org/apache/cocoon/forms/datatype/DynamicSelectionListTestCase.dest.xml");
57: Document expected = this .parser.parse(expectedSource
58: .getInputStream());
59: assertEqual("Test if output is what is expected", expected,
60: dest.getDocument());
61: }
62:
63: }
|