JSONWebServiceClientImpl extends BaseJSONWebServiceClientImpl { @Activate protected void activate(Map<String, Object> properties) throws IOReactorException { _setHeaders(getString("headers", properties)); setClassLoader((ClassLoader)properties.get("classLoader")); setHostName(getString("hostName", properties)); setHostPort(Integer.parseInt(getString("hostPort", properties))); setKeyStore((KeyStore)properties.get("keyStore")); setLogin(getString("login", properties)); if (properties.containsKey("maxAttempts")) { setMaxAttempts( Integer.parseInt(getString("maxAttempts", properties))); } setPassword(getString("password", properties)); setProtocol(getString("protocol", properties)); if (properties.containsKey("proxyAuthType")) { setProxyAuthType(getString("proxyAuthType", properties)); setProxyDomain(getString("proxyDomain", properties)); setProxyWorkstation(getString("proxyWorkstation", properties)); } if (properties.containsKey("proxyHostName")) { setProxyHostName(getString("proxyHostName", properties)); setProxyHostPort( Integer.parseInt(getString("proxyHostPort", properties))); setProxyLogin(getString("proxyLogin", properties)); setProxyPassword(getString("proxyPassword", properties)); } afterPropertiesSet(); }  @Override void afterPropertiesSet();  }
@Test public void testActivateForBasicProxy() throws Exception { JSONWebServiceClientImpl jsonWebServiceClientImpl = new JSONWebServiceClientImpl(); Map<String, Object> properties = getBaseProperties(); properties.put("proxyHostName", "proxyhost.net"); properties.put("proxyHostPort", "443"); properties.put("proxyLogin", "proxylogin"); properties.put("proxyPassword", "proxypass"); jsonWebServiceClientImpl.activate(properties); Assert.assertEquals( properties.get("hostName"), jsonWebServiceClientImpl.getHostName()); Assert.assertEquals( properties.get("protocol"), jsonWebServiceClientImpl.getProtocol()); Assert.assertNull(jsonWebServiceClientImpl.getProxyAuthType()); Assert.assertEquals( properties.get("proxyHostName"), jsonWebServiceClientImpl.getProxyHostName()); Assert.assertEquals( Integer.parseInt(String.valueOf(properties.get("proxyHostPort"))), jsonWebServiceClientImpl.getProxyHostPort()); Assert.assertEquals( properties.get("proxyLogin"), jsonWebServiceClientImpl.getProxyLogin()); Assert.assertEquals( properties.get("proxyPassword"), jsonWebServiceClientImpl.getProxyPassword()); }
@Test public void testActivateForNTLMProxy() throws Exception { JSONWebServiceClientImpl jsonWebServiceClientImpl = new JSONWebServiceClientImpl(); Map<String, Object> properties = getBaseProperties(); properties.put("proxyAuthType", "ntlm"); properties.put("proxyDomain", "liferay.com"); properties.put("proxyWorkstation", "lrdcom2003"); jsonWebServiceClientImpl.activate(properties); Assert.assertEquals( properties.get("proxyAuthType"), jsonWebServiceClientImpl.getProxyAuthType()); Assert.assertEquals( properties.get("proxyDomain"), jsonWebServiceClientImpl.getProxyDomain()); Assert.assertEquals( properties.get("proxyWorkstation"), jsonWebServiceClientImpl.getProxyWorkstation()); }
@Test public void testActivateWithHeaders() throws Exception { JSONWebServiceClientImpl jsonWebServiceClientImpl = new JSONWebServiceClientImpl(); Map<String, Object> properties = getBaseProperties(); properties.put( "headers", "headerKey1=headerValue1;headerKey2=headerValue2"); jsonWebServiceClientImpl.activate(properties); Map<String, String> headers = jsonWebServiceClientImpl.getHeaders(); Assert.assertTrue(headers.containsKey("headerKey1")); }