001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 2002 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.tasklist.trampoline;
043:
044: import java.util.List;
045: import junit.framework.*;
046: import org.netbeans.junit.*;
047: import org.netbeans.modules.tasklist.trampoline.TaskGroupFactory;
048:
049: /**
050: * Tests for TaskGroup class.
051: *
052: * @author S. Aubrecht
053: */
054: public class TaskGroupFactoryTest extends NbTestCase {
055:
056: public static final String TASK_GROUP_NAME_A = "nb-tasklist-unittestA";
057: public static final String TASK_GROUP_DISPLAY_NAME_A = "unitTestGroupLabelA";
058: public static final String TASK_GROUP_DESCRIPTION_A = "unitTestGroupDescriptionA";
059:
060: public static final String TASK_GROUP_NAME_B = "nb-tasklist-unittestB";
061: public static final String TASK_GROUP_DISPLAY_NAME_B = "unitTestGroupLabelB";
062: public static final String TASK_GROUP_DESCRIPTION_B = "unitTestGroupDescriptionB";
063:
064: public static final String TASK_GROUP_NAME_C = "nb-tasklist-unittestC";
065: public static final String TASK_GROUP_DISPLAY_NAME_C = "unitTestGroupLabelC";
066: public static final String TASK_GROUP_DESCRIPTION_C = "unitTestGroupDescriptionC";
067:
068: static {
069: String[] layers = new String[] { "org/netbeans/modules/tasklist/trampoline/resources/mf-layer.xml" };//NOI18N
070: IDEInitializer.setup(layers, new Object[0]);
071: }
072:
073: public TaskGroupFactoryTest(String name) {
074: super (name);
075: }
076:
077: @Override
078: protected void setUp() throws Exception {
079: super .setUp();
080: }
081:
082: /**
083: * @param args the command line arguments
084: */
085: public static void main(java.lang.String[] args) {
086: junit.textui.TestRunner.run(suite());
087: }
088:
089: public static Test suite() {
090: TestSuite suite = new NbTestSuite(TaskGroupFactoryTest.class);
091:
092: return suite;
093: }
094:
095: public void testGetGroup() {
096: TaskGroupFactory factory = TaskGroupFactory.getDefault();
097:
098: List<? extends TaskGroup> groups = factory.getGroups();
099:
100: assertEquals(2, groups.size());
101:
102: TaskGroup tgA = groups.get(0);
103: assertEquals(TASK_GROUP_NAME_A, tgA.getName());
104: assertEquals(TASK_GROUP_DISPLAY_NAME_A, tgA.getDisplayName());
105: assertEquals(TASK_GROUP_DESCRIPTION_A, tgA.getDescription());
106:
107: TaskGroup tgB = groups.get(1);
108: assertEquals(TASK_GROUP_NAME_B, tgB.getName());
109: assertEquals(TASK_GROUP_DISPLAY_NAME_B, tgB.getDisplayName());
110: assertEquals(TASK_GROUP_DESCRIPTION_B, tgB.getDescription());
111:
112: assertFalse(tgA.equals(tgB));
113:
114: TaskGroup group = factory.getGroup(TASK_GROUP_NAME_A);
115: assertNotNull(group);
116: assertEquals(TASK_GROUP_NAME_A, group.getName());
117:
118: group = factory.getGroup(TASK_GROUP_NAME_B);
119: assertNotNull(group);
120:
121: group = factory.getGroup("unknown group name");
122: assertNull(group);
123:
124: assertNotNull(factory.getDefaultGroup());
125:
126: try {
127: factory.getGroup(null);
128: fail("null group name is not acceptable");
129: } catch (AssertionError e) {
130: //expected
131: }
132: }
133:
134: public void testCreate() {
135: TaskGroup group = TaskGroupFactory
136: .create(
137: TASK_GROUP_NAME_C,
138: "org.netbeans.modules.tasklist.trampoline.resources.Bundle",
139: "LBL_unittest_groupC", "HINT_unittest_groupC",
140: "ICON_unittestgroupC");
141:
142: assertNotNull(group);
143: assertEquals(TASK_GROUP_NAME_C, group.getName());
144: assertEquals(TASK_GROUP_DISPLAY_NAME_C, group.getDisplayName());
145: assertEquals(TASK_GROUP_DESCRIPTION_C, group.getDescription());
146: }
147: }
|