Skip to content

Commit

Permalink
Revert "Revert "Revert "Add unit tests for java.nio.channels.FileChan…
Browse files Browse the repository at this point in the history
…nel open methods"""

This reverts commit 7e36f38.

https://build.chromium.org/p/client.art/builders/mips64-emulator-debug/builds/12034/steps/steps/logs/stdio

Change-Id: Ic31fae25f197bc5aaf6d8980d5b2a215086c14c9
  • Loading branch information
Shubham Ajmera committed Nov 3, 2016
1 parent 7e36f38 commit 1a5d070
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 332 deletions.
5 changes: 2 additions & 3 deletions JavaLibrary.mk
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,7 @@ LOCAL_STATIC_JAVA_LIBRARIES := \
core-tests-support \
mockwebserver \
nist-pkix-tests \
sqlite-jdbc \
junit-params
sqlite-jdbc
LOCAL_JAVACFLAGS := $(local_javac_flags)
LOCAL_ERROR_PRONE_FLAGS := -Xep:TryFailThrowable:ERROR
LOCAL_JAVA_LANGUAGE_VERSION := 1.8
Expand Down Expand Up @@ -361,7 +360,7 @@ ifeq ($(LIBCORE_SKIP_TESTS),)
LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
LOCAL_NO_STANDARD_LIBRARIES := true
LOCAL_JAVA_LIBRARIES := core-oj-hostdex core-libart-hostdex okhttp-hostdex bouncycastle-hostdex core-junit-hostdex junit4-target-hostdex core-tests-support-hostdex mockito-api-hostdex
LOCAL_STATIC_JAVA_LIBRARIES := sqlite-jdbc-host mockwebserver-host nist-pkix-tests-host core-test-rules-hostdex junit-params-hostdex
LOCAL_STATIC_JAVA_LIBRARIES := sqlite-jdbc-host mockwebserver-host nist-pkix-tests-host core-test-rules-hostdex
LOCAL_JAVACFLAGS := $(local_javac_flags)
LOCAL_MODULE_TAGS := optional
LOCAL_JAVA_LANGUAGE_VERSION := 1.8
Expand Down
63 changes: 0 additions & 63 deletions luni/src/test/java/libcore/java/nio/channels/FileChannelTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,8 @@
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.file.FileSystem;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.nio.file.attribute.FileAttribute;
import java.nio.file.spi.FileSystemProvider;
import java.util.HashSet;
import java.util.Set;
import libcore.io.IoUtils;

import static java.nio.file.StandardOpenOption.READ;
import static java.nio.file.StandardOpenOption.WRITE;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public class FileChannelTest extends junit.framework.TestCase {
public void testReadOnlyByteArrays() throws Exception {
ByteBuffer readOnly = ByteBuffer.allocate(1).asReadOnlyBuffer();
Expand Down Expand Up @@ -267,55 +255,4 @@ private static FileChannel createFileContainingBytes(byte[] bytes) throws IOExce

return fc;
}

/**
* The test verifies that FileChannel#open(Path, Set<OpenOption>, FileAttribute ...) returns the
* same object returned by #newFileChannel(Path, Set<OpenOption>, FileAttribute ...) method
* in given Paths's FileSystemProvider.
*/
public void test_open_Path_Set_FileAttributes() throws IOException {
Path mockPath = mock(Path.class);
FileSystem mockFileSystem = mock(FileSystem.class);
FileSystemProvider mockFileSystemProvider = mock(FileSystemProvider.class);
FileChannel mockFileChannel = mock(FileChannel.class);

FileAttribute mockFileAttribute1 = mock(FileAttribute.class);
FileAttribute mockFileAttribute2 = mock(FileAttribute.class);

Set<StandardOpenOption> standardOpenOptions = new HashSet<>();
standardOpenOptions.add(READ);
standardOpenOptions.add(WRITE);

when(mockPath.getFileSystem()).thenReturn(mockFileSystem);
when(mockFileSystem.provider()).thenReturn(mockFileSystemProvider);
when(mockFileSystemProvider.newFileChannel(mockPath, standardOpenOptions,
mockFileAttribute1, mockFileAttribute2)).thenReturn(mockFileChannel);

assertEquals(mockFileChannel, FileChannel.open(mockPath, standardOpenOptions,
mockFileAttribute1, mockFileAttribute2));
}

/**
* The test verifies that FileChannel#open(Path, OpenOption ...) returns the
* same object returned by #newFileChannel(Path, OpenOption ...) method
* in given Paths's FileSystemProvider.
*/
public void test_open_Path_OpenOptions() throws IOException {

Path mockPath = mock(Path.class);
FileSystem mockFileSystem = mock(FileSystem.class);
FileSystemProvider mockFileSystemProvider = mock(FileSystemProvider.class);
FileChannel mockFileChannel = mock(FileChannel.class);

Set<StandardOpenOption> standardOpenOptions = new HashSet<>();
standardOpenOptions.add(READ);
standardOpenOptions.add(WRITE);

when(mockPath.getFileSystem()).thenReturn(mockFileSystem);
when(mockFileSystem.provider()).thenReturn(mockFileSystemProvider);
when(mockFileSystemProvider.newFileChannel(mockPath, standardOpenOptions))
.thenReturn(mockFileChannel);

assertEquals(mockFileChannel, FileChannel.open(mockPath, READ, WRITE));
}
}
Loading

0 comments on commit 1a5d070

Please sign in to comment.