Search in sources :

Example 21 with KeyValuePair

use of com.adaptris.util.KeyValuePair in project interlok by adaptris.

the class IdentityBuilderTest method testMappedMetadataIdentityBuilder_ObjectMetadata.

@Test
public void testMappedMetadataIdentityBuilder_ObjectMetadata() throws Exception {
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
    String username = getName() + ThreadLocalRandom.current().nextInt();
    String password = getName() + ThreadLocalRandom.current().nextInt();
    String role = getName() + +ThreadLocalRandom.current().nextInt();
    msg.getObjectHeaders().put(MAPPED_USER, username);
    msg.getObjectHeaders().put(MAPPED_PASSWORD, password);
    msg.getObjectHeaders().put(MAPPED_ROLE, role);
    MappedMetadataIdentityBuilder builder = new MappedMetadataIdentityBuilder(MetadataSource.Object, new KeyValuePairList(Arrays.asList(new KeyValuePair[] { new KeyValuePair(MAPPED_USER, USER), new KeyValuePair(MAPPED_PASSWORD, PASSWORD), new KeyValuePair(MAPPED_ROLE, ROLE) })));
    try {
        BaseCase.start(builder);
        Map<String, Object> identityMap = builder.build(msg);
        assertTrue(identityMap.containsKey(ROLE));
        assertTrue(identityMap.containsKey(USER));
        assertTrue(identityMap.containsKey(PASSWORD));
        assertEquals(username, identityMap.get(USER));
        assertEquals(password, identityMap.get(PASSWORD));
        assertEquals(role, identityMap.get(ROLE));
    } finally {
        BaseCase.stop(builder);
    }
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) KeyValuePairList(com.adaptris.util.KeyValuePairList) Test(org.junit.Test)

Example 22 with KeyValuePair

use of com.adaptris.util.KeyValuePair in project interlok by adaptris.

the class IdentityBuilderTest method testMappedMetadataIdentityBuilder.

@Test
public void testMappedMetadataIdentityBuilder() throws Exception {
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
    String username = getName() + ThreadLocalRandom.current().nextInt();
    String password = getName() + ThreadLocalRandom.current().nextInt();
    String role = getName() + +ThreadLocalRandom.current().nextInt();
    msg.addMetadata(MAPPED_USER, username);
    msg.addMetadata(MAPPED_PASSWORD, password);
    msg.addMetadata(MAPPED_ROLE, role);
    MappedMetadataIdentityBuilder builder = new MappedMetadataIdentityBuilder(new KeyValuePairList(Arrays.asList(new KeyValuePair[] { new KeyValuePair(MAPPED_USER, USER), new KeyValuePair(MAPPED_PASSWORD, PASSWORD), new KeyValuePair(MAPPED_ROLE, ROLE) })));
    try {
        BaseCase.start(builder);
        Map<String, Object> identityMap = builder.build(msg);
        assertTrue(identityMap.containsKey(ROLE));
        assertTrue(identityMap.containsKey(USER));
        assertTrue(identityMap.containsKey(PASSWORD));
        assertEquals(username, identityMap.get(USER));
        assertEquals(password, identityMap.get(PASSWORD));
        assertEquals(role, identityMap.get(ROLE));
    } finally {
        BaseCase.stop(builder);
    }
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) KeyValuePairList(com.adaptris.util.KeyValuePairList) Test(org.junit.Test)

Example 23 with KeyValuePair

use of com.adaptris.util.KeyValuePair in project interlok by adaptris.

the class VerifyIdentityServiceTest method testMetadataVerification.

@Test
public void testMetadataVerification() throws Exception {
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
    msg.addMetadata(USER, "user");
    msg.addMetadata(PASSWORD, "password");
    msg.addMetadata("dbUser", "user");
    msg.addMetadata("dbPassword", "password");
    MetadataIdentityVerifier verifier = new MetadataIdentityVerifier(new KeyValuePairSet(Arrays.asList(new KeyValuePair[] { new KeyValuePair(USER, "dbUser"), new KeyValuePair(PASSWORD, "dbPassword") })));
    MetadataIdentityBuilder builder = new MetadataIdentityBuilder(MetadataSource.Standard, new ArrayList<String>(Arrays.asList(USER, PASSWORD)));
    VerifyIdentityService service = new VerifyIdentityService(builder, verifier);
    execute(service, msg);
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) KeyValuePairSet(com.adaptris.util.KeyValuePairSet) Test(org.junit.Test)

Example 24 with KeyValuePair

use of com.adaptris.util.KeyValuePair in project interlok by adaptris.

the class XpathCacheValueTranslatorTest method createTranslator.

private XpathCacheValueTranslator createTranslator() {
    XpathCacheValueTranslator translator = new XpathCacheValueTranslator();
    KeyValuePairSet set = new KeyValuePairSet();
    set.add(new KeyValuePair("test", "uri:test"));
    translator.setNamespaceContext(set);
    translator.setXpath("/test:root/test:element[@id='one']");
    return translator;
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) KeyValuePairSet(com.adaptris.util.KeyValuePairSet)

Example 25 with KeyValuePair

use of com.adaptris.util.KeyValuePair in project interlok by adaptris.

the class JdbcServiceExample method applyDefaultConfig.

public static DatabaseConnection applyDefaultConfig(DatabaseConnection connection) {
    connection.setConnectionAttempts(2);
    connection.setUsername("my_db_username");
    connection.setPassword("plain or encoded password");
    connection.setConnectionRetryInterval(new TimeInterval(3L, "SECONDS"));
    KeyValuePairSet connectionProps = new KeyValuePairSet();
    connectionProps.add(new KeyValuePair("dontTrackOpenResources", "true"));
    connectionProps.add(new KeyValuePair("autoReconnect", "true"));
    connection.setConnectionProperties(connectionProps);
    return connection;
}
Also used : TimeInterval(com.adaptris.util.TimeInterval) KeyValuePair(com.adaptris.util.KeyValuePair) KeyValuePairSet(com.adaptris.util.KeyValuePairSet)

Aggregations

KeyValuePair (com.adaptris.util.KeyValuePair)143 Test (org.junit.Test)79 KeyValuePairSet (com.adaptris.util.KeyValuePairSet)55 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)26 KeyValuePairList (com.adaptris.util.KeyValuePairList)12 StandardJndiImplementation (com.adaptris.core.jms.jndi.StandardJndiImplementation)11 StandaloneProducer (com.adaptris.core.StandaloneProducer)10 Channel (com.adaptris.core.Channel)9 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)9 TimeInterval (com.adaptris.util.TimeInterval)9 ServiceException (com.adaptris.core.ServiceException)7 JmsConnection (com.adaptris.core.jms.JmsConnection)6 ArrayList (java.util.ArrayList)6 CoreException (com.adaptris.core.CoreException)5 StandardWorkflow (com.adaptris.core.StandardWorkflow)5 PasProducer (com.adaptris.core.jms.PasProducer)5 MetadataCollection (com.adaptris.core.MetadataCollection)4 MetadataElement (com.adaptris.core.MetadataElement)4 StandaloneConsumer (com.adaptris.core.StandaloneConsumer)4 StandaloneRequestor (com.adaptris.core.StandaloneRequestor)3