001 /***************************************************************************** 002 * Copyright (C) PicoContainer Organization. All rights reserved. * 003 * ------------------------------------------------------------------------- * 004 * The software in this package is published under the terms of the BSD * 005 * style license a copy of which has been included with this distribution in * 006 * the LICENSE.txt file. * 007 * * 008 * Original code by * 009 *****************************************************************************/ 010 package org.picocontainer.defaults; 011 012 import java.beans.IntrospectionException; 013 014 import org.junit.Test; 015 016 /** 017 * @author Aslak Hellesøy 018 */ 019 public class SetterIntrospectorTestCase { 020 public static class TestBean { 021 public void setPublicMethod(int i) { 022 } 023 024 public void setPublicMETHODAgain(int i) { 025 } 026 027 public void setMOOky(int i) { 028 } 029 030 public void setFOOBAR(int i) { 031 } 032 033 public void set(int i) { 034 } 035 036 public void sets(int i) { 037 } 038 039 public void fooBar(int i) { 040 } 041 042 public void setX(int i) { 043 } 044 045 public static void setStaticMethod(int i) { 046 } 047 048 public static void setMany() { 049 } 050 051 protected void setProtectedMethod(int i) { 052 } 053 054 private void setPrivateMethod(int i) { 055 } 056 } 057 058 @Test public void testShouldConvertPropertyNamesInSameWayAsBeanInfo() throws IntrospectionException { 059 060 // TODO - to test via SetterInjectionComponentAdaptor with mock/expects. 061 062 // BeanInfo beanInfo = Introspector.getBeanInfo(TestBean.class); 063 // PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); 064 // 065 // Map setters = getSetters(TestBean.class); 066 // assertEquals(propertyDescriptors.length, setters.size()); 067 // 068 // for (int i = 0; i < propertyDescriptors.length; i++) { 069 // PropertyDescriptor propertyDescriptor = propertyDescriptors[i]; 070 // String expectedPropertyName = propertyDescriptor.getName(); 071 // assertEquals("No property found for " + expectedPropertyName, propertyDescriptor.getWriteMethod(), setters.get(expectedPropertyName)); 072 // } 073 } 074 075 }