Search in sources :

Example 6 with ValueFields

use of org.camunda.bpm.engine.impl.variable.serializer.ValueFields in project camunda-bpm-platform by camunda.

the class FileValueSerializerTest method testWriteMimetypeFilenameAndBytesValue.

@Test
public void testWriteMimetypeFilenameAndBytesValue() throws UnsupportedEncodingException {
    String filename = "test.txt";
    String mimeType = "text/json";
    InputStream is = this.getClass().getClassLoader().getResourceAsStream("org/camunda/bpm/engine/test/standalone/variables/simpleFile.txt");
    FileValue fileValue = Variables.fileValue(filename).mimeType(mimeType).file(is).create();
    ValueFields valueFields = new MockValueFields();
    serializer.writeValue(fileValue, valueFields);
    assertThat(new String(valueFields.getByteArrayValue(), "UTF-8"), is("text"));
    assertThat(valueFields.getTextValue(), is(filename));
    assertThat(valueFields.getTextValue2(), is(mimeType + SEPARATOR));
}
Also used : FileValue(org.camunda.bpm.engine.variable.value.FileValue) DataInputStream(java.io.DataInputStream) InputStream(java.io.InputStream) ValueFields(org.camunda.bpm.engine.impl.variable.serializer.ValueFields) Test(org.junit.Test)

Aggregations

ValueFields (org.camunda.bpm.engine.impl.variable.serializer.ValueFields)6 FileValue (org.camunda.bpm.engine.variable.value.FileValue)6 Test (org.junit.Test)6 DataInputStream (java.io.DataInputStream)2 InputStream (java.io.InputStream)2 File (java.io.File)1 Charset (java.nio.charset.Charset)1