View Javadoc

1   /*
2    * Copyright 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.apache.pluto.portalImpl.portlet;
17  
18  import java.io.InputStream;
19  import java.io.IOException;
20  import java.util.List;
21  
22  import org.apache.commons.digester.Digester;
23  import org.xml.sax.SAXException;
24  
25  /***
26   * @author <a href="ddewolf@apache.com">David H. DeWolf</a>
27   *
28   */
29  public class TestConfigFactory {
30  
31      private Digester digester = new Digester();
32  
33      public TestConfigFactory() {
34          digester = new Digester();
35          digester.addObjectCreate("testportlet-config",
36                                   java.util.ArrayList.class);
37  
38  
39          digester.addObjectCreate("testportlet-config/testsuite-config",
40                                   TestConfig.class);
41  
42          digester.addBeanPropertySetter("testportlet-config/testsuite-config/name",
43                                         "name");
44  
45          digester.addBeanPropertySetter("testportlet-config/testsuite-config/class",
46                                         "testClassName");
47  
48          digester.addBeanPropertySetter("testportlet-config/testsuite-config/display-uri",
49                                         "displayURI");
50  
51          digester.addCallMethod("testportlet-config/testsuite-config/init-param", "addInitParameter", 2);
52          digester.addCallParam("testportlet-config/testsuite-config/init-param/name", 0);
53          digester.addCallParam("testportlet-config/testsuite-config/init-param/value", 1);
54  
55  
56          digester.addSetRoot("testportlet-config/testsuite-config",
57                              "add");
58  
59      }
60  
61      public List createTests(InputStream in)
62      throws SAXException, IOException {
63          return (List)digester.parse(in);
64      }
65  }