Create CircularDependencyTest
This commit is contained in:
parent
170a45a314
commit
4e7a47de12
|
@ -0,0 +1,35 @@
|
|||
package com.baeldung.circulardependency;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = { TestConfig.class })
|
||||
public class CircularDependencyTest {
|
||||
|
||||
@Autowired
|
||||
ApplicationContext context;
|
||||
|
||||
@Bean
|
||||
public CircularDependencyA getCircularDependencyA() {
|
||||
return new CircularDependencyA();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CircularDependencyB getCircularDependencyB() {
|
||||
return new CircularDependencyB();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenCircularDependency_whenSetterInjection_thenItWorks() {
|
||||
final CircularDependencyA circA = context.getBean(CircularDependencyA.class);
|
||||
|
||||
Assert.assertEquals("Hi!", circA.getCircB().getMessage());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue