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

File SolrTestUtils.java

 

Coverage histogram

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

Code metrics

4
9
4
1
79
39
6
0.67
2.25
4
1.5

Classes

Class Line # Actions
SolrTestUtils 32 9 0% 6 0
1.0100%
 

Contributing tests

This file is covered by 5 tests. .

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.repository.test;
21   
22    import java.util.HashMap;
23    import java.util.Map;
24   
25    import org.xwiki.model.reference.LocalDocumentReference;
26    import org.xwiki.test.ui.TestUtils;
27   
28    /**
29    * @version $Id: 6baf7cca8fe9f05387143b053ce0543563d60d8b $
30    * @since 7.0RC1
31    */
 
32    public class SolrTestUtils
33    {
34    public static final String PROPERTY_KEY = "solrutils";
35   
36    private static final String SOLRSERVICE_SPACE = "TestService";
37   
38    private static final String SOLRSERVICE_PAGE = "Solr";
39   
40    private static final LocalDocumentReference SOLRSERVICE_REFERENCE =
41    new LocalDocumentReference(SOLRSERVICE_SPACE, SOLRSERVICE_PAGE);
42   
43    private final TestUtils testUtils;
44   
 
45  75 toggle public SolrTestUtils(TestUtils testUtils) throws Exception
46    {
47  75 this.testUtils = testUtils;
48   
49  75 initService();
50    }
51   
 
52  75 toggle private void initService() throws Exception
53    {
54  75 if (!this.testUtils.pageExists(SOLRSERVICE_SPACE, SOLRSERVICE_PAGE)) {
55    // Create the utility page.
56  4 this.testUtils.rest().savePage(SOLRSERVICE_REFERENCE, "{{velocity}}$services.solr.queueSize{{/velocity}}",
57    null);
58    }
59    }
60   
61    /**
62    * Wait until the Solr does not have anything left to index.
63    */
 
64  21 toggle public void waitEmpyQueue() throws Exception
65    {
66  11029 while (getSolrQueueSize() > 0) {
67  11008 Thread.sleep(100);
68    }
69    }
70   
 
71  11029 toggle public long getSolrQueueSize() throws Exception
72    {
73  11029 Map<String, String> parameters = new HashMap<String, String>();
74  11029 parameters.put("outputSyntax", "plain");
75   
76  11029 return Long
77    .valueOf(this.testUtils.getString("/bin/get/" + SOLRSERVICE_SPACE + '/' + SOLRSERVICE_PAGE, parameters));
78    }
79    }