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 junit.framework.TestCase;
013    
014    import java.beans.IntrospectionException;
015    
016    /**
017     * @author Aslak Hellesøy
018     * @version $Revision: 3603 $
019     */
020    public class SetterIntrospectorTestCase extends TestCase {
021        public static class TestBean {
022            public void setPublicMethod(int i) {
023            }
024    
025            public void setPublicMETHODAgain(int i) {
026            }
027    
028            public void setMOOky(int i) {
029            }
030    
031            public void setFOOBAR(int i) {
032            }
033    
034            public void set(int i) {
035            }
036    
037            public void sets(int i) {
038            }
039    
040            public void fooBar(int i) {
041            }
042    
043            public void setX(int i) {
044            }
045    
046            public static void setStaticMethod(int i) {
047            }
048    
049            public static void setMany() {
050            }
051    
052            protected void setProtectedMethod(int i) {
053            }
054    
055            private void setPrivateMethod(int i) {
056            }
057        }
058    
059        public void testShouldConvertPropertyNamesInSameWayAsBeanInfo() throws IntrospectionException {
060    
061    // TODO - to test via SetterInjectionComponentAdaptor with mock/expects.
062    
063    //        BeanInfo beanInfo = Introspector.getBeanInfo(TestBean.class);
064    //        PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
065    //
066    //        Map setters = getSetters(TestBean.class);
067    //        assertEquals(propertyDescriptors.length, setters.size());
068    //
069    //        for (int i = 0; i < propertyDescriptors.length; i++) {
070    //            PropertyDescriptor propertyDescriptor = propertyDescriptors[i];
071    //            String expectedPropertyName = propertyDescriptor.getName();
072    //            assertEquals("No property found for " + expectedPropertyName, propertyDescriptor.getWriteMethod(), setters.get(expectedPropertyName));
073    //        }
074        }
075    
076    }