Author: dkulp Date: Mon Aug 26 15:58:10 2013 New Revision: 1517582 URL: http://svn.apache.org/r1517582 Log: Merged revisions 1517576 via git cherry-pick from https://svn.apache.org/repos/asf/cxf/branches/2.7.x-fixes
........ r1517576 | dkulp | 2013-08-26 11:51:59 -0400 (Mon, 26 Aug 2013) | 10 lines Merged revisions 1517548 via git cherry-pick from https://svn.apache.org/repos/asf/cxf/trunk ........ r1517548 | dkulp | 2013-08-26 10:44:41 -0400 (Mon, 26 Aug 2013) | 2 lines Check the service itself and the binding for the various JMS spec extensors and adjust those url's as well. ........ ........ Modified: cxf/branches/2.6.x-fixes/testutils/src/main/java/org/apache/cxf/testutil/common/EmbeddedJMSBrokerLauncher.java Modified: cxf/branches/2.6.x-fixes/testutils/src/main/java/org/apache/cxf/testutil/common/EmbeddedJMSBrokerLauncher.java URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/testutils/src/main/java/org/apache/cxf/testutil/common/EmbeddedJMSBrokerLauncher.java?rev=1517582&r1=1517581&r2=1517582&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/testutils/src/main/java/org/apache/cxf/testutil/common/EmbeddedJMSBrokerLauncher.java (original) +++ cxf/branches/2.6.x-fixes/testutils/src/main/java/org/apache/cxf/testutil/common/EmbeddedJMSBrokerLauncher.java Mon Aug 26 15:58:10 2013 @@ -75,39 +75,13 @@ public class EmbeddedJMSBrokerLauncher e for (Object o : map.values()) { Service service = (Service)o; Map<?, ?> ports = service.getPorts(); + adjustExtensibilityElements(service.getExtensibilityElements(), url, encodedUrl); + for (Object p : ports.values()) { Port port = (Port)p; - List<?> l = port.getExtensibilityElements(); - for (Object e : l) { - if (e instanceof SOAPAddress) { - String add = ((SOAPAddress)e).getLocationURI(); - int idx = add.indexOf("jndiURL="); - if (idx != -1) { - int idx2 = add.indexOf("&", idx); - add = add.substring(0, idx) - + "jndiURL=" + url - + (idx2 == -1 ? "" : add.substring(idx2)); - ((SOAPAddress)e).setLocationURI(add); - } - } else { - try { - Field f = e.getClass().getDeclaredField("jmsNamingProperty"); - f.setAccessible(true); - List<?> props = (List<?>)f.get(e); - for (Object prop : props) { - f = prop.getClass().getDeclaredField("name"); - f.setAccessible(true); - if ("java.naming.provider.url".equals(f.get(prop))) { - f = prop.getClass().getDeclaredField("value"); - f.setAccessible(true); - f.set(prop, url); - } - } - } catch (Exception ex) { - //ignore - } - } - } + + adjustExtensibilityElements(port.getExtensibilityElements(), url, encodedUrl); + adjustExtensibilityElements(port.getBinding().getExtensibilityElements(), url, encodedUrl); } } } catch (Exception e) { @@ -115,6 +89,49 @@ public class EmbeddedJMSBrokerLauncher e } } + private static void adjustExtensibilityElements(List<?> l, + String url, + String encodedUrl) { + for (Object e : l) { + if (e instanceof SOAPAddress) { + String add = ((SOAPAddress)e).getLocationURI(); + int idx = add.indexOf("jndiURL="); + if (idx != -1) { + int idx2 = add.indexOf("&", idx); + add = add.substring(0, idx) + + "jndiURL=" + encodedUrl + + (idx2 == -1 ? "" : add.substring(idx2)); + ((SOAPAddress)e).setLocationURI(add); + } + } else if (e.getClass().getSimpleName().startsWith("JndiURLType")) { + try { + e.getClass().getMethod("setValue", String.class).invoke(e, url); + } catch (Exception ex) { + //ignore + } + } else { + try { + Field f = e.getClass().getDeclaredField("jmsNamingProperty"); + ReflectionUtil.setAccessible(f); + List<?> props = (List<?>)f.get(e); + for (Object prop : props) { + f = prop.getClass().getDeclaredField("name"); + ReflectionUtil.setAccessible(f); + if ("java.naming.provider.url".equals(f.get(prop))) { + f = prop.getClass().getDeclaredField("value"); + ReflectionUtil.setAccessible(f); + String value = (String)f.get(prop); + if (value == null || !value.startsWith("classpath")) { + f.set(prop, url); + } + } + } + } catch (Exception ex) { + //ignore + } + } + } + } public void stop() throws Exception { tearDown(); }
