Package org.codehaus.dna.impl

Examples of org.codehaus.dna.impl.DefaultResourceLocator


    extends TestCase
{
    public void testLookupMissingResourceWithNoParent()
        throws Exception
    {
        final DefaultResourceLocator locator = new DefaultResourceLocator();
        assertEquals( "locator.contains(rez) post to insert",
                      false,
                      locator.contains( "rez" ) );

        try
        {
            locator.lookup( "rez" );
        }
        catch( MissingResourceException e )
        {
            return;
        }
View Full Code Here


    }

    public void testLookupMissingResourceWithParent()
        throws Exception
    {
        final DefaultResourceLocator parent = new DefaultResourceLocator();
        final DefaultResourceLocator locator = new DefaultResourceLocator( parent );
        assertEquals( "locator.contains(rez) post to insert",
                      false,
                      locator.contains( "rez" ) );

        try
        {
            locator.lookup( "rez" );
        }
        catch( MissingResourceException e )
        {
            return;
        }
View Full Code Here

    public void testLookupResourceInLocalLocator()
        throws Exception
    {
        final Object resource = new Object();
        final DefaultResourceLocator locator = new DefaultResourceLocator();
        locator.put( "rez", resource );
        assertEquals( "locator.contains(rez) post to insert",
                      true,
                      locator.contains( "rez" ) );

        final Object result = locator.lookup( "rez" );
        assertEquals( "locator.contains(rez) == resource",
                      resource, result );
    }
View Full Code Here

    public void testLookupResourceInParentLocator()
        throws Exception
    {
        final Object resource = new Object();
        final DefaultResourceLocator parent = new DefaultResourceLocator();
        final DefaultResourceLocator locator = new DefaultResourceLocator( parent );
        parent.put( "rez", resource );
        assertEquals( "locator.contains(rez) post to insert",
                      true,
                      locator.contains( "rez" ) );

        final Object result = locator.lookup( "rez" );
        assertEquals( "locator.contains(rez) == resource",
                      resource, result );
    }
View Full Code Here

    }

    public void testPutWithNullKey()
        throws Exception
    {
        final DefaultResourceLocator locator = new DefaultResourceLocator();
        try
        {
            locator.put( null, new Object() );
        }
        catch( NullPointerException e )
        {
            assertEquals( "key", e.getMessage() );
            return;
View Full Code Here

    }

    public void testPutWithNullResource()
        throws Exception
    {
        final DefaultResourceLocator locator = new DefaultResourceLocator();
        try
        {
            locator.put( "rez", null );
        }
        catch( NullPointerException e )
        {
            assertEquals( "resource", e.getMessage() );
            return;
View Full Code Here

    public void testComposeOnComponentImplementingStage()
        throws Exception
    {
        final MockComponent object = new MockComponent();
        final ResourceLocator resource = new DefaultResourceLocator();

        ContainerUtil.compose( object, resource );

        assertEquals( resource, object.getServices() );
    }
View Full Code Here

    }

    private ResourceLocator getResourceLocator()
        throws Exception
    {
        final DefaultResourceLocator locator = new DefaultResourceLocator();
        locator.put( Embeddor.class.getName(), this );
        for( int i = 0; i < m_entries.length; i++ )
        {
            final String role = m_entries[ i ].getRole();
            if( null == role )
            {
                continue;
            }
            final Object component = getEmbeddorComponent( role );
            if( null != component )
            {
                locator.put( role, component );
            }
        }

        locator.put( File.class.getName() + "/home", m_loomHome );
        locator.put( ClassLoader.class.getName() + "/common",
                     m_commonClassLoader );
        locator.put( ClassLoader.class.getName() + "/container",
                     m_containerClassLoader );

        return locator;
    }
View Full Code Here

        return childLogger;
    }

    private ResourceLocator createResourceLocator()
    {
        final DefaultResourceLocator serviceManager = new DefaultResourceLocator();
        serviceManager.put( SystemManager.class.getName(), m_systemManager );
        serviceManager.put( ConfigurationInterceptor.class.getName(),
                            m_repository );
        serviceManager.put( ConfigurationValidator.class.getName(),
                            m_validator );
        serviceManager.put( InstrumentManager.class.getName(),
                            m_instrumentManager );
        serviceManager.put( Kernel.class.getName(), this );
        serviceManager.makeReadOnly();
        return serviceManager;
    }
View Full Code Here

        return true;
    }

    private DefaultResourceLocator createLocator( final Map data )
    {
        final DefaultResourceLocator locator = new DefaultResourceLocator();
        final Iterator iterator = data.keySet().iterator();
        while( iterator.hasNext() )
        {
            final String key = (String)iterator.next();
            final Object value = data.get( key );
            locator.put( key, value );
        }
        return locator;
    }
View Full Code Here

TOP

Related Classes of org.codehaus.dna.impl.DefaultResourceLocator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.