Example usage for org.springframework.boot.web.server Ssl setEnabled

List of usage examples for org.springframework.boot.web.server Ssl setEnabled

Introduction

In this page you can find the example usage for org.springframework.boot.web.server Ssl setEnabled.

Prototype

public void setEnabled(boolean enabled) 

Source Link

Usage

From source file:org.springframework.boot.web.servlet.server.AbstractServletWebServerFactoryTests.java

@Test
public void sslDisabled() throws Exception {
    AbstractServletWebServerFactory factory = getFactory();
    Ssl ssl = getSsl(null, "password", "classpath:test.jks");
    ssl.setEnabled(false);
    factory.setSsl(ssl);// w w  w.ja  v a2  s  .  com
    this.webServer = factory
            .getWebServer(new ServletRegistrationBean<>(new ExampleServlet(true, false), "/hello"));
    this.webServer.start();
    SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
            new SSLContextBuilder().loadTrustMaterial(null, new TrustSelfSignedStrategy()).build());
    HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory).build();
    HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(
            httpClient);
    this.thrown.expect(SSLException.class);
    getResponse(getLocalUrl("https", "/hello"), requestFactory);
}