Package org.jboss.jopr.jsfunit.as5.connectors

Source Code of org.jboss.jopr.jsfunit.as5.connectors.ConnectorsTest

package org.jboss.jopr.jsfunit.as5.connectors;

import java.io.IOException;
import java.net.URL;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.jboss.jopr.jsfunit.*;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.commons.lang.StringUtils;
import org.jboss.jopr.jsfunit.exceptions.EmbJoprTestException;
import org.jboss.jopr.jsfunit.util.EmbJoprTestToolkit.*;




public class ConnectorsTest extends EmbjoprTestCase implements AppConstants {


  /**
   * @return the suite of tests being tested
   */
  public static Test suite() {
    return new TestSuite(ConnectorsTest.class);
  }


  /**
   * This test asummes that HTTP and AJP connectors are present, like in the default AS config.
   */
  public void testConnectorHttp() throws IOException, EmbJoprTestException
  {
    // Expand the Connectors node and click it.
    ejtt.navTree.getNodeByLabel(NAV_JBOSS_WEB).getArrowLink().click();
    ejtt.navTree.waitUntilNodeLoadedByAjax(NAV_CONNECTORS, 1000, 6);
    ejtt.navTree.getNodeByLabel(NAV_CONNECTORS).getLabelLink().click();

    ContentTable connList = ejtt.tabMenu.getTabContentBox().getFirstTable();

    // HTTP
    ContentTableRow rowHttp = connList.getFirstRowContainingText("http://");
    if( null == rowHttp )
      throw new EmbJoprTestException("HTTP connector not listed.", this);
    String status = rowHttp.getCellTextByColumnName("Status");
    if( ! "UP".equals(status) )
      throw new EmbJoprTestException("HTTP connector is not UP, but: "+status);

    // AJP
    ContentTableRow rowAjp  = connList.getFirstRowContainingText("ajp://");
    if( null == rowAjp )
      throw new EmbJoprTestException("AJP connector not listed.", this);
    status = rowAjp.getCellTextByColumnName("Status");
    if( ! "UP".equals(status) )
      throw new EmbJoprTestException("AJP connector is not UP, but: "+status);


    // Get all children nodes
    ejtt.navTree.getNodeByLabel(NAV_CONNECTORS).expand();
    List<NavTreeNode> childNodes = ejtt.navTree.getNodeByLabel(NAV_CONNECTORS).getChildren();

    // They all should have a name in the form of URL.
    // So take the protocol part and put it in a set.
    Set<String> presentNodeNames = new HashSet(childNodes.size());
    for (NavTreeNode navTreeNode : childNodes) {
      String nodeLabel = navTreeNode.getLabelLink().getTextContent().trim();
      //URL url = new URL(nodeLabel);
      //presentNodeNames.add(url.getProtocol());
      // java.net.MalformedURLException: unknown protocol: ajp
      String protocol = StringUtils.substringBefore( nodeLabel, "://" );
      presentNodeNames.add( protocol );
    }

    assertTrue( "Connectors node should contain a subnode for AJP protocol.", presentNodeNames.contains("ajp") );
    assertTrue( "Connectors node should contain a subnode for HTTP protocol.", presentNodeNames.contains("http") );

  }


}// class
TOP

Related Classes of org.jboss.jopr.jsfunit.as5.connectors.ConnectorsTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.