Search in sources :

Example 1 with Listener

use of edu.mit.csail.sdg.alloy4.Listener in project webtools.servertools by eclipse.

the class XmlTestCase method testDefaultServerXml50.

/**
 * Test reading of the default server.xml provided by the
 * current Tomcat 5.0 release (28).
 */
public void testDefaultServerXml50() {
    Server server = getXml40Server("default.serverxml.50");
    assertNotNull(server);
    // Check contents of XML
    String port = server.getPort();
    assertEquals("8005", port);
    assertEquals(server.getListenerCount(), 2);
    Listener listener = server.getListener(0);
    assertNotNull(listener);
    assertEquals("org.apache.catalina.mbeans.ServerLifecycleListener", listener.getClassName());
    listener = server.getListener(1);
    assertNotNull(listener);
    assertEquals("org.apache.catalina.mbeans.GlobalResourcesLifecycleListener", listener.getClassName());
    assertEquals(1, server.getServiceCount());
    Service service = server.getService(0);
    assertNotNull(service);
    assertEquals("Catalina", service.getName());
    assertEquals(2, service.getConnectorCount());
    Connector connector = service.getConnector(0);
    assertNotNull(connector);
    assertEquals("8080", connector.getPort());
    assertNull(connector.getProtocol());
    connector = service.getConnector(1);
    assertNotNull(connector);
    assertEquals("8009", connector.getPort());
    assertEquals("AJP/1.3", connector.getProtocol());
    Engine engine = service.getEngine();
    assertNotNull(engine);
    assertEquals("Catalina", engine.getName());
    assertEquals("localhost", engine.getDefaultHost());
    assertEquals(engine.getHostCount(), 1);
    Host host = engine.getHost(0);
    assertNotNull(host);
    assertEquals("localhost", host.getName());
    assertEquals("webapps", host.getAppBase());
    assertEquals("true", host.getAttributeValue("unpackWARs"));
    assertEquals("true", host.getAttributeValue("autoDeploy"));
    assertEquals(0, host.getContextCount());
}
Also used : 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) Engine(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Engine)

Example 2 with Listener

use of edu.mit.csail.sdg.alloy4.Listener in project webtools.servertools by eclipse.

the class XmlTestCase method testDefaultServerXml55.

/**
 * Test reading of the default server.xml provided by the
 * current Tomcat 5.5 release (20).
 */
public void testDefaultServerXml55() {
    Server server = getXml40Server("default.serverxml.55");
    assertNotNull(server);
    // Check contents of XML
    String port = server.getPort();
    assertEquals("8005", port);
    assertEquals(server.getListenerCount(), 4);
    Listener listener = server.getListener(0);
    assertNotNull(listener);
    assertEquals("org.apache.catalina.core.AprLifecycleListener", listener.getClassName());
    listener = server.getListener(1);
    assertNotNull(listener);
    assertEquals("org.apache.catalina.mbeans.ServerLifecycleListener", listener.getClassName());
    listener = server.getListener(2);
    assertNotNull(listener);
    assertEquals("org.apache.catalina.mbeans.GlobalResourcesLifecycleListener", listener.getClassName());
    listener = server.getListener(3);
    assertNotNull(listener);
    assertEquals("org.apache.catalina.storeconfig.StoreConfigLifecycleListener", listener.getClassName());
    assertEquals(server.getServiceCount(), 1);
    Service service = server.getService(0);
    assertNotNull(service);
    assertEquals("Catalina", service.getName());
    assertEquals(2, service.getConnectorCount());
    Connector connector = service.getConnector(0);
    assertNotNull(connector);
    assertEquals("8080", connector.getPort());
    assertNull(connector.getProtocol());
    connector = service.getConnector(1);
    assertNotNull(connector);
    assertEquals("8009", connector.getPort());
    assertEquals("AJP/1.3", connector.getProtocol());
    Engine engine = service.getEngine();
    assertNotNull(engine);
    assertEquals("Catalina", engine.getName());
    assertEquals("localhost", engine.getDefaultHost());
    assertEquals(1, engine.getHostCount());
    Host host = engine.getHost(0);
    assertNotNull(host);
    assertEquals("localhost", host.getName());
    assertEquals("webapps", host.getAppBase());
    assertEquals("true", host.getAttributeValue("unpackWARs"));
    assertEquals("true", host.getAttributeValue("autoDeploy"));
    assertEquals(0, host.getContextCount());
}
Also used : 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) Engine(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Engine)

Example 3 with Listener

use of edu.mit.csail.sdg.alloy4.Listener in project webtools.servertools by eclipse.

the class XmlTestCase method testDefaultServerXml60.

/**
 * Test reading of the default server.xml provided by the
 * current Tomcat 6.0 release.
 */
public void testDefaultServerXml60() {
    Server server = getXml40Server("default.serverxml.60");
    assertNotNull(server);
    // Check contents of XML
    String port = server.getPort();
    assertEquals("8005", port);
    assertEquals(4, server.getListenerCount());
    Listener listener = server.getListener(0);
    assertNotNull(listener);
    assertEquals("org.apache.catalina.core.AprLifecycleListener", listener.getClassName());
    listener = server.getListener(1);
    assertNotNull(listener);
    assertEquals("org.apache.catalina.core.JasperListener", listener.getClassName());
    listener = server.getListener(2);
    assertNotNull(listener);
    assertEquals("org.apache.catalina.mbeans.ServerLifecycleListener", listener.getClassName());
    listener = server.getListener(3);
    assertNotNull(listener);
    assertEquals("org.apache.catalina.mbeans.GlobalResourcesLifecycleListener", listener.getClassName());
    assertEquals(1, server.getServiceCount());
    Service service = server.getService(0);
    assertNotNull(service);
    assertEquals("Catalina", service.getName());
    assertEquals(2, service.getConnectorCount());
    Connector connector = service.getConnector(0);
    assertNotNull(connector);
    assertEquals("8080", connector.getPort());
    assertEquals("HTTP/1.1", connector.getProtocol());
    connector = service.getConnector(1);
    assertNotNull(connector);
    assertEquals("8009", connector.getPort());
    assertEquals("AJP/1.3", connector.getProtocol());
    Engine engine = service.getEngine();
    assertNotNull(engine);
    assertEquals("Catalina", engine.getName());
    assertEquals("localhost", engine.getDefaultHost());
    assertEquals(1, engine.getHostCount());
    Host host = engine.getHost(0);
    assertNotNull(host);
    assertEquals("localhost", host.getName());
    assertEquals("webapps", host.getAppBase());
    assertEquals("true", host.getAttributeValue("unpackWARs"));
    assertEquals("true", host.getAttributeValue("autoDeploy"));
    assertEquals(0, host.getContextCount());
}
Also used : 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) Engine(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Engine)

Example 4 with Listener

use of edu.mit.csail.sdg.alloy4.Listener 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 5 with Listener

use of edu.mit.csail.sdg.alloy4.Listener in project org.alloytools.alloy by AlloyTools.

the class Browsable method showAsTree.

/**
 * Display this node and its subnodes as a tree; if listener!=null, it will
 * receive OurTree.Event.SELECT events when nodes are selected.
 */
public final JFrame showAsTree(Listener listener) {
    final OurTree tree = new OurTree(12) {

        private static final long serialVersionUID = 0;

        private final boolean onWindows = Util.onWindows();

        {
            do_start();
        }

        @Override
        public String convertValueToText(Object val, boolean selected, boolean expanded, boolean leaf, int row, boolean focus) {
            String c = ">";
            String x = (val instanceof Browsable) ? ((Browsable) val).getHTML() : Util.encode(String.valueOf(val));
            if (onWindows)
                c = selected ? " style=\"color:#ffffff;\">" : " style=\"color:#000000;\">";
            return "<html><span" + c + x + "</span></html>";
        }

        @Override
        public List<?> do_ask(Object parent) {
            if (parent instanceof Browsable)
                return ((Browsable) parent).getSubnodes();
            else
                return new ArrayList<Browsable>();
        }

        @Override
        public Object do_root() {
            return Browsable.this;
        }
    };
    tree.setBorder(new EmptyBorder(3, 3, 3, 3));
    final JScrollPane scr = new JScrollPane(tree, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scr.addFocusListener(new FocusListener() {

        @Override
        public void focusGained(FocusEvent e) {
            tree.requestFocusInWindow();
        }

        @Override
        public void focusLost(FocusEvent e) {
        }
    });
    final JFrame x = new JFrame("Parse Tree");
    x.setLayout(new BorderLayout());
    x.add(scr, BorderLayout.CENTER);
    x.pack();
    x.setSize(500, 500);
    x.setLocationRelativeTo(null);
    x.setVisible(true);
    if (listener != null)
        tree.listeners.add(listener);
    return x;
}
Also used : JScrollPane(javax.swing.JScrollPane) BorderLayout(java.awt.BorderLayout) JFrame(javax.swing.JFrame) OurTree(edu.mit.csail.sdg.alloy4.OurTree) EmptyBorder(javax.swing.border.EmptyBorder) FocusListener(java.awt.event.FocusListener) FocusEvent(java.awt.event.FocusEvent)

Aggregations

Connector (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Connector)4 Engine (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Engine)4 Host (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Host)4 Listener (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Listener)4 Server (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Server)4 Service (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Service)4 OurBorder (edu.mit.csail.sdg.alloy4.OurBorder)2 OurTree (edu.mit.csail.sdg.alloy4.OurTree)2 BorderLayout (java.awt.BorderLayout)2 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 FocusEvent (java.awt.event.FocusEvent)2 JScrollPane (javax.swing.JScrollPane)2 BooleanPref (edu.mit.csail.sdg.alloy4.A4Preferences.BooleanPref)1 ChoicePref (edu.mit.csail.sdg.alloy4.A4Preferences.ChoicePref)1 Pref (edu.mit.csail.sdg.alloy4.A4Preferences.Pref)1 StringPref (edu.mit.csail.sdg.alloy4.A4Preferences.StringPref)1 VerbosityPref (edu.mit.csail.sdg.alloy4.A4Preferences.VerbosityPref)1 Listener (edu.mit.csail.sdg.alloy4.Listener)1 OurTabbedSyntaxWidget (edu.mit.csail.sdg.alloy4.OurTabbedSyntaxWidget)1