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 156158
Collapse All | Expand All

(-)a/core.startup/src/org/netbeans/core/startup/layers/BinaryFS.java (-1 / +1 lines)
Lines 385-391 Link Here
385
385
386
                ThreadLocal<?> attrAskedFileObject = ThreadLocal.class.cast(field.get(null));
386
                ThreadLocal<?> attrAskedFileObject = ThreadLocal.class.cast(field.get(null));
387
                topFO = (FileObject)attrAskedFileObject.get();
387
                topFO = (FileObject)attrAskedFileObject.get();
388
                attrAskedFileObject.set(null);
388
                //attrAskedFileObject.set(null);
389
            } catch (Exception e) {
389
            } catch (Exception e) {
390
                Exceptions.printStackTrace(e);
390
                Exceptions.printStackTrace(e);
391
            }
391
            }
(-)d536b9e45a9a (+105 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * Contributor(s):
25
 *
26
 * The Original Software is NetBeans. The Initial Developer of the Original
27
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
 * Microsystems, Inc. All Rights Reserved.
29
 *
30
 * If you wish your version of this file to be governed by only the CDDL
31
 * or only the GPL Version 2, indicate your decision by adding
32
 * "[Contributor] elects to include this software in this distribution
33
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
34
 * single choice of license, a recipient has the option to distribute
35
 * your version of this file under either the CDDL, the GPL Version 2 or
36
 * to extend the choice of license to its licensees as provided above.
37
 * However, if you add GPL Version 2 code and therefore, elected the GPL
38
 * Version 2 license, then the option applies only if the new code is
39
 * made subject to such option by the copyright holder.
40
 */
41
42
package org.netbeans.core.startup.layers;
43
44
import java.io.File;
45
import java.io.IOException;
46
import java.net.URL;
47
import java.util.Arrays;
48
import junit.framework.Test;
49
import org.netbeans.junit.NbTestSuite;
50
import org.openide.filesystems.AttributesTestHidden;
51
import org.openide.filesystems.FileObjectTestHid;
52
import org.openide.filesystems.FileSystem;
53
import org.openide.filesystems.FileSystemFactoryHid;
54
import org.openide.filesystems.FileSystemTestHid;
55
import org.openide.filesystems.MultiFileSystem;
56
import org.openide.filesystems.TestUtilHid;
57
import org.openide.filesystems.XMLFileSystem;
58
import org.openide.filesystems.XMLFileSystemTestHid;
59
60
/**
61
 *
62
 * @author Radek Matous
63
 */
64
public class BinaryFSBehindMultiFSTest extends FileSystemFactoryHid
65
implements XMLFileSystemTestHid.Factory {
66
    public BinaryFSBehindMultiFSTest(Test test) {
67
        super(test);
68
    }
69
70
    public static Test suite() {
71
        NbTestSuite suite = new NbTestSuite();
72
        suite.addTestSuite(FileSystemTestHid.class);
73
        suite.addTestSuite(FileObjectTestHid.class);
74
        suite.addTestSuite(AttributesTestHidden.class);
75
        suite.addTestSuite(XMLFileSystemTestHid.class);
76
         
77
        return new BinaryFSBehindMultiFSTest(suite);
78
    }
79
    
80
    protected FileSystem[] createFileSystem(String testName, String[] resources) throws IOException {
81
        XMLFileSystem xfs = (XMLFileSystem)TestUtilHid.createXMLFileSystem(testName, resources);
82
        LayerCacheManager bm = LayerCacheManager.manager(true);
83
        return new FileSystem[] {BinaryCacheManagerTest.store(bm, Arrays.asList(xfs.getXmlUrls()))};
84
    }
85
86
    protected void destroyFileSystem(String testName) throws IOException {
87
    }
88
89
    private File getWorkDir() {
90
        String workDirProperty = System.getProperty("workdir");//NOI18N
91
        workDirProperty = (workDirProperty != null) ? workDirProperty : System.getProperty("java.io.tmpdir");//NOI18N                 
92
        return new File(workDirProperty);
93
    }
94
95
    public FileSystem createLayerSystem(String testName, URL[] layers) throws IOException {
96
        LayerCacheManager bm = LayerCacheManager.manager(true);
97
        return new MultiFileSystem(new FileSystem[] {
98
            BinaryCacheManagerTest.store(bm, Arrays.asList(layers))
99
        });
100
    }
101
102
    public boolean setXmlUrl(FileSystem fs, URL[] layers) throws IOException {
103
        return false;
104
    }
105
}
(-)a/openide.filesystems/src/org/openide/filesystems/MultiFileObject.java (-5 / +3 lines)
Lines 814-822 Link Here
814
    private Object getAttribute(FileObject fo, String attrName, String path) {
814
    private Object getAttribute(FileObject fo, String attrName, String path) {
815
        Object o;
815
        Object o;
816
816
817
        FileObject topFO = attrAskedFileObject.get();
817
        FileObject previousFO = attrAskedFileObject.get();
818
818
819
        if (topFO == null) {
819
        if (previousFO == null || !previousFO.getPath().equals(getPath()))  {
820
            attrAskedFileObject.set(this);
820
            attrAskedFileObject.set(this);
821
        }
821
        }
822
822
Lines 829-838 Link Here
829
                o = fo.getAttribute(attrName);
829
                o = fo.getAttribute(attrName);
830
            }
830
            }
831
        } finally {
831
        } finally {
832
            if (topFO == null) {
832
            attrAskedFileObject.set(previousFO);
833
                attrAskedFileObject.set(null);
834
            }
833
            }
835
        }
836
834
837
        if (o != null) {
835
        if (o != null) {
838
            getAttributeCache().setDelegate(fo);
836
            getAttributeCache().setDelegate(fo);
(-)d536b9e45a9a (+110 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * Contributor(s):
25
 *
26
 * The Original Software is NetBeans. The Initial Developer of the Original
27
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
 * Microsystems, Inc. All Rights Reserved.
29
 *
30
 * If you wish your version of this file to be governed by only the CDDL
31
 * or only the GPL Version 2, indicate your decision by adding
32
 * "[Contributor] elects to include this software in this distribution
33
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
34
 * single choice of license, a recipient has the option to distribute
35
 * your version of this file under either the CDDL, the GPL Version 2 or
36
 * to extend the choice of license to its licensees as provided above.
37
 * However, if you add GPL Version 2 code and therefore, elected the GPL
38
 * Version 2 license, then the option applies only if the new code is
39
 * made subject to such option by the copyright holder.
40
 */
41
42
package org.openide.filesystems;
43
44
import java.beans.PropertyVetoException;
45
import java.io.IOException;
46
import java.net.URL;
47
import junit.framework.Test;
48
import org.netbeans.junit.*;
49
50
/**
51
 *
52
 * @author  rm111737
53
 * @version
54
 */
55
public class MultiFileSystemXMLTest extends FileSystemFactoryHid
56
implements XMLFileSystemTestHid.Factory {
57
58
    /** Creates new XMLFileSystemTest */
59
    public MultiFileSystemXMLTest(Test test) {
60
        super(test);
61
    }
62
63
    public static Test suite() {
64
        NbTestSuite suite = new NbTestSuite();
65
        suite.addTestSuite(FileSystemTestHid.class);
66
        suite.addTestSuite(FileObjectTestHid.class);
67
        suite.addTestSuite(XMLFileSystemTestHid.class);        
68
                
69
        return new MultiFileSystemXMLTest(suite);
70
    }
71
72
    protected void destroyFileSystem(String testName) throws IOException {}
73
    
74
    protected FileSystem[] createFileSystem(String testName, String[] resources) throws IOException {
75
        return new FileSystem[] {TestUtilHid.createXMLFileSystem(testName, resources)};
76
    }
77
78
    public FileSystem createLayerSystem(String testName, URL[] layers) throws IOException {
79
        MFS mfs = new MFS();
80
        try {
81
            mfs.xfs.setXmlUrls(layers);
82
        } catch (PropertyVetoException ex) {
83
            throw (IOException)new IOException().initCause(ex);
84
        }
85
        return mfs;
86
    }
87
88
    public boolean setXmlUrl(org.openide.filesystems.FileSystem fs, URL[] layers) throws IOException {
89
        MFS mfs = (MFS)fs;
90
        try {
91
            mfs.xfs.setXmlUrls(layers);
92
        } catch (PropertyVetoException ex) {
93
            throw (IOException)new IOException().initCause(ex);
94
        }
95
        return true;
96
    }
97
    
98
99
    private static final class MFS extends MultiFileSystem {
100
        private XMLFileSystem xfs;
101
        public MFS() {
102
            this(new XMLFileSystem());
103
        }
104
105
        private MFS(XMLFileSystem fs) {
106
            super(new FileSystem[] { fs });
107
            this.xfs = fs;
108
        }
109
    }
110
}
(-)a/openide.filesystems/test/unit/src/org/openide/filesystems/XMLFileSystemTest.java (-1 lines)
Lines 46-52 Link Here
46
import junit.framework.*;
46
import junit.framework.*;
47
import java.io.*;
47
import java.io.*;
48
import org.netbeans.junit.*;
48
import org.netbeans.junit.*;
49
import org.openide.util.Exceptions;
50
49
51
/**
50
/**
52
 *
51
 *
(-)a/openide.filesystems/test/unit/src/org/openide/filesystems/XMLFileSystemTestHid.java (+27 lines)
Lines 487-492 Link Here
487
      assertNotNull("Value returned", obj);
487
      assertNotNull("Value returned", obj);
488
      assertEquals("works for bundle key", "Hello World!", obj);
488
      assertEquals("works for bundle key", "Hello World!", obj);
489
    }
489
    }
490
    public void testPeerAttribute() throws Exception {
491
      URL fsURLDef = XMLFileSystemTestHid.class.getResource("data/Attributes.xml");
492
      assertTrue ("Cannot create XML FS for testing purposes", fsURLDef != null);
493
      FileSystem fs = FileSystemFactoryHid.createXMLSystem(getName(), this, fsURLDef);
494
      root = fs.getRoot();
495
      FileObject fo = fs.findResource("peer/base");
496
      FileObject peer = fs.findResource("peer/snd");
497
      assertTrue ("Cannot acces  FileObject named testMethodValue", fo != null);
498
499
      Object obj = fo.getAttribute("testPeer");
500
      assertNotNull("methodValue failed", obj);
501
      assertEquals(Data.class, obj.getClass());
502
      Data data = (Data)obj;
503
      assertEquals("it is the top most fileobject", peer, data.peer);
504
505
    }
490
506
491
    
507
    
492
    public void testChangeOfAnAttributeInLayerIsFiredIfThereIsRealChange() throws Exception {
508
    public void testChangeOfAnAttributeInLayerIsFiredIfThereIsRealChange() throws Exception {
Lines 730-734 Link Here
730
746
731
        return attrs.get("value1") + attrName;
747
        return attrs.get("value1") + attrName;
732
    }
748
    }
749
    private static FileObject root;
750
    public static final class Data {
751
        Object peer;
752
        public Data() {
753
            FileObject fo = root.getFileObject("peer/snd");
754
            peer = fo.getAttribute("testPeer");
755
        }
756
    }
757
    private static Object getFO(FileObject fo) {
758
        return fo;
759
    }
733
    
760
    
734
}
761
}
(-)a/openide.filesystems/test/unit/src/org/openide/filesystems/data/Attributes.xml (+8 lines)
Lines 21-24 Link Here
21
        <attr name="value1" stringvalue="Ahoj1"/>
21
        <attr name="value1" stringvalue="Ahoj1"/>
22
        <attr name="testLoc" bundlevalue="org.openide.filesystems.data.TestBundle#AHOJ"/>
22
        <attr name="testLoc" bundlevalue="org.openide.filesystems.data.TestBundle#AHOJ"/>
23
    </folder>
23
    </folder>
24
    <folder name="peer">
25
        <file name="base">
26
            <attr name="testPeer" newvalue="org.openide.filesystems.XMLFileSystemTestHid$Data"/>
27
        </file>
28
        <file name="snd">
29
            <attr name="testPeer" methodvalue="org.openide.filesystems.XMLFileSystemTestHid.getFO"/>
30
        </file>
31
    </folder>
24
</filesystem>
32
</filesystem>

Return to bug 156158