use of org.eclipse.scout.rt.server.services.common.security.fixture.TestPermission1 in project scout.rt by eclipse.
the class PermissionServiceTest method testImpl.
/* ---------------------------------------------------------------------------------------------- */
/* Tests for Bug 398323 - CodeService / PermissionService: More fine-grained lookup strategies for finding classes */
/* ---------------------------------------------------------------------------------------------- */
private void testImpl(IPermissionService testService, boolean testPermission1Expected, boolean testPermission2Expected) {
List<IBean<?>> reg = TestingUtility.registerBeans(new BeanMetaData(IPermissionService.class).withInitialInstance(testService).withApplicationScoped(true));
try {
IPermissionService service = BEANS.get(IPermissionService.class);
assertSame(testService, service);
//
Set<Class<? extends Permission>> result = service.getAllPermissionClasses();
boolean testPermission1Found = false;
boolean testPermission2Found = false;
for (Class<?> b : result) {
if (ObjectUtility.equals(b.getName(), TestPermission1.class.getName())) {
testPermission1Found = true;
}
if (ObjectUtility.equals(b.getName(), TestPermission2.class.getName())) {
testPermission2Found = true;
}
}
//
if (testPermission1Expected) {
assertTrue("TestPermission1 class not found (expected: found)", testPermission1Found);
} else {
assertFalse("TestPermission1 class found (expected: not found)", testPermission1Found);
}
if (testPermission2Expected) {
assertTrue("TestPermission2 class not found (expected: found)", testPermission2Found);
} else {
assertFalse("TestPermission2 class found (expected: not found)", testPermission2Found);
}
} finally {
TestingUtility.unregisterBeans(reg);
}
}
Aggregations