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.webmodule;

import org.netbeans.junit.NbTestSuite;
import org.netbeans.jellytools.ExplorerOperator;
import org.netbeans.jellytools.JellyTestCase;
import org.netbeans.jellytools.RepositoryTabOperator;
import org.netbeans.jellytools.nodes.FilesystemNode;
import org.netbeans.jellytools.nodes.FolderNode;
import org.netbeans.jellytools.QuestionDialogOperator;
import org.netbeans.jellytools.WizardOperator;
import org.netbeans.jellytools.actions.ActionNoBlock;
import org.netbeans.jellytools.ChooseTemplateStepOperator;
import org.netbeans.jellytools.TargetLocationStepOperator;
import org.netbeans.jemmy.operators.JTextFieldOperator;
import org.netbeans.jellytools.Bundle;

import org.netbeans.test.gui.web.webmodule.util.Test_Support;
/**
 */
public class Webmodule_creation extends JellyTestCase 
{
    private static String ssep = "|";
    private static String fsep = System.getProperty("file.separator");
    
    /** Creates a new instance of webmodule_creation */
    public Webmodule_creation(String testName) {
        super(testName);
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        junit.textui.TestRunner.run(new NbTestSuite(Webmodule_creation.class));
        
    }
    public void test_WebModuleCreation_convert(){
        
        String path = Test_Support.getTestDir(this.getName());
        String m_path1 = Bundle.getString("org.netbeans.core.Bundle","Actions/Tools");
        String m_path2 = Bundle.getStringTrimmed("org.netbeans.modules.web.context.actions.Bundle","ACT_ConvertWar");
        
        new RepositoryTabOperator().mountLocalDirectoryAPI(path);
        new FolderNode(path).performPopupActionNoBlock(m_path1+ssep+m_path2);
        new QuestionDialogOperator().ok();
        Test_Support.sleep();
        assertTrue(verify_webmodule(path));
        
    }   

     public void test_WebModuleCreation_new_menu(){
        String m_path2 = Bundle.getString("org.netbeans.modules.web.core.Bundle","Templates/JSP_Servlet");
        String m_path3 = Bundle.getString("org.netbeans.modules.web.context.Bundle","Templates/JSP_Servlet/webapp.warImage");
        String path = Test_Support.getTestDir(this.getName());
        new ActionNoBlock("File|New", null).perform();
        WizardOperator wzd = new WizardOperator(Bundle.getString("org.netbeans.core.ui.Bundle","CTL_New"));
        new ChooseTemplateStepOperator().selectTemplate(m_path2+ssep+m_path3);
        wzd.next();
        JTextFieldOperator dirOpr = new JTextFieldOperator(wzd);
        dirOpr.clearText();
        dirOpr.typeText(path);
        wzd.finish();
        Test_Support.sleep();        
        assertTrue(verify_webmodule(path));
       
    }

    public void test_WebModuleCreation_dir_exist() {
        String m_path2 = Bundle.getString("org.netbeans.modules.web.core.Bundle","Templates/JSP_Servlet");
        String m_path3 = Bundle.getString("org.netbeans.modules.web.context.Bundle","Templates/JSP_Servlet/webapp.warImage");
        String path = Test_Support.getTestDir(this.getName());
        new RepositoryTabOperator().mountLocalDirectoryAPI(path);
        new ActionNoBlock("File|New", null).perform();
        WizardOperator wzd = new WizardOperator(Bundle.getString("org.netbeans.core.ui.Bundle","CTL_New"));
        new ChooseTemplateStepOperator().selectTemplate(m_path2+ssep+m_path3);
        wzd.next();
        JTextFieldOperator dirOpr = new JTextFieldOperator(wzd);
        dirOpr.clearText();
        dirOpr.typeText(path);
        wzd.finish();
        Test_Support.sleep();        
        assertTrue(verify_webmodule(path));
    }

    public void test_WebModuleCreation_dir_and_files_exist() {
        String m_path2 = Bundle.getString("org.netbeans.modules.web.core.Bundle","Templates/JSP_Servlet");
        String m_path3 = Bundle.getString("org.netbeans.modules.web.context.Bundle","Templates/JSP_Servlet/webapp.warImage");
        String m_path4 = Bundle.getString("org.netbeans.modules.web.core.Bundle","Templates/JSP_Servlet/JSP.jsp");
        String path = Test_Support.getTestDir(this.getName());
        new RepositoryTabOperator().mountLocalDirectoryAPI(path);
        new FilesystemNode(path).select();
        new ActionNoBlock("File|New", null).perform();
        WizardOperator wzd = new WizardOperator(Bundle.getString("org.netbeans.core.ui.Bundle","CTL_New"));
        new ChooseTemplateStepOperator().selectTemplate(m_path2+ssep+m_path4);
        wzd.next();
        wzd.finish();
        new FilesystemNode(path).select();
        new ActionNoBlock("File|New", null).perform();
        wzd = new WizardOperator(Bundle.getString("org.netbeans.core.ui.Bundle","CTL_New"));
        new ChooseTemplateStepOperator().selectTemplate(m_path2+ssep+m_path4);
        wzd.next();
        wzd.finish();
        Test_Support.sleep();
        new FilesystemNode(path).select();
        new ActionNoBlock("File|New", null).perform();
        wzd = new WizardOperator(Bundle.getString("org.netbeans.core.ui.Bundle","CTL_New"));
        new ChooseTemplateStepOperator().selectTemplate(m_path2+ssep+m_path3);
        wzd.next();
        JTextFieldOperator dirOpr = new JTextFieldOperator(wzd);
        dirOpr.clearText();
        dirOpr.typeText(path);
        wzd.finish();
        Test_Support.sleep();        
        assertTrue(verify_webmodule(path));
    }
       
    
    public boolean verify_webmodule(String path){
        return (Test_Support.isFileExist(path+fsep+"WEB-INF") && Test_Support.isFileExist(path+fsep+"WEB-INF"+fsep+"web.xml"));
        
    }
    
}
... 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.