package com.maxifier.guice.mbean;

import org.testng.annotations.Test;

import static org.testng.Assert.assertTrue;

/**
 * Created by: Aleksey Didik
 * Date: 5/26/11
 * Time: 9:55 PM
 * <p/>
 * Copyright (c) 1999-2011 Maxifier Ltd. All Rights Reserved.
 * Code proprietary and confidential.
 * Use is subject to license terms.
 *
 * @author Aleksey Didik
 */
public class CGLIBMBeanGeneratorTest {

    @Test
    public void testNameCompliance() throws Exception {
        CGLIBMBeanGenerator cglibmBeanGenerator = new CGLIBMBeanGenerator();
        Foo mbeanPretender = new Foo();
        Object mbean = cglibmBeanGenerator.makeMBean(mbeanPretender);
        MBeanManagerImpl.checkCompliantion(mbean);
    }

    @Test
    public void testMethodDelegation() throws Exception {
        CGLIBMBeanGenerator cglibmBeanGenerator = new CGLIBMBeanGenerator();
        Foo mbeanPretender = new Foo();
        Object mbean = cglibmBeanGenerator.makeMBean(mbeanPretender);
        Foo.class.getMethod("hello").invoke(mbean);
        assertTrue(mbeanPretender.called, "mbeanPretender method have to be called");
    }

    static class Foo {

        boolean called;

        @MBeanMethod
        void hello() {
            called = true;
        }

    }
}

@@ -971,17 +971,24 @@
     
-Foo.c
+mbean.getC
 lass
+()
 .get
@@ -1115,16 +1115,23 @@
  %7D%0A%0A    
+public 
 static c
@@ -1196,16 +1196,23 @@
         
+public 
 void hel

fix Mbeans generation