KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > lib > uihandlerserver > ProjectOpTest


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
16  */

17
18 package org.netbeans.lib.uihandlerserver;
19
20 import java.io.ByteArrayInputStream JavaDoc;
21 import java.io.InputStream JavaDoc;
22 import java.util.logging.Level JavaDoc;
23 import java.util.logging.LogRecord JavaDoc;
24 import java.util.logging.Logger JavaDoc;
25 import org.netbeans.junit.NbTestCase;
26 import org.netbeans.lib.uihandler.LogRecords;
27 import org.netbeans.lib.uihandler.ProjectOp;
28
29 /**
30  *
31  * @author Jaroslav Tulach
32  */

33 public class ProjectOpTest extends NbTestCase {
34     private Logger JavaDoc LOG;
35     
36     public ProjectOpTest(String JavaDoc testName) {
37         super(testName);
38     }
39     
40     protected Level JavaDoc logLevel() {
41         return Level.FINEST;
42     }
43
44     protected void setUp() throws Exception JavaDoc {
45         LOG = Logger.getLogger("TEST-" + getName());
46     }
47
48     protected void tearDown() throws Exception JavaDoc {
49     }
50
51     public void testOpenAndCloseAProject() throws Exception JavaDoc {
52         String JavaDoc 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>&lt;null&gt;</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>&lt;null&gt;</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>&lt;null&gt;</catalog>" +
92             " <param>org.netbeans.modules.apisupport.project.NbModuleProject</param>" +
93             " <param>NbModuleProject</param>" +
94             " <param>1</param>" +
95             "</record>";
96
97         InputStream JavaDoc is = new ByteArrayInputStream JavaDoc(what.getBytes());
98         LogRecord JavaDoc rec = LogRecords.read(is);
99         LogRecord JavaDoc rec2 = LogRecords.read(is);
100         LogRecord JavaDoc 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