diff options
| author | Alex Rudyy <orudyy@apache.org> | 2013-06-21 17:06:57 +0000 |
|---|---|---|
| committer | Alex Rudyy <orudyy@apache.org> | 2013-06-21 17:06:57 +0000 |
| commit | e409124b9f3a7423fe4ab04e7ce3e446244d04e3 (patch) | |
| tree | 95eb9be13518f19536314f7c0993fe40d84c70c9 /qpid/java/client/src/test | |
| parent | 8bdb080ef1f4afb1727dc3fc5f2666bdfd982107 (diff) | |
| download | qpid-python-e409124b9f3a7423fe4ab04e7ce3e446244d04e3.tar.gz | |
QPID-4943: Introduce a feature for 0-8/0-9/0-9-1 protocols to close a connection on receiving a mandatory unroutable message in a transacted session
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1495511 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/client/src/test')
| -rw-r--r-- | qpid/java/client/src/test/java/org/apache/qpid/client/handler/CloseWhenNoRouteSettingsHelperTest.java | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/qpid/java/client/src/test/java/org/apache/qpid/client/handler/CloseWhenNoRouteSettingsHelperTest.java b/qpid/java/client/src/test/java/org/apache/qpid/client/handler/CloseWhenNoRouteSettingsHelperTest.java new file mode 100644 index 0000000000..f1d7a76c75 --- /dev/null +++ b/qpid/java/client/src/test/java/org/apache/qpid/client/handler/CloseWhenNoRouteSettingsHelperTest.java @@ -0,0 +1,77 @@ +/* + * 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.client.handler; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import org.apache.qpid.framing.FieldTable; +import org.apache.qpid.jms.ConnectionURL; +import org.apache.qpid.properties.ConnectionStartProperties; +import org.apache.qpid.test.utils.QpidTestCase; + +public class CloseWhenNoRouteSettingsHelperTest extends QpidTestCase +{ + private static final String FALSE_STR = Boolean.toString(false); + private static final String TRUE_STR = Boolean.toString(true); + + private final CloseWhenNoRouteSettingsHelper _closeWhenNoRouteSettingsHelper = new CloseWhenNoRouteSettingsHelper(); + + public void testCloseWhenNoRouteNegotiation() + { + test("Nothing should be set if option not in URL", + null, + true, + null); + test("Client should disable broker's enabled option", + FALSE_STR, + true, + false); + test("Client should be able to disable broker's enabled option", + TRUE_STR, + false, + true); + test("Client should not enable option if unsupported by broker", + TRUE_STR, + null, + null); + test("Malformed client option should evaluate to false", + "malformed boolean", + true, + false); + } + + private void test(String message, String urlOption, Boolean serverOption, Boolean expectedClientProperty) + { + ConnectionURL url = mock(ConnectionURL.class); + when(url.getOption(ConnectionURL.OPTIONS_CLOSE_WHEN_NO_ROUTE)).thenReturn(urlOption); + + FieldTable serverProperties = new FieldTable(); + if(serverOption != null) + { + serverProperties.setBoolean(ConnectionStartProperties.QPID_CLOSE_WHEN_NO_ROUTE, serverOption); + } + + FieldTable clientProperties = new FieldTable(); + + _closeWhenNoRouteSettingsHelper.setClientProperties(clientProperties, url, serverProperties); + + assertEquals(message, expectedClientProperty, clientProperties.getBoolean(ConnectionStartProperties.QPID_CLOSE_WHEN_NO_ROUTE)); + } +} |
