// Path: tftp-protocol/src/test/java/org/anarres/tftp/protocol/engine/TftpServerTester.java
// public class TftpServerTester {
// 
//     private static final Random RANDOM = new Random();
//     private final TftpMemoryDataProvider provider = new TftpMemoryDataProvider();
//     private final TFTPClient client = new TFTPClient();
// 
//     @Nonnull
//     public TftpMemoryDataProvider getProvider() {
//         return provider;
//     }
// 
//     @Nonnegative
//     public int getPort() {
//         return 1067;
//     }
// 
//     private void assertSucceeds(String path, int mode) throws Exception {
//         ByteArrayOutputStream out = new ByteArrayOutputStream();
//         client.receiveFile(path, mode, out, InetAddress.getLoopbackAddress(), getPort());
//         assertArrayEquals(provider.getData(path), out.toByteArray());
//     }
// 
//     private void assertFails(String path, int mode) throws Exception {
//         try {
//             client.receiveFile(path, mode, ByteStreams.nullOutputStream(), InetAddress.getLoopbackAddress(), getPort());
//             fail("Receive file " + path + "/" + mode + " succeeded unexpectedly.");
//         } catch (IOException e) {
//         }
//     }
// 
//     @Nonnull
//     public static byte[] newRandomBytes(int length) {
//         byte[] data = new byte[length];
//         RANDOM.nextBytes(data);
//         return data;
//     }
// 
//     public void run() throws Exception {
//         client.open();
// 
//         provider.setData("/hello", "Hello, world.");
// 
//         assertFails("/nonexistent", TFTPClient.BINARY_MODE);
//         assertFails("/nonexistent", TFTPClient.ASCII_MODE);
// 
//         assertSucceeds("/hello", TFTPClient.BINARY_MODE);
//         assertSucceeds("/hello", TFTPClient.ASCII_MODE);
// 
//         int[] sizes = new int[]{
//             0,
//             1,
//             8,
//             511,
//             512,
//             513,
//             1 * 1024 - 1,
//             1 * 1024,
//             1 * 1024 + 1,
//             4 * 1024 - 1,
//             4 * 1024,
//             4 * 1024 + 1,
//             1024 * 1024 - 1,
//             1024 * 1024,
//             1024 * 1024 + 1
//         };
// 
//         for (int size : sizes) {
//             byte[] data = newRandomBytes(size);
//             provider.setData("/binary", data);
//             assertSucceeds("/binary", TFTPClient.BINARY_MODE);
// 
//             provider.setData("/ascii", Base64.encodeBase64(data));
//             assertSucceeds("/ascii", TFTPClient.ASCII_MODE);
//         }
// 
//         client.close();
// 
//     }
// }


import org.junit.Before;
import org.junit.Test;
import io.netty.util.ResourceLeakDetector;
import org.anarres.tftp.protocol.engine.TftpServerTester;
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.anarres.tftp.server.netty;


/**
 *
 * @author shevek
 */
public class TftpServerTest {

    @Before
    public void setUp() {
        ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.PARANOID);
    }

    @Test
    public void testServer() throws Exception {
// Path: tftp-protocol/src/test/java/org/anarres/tftp/protocol/engine/TftpServerTester.java
// public class TftpServerTester {
// 
//     private static final Random RANDOM = new Random();
//     private final TftpMemoryDataProvider provider = new TftpMemoryDataProvider();
//     private final TFTPClient client = new TFTPClient();
// 
//     @Nonnull
//     public TftpMemoryDataProvider getProvider() {
//         return provider;
//     }
// 
//     @Nonnegative
//     public int getPort() {
//         return 1067;
//     }
// 
//     private void assertSucceeds(String path, int mode) throws Exception {
//         ByteArrayOutputStream out = new ByteArrayOutputStream();
//         client.receiveFile(path, mode, out, InetAddress.getLoopbackAddress(), getPort());
//         assertArrayEquals(provider.getData(path), out.toByteArray());
//     }
// 
//     private void assertFails(String path, int mode) throws Exception {
//         try {
//             client.receiveFile(path, mode, ByteStreams.nullOutputStream(), InetAddress.getLoopbackAddress(), getPort());
//             fail("Receive file " + path + "/" + mode + " succeeded unexpectedly.");
//         } catch (IOException e) {
//         }
//     }
// 
//     @Nonnull
//     public static byte[] newRandomBytes(int length) {
//         byte[] data = new byte[length];
//         RANDOM.nextBytes(data);
//         return data;
//     }
// 
//     public void run() throws Exception {
//         client.open();
// 
//         provider.setData("/hello", "Hello, world.");
// 
//         assertFails("/nonexistent", TFTPClient.BINARY_MODE);
//         assertFails("/nonexistent", TFTPClient.ASCII_MODE);
// 
//         assertSucceeds("/hello", TFTPClient.BINARY_MODE);
//         assertSucceeds("/hello", TFTPClient.ASCII_MODE);
// 
//         int[] sizes = new int[]{
//             0,
//             1,
//             8,
//             511,
//             512,
//             513,
//             1 * 1024 - 1,
//             1 * 1024,
//             1 * 1024 + 1,
//             4 * 1024 - 1,
//             4 * 1024,
//             4 * 1024 + 1,
//             1024 * 1024 - 1,
//             1024 * 1024,
//             1024 * 1024 + 1
//         };
// 
//         for (int size : sizes) {
//             byte[] data = newRandomBytes(size);
//             provider.setData("/binary", data);
//             assertSucceeds("/binary", TFTPClient.BINARY_MODE);
// 
//             provider.setData("/ascii", Base64.encodeBase64(data));
//             assertSucceeds("/ascii", TFTPClient.ASCII_MODE);
//         }
// 
//         client.close();
// 
//     }
// }


// Path: tftp-server-netty/src/test/java/org/anarres/tftp/server/netty/TftpServerTest.java
import org.junit.Before;
import org.junit.Test;
import io.netty.util.ResourceLeakDetector;
import org.anarres.tftp.protocol.engine.TftpServerTester;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.anarres.tftp.server.netty;


/**
 *
 * @author shevek
 */
public class TftpServerTest {

    @Before
    public void setUp() {
        ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.PARANOID);
    }

    @Test
    public void testServer() throws Exception {
        TftpServerTester tester = new TftpServerTester();