类org.mockito.cglib.core.NamingPolicy源码实例Demo

下面列出了怎么用org.mockito.cglib.core.NamingPolicy的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: Eagle   文件: EntityDefinitionManager.java
private static Class<?> createDynamicClassForMetric(final String className, Map<String, Class<?>> dynamicFieldTypes){
	BeanGenerator beanGenerator = new BeanGenerator();
	beanGenerator.setNamingPolicy(new NamingPolicy(){
        @Override 
        public String getClassName(String prefix,String source, Object key, Predicate names){
            return className;
        }});
    BeanGenerator.addProperties(beanGenerator, dynamicFieldTypes);
    beanGenerator.setSuperclass(TaggedLogAPIEntity.class);
    return (Class<?>) beanGenerator.createClass();
}
 
源代码2 项目: eagle   文件: EntityDefinitionManager.java
private static Class<?> createDynamicClassForMetric(final String className,
                                                    Map<String, Class<?>> dynamicFieldTypes) {
    BeanGenerator beanGenerator = new BeanGenerator();
    beanGenerator.setNamingPolicy(new NamingPolicy() {
        @Override
        public String getClassName(String prefix, String source, Object key, Predicate names) {
            return className;
        }
    });
    BeanGenerator.addProperties(beanGenerator, dynamicFieldTypes);
    beanGenerator.setSuperclass(TaggedLogAPIEntity.class);
    return (Class<?>)beanGenerator.createClass();
}
 
源代码3 项目: astor   文件: CGLIBHackerTest.java
@Test
public void shouldSetMockitoNamingPolicy() throws Exception {
    //given
    MockitoMethodProxy methodProxy = new MethodProxyBuilder().build();
    
    //when
    new CGLIBHacker().setMockitoNamingPolicy(methodProxy);
    
    //then
    Object realMethodProxy = Whitebox.invokeMethod(methodProxy, "getMethodProxy", new Object[0]);
    Object createInfo = Whitebox.getInternalState(realMethodProxy, "createInfo");
    NamingPolicy namingPolicy = (NamingPolicy) Whitebox.getInternalState(createInfo, "namingPolicy");
    assertEquals(MockitoNamingPolicy.INSTANCE, namingPolicy);
}
 
源代码4 项目: astor   文件: CGLIBHackerTest.java
@Test
public void shouldSetMockitoNamingPolicyEvenIfMethodProxyIsProxied() throws Exception {
    //given
    MockitoMethodProxy proxiedMethodProxy = spy(new MethodProxyBuilder().build());
    
    //when
    new CGLIBHacker().setMockitoNamingPolicy(proxiedMethodProxy);
    
    //then
    Object realMethodProxy = Whitebox.invokeMethod(proxiedMethodProxy, "getMethodProxy", new Object[0]);
    Object createInfo = Whitebox.getInternalState(realMethodProxy, "createInfo");
    NamingPolicy namingPolicy = (NamingPolicy) Whitebox.getInternalState(createInfo, "namingPolicy");
    assertEquals(MockitoNamingPolicy.INSTANCE, namingPolicy);
}
 
源代码5 项目: astor   文件: CGLIBHackerTest.java
@Test
public void shouldSetMockitoNamingPolicy() throws Exception {
    //given
    MockitoMethodProxy methodProxy = new MethodProxyBuilder().build();
    
    //when
    new CGLIBHacker().setMockitoNamingPolicy(methodProxy);
    
    //then
    Object realMethodProxy = Whitebox.invokeMethod(methodProxy, "getMethodProxy", new Object[0]);
    Object createInfo = Whitebox.getInternalState(realMethodProxy, "createInfo");
    NamingPolicy namingPolicy = (NamingPolicy) Whitebox.getInternalState(createInfo, "namingPolicy");
    assertEquals(MockitoNamingPolicy.INSTANCE, namingPolicy);
}
 
源代码6 项目: astor   文件: CGLIBHackerTest.java
@Test
public void shouldSetMockitoNamingPolicyEvenIfMethodProxyIsProxied() throws Exception {
    //given
    MockitoMethodProxy proxiedMethodProxy = spy(new MethodProxyBuilder().build());
    
    //when
    new CGLIBHacker().setMockitoNamingPolicy(proxiedMethodProxy);
    
    //then
    Object realMethodProxy = Whitebox.invokeMethod(proxiedMethodProxy, "getMethodProxy", new Object[0]);
    Object createInfo = Whitebox.getInternalState(realMethodProxy, "createInfo");
    NamingPolicy namingPolicy = (NamingPolicy) Whitebox.getInternalState(createInfo, "namingPolicy");
    assertEquals(MockitoNamingPolicy.INSTANCE, namingPolicy);
}
 
 类所在包
 同包方法