// Path: src/test/java/org/apache/sshd/util/test/JSchLogger.java
// public class JSchLogger implements Logger {
//     private final org.slf4j.Logger log = LoggerFactory.getLogger(JSch.class);
// 
//     public JSchLogger() {
//         super();
//     }
// 
//     @Override
//     public boolean isEnabled(int level) {
//         switch (level) {
//             case INFO:  // INFO is too "chatty" so we map it to debug
//             case DEBUG:
//                 return log.isDebugEnabled();
//             case WARN:
//                 return log.isWarnEnabled();
//             case ERROR:
//                 return log.isErrorEnabled();
//             case FATAL:
//                 return log.isErrorEnabled();
//             default:
//                 return false;
//         }
//     }
// 
//     @Override
//     public void log(int level, String message) {
//         switch (level) {
//             case INFO:  // INFO is too "chatty" so we map it to debug
//             case DEBUG:
//                 log.debug(message);
//                 break;
//             case WARN:
//                 log.warn(message);
//                 break;
//             case ERROR:
//             case FATAL:
//                 log.error(message);
//                 break;
//             default:
//                 log.error("[LEVEL=" + level + "]: " + message);
//         }
//     }
// 
//     public static void init() {
//         JSch.setLogger(new JSchLogger());
//     }
// }
// 
// Path: src/test/java/org/apache/sshd/util/test/OutputCountTrackingOutputStream.java
// public class OutputCountTrackingOutputStream extends FilterOutputStream {
//     protected long writeCount;
// 
//     public OutputCountTrackingOutputStream(OutputStream out) {
//         super(out);
//     }
// 
//     @Override
//     public void write(int b) throws IOException {
//         out.write(b);
//         updateWriteCount(1L);
//     }
// 
//     @Override
//     public void write(byte[] b, int off, int len) throws IOException {
//         out.write(b, off, len); // don't call super since it calls the single 'write'
//         updateWriteCount(len);
//     }
// 
//     public long getWriteCount() {
//         return writeCount;
//     }
// 
//     protected long updateWriteCount(long delta) {
//         writeCount += delta;
//         return writeCount;
//     }
// }


import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.EnumSet;
import java.util.List;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import com.jcraft.jsch.JSch;
import org.apache.sshd.client.SshClient;
import org.apache.sshd.client.channel.ChannelShell;
import org.apache.sshd.client.channel.ClientChannel;
import org.apache.sshd.client.channel.ClientChannelEvent;
import org.apache.sshd.client.session.ClientSession;
import org.apache.sshd.common.FactoryManager;
import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.PropertyResolverUtils;
import org.apache.sshd.common.channel.Channel;
import org.apache.sshd.common.cipher.BuiltinCiphers;
import org.apache.sshd.common.future.KeyExchangeFuture;
import org.apache.sshd.common.kex.BuiltinDHFactories;
import org.apache.sshd.common.kex.KeyExchange;
import org.apache.sshd.common.session.Session;
import org.apache.sshd.common.session.SessionListener;
import org.apache.sshd.common.subsystem.sftp.SftpConstants;
import org.apache.sshd.common.util.SecurityUtils;
import org.apache.sshd.common.util.io.NullOutputStream;
import org.apache.sshd.server.SshServer;
import org.apache.sshd.util.test.BaseTestSupport;
import org.apache.sshd.util.test.JSchLogger;
import org.apache.sshd.util.test.OutputCountTrackingOutputStream;
import org.apache.sshd.util.test.SimpleUserInfo;
import org.apache.sshd.util.test.TeeOutputStream;
import org.junit.After;
import org.junit.Assume;
import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
/*
 * 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.sshd;




/**
 * Test key exchange algorithms.
 *
 * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
 */
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class KeyReExchangeTest extends BaseTestSupport {

    private SshServer sshd;
    private int port;

    public KeyReExchangeTest() {
        super();
    }

    @BeforeClass
    public static void jschInit() {
// Path: src/test/java/org/apache/sshd/util/test/JSchLogger.java
// public class JSchLogger implements Logger {
//     private final org.slf4j.Logger log = LoggerFactory.getLogger(JSch.class);
// 
//     public JSchLogger() {
//         super();
//     }
// 
//     @Override
//     public boolean isEnabled(int level) {
//         switch (level) {
//             case INFO:  // INFO is too "chatty" so we map it to debug
//             case DEBUG:
//                 return log.isDebugEnabled();
//             case WARN:
//                 return log.isWarnEnabled();
//             case ERROR:
//                 return log.isErrorEnabled();
//             case FATAL:
//                 return log.isErrorEnabled();
//             default:
//                 return false;
//         }
//     }
// 
//     @Override
//     public void log(int level, String message) {
//         switch (level) {
//             case INFO:  // INFO is too "chatty" so we map it to debug
//             case DEBUG:
//                 log.debug(message);
//                 break;
//             case WARN:
//                 log.warn(message);
//                 break;
//             case ERROR:
//             case FATAL:
//                 log.error(message);
//                 break;
//             default:
//                 log.error("[LEVEL=" + level + "]: " + message);
//         }
//     }
// 
//     public static void init() {
//         JSch.setLogger(new JSchLogger());
//     }
// }
// 
// Path: src/test/java/org/apache/sshd/util/test/OutputCountTrackingOutputStream.java
// public class OutputCountTrackingOutputStream extends FilterOutputStream {
//     protected long writeCount;
// 
//     public OutputCountTrackingOutputStream(OutputStream out) {
//         super(out);
//     }
// 
//     @Override
//     public void write(int b) throws IOException {
//         out.write(b);
//         updateWriteCount(1L);
//     }
// 
//     @Override
//     public void write(byte[] b, int off, int len) throws IOException {
//         out.write(b, off, len); // don't call super since it calls the single 'write'
//         updateWriteCount(len);
//     }
// 
//     public long getWriteCount() {
//         return writeCount;
//     }
// 
//     protected long updateWriteCount(long delta) {
//         writeCount += delta;
//         return writeCount;
//     }
// }


// Path: src/test/java/org/apache/sshd/KeyReExchangeTest.java
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.EnumSet;
import java.util.List;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import com.jcraft.jsch.JSch;
import org.apache.sshd.client.SshClient;
import org.apache.sshd.client.channel.ChannelShell;
import org.apache.sshd.client.channel.ClientChannel;
import org.apache.sshd.client.channel.ClientChannelEvent;
import org.apache.sshd.client.session.ClientSession;
import org.apache.sshd.common.FactoryManager;
import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.PropertyResolverUtils;
import org.apache.sshd.common.channel.Channel;
import org.apache.sshd.common.cipher.BuiltinCiphers;
import org.apache.sshd.common.future.KeyExchangeFuture;
import org.apache.sshd.common.kex.BuiltinDHFactories;
import org.apache.sshd.common.kex.KeyExchange;
import org.apache.sshd.common.session.Session;
import org.apache.sshd.common.session.SessionListener;
import org.apache.sshd.common.subsystem.sftp.SftpConstants;
import org.apache.sshd.common.util.SecurityUtils;
import org.apache.sshd.common.util.io.NullOutputStream;
import org.apache.sshd.server.SshServer;
import org.apache.sshd.util.test.BaseTestSupport;
import org.apache.sshd.util.test.JSchLogger;
import org.apache.sshd.util.test.OutputCountTrackingOutputStream;
import org.apache.sshd.util.test.SimpleUserInfo;
import org.apache.sshd.util.test.TeeOutputStream;
import org.junit.After;
import org.junit.Assume;
import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;

/*
 * 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.sshd;




/**
 * Test key exchange algorithms.
 *
 * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
 */
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class KeyReExchangeTest extends BaseTestSupport {

    private SshServer sshd;
    private int port;

    public KeyReExchangeTest() {
        super();
    }

    @BeforeClass
    public static void jschInit() {
        JSchLogger.init();