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.datatype.typeimpl.EnumType;
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:
29: /**
30: * Test case for CForms's DynamicSelectionList datatype.
31: *
32: * @version $Id: EnumSelectionListTestCase.java 518026 2007-03-14 05:25:54Z antonio $
33: */
34: public class EnumSelectionListTestCase 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: EnumSelectionList list = new EnumSelectionList(Sex.class
45: .getName(), new EnumType(), false);
46: list.generateSaxFragment(dest, Locale.ENGLISH);
47: ResourceSource expectedSource = new ResourceSource(
48: "resource://org/apache/cocoon/forms/datatype/EnumSelectionListTestCase.dest-no-null.xml");
49: Document expected = this .parser.parse(expectedSource
50: .getInputStream());
51: Document destDocument = dest.getDocument();
52: assertEqual("Test if output is what is expected", expected,
53: destDocument);
54: }
55:
56: /**
57: * Test the generateSaxFragment method with a nullable selection list
58: * @throws MalformedURLException
59: * @throws ParserConfigurationException
60: */
61: public void testGenerateSaxFragmentNullable() throws Exception {
62: DOMBuilder dest = new DOMBuilder();
63: EnumSelectionList list = new EnumSelectionList(Sex.class
64: .getName(), new EnumType(), true);
65: list.generateSaxFragment(dest, Locale.ENGLISH);
66: ResourceSource expectedSource = new ResourceSource(
67: "resource://org/apache/cocoon/forms/datatype/EnumSelectionListTestCase.dest.xml");
68: Document expected = this .parser.parse(expectedSource
69: .getInputStream());
70: Document destDocument = dest.getDocument();
71: assertEqual("Test if output is what is expected", expected,
72: destDocument);
73: }
74:
75: }
|