Return-Path: Delivered-To: apmail-jakarta-hivemind-cvs-archive@www.apache.org Received: (qmail 22387 invoked from network); 22 Aug 2005 19:51:02 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 22 Aug 2005 19:51:02 -0000 Received: (qmail 51060 invoked by uid 500); 22 Aug 2005 19:51:02 -0000 Delivered-To: apmail-jakarta-hivemind-cvs-archive@jakarta.apache.org Received: (qmail 51044 invoked by uid 500); 22 Aug 2005 19:51:02 -0000 Mailing-List: contact hivemind-cvs-help@jakarta.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: hivemind-dev@jakarta.apache.org List-Id: Delivered-To: mailing list hivemind-cvs@jakarta.apache.org Received: (qmail 51031 invoked by uid 99); 22 Aug 2005 19:51:01 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Mon, 22 Aug 2005 12:51:01 -0700 Received: (qmail 22326 invoked by uid 65534); 22 Aug 2005 19:51:01 -0000 Message-ID: <20050822195101.22325.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r239233 - in /jakarta/hivemind/trunk/framework/src: java/org/apache/hivemind/impl/RegistryInfrastructureImpl.java test/org/apache/hivemind/impl/TestRegistryInfrastructure.java Date: Mon, 22 Aug 2005 19:51:00 -0000 To: hivemind-cvs@jakarta.apache.org From: jcarman@apache.org X-Mailer: svnmailer-1.0.3 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: jcarman Date: Mon Aug 22 12:50:55 2005 New Revision: 239233 URL: http://svn.apache.org/viewcvs?rev=239233&view=rev Log: HIVEMIND-149: Registry.getServiceIds() requires Spring framework Modified: jakarta/hivemind/trunk/framework/src/java/org/apache/hivemind/impl/RegistryInfrastructureImpl.java jakarta/hivemind/trunk/framework/src/test/org/apache/hivemind/impl/TestRegistryInfrastructure.java Modified: jakarta/hivemind/trunk/framework/src/java/org/apache/hivemind/impl/RegistryInfrastructureImpl.java URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/framework/src/java/org/apache/hivemind/impl/RegistryInfrastructureImpl.java?rev=239233&r1=239232&r2=239233&view=diff ============================================================================== --- jakarta/hivemind/trunk/framework/src/java/org/apache/hivemind/impl/RegistryInfrastructureImpl.java (original) +++ jakarta/hivemind/trunk/framework/src/java/org/apache/hivemind/impl/RegistryInfrastructureImpl.java Mon Aug 22 12:50:55 2005 @@ -610,7 +610,7 @@ { final ServicePoint servicePoint = (ServicePoint) i.next(); - if (serviceInterface.isAssignableFrom( servicePoint.getDeclaredInterface() ) + if (serviceInterface.getName().equals( servicePoint.getServiceInterfaceClassName() ) && servicePoint.visibleToModule(null)) { serviceIds.add(servicePoint.getExtensionPointId()); Modified: jakarta/hivemind/trunk/framework/src/test/org/apache/hivemind/impl/TestRegistryInfrastructure.java URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/framework/src/test/org/apache/hivemind/impl/TestRegistryInfrastructure.java?rev=239233&r1=239232&r2=239233&view=diff ============================================================================== --- jakarta/hivemind/trunk/framework/src/test/org/apache/hivemind/impl/TestRegistryInfrastructure.java (original) +++ jakarta/hivemind/trunk/framework/src/test/org/apache/hivemind/impl/TestRegistryInfrastructure.java Mon Aug 22 12:50:55 2005 @@ -11,16 +11,8 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - package org.apache.hivemind.impl; -import java.sql.ResultSet; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.io.Serializable; - import org.apache.hivemind.ApplicationRuntimeException; import org.apache.hivemind.internal.ConfigurationPoint; import org.apache.hivemind.internal.RegistryInfrastructure; @@ -29,11 +21,17 @@ import org.apache.hivemind.test.HiveMindTestCase; import org.easymock.MockControl; +import java.sql.ResultSet; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; + /** - * Additional tests for {@link org.apache.hivemind.impl.RegistryInfrastructureImpl}. Much of the + * Additional tests for {@link RegistryInfrastructureImpl}. Much of the * existing testing is, alas, integration (not unit) testing. Gradually hope to move more of that * into this class. - * + * * @author Howard Lewis Ship * @since 1.1 */ @@ -41,168 +39,165 @@ { public void testGetMissingExtensionPoint() { - RegistryInfrastructure r = new RegistryInfrastructureImpl(null, null); - + RegistryInfrastructure r = new RegistryInfrastructureImpl( null, null ); try { - r.getServicePoint("foo", null); + r.getServicePoint( "foo", null ); unreachable(); } - catch (ApplicationRuntimeException ex) + catch( ApplicationRuntimeException ex ) { - assertEquals(ImplMessages.noSuchServicePoint("foo"), ex.getMessage()); + assertEquals( ImplMessages.noSuchServicePoint( "foo" ), ex.getMessage() ); } } public void testGetUnqualifiedServicePoint() - { - RegistryInfrastructureImpl r = new RegistryInfrastructureImpl(null, null); + { + RegistryInfrastructureImpl r = new RegistryInfrastructureImpl( null, null ); final ModuleImpl module1 = new ModuleImpl(); module1.setModuleId( "module1" ); r.addServicePoint( createServicePoint( module1, "module1.foo", ResultSet.class, Visibility.PUBLIC ) ); try { - r.getServicePoint("foo", null); + r.getServicePoint( "foo", null ); unreachable(); } - catch (ApplicationRuntimeException ex) + catch( ApplicationRuntimeException ex ) { - assertEquals(ImplMessages.unqualifiedServicePoint( "foo", "\"module1.foo\""), ex.getMessage()); + assertEquals( ImplMessages.unqualifiedServicePoint( "foo", "\"module1.foo\"" ), ex.getMessage() ); } final ModuleImpl module2 = new ModuleImpl(); module2.setModuleId( "module2" ); r.addServicePoint( createServicePoint( module2, "module2.foo", ResultSet.class, Visibility.PUBLIC ) ); try { - r.getServicePoint("foo", null); + r.getServicePoint( "foo", null ); unreachable(); } - catch (ApplicationRuntimeException ex) + catch( ApplicationRuntimeException ex ) { - assertEquals(ImplMessages.unqualifiedServicePoint( "foo", "\"module1.foo\", \"module2.foo\""), ex.getMessage()); + assertEquals( ImplMessages.unqualifiedServicePoint( "foo", "\"module1.foo\", \"module2.foo\"" ), ex.getMessage() ); } } - - + public void testGetServiceIdsNoServices() { - RegistryInfrastructureImpl r = new RegistryInfrastructureImpl(null, null); + RegistryInfrastructureImpl r = new RegistryInfrastructureImpl( null, null ); final List serviceIds = r.getServiceIds( ResultSet.class ); assertNotNull( serviceIds ); assertTrue( serviceIds.isEmpty() ); } - + + public void testGetServiceIdsInterfaceNotFound() + { + RegistryInfrastructureImpl r = new RegistryInfrastructureImpl( null, null ); + final ModuleImpl module1 = new ModuleImpl(); + module1.setClassResolver( new DefaultClassResolver() ); + module1.setModuleId( "module1" ); + r.addServicePoint( createServicePoint( module1, "module1.foo", "com.evilsite.some.bogus.package.SomeBogusInterface.", Visibility.PUBLIC ) ); + assertEquals( new HashSet(), new HashSet( r.getServiceIds( ResultSet.class ) ) ); + } + public void testGetServiceIds() - { - RegistryInfrastructureImpl r = new RegistryInfrastructureImpl(null, null); + { + RegistryInfrastructureImpl r = new RegistryInfrastructureImpl( null, null ); assertTrue( r.getServiceIds( ResultSet.class ).isEmpty() ); final ModuleImpl module1 = new ModuleImpl(); module1.setClassResolver( new DefaultClassResolver() ); module1.setModuleId( "module1" ); - r.addServicePoint( createServicePoint(module1, "module1.foo", ResultSet.class, Visibility.PUBLIC ) ); - r.addServicePoint( createServicePoint(module1, "module1.bar", ResultSet.class, Visibility.PUBLIC ) ); - r.addServicePoint( createServicePoint(module1, "module1.baz", ResultSet.class, Visibility.PRIVATE ) ); - r.addServicePoint( createServicePoint(module1, "module1.string", String.class, Visibility.PUBLIC ) ); - assertEquals( new HashSet( Arrays.asList( new String[] { "module1.foo", "module1.bar" } ) ), new HashSet( r.getServiceIds( ResultSet.class ) ) ); - assertEquals( new HashSet( Arrays.asList( new String[] { "module1.string" } ) ), new HashSet( r.getServiceIds( String.class ) ) ); - assertEquals( new HashSet( Arrays.asList( new String[] { "module1.string" } ) ), new HashSet( r.getServiceIds( Serializable.class ) ) ); + r.addServicePoint( createServicePoint( module1, "module1.foo", ResultSet.class, Visibility.PUBLIC ) ); + r.addServicePoint( createServicePoint( module1, "module1.bar", ResultSet.class, Visibility.PUBLIC ) ); + r.addServicePoint( createServicePoint( module1, "module1.baz", ResultSet.class, Visibility.PRIVATE ) ); + r.addServicePoint( createServicePoint( module1, "module1.string", String.class, Visibility.PUBLIC ) ); + assertEquals( new HashSet( Arrays.asList( new String[]{"module1.foo", "module1.bar"} ) ), new HashSet( r.getServiceIds( ResultSet.class ) ) ); + assertEquals( new HashSet( Arrays.asList( new String[]{"module1.string"} ) ), new HashSet( r.getServiceIds( String.class ) ) ); List serviceIds = r.getServiceIds( null ); assertNotNull( serviceIds ); assertEquals( 0, serviceIds.size() ); } - - private ServicePointImpl createServicePoint(final ModuleImpl module, String id, Class serviceInterface, Visibility visibility ) + + private ServicePointImpl createServicePoint( final ModuleImpl module, String id, Class serviceInterface, Visibility visibility ) + { + final ServicePointImpl servicePoint2 = new ServicePointImpl(); + servicePoint2.setModule( module ); + servicePoint2.setExtensionPointId( id ); + servicePoint2.setVisibility( visibility ); + servicePoint2.setServiceInterfaceName( serviceInterface.getName() ); + return servicePoint2; + } + + private ServicePointImpl createServicePoint( final ModuleImpl module, String id, String serviceInterfaceName, Visibility visibility ) { final ServicePointImpl servicePoint2 = new ServicePointImpl(); servicePoint2.setModule( module ); servicePoint2.setExtensionPointId( id ); servicePoint2.setVisibility( visibility ); - servicePoint2.setServiceInterfaceName(serviceInterface.getName()); + servicePoint2.setServiceInterfaceName( serviceInterfaceName ); return servicePoint2; } /** * Ensure that the Registry "locks down" after being started up. - * + * * @since 1.1 */ public void testDoubleStartup() { - MockControl spc = newControl(ServicePoint.class); - ServicePoint sp = (ServicePoint) spc.getMock(); - - Runnable service = (Runnable) newMock(Runnable.class); + MockControl spc = newControl( ServicePoint.class ); + ServicePoint sp = ( ServicePoint ) spc.getMock(); + Runnable service = ( Runnable ) newMock( Runnable.class ); // Training - sp.getExtensionPointId(); - spc.setReturnValue("hivemind.Startup"); - + spc.setReturnValue( "hivemind.Startup" ); sp.getServiceInterfaceClassName(); - spc.setReturnValue(Runnable.class.getName()); - - sp.visibleToModule(null); - spc.setReturnValue(true); - - sp.getService(Runnable.class); - spc.setReturnValue(service); - + spc.setReturnValue( Runnable.class.getName() ); + sp.visibleToModule( null ); + spc.setReturnValue( true ); + sp.getService( Runnable.class ); + spc.setReturnValue( service ); service.run(); - replayControls(); - - RegistryInfrastructureImpl r = new RegistryInfrastructureImpl(null, null); - - r.addServicePoint(sp); - + RegistryInfrastructureImpl r = new RegistryInfrastructureImpl( null, null ); + r.addServicePoint( sp ); r.startup(); - verifyControls(); - try { r.startup(); unreachable(); } - catch (IllegalStateException ex) + catch( IllegalStateException ex ) { - assertEquals(ImplMessages.registryAlreadyStarted(), ex.getMessage()); + assertEquals( ImplMessages.registryAlreadyStarted(), ex.getMessage() ); } } public void testUnknownServiceModelFactory() { - MockControl cpc = newControl(ConfigurationPoint.class); - ConfigurationPoint cp = (ConfigurationPoint) cpc.getMock(); + MockControl cpc = newControl( ConfigurationPoint.class ); + ConfigurationPoint cp = ( ConfigurationPoint ) cpc.getMock(); // Training - cp.getExtensionPointId(); - cpc.setReturnValue("hivemind.ServiceModels"); - - cp.visibleToModule(null); - cpc.setReturnValue(true); - + cpc.setReturnValue( "hivemind.ServiceModels" ); + cp.visibleToModule( null ); + cpc.setReturnValue( true ); cp.getElements(); - cpc.setReturnValue(Collections.EMPTY_LIST); - + cpc.setReturnValue( Collections.EMPTY_LIST ); replayControls(); - - RegistryInfrastructureImpl r = new RegistryInfrastructureImpl(null, null); - - r.addConfigurationPoint(cp); - + RegistryInfrastructureImpl r = new RegistryInfrastructureImpl( null, null ); + r.addConfigurationPoint( cp ); try { - r.getServiceModelFactory("unknown"); + r.getServiceModelFactory( "unknown" ); unreachable(); } - catch (ApplicationRuntimeException ex) + catch( ApplicationRuntimeException ex ) { - assertEquals(ImplMessages.unknownServiceModel("unknown"), ex.getMessage()); + assertEquals( ImplMessages.unknownServiceModel( "unknown" ), ex.getMessage() ); } - verifyControls(); } --------------------------------------------------------------------- To unsubscribe, e-mail: hivemind-cvs-unsubscribe@jakarta.apache.org For additional commands, e-mail: hivemind-cvs-help@jakarta.apache.org