Search in sources :

Example 36 with Context

use of org.eclipse.jst.server.tomcat.core.internal.xml.server32.Context in project webtools.servertools by eclipse.

the class XmlTestCase method testTomcatContextComparison.

public void testTomcatContextComparison() {
    Context context = getXml40Context("tomcat.context.50");
    assertTrue(context.isEquivalentTest(context));
    Context context2 = getXml40Context("tomcat.context.50");
    assertTrue(context.isEquivalentTest(context2));
    assertTrue(context2.isEquivalentTest(context));
    String docBase = context2.getDocBase();
    context2.setDocBase(docBase + "X");
    assertTrue(!context.isEquivalentTest(context2));
    assertTrue(!context2.isEquivalentTest(context));
    context.setDocBase(docBase + "X");
    assertTrue(context.isEquivalentTest(context2));
    assertTrue(context2.isEquivalentTest(context));
    Element realm = context2.getSubElement("Realm");
    assertNotNull(realm);
    Node parent = realm.getParentNode();
    assertNotNull(parent);
    assertTrue(parent == context2.getElementNode());
    parent.removeChild(realm);
    assertTrue(!context.isEquivalentTest(context2));
    assertTrue(!context2.isEquivalentTest(context));
    parent.insertBefore(realm, parent.getFirstChild());
    assertTrue(!context.isEquivalentTest(context2));
    assertTrue(!context2.isEquivalentTest(context));
    parent.removeChild(realm);
    parent.appendChild(realm);
    assertTrue(context.isEquivalentTest(context2));
    assertTrue(context2.isEquivalentTest(context));
}
Also used : Context(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Context) Element(org.w3c.dom.Element) Node(org.w3c.dom.Node)

Example 37 with Context

use of org.eclipse.jst.server.tomcat.core.internal.xml.server32.Context in project webtools.servertools by eclipse.

the class XmlTestCase method testServerInstance32.

/**
 * Test behavior of ServerInstance with Tomcat 3.2 default server.xml.
 */
public void testServerInstance32() {
    org.eclipse.jst.server.tomcat.core.internal.xml.server32.Server server = getXml32Server("default.serverxml.32");
    assertNotNull(server);
    org.eclipse.jst.server.tomcat.core.internal.xml.server32.ServerInstance si = new org.eclipse.jst.server.tomcat.core.internal.xml.server32.ServerInstance(server);
    assertNotNull(si.getContextManager());
    org.eclipse.jst.server.tomcat.core.internal.xml.server32.Connector[] connectors = si.getConnectors();
    assertNotNull(connectors);
    assertEquals(2, connectors.length);
    Parameter parameter = connectors[0].getParameter(0);
    assertEquals("handler", parameter.getName());
    assertEquals("org.apache.tomcat.service.http.HttpConnectionHandler", parameter.getValue());
    parameter = connectors[0].getParameter(1);
    assertEquals("port", parameter.getName());
    assertEquals("8080", parameter.getValue());
    parameter = connectors[1].getParameter(0);
    assertEquals("handler", parameter.getName());
    assertEquals("org.apache.tomcat.service.connector.Ajp12ConnectionHandler", parameter.getValue());
    parameter = connectors[1].getParameter(1);
    assertEquals("port", parameter.getName());
    assertEquals("8007", parameter.getValue());
    parameter = si.getConnector(0).getParameter(0);
    assertEquals("handler", parameter.getName());
    assertEquals("org.apache.tomcat.service.http.HttpConnectionHandler", parameter.getValue());
    parameter = si.getConnector(0).getParameter(1);
    assertEquals("port", parameter.getName());
    assertEquals("8080", parameter.getValue());
    parameter = si.getConnector(1).getParameter(0);
    assertEquals("handler", parameter.getName());
    assertEquals("org.apache.tomcat.service.connector.Ajp12ConnectionHandler", parameter.getValue());
    parameter = si.getConnector(1).getParameter(1);
    assertEquals("port", parameter.getName());
    assertEquals("8007", parameter.getValue());
    org.eclipse.jst.server.tomcat.core.internal.xml.server32.Context[] contexts = si.getContexts();
    assertNotNull(contexts);
    assertEquals(2, contexts.length);
    assertEquals("/examples", contexts[0].getPath());
    assertEquals("/admin", contexts[1].getPath());
    assertEquals("/examples", si.getContext(0).getPath());
    assertEquals("/admin", si.getContext(1).getPath());
    assertEquals("/examples", si.getContext("examples").getPath());
    assertEquals("/admin", si.getContext("/admin").getPath());
    org.eclipse.jst.server.tomcat.core.internal.xml.server32.Context context = si.createContext(2);
    context.setPath("/WebApp1");
    contexts = si.getContexts();
    assertNotNull(contexts);
    assertEquals(3, contexts.length);
    assertEquals("/examples", contexts[0].getPath());
    assertEquals("/admin", contexts[1].getPath());
    assertEquals("/WebApp1", contexts[2].getPath());
    assertEquals(new Path("/Base/work/localhost_8080%2Fexamples"), si.getContextWorkDirectory(new Path("/Base"), si.getContext("examples")));
    assertEquals(new Path("/Base/work/localhost_8080%2Fadmin"), si.getContextWorkDirectory(new Path("/Base"), si.getContext("admin")));
    assertEquals(new Path("/Base/work/localhost_8080%2FWebApp1"), si.getContextWorkDirectory(new Path("/Base"), si.getContext("WebApp1")));
    assertTrue(si.removeContext(2));
    contexts = si.getContexts();
    assertNotNull(contexts);
    assertEquals(2, contexts.length);
    assertEquals("/examples", contexts[0].getPath());
    assertEquals("/admin", contexts[1].getPath());
    context = si.createContext(2);
    context.setPath("");
    context = si.getContext("");
    assertNotNull(context);
    assertEquals("", context.getPath());
    assertEquals(new Path("/Base/work/localhost_8080"), si.getContextWorkDirectory(new Path("/Base"), si.getContext("")));
    assertEquals(si.getServerWorkDirectory(new Path("/Base")), new Path("/Base/work"));
}
Also used : Context(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Context) Path(org.eclipse.core.runtime.Path) Connector(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Connector) Parameter(org.eclipse.jst.server.tomcat.core.internal.xml.server32.Parameter) ServerInstance(org.eclipse.jst.server.tomcat.core.internal.xml.server40.ServerInstance)

Example 38 with Context

use of org.eclipse.jst.server.tomcat.core.internal.xml.server32.Context in project webtools.servertools by eclipse.

the class XmlTestCase method testServerInstance3.

/**
 * Test behavior of ServerInstance
 */
public void testServerInstance3() {
    Server server = getXml40Server("serverxml.test3");
    assertNotNull(server);
    ServerInstance si = new ServerInstance(server, "Service", null);
    Context context = si.getContext("/WebApp1");
    assertNotNull(context);
    assertEquals(new Path("/Base/relative/host/WebApp1"), si.getContextWorkDirectory(new Path("/Base"), context));
    context = si.getContext("WebApp2");
    assertNotNull(context);
    assertEquals(new Path("/Base/relative/workdir"), si.getContextWorkDirectory(new Path("/Base"), context));
    context = si.getContext("WebApp3");
    assertNotNull(context);
    assertEquals(new Path("/absolute/workdir"), si.getContextWorkDirectory(new Path("/Base"), context));
}
Also used : Context(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Context) Path(org.eclipse.core.runtime.Path) Server(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Server) ServerInstance(org.eclipse.jst.server.tomcat.core.internal.xml.server40.ServerInstance)

Example 39 with Context

use of org.eclipse.jst.server.tomcat.core.internal.xml.server32.Context in project webtools.servertools by eclipse.

the class XmlTestCase method testServerInstance50.

/**
 * Test reading of the default server.xml provided by the
 * current Tomcat 5.0 release using ServerInstance.
 */
public void testServerInstance50() {
    Server server = getXml40Server("default.serverxml.50");
    assertNotNull(server);
    ServerInstance si = new ServerInstance(server, null, null);
    assertEquals(2, server.getListenerCount());
    Listener[] listeners = si.getListeners();
    assertEquals("org.apache.catalina.mbeans.ServerLifecycleListener", listeners[0].getClassName());
    assertEquals("org.apache.catalina.mbeans.GlobalResourcesLifecycleListener", listeners[1].getClassName());
    Service service = si.getService();
    assertNotNull(service);
    assertEquals("Catalina", service.getName());
    assertEquals("8080", si.getConnector(0).getPort());
    assertNull(si.getConnector(0).getProtocol());
    assertEquals("8009", si.getConnector(1).getPort());
    assertEquals("AJP/1.3", si.getConnector(1).getProtocol());
    Connector[] connectors = si.getConnectors();
    assertEquals(2, connectors.length);
    assertEquals("8080", connectors[0].getPort());
    assertNull(connectors[0].getProtocol());
    assertEquals("8009", connectors[1].getPort());
    assertEquals("AJP/1.3", connectors[1].getProtocol());
    Engine engine = si.getEngine();
    assertNotNull(engine);
    assertEquals("Catalina", engine.getName());
    assertEquals("localhost", engine.getDefaultHost());
    Host host = si.getHost();
    assertNotNull(host);
    assertEquals("localhost", host.getName());
    assertEquals("webapps", host.getAppBase());
    assertEquals("true", host.getAttributeValue("unpackWARs"));
    assertEquals("true", host.getAttributeValue("autoDeploy"));
    Context[] contexts = si.getContexts();
    assertEquals(0, contexts.length);
}
Also used : Context(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Context) Connector(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Connector) Listener(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Listener) Server(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Server) Service(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Service) Host(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Host) ServerInstance(org.eclipse.jst.server.tomcat.core.internal.xml.server40.ServerInstance) Engine(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Engine)

Example 40 with Context

use of org.eclipse.jst.server.tomcat.core.internal.xml.server32.Context in project webtools.servertools by eclipse.

the class Tomcat32TestConfiguration method verifyPublishedModule.

protected void verifyPublishedModule(IPath baseDir, IModule module) throws Exception {
    Tomcat32TestConfiguration config = new Tomcat32TestConfiguration(null);
    config.load(baseDir.append("conf"), null);
    ServerInstance serverInstance = config.getServerInstance();
    Context context = serverInstance.getContext(module.getName());
    String deployDir = getTomcatServer().getDeployDirectory();
    if ("webapps".equals(deployDir)) {
        assertEquals("webapps/" + module.getName(), context.getDocBase());
    } else {
        assertEquals(getTomcatServerBehaviour().getModuleDeployDirectory(module).toOSString(), context.getDocBase());
    }
    verifyPublishedModuleFiles(module);
}
Also used : Context(org.eclipse.jst.server.tomcat.core.internal.xml.server32.Context) ServerInstance(org.eclipse.jst.server.tomcat.core.internal.xml.server32.ServerInstance)

Aggregations

Context (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Context)58 Context (com.microsoft.z3.Context)36 CoreException (org.eclipse.core.runtime.CoreException)34 Test (org.junit.Test)24 BoolExpr (com.microsoft.z3.BoolExpr)23 List (java.util.List)20 IOException (java.io.IOException)18 ServerInstance (org.eclipse.jst.server.tomcat.core.internal.xml.server40.ServerInstance)17 Context (org.kie.workbench.common.dmn.api.definition.v1_1.Context)17 HashMap (java.util.HashMap)16 Map (java.util.Map)14 File (java.io.File)13 ArrayList (java.util.ArrayList)13 Solver (com.microsoft.z3.Solver)12 Status (com.microsoft.z3.Status)12 IPath (org.eclipse.core.runtime.IPath)11 IStatus (org.eclipse.core.runtime.IStatus)11 Status (org.eclipse.core.runtime.Status)11 Factory (org.eclipse.jst.server.tomcat.core.internal.xml.Factory)11 Z3Exception (com.microsoft.z3.Z3Exception)9