mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud)
75011: Merged WAT2 (5.0/Cloud) to HEAD-BUG-FIX (5.0/Cloud) 70370: Cleaned up the solr stats code, added security check and tenants git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@75339 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -95,5 +95,7 @@ public class AllUnitTestsSuite extends TestSuite
|
||||
suite.addTest(new JUnit4TestAdapter(org.alfresco.util.schemacomp.validator.SchemaVersionValidatorTest.class));
|
||||
suite.addTest(new JUnit4TestAdapter(org.alfresco.util.schemacomp.validator.TypeNameOnlyValidatorTest.class));
|
||||
suite.addTest(new JUnit4TestAdapter(org.alfresco.util.test.junitrules.TemporaryMockOverrideTest.class));
|
||||
suite.addTest(new JUnit4TestAdapter(org.alfresco.repo.search.impl.solr.SolrQueryHTTPClientTest.class));
|
||||
suite.addTest(new JUnit4TestAdapter(org.alfresco.repo.search.impl.solr.SolrStatsResultTest.class));
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package org.alfresco.repo.search.impl.solr;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.HashMap;
|
||||
@@ -11,6 +11,7 @@ import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.search.SearchParameters.SortDefinition;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.cmr.search.StatsParameters;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.junit.Before;
|
||||
@@ -21,6 +22,7 @@ import org.junit.Test;
|
||||
* Basic test of SolrQueryHTTPClient
|
||||
*
|
||||
* @author Gethin James
|
||||
* @since 5.0
|
||||
*/
|
||||
public class SolrQueryHTTPClientTest
|
||||
{
|
||||
@@ -49,6 +51,10 @@ public class SolrQueryHTTPClientTest
|
||||
StatsParameters params = getParameters();
|
||||
String url = client.buildStatsUrl(params, "http://localhost:8080/solr/alfresco/select", Locale.CANADA_FRENCH);
|
||||
assertNotNull(url);
|
||||
assertTrue(url.contains("locale=fr_CA"));
|
||||
assertTrue(url.contains("sort=contentsize"));
|
||||
assertTrue(url.contains("fq=ANCESTOR"));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -58,6 +64,13 @@ public class SolrQueryHTTPClientTest
|
||||
StatsParameters params = getParameters();
|
||||
JSONObject body = client.buildStatsBody(params, "myTenant", Locale.US);
|
||||
assertNotNull(body);
|
||||
JSONArray tenant = body.getJSONArray("tenants");
|
||||
assertEquals("myTenant",tenant.get(0).toString());
|
||||
JSONArray locale = body.getJSONArray("locales");
|
||||
assertEquals("en_US",locale.get(0).toString());
|
||||
String query = body.getString("query");
|
||||
assertTrue(query.contains("TYPE:"));
|
||||
assertTrue(query.contains("{http://www.alfresco.org/model/content/1.0}content"));
|
||||
}
|
||||
|
||||
private StatsParameters getParameters() {
|
||||
|
@@ -1,3 +1,21 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.search.impl.solr;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
@@ -9,6 +27,12 @@ import org.json.JSONTokener;
|
||||
import org.junit.Test;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* The results of executing a solr stats query, parsing the json
|
||||
*
|
||||
* @author Gethin James
|
||||
* @since 5.0
|
||||
*/
|
||||
public class SolrStatsResultTest
|
||||
{
|
||||
|
||||
|
Reference in New Issue
Block a user