title: test failed when i use @Value
body: <p>I have configured my server to support TLS and everything works fine and all test cases pass. But when i decide to take the value from my .yaml i used @Value and the server still works fine but the cases case has error like</p>
  <pre><code>Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ServerConfig': Unsatisfied dependency expressed through field 'securePort'; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert value of type 'java.lang.String' to required type 'java.lang.Integer'; nested exception is java.lang.NumberFormatException: For input string: &quot;${securePort}&quot;
  </code></pre>
  <p>Here is the config file:</p>
  <pre><code>@Configuration
  public class ServerConfig {
  
    @Value(&quot;${previousScheme}&quot;)
    private String previousScheme;
    @Value(&quot;${securePort}&quot;)
    private Integer securePort;
    @Value(&quot;${previousPort}&quot;)
    private Integer previousPort;
    @Value(&quot;${setSecure}&quot;)
    private boolean setSecure;
  
    @Bean
    public ServletWebServerFactory servletContainer() {
      TomcatServletWebServerFactory tomcat =
          new TomcatServletWebServerFactory() {
            @Override
            protected void postProcessContext(Context context) {
              SecurityConstraint securityConstraint = new SecurityConstraint();
              securityConstraint.setUserConstraint(&quot;CONFIDENTIAL&quot;);
              SecurityCollection collection = new SecurityCollection();
              collection.addPattern(&quot;/*&quot;);
              securityConstraint.addCollection(collection);
              context.addConstraint(securityConstraint);
            }
          };
      tomcat.addAdditionalTomcatConnectors(getHttpConnector());
      return tomcat;
    }
  
    private Connector getHttpConnector() {
      Connector connector = new Connector(TomcatServletWebServerFactory.DEFAULT_PROTOCOL);
      connector.setScheme(previousScheme);
      connector.setPort(previousPort);
      connector.setSecure(setSecure);
      connector.setRedirectPort(securePort);
      return connector;
    }
  }
  </code></pre>
  <p>yaml:</p>
  <pre><code>server:
    ssl:
      key-store: classpath:keystore.p12
      key-store-password: password
      key-store-type: pkcs12
      key-alias: tomcat
      key-password: password
      protocol: TLS
      enabled: true
      enabled-protocols: TLSv1.2,TLSv1.3
  
    port: 8443
  
  previousPort: 8080
  setSecure: false
  previousScheme: &quot;http&quot;
  securePort: 8443
  </code></pre>
  <p>These two test works fine before i added @Value</p>
  <p>And the test:</p>
  <pre><code>@RunWith(SpringJUnit4ClassRunner.class)
  @ContextConfiguration(classes = ServerConfig.class)
  public class ServerConfigTest {
  
    @Autowired
    CapifServerConfig ServerConfig;
  
    @Test
    public void givenValidInitializationWhenServletContainerThenServletWebServerFactory() {
      assertNotNull(ServerConfig.servletContainer()); //error
    }
  
    @Test
    public void givenNullPortWhenServletContainerThenNull() {
      assertEquals(ServerConfig.servletContainer().getWebServer().getPort(), -1); //error
    }
  }
  </code></pre>