|
ActiveMQ example source code file (SslTransportFactoryTest.java)
The ActiveMQ SslTransportFactoryTest.java source code/** * 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.activemq.transport.tcp; import java.io.IOException; import java.net.URI; import java.util.HashMap; import java.util.Map; import junit.framework.TestCase; import org.apache.activemq.openwire.OpenWireFormat; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class SslTransportFactoryTest extends TestCase { private static final Logger LOG = LoggerFactory.getLogger(SslTransportFactoryTest.class); private SslTransportFactory factory; private boolean verbose; protected void setUp() throws Exception { factory = new SslTransportFactory(); } protected void tearDown() throws Exception { super.tearDown(); } public void testBindServerOptions() throws IOException { SslTransportServer sslTransportServer = null; for (int i = 0; i < 4; ++i) { final boolean wantClientAuth = (i & 0x1) == 1; final boolean needClientAuth = (i & 0x2) == 1; String options = "wantClientAuth=" + (wantClientAuth ? "true" : "false") + "&needClientAuth=" + (needClientAuth ? "true" : "false"); try { sslTransportServer = (SslTransportServer)factory.doBind(new URI( "ssl://localhost:61616?" + options)); } catch (Exception e) { fail("Unable to bind to address: " + e.getMessage()); } assertEquals("Created ServerSocket did not have correct wantClientAuth status.", sslTransportServer.getWantClientAuth(), wantClientAuth); assertEquals("Created ServerSocket did not have correct needClientAuth status.", sslTransportServer.getNeedClientAuth(), needClientAuth); try { sslTransportServer.stop(); } catch (Exception e) { fail("Unable to stop TransportServer: " + e.getMessage()); } } } private int getMthNaryDigit(int number, int digitIdx, int numBase) { return (number / ((int)Math.pow(numBase, digitIdx))) % numBase; } public void testCompositeConfigure() throws IOException { // The 5 options being tested. int optionSettings[] = new int[5]; String optionNames[] = {"wantClientAuth", "needClientAuth", "socket.wantClientAuth", "socket.needClientAuth", "socket.useClientMode"}; // Using a trinary interpretation of i to set all possible values of // stub options for socket and transport. // 2 transport options, 3 socket options, 3 settings for each option => // 3^5 = 243 combos. for (int i = 0; i < 243; ++i) { Map<String, String> options = new HashMap Other ActiveMQ examples (source code examples)Here is a short list of links related to this ActiveMQ SslTransportFactoryTest.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.