use of com.adaptris.util.URLString in project interlok by adaptris.
the class VersionedHttpsProduceConnection method initialiseClient.
/**
* @see HttpClientConnection#initialiseClient(java.lang.String)
*/
@Override
public HttpClientTransport initialiseClient(String url) throws HttpException {
HttpsClient client = new HttpsClient(new URLString(url), protocolVersion);
try {
if (getKeystore() != null) {
KeystoreFactory ksf = KeystoreFactory.getDefault();
KeystoreLocation ksl = null;
if (getKeystorePassword() != null) {
ksl = ksf.create(getKeystore(), Password.decode(getKeystorePassword()).toCharArray());
} else {
ksl = ksf.create(getKeystore());
}
char[] pkpw = PasswordOverride.discoverPrivateKeyPassword(ksl, getPrivateKeyPasswordProvider());
if (pkpw != null) {
client.registerPrivateKeyPassword(pkpw);
}
client.registerKeystore(ksf.create(ksl));
}
} catch (AdaptrisSecurityException e) {
throw new HttpException(e);
}
client.setAlwaysTrust(getAlwaysTrust());
return client;
}
use of com.adaptris.util.URLString in project interlok by adaptris.
the class MarshallingBaseCase method testUnmarshalFromURLString.
@Test
public void testUnmarshalFromURLString() throws Exception {
AdaptrisMarshaller marshaller = createMarshaller();
Adapter adapter = createMarshallingObject();
File f = new File(testOutputDir, new GuidGenerator().getUUID());
marshaller.marshal(adapter, f);
assertRoundtripEquality(adapter, marshaller.unmarshal(new URLString(f.toURI().toURL())));
}
use of com.adaptris.util.URLString in project interlok by adaptris.
the class MarshallingBaseCase method testUnmarshalFromUrlStringClasspath.
@Test
public void testUnmarshalFromUrlStringClasspath() throws Exception {
AdaptrisMarshaller marshaller = createMarshaller();
StandaloneProducer o1 = (StandaloneProducer) marshaller.unmarshal(new URLString(getClasspathXmlFilename()));
assertEquals("unique-id", o1.getUniqueId());
String unknownLoc = "zzzz-does-not-exist.xml";
try {
o1 = (StandaloneProducer) marshaller.unmarshal(new URLString(unknownLoc));
fail("Success unmarshal of something that doesn't exist");
} catch (CoreException e) {
assertNotNull(e.getCause());
assertTrue(IOException.class.isAssignableFrom(e.getCause().getClass()));
}
}
use of com.adaptris.util.URLString in project interlok by adaptris.
the class AdapterRegistryTest method testMultiPreProcessorCalled.
@Test
public void testMultiPreProcessorCalled() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName, 2, 2);
File filename = deleteLater(adapter);
DefaultMarshaller.getDefaultMarshaller().marshal(adapter, filename);
AdapterRegistry myAdapterRegistry = (AdapterRegistry) AdapterRegistry.findInstance(new JunitBootstrapProperties(new Properties()));
AdapterBuilder builder = new ArrayList<AdapterBuilder>(myAdapterRegistry.builders()).get(0);
builder.setConfigurationPreProcessorLoader(mockPreProcessorLoader);
ConfigPreProcessors preProcessorsList = new ConfigPreProcessors();
preProcessorsList.add(mockPreProcessor);
preProcessorsList.add(mockPreProcessor);
preProcessorsList.add(mockPreProcessor);
when(mockPreProcessorLoader.load(any(BootstrapProperties.class))).thenReturn(preProcessorsList);
when(mockPreProcessor.process(any(String.class))).thenReturn(FileUtils.readFileToString(filename));
myAdapterRegistry.createAdapter(new URLString(filename));
// Make sure our pre-processors are called - even though our pre-processors do nothing!
verify(mockPreProcessor, times(3)).process(any(String.class));
}
use of com.adaptris.util.URLString in project interlok by adaptris.
the class AdapterRegistryTest method testGetConfigurationURL.
@Test
public void testGetConfigurationURL() throws Exception {
AdapterRegistry adapterRegistry = (AdapterRegistry) AdapterRegistry.findInstance(new JunitBootstrapProperties(new Properties()));
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName, 2, 2);
File filename = deleteLater(adapter);
DefaultMarshaller.getDefaultMarshaller().marshal(adapter, filename);
URLString expectedURL = new URLString(filename);
ObjectName objName = adapterRegistry.createAdapter(expectedURL);
assertNotNull(objName);
assertTrue(mBeanServer.isRegistered(objName));
assertEquals(expectedURL, adapterRegistry.getConfigurationURL(objName));
}
Aggregations