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

File SingleXWikiExecutor.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

10
15
4
1
98
42
10
0.67
3.75
4
2.5

Classes

Class Line # Actions
SingleXWikiExecutor 33 15 0% 10 2
0.931034593.1%
 

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.escaping.framework;
21   
22    import org.apache.commons.configuration.PropertiesConfiguration;
23    import org.xwiki.test.integration.XWikiExecutor;
24   
25    /**
26    * Starts and stops exactly one XWiki instance. The methods {@link #start()} and {@link #stop()}
27    * allow to call them multiple times, starting and stopping the server only on the first and
28    * last call respectively.
29    *
30    * @version $Id: 25c333b03ccc056800f71070ee7cdbcf06b20482 $
31    * @since 2.5M1
32    */
 
33    public final class SingleXWikiExecutor extends XWikiExecutor
34    {
35    /** Singleton instance. */
36    private static SingleXWikiExecutor executor = null;
37   
38    /** Call counter. */
39    private static int counter = 0;
40   
41    /**
42    * Create new SingleXWikiExecutor.
43    */
 
44  1 toggle private SingleXWikiExecutor()
45    {
46  1 super(0);
47    }
48   
49    /**
50    * Get the executor instance.
51    *
52    * @return XWiki server executor
53    */
 
54  1912 toggle public static synchronized SingleXWikiExecutor getExecutor()
55    {
56  1912 if (SingleXWikiExecutor.executor == null) {
57  1 SingleXWikiExecutor.executor = new SingleXWikiExecutor();
58    }
59  1912 return SingleXWikiExecutor.executor;
60    }
61   
62    /**
63    * {@inheritDoc}
64    *
65    * Starts the server on the first call, subsequent calls only increase the internal counter by one.
66    */
 
67  956 toggle @Override
68    public synchronized void start() throws Exception
69    {
70  956 if (counter == 0) {
71  1 if (!VERIFY_RUNNING_XWIKI_AT_START.equals("true") || isXWikiStarted(getURL(), 15).timedOut) {
72    // Disable extensions manager external repositories
73  1 PropertiesConfiguration properties = loadXWikiPropertiesConfiguration();
74  1 if (!properties.containsKey("extension.repositories")) {
75  1 properties.setProperty("extension.repositories", "");
76    }
77  1 saveXWikiProperties(properties);
78    }
79   
80  1 super.start();
81    }
82  956 counter++;
83    }
84   
85    /**
86    * {@inheritDoc}
87    *
88    * Decreases the internal counter, stops the server when it reaches 0.
89    */
 
90  956 toggle @Override
91    public synchronized void stop() throws Exception
92    {
93  956 if (counter == 1) {
94  1 super.stop();
95    }
96  956 counter--;
97    }
98    }