use of org.kie.workbench.common.dmn.api.definition.v1_1.Context in project webtools.servertools by eclipse.
the class Tomcat41Configuration method addWebModule.
/**
* @see ITomcatConfigurationWorkingCopy#addWebModule(int, ITomcatWebModule)
*/
public void addWebModule(int index, ITomcatWebModule module) {
try {
Context context = serverInstance.createContext(index);
if (context != null) {
context.setDocBase(module.getDocumentBase());
context.setPath(module.getPath());
context.setReloadable(module.isReloadable() ? "true" : "false");
if (module.getMemento() != null && module.getMemento().length() > 0)
context.setSource(module.getMemento());
isServerDirty = true;
firePropertyChangeEvent(ADD_WEB_MODULE_PROPERTY, null, module);
}
} catch (Exception e) {
Trace.trace(Trace.SEVERE, "Error adding web module " + module.getPath(), e);
}
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.Context in project webtools.servertools by eclipse.
the class Tomcat41Configuration method getWebModules.
/**
* Return a list of the web modules in this server.
* @return java.util.List
*/
public List getWebModules() {
List<WebModule> list = new ArrayList<WebModule>();
try {
Context[] contexts = serverInstance.getContexts();
if (contexts != null) {
for (int i = 0; i < contexts.length; i++) {
Context context = contexts[i];
String reload = context.getReloadable();
if (reload == null)
reload = "false";
WebModule module = new WebModule(context.getPath(), context.getDocBase(), context.getSource(), reload.equalsIgnoreCase("true") ? true : false);
list.add(module);
}
}
} catch (Exception e) {
Trace.trace(Trace.SEVERE, "Error getting project refs", e);
}
return list;
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.Context in project webtools.servertools by eclipse.
the class XmlTestCase method testServerInstance2.
/**
* Test behavior of ServerInstance
*/
public void testServerInstance2() {
Server server = getXml40Server("serverxml.test2");
assertNotNull(server);
ServerInstance si = new ServerInstance(server, "Service", "nonexistent_host");
assertNotNull(si.getService());
assertNotNull(si.getEngine());
assertEquals("Engine", si.getEngine().getName());
assertNull(si.getHost());
assertEquals("Host \"nonexistent_host\" was not found under Engine \"Engine\" and Service \"Service\".", si.getStatus().getMessage());
si = new ServerInstance(server, "Service", null);
assertNotNull(si.getService());
assertNotNull(si.getEngine());
assertEquals("Engine", si.getEngine().getName());
assertNotNull(si.getHost());
assertEquals("localhost", si.getHost().getName());
assertEquals((new Path("/Base")).append("Engine").append("localhost"), si.getContextXmlDirectory(new Path("/Base")));
Context context = si.getContext(0);
assertNotNull(context);
assertEquals("/WebApp1", context.getPath());
context = si.getContext(1);
assertNotNull(context);
assertEquals("/WebApp2", context.getPath());
context = si.getContext(2);
assertNotNull(context);
assertEquals("/WebApp3", context.getPath());
// create new context
context = si.getContext(3);
context.setPath("/WebApp4");
Context[] contexts = si.getContexts();
assertEquals(4, contexts.length);
assertEquals("/WebApp1", contexts[0].getPath());
assertEquals("/WebApp2", contexts[1].getPath());
assertEquals("/WebApp3", contexts[2].getPath());
assertEquals("/WebApp4", contexts[3].getPath());
context = si.createContext(2);
context.setPath("/WebApp2b");
contexts = si.getContexts();
assertEquals(5, contexts.length);
assertEquals("/WebApp1", contexts[0].getPath());
assertEquals("/WebApp2", contexts[1].getPath());
assertEquals("/WebApp2b", contexts[2].getPath());
assertEquals("/WebApp3", contexts[3].getPath());
assertEquals("/WebApp4", contexts[4].getPath());
assertTrue(si.removeContext("WebApp2b"));
contexts = si.getContexts();
assertEquals(4, contexts.length);
assertEquals("/WebApp1", contexts[0].getPath());
assertEquals("/WebApp2", contexts[1].getPath());
assertEquals("/WebApp3", contexts[2].getPath());
assertEquals("/WebApp4", contexts[3].getPath());
assertTrue(si.removeContext(3));
contexts = si.getContexts();
assertEquals(3, contexts.length);
assertEquals("/WebApp1", contexts[0].getPath());
assertEquals("/WebApp2", contexts[1].getPath());
assertEquals("/WebApp3", contexts[2].getPath());
context = si.getContext("/WebApp1");
assertNotNull(context);
assertEquals("/WebApp1", context.getPath());
assertEquals(new Path("/Base/work/Engine/localhost/WebApp1"), si.getContextWorkDirectory(new Path("/Base"), context));
context = si.getContext("WebApp2");
assertNotNull(context);
assertEquals("/WebApp2", context.getPath());
assertEquals(new Path("/Base/relative/workdir"), si.getContextWorkDirectory(new Path("/Base"), context));
context = si.getContext("WebApp3");
assertNotNull(context);
assertEquals("/WebApp3", context.getPath());
assertEquals(new Path("/absolute/workdir"), si.getContextWorkDirectory(new Path("/Base"), context));
context = si.createContext(3);
context.setPath("");
context = si.getContext("");
assertNotNull(context);
assertEquals("", context.getPath());
assertEquals(new Path("/Base/work/Engine/localhost/_"), si.getContextWorkDirectory(new Path("/Base"), context));
assertEquals(new Path("/Base/work/Engine/localhost"), si.getHostWorkDirectory(new Path("/Base")));
assertNull(si.getContext("nonexistent"));
assertEquals("Context with path \"/nonexistent\" was not found under Service \"Service\", Engine \"Engine\", and Host \"localhost\".", si.getStatus().getMessage());
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.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));
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.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"));
}
Aggregations