001 /* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018 package org.apache.commons.proxy.invoker; 019 import junit.framework.TestCase; 020 import org.apache.commons.proxy.ProxyUtils; 021 import org.apache.commons.proxy.factory.cglib.CglibProxyFactory; 022 023 public class TestNullInvoker extends TestCase 024 { 025 public void testReturnValues() 026 { 027 final Tester tester = ( Tester )ProxyUtils.createNullObject( new CglibProxyFactory(), new Class[] { Tester.class } ); 028 assertEquals( 0, tester.intMethod() ); 029 assertEquals( 0L, tester.longMethod() ); 030 assertEquals( ( short )0, tester.shortMethod() ); 031 assertEquals( ( byte )0, tester.byteMethod() ); 032 assertEquals( ( char )0, tester.charMethod() ); 033 assertEquals( 0.0f, tester.floatMethod(), 0.0f ); 034 assertEquals( 0.0, tester.doubleMethod(), 0.0f ); 035 assertFalse( tester.booleanMethod() ); 036 assertNull( tester.stringMethod() ); 037 } 038 039 public static interface Tester 040 { 041 public int intMethod(); 042 public long longMethod(); 043 public short shortMethod(); 044 public byte byteMethod(); 045 public char charMethod(); 046 public double doubleMethod(); 047 public float floatMethod(); 048 public String stringMethod(); 049 public boolean booleanMethod(); 050 } 051 }