001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020package org.apache.mina.integration.beans; 021 022import static org.junit.Assert.assertEquals; 023import static org.junit.Assert.fail; 024 025import org.apache.mina.transport.vmpipe.VmPipeAddress; 026import org.junit.Before; 027import org.junit.Test; 028 029/** 030 * Tests {@link VmPipeAddressEditor}. 031 * 032 * @author <a href="http://mina.apache.org">Apache MINA Project</a> 033 */ 034public class VmPipeAddressEditorTest { 035 VmPipeAddressEditor editor; 036 037 @Before 038 public void setUp() throws Exception { 039 editor = new VmPipeAddressEditor(); 040 } 041 042 @Test 043 public void testSetAsTextWithLegalValues() throws Exception { 044 editor.setAsText("1"); 045 assertEquals(new VmPipeAddress(1), editor.getValue()); 046 editor.setAsText(":10"); 047 assertEquals(new VmPipeAddress(10), editor.getValue()); 048 editor.setAsText(":100"); 049 assertEquals(new VmPipeAddress(100), editor.getValue()); 050 } 051 052 @Test 053 public void testSetAsTextWithIllegalValues() throws Exception { 054 try { 055 editor.setAsText("bar"); 056 fail("Illegal port number. IllegalArgumentException expected."); 057 } catch (IllegalArgumentException iae) { 058 } 059 try { 060 editor.setAsText(":foo"); 061 fail("Illegal port number. IllegalArgumentException expected."); 062 } catch (IllegalArgumentException iae) { 063 } 064 } 065}