Search in sources :

Example 16 with CompositeName

use of javax.naming.CompositeName in project wildfly by wildfly.

the class ServiceBasedNamingStoreTestCase method testListBindings.

@Test
public void testListBindings() throws Exception {
    final Object value = new Object();
    bindObject(ServiceName.JBOSS.append("TestBean"), value);
    bindObject(ServiceName.JBOSS.append("foo", "TestBean"), value);
    bindObject(ServiceName.JBOSS.append("foo", "bar", "TestBean"), value);
    bindObject(ServiceName.JBOSS.append("foo", "bar", "baz", "TestBean"), value);
    store.add(ServiceName.JBOSS.append("foos", "bar"));
    store.add(ServiceName.JBOSS.append("fo", "bar"));
    store.add(ServiceName.JBOSS.append("foo", "ba", "baz"));
    store.add(ServiceName.JBOSS.append("foo", "bart", "baz"));
    store.add(ServiceName.JBOSS.append("foo", "bar", "ba"));
    store.add(ServiceName.JBOSS.append("foo", "bar", "bazt"));
    store.add(ServiceName.JBOSS.append("foo", "bar", "art"));
    store.add(ServiceName.JBOSS.append("other", "one"));
    List<Binding> list = store.listBindings(new CompositeName(""));
    assertEquals(5, list.size());
    assertContains(list, "TestBean", Object.class);
    assertContains(list, "foo", NamingContext.class);
    assertContains(list, "fo", NamingContext.class);
    assertContains(list, "foos", NamingContext.class);
    assertContains(list, "other", NamingContext.class);
    list = store.listBindings(new CompositeName("foo"));
    assertEquals(4, list.size());
    assertContains(list, "TestBean", Object.class);
    assertContains(list, "ba", NamingContext.class);
    assertContains(list, "bart", NamingContext.class);
    assertContains(list, "bar", NamingContext.class);
    for (Binding binding : list) {
        if (binding.getName().equals("bar")) {
            final Object bean = Context.class.cast(binding.getObject()).lookup("TestBean");
            assertNotNull(bean);
            assertEquals(value, bean);
        }
    }
}
Also used : Binding(javax.naming.Binding) StopContext(org.jboss.msc.service.StopContext) Context(javax.naming.Context) StartContext(org.jboss.msc.service.StartContext) CompositeName(javax.naming.CompositeName) Test(org.junit.Test)

Example 17 with CompositeName

use of javax.naming.CompositeName in project wildfly by wildfly.

the class ServiceBasedNamingStoreTestCase method testLookupBinding.

@Test
public void testLookupBinding() throws Exception {
    final ServiceName bindingName = ServiceName.JBOSS.append("foo", "bar");
    final Object value = new Object();
    bindObject(bindingName, value);
    final Object obj = store.lookup(new CompositeName("foo/bar"));
    assertNotNull(obj);
    assertEquals(value, obj);
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) CompositeName(javax.naming.CompositeName) Test(org.junit.Test)

Example 18 with CompositeName

use of javax.naming.CompositeName in project wildfly by wildfly.

the class WritableServiceBasedNamingStoreTestCase method testBind.

@Test
public void testBind() throws Exception {
    final Name name = new CompositeName("test");
    final Object value = new Object();
    WritableServiceBasedNamingStore.pushOwner(OWNER_FOO);
    try {
        store.bind(name, value);
    } finally {
        WritableServiceBasedNamingStore.popOwner();
    }
    assertEquals(value, store.lookup(name));
}
Also used : CompositeName(javax.naming.CompositeName) CompositeName(javax.naming.CompositeName) Name(javax.naming.Name) ServiceName(org.jboss.msc.service.ServiceName) Test(org.junit.Test)

Example 19 with CompositeName

use of javax.naming.CompositeName in project wildfly by wildfly.

the class WritableServiceBasedNamingStoreTestCase method testBindNested.

@Test
public void testBindNested() throws Exception {
    final Name name = new CompositeName("nested/test");
    final Object value = new Object();
    WritableServiceBasedNamingStore.pushOwner(OWNER_FOO);
    try {
        store.bind(name, value);
    } finally {
        WritableServiceBasedNamingStore.popOwner();
    }
    assertEquals(value, store.lookup(name));
}
Also used : CompositeName(javax.naming.CompositeName) CompositeName(javax.naming.CompositeName) Name(javax.naming.Name) ServiceName(org.jboss.msc.service.ServiceName) Test(org.junit.Test)

Example 20 with CompositeName

use of javax.naming.CompositeName in project wildfly by wildfly.

the class InMemoryNamingStoreTestCase method testRebindAndLookup.

@Test
public void testRebindAndLookup() throws Exception {
    final Name name = new CompositeName("test");
    final Object object = new Object();
    nameStore.rebind(name, object, Object.class);
    final Object result = nameStore.lookup(name);
    assertEquals(object, result);
}
Also used : CompositeName(javax.naming.CompositeName) CompositeName(javax.naming.CompositeName) Name(javax.naming.Name) Test(org.junit.Test)

Aggregations

CompositeName (javax.naming.CompositeName)124 Test (org.junit.Test)69 Name (javax.naming.Name)43 NameNotFoundException (javax.naming.NameNotFoundException)27 NamingException (javax.naming.NamingException)25 Reference (javax.naming.Reference)19 Context (javax.naming.Context)18 InvalidNameException (javax.naming.InvalidNameException)13 NotContextException (javax.naming.NotContextException)12 ServiceName (org.jboss.msc.service.ServiceName)11 Test (org.junit.jupiter.api.Test)10 JndiPermission (org.wildfly.naming.java.permission.JndiPermission)10 Hashtable (java.util.Hashtable)9 Binding (javax.naming.Binding)8 LinkRef (javax.naming.LinkRef)8 OperationNotSupportedException (javax.naming.OperationNotSupportedException)8 CallableWithoutResult (org.apereo.portal.concurrency.CallableWithoutResult)7 IEntityGroup (org.apereo.portal.groups.IEntityGroup)7 BaseAggrEventsJpaDaoTest (org.apereo.portal.test.BaseAggrEventsJpaDaoTest)7 StringRefAddr (javax.naming.StringRefAddr)5