public class AsmClassAgentTest {
@Test
public void test_duplicate_class_exception() throws Exception {
int[] cc = new int[4];
ClassAgent ca = getNewClassAgent();
ca.addInterceptor(MethodMatcherFactory.matcher(".*"), new MethodCounter(cc));
ClassAgent ca2 = getNewClassAgent();
ca2.addInterceptor(MethodMatcherFactory.matcher(".*"), new MethodCounter(cc));
ClassDefiner cd = Nutzs.cd();
Class<? extends Moose> c = ca.define(cd, Moose.class);
Moose m = c.newInstance();
m.doSomething(BEH.run);
assertEquals("[2, 2, 0, 0]", Json.toJson(cc));
Class<? extends Moose> c2 = ca2.define(cd, Moose.class);
assertEquals(c, c2);
m = c.newInstance();
m.doSomething(BEH.run);
assertEquals("[4, 4, 0, 0]", Json.toJson(cc));
}