View Javadoc

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  package org.apache.chemistry.opencmis.tck.runner;
20  
21  import java.io.File;
22  import java.io.PrintWriter;
23  
24  import org.apache.chemistry.opencmis.tck.CmisTest;
25  import org.apache.chemistry.opencmis.tck.CmisTestGroup;
26  import org.apache.chemistry.opencmis.tck.CmisTestProgressMonitor;
27  import org.apache.chemistry.opencmis.tck.CmisTestReport;
28  import org.apache.chemistry.opencmis.tck.report.TextReport;
29  
30  /**
31   * Console Runner.
32   * 
33   * This runner can be started for a console and accepts two parameters: OpenCMIS
34   * Session parameters file name and group list file name.
35   */
36  public class ConsoleRunner extends AbstractRunner {
37  
38      public ConsoleRunner(String[] args) throws Exception {
39          if (args.length < 1) {
40              setParameters(null);
41          } else {
42              loadParameters(new File(args[0]));
43          }
44  
45          if (args.length < 2) {
46              loadDefaultTckGroups();
47          } else {
48              loadGroups(new File(args[1]));
49          }
50  
51          run(new ConsoleProgressMonitor());
52  
53          CmisTestReport report = new TextReport();
54          report.createReport(getParameters(), getGroups(), new PrintWriter(System.out));
55      }
56  
57      private static class ConsoleProgressMonitor implements CmisTestProgressMonitor {
58          
59          @Override
60          @SuppressWarnings("PMD.SystemPrintln")
61          public void startGroup(CmisTestGroup group) {
62              System.out.println(group.getName() + " (" + group.getTests().size() + " tests)");
63          }
64  
65          @Override
66          @SuppressWarnings("PMD.SystemPrintln")
67          public void endGroup(CmisTestGroup group) {
68              System.out.println();
69          }
70  
71          @Override
72          @SuppressWarnings("PMD.SystemPrintln")
73          public void startTest(CmisTest test) {
74              System.out.print('.');
75          }
76  
77          @Override
78          public void endTest(CmisTest test) {
79          }
80  
81          @Override
82          @SuppressWarnings("PMD.SystemPrintln")
83          public void message(String msg) {
84              System.out.println(msg);
85          }
86      }
87  
88      public static void main(String[] args) throws Exception {
89          new ConsoleRunner(args);
90      }
91  }