    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.alternatives;
    011
    012    import static org.junit.Assert.assertNotNull;
    013    import static org.junit.Assert.assertEquals;
    014
    015    import org.junit.Test;
    016    import org.picocontainer.injectors.ParameterNameBinding;
    017
    018    import com.thoughtworks.paranamer.DefaultParanamer;
    019    import com.thoughtworks.paranamer.Paranamer;
    020    import com.thoughtworks.paranamer.AdaptiveParanamer;
    021    import com.thoughtworks.paranamer.CachingParanamer;
    022
    023    import java.lang.reflect.Method;
    024
    025    public class ParanamerPicoContainerTestCase {
    026
    027        @Test
    028        public void testCanInstantiateParanamer() {
    029            Paranamer paranamer = new DefaultParanamer();
    030            assertNotNull(paranamer);
    031        }
    032
    033
    034        public void methodToFind(String name) {
    035                    assert name != null;
    036            }
    037
    038
    039        @Test
    040        public void
    041               testNameBindingShouldNotThrowWhenAreParameterNamesAreNotAvailable()
    042                throws Exception {
    043            Paranamer paranamer = new CachingParanamer(new AdaptiveParanamer());
    044
    045            Method method = getClass().getMethod("methodToFind", String.class);
    046            ParameterNameBinding binding = new ParameterNameBinding(paranamer, method, 0);
    047
    048            assertEquals("name", binding.getName());
    049        }
    050
    051
    052    }