Search in sources :

Example 46 with Reference

use of javax.naming.Reference in project rabbitmq-jms-client by rabbitmq.

the class RMQConnectionFactoryTest method testDefaultConnectionFactoryReference.

@Test
public void testDefaultConnectionFactoryReference() throws Exception {
    RMQConnectionFactory connFactory = new RMQConnectionFactory();
    Reference ref = connFactory.getReference();
    assertEquals(defaultProps, getProps(ref), "Not the default properties");
}
Also used : Reference(javax.naming.Reference) Test(org.junit.jupiter.api.Test)

Example 47 with Reference

use of javax.naming.Reference in project rabbitmq-jms-client by rabbitmq.

the class RMQConnectionFactoryTest method testConnectionFactoryRegeneration.

@Test
public void testConnectionFactoryRegeneration() throws Exception {
    RMQConnectionFactory connFactory = new RMQConnectionFactory();
    connFactory.setHost("sillyHost");
    connFactory.setPassword("my-password");
    connFactory.setPort(42);
    connFactory.setQueueBrowserReadMax(52);
    connFactory.setSsl(true);
    connFactory.setTerminationTimeout(1234567890123456789L);
    connFactory.setUsername("fred");
    connFactory.setVirtualHost("bill");
    Reference ref = connFactory.getReference();
    RMQConnectionFactory newFactory = (RMQConnectionFactory) new RMQObjectFactory().createConnectionFactory(ref, new Hashtable<Object, Object>(), new CompositeName("newOne"));
    assertEquals("amqps://fred:my-password@sillyHost:42/bill", newFactory.getUri(), "Not the correct uri");
    assertEquals("sillyHost", newFactory.getHost(), "Not the correct host");
    assertEquals("my-password", newFactory.getPassword(), "Not the correct password");
    assertEquals(42, newFactory.getPort(), "Not the correct port");
    assertEquals(52, newFactory.getQueueBrowserReadMax(), "Not the correct queueBrowserReadMax");
    assertEquals(true, newFactory.isSsl(), "Not the correct ssl");
    assertEquals(15000L, newFactory.getTerminationTimeout(), "Not the correct terminationTimeout");
    assertEquals("fred", newFactory.getUsername(), "Not the correct username");
    assertEquals("bill", newFactory.getVirtualHost(), "Not the correct virtualHost");
}
Also used : Reference(javax.naming.Reference) Hashtable(java.util.Hashtable) CompositeName(javax.naming.CompositeName) Test(org.junit.jupiter.api.Test)

Example 48 with Reference

use of javax.naming.Reference in project rabbitmq-jms-client by rabbitmq.

the class RMQConnectionFactoryTest method testConnectionFactoryReferenceUpdated.

@Test
public void testConnectionFactoryReferenceUpdated() throws Exception {
    RMQConnectionFactory connFactory = new RMQConnectionFactory();
    connFactory.setQueueBrowserReadMax(52);
    Reference ref = connFactory.getReference();
    addStringRefProperty(ref, "host", "sillyHost");
    addStringRefProperty(ref, "password", "my-password");
    addStringRefProperty(ref, "port", "42");
    // duplicates don't overwrite
    addStringRefProperty(ref, "queueBrowserReadMax", "52");
    addStringRefProperty(ref, "onMessageTimeoutMs", "62");
    addStringRefProperty(ref, "ssl", "true");
    addStringRefProperty(ref, "terminationTimeout", "1234567890123456789");
    addStringRefProperty(ref, "username", "fred");
    addStringRefProperty(ref, "virtualHost", "bill");
    RMQConnectionFactory newFactory = (RMQConnectionFactory) new RMQObjectFactory().createConnectionFactory(ref, new Hashtable<Object, Object>(), new CompositeName("newOne"));
    assertEquals("sillyHost", newFactory.getHost(), "Not the correct host");
    assertEquals("my-password", newFactory.getPassword(), "Not the correct password");
    assertEquals(42, newFactory.getPort(), "Not the correct port");
    assertEquals(52, newFactory.getQueueBrowserReadMax(), "Not the correct queueBrowserReadMax");
    assertEquals(62, newFactory.getOnMessageTimeoutMs(), "Not the correct onMessageTimeoutMs");
    assertEquals(true, newFactory.isSsl(), "Not the correct ssl");
    assertEquals(1234567890123456789L, newFactory.getTerminationTimeout(), "Not the correct terminationTimeout");
    assertEquals("fred", newFactory.getUsername(), "Not the correct username");
    assertEquals("bill", newFactory.getVirtualHost(), "Not the correct virtualHost");
    assertEquals("amqps://fred:my-password@sillyHost:42/bill", newFactory.getUri());
}
Also used : Reference(javax.naming.Reference) Hashtable(java.util.Hashtable) CompositeName(javax.naming.CompositeName) Test(org.junit.jupiter.api.Test)

Example 49 with Reference

use of javax.naming.Reference in project mssql-jdbc by Microsoft.

the class SQLServerDataSource method getReference.

// Implement javax.naming.Referenceable interface methods.
public Reference getReference() {
    loggerExternal.entering(getClassNameLogging(), "getReference");
    Reference ref = getReferenceInternal("com.microsoft.sqlserver.jdbc.SQLServerDataSource");
    loggerExternal.exiting(getClassNameLogging(), "getReference", ref);
    return ref;
}
Also used : Reference(javax.naming.Reference)

Example 50 with Reference

use of javax.naming.Reference in project h2database by h2database.

the class JdbcDataSource method getReference.

/**
 * Get a new reference for this object, using the current settings.
 *
 * @return the new reference
 */
@Override
public Reference getReference() {
    debugCodeCall("getReference");
    String factoryClassName = JdbcDataSourceFactory.class.getName();
    Reference ref = new Reference(getClass().getName(), factoryClassName, null);
    ref.add(new StringRefAddr("url", url));
    ref.add(new StringRefAddr("user", userName));
    ref.add(new StringRefAddr("password", convertToString(passwordChars)));
    ref.add(new StringRefAddr("loginTimeout", String.valueOf(loginTimeout)));
    ref.add(new StringRefAddr("description", description));
    return ref;
}
Also used : StringRefAddr(javax.naming.StringRefAddr) Reference(javax.naming.Reference)

Aggregations

Reference (javax.naming.Reference)226 NamingException (javax.naming.NamingException)79 RefAddr (javax.naming.RefAddr)59 StringRefAddr (javax.naming.StringRefAddr)54 Context (javax.naming.Context)41 NameNotFoundException (javax.naming.NameNotFoundException)40 InitialContext (javax.naming.InitialContext)37 Test (org.junit.Test)33 Name (javax.naming.Name)30 NameAlreadyBoundException (javax.naming.NameAlreadyBoundException)28 Properties (java.util.Properties)26 OperationNotSupportedException (javax.naming.OperationNotSupportedException)25 NotContextException (javax.naming.NotContextException)24 ObjectFactory (javax.naming.spi.ObjectFactory)23 CompositeName (javax.naming.CompositeName)21 Referenceable (javax.naming.Referenceable)18 Binding (javax.naming.Binding)17 CompoundName (javax.naming.CompoundName)16 LinkRef (javax.naming.LinkRef)15 Hashtable (java.util.Hashtable)12