DATACMNS-37 - Added unit tests for annotation based repository usage.

This commit is contained in:
Oliver Gierke
2011-05-17 20:14:47 +01:00
parent 1761255c2d
commit 66c77820c4
2 changed files with 75 additions and 0 deletions

View File

@@ -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<BeanDefinition> components = provider.findCandidateComponents("org.springframework.data.repository.sample");
assertThat(components.size(), is(1));
assertThat(components.iterator().next().getBeanClassName(), is(SampleAnnotatedRepository.class.getName()));
}
}

View File

@@ -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 {
}