directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r371249 - in /directory/sandbox/trustin/mina-spi/spring/src: main/java/org/apache/mina/integration/spring/IoAddressEditor.java test/java/org/apache/mina/integration/spring/IoAddressEditorTest.java
Date Sun, 22 Jan 2006 09:27:32 GMT
Author: trustin
Date: Sun Jan 22 01:27:26 2006
New Revision: 371249

URL: http://svn.apache.org/viewcvs?rev=371249&view=rev
Log:
Added JavaBeans editor for IoAddress

Added:
    directory/sandbox/trustin/mina-spi/spring/src/main/java/org/apache/mina/integration/spring/IoAddressEditor.java
  (with props)
    directory/sandbox/trustin/mina-spi/spring/src/test/java/org/apache/mina/integration/spring/IoAddressEditorTest.java
  (with props)

Added: directory/sandbox/trustin/mina-spi/spring/src/main/java/org/apache/mina/integration/spring/IoAddressEditor.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/mina-spi/spring/src/main/java/org/apache/mina/integration/spring/IoAddressEditor.java?rev=371249&view=auto
==============================================================================
--- directory/sandbox/trustin/mina-spi/spring/src/main/java/org/apache/mina/integration/spring/IoAddressEditor.java
(added)
+++ directory/sandbox/trustin/mina-spi/spring/src/main/java/org/apache/mina/integration/spring/IoAddressEditor.java
Sun Jan 22 01:27:26 2006
@@ -0,0 +1,46 @@
+/*
+ *   @(#) $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 org.apache.mina.common.IoAddress;
+
+/**
+ * Java Bean PropertyEditor which converts Strings into {@link IoAddress} objects.
+ * This may be used together with Spring to be able to set IoAddress bean
+ * properties
+ * 
+ * Simply calls {@link IoAddress#IoAddress(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.
+ * </p>
+ * 
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Revision$, $Date$
+ */
+public class IoAddressEditor extends PropertyEditorSupport
+{
+    public void setAsText( String text ) throws IllegalArgumentException
+    {
+        setValue( new IoAddress( text ) );
+    }
+}

Propchange: directory/sandbox/trustin/mina-spi/spring/src/main/java/org/apache/mina/integration/spring/IoAddressEditor.java
------------------------------------------------------------------------------
    svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision

Added: directory/sandbox/trustin/mina-spi/spring/src/test/java/org/apache/mina/integration/spring/IoAddressEditorTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/mina-spi/spring/src/test/java/org/apache/mina/integration/spring/IoAddressEditorTest.java?rev=371249&view=auto
==============================================================================
--- directory/sandbox/trustin/mina-spi/spring/src/test/java/org/apache/mina/integration/spring/IoAddressEditorTest.java
(added)
+++ directory/sandbox/trustin/mina-spi/spring/src/test/java/org/apache/mina/integration/spring/IoAddressEditorTest.java
Sun Jan 22 01:27:26 2006
@@ -0,0 +1,49 @@
+/*
+ *   @(#) $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.Assert;
+import junit.framework.TestCase;
+
+import org.apache.mina.common.IoAddress;
+
+/**
+ * Tests {@link org.apache.mina.integration.spring.IoAddressEditor}.
+ * 
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ */
+public class IoAddressEditorTest extends TestCase
+{
+    IoAddressEditor editor;
+
+    protected void setUp() throws Exception
+    {
+        editor = new IoAddressEditor();
+    }
+
+    public void testSetAsText() throws Exception
+    {
+        editor.setAsText( "nio:socket:localhost:8080" );
+        IoAddress address = ( IoAddress ) editor.getValue();
+        Assert.assertEquals( "nio", address.getProviderType() );
+        Assert.assertEquals( "socket", address.getTransportType() );
+        Assert.assertEquals( "localhost:8080", address.getAddress() );
+    }
+}

Propchange: directory/sandbox/trustin/mina-spi/spring/src/test/java/org/apache/mina/integration/spring/IoAddressEditorTest.java
------------------------------------------------------------------------------
    svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision



Mime
View raw message