package org.xbib.files.ftp.fs.test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.io.OutputStream;
import org.xbib.files.ftp.mock.fake.filesystem.FileEntry;

public class FTPFileSystemOutputStreamTest extends AbstractFTPFileSystemTest {

    @Test
    public void testWriteSingle() throws IOException {
        try (OutputStream output = getFileSystem().newOutputStream(createPath("/foo"))) {
            output.write('H');
            output.write('e');
            output.write('l');
            output.write('l');
            output.write('o');
        }
        FileEntry file = getFile("/foo");
        assertEquals("Hello", getStringContents(file));
    }

    @Test
    public void testWriteBulk() throws IOException {
        try (OutputStream output = getFileSystem().newOutputStream(createPath("/foo"))) {
            output.write("Hello".getBytes());
        }
        FileEntry file = getFile("/foo");
        assertEquals("Hello", getStringContents(file));
    }
}
