DATAREST-1587 - Remove Solr integration tests.
This commit is contained in:
@@ -20,7 +20,6 @@
|
||||
<module>spring-data-rest-tests-mongodb</module>
|
||||
<module>spring-data-rest-tests-security</module>
|
||||
<module>spring-data-rest-tests-shop</module>
|
||||
<module>spring-data-rest-tests-solr</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-rest-tests</artifactId>
|
||||
<version>3.3.7.BUILD-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<name>Spring Data REST Tests - Solr</name>
|
||||
<artifactId>spring-data-rest-tests-solr</artifactId>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-rest-tests-core</artifactId>
|
||||
<version>3.3.7.BUILD-SNAPSHOT</version>
|
||||
<type>test-jar</type>
|
||||
</dependency>
|
||||
|
||||
<!-- Solr -->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-solr</artifactId>
|
||||
<version>${springdata.solr}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.solr</groupId>
|
||||
<artifactId>solr-core</artifactId>
|
||||
<version>8.4.1</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>jdk.tools</artifactId>
|
||||
<groupId>jdk.tools</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.google</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.rest.webmvc.solr;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.solr.core.mapping.Indexed;
|
||||
import org.springframework.data.solr.core.mapping.SolrDocument;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* @author Christoph Strobl
|
||||
*/
|
||||
@SolrDocument(solrCoreName = "collection1")
|
||||
public class Product {
|
||||
|
||||
private @Id String id;
|
||||
private @Indexed String name;
|
||||
private @Indexed(name = "cat") List<String> categories;
|
||||
|
||||
public Product() {}
|
||||
|
||||
public Product(String id, String name, String... categories) {
|
||||
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.categories = ObjectUtils.isEmpty(categories) ? Collections.<String> emptyList() : Arrays.asList(categories);
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<String> getCategories() {
|
||||
return categories;
|
||||
}
|
||||
|
||||
public void setCategories(List<String> categories) {
|
||||
this.categories = categories;
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.rest.webmvc.solr;
|
||||
|
||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||
|
||||
/**
|
||||
* @author Christoph Strobl
|
||||
*/
|
||||
public interface ProductRepository extends PagingAndSortingRepository<Product, String> {}
|
||||
@@ -1,173 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.rest.webmvc.solr;
|
||||
|
||||
import static org.springframework.data.rest.webmvc.solr.TestUtils.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
|
||||
import org.apache.solr.core.CloseHook;
|
||||
import org.apache.solr.core.CoreDescriptor;
|
||||
import org.apache.solr.core.SolrCore;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.data.solr.core.SolrTemplate;
|
||||
import org.springframework.data.solr.server.SolrClientFactory;
|
||||
import org.springframework.data.solr.server.support.EmbeddedSolrServerFactory;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* @author Christoph Strobl
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@Configuration
|
||||
public class SolrInfrastructureConfig {
|
||||
|
||||
private static final String CORE_PROPERTIES = "name=collection1";
|
||||
private static final Resource MANAGED_SCHEMA = new ClassPathResource("managed-schema", SolrInfrastructureConfig.class);
|
||||
private static final Resource SOLR_CONFIG = new ClassPathResource("solrconfig.xml", SolrInfrastructureConfig.class);
|
||||
private static final Resource SOLR_SCHEMA = new ClassPathResource("schema.xml", SolrInfrastructureConfig.class);
|
||||
private static final Resource SOLR_XML = new ClassPathResource("solr.xml", SolrInfrastructureConfig.class);
|
||||
|
||||
@Bean
|
||||
public SolrClientFactory solrClientFactory(final String solrHomeDir)
|
||||
throws ParserConfigurationException, IOException, SAXException {
|
||||
|
||||
prepareConfiguration(solrHomeDir);
|
||||
return new EmbeddedSolrServerFactory(solrHomeDir);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SolrTemplate solrTemplate(SolrClientFactory factory) {
|
||||
|
||||
attachCloseHook(factory);
|
||||
return new SolrTemplate(factory);
|
||||
}
|
||||
|
||||
private static void prepareConfiguration(final String solrHomePath) throws IOException {
|
||||
|
||||
Map<String, String> configParams = new HashMap<String, String>();
|
||||
configParams.put("${data.dir}", solrHomePath);
|
||||
configParams.put("${lucene.version}", "5.3.1");
|
||||
|
||||
Resource solrConfig = filterResource(SOLR_CONFIG, configParams);
|
||||
Resource solrSchema = SOLR_SCHEMA;
|
||||
Resource solrXml = SOLR_XML;
|
||||
Resource solrManagedSchema = MANAGED_SCHEMA;
|
||||
|
||||
File solrHomeDir = new File(solrHomePath);
|
||||
File collectionDir = new File(solrHomeDir, "collection1");
|
||||
File confDir = new File(collectionDir, "conf");
|
||||
confDir.mkdirs();
|
||||
|
||||
FileCopyUtils.copy(solrXml.getInputStream(), new FileOutputStream(createFile(solrHomeDir, "solr.xml")));
|
||||
FileCopyUtils.copy(CORE_PROPERTIES.getBytes(), new FileOutputStream(createFile(collectionDir, "core.properties")));
|
||||
FileCopyUtils.copy(solrSchema.getInputStream(), new FileOutputStream(createFile(confDir, "schema.xml")));
|
||||
FileCopyUtils.copy(solrManagedSchema.getInputStream(), new FileOutputStream(createFile(confDir, "managed-schema")));
|
||||
FileCopyUtils.copy(solrConfig.getInputStream(), new FileOutputStream(createFile(confDir, "solrconfig.xml")));
|
||||
}
|
||||
|
||||
private static File createFile(File parent, String child) throws IOException {
|
||||
|
||||
File file = new File(parent, child);
|
||||
if (!file.exists()) {
|
||||
file.createNewFile();
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link SpringRunner} executes {@link ClassRule}s before the actual shutdown of the {@link ApplicationContext}. This
|
||||
* causes the {@link TemporaryFolder} to vanish before Solr can gracefully shutdown. <br />
|
||||
* To prevent error messages popping up we register a {@link CloseHook} re adding the index directory and removing it
|
||||
* after {@link SolrCore#close()}.
|
||||
*
|
||||
* @param factory
|
||||
*/
|
||||
private void attachCloseHook(SolrClientFactory factory) {
|
||||
|
||||
EmbeddedSolrServer server = (EmbeddedSolrServer) factory.getSolrClient();
|
||||
|
||||
for (SolrCore core : server.getCoreContainer().getCores()) {
|
||||
|
||||
core.addCloseHook(new CloseHook() {
|
||||
|
||||
private String path;
|
||||
|
||||
@Override
|
||||
public void preClose(SolrCore core) {
|
||||
|
||||
CoreDescriptor cd = core.getCoreDescriptor();
|
||||
|
||||
if (cd == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
File tmp = new File(core.getIndexDir()).getParentFile();
|
||||
|
||||
if (tmp.exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
File indexFile = new File(tmp, "index");
|
||||
indexFile.mkdirs();
|
||||
|
||||
this.path = indexFile.getPath();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postClose(SolrCore core) {
|
||||
|
||||
if (!StringUtils.hasText(this.path)) {
|
||||
return;
|
||||
}
|
||||
|
||||
File tmp = new File(this.path);
|
||||
|
||||
if (tmp.exists() && tmp.getPath().startsWith(FileUtils.getTempDirectoryPath())) {
|
||||
|
||||
try {
|
||||
FileUtils.deleteDirectory(tmp);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.rest.webmvc.solr;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.data.solr.repository.config.EnableSolrRepositories;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
/**
|
||||
* @author Christoph Strobl
|
||||
*/
|
||||
@ContextConfiguration
|
||||
public class SolrTestBase {
|
||||
|
||||
public static @ClassRule TemporaryFolder TEMP_FOLDER = new TemporaryFolder();
|
||||
|
||||
@Configuration
|
||||
@EnableSolrRepositories
|
||||
@Import(SolrInfrastructureConfig.class)
|
||||
static class MyConf {
|
||||
|
||||
@Bean
|
||||
String solrHomeDir() {
|
||||
return TEMP_FOLDER.getRoot().getAbsolutePath();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,144 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.rest.webmvc.solr;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.data.rest.tests.CommonWebTests;
|
||||
import org.springframework.data.solr.repository.config.EnableSolrRepositories;
|
||||
import org.springframework.hateoas.IanaLinkRelations;
|
||||
import org.springframework.hateoas.Link;
|
||||
import org.springframework.hateoas.LinkRelation;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.mock.web.MockHttpServletResponse;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
/**
|
||||
* @author Christoph Strobl
|
||||
*/
|
||||
@ContextConfiguration(classes = { SolrWebTests.MyConf.class })
|
||||
public class SolrWebTests extends CommonWebTests {
|
||||
|
||||
public static @ClassRule TemporaryFolder TEMP_FOLDER = new TemporaryFolder();
|
||||
|
||||
private static final Product PLAYSTATION = new Product("1", "playstation", "electronic", "game", "media");
|
||||
private static final Product GAMEBOY = new Product("2", "gameboy", "electronic");
|
||||
private static final Product AMIGA500 = new Product("3", "amiga500", "ancient");
|
||||
|
||||
private static final ObjectMapper MAPPER = new ObjectMapper();
|
||||
|
||||
@Configuration
|
||||
@EnableSolrRepositories
|
||||
@Import(value = { SolrInfrastructureConfig.class })
|
||||
static class MyConf {
|
||||
|
||||
@Bean
|
||||
String solrHomeDir() {
|
||||
return TEMP_FOLDER.getRoot().getAbsolutePath();
|
||||
}
|
||||
}
|
||||
|
||||
@Autowired ProductRepository repo;
|
||||
|
||||
@Override
|
||||
@Before
|
||||
public void setUp() {
|
||||
|
||||
super.setUp();
|
||||
repo.saveAll(Arrays.asList(PLAYSTATION, GAMEBOY, AMIGA500));
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
repo.deleteAll();
|
||||
}
|
||||
|
||||
@Test // DATAREST-387
|
||||
public void allowsPaginationThroughData() throws Exception {
|
||||
|
||||
MockHttpServletResponse response = client.request("/products?page=0&size=1");
|
||||
|
||||
Link nextLink = client.assertHasLinkWithRel(IanaLinkRelations.NEXT, response);
|
||||
assertDoesNotHaveLinkWithRel(IanaLinkRelations.PREV, response);
|
||||
|
||||
response = client.request(nextLink);
|
||||
client.assertHasLinkWithRel(IanaLinkRelations.PREV, response);
|
||||
nextLink = client.assertHasLinkWithRel(IanaLinkRelations.NEXT, response);
|
||||
|
||||
response = client.request(nextLink);
|
||||
client.assertHasLinkWithRel(IanaLinkRelations.PREV, response);
|
||||
assertDoesNotHaveLinkWithRel(IanaLinkRelations.NEXT, response);
|
||||
}
|
||||
|
||||
@Test // DATAREST-387
|
||||
public void allowsRetrievingDataById() throws Exception {
|
||||
requestAndCompare(PLAYSTATION);
|
||||
}
|
||||
|
||||
@Test // DATAREST-387
|
||||
public void createsEntitesCorrectly() throws Exception {
|
||||
|
||||
Product product = new Product("4", "iWatch", "trends", "scary");
|
||||
|
||||
mvc.perform(
|
||||
put("/products/{id}", 4).content(MAPPER.writeValueAsString(product)).contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isCreated()).andReturn().getResponse();
|
||||
|
||||
assertJsonDocumentMatches(product);
|
||||
}
|
||||
|
||||
@Test // DATAREST-387
|
||||
public void deletesEntitiesCorrectly() throws Exception {
|
||||
deleteAndVerify(new Link("/products/1"));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.rest.webmvc.AbstractWebIntegrationTests#expectedRootLinkRels()
|
||||
*/
|
||||
@Override
|
||||
protected Iterable<LinkRelation> expectedRootLinkRels() {
|
||||
return LinkRelation.manyOf("products");
|
||||
}
|
||||
|
||||
private void assertJsonDocumentMatches(Product reference) throws Exception {
|
||||
requestAndCompare(reference);
|
||||
}
|
||||
|
||||
private MockHttpServletResponse requestAndCompare(Product reference) throws Exception {
|
||||
|
||||
MockHttpServletResponse response = client.request("/products/" + reference.getId());
|
||||
|
||||
assertJsonPathEquals("name", reference.getName(), response);
|
||||
assertJsonPathEquals("categories", MAPPER.writeValueAsString(reference.getCategories()), response);
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.rest.webmvc.solr;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.core.io.ByteArrayResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StreamUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Test helper methods.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Christoph Strobl
|
||||
*/
|
||||
class TestUtils {
|
||||
|
||||
private static final Charset UTF8 = Charset.forName("UTF-8");
|
||||
|
||||
/**
|
||||
* Filters the given {@link Resource} by replacing values within.
|
||||
*
|
||||
* @param source must not be {@literal null}.
|
||||
* @param replacements
|
||||
* @return {@link Resource} with replaced values.
|
||||
* @throws IOException
|
||||
*/
|
||||
public static Resource filterResource(Resource source, Map<String, ?> replacements) throws IOException {
|
||||
|
||||
Assert.notNull(source, "Cannot filter 'null' resource");
|
||||
if (CollectionUtils.isEmpty(replacements)) {
|
||||
return source;
|
||||
}
|
||||
|
||||
String temp = StreamUtils.copyToString(source.getInputStream(), UTF8);
|
||||
|
||||
for (Map.Entry<String, ?> entry : replacements.entrySet()) {
|
||||
temp = StringUtils.replace(temp, entry.getKey(), entry.getValue() != null ? entry.getValue().toString() : "");
|
||||
}
|
||||
|
||||
return new ByteArrayResource(temp.getBytes(UTF8));
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<schema name="minimal" version="1.1">
|
||||
<types>
|
||||
<fieldType name="string" class="solr.StrField" />
|
||||
</types>
|
||||
<fields>
|
||||
<field name="id" type="string" indexed="true" stored="true" required="true" />
|
||||
<field name="name" type="string" indexed="true" stored="true" />
|
||||
<field name="cat" type="string" indexed="true" stored="true" multiValued="true" />
|
||||
</fields>
|
||||
<uniqueKey>id</uniqueKey>
|
||||
</schema>
|
||||
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<schema name="minimal" version="1.1">
|
||||
<types>
|
||||
<fieldType name="string" class="solr.StrField" />
|
||||
</types>
|
||||
<fields>
|
||||
<field name="id" type="string" indexed="true" stored="true" required="true" />
|
||||
<field name="name" type="string" indexed="true" stored="true" />
|
||||
<field name="cat" type="string" indexed="true" stored="true" multiValued="true" />
|
||||
</fields>
|
||||
<uniqueKey>id</uniqueKey>
|
||||
</schema>
|
||||
@@ -1,16 +0,0 @@
|
||||
<solr>
|
||||
|
||||
<solrcloud>
|
||||
<str name="host">${host:}</str>
|
||||
<int name="hostPort">${jetty.port:8983}</int>
|
||||
<str name="hostContext">${hostContext:solr}</str>
|
||||
<int name="zkClientTimeout">${zkClientTimeout:15000}</int>
|
||||
<bool name="genericCoreNodeNames">${genericCoreNodeNames:true}</bool>
|
||||
</solrcloud>
|
||||
|
||||
<shardHandlerFactory name="shardHandlerFactory" class="HttpShardHandlerFactory">
|
||||
<int name="socketTimeout">${socketTimeout:0}</int>
|
||||
<int name="connTimeout">${connTimeout:0}</int>
|
||||
</shardHandlerFactory>
|
||||
|
||||
</solr>
|
||||
@@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<config>
|
||||
<dataDir>${data.dir}</dataDir>
|
||||
<directoryFactory name="DirectoryFactory"
|
||||
class="solr.NRTCachingDirectoryFactory" />
|
||||
<luceneMatchVersion>${lucene.version}</luceneMatchVersion>
|
||||
<updateHandler class="solr.DirectUpdateHandler2">
|
||||
<commitWithin>
|
||||
<softCommit>${solr.commitwithin.softcommit:true}</softCommit>
|
||||
</commitWithin>
|
||||
</updateHandler>
|
||||
<requestHandler name="/select" class="solr.SearchHandler">
|
||||
<lst name="defaults">
|
||||
<str name="echoParams">explicit</str>
|
||||
<str name="indent">true</str>
|
||||
<str name="df">text</str>
|
||||
</lst>
|
||||
</requestHandler>
|
||||
<requestHandler name="/update" class="solr.UpdateRequestHandler" />
|
||||
</config>
|
||||
Reference in New Issue
Block a user