2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.mdsal.binding.generator.util;
10 import static org.junit.Assert.assertFalse;
11 import static org.junit.Assert.assertNotNull;
12 import static org.mockito.ArgumentMatchers.any;
13 import static org.mockito.Mockito.doNothing;
14 import static org.mockito.Mockito.mock;
16 import javassist.CannotCompileException;
17 import javassist.ClassPool;
18 import javassist.NotFoundException;
19 import org.junit.Test;
21 public class JavassistUtilsTest {
24 public void forClassPool() throws CannotCompileException, NotFoundException {
25 final JavassistUtils javassistUtils = JavassistUtils.forClassPool(ClassPool.getDefault());
26 final ClassGenerator classGenerator = mock(ClassGenerator.class);
27 doNothing().when(classGenerator).process(any());
29 final ClassCustomizer classCustomizer = mock(ClassCustomizer.class);
30 doNothing().when(classCustomizer).customizeClass(any());
31 assertNotNull(javassistUtils.instantiatePrototype("javassist.CtNewClass", "leWut", classCustomizer));
35 public void privateConstructTest() throws Exception {
36 assertFalse(JavassistUtils.class.getDeclaredConstructor(ClassPool.class).isAccessible());