CVS: plexus-container-new/src/test/org/apache/plexus/lifecycle/avalon AvalonServiceSelectorTest.java,NONE,1.1 AvalonServiceSelectorTest.xml,NONE,1.1

[email protected] Sat, 10 May 2003 11:39:32 -0500
Newsgroups gmane.comp.java.plexus.devel
Message-ID <[email protected]>
Update of /cvsroot/plexus/plexus-container-new/src/test/org/apache/plexus/lifecycle/avalon
In directory eng.werken.com:/tmp/cvs-serv21976/src/test/org/apache/plexus/lifecycle/avalon

Added Files:
	AvalonServiceSelectorTest.java AvalonServiceSelectorTest.xml 
Log Message:
Add support for ServiceSelectors (again).  The new 
AvalonComponentRepository is now the default.

The addComponentDescriptor method had to be modified to allow
protected access.  This may or may not be the ideal way, but
now it all works with pretty minimal changes.

--- NEW FILE: AvalonServiceSelectorTest.java ---
package org.apache.plexus.lifecycle.avalon;

import org.apache.avalon.framework.service.ServiceSelector;
import org.apache.plexus.PlexusTestCase;
import org.apache.plexus.ServiceC;

/**
 * @author <a href="mailto:[email protected]">Dan Diephouse</a>
 * @since May 10, 2003
 */
public class AvalonServiceSelectorTest
    extends PlexusTestCase
{

    /**
     * @param testName
     */
    public AvalonServiceSelectorTest(String testName)
    {
        super(testName);
    }

    public void testSelector() throws Exception
    {
        ServiceSelector selector = (ServiceSelector) getComponent( ServiceC.ROLE + "Selector" );
        
        assertTrue( selector != null );
        assertTrue( selector.isSelectable( "only-instance" ) );
        
        ServiceC serviceC = (ServiceC) selector.select( "only-instance" );
        assertTrue( serviceC != null );
    }
}

--- NEW FILE: AvalonServiceSelectorTest.xml ---
<plexus>

  <components>

    <!--
     |
     | A Service
     |
     | This service implements all the Avalon lifecycle methods.
     |
     -->
    <component>
      <role>org.apache.plexus.ServiceA</role>
      <implementation>org.apache.plexus.DefaultServiceA</implementation>
      <configuration>
        <host>localhost</host>
        <port>10000</port>
      </configuration>
    </component>

    <!--
     |
     | C Service
     |
     -->
    <component>
      <role>org.apache.plexus.ServiceC</role>
      <id>only-instance</id>
      <implementation>org.apache.plexus.DefaultServiceC</implementation>
      <configuration>
        <host>localhost</host>
        <port>10000</port>
      </configuration>
    </component>

  </components>

</plexus>