You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hivemind.apache.org by "Kent Tong (JIRA)" <hi...@jakarta.apache.org> on 2006/09/13 17:45:25 UTC

[jira] Commented: (HIVEMIND-186) Allow overriding service implementations using specified objects

    [ http://issues.apache.org/jira/browse/HIVEMIND-186?page=comments#action_12434476 ] 
            
Kent Tong commented on HIVEMIND-186:
------------------------------------

I've implemented this feature. The code is in the patch for HIVEMIND-185. I implemented both at the same time. It's difficult to separate them now.

Here is an example using this feature:

public class TestRegistryBuilderUsingStrings extends TestCase
{
	...
	public void testOverrideImplementation() throws Exception
	{
		String module1 = "<?xml version=\"1.0\"?>"
				+ "<module id=\"com.myco.mypackage\" version=\"1.0.0\">"
				+ "  <service-point id=\"Adder\" interface=\"org.apache.hivemind.Adder\"/>"
				+ "</module>";
		String module2 = "<?xml version=\"1.0\"?>"
				+ "<module id=\"com.myco.mypackage.impl\" version=\"1.0.0\">"
				+ "  <implementation service-id=\"com.myco.mypackage.Adder\">"
				+ "  <create-instance class=\"org.apache.hivemind.AdderImpl\"/>"
				+ "  </implementation>" + "</module>";
		ServiceImplOverride override = new ServiceImplOverride(
				"com.myco.mypackage.Adder", new Adder()
				{
					public int add(int arg1, int arg2)
					{
						return 123;
					}
				});
		setupRegistry(new String[] { module1, module2 },
				new ServiceImplOverride[] { override });
		Adder adder = (Adder) registry.getService("com.myco.mypackage.Adder",
				Adder.class);
		assertNotNull(adder);
		assertEquals(adder.add(4, 5), 123);
	}
}


> Allow overriding service implementations using specified objects
> ----------------------------------------------------------------
>
>                 Key: HIVEMIND-186
>                 URL: http://issues.apache.org/jira/browse/HIVEMIND-186
>             Project: HiveMind
>          Issue Type: New Feature
>          Components: framework
>    Affects Versions: 1.2
>            Reporter: Kent Tong
>
> This is useful when performing integration tests involving hivemind services. As one hivemind service can bring in another. To stop it we can use override a certain "boundary" service implementations using stub/mock objects. I need this capacity to test Tapestry pages (eg, provide a stub HttpServletRequest).

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira