Search in sources :

Example 1 with ValueFields

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

the class FileValueSerializerTest method testWriteMimetypeFilenameBytesValueAndEncoding.

@Test
public void testWriteMimetypeFilenameBytesValueAndEncoding() throws UnsupportedEncodingException {
    String filename = "test.txt";
    String mimeType = "text/json";
    Charset encoding = Charset.forName("UTF-8");
    InputStream is = this.getClass().getClassLoader().getResourceAsStream("org/camunda/bpm/engine/test/standalone/variables/simpleFile.txt");
    FileValue fileValue = Variables.fileValue(filename).mimeType(mimeType).encoding(encoding).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 + encoding.name()));
}
Also used : FileValue(org.camunda.bpm.engine.variable.value.FileValue) DataInputStream(java.io.DataInputStream) InputStream(java.io.InputStream) Charset(java.nio.charset.Charset) ValueFields(org.camunda.bpm.engine.impl.variable.serializer.ValueFields) Test(org.junit.Test)

Example 2 with ValueFields

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

the class FileValueSerializerTest method testWriteMimetypeAndFilenameValue.

@Test
public void testWriteMimetypeAndFilenameValue() {
    String filename = "test.txt";
    String mimeType = "text/json";
    FileValue fileValue = Variables.fileValue(filename).mimeType(mimeType).create();
    ValueFields valueFields = new MockValueFields();
    serializer.writeValue(fileValue, valueFields);
    assertThat(valueFields.getByteArrayValue(), is(nullValue()));
    assertThat(valueFields.getTextValue(), is(filename));
    assertThat(valueFields.getTextValue2(), is(mimeType + SEPARATOR));
}
Also used : FileValue(org.camunda.bpm.engine.variable.value.FileValue) ValueFields(org.camunda.bpm.engine.impl.variable.serializer.ValueFields) Test(org.junit.Test)

Example 3 with ValueFields

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

the class FileValueSerializerTest method testWriteFilenameOnlyValue.

@Test
public void testWriteFilenameOnlyValue() {
    String filename = "test.txt";
    FileValue fileValue = Variables.fileValue(filename).create();
    ValueFields valueFields = new MockValueFields();
    serializer.writeValue(fileValue, valueFields);
    assertThat(valueFields.getByteArrayValue(), is(nullValue()));
    assertThat(valueFields.getTextValue(), is(filename));
    assertThat(valueFields.getTextValue2(), is(nullValue()));
}
Also used : FileValue(org.camunda.bpm.engine.variable.value.FileValue) ValueFields(org.camunda.bpm.engine.impl.variable.serializer.ValueFields) Test(org.junit.Test)

Example 4 with ValueFields

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

the class FileValueSerializerTest method testWriteMimetypeFilenameAndBytesValueWithShortcutMethod.

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

Example 5 with ValueFields

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

the class FileValueSerializerTest method testWriteFilenameAndEncodingValue.

@Test
public void testWriteFilenameAndEncodingValue() {
    String filename = "test.txt";
    String encoding = "UTF-8";
    FileValue fileValue = Variables.fileValue(filename).encoding(encoding).create();
    ValueFields valueFields = new MockValueFields();
    serializer.writeValue(fileValue, valueFields);
    assertThat(valueFields.getByteArrayValue(), is(nullValue()));
    assertThat(valueFields.getTextValue(), is(filename));
    assertThat(valueFields.getTextValue2(), is(SEPARATOR + encoding));
}
Also used : FileValue(org.camunda.bpm.engine.variable.value.FileValue) 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