Package org.jboss.jopr.jsfunit.util.EmbJoprTestToolkit

Examples of org.jboss.jopr.jsfunit.util.EmbJoprTestToolkit.ContentTable


        // Find the result values table.
        HtmlDivision opResDiv = (HtmlDivision) client.getElement("operationResults");
        log.debug("opRes div: "+opResDiv.getTextContent());

        final String xPath = ".//table[ contains( @class,  'properties-table' ) ]//table[ contains( @class,  'property-map-summary-table' ) ]";
        ContentTable opResultTable = ejtt.getTable((HtmlTable) opResDiv.getFirstByXPath(xPath) );
        if( null == opResultTable )
          throw new org.jboss.jopr.jsfunit.exceptions.HtmlElementNotFoundException("Can't find operation result table: "+xPath, this);

        log.debug("property-map-summary-table: "+opResultTable.getElement().getTextContent());

        // Get the rows and list them.
        List<ContentTableRow> rows = opResultTable.getRows();
        int subscCount = rows.size() -1;
        log.info("List contains "+subscCount+" subscriptions.");
        for( ContentTableRow row : rows ) {
          if( row.isHeader() )
            continue;
View Full Code Here


    // Go to SBM.
    row.getLinkByLabel(NAV_SBM_SETS).click();


    // Summary tab
    ContentTable table = ejtt.tabMenu.getTabContentBox().getTableUnderHeader(LABEL_GENERAL_PROPERTIES);
    ContentInfoTable infoTable = ejtt.getContentInfoTable(table.getElement());
    Properties props = infoTable.getProperties();

    // Name
    assertEquals("Name should be "+NAV_SBM_SETS, NAV_SBM_SETS, props.getProperty("Name"));
View Full Code Here

    cachesNode.click();
   
    final String HA_PARTITION = "ha-partition";
    assertTrue("JBoss Caches should list '"+HA_PARTITION+"'", client.getPageAsText().contains(HA_PARTITION) );

    ContentTable table = ejtt.getTabMenu().getTabContentBox().getFirstTable();
   
    // Rows 1+
    List<ContentTableRow> rows = table.getRows();
    assertTrue( "Caches list should contain at least one cache.", rows.size() > 0 );

    // The ha-partition cache is active by default.
    // Check that it's present.
    boolean haparPresent = false;
View Full Code Here

   * Tests whether the scripts node exists and that all the scripts are listed.
   */
  public void testScriptsListingTest() throws IOException, EmbJoprTestException  {

    ejtt.navTree.getNodeByLabel(NAV_SCRIPTS).click();
    ContentTable scriptsListingTable = ejtt.tabMenu.getTabContentBox().getFirstTable();

    // Go through the dir, and check whether each *.sh file is listed in the page.
    File binDir = new File(ejtt.getJBossHomeDir());
    if( !binDir.isDirectory() )
      throw new EmbJoprTestException(binDir.getAbsolutePath()+" is not a directory.");

    // Get the list of .sh files in the <JBOSS_HOME>/bin dir.
    log.info("Scanning directory "+binDir.getAbsolutePath());
    //File scriptFiles[] = binDir.listFiles(new FilenameSuffixFilter("sh"));
    File scriptFiles[] = binDir.listFiles((FilenameFilter)new SuffixFileFilter(".sh"));

    /*
    List<String> notListedScripts = new ArrayList();

    for( File file : scriptFiles ) {
      // Go to the scripts node.
      ejtt.navTree.getNodeByLabel(NAV_SCRIPTS).click();

      // Check whether the script is listed (on any page).
      ContentTableRow row = ejtt.getTabMenu().getTabContentBox().findLinkRowInDataTableUsingPagination(file.getName());
      if( null == row )
        notListedScripts.add("");
    }
    /*/

    // Faster method.
    List<String> notListedScripts = new ArrayList();
    for( File file : scriptFiles ) {
      notListedScripts.add(file.getName());
      log.info("Script in bin/ : "+file.getName());
    }

    // Go to the scripts node.
    ejtt.navTree.getNodeByLabel(NAV_SCRIPTS).click();

    int curPage = 1;

    do {

      log.info("Scanning scripts listing, page "+curPage);

      // Remove all scripts listed on this page from the not-listed list.
      ContentTable scriptListingTable = ejtt.getTabMenu().getTabContentBox().getDefaultTable();
      for( ContentTableRow row : scriptListingTable.getRows() ) {
        String scriptName = row.getCell(0).getTextContent().trim();
        notListedScripts.remove(scriptName);
        log.info("Listed script: '"+scriptName+"'");
      }
      // Go to the next page. If there's no next page, quit the loop.
View Full Code Here

        throw new HtmlElementNotFoundException("#operationResults - a div around a results table.");

      HtmlTable resultsTableElm = resultsDiv.getFirstByXPath(".//table[@class='properties-table']");
      if( null == resultsTableElm )
        throw new HtmlElementNotFoundException(".//table[@class='properties-table'] - a results table.");
      ContentTable resultsTable = ejtt.getTabMenu().getTabContentBox().getTable(resultsTableElm);
     
      // Process the results table.

      // Exit Code
      HtmlTextInput exitCodeInput = resultsTable.getFirstRowContainingText("Exit Code").getCellByColumnName("Value").getFirstByXPath(".//input");
      assertEquals("Exit Code should be 0", "0", exitCodeInput.getValueAttribute().trim() );

      String expectedOutputPart = "usage";
      HtmlTextArea outputTA = resultsTable.getFirstRowContainingText("Output").getCellByColumnName("Value").getFirstByXPath(".//textarea");
      String taText = outputTA.getText();
      DebugUtils.writeFile("target/scriptsWithoutParam-output.html", taText);
      assertTrue("classpath.sh parameter-less run output should contain '"+expectedOutputPart+"'; is:\n"+taText,  taText.toLowerCase().contains(expectedOutputPart));

    }
View Full Code Here

      // Command Line Arguments:  "-c"
      // No tab content box in this block.
      {
        HtmlTable resultsTableElm = ((HtmlForm)client.getElement("parametersForm")).getFirstByXPath(".//table[@class='properties-table']");
        ContentTable resultsTable = ejtt.getTable(resultsTableElm);

        ContentTableRow row = resultsTable.getFirstRowContainingText("Command Line Arguments");
        assertNotNull("'Command Line Arguments' row not found.", row);
        HtmlCheckBoxInput unsetCheckbox = row./*getCellByColumnName("Unset").*/ getElement().getFirstByXPath(".//input[@type='checkbox']");
        unsetCheckbox.setChecked(false);
        HtmlTextArea argsTA = row./*getCellByColumnName("Value").*/ getElement().getFirstByXPath(".//textarea"); // [@ondblclick='commandLineArguments']
        argsTA.setText("-c");
        DebugUtils.writeFile("target/scriptsWithParam-settingParams.html", client.getPageAsText());

        ejtt.sleep(2000);

        // Run.
        ((HtmlSubmitInput) client.getElement("parametersForm:okButton")).click();
      }


      // Wait for the operation to succesfuly finish.
      ejtt.operations.waitActivelyForOperationToFinish(EXECUTE_OP_NAME, 5000, 5);
      assertTrue(EXECUTE_OP_NAME+" operation wasn't successful.", ejtt.tabMenu.getTabContentBox().getOperationsHistoryTable().wasLastOperationSuccesful() );

      ejtt.sleep(2000);

      // Get the results table.
      //client.getElement("historyDetailsPanel_body");
      HtmlDivision resultsDiv = (HtmlDivision) client.getElement("operationResults");
      if( null == resultsDiv )
        throw new HtmlElementNotFoundException("#operationResults - a div around a results table.");

      HtmlTable resultsTableElm = resultsDiv.getFirstByXPath(".//table[@class='properties-table']");
      if( null == resultsTableElm )
        throw new HtmlElementNotFoundException(".//table[@class='properties-table'] - a results table.");
      ContentTable resultsTable = ejtt.getTabMenu().getTabContentBox().getTable(resultsTableElm);

      // Process the results table.

      // Exit Code
      HtmlTextInput exitCodeInput = resultsTable.getFirstRowContainingText("Exit Code").getCellByColumnName("Value").getFirstByXPath(".//input");
      assertEquals("Exit Code should be 0", "0", exitCodeInput.getValueAttribute().trim() );

      String expectedOutputPart = "/client";
      HtmlTextArea outputTA = resultsTable.getFirstRowContainingText("Output").getCellByColumnName("Value").getFirstByXPath(".//textarea");
      String taText = outputTA.getText().trim();
      DebugUtils.writeFile("target/scriptsWithParam-output.html", client.getPageAsText());
      assertTrue("`classpath.sh -c` run output should contain '"+expectedOutputPart+"'; is:\n"+taText, taText.toLowerCase().contains(expectedOutputPart));

    }
View Full Code Here

    String pageHeaderText = String.format(AS_NODE_NAME_FORMAT, jbossConfig);
    //assertTrue("Page doesn't contain the header: "+headerText, pageText.contains(headerText));
    assertTrue("Content doesn't contain the header: "+pageHeaderText,
            client.getElement("content").getTextContent().contains(pageHeaderText));

    ContentTable table;
    ContentInfoTable infoTable;
    String headerText;
    Properties properties;

    JMXUtils jmxUtils = JMXUtils.getInstanceForLocalJBoss();


    /*
     * General Properties
        Name:JBoss AS 5 (default)
        Version:5.1.0.CR1
        Description:JBoss Application Server
     */
    headerText = "General Properties";
    assertTrue("Page doesn't contain the header: "+headerText, pageText.contains(headerText));
    table = ejtt.getTabMenu().getTabContentBox().getTableUnderHeader(headerText);
    infoTable = ejtt.getContentInfoTable(table.getElement());
    properties = infoTable.getProperties();

    assertEquals("General Properties / Name", pageHeaderText, properties.getProperty("Name") );

    String versionPrefix = "5.1";
    String jmxMBeanName = "jboss.system:type=Server";
    versionPrefix = (String) jmxUtils.getMBeanAttribute(jmxMBeanName, "VersionNumber");

    assertTrue("General Properties / Version startsWith('"+versionPrefix+"')",
            properties.getProperty("Version","~not found~").startsWith(versionPrefix) );
    assertEquals("General Properties / Description", AS_NODE_DESCRIPTION, properties.get("Description") );


    /*
     * Resource Traits
        Server Name: default
        Server Home Dir: /home/brq/ozizka/.../jboss-as-5.x/build/output/jboss-5.1.0.CR1/server/default
        Version Name: The Oracle
        Build Date: April 22 2009
        Start Date: Wed Apr 22 18:26:43 CEST 2009
     */
    headerText = AppConstants.LABEL_TRAITS;
    assertTrue("Page doesn't contain the header: "+headerText, pageText.contains(headerText));
    table = ejtt.getTabMenu().getTabContentBox().getTableUnderHeader(headerText);
    infoTable = ejtt.getContentInfoTable(table.getElement());
    properties = infoTable.getProperties();

    assertEquals(AppConstants.LABEL_TRAITS+" / Server Name", ejtt.getJBossConfig(),
            properties.getProperty("Server Name"));

    assertEquals(AppConstants.LABEL_TRAITS+" / Server Home Dir",
            //String.format("%s/server/%s", ejtt.getJBossHomeDir(), ejtt.getJBossConfig()),
            ejtt.getJBossHomeDir(),
            properties.getProperty("Server Home Dir"));


    /*
     * Metrics Summary
        Name  Value  Description
        Active Thread Count  7.0  The current number of active threads for this app server instance
        JVM Free Memory  183.6MB  The amount of free memory for the JVM this app server instance is running on
        JVM Total Memory  218.7MB  The amount of total memory for the JVM this app server instance is running on

        TODO: Split - grab some resources and do a page refresh for every part?
     */
    headerText = AppConstants.LABEL_NUMERIC_METRICS;
    assertTrue("Page doesn't contain the header: "+headerText, pageText.contains(headerText));
    table = ejtt.getTabMenu().getTabContentBox().getTableUnderHeader(headerText);

    // Get values as properties.
    table.analyzeColumns();
    Properties metricsProps = table.getProperties("Name", "Value");
    log.info( headerText +" 1st: "+ metricsProps.toString() );

    // Parse the values.
    int threads1 = (int)NumberUtils.toDouble(metricsProps.getProperty("Active Thread Count").replace(',', '.'));
    double memFree1 = NumberUtils.toDouble(metricsProps.getProperty("JVM Free Memory").replace(',', '.').replace("MB", ""));
    double memTotal1 = NumberUtils.toDouble(metricsProps.getProperty("JVM Total Memory").replace(',', '.').replace("MB", ""));



    // Do some requests to add threads.
    // Bad way - thread pool can cause thread number not to change.
    /*
    // Create HTMLUnit WebClient.
    WebClient wc = new WebClient(BrowserVersion.FIREFOX_3);
    wc.setCssEnabled(false);
    wc.setJavaScriptEnabled(false);
    // Get some page.
    wc.getPage("http://localhost:8080/");
     */

    // Launch as much threads as the current number to get higher number.
    log.info("Starting "+threads1+" threads.");
    ThreadGroup threadGroup = new ThreadGroup("Dummy threads");
    for( int i = 0; i < threads1; i++ ) {
      log.debug("Starting thread 'Dummy thread "+i+"'");
      Thread thread = new Thread(threadGroup, new MyRunnable(), "Dummy thread "+i);
      thread.start();
    }
   


    // Allocate some memory to decrease free mem.
    log.info("Allocating 500 MB of ram.");
    byte tmp[] = new byte[500 * 1024 * 1024]; // Few MB.
    tmp[0] = 1;
    tmp[tmp.length-1] = 1;



    // Refresh the page
    ((HtmlPage)client.getContentPage()).refresh();

    // Stop the threads.
    threadGroup.interrupt();


    // Read new values.
    headerText = "Metrics Summary";
    assertTrue("Page doesn't contain the header: "+headerText, pageText.contains(headerText));
    table = ejtt.getTabMenu().getTabContentBox().getTableUnderHeader(headerText);

    // Get values as properties.
    table.analyzeColumns();
    metricsProps = table.getProperties("Name", "Value");
    log.info( headerText +" 2nd: "+ metricsProps.toString() );

    // Parse the values.
    int threads2 = (int)NumberUtils.toDouble( metricsProps.getProperty("Active Thread Count").replace(',', '.') );
    double memFree2 = NumberUtils.toDouble(metricsProps.getProperty("JVM Free Memory").replace(',', '.').replace("MB", "") );
View Full Code Here

TOP

Related Classes of org.jboss.jopr.jsfunit.util.EmbJoprTestToolkit.ContentTable

Copyright © 2018 www.massapicom. 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.