<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:test="http://www.mulesource.org/schema/mule/test/2.0"
       xmlns:mule="http://www.mulesource.org/schema/mule/core/2.0"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
       http://www.mulesource.org/schema/mule/test/2.0 http://www.mulesource.org/schema/mule/test/2.0/mule-test.xsd
       http://www.mulesource.org/schema/mule/core/2.0 http://www.mulesource.org/schema/mule/core/2.0/mule.xsd">

    <mule:mule>

        <mule:global-property name="doCompression" value="true"/>
        <mule:global-property name="beanProperty1" value="this was set from the manager properties!"/>
        <mule:global-property name="OS_Version" value="${os.version}"/>
        <mule:global-property name="system-prop2" value="${system-prop2-cannot-loop}"/> <!-- defaultValue="default" -->

        <mule:configuration defaultSynchronousEndpoints="true" defaultRemoteSync="true">
            <mule:default-threading-profile maxBufferSize="42" maxThreadsActive="16"
                maxThreadsIdle="3" poolExhaustedAction="WAIT" threadTTL="60001"/>
        </mule:configuration>

        <mule:custom-transaction-manager class="org.mule.tck.testmodels.mule.TestTransactionManagerFactory"/>

        <!-- TODO -->
        <!-- daniel is working on management, i think -->
        <!-- agents>
        <agent name="jmxAgent" className="org.mule.management.agents.JmxAgent"/>
        </agents -->

        <test:connector name="dummyConnector">
            <mule:dispatcher-threading-profile maxBufferSize="2"/>
            <mule:custom-exception-strategy class="org.mule.tck.testmodels.mule.TestExceptionStrategy"/>
            <!-- TODO -->
            <!-- no way to specify connection strategy on a connector? -->
        </test:connector>

        <mule:endpoint name="AppleQueue" address="test://apple.queue"/>
        <mule:endpoint name="Banana_Queue" address="test://banana.queue"/>
        <mule:endpoint name="TestQueue" address="test://test.queue"/>

        <mule:custom-transformer name="TestCompressionTransformer"
                                 class="org.mule.tck.testmodels.mule.TestCompressionTransformer"
                                 returnClass="java.lang.String">
            <property name="beanProperty1" value="${beanProperty1}"/>
            <property name="beanProperty2" value="12"/>
            <property name="containerProperty" value="a string"/>
        </mule:custom-transformer>
        <mule:no-action-transformer name="TestTransformer" returnClass="[B"/>

        <mule:endpoint name="fruitBowlEndpoint" address="test://fruitBowlPublishQ">
            <mule:message-property-filter pattern="foo=bar"/>
        </mule:endpoint>
        <!-- cannot have aliases -->
        <!-- mule:endpoint name="waterMelonEndpoint" ref="TestQueue"/ -->
        <mule:endpoint name="waterMelonEndpoint" address="test://test.queue" encoding="UTF-8-TEST"/>
        <mule:endpoint name="appleInEndpoint" address="test://AppleQueue"/>
        <mule:endpoint name="appleResponseEndpoint" address="test://AppleResponseQueue"/>
        <mule:endpoint name="orangeEndpoint" address="test://orangeQ">
            <mule:properties>
                <entry key="testGlobal" value="value1"/>
            </mule:properties>
        </mule:endpoint>
        <mule:endpoint name="testEPWithCS" address="test://test.queue2"/>

    <mule:endpoint name="endpointWithProps" address="test://endpointWithProps">
    	<mule:properties>
    		<entry key="brand" value="Juicy Baby!"/>
    		<entry key="segments" value="9"/>
    		<entry key="radius" value="4.21"/>
			<entry key="mapProperties">
				<map>
				    <entry key="prop1" value="prop1"/>
			    	<entry key="prop2" value="prop2"/>
				</map>
			</entry>
			<entry key="listProperties">
				<list>
					<value>prop1</value>
					<value>prop2</value>
					<value>prop3</value>
				</list>
			</entry>
			<entry key="arrayProperties">
				<list>
					<value>prop4</value>
					<value>prop5</value>
					<value>prop6</value>
				</list>
			</entry>
    	</mule:properties>
    </mule:endpoint>

    </mule:mule>

    <bean name="orange" class="org.mule.tck.testmodels.fruit.Orange">
        <property name="brand" value="Juicy Baby!"/>
        <property name="segments" value="9"/>
        <property name="radius" value="4.21"/>
        <property name="mapProperties">
            <map>
                <entry key="prop1" value="prop1"/>
                <entry key="prop2" value="prop2"/>
            </map>
        </property>
        <property name="listProperties">
            <list>
                <value>prop1</value>
                <value>prop2</value>
                <value>prop3</value>
            </list>
        </property>
        <property name="arrayProperties">
            <list>
                <value>prop4</value>
                <value>prop5</value>
                <value>prop6</value>
            </list>
        </property>
    </bean>

    <mule:mule>

        <mule:model name="main">

            <mule:custom-exception-strategy class="org.mule.tck.testmodels.mule.TestExceptionStrategy">
                <mule:outbound-endpoint
                        address="test://component.exceptions"/>
            </mule:custom-exception-strategy>

            <!-- component-lifecycle-adapter-factory className="org.mule.tck.testmodels.mule.TestDefaultLifecycleAdapterFactory"/ -->

            <mule:service name="orangeComponent">
                
                <mule:inbound>
                    <mule:forwarding-catch-all-strategy>
                        <mule:outbound-endpoint
                                address="test://catch.all"/>
                    </mule:forwarding-catch-all-strategy>
                    <mule:inbound-endpoint name="Orange"
                                           address="test://orange/" transformer-refs="TestCompressionTransformer"
                                           responseTransformer-refs="TestCompressionTransformer"/>
                    <mule:inbound-endpoint ref="orangeEndpoint"
                                           transformer-refs="TestCompressionTransformer">
                        <mule:payload-type-filter expectedType="java.lang.String"/>
                        <mule:properties>
                            <entry key="testLocal" value="value1"/>
                        </mule:properties>
                    </mule:inbound-endpoint>
                </mule:inbound>

                <mule:component>
                    <mule:spring-object bean="orange"/>
                    <mule:binding interface="org.mule.tck.testmodels.fruit.FruitCleaner" method="wash">
                        <mule:outbound-endpoint address="test://do.wash"/>
                    </mule:binding>
                    <mule:binding interface="org.mule.tck.testmodels.fruit.FruitCleaner" method="polish">
                        <mule:outbound-endpoint address="test://do.polish"/>
                    </mule:binding>
                </mule:component>

                <mule:outbound>
                    <mule:outbound-pass-through-router>
                        <mule:outbound-endpoint ref="appleInEndpoint"
                                                transformer-refs="TestCompressionTransformer"/>
                    </mule:outbound-pass-through-router>
                </mule:outbound>

                <mule:async-reply timeout="10001">
                    <mule:inbound-endpoint address="test://response1"/>
                    <mule:inbound-endpoint ref="appleResponseEndpoint"/>
                    <mule:custom-async-reply-router class="org.mule.tck.testmodels.mule.TestResponseAggregator"/>
                </mule:async-reply>

                <mule:default-connector-exception-strategy>
                    <mule:outbound-endpoint address="test://orange.exceptions"/>
                </mule:default-connector-exception-strategy>
            </mule:service>

            <mule:service name="appleComponent">

                <mule:inbound>
                    <mule:custom-catch-all-strategy class="org.mule.tck.testmodels.mule.TestCatchAllStrategy"/>
                    <mule:inbound-endpoint ref="appleInEndpoint"/>
                    <mule:selective-consumer-router>
                        <mule:payload-type-filter expectedType="java.lang.String"/>
                    </mule:selective-consumer-router>
                    <mule:idempotent-receiver-router/>
                </mule:inbound>

                <mule:component class="org.mule.tck.testmodels.fruit.Apple"/>

                <mule:outbound>
                    <mule:custom-catch-all-strategy class="org.mule.tck.testmodels.mule.TestCatchAllStrategy"/>
                    <mule:filtering-router>
                        <mule:outbound-endpoint name="TestApple-Out" address="test://appleQ2"/>
                        <mule:payload-type-filter expectedType="java.lang.String"/>
                        <mule:transformer ref="TestCompressionTransformer"/>
                    </mule:filtering-router>
                    <mule:filtering-router>
                        <mule:outbound-endpoint ref="waterMelonEndpoint"/>
                        <mule:and-filter>
                            <mule:regex-filter pattern="the quick brown (.*)"/>
                            <mule:regex-filter pattern="(.*) brown (.*)"/>
                        </mule:and-filter>
                    </mule:filtering-router>
                </mule:outbound>

                <mule:default-service-exception-strategy/>

            </mule:service>

            <mule:service name="msgInfoMappingTestComponent">
                <mule:inbound/>
                <mule:component class="org.mule.tck.testmodels.fruit.Apple"/>
                <mule:outbound>
                    <mule:filtering-router>
                        <mule:expression-message-info-mapping messageIdExpression="${header:id}"
                                                              correlationIdExpression="${header:correlation}"/>
                    </mule:filtering-router>
                </mule:outbound>
            </mule:service>

            <mule:service name="msgInfoMappingResponseRouterTestComponent">
                <mule:inbound/>
                <mule:component class="org.mule.tck.testmodels.fruit.Apple"/>
                <mule:async-reply>
                    <mule:single-async-reply-router>
                        <mule:expression-message-info-mapping messageIdExpression="${header:id}"
                                                              correlationIdExpression="${header:correlation}"/>
                    </mule:single-async-reply-router>
                </mule:async-reply>
            </mule:service>

        </mule:model>

    </mule:mule>

</beans>
