All Downloads are FREE. Search and download functionalities are using the official Maven repository.

test.junit.fedora.utilities.install.container.TestTomcatServerXML Maven / Gradle / Ivy

Go to download

The Fedora Client is a Java Library that allows API access to a Fedora Repository. The client is typically one part of a full Fedora installation.

The newest version!
/* The contents of this file are subject to the license and copyright terms
 * detailed in the license directory at the root of the source tree (also 
 * available online at http://www.fedora.info/license/).
 */
package fedora.utilities.install.container;


import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import fedora.utilities.install.InstallOptions;


/**
 *
 * @author Edwin Shin
 */
public class TestTomcatServerXML {
    private InputStream is;
    private InstallOptions installOptions;
    
    /** The default server.xml shipped with Tomcat 5.5.23 (stripped of comments) */
    private static byte[] defaultServerXML;
    
    static {
        StringBuilder sb = new StringBuilder();
        sb.append("");
        sb.append("  ");
        sb.append("  ");
        sb.append("  ");
        sb.append("  ");
        sb.append("  ");
        sb.append("    ");
        sb.append("    ");
        sb.append("  ");
        sb.append("  ");
        sb.append("    ");
        sb.append("    ");
        sb.append("    ");
        sb.append("      ");
        sb.append("      ");
        sb.append("      ");
        sb.append("    ");
        sb.append("  ");
        sb.append("");
        
        try {
            defaultServerXML = sb.toString().getBytes("UTF-8");
        } catch (UnsupportedEncodingException e) {
            // should never happen with UTF-8
        }
    }
    
    /**
     * @throws java.lang.Exception
     */
    @Before
    public void setUp() throws Exception {
        is = new ByteArrayInputStream(defaultServerXML);
        installOptions = getDefaultOptions();
    }

    /**
     * @throws java.lang.Exception
     */
    @After
    public void tearDown() throws Exception {
        if (is != null) {
            is.close();
        }
    }
    
    @Test
    public void testUpdate() throws Exception {
        TomcatServerXML serverXML;
        serverXML = new TomcatServerXML(is, installOptions);
        serverXML.update();
    }
    
    private InstallOptions getDefaultOptions() throws Exception {
        Map map = new HashMap();
        map.put(InstallOptions.TOMCAT_HTTP_PORT, "8080");
        map.put(InstallOptions.TOMCAT_SHUTDOWN_PORT, "8005");
        map.put(InstallOptions.SSL_AVAILABLE, "true");
        map.put(InstallOptions.TOMCAT_SSL_PORT, "8443");
        map.put(InstallOptions.KEYSTORE_FILE, "included");
        
        return new InstallOptions(null, map);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy