You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ni...@apache.org on 2006/02/12 19:55:05 UTC
svn commit: r377212 - in
/directory/sandbox/trustin/dirmina-158/integration-spring/src:
main/java/org/apache/mina/integration/spring/
main/java/org/apache/mina/integration/spring/support/
test/java/org/apache/mina/integration/spring/ test/java/org/apac...
Author: niklas
Date: Sun Feb 12 10:55:02 2006
New Revision: 377212
URL: http://svn.apache.org/viewcvs?rev=377212&view=rev
Log:
Updated Spring integration code to work with the new IoService/IoServiceConfig design.
Added:
directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/DefaultIoFilterChainBuilderFactoryBean.java (with props)
directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/InetSocketAddressEditor.java (with props)
directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/IoAcceptorFactoryBean.java (with props)
directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/VmPipeAddressEditor.java (with props)
directory/sandbox/trustin/dirmina-158/integration-spring/src/test/java/org/apache/mina/integration/spring/DefaultIoFilterChainBuilderFactoryBeanTest.java (with props)
directory/sandbox/trustin/dirmina-158/integration-spring/src/test/java/org/apache/mina/integration/spring/InetSocketAddressEditorTest.java (with props)
directory/sandbox/trustin/dirmina-158/integration-spring/src/test/java/org/apache/mina/integration/spring/IoAcceptorFactoryBeanTest.java (with props)
directory/sandbox/trustin/dirmina-158/integration-spring/src/test/java/org/apache/mina/integration/spring/VmPipeAddressEditorTest.java (with props)
Removed:
directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/DatagramAcceptorFactoryBean.java
directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/DatagramConnectorFactoryBean.java
directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/InetSocketAddressBindingIoAcceptorFactoryBean.java
directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/SocketAcceptorFactoryBean.java
directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/SocketConnectorFactoryBean.java
directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/VmPipeAcceptorFactoryBean.java
directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/VmPipeConnectorFactoryBean.java
directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/support/
directory/sandbox/trustin/dirmina-158/integration-spring/src/test/java/org/apache/mina/integration/spring/DatagramAcceptorFactoryBeanTest.java
directory/sandbox/trustin/dirmina-158/integration-spring/src/test/java/org/apache/mina/integration/spring/DatagramConnectorFactoryBeanTest.java
directory/sandbox/trustin/dirmina-158/integration-spring/src/test/java/org/apache/mina/integration/spring/InetSocketAddressBindingIoAcceptorFactoryBeanTest.java
directory/sandbox/trustin/dirmina-158/integration-spring/src/test/java/org/apache/mina/integration/spring/SocketAcceptorFactoryBeanTest.java
directory/sandbox/trustin/dirmina-158/integration-spring/src/test/java/org/apache/mina/integration/spring/SocketConnectorFactoryBeanTest.java
directory/sandbox/trustin/dirmina-158/integration-spring/src/test/java/org/apache/mina/integration/spring/VmPipeAcceptorFactoryBeanTest.java
directory/sandbox/trustin/dirmina-158/integration-spring/src/test/java/org/apache/mina/integration/spring/VmPipeConnectorFactoryBeanTest.java
directory/sandbox/trustin/dirmina-158/integration-spring/src/test/java/org/apache/mina/integration/spring/support/
Modified:
directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/Binding.java
directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/InetAddressEditor.java
Modified: directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/Binding.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/Binding.java?rev=377212&r1=377211&r2=377212&view=diff
==============================================================================
--- directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/Binding.java (original)
+++ directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/Binding.java Sun Feb 12 10:55:02 2006
@@ -18,22 +18,33 @@
*/
package org.apache.mina.integration.spring;
-import org.apache.mina.common.IoFilter;
+import java.net.SocketAddress;
+
+import org.apache.mina.common.IoAcceptor;
import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoServiceConfig;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.util.Assert;
/**
- * Defines an address to {@link org.apache.mina.common.IoHandler} binding.
+ * Defines an address to {@link IoHandler} binding.
* This is used when specifying the addresses to accept new connections on when
- * creating {@link org.apache.mina.common.IoAcceptor} objects using one of the
- * {@link org.apache.mina.integration.spring.support.AbstractIoAcceptorFactoryBean}
- * sub-classes.
+ * creating {@link org.apache.mina.common.IoAcceptor} objects using
+ * {@link IoAcceptorFactoryBean}.
+ * <p>
+ * Note that the <code>address</code> property is of {@link java.net.SocketAddress}
+ * type. Use {@link InetSocketAddressEditor} or {@link VmPipeAddressEditor} in
+ * your Spring configuration file to simply the creation of
+ * {@link java.net.SocketAddress} instances using Spring.
+ * </p>
* <p>
- * This class also allows for an optional list of filters to be associated with
- * the address. The {@link org.apache.mina.common.IoAcceptor} will add
- * all these filters to the filter chain of sessions created for incoming
- * connections on the address specified by this binding. This makes it possible
+ * This class also allows for an optional service configuration using
+ * {@link #setServiceConfig(IoServiceConfig)} to be specified. If the binding
+ * specifies an {@link IoServiceConfig} {@link IoAcceptorFactoryBean} will
+ * use {@link IoAcceptor#bind(SocketAddress, IoHandler, IoServiceConfig)} instead
+ * of {@link IoAcceptor#bind(SocketAddress, IoHandler)} when binding. The
+ * {@link IoServiceConfig} object lets you specify transport specific
+ * confiuration options and define port specific filters. This makes it possible
* to specify different filters depending on the port the client is connecting
* on (e.g. using an {@link org.apache.mina.filter.SSLFilter} when connecting
* on port 443 but not on port 80).
@@ -44,9 +55,9 @@
*/
public class Binding implements InitializingBean
{
- private String address = null;
+ private SocketAddress address = null;
private IoHandler handler = null;
- private IoFilterMapping[] filterMappings = new IoFilterMapping[ 0 ];
+ private IoServiceConfig serviceConfig = null;
/**
* Creates a new empty instance.
@@ -58,13 +69,12 @@
/**
* Creates a new instance using the specified values.
*
- * @param address the address. See {@link #setAddress(String)} for
- * information on the format.
+ * @param address the address.
* @param handler the handler.
* @throws IllegalArgumentException if the any of the specified values are
* <code>null</code>.
*/
- public Binding( String address, IoHandler handler )
+ public Binding( SocketAddress address, IoHandler handler )
{
setAddress( address );
setHandler( handler );
@@ -73,66 +83,38 @@
/**
* Creates a new instance using the specified values.
*
- * @param address the address. See {@link #setAddress(String)} for
- * information on the format.
+ * @param address the address.
* @param handler the handler.
- * @param filterMappings the filter mappigns.
+ * @param serviceConfig the service configuration.
* @throws IllegalArgumentException if the any of the specified values are
* <code>null</code>.
*/
- public Binding( String address, IoHandler handler,
- IoFilterMapping[] filterMappings )
+ public Binding( SocketAddress address, IoHandler handler,
+ IoServiceConfig serviceConfig )
{
setAddress( address );
setHandler( handler );
- setFilterMappings( filterMappings );
+ setServiceConfig( serviceConfig );
}
/**
- * Creates a new instance using the specified values.
- *
- * @param address the address. See {@link #setAddress(String)} for
- * information on the format.
- * @param handler the handler.
- * @param filters the filters.
- * @throws IllegalArgumentException if the any of the specified values are
- * <code>null</code>.
- */
- public Binding( String address, IoHandler handler,
- IoFilter[] filters )
- {
- setAddress( address );
- setHandler( handler );
- setFilters( filters );
- }
-
- /**
* Returns the address the handler of this object will be bound to.
- * See {@link #setAddress(String)} for more information on the format of this
- * string.
*
- * @return the textual representation of the transport type specific address.
+ * @return the address.
*/
- public String getAddress()
+ public SocketAddress getAddress()
{
return address;
}
/**
* Sets the address the handler of this object will be bound to.
- * The format of this address depends on the transport type of the
- * {@link org.apache.mina.common.IoAcceptor} this binding will be used for.
- * When creating a {@link org.apache.mina.transport.socket.nio.SocketAcceptor}
- * using {@link SocketAcceptorFactoryBean} the format looks like
- * <code>[<interface>:]port</code>, e.g. <code>127.0.0.1:8080</code>.
- * {@link #getAddress()}
*
- * @param address the textual representation of the transport type specific
- * address.
+ * @param address the address.
* @throws IllegalArgumentException if the specified value is
* <code>null</code>.
*/
- public void setAddress( String address )
+ public void setAddress( SocketAddress address )
{
Assert.notNull( address, "Property 'address' may not be null" );
this.address = address;
@@ -161,53 +143,14 @@
this.handler = handler;
}
- /**
- * Sets a number of unnamed filters. These will be added to the filter chain
- * of sessions created when a connection is made on the address specified by
- * this binding. The filters will be assigned automatically generated names
- * (<code>portFilter0</code>, <code>portFilter1</code>, etc).
- *
- * @param filters the filters.
- * @throws IllegalArgumentException if the specified value is
- * <code>null</code>.
- */
- public void setFilters( IoFilter[] filters )
+ public IoServiceConfig getServiceConfig()
{
- Assert.notNull( filters, "Property 'filters' may not be null" );
- this.filterMappings = new IoFilterMapping[ filters.length ];
-
- for( int i = 0; i < filters.length; i++ )
- {
- this.filterMappings[ i ] = new IoFilterMapping();
- this.filterMappings[ i ].setName( "portFilter" + i );
- this.filterMappings[ i ].setFilter( filters[ i ] );
- }
+ return serviceConfig;
}
- /**
- * Sets a number of named filters. These will be added to the filter chain
- * of sessions created when a connection is made on the address specified by
- * this binding.
- *
- * @param filterMappings the name to filter mappings.
- * @throws IllegalArgumentException if the specified value is
- * <code>null</code>.
- */
- public void setFilterMappings( IoFilterMapping[] filterMappings )
- {
- Assert.notNull( filterMappings, "Property 'filterMappings' may not be null" );
- this.filterMappings = filterMappings;
- }
-
- /**
- * Returns the array of {@link IoFilterMapping} objects configured for this
- * binding.
- *
- * @return the mappings.
- */
- public IoFilterMapping[] getFilterMappings()
+ public void setServiceConfig( IoServiceConfig serviceConfig )
{
- return filterMappings;
+ this.serviceConfig = serviceConfig;
}
public void afterPropertiesSet() throws Exception
Added: directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/DefaultIoFilterChainBuilderFactoryBean.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/DefaultIoFilterChainBuilderFactoryBean.java?rev=377212&view=auto
==============================================================================
--- directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/DefaultIoFilterChainBuilderFactoryBean.java (added)
+++ directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/DefaultIoFilterChainBuilderFactoryBean.java Sun Feb 12 10:55:02 2006
@@ -0,0 +1,127 @@
+/*
+ * @(#) $Id$
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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.mina.integration.spring;
+
+import org.apache.mina.common.DefaultIoFilterChainBuilder;
+import org.apache.mina.common.IoFilter;
+import org.springframework.beans.factory.config.AbstractFactoryBean;
+import org.springframework.util.Assert;
+
+/**
+ * Spring {@link org.springframework.beans.factory.FactoryBean}
+ * which creates {@link DefaultIoFilterChainBuilder} instances. This
+ * factory bean makes it possible to configure the filters to be added to all the
+ * sessions created by an {@link org.apache.mina.common.IoAcceptor}
+ * or {@link org.apache.mina.common.IoConnector} using Spring.
+ * <p>
+ * The filters may be set up in two ways. By creating
+ * {@link IoFilterMapping} objects which associate a name with an {@link IoFilter}
+ * instance and set them using {@link #setFilterMappings(IoFilterMapping[])} or
+ * by using {@link #setFilters(IoFilter[])} directly which assigns automatically
+ * generated names to each {@link IoFilter}. Use the
+ * {@link #setFilterNamePrefix(String)} method to set the prefix used for
+ * auto generated names.
+ * </p>
+ *
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ */
+public class DefaultIoFilterChainBuilderFactoryBean extends AbstractFactoryBean
+{
+ private IoFilterMapping[] filterMappings = new IoFilterMapping[ 0 ];
+ private String prefix = "filter";
+
+ protected Object createInstance() throws Exception
+ {
+ DefaultIoFilterChainBuilder builder = new DefaultIoFilterChainBuilder();
+ for( int i = 0; i < filterMappings.length; i++ )
+ {
+ String name = filterMappings[ i ].getName();
+ if( name == null )
+ {
+ name = prefix + i;
+ }
+ builder.addLast( name, filterMappings[ i ].getFilter() );
+ }
+
+ return builder;
+ }
+
+ public Class getObjectType()
+ {
+ return DefaultIoFilterChainBuilder.class;
+ }
+
+ /**
+ * Sets the prefix used to create the names for automatically named filters
+ * added using {@link #setFilters(IoFilter[]). The default prefix is
+ * <tt>filter</tt>.
+ *
+ * @param prefix the prefix.
+ * @throws IllegalArgumentException if the specified value is
+ * <code>null</code>.
+ */
+ public void setFilterNamePrefix( String prefix )
+ {
+ Assert.notNull( prefix, "Property 'filterNamePrefix' may not be null" );
+ this.prefix = prefix;
+ }
+
+ /**
+ * Sets a number of unnamed filters which will be added to the filter
+ * chain created by this factory bean. The filters will be assigned
+ * automatically generated names (<code><filterNamePrefix>0</code>,
+ * <code><filterNamePrefix>1</code>, etc).
+ *
+ * @param filters the filters.
+ * @throws IllegalArgumentException if the specified value is
+ * <code>null</code>.
+ * @see #setFilterNamePrefix(String)
+ */
+ public void setFilters( IoFilter[] filters )
+ {
+ Assert.notNull( filters, "Property 'filters' may not be null" );
+ this.filterMappings = new IoFilterMapping[ filters.length ];
+
+ for( int i = 0; i < filters.length; i++ )
+ {
+ this.filterMappings[ i ] = new IoFilterMapping();
+ this.filterMappings[ i ].setFilter( filters[ i ] );
+ }
+ }
+
+ /**
+ * Sets a number of named filters which will be added to the filter
+ * chain created by this factory bean. {@link IoFilterMapping} objects
+ * set using this method which haven't had their name set will be assigned
+ * automatically generated names derived from the prefix set using
+ * {@link #setFilterNamePrefix(String)} and the position in the specified
+ * array (i.e. <code><filterNamePrefix><pos></code>).
+ *
+ * @param filterMappings the name to filter mappings.
+ * @throws IllegalArgumentException if the specified value is
+ * <code>null</code>.
+ * @see #setFilterNamePrefix(String)
+ */
+ public void setFilterMappings( IoFilterMapping[] filterMappings )
+ {
+ Assert.notNull( filterMappings, "Property 'filterMappings' may not be null" );
+ this.filterMappings = filterMappings;
+ }
+}
Propchange: directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/DefaultIoFilterChainBuilderFactoryBean.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/InetAddressEditor.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/InetAddressEditor.java?rev=377212&r1=377211&r2=377212&view=diff
==============================================================================
--- directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/InetAddressEditor.java (original)
+++ directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/InetAddressEditor.java Sun Feb 12 10:55:02 2006
@@ -23,16 +23,16 @@
import java.net.UnknownHostException;
/**
- * Java Bean PropertyEditor which converts Strings into InetAddress objects.
- * This may be used together with Spring to be able to set InetAddress bean
- * properties, e.g.
+ * Java Bean {@link java.beans.PropertyEditor} which converts Strings into
+ * {@link InetAddress} objects. This may be used together with Spring to be able
+ * to set {@link InetAddress} bean properties, e.g.
* {@link org.apache.mina.filter.BlacklistFilter#setBlacklist(InetAddress[])}.
- * Simply calls {@link java.net.InetAddress#getByName(java.lang.String)} when
+ * Simply calls {@link InetAddress#getByName(java.lang.String)} when
* converting from a String.
* <p>
* Use Spring's CustomEditorConfigurer to use this property editor in a Spring
- * context. See chapter 3.14 of the Spring Reference Documentation for more
- * info.
+ * configuration file. See chapter 3.14 of the Spring Reference Documentation
+ * for more info.
* </p>
*
* @author The Apache Directory Project (dev@directory.apache.org)
Added: directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/InetSocketAddressEditor.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/InetSocketAddressEditor.java?rev=377212&view=auto
==============================================================================
--- directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/InetSocketAddressEditor.java (added)
+++ directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/InetSocketAddressEditor.java Sun Feb 12 10:55:02 2006
@@ -0,0 +1,80 @@
+/*
+ * @(#) $Id$
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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.mina.integration.spring;
+
+import java.beans.PropertyEditorSupport;
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+
+import org.springframework.util.Assert;
+
+/**
+ * Java Bean {@link java.beans.PropertyEditor} which converts Strings into
+ * {@link InetSocketAddress} objects. Valid values include a hostname or ip
+ * address and a port number separated by a ':'. If the hostname or ip address
+ * is omitted the wildcard address will be used. E.g.:
+ * <code>google.com:80</code>, <code>:22</code>, <code>192.168.0.1:110</code>.
+ * <p>
+ * Use Spring's CustomEditorConfigurer to use this property editor in a Spring
+ * configuration file. See chapter 3.14 of the Spring Reference Documentation
+ * for more info.
+ * </p>
+ *
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Revision$, $Date$
+ *
+ * @see java.net.InetSocketAddress
+ */
+public class InetSocketAddressEditor extends PropertyEditorSupport
+{
+ public void setAsText( String text ) throws IllegalArgumentException
+ {
+ setValue( parseSocketAddress( text ) );
+ }
+
+ private SocketAddress parseSocketAddress( String s )
+ {
+ Assert.notNull( s, "null SocketAddress string" );
+ s = s.trim();
+ int colonIndex = s.indexOf( ":" );
+ if( colonIndex > 0 )
+ {
+ String host = s.substring( 0, colonIndex );
+ int port = parsePort( s.substring( colonIndex + 1 ) );
+ return new InetSocketAddress( host, port );
+ }
+ else
+ {
+ int port = parsePort( s.substring( colonIndex + 1 ) );
+ return new InetSocketAddress( port );
+ }
+ }
+
+ private int parsePort( String s )
+ {
+ try
+ {
+ return Integer.parseInt( s );
+ }
+ catch( NumberFormatException nfe )
+ {
+ throw new IllegalArgumentException( "Illegal port number: " + s );
+ }
+ }
+}
Propchange: directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/InetSocketAddressEditor.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/IoAcceptorFactoryBean.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/IoAcceptorFactoryBean.java?rev=377212&view=auto
==============================================================================
--- directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/IoAcceptorFactoryBean.java (added)
+++ directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/IoAcceptorFactoryBean.java Sun Feb 12 10:55:02 2006
@@ -0,0 +1,187 @@
+/*
+ * @(#) $Id$
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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.mina.integration.spring;
+
+import java.net.SocketAddress;
+
+import org.apache.mina.common.IoAcceptor;
+import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoServiceConfig;
+import org.springframework.beans.factory.DisposableBean;
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.util.Assert;
+
+
+/**
+ * Spring {@link FactoryBean} which enables the bindings of an {@link IoAcceptor}
+ * to be configured using Spring. Example of usage:
+ * <p>
+ *
+ * <pre>
+ * <!-- POP3 server IoHandler implementation-->
+ * <bean id="pop3Handler" class="com.foo.bar.MyPop3Handler">
+ * ...
+ * <!-- IMAP server IoHandler implementation -->
+ * <bean id="imapHandler" class="com.foo.bar.MyImapHandler">
+ * ...
+ * </bean>
+ * <!-- Telnet based admin console handler. Should only be
+ * accessible from localhost -->
+ * <bean id="adminHandler" class="com.foo.bar.MyAdminHandler">
+ * ...
+ * </bean>
+ *
+ * <!-- Create a thread pool filter -->
+ * <bean id="threadPoolFilter"
+ * class="org.apache.mina.filter.ThreadPoolFilter">
+ * <!-- Threads will be named IoWorker-1, IoWorker-2, etc -->
+ * <constructor-arg value="IoWorker"/>
+ * <property name="maximumPoolSize" value="10"/>
+ * </bean>
+ *
+ * <!-- Create an SSL filter to be used for POP3 over SSL -->
+ * <bean id="sslFilter" class="org.apache.mina.filter.SSLFilter">
+ * ...
+ * </bean>
+ *
+ * <!-- Create the SocketAcceptor -->
+ * <bean id="socketAcceptor"
+ * class="org.apache.mina.integration.spring.SocketAcceptorFactoryBean">
+ * <property name="filters">
+ * <list>
+ * <ref local="threadPoolFilter"/>
+ * </list>
+ * </property>
+ * <property name="bindings">
+ * <list>
+ * <bean class="org.apache.mina.integration.spring.Binding">
+ * <property name="address" value=":110"/>
+ * <property name="handler" ref="pop3Handler"/>
+ * </bean>
+ * <bean class="org.apache.mina.integration.spring.Binding">
+ * <property name="address" value=":995"/>
+ * <property name="handler" ref="pop3Handler"/>
+ * <property name="filters">
+ * <list>
+ * <ref local="sslFilter"/>
+ * </list>
+ * </property>
+ * </bean>
+ * <bean class="org.apache.mina.integration.spring.Binding">
+ * <property name="address" value=":143"/>
+ * <property name="handler" ref="imapHandler"/>
+ * </bean>
+ * <bean class="org.apache.mina.integration.spring.Binding">
+ * <property name="address" value="127.0.0.1:60987"/>
+ * <property name="handler" ref="adminHandler"/>
+ * </bean>
+ * </list>
+ * </property>
+ * </bean>
+ * </pre>
+ *
+ * </p>
+ *
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ */
+public class IoAcceptorFactoryBean implements FactoryBean, InitializingBean, DisposableBean
+{
+ private Binding[] bindings = new Binding[ 0 ];
+ private IoAcceptor target;
+
+ /**
+ * Sets the {@link IoAcceptor} to be configured using this factory bean.
+ *
+ * @param target the target {@link IoAcceptor}.
+ */
+ public void setTarget( IoAcceptor target )
+ {
+ this.target = target;
+ }
+
+ /**
+ * Sets the bindings to be used by the {@link IoAcceptor} configured by this
+ * factory bean.
+ *
+ * @param bindings the bindings.
+ * @throws IllegalArgumentException if the specified value is
+ * <code>null</code>.
+ * @see IoAcceptor#bind(SocketAddress, IoHandler)
+ * @see IoAcceptor#bind(SocketAddress, IoHandler, IoServiceConfig)
+ * @see Binding
+ */
+ public void setBindings( Binding[] bindings )
+ {
+ Assert.notNull( bindings, "Property 'bindings' may not be null" );
+ this.bindings = bindings;
+ }
+
+ public Object getObject() throws Exception
+ {
+ return target;
+ }
+
+ public Class getObjectType()
+ {
+ return IoAcceptor.class;
+ }
+
+ public boolean isSingleton()
+ {
+ return true;
+ }
+
+ public void afterPropertiesSet() throws Exception
+ {
+ Assert.notNull( target, "Property 'target' may not be null" );
+
+ /*
+ * Bind all.
+ */
+ for( int i = 0; i < bindings.length; i++ )
+ {
+ Binding b = bindings[ i ];
+ if( b.getServiceConfig() != null )
+ {
+ target.bind( b.getAddress(), b.getHandler(), b.getServiceConfig() );
+ }
+ else
+ {
+ target.bind( b.getAddress(), b.getHandler() );
+ }
+ }
+ }
+
+ public void destroy() throws Exception
+ {
+ for( int i = 0; i < bindings.length; i++ )
+ {
+ Binding b = bindings[ i ];
+ try
+ {
+ target.unbind( b.getAddress() );
+ }
+ catch( Exception ignored )
+ {
+ }
+ }
+ }
+}
Propchange: directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/IoAcceptorFactoryBean.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/VmPipeAddressEditor.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/VmPipeAddressEditor.java?rev=377212&view=auto
==============================================================================
--- directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/VmPipeAddressEditor.java (added)
+++ directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/VmPipeAddressEditor.java Sun Feb 12 10:55:02 2006
@@ -0,0 +1,66 @@
+/*
+ * @(#) $Id$
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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.mina.integration.spring;
+
+import java.beans.PropertyEditorSupport;
+import java.net.SocketAddress;
+
+import org.apache.mina.transport.vmpipe.VmPipeAddress;
+import org.springframework.util.Assert;
+
+/**
+ * Java Bean {@link java.beans.PropertyEditor} which converts Strings into
+ * {@link VmPipeAddress} objects. Valid values specify an integer port number
+ * optionally prefixed with a ':'. E.g.: <code>:80</code>, <code>22</code>.
+ * <p>
+ * Use Spring's CustomEditorConfigurer to use this property editor in a Spring
+ * configuration file. See chapter 3.14 of the Spring Reference Documentation
+ * for more info.
+ * </p>
+ *
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Revision$, $Date$
+ *
+ * @see org.apache.mina.transport.vmpipe.VmPipeAddress
+ */
+public class VmPipeAddressEditor extends PropertyEditorSupport
+{
+ public void setAsText( String text ) throws IllegalArgumentException
+ {
+ setValue( parseSocketAddress( text ) );
+ }
+
+ private SocketAddress parseSocketAddress( String s )
+ {
+ Assert.notNull( s, "null SocketAddress string" );
+ s = s.trim();
+ if( s.startsWith( ":" ) )
+ {
+ s = s.substring( 1 );
+ }
+ try
+ {
+ return new VmPipeAddress( Integer.parseInt( s.trim() ) );
+ }
+ catch( NumberFormatException nfe )
+ {
+ throw new IllegalArgumentException( "Illegal vm pipe address: " + s );
+ }
+ }
+}
Propchange: directory/sandbox/trustin/dirmina-158/integration-spring/src/main/java/org/apache/mina/integration/spring/VmPipeAddressEditor.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: directory/sandbox/trustin/dirmina-158/integration-spring/src/test/java/org/apache/mina/integration/spring/DefaultIoFilterChainBuilderFactoryBeanTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/dirmina-158/integration-spring/src/test/java/org/apache/mina/integration/spring/DefaultIoFilterChainBuilderFactoryBeanTest.java?rev=377212&view=auto
==============================================================================
--- directory/sandbox/trustin/dirmina-158/integration-spring/src/test/java/org/apache/mina/integration/spring/DefaultIoFilterChainBuilderFactoryBeanTest.java (added)
+++ directory/sandbox/trustin/dirmina-158/integration-spring/src/test/java/org/apache/mina/integration/spring/DefaultIoFilterChainBuilderFactoryBeanTest.java Sun Feb 12 10:55:02 2006
@@ -0,0 +1,100 @@
+/*
+ * @(#) $Id$
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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.mina.integration.spring;
+
+import org.apache.mina.common.DefaultIoFilterChainBuilder;
+import org.apache.mina.common.IoFilter;
+import org.apache.mina.common.IoFilterChain;
+import org.easymock.MockControl;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests {@link DefaultFilterChainBuilderFactoryBean}.
+ *
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ */
+public class DefaultIoFilterChainBuilderFactoryBeanTest extends TestCase
+{
+ MockControl mockChain;
+ IoFilterChain chain;
+ IoFilter[] filters;
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ mockChain = MockControl.createControl( IoFilterChain.class );
+ chain = ( IoFilterChain ) mockChain.getMock();
+ filters = new IoFilter[] {
+ ( IoFilter ) MockControl.createControl( IoFilter.class ).getMock(),
+ ( IoFilter ) MockControl.createControl( IoFilter.class ).getMock(),
+ ( IoFilter ) MockControl.createControl( IoFilter.class ).getMock()
+ };
+ }
+
+ public void testUnnamedFilters() throws Exception
+ {
+ chain.addLast( "prefix0", filters[ 0 ] );
+ chain.addLast( "prefix1", filters[ 1 ] );
+ chain.addLast( "prefix2", filters[ 2 ] );
+
+ mockChain.replay();
+
+ DefaultIoFilterChainBuilderFactoryBean factory =
+ new DefaultIoFilterChainBuilderFactoryBean();
+ factory.setFilters( filters );
+ factory.setFilterNamePrefix( "prefix" );
+ DefaultIoFilterChainBuilder builder =
+ ( DefaultIoFilterChainBuilder) factory.createInstance();
+ builder.buildFilterChain( chain );
+
+ mockChain.verify();
+ }
+
+ public void testnamedAndUnnamedFilters() throws Exception
+ {
+ IoFilterMapping[] mappings = new IoFilterMapping[] {
+ new IoFilterMapping(),
+ new IoFilterMapping(),
+ new IoFilterMapping()
+ };
+ mappings[ 0 ].setFilter( filters[ 0 ] );
+ mappings[ 0 ].setName( "f0" );
+ mappings[ 1 ].setFilter( filters[ 1 ] );
+ mappings[ 2 ].setFilter( filters[ 2 ] );
+ mappings[ 2 ].setName( "f2" );
+
+ chain.addLast( "f0", filters[ 0 ] );
+ chain.addLast( "filter1", filters[ 1 ] );
+ chain.addLast( "f2", filters[ 2 ] );
+
+ mockChain.replay();
+
+ DefaultIoFilterChainBuilderFactoryBean factory =
+ new DefaultIoFilterChainBuilderFactoryBean();
+ factory.setFilterMappings( mappings );
+ DefaultIoFilterChainBuilder builder =
+ ( DefaultIoFilterChainBuilder) factory.createInstance();
+ builder.buildFilterChain( chain );
+
+ mockChain.verify();
+ }
+}
Propchange: directory/sandbox/trustin/dirmina-158/integration-spring/src/test/java/org/apache/mina/integration/spring/DefaultIoFilterChainBuilderFactoryBeanTest.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: directory/sandbox/trustin/dirmina-158/integration-spring/src/test/java/org/apache/mina/integration/spring/InetSocketAddressEditorTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/dirmina-158/integration-spring/src/test/java/org/apache/mina/integration/spring/InetSocketAddressEditorTest.java?rev=377212&view=auto
==============================================================================
--- directory/sandbox/trustin/dirmina-158/integration-spring/src/test/java/org/apache/mina/integration/spring/InetSocketAddressEditorTest.java (added)
+++ directory/sandbox/trustin/dirmina-158/integration-spring/src/test/java/org/apache/mina/integration/spring/InetSocketAddressEditorTest.java Sun Feb 12 10:55:02 2006
@@ -0,0 +1,96 @@
+/*
+ * @(#) $Id$
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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.mina.integration.spring;
+
+import java.net.InetSocketAddress;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests {@link InetSocketAddressEditor}.
+ *
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ */
+public class InetSocketAddressEditorTest extends TestCase
+{
+ InetSocketAddressEditor editor;
+
+ protected void setUp() throws Exception
+ {
+ editor = new InetSocketAddressEditor();
+ }
+
+ public void testSetAsTextWithWildcardAddress() throws Exception
+ {
+ editor.setAsText( "1" );
+ assertEquals( new InetSocketAddress( 1 ), editor.getValue() );
+ editor.setAsText( ":10" );
+ assertEquals( new InetSocketAddress( 10 ), editor.getValue() );
+ }
+
+ public void testSetAsTextWithHostName() throws Exception
+ {
+ editor.setAsText( "www.google.com:80" );
+ assertEquals( new InetSocketAddress( "www.google.com", 80 ), editor.getValue() );
+ }
+
+ public void testSetAsTextWithIpAddress() throws Exception
+ {
+ editor.setAsText( "192.168.0.1:1000" );
+ assertEquals( new InetSocketAddress( "192.168.0.1", 1000 ), editor.getValue() );
+ }
+
+ public void testSetAsTextWithIllegalValues() throws Exception
+ {
+ try
+ {
+ editor.setAsText( null );
+ fail( "null string. IllegalArgumentException expected." );
+ }
+ catch( IllegalArgumentException iae )
+ {
+ }
+ try
+ {
+ editor.setAsText( "bar" );
+ fail( "Illegal port number. IllegalArgumentException expected." );
+ }
+ catch( IllegalArgumentException iae )
+ {
+ }
+ try
+ {
+ editor.setAsText( ":foo" );
+ fail( "Illegal port number. IllegalArgumentException expected." );
+ }
+ catch( IllegalArgumentException iae )
+ {
+ }
+ try
+ {
+ editor.setAsText( "www.foo.com:yada" );
+ fail( "Illegal port number. IllegalArgumentException expected." );
+ }
+ catch( IllegalArgumentException iae )
+ {
+ }
+ }
+
+}
Propchange: directory/sandbox/trustin/dirmina-158/integration-spring/src/test/java/org/apache/mina/integration/spring/InetSocketAddressEditorTest.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: directory/sandbox/trustin/dirmina-158/integration-spring/src/test/java/org/apache/mina/integration/spring/IoAcceptorFactoryBeanTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/dirmina-158/integration-spring/src/test/java/org/apache/mina/integration/spring/IoAcceptorFactoryBeanTest.java?rev=377212&view=auto
==============================================================================
--- directory/sandbox/trustin/dirmina-158/integration-spring/src/test/java/org/apache/mina/integration/spring/IoAcceptorFactoryBeanTest.java (added)
+++ directory/sandbox/trustin/dirmina-158/integration-spring/src/test/java/org/apache/mina/integration/spring/IoAcceptorFactoryBeanTest.java Sun Feb 12 10:55:02 2006
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2004-2005, Trillian AB. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are prohibited without specific prior
+ * written permission from Trillian AB (http://www.trillian.se).
+ *
+ * This notice and attribution to Trillian AB may not be removed.
+ *
+ * Created on 2006-feb-12
+ */
+package org.apache.mina.integration.spring;
+
+import java.net.InetSocketAddress;
+
+import org.apache.mina.common.IoAcceptor;
+import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoHandlerAdapter;
+import org.apache.mina.common.IoServiceConfig;
+import org.easymock.MockControl;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests {@link IoAcceptorFactoryBean}.
+ *
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ */
+public class IoAcceptorFactoryBeanTest extends TestCase
+{
+ public void testBindUnbind() throws Exception
+ {
+ IoHandler handler1 = new IoHandlerAdapter();
+ IoHandler handler2 = new IoHandlerAdapter();
+ IoHandler handler3 = new IoHandlerAdapter();
+ IoServiceConfig config1 =
+ ( IoServiceConfig ) MockControl.createControl( IoServiceConfig.class ).getMock();
+ IoServiceConfig config2 =
+ ( IoServiceConfig ) MockControl.createControl( IoServiceConfig.class ).getMock();
+ MockControl mockIoAcceptor = MockControl.createControl( IoAcceptor.class );
+ IoAcceptor acceptor = ( IoAcceptor ) mockIoAcceptor.getMock();
+
+ acceptor.bind( new InetSocketAddress( 80 ), handler1, config1 );
+ acceptor.bind( new InetSocketAddress( "192.168.0.1", 22 ), handler2, config2 );
+ acceptor.bind( new InetSocketAddress( "10.0.0.1", 9876 ), handler3 );
+ acceptor.unbind( new InetSocketAddress( 80 ) );
+ acceptor.unbind( new InetSocketAddress( "192.168.0.1", 22 ) );
+ acceptor.unbind( new InetSocketAddress( "10.0.0.1", 9876 ) );
+
+ mockIoAcceptor.replay();
+
+ IoAcceptorFactoryBean factory = new IoAcceptorFactoryBean();
+ factory.setTarget( acceptor );
+ factory.setBindings( new Binding[] {
+ new Binding( new InetSocketAddress( 80 ), handler1, config1 ),
+ new Binding( new InetSocketAddress( "192.168.0.1", 22 ), handler2, config2 ),
+ new Binding( new InetSocketAddress( "10.0.0.1", 9876 ), handler3 )
+ } );
+ factory.afterPropertiesSet();
+ factory.destroy();
+
+ mockIoAcceptor.verify();
+ }
+
+ public void testIsSingleton() throws Exception
+ {
+ assertTrue( new IoAcceptorFactoryBean().isSingleton() );
+ }
+
+ public void testGetObjectType() throws Exception
+ {
+ assertEquals( IoAcceptor.class, new IoAcceptorFactoryBean().getObjectType() );
+ }
+
+ public void testGetObject() throws Exception
+ {
+ IoAcceptor acceptor =
+ ( IoAcceptor ) MockControl.createControl( IoAcceptor.class ).getMock();
+ IoAcceptorFactoryBean factory = new IoAcceptorFactoryBean();
+ factory.setTarget( acceptor );
+
+ assertEquals( acceptor, factory.getObject() );
+ }
+
+}
Propchange: directory/sandbox/trustin/dirmina-158/integration-spring/src/test/java/org/apache/mina/integration/spring/IoAcceptorFactoryBeanTest.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: directory/sandbox/trustin/dirmina-158/integration-spring/src/test/java/org/apache/mina/integration/spring/VmPipeAddressEditorTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/dirmina-158/integration-spring/src/test/java/org/apache/mina/integration/spring/VmPipeAddressEditorTest.java?rev=377212&view=auto
==============================================================================
--- directory/sandbox/trustin/dirmina-158/integration-spring/src/test/java/org/apache/mina/integration/spring/VmPipeAddressEditorTest.java (added)
+++ directory/sandbox/trustin/dirmina-158/integration-spring/src/test/java/org/apache/mina/integration/spring/VmPipeAddressEditorTest.java Sun Feb 12 10:55:02 2006
@@ -0,0 +1,78 @@
+/*
+ * @(#) $Id$
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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.mina.integration.spring;
+
+import junit.framework.TestCase;
+
+import org.apache.mina.transport.vmpipe.VmPipeAddress;
+
+/**
+ * Tests {@link VmPipeAddressEditor}.
+ *
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ */
+public class VmPipeAddressEditorTest extends TestCase
+{
+ VmPipeAddressEditor editor;
+
+ protected void setUp() throws Exception
+ {
+ editor = new VmPipeAddressEditor();
+ }
+
+ public void testSetAsTextWithLegalValues() throws Exception
+ {
+ editor.setAsText( "1" );
+ assertEquals( new VmPipeAddress( 1 ), editor.getValue() );
+ editor.setAsText( ":10" );
+ assertEquals( new VmPipeAddress( 10 ), editor.getValue() );
+ editor.setAsText( ":100" );
+ assertEquals( new VmPipeAddress( 100 ), editor.getValue() );
+ }
+
+ public void testSetAsTextWithIllegalValues() throws Exception
+ {
+ try
+ {
+ editor.setAsText( null );
+ fail( "null string. IllegalArgumentException expected." );
+ }
+ catch( IllegalArgumentException iae )
+ {
+ }
+ try
+ {
+ editor.setAsText( "bar" );
+ fail( "Illegal port number. IllegalArgumentException expected." );
+ }
+ catch( IllegalArgumentException iae )
+ {
+ }
+ try
+ {
+ editor.setAsText( ":foo" );
+ fail( "Illegal port number. IllegalArgumentException expected." );
+ }
+ catch( IllegalArgumentException iae )
+ {
+ }
+ }
+
+}
Propchange: directory/sandbox/trustin/dirmina-158/integration-spring/src/test/java/org/apache/mina/integration/spring/VmPipeAddressEditorTest.java
------------------------------------------------------------------------------
svn:keywords = Id