I have this test:
@RunWith(MockitoJUnitRunner.class)
public class CollectionManagerTest {
@InjectMocks
private CollectionManager collectionManager;
@Mock
RestTemplate restTemplate;
@Captor
private ResponseEntity<String> responseEntity;
/**
*
*/
@Before
public void setup() {
org.springframework.test.util.ReflectionTestUtils.setField(collectionManager, "myUrl", "http://test");
responseEntity = new ResponseEntity<>("SUCCESS", HttpStatus.OK);
}
@Test
public void createMyStringTest() throws Exception {
String myString = collectionManager.createMyString("TestDocIsns");
assertTrue(myString.contains("DOC_ISN=TestDocIsns"));
}
}
It fails with this error:
ReflectionTestUtils - Setting field 'myUrl' of type [null] on target object [org.me.services.docs.CollectionManager@2dc9b0f5] or target class [class org.me.docs.CollectionManager] to value [http://test]
I thought this would have been set with org.springframework.test.util.ReflectionTestUtils.setField(collectionManager, "myUrl", "http://test");
This is the variable in the actual class:
@Value("${my.url}")
private String myUrl;
What am I doing wrong?
Aucun commentaire:
Enregistrer un commentaire