1 17 18 package org.netbeans.lib.uihandlerserver; 19 20 import java.io.ByteArrayInputStream ; 21 import java.io.InputStream ; 22 import java.util.logging.Level ; 23 import java.util.logging.LogRecord ; 24 import java.util.logging.Logger ; 25 import org.netbeans.junit.NbTestCase; 26 import org.netbeans.lib.uihandler.LogRecords; 27 import org.netbeans.lib.uihandler.ProjectOp; 28 29 33 public class ProjectOpTest extends NbTestCase { 34 private Logger LOG; 35 36 public ProjectOpTest(String testName) { 37 super(testName); 38 } 39 40 protected Level logLevel() { 41 return Level.FINEST; 42 } 43 44 protected void setUp() throws Exception { 45 LOG = Logger.getLogger("TEST-" + getName()); 46 } 47 48 protected void tearDown() throws Exception { 49 } 50 51 public void testOpenAndCloseAProject() throws Exception { 52 String what = "<record>" + 53 "<date>2007-02-05T14:14:17</date>" + 54 "<millis>1170681257194</millis>" + 55 "<sequence>1148</sequence>" + 56 "<logger>org.netbeans.ui.projects</logger>" + 57 "<level>CONFIG</level>" + 58 "<thread>11</thread>" + 59 "<message>Closing 1 NbModuleProject Projects</message>" + 60 "<key>UI_CLOSED_PROJECTS</key>" + 61 "<catalog><null></catalog>" + 62 "<param>org.netbeans.modules.apisupport.project.NbModuleProject</param>" + 63 "<param>NbModuleProject</param>" + 64 "<param>1</param>" + 65 "</record>" + 66 "<record>" + 67 "<date>2007-02-06T09:08:03</date>" + 68 "<millis>1170749283986</millis>" + 69 "<sequence>1441</sequence>" + 70 "<logger>org.netbeans.ui.actions.editor</logger>" + 71 "<level>FINE</level>" + 72 "<thread>11</thread>" + 73 "<message>Invoking copy-to-clipboard implemented as org.netbeans.editor.BaseKit$CopyAction@e29e2c thru java.awt.event.ActionEvent[ACTION_PERFORMED,cmd=,when=1170749283985,modifiers=Ctrl] on org.openide.text.QuietEditorPane[,0,-931,1048x1485,layout=javax.swing.plaf.basic.BasicTextUI$UpdateHandler,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.basic.BasicBorders$MarginBorder@aec245,flags=296,maximumSize=,minimumSize=,preferredSize=,caretColor=java.awt.Color[r=255,g=255,b=255],disabledTextColor=javax.swing.plaf.ColorUIResource[r=184,g=207,b=229],editable=true,margin=java.awt.Insets[top=0,left=0,bottom=0,right=0],selectedTextColor=sun.swing.PrintColorUIResource[r=51,g=51,b=51],selectionColor=javax.swing.plaf.ColorUIResource[r=184,g=207,b=229],kit=org.netbeans.modules.editor.java.JavaKit@1e6cecc,typeHandlers=]</message>" + 74 "<key>UI_ACTION_EDITOR</key>" + 75 "<catalog><null></catalog>" + 76 "<param>java.awt.event.ActionEvent[ACTION_PERFORMED,cmd=,when=1170749283985,modifiers=Ctrl] on org.openide.text.QuietEditorPane[,0,-931,1041x1515,layout=javax.swing.plaf.basic.BasicTextUI$UpdateHandler,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.basic.BasicBorders$MarginBorder@aec245,flags=296,maximumSize=,minimumSize=,preferredSize=,caretColor=java.awt.Color[r=255,g=255,b=255],disabledTextColor=javax.swing.plaf.ColorUIResource[r=184,g=207,b=229],editable=true,margin=java.awt.Insets[top=0,left=0,bottom=0,right=0],selectedTextColor=sun.swing.PrintColorUIResource[r=51,g=51,b=51],selectionColor=javax.swing.plaf.ColorUIResource[r=184,g=207,b=229],kit=org.netbeans.modules.editor.java.JavaKit@1e6cecc,typeHandlers=]</param>" + 77 "<param>java.awt.event.ActionEvent[ACTION_PERFORMED,cmd=,when=1170749283985,modifiers=Ctrl] on org.openide.text.QuietEditorPane[,0,-931,1048x1485,layout=javax.swing.plaf.basic.BasicTextUI$UpdateHandler,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.basic.BasicBorders$MarginBorder@aec245,flags=296,maximumSize=,minimumSize=,preferredSize=,caretColor=java.awt.Color[r=255,g=255,b=255],disabledTextColor=javax.swing.plaf.ColorUIResource[r=184,g=207,b=229],editable=true,margin=java.awt.Insets[top=0,left=0,bottom=0,right=0],selectedTextColor=sun.swing.PrintColorUIResource[r=51,g=51,b=51],selectionColor=javax.swing.plaf.ColorUIResource[r=184,g=207,b=229],kit=org.netbeans.modules.editor.java.JavaKit@1e6cecc,typeHandlers=]</param>" + 78 "<param>org.netbeans.editor.BaseKit$CopyAction@e29e2c</param>" + 79 "<param>org.netbeans.editor.BaseKit$CopyAction@e29e2c</param>" + 80 "<param>copy-to-clipboard</param>" + 81 "</record>" + 82 "<record>" + 83 " <date>2007-02-06T09:05:59</date>" + 84 " <millis>1170749159147</millis>" + 85 " <sequence>1399</sequence>" + 86 " <logger>org.netbeans.ui.projects</logger>" + 87 " <level>CONFIG</level>" + 88 " <thread>11</thread>" + 89 " <message>Opening 1 NbModuleProject Projects</message>" + 90 " <key>UI_OPEN_PROJECTS</key>" + 91 " <catalog><null></catalog>" + 92 " <param>org.netbeans.modules.apisupport.project.NbModuleProject</param>" + 93 " <param>NbModuleProject</param>" + 94 " <param>1</param>" + 95 "</record>"; 96 97 InputStream is = new ByteArrayInputStream (what.getBytes()); 98 LogRecord rec = LogRecords.read(is); 99 LogRecord rec2 = LogRecords.read(is); 100 LogRecord rec3 = LogRecords.read(is); 101 is.close(); 102 103 ProjectOp op = ProjectOp.valueOf(rec); 104 105 assertNotNull("This record is project operation", op); 106 assertEquals("org.netbeans.modules.apisupport.project.NbModuleProject", op.getProjectType()); 107 assertEquals(-1, op.getDelta()); 108 assertEquals("NbModuleProject", op.getProjectDisplayName()); 109 110 111 op = ProjectOp.valueOf(rec2); 112 assertNull("No project operation", op); 113 114 op = ProjectOp.valueOf(rec3); 115 assertNotNull("This record is project operation", op); 116 assertEquals("org.netbeans.modules.apisupport.project.NbModuleProject", op.getProjectType()); 117 assertEquals("One project added", 1, op.getDelta()); 118 assertEquals("NbModuleProject", op.getProjectDisplayName()); 119 120 } 121 122 123 124 } 125 126 127 | Popular Tags |