Commit da7e44fa authored by Matija Obreza's avatar Matija Obreza

Sitemaps: Fixed text/xml and added `<lastmod>`

- Unit test /sitemap.xml and /sitemap-content.xml
parent dcb95384
......@@ -264,7 +264,7 @@ public class WebConfiguration implements WebMvcConfigurer {
public StringHttpMessageConverter stringConverter() {
final StringHttpMessageConverter stringConverter = new StringHttpMessageConverter(Charsets.UTF_8);
stringConverter.setSupportedMediaTypes(Arrays.asList(MediaType.TEXT_PLAIN, MediaType.TEXT_HTML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML));
stringConverter.setSupportedMediaTypes(Arrays.asList(MediaType.TEXT_PLAIN, MediaType.TEXT_HTML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML));
return stringConverter;
}
......
......@@ -13,6 +13,8 @@ import javax.validation.ValidatorFactory;
import org.genesys.blocks.util.CurrentApplicationContext;
import org.genesys2.server.component.security.AsAdminInvoker;
import org.genesys2.server.component.security.SecurityUtils;
import org.genesys2.server.mvc.JspHelper;
import org.genesys2.server.mvc.SitemapXMLController;
import org.genesys2.spring.CSVMessageConverter;
import org.genesys2.spring.config.AuditConfig;
import org.genesys2.spring.config.CacheConfig;
......@@ -223,6 +225,18 @@ public final class ApplicationConfig {
return new SameOriginCorsProcessor();
}
// Sitemaps
@Bean
public SitemapXMLController sitemapXmlController() {
return new SitemapXMLController();
}
@Bean
public JspHelper jspHelper() {
return new JspHelper();
}
// -- Sitemaps
/**
* This bean post-processor sets our {@link #corsProcessor()} on all
* AbstractHandlerMapping beans
......@@ -275,7 +289,7 @@ public final class ApplicationConfig {
public StringHttpMessageConverter stringConverter() {
final StringHttpMessageConverter stringConverter = new StringHttpMessageConverter(Charsets.UTF_8);
stringConverter.setSupportedMediaTypes(Arrays.asList(MediaType.TEXT_PLAIN, MediaType.TEXT_HTML, MediaType.APPLICATION_JSON));
stringConverter.setSupportedMediaTypes(Arrays.asList(MediaType.TEXT_PLAIN, MediaType.TEXT_HTML, MediaType.APPLICATION_JSON, MediaType.TEXT_XML));
return stringConverter;
}
......
/*
* Copyright 2019 Global Crop Diversity Trust
*
* 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
*
* http://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.genesys.test.server.api.v0;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
import org.genesys.test.base.AbstractApiTest;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.context.WebApplicationContext;
/**
* The Class SitemapXMLTest.
*/
public class SitemapXMLTest extends AbstractApiTest {
@Autowired
private WebApplicationContext webApplicationContext;
MockMvc mockMvc;
@Transactional
@Before
@Override
public void beforeTest() {
mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
}
@After
@Transactional
@Override
public void cleanup() throws Exception {
super.cleanup();
}
@Test
public void sitemapRoot() throws Exception {
mockMvc.perform(get("/sitemap.xml"))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.TEXT_XML_VALUE));
}
@Test
public void sitemapContent() throws Exception {
mockMvc.perform(get("/sitemap-content.xml"))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.TEXT_XML_VALUE));
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment