alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

/*
 * Util.java
 *
 * Created on 13. červenec 2004, 13:15
 */

package org.netbeans.test.web;

import java.io.File;
import java.util.Arrays;
import org.netbeans.jellytools.Bundle;
import org.netbeans.jellytools.NbDialogOperator;
import org.netbeans.jellytools.OptionsOperator;
import org.netbeans.jellytools.ProjectsTabOperator;
import org.netbeans.jellytools.RuntimeTabOperator;
import org.netbeans.jellytools.TopComponentOperator;
import org.netbeans.jellytools.actions.Action;
import org.netbeans.jellytools.nodes.Node;
import org.netbeans.jellytools.properties.Property;
import org.netbeans.jellytools.properties.PropertySheetOperator;
import org.netbeans.jemmy.TimeoutExpiredException;
import org.netbeans.jemmy.operators.JButtonOperator;
import org.netbeans.jemmy.operators.JFrameOperator;
import org.netbeans.jemmy.operators.Operator;

/**
 *
 * @author  lm97939
 */
public class Util {
    
    /** Creates a new instance of Util */
    public Util() {
    }
    
    public static String dumpProjectView(String project) {
        try { Thread.currentThread().sleep(3000); }
        catch (InterruptedException e) {}
        StringBuffer buff = new StringBuffer();
        Node node = new ProjectsTabOperator().getProjectRootNode(project);
        dumpNode(node, buff, 0);
        return buff.toString();
    }
    
    
    private static void dumpNode(Node node, StringBuffer buff, int level) {
        for (int i=0; i wait max. 3 minutes
        scanningDialogOper.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 180000);
        scanningDialogOper.waitClosed();
    }
    
    public static void waitForProgressMonitor(boolean really) {
        JFrameOperator mon = null;
        try { mon = new JFrameOperator("Monitor"); } 
        catch (TimeoutExpiredException e) {
            if (really) throw e; 
            else return;
        }
        mon.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 180000);
        try { mon.waitClosed(); }
        catch (TimeoutExpiredException e) {
            if (really) throw e; 
            mon.close();
        }
    }
    
    public static void stopTomcat() {
        startStopTomcat(false, false);
    }
    
    public static void startStopTomcat(boolean start, boolean waitClose) {
        RuntimeTabOperator runtimeTab = RuntimeTabOperator.invoke();
        Node tomcatNode = new Node(runtimeTab.getRootNode(), "Server Registry|Tomcat 5 Servers|Bundled Tomcat");
        
        // HACK!!!
        //Node module = new Node(tomcatNode,"Web Modules|/SampleProject");
        //module.performPopupAction("Undeploy");
        
        tomcatNode.performPopupAction("Start / Stop Server...");
        JFrameOperator status = new JFrameOperator("Server Status");
        JButtonOperator startButton;
        if (start)
            startButton = new JButtonOperator(status,"Start Server");
        else
            startButton = new JButtonOperator(status,"Stop Server");
        
        try { startButton.waitComponentEnabled();
              try { Thread.currentThread().sleep(1000); } catch (InterruptedException e) {}
              startButton.push();
              status.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 60000);
              status.waitClosed();        
        }
        catch (TimeoutExpiredException e) {
              e.printStackTrace();
              if (waitClose) 
                  throw e;
              else 
                  status.close();
        }
        catch (InterruptedException e) {
              status.close();
        }
        try { Thread.currentThread().sleep(1000); } catch (InterruptedException e) {}

    }
    
}
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.