1   /****************************************************************
2    * Licensed to the Apache Software Foundation (ASF) under one   *
3    * or more contributor license agreements.  See the NOTICE file *
4    * distributed with this work for additional information        *
5    * regarding copyright ownership.  The ASF licenses this file   *
6    * to you under the Apache License, Version 2.0 (the            *
7    * "License"); you may not use this file except in compliance   *
8    * with the License.  You may obtain a copy of the License at   *
9    *                                                              *
10   *   http://www.apache.org/licenses/LICENSE-2.0                 *
11   *                                                              *
12   * Unless required by applicable law or agreed to in writing,   *
13   * software distributed under the License is distributed on an  *
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
15   * KIND, either express or implied.  See the License for the    *
16   * specific language governing permissions and limitations      *
17   * under the License.                                           *
18   ****************************************************************/
19  
20  package org.apache.james.jspf;
21  
22  import java.io.IOException;
23  import java.util.Iterator;
24  import java.util.List;
25  
26  import org.apache.james.jspf.tester.SPFYamlTestDescriptor;
27  
28  import junit.framework.Test;
29  import junit.framework.TestSuite;
30  
31  public class YamlTest extends AbstractYamlTest {
32  
33      private static final String YAMLFILE2 = "tests.yml";
34  
35      /**
36       * @param name
37       * @throws IOException
38       */
39      public YamlTest(String name) throws IOException {
40          super(name);
41      }
42  
43      protected YamlTest(SPFYamlTestDescriptor def, String test) {
44          super(def, test);
45      }
46  
47      protected String getFilename() {
48          return YAMLFILE2;
49      }
50  
51      public static Test suite() throws IOException {
52          return new BasicSuite();
53      }
54  
55      static class BasicSuite extends TestSuite {
56  
57          public BasicSuite() throws IOException {
58              super();
59              List tests = SPFYamlTestDescriptor.loadTests(YAMLFILE2);
60              Iterator i = tests.iterator();
61              while (i.hasNext()) {
62                  SPFYamlTestDescriptor o = (SPFYamlTestDescriptor) i.next();
63                  Iterator ttt = o.getTests().keySet().iterator();
64                  while (ttt.hasNext()) {
65                      addTest(new YamlTest(o,(String) ttt.next()));
66                  }
67              }
68          }
69  
70      }
71  
72  }