Skip to content

Commit 50e279b

Browse files
committed
Merge pull request kamranzafar#6 from geronimo-iia/master
test case on change
2 parents 628db0e + 88fe0b1 commit 50e279b

File tree

15 files changed

+218
-161
lines changed

15 files changed

+218
-161
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,7 @@ pip-log.txt
161161

162162
# Mac crap
163163
.DS_Store
164+
165+
JCL/.classpath
166+
167+
JCL/.project

JCL/.classpath

Lines changed: 0 additions & 11 deletions
This file was deleted.

JCL/.project

Lines changed: 0 additions & 17 deletions
This file was deleted.

JCL2/core/pom.xml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
<version>${pom.version}</version>
6565
</artifactItem>
6666
</artifactItems>
67-
6867
<outputDirectory>./target</outputDirectory>
6968
<stripVersion>true</stripVersion>
7069
<overWriteReleases>false</overWriteReleases>
@@ -97,12 +96,6 @@
9796
<skip>${skipTest}</skip>
9897
</configuration>
9998
</plugin>
100-
<plugin>
101-
<artifactId>maven-site-plugin</artifactId>
102-
<configuration>
103-
<generateReports>false</generateReports>
104-
</configuration>
105-
</plugin>
10699
</plugins>
107100
</build>
108101
<dependencies>

JCL2/core/src/main/java/org/xeustechnologies/jcl/AbstractClassLoader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ public ProxyClassLoader getCurrentLoader() {
450450
}
451451

452452
public ProxyClassLoader getThreadLoader() {
453-
return currentLoader;
453+
return threadLoader;
454454
}
455455

456456
public ProxyClassLoader getOsgiBootLoader() {
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package org.xeustechnologies.jcl;
2+
3+
import static org.junit.Assert.assertEquals;
4+
import static org.junit.Assert.assertNotNull;
5+
6+
import org.junit.Test;
7+
8+
/**
9+
* AbstractClassLoaderTest test case on AbstractClassLoader class.
10+
*
11+
* @author <a href="mailto:[email protected]" >Jerome Guibert</a>
12+
*
13+
*/
14+
public class AbstractClassLoaderTest {
15+
16+
@Test
17+
public void checkInitializationOfDefaultProxyClassLoader() {
18+
AbstractClassLoader classLoader = new AbstractClassLoader() {
19+
};
20+
21+
assertNotNull("SystemLoader should not be null", classLoader.getSystemLoader());
22+
assertNotNull("ThreadLoader should not be null", classLoader.getThreadLoader());
23+
assertNotNull("ParentLoader should not be null", classLoader.getParentLoader());
24+
assertNotNull("CurrentLoader should not be null", classLoader.getCurrentLoader());
25+
assertNotNull("OsgiBootLoader should not be null", classLoader.getOsgiBootLoader());
26+
27+
assertEquals("SystemLoader order should be 50", 50, classLoader.getSystemLoader().getOrder());
28+
assertEquals("ThreadLoader order should be 40", 40, classLoader.getThreadLoader().getOrder());
29+
assertEquals("ParentLoader order should be 30", 30, classLoader.getParentLoader().getOrder());
30+
assertEquals("CurrentLoader order should be 20", 20, classLoader.getCurrentLoader().getOrder());
31+
assertEquals("OsgiBootLoader order should be 0", 0, classLoader.getOsgiBootLoader().getOrder());
32+
33+
}
34+
35+
@Test
36+
public void checkDefaultEnabledProxy() {
37+
AbstractClassLoader classLoader = new AbstractClassLoader() {
38+
};
39+
40+
assertEquals(Configuration.isCurrentLoaderEnabled(), classLoader.getCurrentLoader().isEnabled());
41+
assertEquals(Configuration.isParentLoaderEnabled(), classLoader.getParentLoader().isEnabled());
42+
assertEquals(Configuration.isThreadContextLoaderEnabled(), classLoader.getThreadLoader().isEnabled());
43+
assertEquals(Configuration.isSystemLoaderEnabled(), classLoader.getSystemLoader().isEnabled());
44+
assertEquals(Configuration.isOsgiBootDelegationEnabled(), classLoader.getOsgiBootLoader().isEnabled());
45+
46+
}
47+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package org.xeustechnologies.jcl;
2+
3+
import org.junit.Test;
4+
import org.xeustechnologies.jcl.sample.Test1;
5+
6+
import static org.junit.Assert.*;
7+
8+
/**
9+
*
10+
* DelegateProxyClassLoaderTest test with DelegateProxyClassLoader.
11+
*
12+
* @author <a href="mailto:[email protected]" >Jerome Guibert</a>
13+
*
14+
*/
15+
public class DelegateProxyClassLoaderTest {
16+
17+
@Test
18+
public void checkDelegateProxyClassLoader() throws ClassNotFoundException {
19+
/**
20+
* First classLoader without Test1
21+
*/
22+
JarClassLoader classLoader = new JarClassLoader();
23+
doIsolated(classLoader);
24+
assertTrue(classLoader.getLocalLoader().isEnabled());
25+
try {
26+
classLoader.loadClass(Test1.class.getName());
27+
fail("Should obtain java.lang.ClassNotFoundException: org.xeustechnologies.jcl.sample.Test1");
28+
} catch (ClassNotFoundException e) {
29+
}
30+
/**
31+
* target classLoader with Test1
32+
*/
33+
JarClassLoader target = new JarClassLoader();
34+
doIsolated(classLoader);
35+
assertTrue(classLoader.getLocalLoader().isEnabled());
36+
target.add(Test1.class.getName());
37+
target.loadClass(Test1.class.getName());
38+
/**
39+
* Add delegate
40+
*/
41+
classLoader.addLoader(new DelegateProxyClassLoader(target));
42+
classLoader.loadClass(Test1.class.getName());
43+
}
44+
45+
/**
46+
* Only local loader.
47+
*
48+
* @param classLoader
49+
*/
50+
protected void doIsolated(JarClassLoader classLoader) {
51+
classLoader.getCurrentLoader().setEnabled(false);
52+
classLoader.getParentLoader().setEnabled(false);
53+
classLoader.getThreadLoader().setEnabled(false);
54+
classLoader.getSystemLoader().setEnabled(false);
55+
classLoader.getOsgiBootLoader().setEnabled(false);
56+
}
57+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package org.xeustechnologies.jcl.sample;
2+
3+
public class Test1 {
4+
5+
}

JCL2/pom.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@
129129
<configuration>
130130
<source>1.5</source>
131131
<target>1.5</target>
132+
<encoding>UTF-8</encoding>
132133
</configuration>
133134
</plugin>
134135
</plugins>
@@ -139,8 +140,7 @@
139140
<artifactId>maven-javadoc-plugin</artifactId>
140141
<configuration>
141142
<aggregate>true</aggregate>
142-
<excludePackageNames>org.xeustechnologies.jcl.test
143-
</excludePackageNames>
143+
<excludePackageNames>org.xeustechnologies.jcl.test</excludePackageNames>
144144
</configuration>
145145
</plugin>
146146
<plugin>
@@ -196,6 +196,12 @@
196196
<issueLinkTemplate>http://sourceforge.net/support/tracker.php?aid=%ISSUE% </issueLinkTemplate>
197197
</configuration>
198198
</plugin>
199+
<plugin>
200+
<artifactId>maven-site-plugin</artifactId>
201+
<configuration>
202+
<generateReports>false</generateReports>
203+
</configuration>
204+
</plugin>
199205
</plugins>
200206
</reporting>
201207
<dependencies>

JCL2/spring/pom.xml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
<artifactId>jcl-spring</artifactId>
1212
<name>JCL - Spring</name>
13-
<build>
13+
<build>
1414
<plugins>
1515
<plugin>
1616
<groupId>org.apache.maven.plugins</groupId>
@@ -42,8 +42,7 @@
4242
<configuration>
4343
<archive>
4444
<manifest>
45-
<addDefaultImplementationEntries>true
46-
</addDefaultImplementationEntries>
45+
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
4746
</manifest>
4847
</archive>
4948
</configuration>
@@ -66,7 +65,6 @@
6665
<version>${pom.version}</version>
6766
</artifactItem>
6867
</artifactItems>
69-
7068
<outputDirectory>./target</outputDirectory>
7169
<stripVersion>true</stripVersion>
7270
<overWriteReleases>false</overWriteReleases>
@@ -94,17 +92,12 @@
9492
<configuration>
9593
<includes>
9694
<include>org/xeustechnologies/jcl/spring/SpringTest.java
97-
</include>
95+
</include>
9896
</includes>
9997
<skip>${skipTest}</skip>
10098
</configuration>
10199
</plugin>
102-
<plugin>
103-
<artifactId>maven-site-plugin</artifactId>
104-
<configuration>
105-
<generateReports>false</generateReports>
106-
</configuration>
107-
</plugin>
100+
108101
</plugins>
109102
</build>
110103
<dependencies>

0 commit comments

Comments
 (0)