This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 70330
Collapse All | Expand All

(-)src/org/netbeans/modules/apisupport/project/ui/UIUtil.java (-1 / +1 lines)
Lines 313-319 Link Here
313
        public int compareTo(Object o) {
313
        public int compareTo(Object o) {
314
            int res = Collator.getInstance().compare(getDisplayName(),
314
            int res = Collator.getInstance().compare(getDisplayName(),
315
                    ((LayerItemPresenter) o).getDisplayName());
315
                    ((LayerItemPresenter) o).getDisplayName());
316
            if (res != -1) {
316
            if (res != 0) {
317
                return res;
317
                return res;
318
            } else {
318
            } else {
319
                return getFullPath().compareTo(((LayerItemPresenter) o).getFullPath());
319
                return getFullPath().compareTo(((LayerItemPresenter) o).getFullPath());
(-)src/org/netbeans/modules/apisupport/project/ui/customizer/ModuleDependency.java (-1 / +1 lines)
Lines 90-96 Link Here
90
        int result = LOC_COLLATOR.compare(
90
        int result = LOC_COLLATOR.compare(
91
            getModuleEntry().getLocalizedName(),
91
            getModuleEntry().getLocalizedName(),
92
            ((ModuleDependency) o).getModuleEntry().getLocalizedName());
92
            ((ModuleDependency) o).getModuleEntry().getLocalizedName());
93
        if (result != -1) {
93
        if (result != 0) {
94
            return result;
94
            return result;
95
        } else {
95
        } else {
96
            return getModuleEntry().getCodeNameBase().compareTo(((ModuleDependency) o).getModuleEntry().getCodeNameBase());
96
            return getModuleEntry().getCodeNameBase().compareTo(((ModuleDependency) o).getModuleEntry().getCodeNameBase());
(-)src/org/netbeans/modules/apisupport/project/ui/platform/PlatformComponentFactory.java (-1 / +1 lines)
Lines 144-150 Link Here
144
            Arrays.sort(platforms, new Comparator() {
144
            Arrays.sort(platforms, new Comparator() {
145
                public int compare(Object o1, Object o2) {
145
                public int compare(Object o1, Object o2) {
146
                    int res = Collator.getInstance().compare(((NbPlatform) o1).getLabel(), ((NbPlatform) o2).getLabel());
146
                    int res = Collator.getInstance().compare(((NbPlatform) o1).getLabel(), ((NbPlatform) o2).getLabel());
147
                    if (res != -1) {
147
                    if (res != 0) {
148
                        return res;
148
                        return res;
149
                    } else {
149
                    } else {
150
                        return System.identityHashCode(o1) - System.identityHashCode(o2);
150
                        return System.identityHashCode(o1) - System.identityHashCode(o2);
(-)test/unit/src/org/netbeans/modules/apisupport/project/BrokenPlatformReferenceTest.java (-12 / +2 lines)
Lines 14-22 Link Here
14
package org.netbeans.modules.apisupport.project;
14
package org.netbeans.modules.apisupport.project;
15
15
16
import java.io.File;
16
import java.io.File;
17
import java.io.IOException;
18
import java.util.Collections;
17
import java.util.Collections;
19
import java.util.jar.Manifest;
20
import org.netbeans.api.project.ProjectManager;
18
import org.netbeans.api.project.ProjectManager;
21
import org.netbeans.junit.NbTestCase;
19
import org.netbeans.junit.NbTestCase;
22
import org.netbeans.modules.apisupport.project.suite.SuiteProject;
20
import org.netbeans.modules.apisupport.project.suite.SuiteProject;
Lines 55-78 Link Here
55
        user.mkdirs();
53
        user.mkdirs();
56
        System.setProperty("netbeans.user", user.getAbsolutePath());
54
        System.setProperty("netbeans.user", user.getAbsolutePath());
57
        install = new File(getWorkDir(), "install");
55
        install = new File(getWorkDir(), "install");
58
        makePlatform(install);
56
        TestBase.makePlatform(install);
59
        // Now set up build.properties accordingly:
57
        // Now set up build.properties accordingly:
60
        InstalledFileLocatorImpl.registerDestDir(install);
58
        InstalledFileLocatorImpl.registerDestDir(install);
61
        ((Install) SharedClassObject.findObject(Install.class, true)).restored();
59
        ((Install) SharedClassObject.findObject(Install.class, true)).restored();
62
        assertEquals("set up run correctly", install.getAbsolutePath(), PropertyUtils.getGlobalProperties().getProperty("nbplatform.default.netbeans.dest.dir"));
60
        assertEquals("set up run correctly", install.getAbsolutePath(), PropertyUtils.getGlobalProperties().getProperty("nbplatform.default.netbeans.dest.dir"));
63
        install2 = new File(getWorkDir(), "install2");
61
        install2 = new File(getWorkDir(), "install2");
64
        makePlatform(install2);
62
        TestBase.makePlatform(install2);
65
        NbPlatform.addPlatform("install2", install2, "install2");
63
        NbPlatform.addPlatform("install2", install2, "install2");
66
    }
64
    }
67
    
65
    
68
    private static void makePlatform(File d) throws IOException {
69
        // To satisfy NbPlatform.defaultPlatformLocation and NbPlatform.isValid, and make at least one module:
70
        Manifest mani = new Manifest();
71
        mani.getMainAttributes().putValue("OpenIDE-Module", "core");
72
        TestBase.createJar(new File(new File(new File(d, "platform"), "core"), "core.jar"), Collections.EMPTY_MAP, mani);
73
        TestBase.dump(new File(new File(d, "harness"), "suite.xml"), "");
74
    }
75
    
76
    /** Make sure everything is working as expected when there are no breakages. */
66
    /** Make sure everything is working as expected when there are no breakages. */
77
    public void testEverythingNormal() throws Exception {
67
    public void testEverythingNormal() throws Exception {
78
        // Try making a standalone module w/ default platform, confirm loaded OK.
68
        // Try making a standalone module w/ default platform, confirm loaded OK.
(-)test/unit/src/org/netbeans/modules/apisupport/project/TestBase.java (+9 lines)
Lines 24-29 Link Here
24
import java.io.OutputStream;
24
import java.io.OutputStream;
25
import java.io.OutputStreamWriter;
25
import java.io.OutputStreamWriter;
26
import java.io.Writer;
26
import java.io.Writer;
27
import java.util.Collections;
27
import java.util.HashMap;
28
import java.util.HashMap;
28
import java.util.HashSet;
29
import java.util.HashSet;
29
import java.util.Iterator;
30
import java.util.Iterator;
Lines 392-397 Link Here
392
        }
393
        }
393
    }
394
    }
394
395
396
    public static void makePlatform(File d) throws IOException {
397
        // To satisfy NbPlatform.defaultPlatformLocation and NbPlatform.isValid, and make at least one module:
398
        Manifest mani = new Manifest();
399
        mani.getMainAttributes().putValue("OpenIDE-Module", "core");
400
        TestBase.createJar(new File(new File(new File(d, "platform"), "core"), "core.jar"), Collections.EMPTY_MAP, mani);
401
        TestBase.dump(new File(new File(d, "harness"), "suite.xml"), "");
402
    }
403
    
395
    public static void delete(File f) throws IOException {
404
    public static void delete(File f) throws IOException {
396
        if (f.isDirectory()) {
405
        if (f.isDirectory()) {
397
            File[] kids = f.listFiles();
406
            File[] kids = f.listFiles();
(-)test/unit/src/org/netbeans/modules/apisupport/project/ui/UIUtilTest.java (-1 / +24 lines)
Lines 18-25 Link Here
18
import javax.swing.ComboBoxModel;
18
import javax.swing.ComboBoxModel;
19
import javax.swing.KeyStroke;
19
import javax.swing.KeyStroke;
20
import org.netbeans.api.project.Project;
20
import org.netbeans.api.project.Project;
21
import org.netbeans.modules.apisupport.project.NbModuleProject;
21
import org.netbeans.modules.apisupport.project.TestBase;
22
import org.netbeans.modules.apisupport.project.TestBase;
22
import org.netbeans.modules.apisupport.project.layers.LayerTestBase;
23
import org.netbeans.modules.apisupport.project.layers.LayerTestBase;
24
import org.netbeans.modules.apisupport.project.layers.LayerUtils;
25
import org.netbeans.modules.apisupport.project.ui.UIUtil.LayerItemPresenter;
26
import org.openide.filesystems.FileObject;
27
import org.openide.filesystems.FileSystem;
23
28
24
/**
29
/**
25
 * @author Martin Krauskopf
30
 * @author Martin Krauskopf
Lines 59-66 Link Here
59
        assertKeyLogicalString("ENTER", "pressed ENTER");
64
        assertKeyLogicalString("ENTER", "pressed ENTER");
60
    }
65
    }
61
    
66
    
62
    public void assertKeyLogicalString(String expected, String swingKeyStroke) {
67
    private void assertKeyLogicalString(String expected, String swingKeyStroke) {
63
        assertEquals(swingKeyStroke + " corresponding to " + expected, expected, UIUtil.keyToLogicalString(KeyStroke.getKeyStroke(swingKeyStroke)));
68
        assertEquals(swingKeyStroke + " corresponding to " + expected, expected, UIUtil.keyToLogicalString(KeyStroke.getKeyStroke(swingKeyStroke)));
69
    }
70
    
71
    public void testLayerItemPresenterCompareTo() throws Exception {
72
        TestBase.initializeBuildProperties(getWorkDir());
73
        NbModuleProject project = TestBase.generateStandaloneModule(getWorkDir(), "module");
74
        FileSystem fs = LayerUtils.getEffectiveSystemFilesystem(project);
75
        FileObject root = fs.getRoot().getFileObject("Templates/Project/APISupport");
76
        FileObject module = root.getFileObject("emptyModule");
77
        FileObject suite = root.getFileObject("emptySuite");
78
        FileObject library = root.getFileObject("libraryModule");
79
        LayerItemPresenter moduleLIP = new LayerItemPresenter(module, root);
80
        LayerItemPresenter moduleLIP1 = new LayerItemPresenter(module, root);
81
        LayerItemPresenter suiteLIP = new LayerItemPresenter(suite, root);
82
        LayerItemPresenter libraryLIP = new LayerItemPresenter(library, root);
83
        assertTrue("'Module Project' < 'Module Suite Project'", moduleLIP.compareTo(suiteLIP) < 0);
84
        assertTrue("'Module Project' == 'Module Project'", moduleLIP.compareTo(moduleLIP1) == 0);
85
        assertTrue("'Library Wrapper Module Project < 'Module Project'", libraryLIP.compareTo(moduleLIP) < 0);
86
        assertTrue("'Library Wrapper Module Project < 'Module Suite Project'", libraryLIP.compareTo(suiteLIP) < 0);
64
    }
87
    }
65
    
88
    
66
}
89
}
(-)test/unit/src/org/netbeans/modules/apisupport/project/ui/customizer/ModuleDependencyTest.java (+59 lines)
Added Link Here
1
/*
2
 *                 Sun Public License Notice
3
 *
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 *
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
14
package org.netbeans.modules.apisupport.project.ui.customizer;
15
16
import java.text.Collator;
17
import org.netbeans.modules.apisupport.project.NbModuleProject;
18
import org.netbeans.modules.apisupport.project.TestBase;
19
import org.netbeans.modules.apisupport.project.universe.ModuleList;
20
import org.openide.filesystems.FileUtil;
21
22
/**
23
 * @author Martin Krauskopf
24
 */
25
public class ModuleDependencyTest extends TestBase {
26
    
27
    public ModuleDependencyTest(String testName) {
28
        super(testName);
29
    }
30
    
31
    public void testCompareTo() throws Exception {
32
        NbModuleProject module = TestBase.generateStandaloneModule(getWorkDir(), "module");
33
        ModuleList ml = ModuleList.getModuleList(FileUtil.toFile(module.getProjectDirectory()));
34
        ModuleDependency[] deps = new ModuleDependency[] {
35
            new ModuleDependency(ml.getEntry("org.apache.tools.ant.module")),
36
            new ModuleDependency(ml.getEntry("org.openide.loaders")),
37
            new ModuleDependency(ml.getEntry("org.apache.tools.ant.module")),
38
            new ModuleDependency(ml.getEntry("org.openide.io")),
39
            new ModuleDependency(ml.getEntry("org.jdesktop.layout")),
40
            new ModuleDependency(ml.getEntry("org.openide.filesystems")),
41
            new ModuleDependency(ml.getEntry("org.openide.execution")),
42
        };
43
        
44
        for (int i = 0; i < deps.length; i++) {
45
            for (int j = 0; j < deps.length; j++) {
46
                int locNameResult = Collator.getInstance().compare(
47
                        deps[i].getModuleEntry().getLocalizedName(),
48
                        deps[j].getModuleEntry().getLocalizedName());
49
                int realResult = deps[i].compareTo(deps[j]);
50
                assertTrue("ordering works: " + deps[i] + " <--> " + deps[j],
51
                        locNameResult > 0 ? realResult > 0 :
52
                            (locNameResult == 0 ? realResult == 0 : realResult < 0));
53
//                (int) Math.signum(locNameResult), (int) Math.signum(realResult));
54
            }
55
        }
56
        
57
    }
58
    
59
}
(-)test/unit/src/org/netbeans/modules/apisupport/project/ui/platform/PlatformComponentFactoryTest.java (+54 lines)
Added Link Here
1
/*
2
 *                 Sun Public License Notice
3
 *
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 *
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
14
package org.netbeans.modules.apisupport.project.ui.platform;
15
16
import java.io.File;
17
import org.netbeans.modules.apisupport.project.TestBase;
18
import org.netbeans.modules.apisupport.project.ui.platform.PlatformComponentFactory.NbPlatformListModel;
19
import org.netbeans.modules.apisupport.project.universe.NbPlatform;
20
21
/**
22
 * @author Martin Krauskopf
23
 */
24
public class PlatformComponentFactoryTest extends TestBase {
25
    
26
    public PlatformComponentFactoryTest(String testName) {
27
        super(testName);
28
    }
29
    
30
    public void testNbPlatformListModelSorting() throws Exception {
31
        File first = new File(getWorkDir(), "first");
32
        TestBase.makePlatform(first);
33
        NbPlatform.addPlatform("first", first, "AAA first");
34
35
        File between = new File(getWorkDir(), "between");
36
        TestBase.makePlatform(between);
37
        NbPlatform.addPlatform("between", between, "KKK between");
38
39
        File last = new File(getWorkDir(), "last");
40
        TestBase.makePlatform(last);
41
        NbPlatform.addPlatform("last", last, "ZZZ last");
42
        
43
        NbPlatform.reset();
44
        
45
        NbPlatformListModel model = new NbPlatformListModel();
46
        assertEquals("four platforms " + NbPlatform.getPlatforms(), 5, model.getSize());
47
        assertSame("first (AAA first)", NbPlatform.getPlatformByID("first"), model.getElementAt(0));
48
        assertSame("second (Invalid Platform)", NbPlatform.getPlatformByID("custom"), model.getElementAt(1));
49
        assertSame("third (KKK between)", NbPlatform.getPlatformByID("between"), model.getElementAt(2));
50
        assertSame("fourth (NetBeans IDE....)", NbPlatform.getDefaultPlatform(), model.getElementAt(3));
51
        assertSame("fifth (ZZZ last)", NbPlatform.getPlatformByID("last"), model.getElementAt(4));
52
    }
53
    
54
}

Return to bug 70330