// Path: src/main/java/org/cleverframe/fastdfs/conn/Connection.java
// public interface Connection extends Closeable {
//     /**
//      * 关闭连接
//      */
//     @Override
//     void close();
// 
//     /**
//      * 连接是否关闭
//      *
//      * @return 返回true表示连接关闭
//      */
//     boolean isClosed();
// 
//     /**
//      * 测试连接是否有效
//      *
//      * @return 返回true表示连接无效
//      */
//     boolean isValid();
// 
//     /**
//      * 获取输出流
//      *
//      * @return 输出流
//      * @throws IOException 操作异常
//      */
//     OutputStream getOutputStream() throws IOException;
// 
//     /**
//      * 获取输入流
//      *
//      * @return 输入流
//      * @throws IOException 获取输入流错误
//      */
//     InputStream getInputStream() throws IOException;
// 
//     /**
//      * 获取字符集
//      *
//      * @return 字符集
//      */
//     Charset getCharset();
// }
// 
// Path: src/main/java/org/cleverframe/fastdfs/protocol/storage/callback/DownloadFileWriter.java
// public class DownloadFileWriter implements DownloadCallback<String> {
// 
//     /**
//      * 文件名称
//      */
//     private String fileName;
// 
//     public DownloadFileWriter(String fileName) {
//         this.fileName = fileName;
//     }
// 
//     /**
//      * 文件下载处理
//      *
//      * @return 返回文件名称
//      */
//     @Override
//     public String receive(InputStream inputStream) throws IOException {
//         FileOutputStream out = null;
//         InputStream in = null;
//         try {
//             out = new FileOutputStream(fileName);
//             in = new BufferedInputStream(inputStream);
//             // 通过ioutil 对接输入输出流，实现文件下载
//             IOUtils.copy(in, out);
//             out.flush();
//         } finally {
//             // 关闭流
//             IOUtils.closeQuietly(in);
//             IOUtils.closeQuietly(out);
//         }
//         return fileName;
//     }
// }
// 
// Path: src/test/java/org/cleverframe/fastdfs/protocol/tracker/GetGroupListCommandTest.java
// public class GetGroupListCommandTest {
//     /**
//      * 日志
//      */
//     private static final Logger logger = LoggerFactory.getLogger(GetGroupListCommandTest.class);
// 
//     @Test
//     public void test01() {
//         Connection connection = GetTrackerConnection.getDefaultConnection();
//         try {
//             GetGroupListCommand command = new GetGroupListCommand();
//             List<GroupState> list = command.execute(connection);
//             for (GroupState groupState : list) {
//                 logger.debug(groupState.toString());
//             }
//         } finally {
//             connection.close();
//         }
//     }
// }
// 
// Path: src/test/java/org/cleverframe/fastdfs/testbase/GetStorageConnection.java
// public class GetStorageConnection {
//     private static final InetSocketAddress address = new InetSocketAddress("192.168.10.128", 23000);
//     private static final int soTimeout = 1500;
//     private static final int connectTimeout = 600;
//     private static final Charset charset = Charset.forName("UTF-8");
// 
//     public static Connection getDefaultConnection() {
//         return new SocketConnection(address, soTimeout, connectTimeout, charset);
//     }
// }


import org.cleverframe.fastdfs.conn.Connection;
import org.cleverframe.fastdfs.protocol.storage.callback.DownloadFileWriter;
import org.cleverframe.fastdfs.protocol.tracker.GetGroupListCommandTest;
import org.cleverframe.fastdfs.testbase.GetStorageConnection;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
package org.cleverframe.fastdfs.protocol.storage;



/**
 * 作者：LiZW <br/>
 * 创建时间：2016/11/20 16:15 <br/>
 */
public class DownloadFileCommandTest {
    /**
     * 日志
     */
    private static final Logger logger = LoggerFactory.getLogger(GetGroupListCommandTest.class);

    @Test
    public void test01() {
// Path: src/main/java/org/cleverframe/fastdfs/conn/Connection.java
// public interface Connection extends Closeable {
//     /**
//      * 关闭连接
//      */
//     @Override
//     void close();
// 
//     /**
//      * 连接是否关闭
//      *
//      * @return 返回true表示连接关闭
//      */
//     boolean isClosed();
// 
//     /**
//      * 测试连接是否有效
//      *
//      * @return 返回true表示连接无效
//      */
//     boolean isValid();
// 
//     /**
//      * 获取输出流
//      *
//      * @return 输出流
//      * @throws IOException 操作异常
//      */
//     OutputStream getOutputStream() throws IOException;
// 
//     /**
//      * 获取输入流
//      *
//      * @return 输入流
//      * @throws IOException 获取输入流错误
//      */
//     InputStream getInputStream() throws IOException;
// 
//     /**
//      * 获取字符集
//      *
//      * @return 字符集
//      */
//     Charset getCharset();
// }
// 
// Path: src/main/java/org/cleverframe/fastdfs/protocol/storage/callback/DownloadFileWriter.java
// public class DownloadFileWriter implements DownloadCallback<String> {
// 
//     /**
//      * 文件名称
//      */
//     private String fileName;
// 
//     public DownloadFileWriter(String fileName) {
//         this.fileName = fileName;
//     }
// 
//     /**
//      * 文件下载处理
//      *
//      * @return 返回文件名称
//      */
//     @Override
//     public String receive(InputStream inputStream) throws IOException {
//         FileOutputStream out = null;
//         InputStream in = null;
//         try {
//             out = new FileOutputStream(fileName);
//             in = new BufferedInputStream(inputStream);
//             // 通过ioutil 对接输入输出流，实现文件下载
//             IOUtils.copy(in, out);
//             out.flush();
//         } finally {
//             // 关闭流
//             IOUtils.closeQuietly(in);
//             IOUtils.closeQuietly(out);
//         }
//         return fileName;
//     }
// }
// 
// Path: src/test/java/org/cleverframe/fastdfs/protocol/tracker/GetGroupListCommandTest.java
// public class GetGroupListCommandTest {
//     /**
//      * 日志
//      */
//     private static final Logger logger = LoggerFactory.getLogger(GetGroupListCommandTest.class);
// 
//     @Test
//     public void test01() {
//         Connection connection = GetTrackerConnection.getDefaultConnection();
//         try {
//             GetGroupListCommand command = new GetGroupListCommand();
//             List<GroupState> list = command.execute(connection);
//             for (GroupState groupState : list) {
//                 logger.debug(groupState.toString());
//             }
//         } finally {
//             connection.close();
//         }
//     }
// }
// 
// Path: src/test/java/org/cleverframe/fastdfs/testbase/GetStorageConnection.java
// public class GetStorageConnection {
//     private static final InetSocketAddress address = new InetSocketAddress("192.168.10.128", 23000);
//     private static final int soTimeout = 1500;
//     private static final int connectTimeout = 600;
//     private static final Charset charset = Charset.forName("UTF-8");
// 
//     public static Connection getDefaultConnection() {
//         return new SocketConnection(address, soTimeout, connectTimeout, charset);
//     }
// }


// Path: src/test/java/org/cleverframe/fastdfs/protocol/storage/DownloadFileCommandTest.java
import org.cleverframe.fastdfs.conn.Connection;
import org.cleverframe.fastdfs.protocol.storage.callback.DownloadFileWriter;
import org.cleverframe.fastdfs.protocol.tracker.GetGroupListCommandTest;
import org.cleverframe.fastdfs.testbase.GetStorageConnection;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.ArrayList;
import java.util.List;

package org.cleverframe.fastdfs.protocol.storage;



/**
 * 作者：LiZW <br/>
 * 创建时间：2016/11/20 16:15 <br/>
 */
public class DownloadFileCommandTest {
    /**
     * 日志
     */
    private static final Logger logger = LoggerFactory.getLogger(GetGroupListCommandTest.class);

    @Test
    public void test01() {
        Connection connection = GetStorageConnection.getDefaultConnection();