Skip to content

Commit

Permalink
upgrade transport to mule2.0.RC3
Browse files Browse the repository at this point in the history
  • Loading branch information
knaas committed Mar 20, 2008
1 parent e82846c commit c5ec32d
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 37 deletions.
@@ -0,0 +1,53 @@
/*
* $Id: JdbcEndpointURIBuilder.java 10489 2008-01-23 17:53:38Z dfeist $
* --------------------------------------------------------------------------------------
* Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
*
* The software in this package is published under the terms of the CPAL v1.0
* license, a copy of which has been included with this distribution in the
* LICENSE.txt file.
*/

package org.jumpmind.mule.transport.symmetric;

import java.net.URI;
import java.util.Properties;

import org.mule.api.endpoint.MalformedEndpointException;
import org.mule.endpoint.AbstractEndpointURIBuilder;

/**
* Parses a Symmetric style endpoint to a MuleEndpointURI
*/
public class SymmetricEndpointURIBuilder extends AbstractEndpointURIBuilder
{

protected void setEndpoint(URI uri, Properties props) throws MalformedEndpointException
{
if (uri.getHost() != null && !"localhost".equals(uri.getHost()))
{
endpointName = uri.getHost();
}
int i = uri.getPath().indexOf("/", 1);
if (i > 0)
{
endpointName = uri.getPath().substring(1, i);
address = uri.getPath().substring(i + 1);
}
else if (uri.getPath() != null && uri.getPath().length() != 0)
{
address = uri.getPath().substring(1);
}
else
{
address = uri.getAuthority();
}
// Symmetric endpoints can just have a param string, hence te address is left
// null, but the address
// should always be a non-null value
if (address == null)
{
address = uri.getScheme();
}
}
}
Expand Up @@ -17,6 +17,6 @@ dispatcher.factory=org.jumpmind.mule.transport.symmetric.SymmetricMessageDispatc
#Defines the way in which endpoints for your transport will be constructed
#Options are (but you can write your own) -

endpoint.builder=org.mule.transport.jdbc.JdbcEndpointURIBuilder
endpoint.builder=org.jumpmind.mule.transport.symmetric.SymmetricEndpointURIBuilder

#For more information see - http://mule.mulesource.org/wiki/x/DQ
Expand Up @@ -10,7 +10,6 @@

package org.jumpmind.mule.transport.symmetric;

import org.jumpmind.mule.transport.symmetric.SymmetricConnector;
import org.mule.api.endpoint.ImmutableEndpoint;
import org.mule.tck.AbstractMuleTestCase;

Expand All @@ -28,14 +27,12 @@ public void testCreateFromFactory() throws Exception
assertNotNull(endpoint);
assertNotNull(endpoint.getConnector());
assertTrue(endpoint.getConnector() instanceof SymmetricConnector);
assertEquals(getEndpointURI(), endpoint.getEndpointURI().getAddress());
assertEquals(getEndpointURI(), endpoint.getEndpointURI().getUri().toASCIIString());
}

public String getEndpointURI()
{
// TODO return a valid endpoint URI string for your transport
// i.e. tcp://localhost:1234
throw new UnsupportedOperationException("getEndpointURI");
return "symmetric://test";
}

}
Expand Up @@ -18,20 +18,10 @@

public class SymmetricConnectorTestCase extends AbstractConnectorTestCase {

/*
* For general guidelines on writing transports see
* http://mule.mulesource.org/display/MULE/Writing+Transports
*/

public Connector createConnector() throws Exception {
/*
* IMPLEMENTATION NOTE: Create and initialise an instance of your
* connector here. Do not actually call the connect method.
*/

SymmetricConnector c = new SymmetricConnector();
c.setName("Test");
// TODO Set any additional properties on the connector here
return c;
}

Expand All @@ -49,4 +39,23 @@ public void testProperties() throws Exception {
// Connector as necessary
}

@Override
public void testConnectorMessageAdapter() throws Exception
{
Connector connector = getConnector();
assertNotNull(connector);
//org.mule.api.transport.MessageAdapter adapter = connector.getMessageAdapter(getValidMessage());
}

@Override
public void testConnectorMessageRequesterFactory() throws Exception
{
Connector connector = getConnector();
assertNotNull(connector);
//org.mule.api.transport.MessageRequesterFactory factory = connector.getRequesterFactory();
}




}
Expand Up @@ -10,31 +10,32 @@

package org.jumpmind.mule.transport.symmetric;

import org.mule.api.endpoint.EndpointURI;
import org.mule.endpoint.MuleEndpointURI;
import org.mule.tck.AbstractMuleTestCase;


public class SymmetricEndpointTestCase extends AbstractMuleTestCase
{

/* For general guidelines on writing transports see
http://mule.mulesource.org/display/MULE/Writing+Transports */

public void testValidEndpointURI() throws Exception
{
// TODO test creating and asserting Endpoint values eg

/*
EndpointURI url = new MuleEndpointURI("tcp://localhost:7856");
assertEquals("tcp", url.getScheme());
assertEquals("tcp://localhost:7856", url.getAddress());
EndpointURI url = new MuleEndpointURI("symmetric://test:1022");
assertEquals("symmetric://test:1022", url.getUri().toASCIIString());
assertEquals("symmetric", url.getScheme());
assertNull(url.getEndpointName());
assertEquals(7856, url.getPort());
assertEquals("localhost", url.getHost());
assertEquals("tcp://localhost:7856", url.getAddress());
assertEquals(1022, url.getPort());
assertEquals("test", url.getHost());
assertEquals(0, url.getParams().size());
*/

throw new UnsupportedOperationException("testValidEndpointURI");
url = new MuleEndpointURI("symmetric://test:1022?x=y");
assertEquals("symmetric://test:1022?x=y", url.getUri().toASCIIString());
assertEquals("symmetric", url.getScheme());
assertNull(url.getEndpointName());
assertEquals(1022, url.getPort());
assertEquals("test", url.getHost());
assertEquals(1, url.getParams().size());
// assertTrue(url.getParams().contains("x"));
// assertEquals("y", url.getParams().get("x"));
}

}
Expand Up @@ -39,13 +39,13 @@ protected void doSetUp() throws Exception

public MessageReceiver getMessageReceiver() throws Exception {
Mock mockService = new Mock(Service.class);
mockService.expectAndReturn("getResponseTransformer", null);
mockService.expectAndReturn("getResponseRouter", null);
return new SymmetricMessageReceiver(endpoint.getConnector(),
(Service) mockService.proxy(), endpoint);
}

public InboundEndpoint getEndpoint() throws Exception {
EndpointBuilder builder = new EndpointURIEndpointBuilder("symmetric:http://localhost:1234", muleContext);
EndpointBuilder builder = new EndpointURIEndpointBuilder("symmetric://test", muleContext);
if (connector == null)
{
throw new InitialisationException(MessageFactory.createStaticMessage("Connector has not been initialized."), null);
Expand Down
Expand Up @@ -7,19 +7,26 @@
* license, a copy of which has been included with this distribution in the
* LICENSE.txt file.
*/

package org.jumpmind.mule.transport.symmetric;

import org.jumpmind.mule.transport.symmetric.SymmetricConnector;
import org.mule.tck.FunctionalTestCase;

/**
* TODO
*/
public class SymmetricNamespaceHandlerTestCase extends FunctionalTestCase
{

@Override
protected boolean isExcluded()
{
return true;
}

protected String getConfigResources()
{
//TODO You'll need to edit this file to configure the properties specific to your transport
// TODO You'll need to edit this file to configure the properties specific to your transport
return "symmetric-namespace-config.xml";
}

Expand All @@ -30,8 +37,7 @@ public void testSymmetricConfig() throws Exception
assertTrue(c.isConnected());
assertTrue(c.isStarted());

//TODO Assert specific properties are configured correctly

// TODO Assert specific properties are configured correctly

}
}

0 comments on commit c5ec32d

Please sign in to comment.