28 lines
852 B
Java
28 lines
852 B
Java
|
package com.baeldung.autowired;
|
||
|
|
||
|
import static org.junit.Assert.assertEquals;
|
||
|
import static org.junit.Assert.assertNotNull;
|
||
|
|
||
|
import org.junit.Test;
|
||
|
import org.junit.runner.RunWith;
|
||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||
|
import org.springframework.test.context.ContextConfiguration;
|
||
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||
|
|
||
|
import com.baeldung.dependency.ArbitraryDependency;
|
||
|
|
||
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||
|
@ContextConfiguration(locations={
|
||
|
"/applicationContextTest-@Autowired-Type.xml"})
|
||
|
public class FieldAutowiredDemo {
|
||
|
|
||
|
@Autowired
|
||
|
private ArbitraryDependency fieldDependency;
|
||
|
|
||
|
@Test
|
||
|
public void fieldDependency_MUST_BE_AUTOWIRED_Correctly() {
|
||
|
assertNotNull(fieldDependency);
|
||
|
assertEquals("Arbitrary Dependency", fieldDependency.toString());
|
||
|
}
|
||
|
}
|