-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
test/src/main/scala/com/amadeus/dataio/test/FileSystemSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.amadeus.dataio.test | ||
|
||
import org.apache.hadoop.conf.Configuration | ||
import org.apache.hadoop.fs.{FileSystem, Path} | ||
import org.scalatest.{BeforeAndAfter, TestSuite} | ||
|
||
/** | ||
* Provides the Hadoop LocalFileSystem for tests needing direct access to an instance of FileSystem. | ||
* | ||
* Provides a dedicated instance initialized before each test and automatically closed after each test, providing as | ||
* much isolation as possible between tests. It also deletes the dataio-test temporary directory (/tmp/dataio-test/) and | ||
* sub-directories, before closing the FileSystem. | ||
* | ||
* e.g. | ||
* {{{ | ||
* class MyClassTest extends WordSpec with FileSystemSpec{ | ||
* // provided by FileSystemSpec: | ||
* // fs: FileSystem | ||
* // val tmpPath: String = "file:///tmp/dataio-test/" | ||
* } | ||
* }}} | ||
*/ | ||
trait FileSystemSpec extends TestSuite with BeforeAndAfter { | ||
val tmpPath = "file:///tmp/dataio-test/" | ||
|
||
var fs: FileSystem = _ | ||
|
||
before { | ||
fs = FileSystem.newInstance(new Configuration()) | ||
} | ||
|
||
after { | ||
fs.delete(new Path(tmpPath), true) | ||
fs.close() | ||
} | ||
} |