1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.test.cluster.framework

File AbstractClusterHttpTest.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart2.png
83% of files have more coverage

Code metrics

2
22
3
1
94
53
7
0.32
7.33
3
2.33

Classes

Class Line # Actions
AbstractClusterHttpTest 43 22 0% 7 22
0.1851851818.5%
 

Contributing tests

This file is covered by 1 test. .

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.cluster.framework;
21   
22    import java.io.File;
23    import java.io.IOException;
24    import java.net.Socket;
25    import java.util.ArrayList;
26    import java.util.Date;
27    import java.util.List;
28   
29    import org.hsqldb.Server;
30    import org.junit.BeforeClass;
31    import org.slf4j.Logger;
32    import org.slf4j.LoggerFactory;
33    import org.xwiki.extension.test.ExtensionTestUtils;
34    import org.xwiki.test.cluster.AllTests;
35    import org.xwiki.test.integration.XWikiExecutor;
36    import org.xwiki.test.ui.AbstractTest;
37   
38    /**
39    * Base class for REST based clustering integration test.
40    *
41    * @version $Id: cc4b9b481a6a3fe447897442a4e78b1f251b8ac4 $
42    */
 
43    public abstract class AbstractClusterHttpTest extends AbstractTest
44    {
45    protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractClusterHttpTest.class);
46   
 
47  3 toggle @BeforeClass
48    public static void init() throws Exception
49    {
50  3 if (context == null) {
51    // Start HSQLDB server if not already running
52  0 try (Socket ignored = new Socket("localhost", 9001)) {
53  0 LOGGER.info("HSQLDB server is already running");
54    } catch (IOException ignored) {
55  0 LOGGER.info("HSQLDB server is not running. Starting one...");
56   
57  0 Server server = new Server();
58   
59  0 server.setSilent(true);
60   
61  0 File testDirectory = new File("target/test-" + new Date().getTime()).getAbsoluteFile();
62  0 File databaseDirectory = new File(testDirectory, "database");
63  0 server.setDatabaseName(0, "xwiki_db");
64  0 server.setDatabasePath(0, databaseDirectory.toString());
65  0 server.setDaemon(true);
66  0 server.start();
67   
68  0 LOGGER.info("HSQLDB server started");
69    }
70   
71  0 List<XWikiExecutor> executors = new ArrayList<>(2);
72   
73  0 executors.add(createExecutor(0));
74  0 executors.add(createExecutor(1));
75   
76    // Require some AbstractTest initialization
77  0 AbstractTest.init(executors);
78    }
79    }
80   
 
81  0 toggle protected static XWikiExecutor createExecutor(int index)
82    {
83  0 XWikiExecutor executor = new XWikiExecutor(index);
84   
85  0 AllTests.setupExecutor(executor);
86   
87  0 return executor;
88    }
89   
 
90  7 toggle protected static ExtensionTestUtils getExtensionTestUtils()
91    {
92  7 return (ExtensionTestUtils) context.getProperties().get(ExtensionTestUtils.PROPERTY_KEY);
93    }
94    }