use of javax.naming.CompositeName 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.CompositeName in project wildfly by wildfly.
the class NamingContextTestCase method testLookupWitResolveResult.
@Test
public void testLookupWitResolveResult() throws Exception {
namingStore.bind(new CompositeName("test/nested"), "test");
final Reference reference = new Reference(String.class.getName(), new StringRefAddr("blahh", "test"), TestObjectFactoryWithNameResolution.class.getName(), null);
namingStore.bind(new CompositeName("comp"), reference);
Object result = namingContext.lookup(new CompositeName("comp/nested"));
assertEquals("test", result);
//the same with security permissions
result = testActionPermission(JndiPermission.ACTION_LOOKUP, Arrays.asList(new JndiPermission("test/nested", "lookup")), namingContext, "comp/nested");
assertEquals("test", result);
}
use of javax.naming.CompositeName in project wildfly by wildfly.
the class NamingContextTestCase method testCreateSubcontext.
@Test
public void testCreateSubcontext() throws Exception {
assertTrue(namingContext.createSubcontext(new CompositeName("test")) instanceof NamingContext);
//the same with security permissions
assertTrue(testActionPermission(JndiPermission.ACTION_CREATE_SUBCONTEXT, namingContext, "securitytest") instanceof NamingContext);
}
use of javax.naming.CompositeName 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.CompositeName 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));
}
Aggregations