Search in sources :

Example 1 with TestSecurityModuleNoDB

use of org.killbill.billing.util.glue.TestSecurityModuleNoDB in project killbill by killbill.

the class TestPermissionAnnotationMethodInterceptor method testAOPForClass.

@Test(groups = "fast")
public void testAOPForClass() throws Exception {
    // Make sure it works as expected without any AOP magic
    final IAopTester simpleTester = new AopTester();
    try {
        simpleTester.createRefund();
    } catch (Exception e) {
        Assert.fail(e.getLocalizedMessage());
    }
    // Now, verify the interception works
    configureShiro();
    // Shutdown the cache manager to avoid duplicate exceptions
    CacheManager.getInstance().shutdown();
    final Injector injector = Guice.createInjector(Stage.PRODUCTION, new ShiroModuleNoDB(configSource), new KillBillShiroAopModule(), new TestSecurityModuleNoDB(configSource), new AbstractModule() {

        @Override
        protected void configure() {
            bind(IDBI.class).toInstance(Mockito.mock(IDBI.class));
        }
    });
    final AopTester aopedTester = injector.getInstance(AopTester.class);
    verifyAopedTester(aopedTester);
}
Also used : TestSecurityModuleNoDB(org.killbill.billing.util.glue.TestSecurityModuleNoDB) KillBillShiroAopModule(org.killbill.billing.util.glue.KillBillShiroAopModule) Injector(com.google.inject.Injector) ShiroModuleNoDB(org.killbill.billing.util.glue.TestUtilModuleNoDB.ShiroModuleNoDB) UnauthenticatedException(org.apache.shiro.authz.UnauthenticatedException) AuthorizationException(org.apache.shiro.authz.AuthorizationException) AbstractModule(com.google.inject.AbstractModule) Test(org.testng.annotations.Test)

Example 2 with TestSecurityModuleNoDB

use of org.killbill.billing.util.glue.TestSecurityModuleNoDB in project killbill by killbill.

the class TestPermissionAnnotationMethodInterceptor method testAOPForInterface.

@Test(groups = "fast")
public void testAOPForInterface() throws Exception {
    // Make sure it works as expected without any AOP magic
    final IAopTester simpleTester = new AopTesterImpl();
    try {
        simpleTester.createRefund();
    } catch (Exception e) {
        Assert.fail(e.getLocalizedMessage());
    }
    // Now, verify the interception works
    configureShiro();
    // Shutdown the cache manager to avoid duplicate exceptions
    CacheManager.getInstance().shutdown();
    final Injector injector = Guice.createInjector(Stage.PRODUCTION, new ShiroModuleNoDB(configSource), new KillBillShiroAopModule(), new TestSecurityModuleNoDB(configSource), new AbstractModule() {

        @Override
        public void configure() {
            bind(IDBI.class).toInstance(Mockito.mock(IDBI.class));
            bind(IAopTester.class).to(AopTesterImpl.class).asEagerSingleton();
        }
    });
    final IAopTester aopedTester = injector.getInstance(IAopTester.class);
    verifyAopedTester(aopedTester);
}
Also used : TestSecurityModuleNoDB(org.killbill.billing.util.glue.TestSecurityModuleNoDB) KillBillShiroAopModule(org.killbill.billing.util.glue.KillBillShiroAopModule) Injector(com.google.inject.Injector) ShiroModuleNoDB(org.killbill.billing.util.glue.TestUtilModuleNoDB.ShiroModuleNoDB) UnauthenticatedException(org.apache.shiro.authz.UnauthenticatedException) AuthorizationException(org.apache.shiro.authz.AuthorizationException) AbstractModule(com.google.inject.AbstractModule) Test(org.testng.annotations.Test)

Aggregations

AbstractModule (com.google.inject.AbstractModule)2 Injector (com.google.inject.Injector)2 AuthorizationException (org.apache.shiro.authz.AuthorizationException)2 UnauthenticatedException (org.apache.shiro.authz.UnauthenticatedException)2 KillBillShiroAopModule (org.killbill.billing.util.glue.KillBillShiroAopModule)2 TestSecurityModuleNoDB (org.killbill.billing.util.glue.TestSecurityModuleNoDB)2 ShiroModuleNoDB (org.killbill.billing.util.glue.TestUtilModuleNoDB.ShiroModuleNoDB)2 Test (org.testng.annotations.Test)2