Search in sources :

Example 1 with ByteArrayOutputStream

use of org.apache.tomcat.util.http.fileupload.ByteArrayOutputStream in project tomcat by apache.

the class TestSSLHostConfigIntegration method testSslHostConfigIsSerializable.

@Test
public void testSslHostConfigIsSerializable() throws Exception {
    TesterSupport.configureClientSsl();
    Tomcat tomcat = getTomcatInstance();
    File appDir = new File(getBuildDirectory(), "webapps/examples");
    org.apache.catalina.Context ctxt = tomcat.addWebapp(null, "/examples", appDir.getAbsolutePath());
    ctxt.addApplicationListener(WsContextListener.class.getName());
    TesterSupport.initSsl(tomcat);
    tomcat.start();
    SSLHostConfig[] sslHostConfigs = tomcat.getConnector().getProtocolHandler().findSslHostConfigs();
    boolean written = false;
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try (ObjectOutputStream oos = new ObjectOutputStream(baos)) {
        for (SSLHostConfig sslHostConfig : sslHostConfigs) {
            oos.writeObject(sslHostConfig);
            written = true;
        }
    }
    Assert.assertTrue(written);
}
Also used : Tomcat(org.apache.catalina.startup.Tomcat) WsContextListener(org.apache.tomcat.websocket.server.WsContextListener) ByteArrayOutputStream(org.apache.tomcat.util.http.fileupload.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) File(java.io.File) TomcatBaseTest(org.apache.catalina.startup.TomcatBaseTest) Test(org.junit.Test)

Aggregations

File (java.io.File)1 ObjectOutputStream (java.io.ObjectOutputStream)1 Tomcat (org.apache.catalina.startup.Tomcat)1 TomcatBaseTest (org.apache.catalina.startup.TomcatBaseTest)1 ByteArrayOutputStream (org.apache.tomcat.util.http.fileupload.ByteArrayOutputStream)1 WsContextListener (org.apache.tomcat.websocket.server.WsContextListener)1 Test (org.junit.Test)1