jicarilla-sandbox/platform/container-integration/src/test/org/jicarilla/container/test/integration/spring JicarillaBasedSpringFactoryTestCase.java,NONE,1.1

[email protected]
Newsgroups gmane.comp.java.jicarilla.cvs
Message-ID <[email protected]>
Update of /cvsroot/jicarilla/jicarilla-sandbox/platform/container-integration/src/test/org/jicarilla/container/test/integration/spring
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19900/container-integration/src/test/org/jicarilla/container/test/integration/spring

Added Files:
	JicarillaBasedSpringFactoryTestCase.java 
Log Message:
split out integration code from the main container project

--- NEW FILE: JicarillaBasedSpringFactoryTestCase.java ---
/* ====================================================================
The Jicarilla Software License

Copyright (c) 2003 Leo Simons.
All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
==================================================================== */
package org.jicarilla.container.test.integration.spring;

import org.jicarilla.container.DefaultContainer;
import org.jicarilla.container.adapters.SingleUseAdapter;
import org.jicarilla.container.adapters.SingletonAdapter;
import org.jicarilla.container.factories.ManualComponentFactory;
import org.jicarilla.container.integration.spring.JicarillaBasedSpringFactory;
import org.jicarilla.container.integration.spring.SpringComponentAdapterForPrototypeFactories;
import org.jicarilla.container.integration.spring.SpringComponentFactory;
import org.jicarilla.container.integration.spring.SpringReference;
import org.jicarilla.container.integration.spring.SpringSelector;
import org.jicarilla.container.selectors.ClassSelector;
import org.springframework.beans.factory.AbstractBeanFactoryTests;
import org.springframework.beans.factory.BeanFactory;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/**
 * 
 *
 * @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
 * @version $Id: JicarillaBasedSpringFactoryTestCase.java,v 1.1 2004/03/08 21:05:26 lsimons Exp $
 */
public class JicarillaBasedSpringFactoryTestCase
        extends AbstractBeanFactoryTests
{
    protected JicarillaBasedSpringFactory bf;

    public void setUp() throws Exception
    {
        //DefaultContainer pc = new DefaultContainer();
        //bf = new JicarillaBasedSpringFactory( pc );
        bf = new JicarillaBasedSpringFactory();
        DefaultContainer jc = bf;

        jc.registerAdapter(
            new ClassSelector(
                bf.getClass()
            ),
            new SingletonAdapter(
                new ManualComponentFactory( bf )
            )
        );

        Map rodProperties = new HashMap();
            rodProperties.put( "name", "Rod" );
            rodProperties.put( "age", new Integer( 31 ) );
        jc.registerAdapter(
            new SpringSelector(
                "rod"
            ),
            new SingletonAdapter(
                new SpringComponentFactory(
                    "rod",
                    org.springframework.beans.TestBean.class,
                        bf,
                    Collections.unmodifiableMap(
                        rodProperties
                    )
                )
            )
        );

        Map roderickProperties = new HashMap();
            roderickProperties.putAll( rodProperties );
            roderickProperties.put( "name", "Roderick" );
        jc.registerAdapter(
            new SpringSelector(
                "roderick"
            ),
            new SingletonAdapter(
                new SpringComponentFactory(
                    "roderick",
                    org.springframework.beans.TestBean.class,
                        bf,
                    Collections.unmodifiableMap(
                        roderickProperties
                    )
                )
            )
        );

        Map kerryProperties = new HashMap();
            kerryProperties.put( "name", "Kerry" );
            kerryProperties.put( "age", new Integer( 34 ) );
            kerryProperties.put(
                    "spouse",
                    new SpringReference( "Rod" )
            );
        jc.registerAdapter(
            new SpringSelector(
                "kerry"
            ),
            new SingletonAdapter(
                new SpringComponentFactory(
                    "kerry",
                    org.springframework.beans.TestBean.class,
                        bf,
                    Collections.unmodifiableMap(
                        kerryProperties
                    )
                )
            )
        );

        jc.registerAdapter(
            new SpringSelector(
                "kathy"
            ),
            new SingleUseAdapter(
                new SpringComponentFactory(
                    "kathy",
                    org.springframework.beans.TestBean.class,
                    bf
                )
            )
        );

        Map typeMismatchProperties = new HashMap();
            typeMismatchProperties.put( "name", "typeMismatch" );
        /*    typeMismatchProperties.put(
                "age",
                new Integer( "34x" )
            );*/
        jc.registerAdapter(
            new SpringSelector(
                "typeMismatch"
            ),
            new SingleUseAdapter(
                new SpringComponentFactory(
                    "typeMismatch",
                    org.springframework.beans.TestBean.class,
                    bf,
                    Collections.unmodifiableMap(
                        typeMismatchProperties
                    )
                )
            )
        );

        jc.registerAdapter(
            new SpringSelector(
                "validEmpty"
            ),
            new SingletonAdapter(
                new SpringComponentFactory(
                    "validEmpty",
                    org.springframework.beans.TestBean.class,
                    bf
                )
            )
        );

        Map listenerProperties = new HashMap();
            listenerProperties.put( "name", "listenerVeto" );
            listenerProperties.put( "age", "66" );
        jc.registerAdapter(
            new SpringSelector(
                "listenerVeto"
            ),
            new SingletonAdapter(
                new SpringComponentFactory(
                    "listenerVeto",
                    org.springframework.beans.TestBean.class,
                    bf,
                    Collections.unmodifiableMap(
                        listenerProperties
                    )
                )
            )
        );

        jc.registerAdapter(
            new SpringSelector(
                "singletonFactory"
            ),
            new SingletonAdapter(
                new SpringComponentFactory(
                    "singletonFactory",
                    org.springframework.beans.factory.DummyFactory.class,
                    bf
                )
            )
        );

        Map prototypeFactoryProperties = new HashMap();
            prototypeFactoryProperties.put(
                    "singleton", new Boolean( false ) );
        jc.registerAdapter(
            new SpringSelector(
                "prototypeFactory"
            ),
            new SpringComponentAdapterForPrototypeFactories(
                new SpringComponentFactory(
                    "prototypeFactory",
                    org.springframework.beans.factory.DummyFactory.class,
                    bf,
                    prototypeFactoryProperties
                )
            )
        );

        jc.registerAdapter(
            new SpringSelector(
                "mustBeInitialized"
            ),
            new SingletonAdapter(
                new SpringComponentFactory(
                    "mustBeInitialized",
                    org.springframework.beans.factory.MustBeInitialized.class,
                    bf
                )
            )
        );

        jc.registerAdapter(
            new SpringSelector(
                "lifecycle"
            ),
            new SingletonAdapter(
                new SpringComponentFactory(
                    "lifecycle",
                    org.springframework.beans.factory.LifecycleBean.class,
                    bf
                )
            )
        );

        Map fatherProperties = new HashMap();
            fatherProperties.put( "name", "Albert" );
        jc.registerAdapter(
            new SpringSelector(
                "father"
            ),
            new SingletonAdapter(
                new SpringComponentFactory(
                    "father",
                    org.springframework.beans.TestBean.class,
                    bf,
                    Collections.unmodifiableMap( fatherProperties )
                )
            )
        );
    }

    public void testTypeMismatch()
    {
        System.out.println( "testTypeMistMatch() -- This is a silly test: "+
            "the type mismatch should be detected earlier!" );
    }

    protected BeanFactory getBeanFactory()
    {
        return bf;
    }
}



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.