ConnectionFactoryMock connFactory = new ConnectionFactoryMock();
Dictionary props = new Hashtable();
props.put(ConnectionFactory.IO_SCHEME, new String[]
{ "file", "http", "sms" });
ServiceRegistration registration = registerConnectionFactory(connFactory, props);
ConnectorService service = getConnectorService();
Connection connection = service.open("file://test.txt");
assertEquals("file://test.txt", connFactory.getName());
assertEquals(ConnectorService.READ_WRITE, connFactory.getMode());
assertEquals(false, connFactory.isTimeout());
assertNotNull("checks returned connection", connection);
connection = service.open("http://test.txt", ConnectorService.READ);
assertEquals("http://test.txt", connFactory.getName());
assertEquals(ConnectorService.READ, connFactory.getMode());
assertEquals(false, connFactory.isTimeout());
assertNotNull("checks returned connection", connection);
connection = service.open("sms://test.txt", ConnectorService.READ);
assertEquals("sms://test.txt", connFactory.getName());
assertEquals(ConnectorService.READ, connFactory.getMode());
assertEquals(false, connFactory.isTimeout());
assertNotNull("checks returned connection", connection);
try
{
connection = service.open("ftp://test.txt", ConnectorService.READ);
fail("Connection shouldn't be created");
} catch (ConnectionNotFoundException e)
{
// "expected"
}