private static boolean validateUri(String uri) { try { // the same validation as done in DefaultCamelContext#normalizeEndpointUri(String) URISupport.normalizeUri(uri); } catch (URISyntaxException | UnsupportedEncodingException e) { LOG.error("Endpoint URI '" + uri + "' is not valid due to: " + e.getMessage(), e); return false; } return true; } }
/** * Verify if given parameter is equals to expected value. * * NOTE: expected uri is normalized before comparision, given uri should be * normalized by caller. * * @param expected Expected uri. * @param given Given uri, after normalization done by camel. */ protected void assertUriEquals(String expected, String given) { try { assertEquals(normalizeUri(expected), given); } catch (UnsupportedEncodingException e) { throw new Error("Unsuported encoding", e); } catch (URISyntaxException e) { throw new Error("Uri syntax is invalid", e); } }
/** * Verify if given parameter is equals to expected value. * * NOTE: expected uri is normalized before comparision, given uri should be * normalized by caller. * * @param expected Expected uri. * @param given Given uri, after normalization done by camel. */ protected void assertUriEquals(String expected, String given) { try { assertEquals(normalizeUri(expected), given); } catch (UnsupportedEncodingException e) { throw new Error("Unsuported encoding", e); } catch (URISyntaxException e) { throw new Error("Uri syntax is invalid", e); } }
/** * @param endpointUri he endpoint URI that this definition expects to act against */ public MorcBuilder(String endpointUri) { try { this.endpointUri = URISupport.normalizeUri(endpointUri); } catch (URISyntaxException | UnsupportedEncodingException e) { throw new RuntimeException(e); } //we don't want to use POJO to receive messages endpointOverrides.add(new CxfEndpointOverride()); endpointOverrides.add(new UrlConnectionOverride()); }
protected URI prepareCamelUri(String schema, String path, Map<String, Object> params) throws URISyntaxException { String url; if (schema == null) { url = path; } else { url = schema + "://" + path; } URI camelUri; try { camelUri = new URI(URISupport.normalizeUri(url)); } catch (UnsupportedEncodingException e) { camelUri = new URI(url); } if (params.isEmpty()) { return camelUri; } else { return URISupport.createURIWithQuery(camelUri, URISupport.createQueryString(params)); } }
protected URI prepareCamelUri(String schema, String path, Map<String, Object> params) throws URISyntaxException { String url; if (schema == null) { url = path; } else { url = schema + "://" + path; } URI camelUri; try { camelUri = new URI(URISupport.normalizeUri(url)); } catch (UnsupportedEncodingException e) { camelUri = new URI(url); } if (params.isEmpty()) { return camelUri; } else { return URISupport.createURIWithQuery(camelUri, URISupport.createQueryString(params)); } } }
private void parseUri(String remaining, HipchatEndpoint endpoint) throws Exception { String uri = URISupport.normalizeUri(remaining); URI hipChatUri = new URI(uri); if (hipChatUri.getHost() != null) { endpoint.getConfiguration().setHost(hipChatUri.getHost()); if (hipChatUri.getPort() != -1) { endpoint.getConfiguration().setPort(hipChatUri.getPort()); } endpoint.getConfiguration().setProtocol(hipChatUri.getScheme()); } }
/** * Verify if uri generated by model binding is equals to uri produced by test. * * @throws Exception Any exception can be thrown from uri normalization code. */ @Test public void verifyModelUri() throws Exception { String componentURI = createTestModel().getComponentURI().toString(); assertUriEquals(createEndpointUri(), normalizeUri(componentURI)); }
/** * Verify if uri generated by model binding is equals to uri produced by test. * * @throws Exception Any exception can be thrown from uri normalization code. */ @Test public void verifyModelUri() throws Exception { String componentURI = createTestModel().getComponentURI().toString(); assertUriEquals(createEndpointUri(), normalizeUri(componentURI)); }
URI remainingUri = new URI(URISupport.normalizeUri(remaining)); String scheme = remainingUri.getScheme();