I made a quick update to the CFC Stub Generator to support creating the proper dependencies in the ColdSpring XML file that it generates. This will only work when using a UML XMI file as the generation source. When you define an aggregation or composition relationship in the UML, the generator knows about these relationships and creates the ColdSpring XML accordingly. So, if you have a UML diagram like this:

The ColdSpring XML that gets generated would look like this:

<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

	<bean id="Config" class="bookstore.components.beans.Config" />		
	<bean id="MockConfig" class="bookstore.components.beans.mock.MockConfig" />
	<bean id="AbstractService" class="bookstore.components.services.AbstractService">
		<property name="Config">	
			<ref bean="Config" />
		<property name="SessionFacade">	
			<ref bean="SessionFacade" />
	<bean id="MockAbstractService" class="bookstore.components.services.mock.MockAbstractService" />
	<bean id="StoreService" class="bookstore.components.services.StoreService">
		<property name="StoreFactory">	
			<ref bean="StoreFactory" />
	<bean id="MockStoreService" class="bookstore.components.services.mock.MockStoreService" />
	<bean id="StoreFactory" class="bookstore.components.factories.StoreFactory" />		
	<bean id="MockStoreFactory" class="bookstore.components.factories.mock.MockStoreFactory" />
	<bean id="Membership" class="bookstore.components.businessobjects.Membership" />		
	<bean id="MockMembership" class="bookstore.components.businessobjects.mock.MockMembership" />
	<bean id="Product" class="bookstore.components.businessobjects.Product" />		
	<bean id="MockProduct" class="bookstore.components.businessobjects.mock.MockProduct" />
	<bean id="SessionFacade" class="bookstore.components.facades.SessionFacade" />		
	<bean id="MockSessionFacade" class="bookstore.components.facades.mock.MockSessionFacade" />

As you can see, the bean dependencies that are created in the ColdSpring XML match the aggregation relationships defined in the UML. This is pretty handy if you plan to copy the ColdSpring XML that is used by the generated test suite in your real application. It also makes it easy to modify this XML to pass Mock objects into your components when creating your tests.

del.ico.us del.icio.us | Digg It! Digg It! | Linking Blogs Linking Blogs | 10088 Views

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)

Comments are not allowed for this entry.