Lines 44-61
Link Here
|
44 |
|
44 |
|
45 |
package org.netbeans.core.netigso; |
45 |
package org.netbeans.core.netigso; |
46 |
|
46 |
|
|
|
47 |
import java.util.logging.Level; |
47 |
import org.netbeans.core.startup.*; |
48 |
import org.netbeans.core.startup.*; |
48 |
import java.io.File; |
49 |
import java.io.File; |
49 |
import java.io.IOException; |
50 |
import java.io.IOException; |
50 |
import java.util.Locale; |
51 |
import java.util.Locale; |
|
|
52 |
import java.util.logging.Logger; |
51 |
import org.netbeans.Module; |
53 |
import org.netbeans.Module; |
52 |
import org.netbeans.ModuleManager; |
54 |
import org.netbeans.ModuleManager; |
|
|
55 |
import org.osgi.framework.Bundle; |
53 |
|
56 |
|
54 |
public class NetigsoReloadTest extends NetigsoHid { |
57 |
public class NetigsoReloadTest extends NetigsoHid { |
55 |
private static Module m1; |
58 |
private static Module m1; |
56 |
private static ModuleManager mgr; |
59 |
private static ModuleManager mgr; |
57 |
private File withActivator; |
60 |
private File withActivator; |
58 |
private File withoutA; |
61 |
private File withoutA; |
|
|
62 |
private Logger LOG; |
59 |
|
63 |
|
60 |
public NetigsoReloadTest(String name) { |
64 |
public NetigsoReloadTest(String name) { |
61 |
super(name); |
65 |
super(name); |
Lines 64-69
Link Here
|
64 |
protected @Override void setUp() throws Exception { |
68 |
protected @Override void setUp() throws Exception { |
65 |
Locale.setDefault(Locale.US); |
69 |
Locale.setDefault(Locale.US); |
66 |
clearWorkDir(); |
70 |
clearWorkDir(); |
|
|
71 |
|
72 |
LOG = Logger.getLogger("TEST." + getName()); |
67 |
|
73 |
|
68 |
File ud = new File(getWorkDir(), "ud"); |
74 |
File ud = new File(getWorkDir(), "ud"); |
69 |
ud.mkdirs(); |
75 |
ud.mkdirs(); |
Lines 76-82
Link Here
|
76 |
withoutA = changeManifest(withActivator, "Manifest-Version: 1.0\n" + |
82 |
withoutA = changeManifest(withActivator, "Manifest-Version: 1.0\n" + |
77 |
"Bundle-SymbolicName: org.activate\n" + |
83 |
"Bundle-SymbolicName: org.activate\n" + |
78 |
"Import-Package: org.osgi.framework\n" + |
84 |
"Import-Package: org.osgi.framework\n" + |
79 |
"Bundle-Version: 1.2\n"); |
85 |
"Bundle-Version: 1.1\n"); |
80 |
} |
86 |
} |
81 |
|
87 |
|
82 |
public void testCanReloadAModule() throws Exception { |
88 |
public void testCanReloadAModule() throws Exception { |
Lines 90-100
Link Here
|
90 |
} finally { |
96 |
} finally { |
91 |
mgr.mutexPrivileged().exitWriteAccess(); |
97 |
mgr.mutexPrivileged().exitWriteAccess(); |
92 |
} |
98 |
} |
|
|
99 |
|
100 |
Bundle b = NetigsoServicesTest.findBundle("org.activate"); |
101 |
assertEquals("version 1.1", "1.1.0", b.getVersion().toString()); |
93 |
|
102 |
|
|
|
103 |
LOG.info("deleting old version and replacing the JAR"); |
94 |
assertTrue("Delete is OK", withoutA.delete()); |
104 |
assertTrue("Delete is OK", withoutA.delete()); |
95 |
assertTrue("Rename is OK", withActivator.renameTo(withoutA)); |
105 |
assertTrue("Rename is OK", withActivator.renameTo(withoutA)); |
96 |
|
106 |
LOG.log(Level.INFO, "jar {0} replaced, redeploying", withoutA); |
97 |
TestModuleDeployer.deployTestModule(withoutA); |
107 |
TestModuleDeployer.deployTestModule(withoutA); |
|
|
108 |
LOG.info("Deployed new module"); |
109 |
|
110 |
Bundle newB = NetigsoServicesTest.findBundle("org.activate"); |
111 |
// assertEquals("new version 1.2.1", "1.2.1", newB.getVersion()); |
112 |
|
98 |
Class<?> main = m1.getClassLoader().loadClass("org.activate.Main"); |
113 |
Class<?> main = m1.getClassLoader().loadClass("org.activate.Main"); |
99 |
Object s = main.getField("start").get(null); |
114 |
Object s = main.getField("start").get(null); |
100 |
assertNotNull("Bundle started, its context provided", s); |
115 |
assertNotNull("Bundle started, its context provided", s); |