Added
Link Here
|
1 |
package org.eclipse.core.tests.internal.registrycache; |
2 |
|
3 |
import java.io.*; |
4 |
import java.net.MalformedURLException; |
5 |
import java.net.URL; |
6 |
import java.util.Iterator; |
7 |
import java.util.Map; |
8 |
|
9 |
import junit.framework.Test; |
10 |
import junit.framework.TestSuite; |
11 |
|
12 |
import org.eclipse.core.internal.plugins.*; |
13 |
import org.eclipse.core.internal.runtime.InternalPlatform; |
14 |
import org.eclipse.core.runtime.model.Factory; |
15 |
import org.eclipse.core.runtime.model.PluginRegistryModel; |
16 |
|
17 |
public class LazyCacheTests extends SimpleCacheTests { |
18 |
public LazyCacheTests() { |
19 |
super(); |
20 |
} |
21 |
public LazyCacheTests(String name) { |
22 |
super(name); |
23 |
} |
24 |
public PluginRegistryModel doCacheRead(PluginRegistryModel inRegistry, DataInputStream input, Factory factory) { |
25 |
// Cobble together a plugin path |
26 |
Map regIndex = InternalPlatform.getRegIndex(); |
27 |
URL[] pluginPath = null; |
28 |
if (regIndex != null) { |
29 |
int entrySize = regIndex.keySet().size(); |
30 |
pluginPath = new URL[entrySize]; |
31 |
int i = 0; |
32 |
for (Iterator list = regIndex.keySet().iterator(); list.hasNext();) { |
33 |
String fileName = (String)list.next(); |
34 |
fileName = "file:" + fileName; |
35 |
try { |
36 |
pluginPath[i++] = new URL(fileName); |
37 |
} catch (MalformedURLException badURL) { |
38 |
assertTrue("2.1 Bad url found for " + fileName + ".", true); |
39 |
} |
40 |
} |
41 |
} |
42 |
RegistryCacheReader cacheReader = new RegistryCacheLazyReader(factory, new File(DEFAULT_LOCATION), true); |
43 |
PluginRegistryModel newRegistry = cacheReader.readPluginRegistry(input, pluginPath, true); |
44 |
return newRegistry; |
45 |
} |
46 |
public static Test suite() { |
47 |
TestSuite suite = new TestSuite("LazyCacheTests"); |
48 |
suite.addTest(new LazyCacheTests("pluginTest")); |
49 |
suite.addTest(new LazyCacheTests("requiresTest")); |
50 |
suite.addTest(new LazyCacheTests("libraryTest")); |
51 |
suite.addTest(new LazyCacheTests("extensionTest")); |
52 |
suite.addTest(new LazyCacheTests("readOnlyTest")); |
53 |
suite.addTest(new LazyCacheTests("registryTest")); |
54 |
suite.addTest(new LazyCacheTests("extExtPtLinkTest")); |
55 |
suite.addTest(new LazyCacheTests("realRegistryTest")); |
56 |
suite.addTest(new LazyCacheTests("fragmentTest")); |
57 |
suite.addTest(new LazyCacheTests("fragmentPluginTest")); |
58 |
suite.addTest(new LazyCacheTests("fragmentExtensionTest")); |
59 |
suite.addTest(new LazyCacheTests("fragmentExtExtPtLinkTest")); |
60 |
suite.addTest(new LazyCacheTests("fragmentLibraryTest")); |
61 |
suite.addTest(new LazyCacheTests("fragmentReadOnlyTest")); |
62 |
suite.addTest(new LazyCacheTests("fragmentRequiresTest")); |
63 |
suite.addTest(new LazyCacheTests("fragmentRegistryTest")); |
64 |
suite.addTest(new LazyCacheTests("testRegistryEOF")); |
65 |
return suite; |
66 |
} |
67 |
} |