/*
 * Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 *  http://aws.amazon.com/apache2.0
 *
 * or in the "license" file accompanying this file. This file 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 software.amazon.awssdk.core.async;

import org.reactivestreams.Publisher;
import org.reactivestreams.tck.TestEnvironment;

import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;

public class FileAsyncRequestPublisherTckTest extends org.reactivestreams.tck.PublisherVerification<ByteBuffer> {

    final File example = File.createTempFile("example", ".tmp");
    final File fileDoesNotExist = new File(example.getPath() + "-does-not-exist");

    public FileAsyncRequestPublisherTckTest() throws IOException {
        super(new TestEnvironment());
    }

    @Override
    public Publisher<ByteBuffer> createPublisher(long l) {
        return AsyncRequestProvider.fromFile(example.toPath());
    }

    @Override
    public Publisher<ByteBuffer> createFailedPublisher() {
        return AsyncRequestProvider.fromFile(fileDoesNotExist.toPath());
    }
}

@@ -623,16 +623,39 @@
 async;%0A%0A
+import org.junit.Test;%0A
 import o
@@ -715,105 +715,528 @@
 ams.
-tck.TestEnvironment;%0A%0Aimport java.io.File;%0Aimport java.io.IOException;%0Aimport java.nio.ByteBuffer
+Subscriber;%0Aimport org.reactivestreams.tck.TestEnvironment;%0Aimport software.amazon.awssdk.http.async.SimpleSubscriber;%0A%0Aimport java.io.BufferedWriter;%0Aimport java.io.File;%0Aimport java.io.FileWriter;%0Aimport java.io.IOException;%0Aimport java.nio.ByteBuffer;%0Aimport java.nio.charset.StandardCharsets;%0Aimport java.nio.file.FileSystem;%0Aimport java.nio.file.Files;%0Aimport java.nio.file.Paths;%0A%0Aimport static org.assertj.core.api.Assertions.assertThat;%0Aimport static org.mockito.Matchers.any;%0Aimport static org.mockito.Mockito.*
 ;%0A%0Ap
@@ -1598,24 +1598,345 @@
 ironment());
+%0A%0A        BufferedWriter writer = new BufferedWriter(new FileWriter(example));%0A        writer.write(%22Hello world%5Cn%22);%0A        writer.write(%22Hello world%5Cn%22);%0A        writer.write(%22Hello world%5Cn%22);%0A        writer.write(%22Hello world%5Cn%22);%0A        writer.write(%22Hello world%5Cn%22);%0A        writer.flush();%0A        writer.close();
 %0A    %7D%0A%0A    

include sample content in test file, FIXME: these should use a virtual filesystem