Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: monicadragomir <monica.dragomir@oracle.com>
- Loading branch information
1 parent
dd2d183
commit 16810e6
Showing
2 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
jaxws-ri/rt/src/test/java/com/sun/xml/ws/client/WSServiceDelegateTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright (c) 2019, 2019 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Distribution License v. 1.0, which is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
package com.sun.xml.ws.client; | ||
|
||
import java.lang.reflect.Method; | ||
|
||
import junit.framework.TestCase; | ||
|
||
public class WSServiceDelegateTest extends TestCase { | ||
public void testGetDelegatingLoader() throws Exception { | ||
MyClassLoader loader2 = new MyClassLoader(); | ||
MyClassLoader loader1 = new MyClassLoader(loader2); | ||
ClassLoader result = invokeGetDelegatingLoader(loader1, loader2); | ||
assertEquals(loader1, result); | ||
|
||
loader2 = new MyClassLoader(); | ||
loader1 = new MyClassLoader(); | ||
result = invokeGetDelegatingLoader(loader1, loader2); | ||
assertEquals(loader2, result.getParent()); | ||
|
||
result = invokeGetDelegatingLoader(loader1, null); | ||
assertEquals(loader1, result); | ||
|
||
result = invokeGetDelegatingLoader(null, loader2); | ||
assertEquals(loader2, result); | ||
} | ||
|
||
private ClassLoader invokeGetDelegatingLoader(ClassLoader loader1, ClassLoader loader2) throws Exception { | ||
Method m = WSServiceDelegate.class.getDeclaredMethod("getDelegatingLoader", ClassLoader.class, ClassLoader.class); | ||
m.setAccessible(true); | ||
return (ClassLoader)m.invoke(WSServiceDelegate.class, loader1, loader2); | ||
} | ||
private static class MyClassLoader extends ClassLoader { | ||
MyClassLoader() {} | ||
MyClassLoader(ClassLoader parent) {super(parent);} | ||
} | ||
} | ||
|
||
|