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

(-)a/core.startup/nbproject/project.xml (-1 / +1 lines)
Lines 60-66 made subject to such option by the copyr Link Here
60
                    <build-prerequisite/>
60
                    <build-prerequisite/>
61
                    <compile-dependency/>
61
                    <compile-dependency/>
62
                    <run-dependency>
62
                    <run-dependency>
63
                        <specification-version>7.2</specification-version>
63
                        <specification-version>7.10</specification-version>
64
                    </run-dependency>
64
                    </run-dependency>
65
                </dependency>
65
                </dependency>
66
                <dependency>
66
                <dependency>
(-)a/core.startup/src/org/netbeans/core/startup/layers/BinaryCacheManager.java (-5 / +8 lines)
Lines 184-199 final class BinaryCacheManager extends P Link Here
184
        "methodvalue", // NOI18N
184
        "methodvalue", // NOI18N
185
        "newvalue", // NOI18N
185
        "newvalue", // NOI18N
186
        "serialvalue", // NOI18N
186
        "serialvalue", // NOI18N
187
        "bundlevalue", // NOI18N
187
    };
188
    };
188
189
189
    private void writeAttribute(BinaryWriter bw, MemAttr attr) throws IOException {
190
    private void writeAttribute(BinaryWriter bw, MemAttr attr) throws IOException {
190
        bw.writeString(attr.name);
191
        bw.writeString(attr.name);
191
        int i = 0;
192
        for (int i = 0; i < ATTR_TYPES.length; i++) {
192
        for(; i < ATTR_TYPES.length; i++) {
193
            if(ATTR_TYPES[i].equals(attr.type)) {
193
            if(ATTR_TYPES[i].equals(attr.type)) break;
194
                bw.writeByte((byte)i);
195
                bw.writeString(attr.data);
196
                return;
197
            }
194
        }
198
        }
195
        bw.writeByte((byte)i); // XXX - may write wrong value if unknown type!
199
        throw new IOException("Wrong type: " + attr);
196
        bw.writeString(attr.data);
197
    }
200
    }
198
    
201
    
199
    // this map is actually valid only during BFS regeneration, null otherwise
202
    // this map is actually valid only during BFS regeneration, null otherwise
(-)a/core.startup/src/org/netbeans/core/startup/layers/BinaryFS.java (-5 / +5 lines)
Lines 48-54 import java.io.IOException; Link Here
48
import java.io.IOException;
48
import java.io.IOException;
49
import java.io.InputStream;
49
import java.io.InputStream;
50
import java.io.OutputStream;
50
import java.io.OutputStream;
51
import java.io.RandomAccessFile;
52
import java.lang.reflect.Field;
51
import java.lang.reflect.Field;
53
import java.lang.reflect.Method;
52
import java.lang.reflect.Method;
54
import java.net.URL;
53
import java.net.URL;
Lines 56-63 import java.nio.ByteOrder; Link Here
56
import java.nio.ByteOrder;
55
import java.nio.ByteOrder;
57
import java.util.AbstractMap;
56
import java.util.AbstractMap;
58
import java.util.AbstractSet;
57
import java.util.AbstractSet;
59
import java.nio.MappedByteBuffer;
60
import java.nio.channels.FileChannel;
61
import java.util.ArrayList;
58
import java.util.ArrayList;
62
import java.util.Arrays;
59
import java.util.Arrays;
63
import java.util.Collections;
60
import java.util.Collections;
Lines 71-77 import java.util.StringTokenizer; Link Here
71
import java.util.StringTokenizer;
68
import java.util.StringTokenizer;
72
import java.util.logging.Level;
69
import java.util.logging.Level;
73
import java.util.logging.Logger;
70
import java.util.logging.Logger;
74
import org.netbeans.Stamps;
75
import org.openide.filesystems.FileChangeListener;
71
import org.openide.filesystems.FileChangeListener;
76
import org.openide.filesystems.FileLock;
72
import org.openide.filesystems.FileLock;
77
import org.openide.filesystems.FileObject;
73
import org.openide.filesystems.FileObject;
Lines 79-84 import org.openide.util.Enumerations; Link Here
79
import org.openide.util.Enumerations;
75
import org.openide.util.Enumerations;
80
import org.openide.util.Exceptions;
76
import org.openide.util.Exceptions;
81
import org.openide.util.Lookup;
77
import org.openide.util.Lookup;
78
import org.openide.util.NbBundle;
82
import org.openide.util.SharedClassObject;
79
import org.openide.util.SharedClassObject;
83
import org.openide.util.Union2;
80
import org.openide.util.Union2;
84
import org.openide.util.actions.SystemAction;
81
import org.openide.util.actions.SystemAction;
Lines 100-106 public class BinaryFS extends FileSystem Link Here
100
     *     FS data
97
     *     FS data
101
     */
98
     */
102
99
103
    static final byte[] MAGIC = "org.netbeans.core.projects.cache.BinaryV3".getBytes(); // NOI18N
100
    static final byte[] MAGIC = "org.netbeans.core.projects.cache.BinaryV4".getBytes(); // NOI18N
104
101
105
    /** An empty array of SystemActions. */
102
    /** An empty array of SystemActions. */
106
    static final SystemAction[] NO_ACTIONS = new SystemAction[0];
103
    static final SystemAction[] NO_ACTIONS = new SystemAction[0];
Lines 492-497 public class BinaryFS extends FileSystem Link Here
492
489
493
                    case 12: // serialvalue
490
                    case 12: // serialvalue
494
                        return decodeValue(value);
491
                        return decodeValue(value);
492
                    case 13: // bundle value
493
                        String[] arr = value.split("#", 2); // NOI18N
494
                        return NbBundle.getBundle(arr[0]).getObject(arr[1]);
495
                    default:
495
                    default:
496
                        throw new IllegalStateException("Bad index: " + index); // NOI18N
496
                        throw new IllegalStateException("Bad index: " + index); // NOI18N
497
                }
497
                }
(-)a/core.startup/src/org/netbeans/core/startup/layers/ParsingLayerCacheManager.java (-1 / +2 lines)
Lines 80-85 abstract class ParsingLayerCacheManager Link Here
80
    
80
    
81
    private final static String[] ATTR_TYPES = {
81
    private final static String[] ATTR_TYPES = {
82
        "boolvalue",
82
        "boolvalue",
83
        "bundlevalue",
83
        "bytevalue",
84
        "bytevalue",
84
        "charvalue",
85
        "charvalue",
85
        "doublevalue",
86
        "doublevalue",
Lines 91-97 abstract class ParsingLayerCacheManager Link Here
91
        "serialvalue",
92
        "serialvalue",
92
        "shortvalue",
93
        "shortvalue",
93
        "stringvalue",
94
        "stringvalue",
94
        "urlvalue"
95
        "urlvalue",
95
    };
96
    };
96
    
97
    
97
    private final static String DTD_1_0 = "-//NetBeans//DTD Filesystem 1.0//EN";
98
    private final static String DTD_1_0 = "-//NetBeans//DTD Filesystem 1.0//EN";
(-)a/core.startup/test/unit/src/org/netbeans/core/startup/layers/BinaryFSTest.java (-4 / +14 lines)
Lines 41-51 Link Here
41
41
42
package org.netbeans.core.startup.layers;
42
package org.netbeans.core.startup.layers;
43
43
44
import java.io.ByteArrayOutputStream;
45
import java.io.File;
44
import java.io.File;
46
import java.io.IOException;
45
import java.io.IOException;
47
import java.net.URL;
46
import java.net.URL;
48
import java.nio.ByteBuffer;
49
import java.util.Arrays;
47
import java.util.Arrays;
50
import junit.framework.Test;
48
import junit.framework.Test;
51
import org.netbeans.junit.NbTestSuite;
49
import org.netbeans.junit.NbTestSuite;
Lines 56-67 import org.openide.filesystems.FileSyste Link Here
56
import org.openide.filesystems.FileSystemTestHid;
54
import org.openide.filesystems.FileSystemTestHid;
57
import org.openide.filesystems.TestUtilHid;
55
import org.openide.filesystems.TestUtilHid;
58
import org.openide.filesystems.XMLFileSystem;
56
import org.openide.filesystems.XMLFileSystem;
57
import org.openide.filesystems.XMLFileSystemTestHid;
59
58
60
/**
59
/**
61
 *
60
 *
62
 * @author Radek Matous
61
 * @author Radek Matous
63
 */
62
 */
64
public class BinaryFSTest extends FileSystemFactoryHid {  
63
public class BinaryFSTest extends FileSystemFactoryHid
64
implements XMLFileSystemTestHid.Factory {
65
    public BinaryFSTest(Test test) {
65
    public BinaryFSTest(Test test) {
66
        super(test);
66
        super(test);
67
    }
67
    }
Lines 71-76 public class BinaryFSTest extends FileSy Link Here
71
        suite.addTestSuite(FileSystemTestHid.class);
71
        suite.addTestSuite(FileSystemTestHid.class);
72
        suite.addTestSuite(FileObjectTestHid.class);
72
        suite.addTestSuite(FileObjectTestHid.class);
73
        suite.addTestSuite(AttributesTestHidden.class);
73
        suite.addTestSuite(AttributesTestHidden.class);
74
        suite.addTestSuite(XMLFileSystemTestHid.class);
74
         
75
         
75
        return new BinaryFSTest(suite);
76
        return new BinaryFSTest(suite);
76
    }
77
    }
Lines 88-92 public class BinaryFSTest extends FileSy Link Here
88
        String workDirProperty = System.getProperty("workdir");//NOI18N
89
        String workDirProperty = System.getProperty("workdir");//NOI18N
89
        workDirProperty = (workDirProperty != null) ? workDirProperty : System.getProperty("java.io.tmpdir");//NOI18N                 
90
        workDirProperty = (workDirProperty != null) ? workDirProperty : System.getProperty("java.io.tmpdir");//NOI18N                 
90
        return new File(workDirProperty);
91
        return new File(workDirProperty);
91
    }    
92
    }
93
94
    public FileSystem createLayerSystem(String testName, URL[] layers) throws IOException {
95
        LayerCacheManager bm = LayerCacheManager.manager(true);
96
        return BinaryCacheManagerTest.store(bm, Arrays.asList(layers));
97
    }
98
99
    public boolean setXmlUrl(FileSystem fs, URL[] layers) throws IOException {
100
        return false;
101
    }
92
}
102
}
(-)a/openide.filesystems/apichanges.xml (+16 lines)
Lines 46-51 made subject to such option by the copyr Link Here
46
        <apidef name="filesystems">Filesystems API</apidef>
46
        <apidef name="filesystems">Filesystems API</apidef>
47
    </apidefs>
47
    </apidefs>
48
    <changes> 	
48
    <changes> 	
49
        <change id="layer.bundlevalue">
50
            <api name="filesystems"/>
51
            <summary>XMLFileSystem supports 'bundlevalue' attribute</summary>
52
            <version major="7" minor="10"/>
53
            <date day="8" month="7" year="2008"/>
54
            <author login="jtulach"/>
55
            <compatibility addition="yes"/>
56
            <description>
57
                <p>
58
                    It is possible to declare a value in <code>layer.xml</code>
59
                    files with &lt;attr name="..." bundlevalue="org.yourpkg.Bundle#key"/&gt;.
60
                </p>
61
            </description>
62
            <class package="org.openide.filesystems" name="XMLFileSystem"/>
63
            <issue number="138076"/>
64
        </change>
49
        <change id="FileUtil.urlForArchiveOrDir.archiveOrDirForURL">
65
        <change id="FileUtil.urlForArchiveOrDir.archiveOrDirForURL">
50
            <api name="filesystems"/>
66
            <api name="filesystems"/>
51
            <summary>Added methods to interconvert URLs and traditional path entries</summary>
67
            <summary>Added methods to interconvert URLs and traditional path entries</summary>
(-)a/openide.filesystems/manifest.mf (-1 / +1 lines)
Lines 1-5 Manifest-Version: 1.0 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.openide.filesystems
2
OpenIDE-Module: org.openide.filesystems
3
OpenIDE-Module-Specification-Version: 7.9
3
OpenIDE-Module-Specification-Version: 7.10
4
OpenIDE-Module-Localizing-Bundle: org/openide/filesystems/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/openide/filesystems/Bundle.properties
5
5
(-)a/openide.filesystems/src/org/openide/filesystems/XMLFileSystem.java (-2 / +5 lines)
Lines 89-95 import org.xml.sax.helpers.DefaultHandle Link Here
89
 * Mandatory attributes:
89
 * Mandatory attributes:
90
 *         -for filesystem    version=... (e.g. "1.0")
90
 *         -for filesystem    version=... (e.g. "1.0")
91
 *         -for file,folder,attr name=....  (e.g.: &lt;folder name="Config"&gt;)
91
 *         -for file,folder,attr name=....  (e.g.: &lt;folder name="Config"&gt;)
92
 *         -for attr is mandatory one of bytevalue,shortvalue,intvalue,longvalue,floatvalue,doublevalue,boolvalue,charvalue,stringvalue,methodvalue,serialvalue,urlvalue
92
 *         -for attr is mandatory one of bytevalue,shortvalue,intvalue,longvalue,floatvalue,doublevalue,boolvalue,charvalue,stringvalue,methodvalue,serialvalue,urlvalue,bundlevalue
93
 *
93
 *
94
 * Allowed atributes:
94
 * Allowed atributes:
95
 *         -for file:        url=.... (e.g.: &lt;file name="sample.xml" url="file:/c:/sample.xml"&gt;)
95
 *         -for file:        url=.... (e.g.: &lt;file name="sample.xml" url="file:/c:/sample.xml"&gt;)
Lines 109-115 import org.xml.sax.helpers.DefaultHandle Link Here
109
 *
109
 *
110
 * This class implements virtual FileSystem. It is special case of FileSystem in XML format.
110
 * This class implements virtual FileSystem. It is special case of FileSystem in XML format.
111
 *
111
 *
112
 * Description of this format best ilustrate DTD file that is showed in next lines:
112
 * Description of this format best ilustrate <a href="http://www.netbeans.org/dtds/filesystem-1_2.dtd">DTD file</a>
113
 * that is showed in the following few lines:
113
 * &lt; !ELEMENT filesystem (file | folder)*&gt;
114
 * &lt; !ELEMENT filesystem (file | folder)*&gt;
114
 * &lt; !ATTLIST filesystem version CDATA #REQUIRED&gt; //version not checkked yet
115
 * &lt; !ATTLIST filesystem version CDATA #REQUIRED&gt; //version not checkked yet
115
 * &lt; !ELEMENT folder (file |folder | attr)*&gt;
116
 * &lt; !ELEMENT folder (file |folder | attr)*&gt;
Lines 131-136 import org.xml.sax.helpers.DefaultHandle Link Here
131
 * &lt; !ATTLIST attr methodvalue CDATA #IMPLIED&gt;
132
 * &lt; !ATTLIST attr methodvalue CDATA #IMPLIED&gt;
132
 * &lt; !ATTLIST attr serialvalue CDATA #IMPLIED&gt;
133
 * &lt; !ATTLIST attr serialvalue CDATA #IMPLIED&gt;
133
 * &lt; !ATTLIST attr urlvalue CDATA #IMPLIED&gt;
134
 * &lt; !ATTLIST attr urlvalue CDATA #IMPLIED&gt;
135
 * &lt; !ATTLIST attr bundlevalue CDATA #IMPLIED&gt; &lt;!-- since version 7.10 --&gt;
134
 * </PRE>
136
 * </PRE>
135
 *
137
 *
136
 * <p>
138
 * <p>
Lines 162-167 public final class XMLFileSystem extends Link Here
162
    static {
164
    static {
163
        DTD_MAP.put("-//NetBeans//DTD Filesystem 1.0//EN", "org/openide/filesystems/filesystem.dtd"); //NOI18N
165
        DTD_MAP.put("-//NetBeans//DTD Filesystem 1.0//EN", "org/openide/filesystems/filesystem.dtd"); //NOI18N
164
        DTD_MAP.put("-//NetBeans//DTD Filesystem 1.1//EN", "org/openide/filesystems/filesystem1_1.dtd"); //NOI18N        
166
        DTD_MAP.put("-//NetBeans//DTD Filesystem 1.1//EN", "org/openide/filesystems/filesystem1_1.dtd"); //NOI18N        
167
        DTD_MAP.put("-//NetBeans//DTD Filesystem 1.2//EN", "org/openide/filesystems/filesystem1_2.dtd"); //NOI18N        
165
    }
168
    }
166
169
167
    /**  Url location of XML document    */
170
    /**  Url location of XML document    */
(-)a/openide.filesystems/src/org/openide/filesystems/XMLMapAttr.java (-2 / +17 lines)
Lines 53-58 import java.net.URL; Link Here
53
53
54
import java.util.*;
54
import java.util.*;
55
import org.openide.util.Exceptions;
55
import org.openide.util.Exceptions;
56
import org.openide.util.NbBundle;
56
57
57
58
58
/**
59
/**
Lines 338-343 final class XMLMapAttr implements Map { Link Here
338
        return map.containsValue(p1);
339
        return map.containsValue(p1);
339
    }
340
    }
340
341
342
    @Override
341
    public synchronized int hashCode() {
343
    public synchronized int hashCode() {
342
        return map.hashCode();
344
        return map.hashCode();
343
    }
345
    }
Lines 367-374 final class XMLMapAttr implements Map { Link Here
367
        return map.isEmpty();
369
        return map.isEmpty();
368
    }
370
    }
369
371
372
    @Override
370
    public synchronized boolean equals(Object p1) {
373
    public synchronized boolean equals(Object p1) {
371
        return map.equals(p1);
374
        if (p1 instanceof Map) {
375
            return map.equals(p1);
376
        } else {
377
            return false;
378
        }
372
    }
379
    }
373
380
374
    public synchronized int size() {
381
    public synchronized int size() {
Lines 384-390 final class XMLMapAttr implements Map { Link Here
384
        // static final long serialVersionUID = -62733358015297232L;
391
        // static final long serialVersionUID = -62733358015297232L;
385
        private static final String[] ALLOWED_ATTR_KEYS = {
392
        private static final String[] ALLOWED_ATTR_KEYS = {
386
            "bytevalue", "shortvalue", "intvalue", "longvalue", "floatvalue", "doublevalue", "boolvalue", "charvalue",
393
            "bytevalue", "shortvalue", "intvalue", "longvalue", "floatvalue", "doublevalue", "boolvalue", "charvalue",
387
            "stringvalue", "methodvalue", "serialvalue", "urlvalue", "newvalue"
394
            "stringvalue", "methodvalue", "serialvalue", "urlvalue", "newvalue", "bundlevalue"
388
        }; // NOI18N
395
        }; // NOI18N
389
        private String value;
396
        private String value;
390
        private int keyIndex;
397
        private int keyIndex;
Lines 861-866 final class XMLMapAttr implements Map { Link Here
861
                        } else {
868
                        } else {
862
                            return cls.newInstance();
869
                            return cls.newInstance();
863
                        }
870
                        }
871
                    case 13:
872
                        String[] arr = value.split("#", 2); // NOI18N
873
                        return NbBundle.getBundle(arr[0]).getObject(arr[1]);
864
                    }
874
                    }
865
                } catch (Exception exc) {
875
                } catch (Exception exc) {
866
                    ExternalUtil.annotate(exc, "value = " + value); //NOI18N
876
                    ExternalUtil.annotate(exc, "value = " + value); //NOI18N
Lines 982-987 final class XMLMapAttr implements Map { Link Here
982
            return index;
992
            return index;
983
        }
993
        }
984
994
995
        @Override
985
        public boolean equals(Object obj) {
996
        public boolean equals(Object obj) {
986
            if (obj instanceof Attr) {
997
            if (obj instanceof Attr) {
987
                Attr other = (Attr)obj;
998
                Attr other = (Attr)obj;
Lines 995-1000 final class XMLMapAttr implements Map { Link Here
995
            return false;
1006
            return false;
996
        }
1007
        }
997
1008
1009
        @Override
998
        public int hashCode() {
1010
        public int hashCode() {
999
            return 743 + keyIndex << 8 + value.hashCode();
1011
            return 743 + keyIndex << 8 + value.hashCode();
1000
        }
1012
        }
Lines 1140-1149 final class XMLMapAttr implements Map { Link Here
1140
            return fo.getAttribute(key);
1152
            return fo.getAttribute(key);
1141
        }
1153
        }
1142
1154
1155
        @Override
1143
        public Object remove(Object key) {
1156
        public Object remove(Object key) {
1144
            throw new UnsupportedOperationException();
1157
            throw new UnsupportedOperationException();
1145
        }
1158
        }
1146
1159
1160
        @Override
1147
        public Object put(String key, Object value) {
1161
        public Object put(String key, Object value) {
1148
            throw new UnsupportedOperationException();
1162
            throw new UnsupportedOperationException();
1149
        }
1163
        }
Lines 1186-1191 final class XMLMapAttr implements Map { Link Here
1186
            return cnt;
1200
            return cnt;
1187
        }
1201
        }
1188
1202
1203
        @Override
1189
        public boolean remove(Object o) {
1204
        public boolean remove(Object o) {
1190
            throw new UnsupportedOperationException();
1205
            throw new UnsupportedOperationException();
1191
        }
1206
        }
(-)846d1a231c05 (+30 lines)
Added Link Here
1
<!-- -//NetBeans//DTD Filesystem 1.2//EN -->
2
<!-- XML representation of a fixed filesystem -->
3
<!-- as for example a module layer. -->
4
<!-- See: org.openide.filesystems.XMLFileSystem -->
5
<!ELEMENT filesystem   (file|folder|attr)*      >
6
<!ELEMENT folder       (folder|file|attr)*   >
7
<!ELEMENT file         (#PCDATA|attr)*>
8
<!ELEMENT attr    EMPTY               >
9
<!ATTLIST filesystem                       >
10
<!ATTLIST folder
11
          name         CDATA #REQUIRED     >
12
<!ATTLIST file
13
          name         CDATA #REQUIRED
14
          url          CDATA #IMPLIED      >
15
<!ATTLIST attr
16
          name         CDATA #REQUIRED
17
          bytevalue    CDATA #IMPLIED
18
          shortvalue   CDATA #IMPLIED
19
          intvalue     CDATA #IMPLIED
20
          longvalue    CDATA #IMPLIED
21
          floatvalue   CDATA #IMPLIED
22
          doublevalue  CDATA #IMPLIED
23
          boolvalue    CDATA #IMPLIED
24
          charvalue    CDATA #IMPLIED
25
          stringvalue  CDATA #IMPLIED
26
          urlvalue     CDATA #IMPLIED
27
          methodvalue  CDATA #IMPLIED
28
          newvalue     CDATA #IMPLIED
29
          serialvalue  CDATA #IMPLIED
30
          bundlevalue  CDATA #IMPLIED      >
(-)a/openide.filesystems/test/unit/src/org/openide/filesystems/AttributesTestHidden.java (-147 / +1 lines)
Lines 41-52 Link Here
41
41
42
package org.openide.filesystems;
42
package org.openide.filesystems;
43
43
44
import junit.framework.*;
45
//import org.openide.filesystems.hidden.*;
46
44
47
import java.util.*;
45
import java.util.*;
48
import java.io.*;
46
import java.io.*;
49
import java.net.URL;
50
47
51
/**
48
/**
52
 *
49
 *
Lines 55-60 import java.net.URL; Link Here
55
 *
52
 *
56
 */
53
 */
57
public class AttributesTestHidden extends TestBaseHid {
54
public class AttributesTestHidden extends TestBaseHid {
55
58
    static final String TEST_ERR = "Not the tested code, but this test contains errors";
56
    static final String TEST_ERR = "Not the tested code, but this test contains errors";
59
    static final String COMMON_ATTR_STRING = "testAttribute";
57
    static final String COMMON_ATTR_STRING = "testAttribute";
60
58
Lines 245-299 public class AttributesTestHidden extend Link Here
245
        assertTrue ("There was not found expected key: " + COMMON_ATTR_STRING +" in .nbattrs",content.indexOf("name=\""+COMMON_ATTR_STRING) != -1 );//        
243
        assertTrue ("There was not found expected key: " + COMMON_ATTR_STRING +" in .nbattrs",content.indexOf("name=\""+COMMON_ATTR_STRING) != -1 );//        
246
    }
244
    }
247
    
245
    
248
    
249
    public void testAttribute08 () throws Exception {
250
      URL fsURLDef = this.getClass().getResource ("data/Attributes.xml");
251
      assertTrue ("Cannot create XML FS for testing purposes", fsURLDef != null);  
252
      FileSystem fs = new XMLFileSystem (fsURLDef);
253
      FileObject fo = fs.findResource("testMethodValue");
254
      assertTrue ("Cannot acces  FileObject named testMethodValue", fo != null);  
255
256
      String testName = "test1";
257
      Object obj = fo.getAttribute(testName);
258
      assertTrue ("methodValue failed", obj != null);          
259
      assertTrue ("methodValue doesn't keep order ", 
260
      obj.equals(getObjectViaMethodValue1 (fo, testName)));                
261
      
262
      testName = "test2";
263
      obj = fo.getAttribute(testName);
264
      assertTrue ("methodValue failed", obj != null);          
265
      assertTrue ("methodValue doesn't keep order ", 
266
      obj.equals(getObjectViaMethodValue2 (testName, fo)));                
267
268
      testName = "test3";
269
      obj = fo.getAttribute(testName);
270
      assertTrue ("methodValue failed", obj != null);          
271
      assertTrue ("methodValue doesn't keep order ", 
272
      obj.equals(getObjectViaMethodValue3 (fo)));                
273
274
      testName = "test4";
275
      obj = fo.getAttribute(testName);
276
      assertTrue ("methodValue failed", obj != null);          
277
      assertTrue ("methodValue doesn't keep order ", 
278
      obj.equals(getObjectViaMethodValue4 (testName)));                
279
280
      testName = "test5";
281
      obj = fo.getAttribute(testName);
282
      assertTrue ("methodValue failed", obj != null);          
283
      assertTrue ("methodValue doesn't keep order ", 
284
      obj.equals(getObjectViaMethodValue5 ()));                     
285
286
      testName = "test6";
287
      obj = fo.getAttribute(testName);
288
      assertTrue ("methodValue failed", obj != null);          
289
      assertEquals("even works for java.util.Map", "Ahoj1", obj);
290
291
      testName = "test7";
292
      obj = fo.getAttribute(testName);
293
      assertTrue ("methodValue failed", obj != null);          
294
      assertEquals("works for map and string", "Ahoj1test7", obj);  
295
    }
296
297
    public void testAttribute09 () throws IOException {
246
    public void testAttribute09 () throws IOException {
298
        assertTrue (TEST_ERR,testedFS != null);
247
        assertTrue (TEST_ERR,testedFS != null);
299
        if (testedFS.isReadOnly ()) return;                
248
        if (testedFS.isReadOnly ()) return;                
Lines 322-422 public class AttributesTestHidden extend Link Here
322
        }                        
271
        }                        
323
    }
272
    }
324
    
273
    
325
    private static String getObjectViaMethodValue1 (FileObject fo, String testName) {
326
        return fo.getPath()+testName;
327
    }
328
329
    private static String getObjectViaMethodValue1 (String testName, FileObject fo) {
330
        return testName+fo.getPath();
331
    }
332
333
    private static String getObjectViaMethodValue1 (FileObject fo) {
334
        return fo.getPath();        
335
    }
336
    
337
    private static String getObjectViaMethodValue1 (String testName) {
338
        return testName;
339
    }
340
341
    private static String getObjectViaMethodValue1 () {
342
        return "";        
343
    }
344
///
345
    private static String getObjectViaMethodValue2 (String testName, FileObject fo) {
346
        return testName+fo.getPath();
347
    }
348
349
    private static String getObjectViaMethodValue2 (FileObject fo) {
350
        return fo.getPath();        
351
    }
352
    
353
    private static String getObjectViaMethodValue2 (String testName) {
354
        return testName;
355
    }
356
357
    private static String getObjectViaMethodValue2 () {
358
        return "";        
359
    }
360
///
361
    private static String getObjectViaMethodValue3 (FileObject fo) {
362
        return fo.getPath();        
363
    }
364
365
    private static String getObjectViaMethodValue3 (String testName) {
366
        return testName;
367
    }
368
369
    private static String getObjectViaMethodValue3 () {
370
        return "";        
371
    }
372
///
373
    private static String getObjectViaMethodValue4 (String testName) {
374
        return testName;
375
    }
376
377
    private static String getObjectViaMethodValue4 () {
378
        return "";        
379
    }
380
///
381
    private static String getObjectViaMethodValue5 () {
382
        return "";        
383
    }
384
            
385
    private static Object getObjectViaMethodValue6 (Map attrs) {
386
        try {
387
            attrs.keySet().iterator().remove();
388
            return "UnsupportedOperationException";
389
        } catch (UnsupportedOperationException ex) {
390
            // ok
391
        }
392
        try {
393
            attrs.put("value1", "nothing");
394
            return "UnsupportedOperationException";
395
        } catch (UnsupportedOperationException ex) {
396
            // ok
397
        }
398
        try {
399
            attrs.remove("value1");
400
            return "UnsupportedOperationException";
401
        } catch (UnsupportedOperationException ex) {
402
            // ok
403
        }
404
        
405
        
406
        return attrs.get("value1");
407
    }
408
    private static Object getObjectViaMethodValue7 (Map<String,Object> attrs, String attrName) {
409
        assertEquals(8, attrs.keySet().size());
410
        try {
411
            attrs.entrySet().remove(null);
412
            return "UnsupportedOperationException";
413
        } catch (UnsupportedOperationException ex) {
414
            // ok
415
        }
416
        
417
        
418
        return attrs.get("value1") + attrName;
419
    }
420
            
274
            
421
    private String basicAttributeTest (String attrName, String attrValue) throws IOException {
275
    private String basicAttributeTest (String attrName, String attrValue) throws IOException {
422
        FileObject foTested = testedFS.getRoot ();        
276
        FileObject foTested = testedFS.getRoot ();        
(-)a/openide.filesystems/test/unit/src/org/openide/filesystems/FileSystemFactoryHid.java (-1 / +22 lines)
Lines 45-53 import org.netbeans.junit.*; Link Here
45
import org.netbeans.junit.*;
45
import org.netbeans.junit.*;
46
46
47
import java.io.*;
47
import java.io.*;
48
import java.net.URL;
48
import java.util.*;
49
import java.util.*;
49
50
50
import org.openide.filesystems.*;
51
51
52
52
53
/**
53
/**
Lines 77-82 public abstract class FileSystemFactoryH Link Here
77
     * @return  array of FileSystems that should be tested in test named: "testName"*/    
77
     * @return  array of FileSystems that should be tested in test named: "testName"*/    
78
    final static FileSystem[] createFileSystem (String testName,String[] resources, Test test) throws IOException {
78
    final static FileSystem[] createFileSystem (String testName,String[] resources, Test test) throws IOException {
79
         return getInstance (test,true).createFileSystem(testName, resources);
79
         return getInstance (test,true).createFileSystem(testName, resources);
80
    }
81
82
    /**
83
     * Intended to allow prepare tested environment for each individual test.
84
     * @param testName name of test
85
     * @return  array of FileSystems that should be tested in test named: "testName"*/
86
    final static FileSystem createXMLSystem (String testName, Test test, URL... layers) throws IOException {
87
        FileSystemFactoryHid factory = getInstance(test, false);
88
        if (factory instanceof XMLFileSystemTestHid.Factory) {
89
            XMLFileSystemTestHid.Factory f = (XMLFileSystemTestHid.Factory) factory;
90
            return f.createLayerSystem(testName, layers);
91
        }
92
        throw new IllegalStateException("You need to implement XMLFileSystemTestHid.Factory to use the AttributesTestHidden!");
93
    }
94
    final static boolean switchXMLSystem (FileSystem fs, Test test, URL... layers) throws IOException {
95
        FileSystemFactoryHid factory = getInstance(test, false);
96
        if (factory instanceof XMLFileSystemTestHid.Factory) {
97
            XMLFileSystemTestHid.Factory f = (XMLFileSystemTestHid.Factory) factory;
98
            return f.setXmlUrl(fs, layers);
99
        }
100
        throw new IllegalStateException("You need to implement XMLFileSystemTestHid.Factory to use the AttributesTestHidden!");
80
    }
101
    }
81
      
102
      
82
    final static void destroyFileSystem (String testName, Test test)  throws IOException  {
103
    final static void destroyFileSystem (String testName, Test test)  throws IOException  {
(-)a/openide.filesystems/test/unit/src/org/openide/filesystems/LocalFileSystemTest.java (-7 lines)
Lines 57-69 public class LocalFileSystemTest extends Link Here
57
        super(test);
57
        super(test);
58
    }
58
    }
59
59
60
61
    public static void main(String args[]) {
62
        junit.textui.TestRunner.run(suite());
63
    }
64
65
66
67
    public static Test suite() {
60
    public static Test suite() {
68
        NbTestSuite suite = new NbTestSuite();
61
        NbTestSuite suite = new NbTestSuite();
69
62
(-)a/openide.filesystems/test/unit/src/org/openide/filesystems/TestBaseHid.java (-1 / +3 lines)
Lines 97-103 public abstract class TestBaseHid extend Link Here
97
        clearWorkDir();
97
        clearWorkDir();
98
        String[] resources = getResources (getName());        
98
        String[] resources = getResources (getName());        
99
        resourcePrefix = FileSystemFactoryHid.getResourcePrefix(this.getName(),this, resources);
99
        resourcePrefix = FileSystemFactoryHid.getResourcePrefix(this.getName(),this, resources);
100
        allTestedFS = FileSystemFactoryHid.createFileSystem(getName(),resources,this);        
100
        if (allTestedFS == null) {
101
            allTestedFS = FileSystemFactoryHid.createFileSystem(getName(),resources,this);
102
        }
101
        if (allTestedFS != null) testedFS = allTestedFS[0];
103
        if (allTestedFS != null) testedFS = allTestedFS[0];
102
        // If not null, file accesses are counted through custom SecurityManager.
104
        // If not null, file accesses are counted through custom SecurityManager.
103
        if(accessMonitor != null) {
105
        if(accessMonitor != null) {
(-)a/openide.filesystems/test/unit/src/org/openide/filesystems/XMLFileSystemTest.java (-11 / +26 lines)
Lines 41-70 Link Here
41
41
42
package org.openide.filesystems;
42
package org.openide.filesystems;
43
43
44
import java.beans.PropertyVetoException;
45
import java.net.URL;
44
import junit.framework.*;
46
import junit.framework.*;
45
import java.io.*;
47
import java.io.*;
46
import java.util.*;
47
import java.util.jar.*;
48
import java.util.zip.*;
49
import java.net.*;
50
import org.netbeans.junit.*;
48
import org.netbeans.junit.*;
51
49
import org.openide.util.Exceptions;
52
//import org.openide.filesystems.hidden.*;
53
50
54
/**
51
/**
55
 *
52
 *
56
 * @author  rm111737
53
 * @author  rm111737
57
 * @version
54
 * @version
58
 */
55
 */
59
public class XMLFileSystemTest extends FileSystemFactoryHid {
56
public class XMLFileSystemTest extends FileSystemFactoryHid
57
implements XMLFileSystemTestHid.Factory {
60
58
61
    /** Creates new XMLFileSystemTest */
59
    /** Creates new XMLFileSystemTest */
62
    public XMLFileSystemTest(Test test) {
60
    public XMLFileSystemTest(Test test) {
63
        super(test);
61
        super(test);
64
    }
65
66
    public static void main(String args[]) {
67
        junit.textui.TestRunner.run(suite());
68
    }
62
    }
69
63
70
    public static Test suite() {
64
    public static Test suite() {
Lines 75-85 public class XMLFileSystemTest extends F Link Here
75
                
69
                
76
        return new XMLFileSystemTest(suite);
70
        return new XMLFileSystemTest(suite);
77
    }
71
    }
72
78
    protected void destroyFileSystem(String testName) throws IOException {}
73
    protected void destroyFileSystem(String testName) throws IOException {}
79
    
74
    
80
    protected FileSystem[] createFileSystem(String testName, String[] resources) throws IOException{
75
    protected FileSystem[] createFileSystem(String testName, String[] resources) throws IOException{
81
        return new FileSystem[] {TestUtilHid.createXMLFileSystem(testName, resources)};
76
        return new FileSystem[] {TestUtilHid.createXMLFileSystem(testName, resources)};
82
    }
77
    }
78
79
    public FileSystem createLayerSystem(String testName, URL[] layers) throws IOException {
80
        XMLFileSystem xfs = new XMLFileSystem();
81
        try {
82
            xfs.setXmlUrls(layers);
83
        } catch (PropertyVetoException ex) {
84
            throw (IOException)new IOException().initCause(ex);
85
        }
86
        return xfs;
87
    }
88
89
    public boolean setXmlUrl(org.openide.filesystems.FileSystem fs, URL[] layers) throws IOException {
90
        XMLFileSystem xfs = (XMLFileSystem)fs;
91
        try {
92
            xfs.setXmlUrls(layers);
93
        } catch (PropertyVetoException ex) {
94
            throw (IOException)new IOException().initCause(ex);
95
        }
96
        return true;
97
    }
83
    
98
    
84
99
85
    
100
    
(-)a/openide.filesystems/test/unit/src/org/openide/filesystems/XMLFileSystemTestHid.java (-17 / +208 lines)
Lines 47-57 import java.net.URL; Link Here
47
import java.net.URL;
47
import java.net.URL;
48
import java.util.ArrayList;
48
import java.util.ArrayList;
49
import java.util.List;
49
import java.util.List;
50
import java.util.Map;
50
51
51
public class XMLFileSystemTestHid extends TestBaseHid {
52
public class XMLFileSystemTestHid extends TestBaseHid {
53
    /** Factory for all filesystems that want to use TCK in this class.
54
     */
55
    public static interface Factory {
56
        /** Creates a filesystem representing XML files at given URLs
57
         *
58
         * @param testName name of the test
59
         * @param layers URLs of layers to parse
60
         * @return new filesystem that represents those layers
61
         */
62
        public FileSystem createLayerSystem(String testName, URL[] layers) throws IOException;
63
64
        /** Assigns new URLs to existing filesystem.
65
         *
66
         * @param fs the filesystem produced by {@link #createLayerSystem(java.lang.String, java.net.URL[])}
67
         * @param layers new URLs that the filesystem shall switch to
68
         * @return true if successful, false if this operation is not supported
69
         */
70
        public boolean setXmlUrl(FileSystem fs, URL[] layers) throws IOException;
71
    }
52
72
53
    private String[] resources = new String[] {"a/b/c"};
73
    private String[] resources = new String[] {"a/b/c"};
54
    XMLFileSystem xfs = null;
74
    FileSystem xfs = null;
55
75
56
    public XMLFileSystemTestHid(String testName) {
76
    public XMLFileSystemTestHid(String testName) {
57
        super(testName);
77
        super(testName);
Lines 70-90 public class XMLFileSystemTestHid extend Link Here
70
        FileChangeAdapter fcl = new FileChangeAdapter();
90
        FileChangeAdapter fcl = new FileChangeAdapter();
71
        a.addFileChangeListener(fcl);
91
        a.addFileChangeListener(fcl);
72
        
92
        
73
        resources = new String[] {"a/b/c","a/b1/c"};        
93
        resources = new String[] {"a/b/c","a/b1/c"};
74
        xfs.setXmlUrl(createXMLLayer().toURL());
94
95
        if (!FileSystemFactoryHid.switchXMLSystem(xfs, this, createXMLLayer().toURL())) {
96
            // OK, unsupported
97
            return;
98
        }
75
        
99
        
76
        FileObject b1 = xfs.findResource("a/b1");
100
        FileObject b1 = xfs.findResource("a/b1");
77
        assertNotNull(b1);                
101
        assertNotNull(b1);                
78
        assertTrue(b1.isFolder());        
102
        assertTrue(b1.isFolder());        
79
    }
103
    }
80
    
104
    
105
    @Override
81
    protected void setUp() throws Exception {
106
    protected void setUp() throws Exception {
107
        File f = createXMLLayer();
108
        xfs = FileSystemFactoryHid.createXMLSystem(getName(), this, f.toURL());
109
        this.testedFS = xfs;
110
        this.allTestedFS = new FileSystem[] { xfs };
82
        super.setUp();
111
        super.setUp();
83
        
84
        File f = createXMLLayer();
85
        xfs = new XMLFileSystem ();
86
        xfs.setXmlUrl(f.toURL());
87
        this.testedFS = xfs;
88
    }
112
    }
89
113
90
    private File createXMLLayer() throws IOException {
114
    private File createXMLLayer() throws IOException {
Lines 113-125 public class XMLFileSystemTestHid extend Link Here
113
        
137
        
114
        
138
        
115
        
139
        
116
        xfs = new XMLFileSystem (f.toURL());
140
        xfs = FileSystemFactoryHid.createXMLSystem(getName(), this, f.toURL());
117
        
141
        
118
        FileObject fo = xfs.findResource ("TestModule/sample.txt");
142
        FileObject fo = xfs.findResource ("TestModule/sample.txt");
119
        assertEquals ("Four bytes there", 4, fo.getSize ());
143
        assertEquals ("Four bytes there", 4, fo.getSize ());
120
        registerDefaultListener (fo);
144
        registerDefaultListener (fo);
121
        
145
        
122
        xfs.setXmlUrl (f2.toURL ());
146
        if (!FileSystemFactoryHid.switchXMLSystem(xfs, this, f2.toURL())) {
147
            // OK, unsupported
148
            return;
149
        }
123
        
150
        
124
        assertEquals ("Six bytes there", 6, fo.getSize ());
151
        assertEquals ("Six bytes there", 6, fo.getSize ());
125
        
152
        
Lines 149-161 public class XMLFileSystemTestHid extend Link Here
149
        
176
        
150
        
177
        
151
        
178
        
152
        xfs = new XMLFileSystem (f.toURL());
179
        xfs = FileSystemFactoryHid.createXMLSystem(getName(), this, f.toURL());
153
        
180
        
154
        FileObject fo = xfs.findResource ("TestModule/sample.txt");
181
        FileObject fo = xfs.findResource ("TestModule/sample.txt");
155
        assertEquals ("Four bytes there", 4, fo.getSize ());
182
        assertEquals ("Four bytes there", 4, fo.getSize ());
156
        registerDefaultListener (fo);
183
        registerDefaultListener (fo);
157
        
184
        
158
        xfs.setXmlUrl (f2.toURL ());
185
        if (!FileSystemFactoryHid.switchXMLSystem(xfs, this, f2.toURL())) {
186
            // OK, unsupported
187
            return;
188
        }
159
        
189
        
160
        assertEquals ("Six bytes there", 6, fo.getSize ());
190
        assertEquals ("Six bytes there", 6, fo.getSize ());
161
        
191
        
Lines 186-198 public class XMLFileSystemTestHid extend Link Here
186
        
216
        
187
        
217
        
188
        
218
        
189
        xfs = new XMLFileSystem (f.toURL());
219
        xfs = FileSystemFactoryHid.createXMLSystem(getName(), this, f.toURL());
190
        
220
        
191
        FileObject fo = xfs.findResource ("TestModule/sample.txt");
221
        FileObject fo = xfs.findResource ("TestModule/sample.txt");
192
        assertEquals("Old value is in the attribute", "old", fo.getAttribute("value"));
222
        assertEquals("Old value is in the attribute", "old", fo.getAttribute("value"));
193
        registerDefaultListener (fo);
223
        registerDefaultListener (fo);
194
        
224
        
195
        xfs.setXmlUrl (f2.toURL ());
225
        if (!FileSystemFactoryHid.switchXMLSystem(xfs, this, f2.toURL())) {
226
            // OK, unsupported
227
            return;
228
        }
196
229
197
        assertEquals("New value is in the attribute", "new", fo.getAttribute("value"));
230
        assertEquals("New value is in the attribute", "new", fo.getAttribute("value"));
198
        fileAttributeChangedAssert("Change in the content", 1);
231
        fileAttributeChangedAssert("Change in the content", 1);
Lines 217-229 public class XMLFileSystemTestHid extend Link Here
217
        
250
        
218
        
251
        
219
        
252
        
220
        xfs = new XMLFileSystem(f.toURL());
253
        xfs = FileSystemFactoryHid.createXMLSystem(getName(), this, f.toURL());
221
        
254
        
222
        FileObject fo = xfs.findResource("TestModule/sample.txt");
255
        FileObject fo = xfs.findResource("TestModule/sample.txt");
223
        assertEquals("Four bytes there", 4, fo.getSize());
256
        assertEquals("Four bytes there", 4, fo.getSize());
224
        registerDefaultListener(fo);
257
        registerDefaultListener(fo);
225
        
258
        
226
        xfs.setXmlUrl(f2.toURL());
259
        if (!FileSystemFactoryHid.switchXMLSystem(xfs, this, f2.toURL())) {
260
            // OK, unsupported
261
            return;
262
        }
227
        
263
        
228
        assertFalse("Valid no more", fo.isValid());
264
        assertFalse("Valid no more", fo.isValid());
229
        assertEquals("Empty now", 0, fo.getSize());
265
        assertEquals("Empty now", 0, fo.getSize());
Lines 246-252 public class XMLFileSystemTestHid extend Link Here
246
            Thread.sleep(3000);
282
            Thread.sleep(3000);
247
            assertTrue(f2.createNewFile());
283
            assertTrue(f2.createNewFile());
248
        }
284
        }
249
        xfs = new XMLFileSystem(f.toURL());
285
        xfs = FileSystemFactoryHid.createXMLSystem(getName(), this, f.toURL());
250
        FileObject fo = xfs.findResource ("TestModule/sample.txt");
286
        FileObject fo = xfs.findResource ("TestModule/sample.txt");
251
        assertNotNull(fo);
287
        assertNotNull(fo);
252
        assertEquals(fo.lastModified().getTime(), f.lastModified());        
288
        assertEquals(fo.lastModified().getTime(), f.lastModified());        
Lines 268-273 public class XMLFileSystemTestHid extend Link Here
268
        return f;
304
        return f;
269
    }
305
    }
270
    
306
    
307
308
    public void testAttribute08 () throws Exception {
309
      URL fsURLDef = this.getClass().getResource ("data/Attributes.xml");
310
      assertTrue ("Cannot create XML FS for testing purposes", fsURLDef != null);
311
      FileSystem fs = FileSystemFactoryHid.createXMLSystem(getName(), this, fsURLDef);
312
      FileObject fo = fs.findResource("testMethodValue");
313
      assertTrue ("Cannot acces  FileObject named testMethodValue", fo != null);
314
315
      String testName = "test1";
316
      Object obj = fo.getAttribute(testName);
317
      assertTrue ("methodValue failed", obj != null);
318
      assertTrue ("methodValue doesn't keep order ",
319
      obj.equals(getObjectViaMethodValue1 (fo, testName)));
320
321
      testName = "test2";
322
      obj = fo.getAttribute(testName);
323
      assertTrue ("methodValue failed", obj != null);
324
      assertTrue ("methodValue doesn't keep order ",
325
      obj.equals(getObjectViaMethodValue2 (testName, fo)));
326
327
      testName = "test3";
328
      obj = fo.getAttribute(testName);
329
      assertTrue ("methodValue failed", obj != null);
330
      assertTrue ("methodValue doesn't keep order ",
331
      obj.equals(getObjectViaMethodValue3 (fo)));
332
333
      testName = "test4";
334
      obj = fo.getAttribute(testName);
335
      assertTrue ("methodValue failed", obj != null);
336
      assertTrue ("methodValue doesn't keep order ",
337
      obj.equals(getObjectViaMethodValue4 (testName)));
338
339
      testName = "test5";
340
      obj = fo.getAttribute(testName);
341
      assertTrue ("methodValue failed", obj != null);
342
      assertTrue ("methodValue doesn't keep order ",
343
      obj.equals(getObjectViaMethodValue5 ()));
344
345
      testName = "test6";
346
      obj = fo.getAttribute(testName);
347
      assertTrue ("methodValue failed", obj != null);
348
      assertEquals("even works for java.util.Map", "Ahoj1", obj);
349
350
      testName = "test7";
351
      obj = fo.getAttribute(testName);
352
      assertTrue ("methodValue failed", obj != null);
353
      assertEquals("works for map and string", "Ahoj1test7", obj);
354
355
      testName = "testLoc";
356
      obj = fo.getAttribute(testName);
357
      assertNotNull("Value returned", obj);
358
      assertEquals("works for bundle key", "Hello World!", obj);
359
    }
360
271
    
361
    
272
    public void testChangeOfAnAttributeInLayerIsFiredIfThereIsRealChange() throws Exception {
362
    public void testChangeOfAnAttributeInLayerIsFiredIfThereIsRealChange() throws Exception {
273
        XMLFileSystem fs = new XMLFileSystem();
363
        XMLFileSystem fs = new XMLFileSystem();
Lines 333-362 public class XMLFileSystemTestHid extend Link Here
333
        public List<FileEvent> change = new ArrayList<FileEvent>();
423
        public List<FileEvent> change = new ArrayList<FileEvent>();
334
        
424
        
335
        
425
        
426
        @Override
336
        public void fileRenamed(FileRenameEvent fe) {
427
        public void fileRenamed(FileRenameEvent fe) {
337
            events.add(fe);
428
            events.add(fe);
338
        }
429
        }
339
430
431
        @Override
340
        public void fileAttributeChanged(FileAttributeEvent fe) {
432
        public void fileAttributeChanged(FileAttributeEvent fe) {
341
            events.add(fe);
433
            events.add(fe);
342
        }
434
        }
343
435
436
        @Override
344
        public void fileFolderCreated(FileEvent fe) {
437
        public void fileFolderCreated(FileEvent fe) {
345
            events.add(fe);
438
            events.add(fe);
346
        }
439
        }
347
440
441
        @Override
348
        public void fileDeleted(FileEvent fe) {
442
        public void fileDeleted(FileEvent fe) {
349
            events.add(fe);
443
            events.add(fe);
350
        }
444
        }
351
445
446
        @Override
352
        public void fileDataCreated(FileEvent fe) {
447
        public void fileDataCreated(FileEvent fe) {
353
            events.add(fe);
448
            events.add(fe);
354
        }
449
        }
355
450
451
        @Override
356
        public void fileChanged(FileEvent fe) {
452
        public void fileChanged(FileEvent fe) {
357
            change.add(fe);
453
            change.add(fe);
358
        }
454
        }
359
        
455
        
360
    }
456
    }
457
    private static String getObjectViaMethodValue1 (FileObject fo, String testName) {
458
        return fo.getPath()+testName;
459
    }
460
461
    private static String getObjectViaMethodValue1 (String testName, FileObject fo) {
462
        return testName+fo.getPath();
463
    }
464
465
    private static String getObjectViaMethodValue1 (FileObject fo) {
466
        return fo.getPath();
467
    }
468
469
    private static String getObjectViaMethodValue1 (String testName) {
470
        return testName;
471
    }
472
473
    private static String getObjectViaMethodValue1 () {
474
        return "";
475
    }
476
///
477
    private static String getObjectViaMethodValue2 (String testName, FileObject fo) {
478
        return testName+fo.getPath();
479
    }
480
481
    private static String getObjectViaMethodValue2 (FileObject fo) {
482
        return fo.getPath();
483
    }
484
485
    private static String getObjectViaMethodValue2 (String testName) {
486
        return testName;
487
    }
488
489
    private static String getObjectViaMethodValue2 () {
490
        return "";
491
    }
492
///
493
    private static String getObjectViaMethodValue3 (FileObject fo) {
494
        return fo.getPath();
495
    }
496
497
    private static String getObjectViaMethodValue3 (String testName) {
498
        return testName;
499
    }
500
501
    private static String getObjectViaMethodValue3 () {
502
        return "";
503
    }
504
///
505
    private static String getObjectViaMethodValue4 (String testName) {
506
        return testName;
507
    }
508
509
    private static String getObjectViaMethodValue4 () {
510
        return "";
511
    }
512
///
513
    private static String getObjectViaMethodValue5 () {
514
        return "";
515
    }
516
517
    private static Object getObjectViaMethodValue6 (Map attrs) {
518
        try {
519
            attrs.keySet().iterator().remove();
520
            return "UnsupportedOperationException";
521
        } catch (UnsupportedOperationException ex) {
522
            // ok
523
        }
524
        try {
525
            attrs.put("value1", "nothing");
526
            return "UnsupportedOperationException";
527
        } catch (UnsupportedOperationException ex) {
528
            // ok
529
        }
530
        try {
531
            attrs.remove("value1");
532
            return "UnsupportedOperationException";
533
        } catch (UnsupportedOperationException ex) {
534
            // ok
535
        }
536
537
538
        return attrs.get("value1");
539
    }
540
    private static Object getObjectViaMethodValue7 (Map<String,Object> attrs, String attrName) {
541
        assertEquals(9, attrs.keySet().size());
542
        try {
543
            attrs.entrySet().remove(null);
544
            return "UnsupportedOperationException";
545
        } catch (UnsupportedOperationException ex) {
546
            // ok
547
        }
548
549
550
        return attrs.get("value1") + attrName;
551
    }
361
    
552
    
362
}
553
}
(-)a/openide.filesystems/test/unit/src/org/openide/filesystems/data/Attributes.xml (-9 / +9 lines)
Lines 8-24 Link Here
8
        Purpose of the document: testing of attributes.
8
        Purpose of the document: testing of attributes.
9
-->
9
-->
10
10
11
<!DOCTYPE filesystem PUBLIC '-//NetBeans//DTD Filesystem 1.1//EN' 'http://www.netbeans.org/dtds/filesystem-1_1.dtd'>
11
<!DOCTYPE filesystem PUBLIC '-//NetBeans//DTD Filesystem 1.2//EN' 'http://www.netbeans.org/dtds/filesystem-1_2.dtd'>
12
<filesystem>
12
<filesystem>
13
    <folder name="testMethodValue"> 
13
    <folder name="testMethodValue"> 
14
        <attr name="test1" methodvalue="org.openide.filesystems.AttributesTestHidden.getObjectViaMethodValue1"/>
14
        <attr name="test1" methodvalue="org.openide.filesystems.XMLFileSystemTestHid.getObjectViaMethodValue1"/>
15
        <attr name="test2" methodvalue="org.openide.filesystems.AttributesTestHidden.getObjectViaMethodValue2"/>        
15
        <attr name="test2" methodvalue="org.openide.filesystems.XMLFileSystemTestHid.getObjectViaMethodValue2"/>
16
        <attr name="test3" methodvalue="org.openide.filesystems.AttributesTestHidden.getObjectViaMethodValue3"/>                
16
        <attr name="test3" methodvalue="org.openide.filesystems.XMLFileSystemTestHid.getObjectViaMethodValue3"/>
17
        <attr name="test4" methodvalue="org.openide.filesystems.AttributesTestHidden.getObjectViaMethodValue4"/>                
17
        <attr name="test4" methodvalue="org.openide.filesystems.XMLFileSystemTestHid.getObjectViaMethodValue4"/>
18
        <attr name="test5" methodvalue="org.openide.filesystems.AttributesTestHidden.getObjectViaMethodValue5"/>                
18
        <attr name="test5" methodvalue="org.openide.filesystems.XMLFileSystemTestHid.getObjectViaMethodValue5"/>
19
        <attr name="test6" methodvalue="org.openide.filesystems.AttributesTestHidden.getObjectViaMethodValue6"/>                
19
        <attr name="test6" methodvalue="org.openide.filesystems.XMLFileSystemTestHid.getObjectViaMethodValue6"/>
20
        <attr name="test7" methodvalue="org.openide.filesystems.AttributesTestHidden.getObjectViaMethodValue7"/>
20
        <attr name="test7" methodvalue="org.openide.filesystems.XMLFileSystemTestHid.getObjectViaMethodValue7"/>
21
                
22
        <attr name="value1" stringvalue="Ahoj1"/>
21
        <attr name="value1" stringvalue="Ahoj1"/>
22
        <attr name="testLoc" bundlevalue="org.openide.filesystems.data.TestBundle#AHOJ"/>
23
    </folder>
23
    </folder>
24
</filesystem>
24
</filesystem>
(-)846d1a231c05 (+39 lines)
Added Link Here
1
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2
# 
3
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
4
# 
5
# The contents of this file are subject to the terms of either the GNU
6
# General Public License Version 2 only ("GPL") or the Common
7
# Development and Distribution License("CDDL") (collectively, the
8
# "License"). You may not use this file except in compliance with the
9
# License. You can obtain a copy of the License at
10
# http://www.netbeans.org/cddl-gplv2.html
11
# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
12
# specific language governing permissions and limitations under the
13
# License.  When distributing the software, include this License Header
14
# Notice in each file and include the License file at
15
# nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
16
# particular file as subject to the "Classpath" exception as provided
17
# by Sun in the GPL Version 2 section of the License file that
18
# accompanied this code. If applicable, add the following below the
19
# License Header, with the fields enclosed by brackets [] replaced by
20
# your own identifying information:
21
# "Portions Copyrighted [year] [name of copyright owner]"
22
# 
23
# If you wish your version of this file to be governed by only the CDDL
24
# or only the GPL Version 2, indicate your decision by adding
25
# "[Contributor] elects to include this software in this distribution
26
# under the [CDDL or GPL Version 2] license." If you do not indicate a
27
# single choice of license, a recipient has the option to distribute
28
# your version of this file under either the CDDL, the GPL Version 2 or
29
# to extend the choice of license to its licensees as provided above.
30
# However, if you add GPL Version 2 code and therefore, elected the GPL
31
# Version 2 license, then the option applies only if the new code is
32
# made subject to such option by the copyright holder.
33
# 
34
# Contributor(s):
35
# 
36
# Portions Copyrighted 2008 Sun Microsystems, Inc.
37
38
AHOJ=Hello World!
39

Return to bug 138076