1   /*
2    * Copyright 2001-2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.portletbridge.xsl;
17  
18  import junit.framework.TestCase;
19  
20  import org.apache.xerces.impl.xs.opti.DefaultDocument;
21  import org.apache.xml.utils.DOMBuilder;
22  import org.w3c.dom.Attr;
23  import org.w3c.dom.CDATASection;
24  import org.w3c.dom.Comment;
25  import org.w3c.dom.DOMException;
26  import org.w3c.dom.DOMImplementation;
27  import org.w3c.dom.Document;
28  import org.w3c.dom.DocumentFragment;
29  import org.w3c.dom.DocumentType;
30  import org.w3c.dom.Element;
31  import org.w3c.dom.EntityReference;
32  import org.w3c.dom.NamedNodeMap;
33  import org.w3c.dom.Node;
34  import org.w3c.dom.NodeList;
35  import org.w3c.dom.ProcessingInstruction;
36  import org.w3c.dom.Text;
37  import org.xml.sax.ContentHandler;
38  import org.xml.sax.helpers.AttributesImpl;
39  import org.xml.sax.helpers.DefaultHandler;
40  
41  import EDU.oswego.cs.dl.util.concurrent.Callable;
42  
43  /***
44   * @author JMcCrindle
45   */
46  public class QueuingContentHandlerTest extends TestCase {
47  
48      /*
49       * @see TestCase#setUp()
50       */
51      protected void setUp() throws Exception {
52          super.setUp();
53      }
54      
55      public void testQueue() throws Exception {
56          final QueuingContentHandler handler = new QueuingContentHandler(new DefaultHandler());
57          handler.startQueuing();
58          handler.startDocument();
59          handler.startElement("", "a", "a", new AttributesImpl());
60          handler.startElement("", "a", "a", new AttributesImpl());
61          handler.enqueue(new Callable() {
62              public Object call() throws Exception {
63                  handler.getContentHandler().startElement("", "b", "b", new AttributesImpl());
64                  return null;
65              }
66          });
67          handler.stopQueuing();
68          handler.endElement("", "a", "a");
69          handler.endElement("", "a", "a");
70          handler.endDocument();
71      }
72  
73      /*
74       * @see TestCase#tearDown()
75       */
76      protected void tearDown() throws Exception {
77          super.tearDown();
78      }
79  
80      /***
81       * Constructor for QueuingContentHandlerTest.
82       * @param arg0
83       */
84      public QueuingContentHandlerTest(String arg0) {
85          super(arg0);
86      }
87  
88  }