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

/*
 *                 Sun Public License Notice
 * 
 * The contents of this file are subject to the Sun Public License
 * Version 1.0 (the "License"). You may not use this file except in
 * compliance with the License. A copy of the License is available at
 * http://www.sun.com/
 * 
 * The Original Code is NetBeans. The Initial Developer of the Original
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun
 * Microsystems, Inc. All Rights Reserved.
 */

package org.netbeans.test.gui.web.warpackager; 

import org.netbeans.jellytools.JellyTestCase;
import org.netbeans.jellytools.Bundle;

import org.netbeans.jellytools.nodes.FilesystemNode;
import org.netbeans.jellytools.nodes.Node;


import org.netbeans.jellytools.OutputWindowOperator;
import org.netbeans.jellytools.NbDialogOperator;
import org.netbeans.jellytools.RuntimeTabOperator;
import org.netbeans.jellytools.ExplorerOperator;
import org.netbeans.jellytools.MainWindowOperator;

import org.netbeans.jellytools.actions.CopyAction;
import org.netbeans.jellytools.actions.CutAction;
import org.netbeans.jellytools.actions.PasteAction;
import org.netbeans.jellytools.actions.DeleteAction;
import org.netbeans.jellytools.actions.RenameAction;
import org.netbeans.jellytools.actions.PropertiesAction;

import org.netbeans.jellytools.properties.TextFieldProperty;
import org.netbeans.jellytools.properties.PropertySheetTabOperator;
import org.netbeans.jellytools.properties.PropertySheetOperator;

import org.netbeans.junit.NbTestSuite;

import org.netbeans.jemmy.operators.JTreeOperator;
import org.netbeans.jemmy.operators.JTextFieldOperator;
import org.netbeans.jemmy.operators.JScrollPaneOperator;
import org.netbeans.jemmy.operators.JTableOperator;
import org.netbeans.jemmy.operators.JButtonOperator;
import org.netbeans.jemmy.util.RegExComparator;
import org.netbeans.jemmy.operators.Operator;
import org.netbeans.jemmy.Waiter;
import org.netbeans.jemmy.Waitable;
import org.netbeans.jemmy.TimeoutExpiredException;

import java.awt.event.KeyEvent;

import org.netbeans.jellytools.EditorOperator;
import org.netbeans.jellytools.EditorWindowOperator;

import org.netbeans.jemmy.operators.JEditorPaneOperator;

import org.netbeans.web.test.nodes.WebInfNode;
import org.netbeans.web.test.actions.ViewContentWarAction;
import org.netbeans.web.test.actions.ExportWarAction;
import org.netbeans.web.test.util.RepositoryNodeWaitable;

/* */
public class WebInfActions extends JellyTestCase {
    private static String workDir = null;     
    private static String webModule = null;
    private static String wm = "wm2";
    private static String webInf = null;
    private static String fSep = System.getProperty("file.separator");
    private static String iSep = "|";
    private static String classes = null;
    private static String from1 = null;
    private static String from2 = null;
    private static String from3 = null;
    private static String to1 = null;
    private static String to2 = null;
    private static String to3 = null;
    private static ExplorerOperator explorer = null;
    private static String wcTitle = null;
    private String[] warContent = {"META-INF/MANIFEST.MF","WEB-INF/classes/pkg/Servlet2.class", "WEB-INF/classes/Servlet1.class", "WEB-INF/web.xml", "jsp/sample_jsp.jsp", "html/wm2.gif", "html/wm2_html.html", "images/wm2.gif", "data/JApplet.form", "data/JApplet.class", "data/JApplet.html"}; 
    //constructor required by JUnit
    public WebInfActions(java.lang.String testName) {
        super(testName);
    }
    
    //method allowing to execute test directly
    //from IDE for debugging    
    public static void main(java.lang.String[] args) {
        junit.textui.TestRunner.run(suite());
    }
         
    //method required by JUnit
    public static junit.framework.Test suite() {
        junit.framework.Test suite =  new NbTestSuite(WebInfActions.class);
	workDir = System.getProperty("warpackager.workdir").replace('/', fSep.charAt(0));
	wcTitle = Bundle.getStringTrimmed("org.netbeans.modules.web.war.actions.Bundle", "CTL_WarViewerDialogTitle");
        webModule = workDir + fSep + wm;
	webInf = webModule + iSep + "WEB-INF";
        from1 = workDir + iSep + "from1";
	from2 = workDir + iSep + "from2";
	from3 = workDir + iSep + "from3";
	to1 = workDir + iSep + "to1";
	to2 = workDir + iSep + "to2";
	to3 = workDir + iSep + "to3";
	explorer = ExplorerOperator.invoke();
	explorer.selectPageFilesystems();
	return suite;
    }

    public void testActionsPresentInMenu() {
	WebInfNode node1 = null;
	try {
            node1 = new WebInfNode(webInf);
        } catch (Exception e) {
            fail("Please check that all mounts are done properly");
            e.printStackTrace();
        }
	try {
	    node1.verifyPopup();
	}catch(Exception e) {
	    e.printStackTrace();
	    fail("Looks like not all popup menu items present for WEB-INF.");
	}
	//PASS
    }

    public void testViewWARContent() {
	WebInfNode node1 = null;
        try {
            node1 = new WebInfNode(webInf);
        } catch (Exception e) {
            fail("Please check that all mounts are done properly");
            e.printStackTrace();
        }
	try {
	    node1.select();
            (new ViewContentWarAction()).performPopup(node1);
        }catch(Exception e) {
            fail("Exception while try to view WAR content via popup: " + e);
        }
	NbDialogOperator dialog = new NbDialogOperator(wcTitle);
	JScrollPaneOperator panel = new JScrollPaneOperator(dialog);
	JTableOperator table = new JTableOperator(panel);
	int rows = table.getModel().getRowCount();
	int columns = table.getModel().getColumnCount();
	if(columns != 3) {
	    dialog.close();
	    fail("Columns != 3 - unknown format of table");
	}
	if(warContent.length != rows) {
	    dialog.close();
	    fail("Detected " + rows + " entries of content instead of " + warContent.length);
	}
	java.util.HashSet hash = new java.util.HashSet(); 
	for(int i=0; i
... 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.