DATACMNS-432 - Make Repositories effectively immutable.
We now eagerly populate the repository factory information in Repositories to provide a read only view on the discovered repository information. Previously lookup operations could also change some maps that held information about the until then discovered repository meta data which could lead to ConcurrentModifcationExceptions in multi-threaded environments. Since we don't allow any modification after construction this won't happen anymore. We also cache the computed RepositoryMetadata in RepositoryFactoryBeanSupport. Original pull request: #63.
This commit is contained in:
committed by
Oliver Gierke
parent
d381b694fe
commit
899cf25330
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013 the original author or authors.
|
||||
* Copyright 2013-2014 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.
|
||||
@@ -22,12 +22,14 @@ import static org.mockito.Mockito.*;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link RepositoryFactoryBeanSupport}.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Thomas Darimont
|
||||
*/
|
||||
public class RepositoryFactoryBeanSupportUnitTests {
|
||||
|
||||
@@ -37,7 +39,7 @@ public class RepositoryFactoryBeanSupportUnitTests {
|
||||
* @see DATACMNS-341
|
||||
*/
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public void setsConfiguredClassLoaderOnRepositoryFactory() {
|
||||
|
||||
ClassLoader classLoader = mock(ClassLoader.class);
|
||||
@@ -45,12 +47,16 @@ public class RepositoryFactoryBeanSupportUnitTests {
|
||||
RepositoryFactoryBeanSupport factoryBean = new DummyRepositoryFactoryBean();
|
||||
factoryBean.setBeanClassLoader(classLoader);
|
||||
factoryBean.setLazyInit(true);
|
||||
factoryBean.setRepositoryInterface(CrudRepository.class);
|
||||
factoryBean.afterPropertiesSet();
|
||||
|
||||
Object factory = ReflectionTestUtils.getField(factoryBean, "factory");
|
||||
assertThat(ReflectionTestUtils.getField(factory, "classLoader"), is((Object) classLoader));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATACMNS-432
|
||||
*/
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void initializationFailsWithMissingRepositoryInterface() {
|
||||
|
||||
Reference in New Issue
Block a user