@@ -0,0 +1,1799 @@
+/*%0A * The Alluxio Open Foundation licenses this work under the Apache License, version 2.0%0A * (the %22License%22). You may not use this work except in compliance with the License, which is%0A * available at www.apache.org/licenses/LICENSE-2.0%0A *%0A * This software is distributed on an %22AS IS%22 basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,%0A * either express or implied, as more fully set forth in the License.%0A *%0A * See the NOTICE file distributed with this work for information regarding copyright ownership.%0A */%0A%0Apackage alluxio.client.block.stream;%0A%0Aimport java.io.IOException;%0Aimport java.nio.ByteBuffer;%0Aimport java.util.Arrays;%0A%0A/**%0A * Test class for mocking %7B@link UnderFileSystemFileOutStream%7D and exposing internal state.%0A */%0Apublic class TestUnderFileSystemFileOutStream extends UnderFileSystemFileOutStream %7B%0A  private final ByteBuffer mData;%0A  private boolean mClosed;%0A  private boolean mCanceled;%0A%0A  /**%0A   * Constructs a new %7B@link TestUnderFileSystemFileOutStream%7D to be used in tests.%0A   *%0A   * @param data the data to test%0A   */%0A  public TestUnderFileSystemFileOutStream(ByteBuffer data) %7B%0A    super(new TestPacketWriter(data));%0A    mData = data;%0A    mClosed = false;%0A    mCanceled = false;%0A  %7D%0A%0A  public byte%5B%5D getWrittenData() %7B%0A    try %7B%0A      super.flush();%0A    %7D catch (IOException e) %7B%0A      throw new RuntimeException(e);%0A    %7D%0A    return Arrays.copyOfRange(mData.array(), 0, mData.position());%0A  %7D%0A%0A  public boolean isClosed() %7B%0A    return mClosed;%0A  %7D%0A%0A  public boolean isCanceled() %7B%0A    return mCanceled;%0A  %7D%0A%0A  @Override%0A  public void close() throws IOException %7B%0A    super.close();%0A    mClosed = true;%0A  %7D%0A%0A  @Override%0A  public void cancel() throws IOException %7B%0A    if (mClosed) %7B%0A      return;%0A    %7D%0A    super.cancel();%0A    mCanceled = true;%0A    mClosed = true;%0A  %7D%0A%7D%0A

Add a test file