/**
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.qpid.jms.transports;

import static org.junit.Assert.assertEquals;

import org.apache.qpid.jms.test.QpidJmsTestCase;
import org.junit.Test;

/**
 * Test for class TransportOptions
 */
public class TransportOptionsTest extends QpidJmsTestCase {

    public static final int TEST_SEND_BUFFER_SIZE = 128 * 1024;
    public static final int TEST_RECEIVE_BUFFER_SIZE = TEST_SEND_BUFFER_SIZE;
    public static final int TEST_TRAFFIC_CLASS = 1;
    public static final boolean TEST_TCP_NO_DELAY = false;
    public static final boolean TEST_TCP_KEEP_ALIVE = true;
    public static final int TEST_SO_LINGER = Short.MAX_VALUE;
    public static final int TEST_SO_TIMEOUT = 10;
    public static final int TEST_CONNECT_TIMEOUT = 90000;

    @Test
    public void testCreate() {
        TransportOptions options = new TransportOptions();

        assertEquals(TransportOptions.DEFAULT_TCP_NO_DELAY, options.isTcpNoDelay());
    }

    @Test
    public void testOptions() {
        TransportOptions options = createNonDefaultOptions();

        assertEquals(TEST_SEND_BUFFER_SIZE, options.getSendBufferSize());
        assertEquals(TEST_RECEIVE_BUFFER_SIZE, options.getReceiveBufferSize());
        assertEquals(TEST_TRAFFIC_CLASS, options.getTrafficClass());
        assertEquals(TEST_TCP_NO_DELAY, options.isTcpNoDelay());
        assertEquals(TEST_TCP_KEEP_ALIVE, options.isTcpKeepAlive());
        assertEquals(TEST_SO_LINGER, options.getSoLinger());
        assertEquals(TEST_SO_TIMEOUT, options.getSoTimeout());
        assertEquals(TEST_CONNECT_TIMEOUT, options.getConnectTimeout());
    }

    @Test
    public void testClone() {
        TransportOptions options = createNonDefaultOptions().clone();

        assertEquals(TEST_SEND_BUFFER_SIZE, options.getSendBufferSize());
        assertEquals(TEST_RECEIVE_BUFFER_SIZE, options.getReceiveBufferSize());
        assertEquals(TEST_TRAFFIC_CLASS, options.getTrafficClass());
        assertEquals(TEST_TCP_NO_DELAY, options.isTcpNoDelay());
        assertEquals(TEST_TCP_KEEP_ALIVE, options.isTcpKeepAlive());
        assertEquals(TEST_SO_LINGER, options.getSoLinger());
        assertEquals(TEST_SO_TIMEOUT, options.getSoTimeout());
        assertEquals(TEST_CONNECT_TIMEOUT, options.getConnectTimeout());
    }

    private TransportOptions createNonDefaultOptions() {
        TransportOptions options = new TransportOptions();

        options.setSendBufferSize(TEST_SEND_BUFFER_SIZE);
        options.setReceiveBufferSize(TEST_RECEIVE_BUFFER_SIZE);
        options.setTrafficClass(TEST_TRAFFIC_CLASS);
        options.setTcpNoDelay(TEST_TCP_NO_DELAY);
        options.setTcpKeepAlive(TEST_TCP_KEEP_ALIVE);
        options.setSoLinger(TEST_SO_LINGER);
        options.setSoTimeout(TEST_SO_TIMEOUT);
        options.setConnectTimeout(TEST_CONNECT_TIMEOUT);

        return options;
    }
}

@@ -882,16 +882,53 @@
 tEquals;
+%0Aimport static org.junit.Assert.fail;
 %0A%0Aimport
@@ -3109,24 +3109,1762 @@
 ());%0A    %7D%0A%0A
+    @Test%0A    public void testSendBufferSizeValidation() %7B%0A        TransportOptions options = createNonDefaultOptions().clone();%0A        try %7B%0A            options.setSendBufferSize(0);%0A            fail(%22Should have thrown an IllegalArgumentException%22);%0A        %7D catch (IllegalArgumentException expected) %7B%0A        %7D%0A        try %7B%0A            options.setSendBufferSize(-1);%0A            fail(%22Should have thrown an IllegalArgumentException%22);%0A        %7D catch (IllegalArgumentException expected) %7B%0A        %7D%0A%0A        options.setSendBufferSize(1);%0A    %7D%0A%0A    @Test%0A    public void testReceiveBufferSizeValidation() %7B%0A        TransportOptions options = createNonDefaultOptions().clone();%0A        try %7B%0A            options.setReceiveBufferSize(0);%0A            fail(%22Should have thrown an IllegalArgumentException%22);%0A        %7D catch (IllegalArgumentException expected) %7B%0A        %7D%0A        try %7B%0A            options.setReceiveBufferSize(-1);%0A            fail(%22Should have thrown an IllegalArgumentException%22);%0A        %7D catch (IllegalArgumentException expected) %7B%0A        %7D%0A%0A        options.setReceiveBufferSize(1);%0A    %7D%0A%0A    @Test%0A    public void testTrafficClassValidation() %7B%0A        TransportOptions options = createNonDefaultOptions().clone();%0A        try %7B%0A            options.setTrafficClass(-1);%0A            fail(%22Should have thrown an IllegalArgumentException%22);%0A        %7D catch (IllegalArgumentException expected) %7B%0A        %7D%0A        try %7B%0A            options.setTrafficClass(256);%0A            fail(%22Should have thrown an IllegalArgumentException%22);%0A        %7D catch (IllegalArgumentException expected) %7B%0A        %7D%0A%0A        options.setTrafficClass(0);%0A        options.setTrafficClass(128);%0A        options.setTrafficClass(255);%0A    %7D%0A%0A
     private 

Add tests for properties that require validation