use of javax.naming.Name in project wildfly by wildfly.
the class WritableServiceBasedNamingStoreTestCase method testOwnerBindingReferences.
@Test
public void testOwnerBindingReferences() throws Exception {
final Name name = new CompositeName("test");
final ServiceName serviceName = store.buildServiceName(name);
final Object value = new Object();
// ensure bind does not exists
try {
store.lookup(name);
fail("Should have thrown name not found");
} catch (NameNotFoundException expect) {
}
final RuntimeBindReleaseService.References duBindingReferences = (RuntimeBindReleaseService.References) container.getService(JndiNamingDependencyProcessor.serviceName(OWNER_FOO)).getValue();
WritableServiceBasedNamingStore.pushOwner(OWNER_FOO);
try {
store.bind(name, value);
// Foo's RuntimeBindReleaseService should now have a reference to the new bind
assertTrue(duBindingReferences.contains(serviceName));
store.rebind(name, value);
// after rebind, Foo's RuntimeBindReleaseService should continue to have a reference to the bind
assertTrue(duBindingReferences.contains(serviceName));
store.unbind(name);
} finally {
WritableServiceBasedNamingStore.popOwner();
}
}
use of javax.naming.Name in project wildfly by wildfly.
the class NamingContextTestCase method testLookupReference.
@Test
public void testLookupReference() throws Exception {
final Name name = new CompositeName("test");
final Reference reference = new Reference(String.class.getName(), new StringRefAddr("blah", "test"), TestObjectFactory.class.getName(), null);
namingStore.bind(name, reference);
Object result = namingContext.lookup(name);
assertEquals("test", result);
//the same with security permissions
result = testActionPermission(JndiPermission.ACTION_LOOKUP, namingContext, "test");
assertEquals("test", result);
}
use of javax.naming.Name in project wildfly by wildfly.
the class NamingContextTestCase method testRebind.
@Test
public void testRebind() throws Exception {
final Name name = new CompositeName("test");
final Object value = new Object();
namingStore.bind(name, value);
Object newValue = new Object();
namingContext.rebind(name, newValue);
assertEquals(newValue, namingStore.lookup(name));
//the same with security permissions
newValue = new Object();
testActionPermission(JndiPermission.ACTION_REBIND, namingContext, "test", newValue);
assertEquals(newValue, namingStore.lookup(name));
}
use of javax.naming.Name in project wildfly by wildfly.
the class NamingContextTestCase method testUnbind.
@Test
public void testUnbind() throws Exception {
final Name name = new CompositeName("test");
final Object value = new Object();
namingStore.bind(name, value);
namingContext.unbind(name);
try {
namingStore.lookup(name);
fail("Should have thrown name not found");
} catch (NameNotFoundException expect) {
}
//the same with security permissions
testActionPermission(JndiPermission.ACTION_BIND, namingContext, "test", value);
testActionPermission(JndiPermission.ACTION_UNBIND, namingContext, "test");
try {
namingStore.lookup(name);
fail("Should have thrown name not found");
} catch (NameNotFoundException expect) {
}
}
use of javax.naming.Name in project wildfly by wildfly.
the class NamingContextTestCase method testBind.
@Test
public void testBind() throws Exception {
Name name = new CompositeName("test");
final Object value = new Object();
namingContext.bind(name, value);
assertEquals(value, namingStore.lookup(name));
//the same with security permissions
name = new CompositeName("securitytest");
testActionPermission(JndiPermission.ACTION_BIND, namingContext, "securitytest", value);
assertEquals(value, namingStore.lookup(name));
}
Aggregations