1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.test.integration

File XWikiTestSetup.java

 

Coverage histogram

../../../../img/srcFileCovDistChart9.png
38% of files have more coverage

Code metrics

2
14
6
1
103
48
7
0.5
2.33
6
1.17

Classes

Class Line # Actions
XWikiTestSetup 52 14 0% 7 4
0.818181881.8%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.test.integration;
21   
22    import java.util.ArrayList;
23    import java.util.List;
24   
25    import junit.extensions.TestSetup;
26    import junit.framework.Test;
27   
28    import org.apache.commons.configuration.PropertiesConfiguration;
29   
30    /**
31    * JUnit TestSetup extension that starts/stops XWiki using a script passed using System Properties. These properties are
32    * meant to be passed by the underlying build system. This class is meant to wrap a JUnit TestSuite. For example:
33    *
34    * <pre>
35    * &lt;code&gt;
36    * public static Test suite()
37    * {
38    * // Create some TestSuite object here
39    * return new XWikiTestSetup(suite);
40    * }
41    * &lt;/code&gt;
42    * </pre>
43    * <p>
44    * Note: We could start XWiki using Java directly but we're using a script so that we can test the exact same script
45    * used by XWiki users who download the standalone distribution.
46    * </p>
47    *
48    * @version $Id: 89c9e75a3a7669b349540879639e6f2ffa477786 $
49    * @deprecated use {@link XWikiExecutorSuite} instead
50    */
51    @Deprecated
 
52    public class XWikiTestSetup extends TestSetup
53    {
54    private List<XWikiExecutor> executors = new ArrayList<XWikiExecutor>();
55   
 
56  2 toggle public XWikiTestSetup(Test test) throws Exception
57    {
58  2 this(test, 1);
59    }
60   
 
61  2 toggle public XWikiTestSetup(Test test, int nb) throws Exception
62    {
63  2 super(test);
64   
65  4 for (int i = 0; i < nb; ++i) {
66  2 XWikiExecutor executor = new XWikiExecutor(i);
67   
68  2 PropertiesConfiguration properties = executor.loadXWikiPropertiesConfiguration();
69    // Don't set any extension repository since we don't need it and we don't want to require internet
70    // connection for the tests.
71  2 properties.setProperty("extension.repositories", "");
72  2 executor.saveXWikiProperties(properties);
73   
74  2 this.executors.add(executor);
75    }
76    }
77   
 
78  2 toggle @Override
79    protected void setUp() throws Exception
80    {
81  2 for (XWikiExecutor executor : this.executors) {
82  2 executor.start();
83    }
84    }
85   
 
86  2 toggle @Override
87    protected void tearDown() throws Exception
88    {
89  2 for (XWikiExecutor executor : this.executors) {
90  2 executor.stop();
91    }
92    }
93   
 
94  0 toggle protected XWikiExecutor getXWikiExecutor()
95    {
96  0 return getXWikiExecutor(0);
97    }
98   
 
99  0 toggle protected XWikiExecutor getXWikiExecutor(int index)
100    {
101  0 return this.executors.get(index);
102    }
103    }