1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package org.openoffice.testgraphical.qa.graphical;
25 
26 import org.openoffice.Runner;
27 import org.openoffice.test.OfficeConnection;
28 import static org.junit.Assert.*;
29 
30 import helper.ProcessHandler;
31 import graphical.FileHelper;
32 import java.io.File;
33 
34 public final class Test {
35     @org.junit.Before
setUp()36     public void setUp() throws Exception
37         {
38             connection.setUp();
39         }
40 
41     @org.junit.After
tearDown()42     public void tearDown() throws Exception
43         {
44             connection.tearDown();
45         }
46 
47     @org.junit.Test
test()48     public void test()
49         {
50             boolean good = true;
51 
52             final String sPerlEXE = System.getenv("PERL");
53             // System.out.println("PERL:=" + sPerlEXE);
54 
55             final String sPRJ = System.getenv("PRJ");
56             // System.out.println("PRJ:=" + sPRJ);
57 
58             String sShow = "";
59             if (System.getProperty("SHOW") != null)
60             {
61                 sShow = "-show";
62             }
63 
64             final String sComparePath = FileHelper.appendPath(sPRJ, "source");
65             final String sCompareName = FileHelper.appendPath(sComparePath, "compare.pl");
66 
67             File aCompareFile = new File(sCompareName);
68             if (!aCompareFile.exists())
69             {
70                 System.out.println("Path to compare.pl is wrong: '" + aCompareFile.getAbsolutePath() + "'");
71                 assertTrue(false);
72             }
73 
74             final String sConnectionString = connection.getDescription();
75 
76             String[] sCommandArray =
77                 {
78                     sPerlEXE,
79                     aCompareFile.getAbsolutePath(),
80                     "-creatortype", "pdf",
81 
82 // If you make changes here, do it also in ../../source/makefile.mk in selftest: target!
83 
84                     "-pool",        "singletest",
85                     "-document",    "eis-test.odt",
86                     // "-pool",        "demo",
87                     // "-document",    "CurrentTime.ods",
88                     "-connectionstring", sConnectionString,
89                     // "-verbose",
90                     sShow
91                 };
92 
93             ProcessHandler aHandler = new ProcessHandler(sCommandArray);
94             boolean bBackValue = aHandler.executeSynchronously();
95             int nExitCode = aHandler.getExitCode();
96 
97             // String sBack = aHandler.getOutputText();
98             if (nExitCode != 0)
99             {
100                 good = false;
101             }
102 
103             assertTrue(good);
104 
105             // Runner.run(
106             //     "-sce", "sw.sce", "-xcl", "knownissues.xcl", "-tdoc",
107             //     "testdocuments", "-cs", connection.getDescription()));
108     }
109 
110     private final OfficeConnection connection = new OfficeConnection();
111 }
112