/** * Create an endpoint and check its properties. * * @throws Exception if something goes wrong */ public void testValidEndpointURI() throws Exception { EndpointURI endpointUri = new MuleEndpointURI("legstar-wmq://CICS01.BRIDGE.REQUEST.QUEUE", muleContext); endpointUri.initialise(); assertEquals("legstar-wmq", endpointUri.getScheme()); assertEquals("legstar-wmq", endpointUri.getSchemeMetaInfo()); assertEquals("CICS01.BRIDGE.REQUEST.QUEUE", endpointUri.getAddress()); }
/** * Get user/password from URI. * * @throws Exception if something goes wrong */ public void testUserPasswordURI() throws Exception { EndpointURI endpointUri = new MuleEndpointURI("legstar-wmq://user:[email protected]", muleContext); endpointUri.initialise(); assertEquals("legstar-wmq", endpointUri.getScheme()); assertEquals("legstar-wmq", endpointUri.getSchemeMetaInfo()); assertEquals("CICS01.BRIDGE.REQUEST.QUEUE", endpointUri.getAddress()); assertEquals("user:password", endpointUri.getUserInfo()); assertEquals("user", endpointUri.getUser()); assertEquals("password", endpointUri.getPassword()); }
/** * Creates an uninitialied connector from the provided MuleEndpointURI. The scheme is used to * determine what kind of connector to create. Any params set on the uri can be used to initialise * bean properties on the created connector. * * <p>Note that the initalise method will need to be called on the connector returned. This is so * that developers can control when the connector initialisation takes place as this is likely to * initialse all connecotr resources. * * @param url the MuleEndpointURI url to create the connector with * @return a new Connector * @throws TransportFactoryException */ public static Connector createConnector(EndpointURI url, MuleContext muleContext) throws TransportFactoryException { try { Connector connector; String scheme = url.getSchemeMetaInfo(); TransportServiceDescriptor sd = (TransportServiceDescriptor) muleContext .getRegistry() .lookupServiceDescriptor( ServiceDescriptorFactory.TRANSPORT_SERVICE_TYPE, scheme, null); if (sd == null) { throw new ServiceException(CoreMessages.noServiceTransportDescriptor(scheme)); } connector = sd.createConnector(); if (connector != null) { connector.setMuleContext(muleContext); if (connector instanceof AbstractConnector) { ((AbstractConnector) connector).initialiseFromUrl(url); } } else { throw new TransportFactoryException( CoreMessages.objectNotSetInService("Connector", scheme)); } connector.setName(ObjectNameHelper.getConnectorName(connector)); // TODO Do we still need to support this for 2.x? // set any manager default properties for the connector // these are set on the Manager with a protocol i.e. // jms.specification=1.1 // Map props = new HashMap(); // // PropertiesUtils.getPropertiesWithPrefix(RegistryContext.getRegistry().lookupProperties(), // connector.getProtocol().toLowerCase(), props); // if (props.size() > 0) // { // props = PropertiesUtils.removeNamespaces(props); // BeanUtils.populateWithoutFail(connector, props, true); // } return connector; } catch (Exception e) { throw new TransportFactoryException( CoreMessages.failedToCreateObjectWith("Endpoint", url), e); } }