Search in sources :

Example 51 with AdaptrisMarshaller

use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.

the class AdapterManagerTest method testMBean_AddAndBindSharedService.

@Test
public void testMBean_AddAndBindSharedService() 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);
        amp.addAndBindSharedService(m.marshal(new NullService(getName())));
        Adapter marshalledAdapter = (Adapter) m.unmarshal(amp.getConfiguration());
        assertEquals(1, marshalledAdapter.getSharedComponents().getServices().size());
        assertEquals(getName(), marshalledAdapter.getSharedComponents().getServices().get(0).getUniqueId());
        assertTrue(amp.getSharedServiceIds().contains(getName()));
        assertTrue(amp.containsSharedService(getName()));
    } finally {
        adapterManager.requestClose();
    }
}
Also used : AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) NullService(com.adaptris.core.NullService) ArrayList(java.util.ArrayList) Adapter(com.adaptris.core.Adapter) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 52 with AdaptrisMarshaller

use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.

the class AdapterManagerTest method testMBean_AddAndBindSharedConnection_IllegalState.

@Test
public void testMBean_AddAndBindSharedConnection_IllegalState() 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);
        AdapterManagerMBean amp = JMX.newMBeanProxy(mBeanServer, adapterObj, AdapterManagerMBean.class);
        try {
            amp.addAndBindSharedConnection(m.marshal(new NullConnection(getName())));
            fail();
        } catch (IllegalStateException expected) {
        }
    } finally {
        adapterManager.requestClose();
    }
}
Also used : AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) ArrayList(java.util.ArrayList) Adapter(com.adaptris.core.Adapter) NullConnection(com.adaptris.core.NullConnection) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 53 with AdaptrisMarshaller

use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.

the class MappedKeyMetadataFilterTest method testRoundTrip.

@Test
public void testRoundTrip() throws Exception {
    MappedKeyMetadataFilter f1 = new MappedKeyMetadataFilter("^key(.*)$", "actual$1");
    AdaptrisMarshaller cm = DefaultMarshaller.getDefaultMarshaller();
    MappedKeyMetadataFilter f2 = (MappedKeyMetadataFilter) cm.unmarshal(cm.marshal(f1));
    assertRoundtripEquality(f1, f2);
}
Also used : AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) Test(org.junit.Test)

Example 54 with AdaptrisMarshaller

use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.

the class IdentityBuilderTest method testMappedMetadataIdentityBuilder_RoundTrip.

@Test
public void testMappedMetadataIdentityBuilder_RoundTrip() throws Exception {
    MappedMetadataIdentityBuilder builder = new MappedMetadataIdentityBuilder(MetadataSource.Standard, new KeyValuePairList(Arrays.asList(new KeyValuePair[] { new KeyValuePair(MAPPED_USER, USER), new KeyValuePair(MAPPED_PASSWORD, PASSWORD), new KeyValuePair(MAPPED_ROLE, ROLE) })));
    AdaptrisMarshaller m = DefaultMarshaller.getDefaultMarshaller();
    assertRoundtripEquality(builder, m.unmarshal(m.marshal(builder)));
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) KeyValuePairList(com.adaptris.util.KeyValuePairList) Test(org.junit.Test)

Example 55 with AdaptrisMarshaller

use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.

the class MessageTypeTranslatorCase method roundTrip.

protected StandaloneProducer roundTrip(StandaloneProducer src) throws Exception {
    AdaptrisMarshaller m = DefaultMarshaller.getDefaultMarshaller();
    String xml = m.marshal(src);
    return (StandaloneProducer) m.unmarshal(xml);
}
Also used : AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) StandaloneProducer(com.adaptris.core.StandaloneProducer)

Aggregations

AdaptrisMarshaller (com.adaptris.core.AdaptrisMarshaller)64 Test (org.junit.Test)57 Adapter (com.adaptris.core.Adapter)43 ObjectName (javax.management.ObjectName)21 NullConnection (com.adaptris.core.NullConnection)17 URLString (com.adaptris.util.URLString)11 CoreException (com.adaptris.core.CoreException)10 GuidGenerator (com.adaptris.util.GuidGenerator)9 File (java.io.File)9 ArrayList (java.util.ArrayList)9 IOException (java.io.IOException)7 Channel (com.adaptris.core.Channel)4 NullService (com.adaptris.core.NullService)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)3 SharedConnection (com.adaptris.core.SharedConnection)3 StandardWorkflow (com.adaptris.core.StandardWorkflow)3 MockServiceWithConnection (com.adaptris.core.stubs.MockServiceWithConnection)3 URL (java.net.URL)3