Browse Source
Added the necessary configuration infrastructure to automatically register the GeoJsonModule as Spring bean when @EnableSpringDataWebSupport is used. This is implemented by exposing a configuration class annotated with @SpringDataWebConfigurationMixin. Added Spring WebMVC as test dependency to be able to write an integration test. Polished GeoJsonModule to hide the actual serializers. Original pull request: #283. Related ticket: DATACMNS-660.pull/282/merge
4 changed files with 112 additions and 13 deletions
@ -0,0 +1,34 @@ |
|||||||
|
/* |
||||||
|
* Copyright 2015 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 |
||||||
|
* |
||||||
|
* 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.springframework.data.mongodb.core; |
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean; |
||||||
|
import org.springframework.data.mongodb.core.geo.GeoJsonModule; |
||||||
|
import org.springframework.data.web.config.SpringDataWebConfigurationMixin; |
||||||
|
|
||||||
|
/** |
||||||
|
* Configuration class to expose {@link GeoJsonModule} as a Spring bean. |
||||||
|
* |
||||||
|
* @author Oliver Gierke |
||||||
|
*/ |
||||||
|
@SpringDataWebConfigurationMixin |
||||||
|
public class GeoJsonConfiguration { |
||||||
|
|
||||||
|
@Bean |
||||||
|
public GeoJsonModule geoJsonModule() { |
||||||
|
return new GeoJsonModule(); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,53 @@ |
|||||||
|
/* |
||||||
|
* Copyright 2015 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 |
||||||
|
* |
||||||
|
* 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.springframework.data.mongodb.config; |
||||||
|
|
||||||
|
import static org.hamcrest.CoreMatchers.*; |
||||||
|
import static org.junit.Assert.*; |
||||||
|
|
||||||
|
import org.junit.Test; |
||||||
|
import org.junit.runner.RunWith; |
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.context.annotation.Configuration; |
||||||
|
import org.springframework.data.mongodb.core.GeoJsonConfiguration; |
||||||
|
import org.springframework.data.mongodb.core.geo.GeoJsonModule; |
||||||
|
import org.springframework.data.web.config.EnableSpringDataWebSupport; |
||||||
|
import org.springframework.test.context.ContextConfiguration; |
||||||
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; |
||||||
|
|
||||||
|
/** |
||||||
|
* Integration tests for {@link GeoJsonConfiguration}. |
||||||
|
* |
||||||
|
* @author Oliver Gierke |
||||||
|
*/ |
||||||
|
@RunWith(SpringJUnit4ClassRunner.class) |
||||||
|
@ContextConfiguration |
||||||
|
public class GeoJsonConfigurationIntegrationTests { |
||||||
|
|
||||||
|
@Configuration |
||||||
|
@EnableSpringDataWebSupport |
||||||
|
static class Config {} |
||||||
|
|
||||||
|
@Autowired GeoJsonModule geoJsonModule; |
||||||
|
|
||||||
|
/** |
||||||
|
* @see DATAMONGO-1181 |
||||||
|
*/ |
||||||
|
@Test |
||||||
|
public void picksUpGeoJsonModuleConfigurationByDefault() { |
||||||
|
assertThat(geoJsonModule, is(notNullValue())); |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue