Package org.iplass.mtp.test
Class TestUploadFileHandle
java.lang.Object
org.iplass.mtp.test.TestUploadFileHandle
- All Implemented Interfaces:
UploadFileHandle
public class TestUploadFileHandle extends java.lang.Object implements UploadFileHandle
テスト時に利用可能なUploadFileHandleの実装です。
アップロードファイルを伴うテストの場合に、
TestRequestContext.setParam(String, Object)にてセットします。-
Constructor Summary
Constructors Constructor Description TestUploadFileHandle(java.io.File tempFile, java.lang.String fileName, java.lang.String type)指定のtempFileで指定されるファイルにてTestUploadFileHandleを生成します。TestUploadFileHandle(java.lang.String fileName, java.lang.String type, long size, boolean isSizeOver)アップロードされたファイルがサイズオーバーであった場合を想定したテストの場合、当コンストラクタを利用し、 isSizeOverがtrueの状態のUploadFileHandleを生成することが可能です。 -
Method Summary
Modifier and Type Method Description java.nio.file.PathcopyTo(java.nio.file.Path target, java.nio.file.CopyOption... options)アップロードされたファイルを指定のtargetへコピーする。java.lang.StringgetFileName()java.io.InputStreamgetInputStream()アップロードされたファイルのバイナリを読み込むためのInputStreamを取得。longgetSize()java.lang.StringgetType()booleanisSizeOver()アップロードされたファイルのファイルサイズが上限値を超えていた場合true。java.nio.file.PathmoveTo(java.nio.file.Path target, java.nio.file.CopyOption... options)アップロードされたファイルを指定のtargetへ移動する。BinaryReferencetoBinaryReference()アップロードされたファイルをBinaryReferenceのインスタンスに変換。 変換されたBinaryReferenceはEntityの属性として保存されるまでは、 テンポラリLOBとしてアップロードしたユーザーのみが参照可能な状態。
-
Constructor Details
-
TestUploadFileHandle
public TestUploadFileHandle(java.io.File tempFile, java.lang.String fileName, java.lang.String type)指定のtempFileで指定されるファイルにてTestUploadFileHandleを生成します。- Parameters:
tempFile-fileName-type-
-
TestUploadFileHandle
public TestUploadFileHandle(java.lang.String fileName, java.lang.String type, long size, boolean isSizeOver)アップロードされたファイルがサイズオーバーであった場合を想定したテストの場合、当コンストラクタを利用し、 isSizeOverがtrueの状態のUploadFileHandleを生成することが可能です。- Parameters:
fileName-type-size-isSizeOver-
-
-
Method Details
-
getFileName
public java.lang.String getFileName()- Specified by:
getFileNamein interfaceUploadFileHandle
-
getType
public java.lang.String getType()- Specified by:
getTypein interfaceUploadFileHandle
-
toBinaryReference
Description copied from interface:UploadFileHandleアップロードされたファイルをBinaryReferenceのインスタンスに変換。 変換されたBinaryReferenceはEntityの属性として保存されるまでは、 テンポラリLOBとしてアップロードしたユーザーのみが参照可能な状態。- Specified by:
toBinaryReferencein interfaceUploadFileHandle- Returns:
-
getSize
public long getSize()- Specified by:
getSizein interfaceUploadFileHandle
-
getInputStream
public java.io.InputStream getInputStream()Description copied from interface:UploadFileHandleアップロードされたファイルのバイナリを読み込むためのInputStreamを取得。- Specified by:
getInputStreamin interfaceUploadFileHandle- Returns:
-
isSizeOver
public boolean isSizeOver()Description copied from interface:UploadFileHandleアップロードされたファイルのファイルサイズが上限値を超えていた場合true。- Specified by:
isSizeOverin interfaceUploadFileHandle- Returns:
-
copyTo
public java.nio.file.Path copyTo(java.nio.file.Path target, java.nio.file.CopyOption... options)Description copied from interface:UploadFileHandleアップロードされたファイルを指定のtargetへコピーする。- Specified by:
copyToin interfaceUploadFileHandle- Returns:
- コピー先のpath
-
moveTo
public java.nio.file.Path moveTo(java.nio.file.Path target, java.nio.file.CopyOption... options)Description copied from interface:UploadFileHandleアップロードされたファイルを指定のtargetへ移動する。- Specified by:
moveToin interfaceUploadFileHandle- Returns:
- 移動先のpath
-