/*
* Copyright 2000-2013 Enonic AS
* http://www.enonic.com/license
*/
package com.enonic.cms.web.portal.services;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import org.apache.commons.fileupload.FileItem;
public class MockFileItem
implements FileItem
{
private byte[] value = null;
protected MockFileItem( byte[] value )
{
this.value = value;
}
public InputStream getInputStream()
throws IOException
{
if ( value == null )
{
return new ByteArrayInputStream( new byte[]{} );
}
return new ByteArrayInputStream( value );
}
public String getContentType()
{
return null;
}
public String getName()
{
return "TestFileItem";
}
public boolean isInMemory()
{
return true;
}
public long getSize()
{
return value.length;
}
public byte[] get()
{
return value;
}
public String getString( String s )
throws UnsupportedEncodingException
{
return null;
}
public String getString()
{
return null;
}
public void write( File file )
throws Exception
{
}
public void delete()
{
}
public String getFieldName()
{
return null;
}
public void setFieldName( String s )
{
}
public boolean isFormField()
{
return false;
}
public void setFormField( boolean b )
{
}
public OutputStream getOutputStream()
throws IOException
{
return null;
}
}