title: How to access application.property variable value into test class
body: <p>I am using spring data jpa for creating microservices. I am trying to write test cases for controller. Now In controller url I am accessing <code>InstituteIdentifier</code> variable value from <code>application.property</code> file. In AccountController class I am getting InstituteIdentifier variable value in url</p>
  
  <p>But I am not able to access that <code>InstituteIdentifier</code> variable value in test class url. I tried using <code>$ InstituteIdentifier</code> in test case url but value is not injecting and I am getting 404 test case failure error.</p>
  
  <p>Instead of accessing variable in url if I am hard coding InstituteIdentifier value then test case running without any error. But I don't want to hard code.</p>
  
  <p><code>application.property</code> file I am having in <code>src/main</code> directory. Can any one tell me how to access that application.property file variable in test class? or I need to create separate property file for test also.</p>
  
  <p><strong>AccountController</strong></p>
  
  <pre><code>@RestController
  @CrossOrigin(origins = "${crossOrigin}")
  @RequestMapping("/spacestudy/${InstituteIdentifier}/admin/account")
  public class AccountController {
  
      @Autowired
      AccountService accService;
  
  
      @GetMapping("/loadAcctLocationList")
      public ResponseEntity&lt;List&lt;Account&gt;&gt; findLocation() throws Exception{
  
          return  ResponseEntity.ok(accService.findLocation());
  
      }
  </code></pre>
  
  <p><strong>TestAccountController</strong></p>
  
  <pre><code>@RunWith(SpringRunner.class)
  @WebMvcTest(value=AccountController.class)
  public class TestAccountController {
  
      @Autowired
      private MockMvc mockMvc;
  
      @MockBean
      private AccountService accountService;
  
          @Test
          public void findLocationTest() throws Exception {
  
              Account account = new Account();
              account.setsLocation("Test1");
  
              List&lt;Account&gt; accountObj = new ArrayList&lt;Account&gt;();
              accountObj.add(account);    
  
              Mockito.when(accountService.findLocation()).thenReturn(accountObj);
  
              mockMvc.perform(get("/spacestudy/$ InstituteIdentifier/admin/account/loadAcctLocationList"))
                      .andExpect(status().isOk())
                      .andExpect(jsonPath("$[0].sLocation", is("Test1")))
                      .andExpect(jsonPath("$.*",Matchers.hasSize(1)));    
  
              for(Account result: accountObj) {
  
                  assertEquals("Test1", result.sLocation);
  
              }
  
              }
  </code></pre>