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 SPFYamlTest extends AbstractYamlTest {
32
33 private static final String YAMLFILE = "pyspf-tests.yml";
34
35
36 public SPFYamlTest(String name) throws IOException {
37 super(name);
38 }
39
40 protected SPFYamlTest(SPFYamlTestDescriptor def, String test) {
41 super(def, test);
42 }
43
44 protected String getFilename() {
45 return YAMLFILE;
46 }
47
48 public static Test suite() throws IOException {
49 return new SPFSuite();
50 }
51
52 static class SPFSuite extends TestSuite {
53
54 public SPFSuite() throws IOException {
55 super();
56 List tests = SPFYamlTestDescriptor.loadTests(YAMLFILE);
57 Iterator i = tests.iterator();
58 while (i.hasNext()) {
59 SPFYamlTestDescriptor o = (SPFYamlTestDescriptor) i.next();
60 Iterator ttt = o.getTests().keySet().iterator();
61 while (ttt.hasNext()) {
62 addTest(new SPFYamlTest(o,(String) ttt.next()));
63 }
64 }
65 }
66
67 }
68 }