1 19 20 package org.netbeans.test.j2ee; 21 22 import java.io.File ; 23 import java.io.IOException ; 24 import junit.textui.TestRunner; 25 import org.netbeans.jellytools.Bundle; 26 import org.netbeans.jellytools.EditorOperator; 27 import org.netbeans.jellytools.EditorWindowOperator; 28 import org.netbeans.jellytools.JellyTestCase; 29 import org.netbeans.jellytools.NbDialogOperator; 30 import org.netbeans.jellytools.ProjectsTabOperator; 31 import org.netbeans.jellytools.nodes.Node; 32 import org.netbeans.jemmy.TimeoutExpiredException; 33 import org.openide.filesystems.FileStateInvalidException; 34 35 39 public class GenerateDTOTest extends JellyTestCase { 40 private static String beanName = "TestingEntity"; 41 private static String dtoName = beanName + "DTO"; 42 43 public static File getFile(String fileName) { 45 String result = EJBValidation.EJB_PROJECT_PATH + File.separator + "src" + File.separator + "java" + File.separator 46 + "test" + File.separator + fileName; 47 return new File (result); 48 } 49 50 51 public GenerateDTOTest(String name) { 52 super(name); 53 } 54 55 56 public static void main(java.lang.String [] args) { 57 TestRunner.run(new GenerateDTOTest("testGenerateDTO")); 59 TestRunner.run(new GenerateDTOTest("testDeleteDTO")); 60 } 61 62 public void testGenerateDTO() throws FileStateInvalidException, IOException { 63 Node node = new Node(new ProjectsTabOperator().getProjectRootNode(EJBValidation.EJB_PROJECT_NAME), 64 Bundle.getStringTrimmed("org.netbeans.modules.j2ee.ejbjar.project.ui.Bundle", "LBL_node") 65 +"|"+beanName); 66 node.performPopupAction(org.netbeans.jellytools.Bundle.getStringTrimmed("org.netbeans.modules.j2ee.ejbcore.ui.logicalview.ejb.action.Bundle", "LBL_GenerateDTOAction")); 67 deleteDateAndAuthor(); 69 assertFile(getFile(dtoName + ".java"), getGoldenFile(), new File (getWorkDir(),"testGenerateDTO.diff")); 70 } 71 72 73 public void testDeleteDTO(){ 74 new org.netbeans.jemmy.EventTool().waitNoEvent(5000); 75 Node node = new Node(new ProjectsTabOperator().getProjectRootNode(EJBValidation.EJB_PROJECT_NAME), 76 Bundle.getStringTrimmed("org.netbeans.modules.j2ee.ejbjarproject.Bundle", "NAME_src.dir") + 77 "|" + "test" + "|" + dtoName + ".java"); 78 node.performPopupAction(Bundle.getStringTrimmed("org.openide.actions.Bundle", "Delete")); 79 new NbDialogOperator(Bundle.getStringTrimmed("org.openide.explorer.Bundle", "MSG_ConfirmDeleteObjectTitle")).yes(); 80 try{ node = new Node(new ProjectsTabOperator().getProjectRootNode(EJBValidation.EJB_PROJECT_PATH), 82 Bundle.getStringTrimmed("org.netbeans.modules.j2ee.ejbjarproject.Bundle", "NAME_src.dir") + 83 "|" + "test" + "|" + dtoName + ".java"); 84 fail("Node wasn't deleted."); 85 }catch(TimeoutExpiredException ex){ 86 } 88 assertFalse("File " + dtoName + ".java isn't deleted.", getFile(dtoName + ".java").exists()); } 90 91 private void deleteDateAndAuthor(){ 92 final EditorOperator editor = new EditorWindowOperator().getEditor(dtoName); 93 new org.netbeans.jemmy.EventTool().waitNoEvent(3000); 94 editor.deleteLine(11); editor.deleteLine(10); editor.save(); 97 editor.close(); 98 } 99 100 } 101 | Popular Tags |