diff --git a/spring-data-commons-core/src/test/java/org/springframework/data/repository/config/RepositoryComponentProviderUnitTests.java b/spring-data-commons-core/src/test/java/org/springframework/data/repository/config/RepositoryComponentProviderUnitTests.java new file mode 100644 index 000000000..4af944765 --- /dev/null +++ b/spring-data-commons-core/src/test/java/org/springframework/data/repository/config/RepositoryComponentProviderUnitTests.java @@ -0,0 +1,45 @@ +/* + * Copyright 2011 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.repository.config; + +import static org.hamcrest.Matchers.*; +import static org.junit.Assert.*; + +import java.util.Set; + +import org.junit.Test; +import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.data.repository.Repository; +import org.springframework.data.repository.config.AbstractRepositoryConfigDefinitionParser.RepositoryComponentProvider; +import org.springframework.data.repository.sample.SampleAnnotatedRepository; + +/** + * Unit tests for {@link RepositoryComponentProvider}. + * + * @author Oliver Gierke + */ +public class RepositoryComponentProviderUnitTests { + + @Test + public void findsAnnotatedRepositoryInterface() { + + RepositoryComponentProvider provider = new RepositoryComponentProvider(Repository.class); + Set components = provider.findCandidateComponents("org.springframework.data.repository.sample"); + + assertThat(components.size(), is(1)); + assertThat(components.iterator().next().getBeanClassName(), is(SampleAnnotatedRepository.class.getName())); + } +} diff --git a/spring-data-commons-core/src/test/java/org/springframework/data/repository/sample/SampleAnnotatedRepository.java b/spring-data-commons-core/src/test/java/org/springframework/data/repository/sample/SampleAnnotatedRepository.java new file mode 100644 index 000000000..ee3bb0a46 --- /dev/null +++ b/spring-data-commons-core/src/test/java/org/springframework/data/repository/sample/SampleAnnotatedRepository.java @@ -0,0 +1,30 @@ +/* + * Copyright 2011 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.repository.sample; + +import java.io.Serializable; + +import org.springframework.data.repository.RepositoryProxy; + +/** + * Sample interface for annotation based repository declaration. + * + * @author Oliver Gierke + */ +@RepositoryProxy(domainClass = Object.class, idClass = Serializable.class) +public interface SampleAnnotatedRepository { + +}