use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.
the class AdapterManagerTest method testMBean_AddAndBindSharedConnection_Duplicate.
@Test
public void testMBean_AddAndBindSharedConnection_Duplicate() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
AdapterManager adapterManager = new AdapterManager(adapter);
ObjectName adapterObj = adapterManager.createObjectName();
AdaptrisMarshaller m = DefaultMarshaller.getDefaultMarshaller();
List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>();
mBeans.add(adapterManager);
mBeans.addAll(adapterManager.getAllDescendants());
try {
register(mBeans);
adapterManager.requestStart();
AdapterManagerMBean amp = JMX.newMBeanProxy(mBeanServer, adapterObj, AdapterManagerMBean.class);
assertTrue(amp.addAndBindSharedConnection(m.marshal(new NullConnection(getName()))));
assertFalse(amp.addAndBindSharedConnection(m.marshal(new NullConnection(getName()))));
Adapter marshalledAdapter = (Adapter) m.unmarshal(amp.getConfiguration());
assertEquals(1, marshalledAdapter.getSharedComponents().getConnections().size());
assertEquals(getName(), marshalledAdapter.getSharedComponents().getConnections().get(0).getUniqueId());
} finally {
adapterManager.requestClose();
}
}
use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.
the class AdapterManagerTest method testMBean_NotificationOnAddSharedConnection.
@Test
public void testMBean_NotificationOnAddSharedConnection() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
AdapterManager adapterManager = new AdapterManager(adapter);
ObjectName adapterObj = adapterManager.createObjectName();
SimpleNotificationListener listener = new SimpleNotificationListener();
NotificationFilterSupport filter = new NotificationFilterSupport();
filter.enableType(NOTIF_TYPE_ADAPTER_CONFIG);
AdaptrisMarshaller m = DefaultMarshaller.getDefaultMarshaller();
try {
adapterManager.registerMBean();
AdapterManagerMBean amp = JMX.newMBeanProxy(mBeanServer, adapterObj, AdapterManagerMBean.class);
mBeanServer.addNotificationListener(adapterObj, listener, filter, null);
amp.addSharedConnection(m.marshal(new NullConnection(getName())));
listener.waitForMessages(1);
assertEquals(1, listener.getNotifications().size());
Notification n = listener.getNotifications().get(0);
assertEquals(NOTIF_TYPE_ADAPTER_CONFIG, n.getType());
assertEquals(NOTIF_MSG_CONFIG_UPDATED, n.getMessage());
assertEquals(amp.getConfiguration(), n.getUserData());
} finally {
}
}
use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.
the class AdapterManagerTest method testMBean_AddSharedConnection_AddChannel_StartAdapter.
@Test
public void testMBean_AddSharedConnection_AddChannel_StartAdapter() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
AdapterManager adapterManager = new AdapterManager(adapter);
ObjectName adapterObj = adapterManager.createObjectName();
Channel newChannel = createChannel(getName(), 1);
newChannel.setConsumeConnection(new SharedConnection(getName()));
newChannel.setProduceConnection(new SharedConnection(getName()));
StandardWorkflow wf = (StandardWorkflow) newChannel.getWorkflowList().getWorkflows().get(0);
MockServiceWithConnection service = new MockServiceWithConnection(new SharedConnection(getName()));
wf.getServiceCollection().add(service);
AdaptrisMarshaller m = DefaultMarshaller.getDefaultMarshaller();
List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>();
mBeans.add(adapterManager);
mBeans.addAll(adapterManager.getAllDescendants());
try {
register(mBeans);
AdapterManagerMBean amp = JMX.newMBeanProxy(mBeanServer, adapterObj, AdapterManagerMBean.class);
amp.addSharedConnection(m.marshal(new NullConnection(getName())));
ObjectName channelObj = amp.addChannel(m.marshal(newChannel));
ChannelManagerMBean cmb = JMX.newMBeanProxy(mBeanServer, channelObj, ChannelManagerMBean.class);
adapterManager.requestStart();
assertEquals(StartedState.getInstance(), cmb.getComponentState());
} finally {
adapterManager.requestClose();
}
}
use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.
the class CompositeMetadataFilterTest method testRoundTrip.
@Test
public void testRoundTrip() throws Exception {
CompositeMetadataFilter f1 = new CompositeMetadataFilter(new NoOpMetadataFilter(), new RegexMetadataFilter());
AdaptrisMarshaller cm = DefaultMarshaller.getDefaultMarshaller();
CompositeMetadataFilter f2 = (CompositeMetadataFilter) cm.unmarshal(cm.marshal(f1));
BaseCase.assertRoundtripEquality(f1, f2);
}
use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.
the class IdentityBuilderTest method testCompositeMetadataIdentityBuilder_RoundTrip.
@Test
public void testCompositeMetadataIdentityBuilder_RoundTrip() throws Exception {
MappedMetadataIdentityBuilder mapped = new MappedMetadataIdentityBuilder(new KeyValuePairList(Arrays.asList(new KeyValuePair[] { new KeyValuePair(MAPPED_USER, USER), new KeyValuePair(MAPPED_PASSWORD, PASSWORD) })));
MetadataIdentityBuilder metadata = new MetadataIdentityBuilder(Arrays.asList(USER, PASSWORD, ROLE));
// Due to order, we should get the mapped-user becoming the "user" etc.
CompositeIdentityBuilder builder = new CompositeIdentityBuilder(new ArrayList<IdentityBuilder>(Arrays.asList(metadata, mapped)));
AdaptrisMarshaller m = DefaultMarshaller.getDefaultMarshaller();
assertRoundtripEquality(builder, m.unmarshal(m.marshal(builder)));
}
Aggregations