Search in sources :

Example 1 with TestPermission1

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);
    }
}
Also used : IPermissionService(org.eclipse.scout.rt.shared.services.common.security.IPermissionService) BeanMetaData(org.eclipse.scout.rt.platform.BeanMetaData) TestPermission1(org.eclipse.scout.rt.server.services.common.security.fixture.TestPermission1) TestPermission2(org.eclipse.scout.rt.server.services.common.security.fixture.TestPermission2) Permission(java.security.Permission) IBean(org.eclipse.scout.rt.platform.IBean)

Aggregations

Permission (java.security.Permission)1 BeanMetaData (org.eclipse.scout.rt.platform.BeanMetaData)1 IBean (org.eclipse.scout.rt.platform.IBean)1 TestPermission1 (org.eclipse.scout.rt.server.services.common.security.fixture.TestPermission1)1 TestPermission2 (org.eclipse.scout.rt.server.services.common.security.fixture.TestPermission2)1 IPermissionService (org.eclipse.scout.rt.shared.services.common.security.IPermissionService)1