public void setPreservePathElements(boolean preservePathElements) {
        this.preservePathElements = preservePathElements;
    }
@Test
    public void testTarWithPreservedPathElements() throws Exception {
        MockEndpoint mock = getMockEndpoint("mock:tar");
        mock.expectedMessageCount(1);
        mock.expectedHeaderReceived(FILE_NAME, "poem.txt.tar");

        tar.setPreservePathElements(true);

        template.sendBodyAndHeader("direct:tar", TEXT, FILE_NAME, "poems/poem.txt");

        MockEndpoint.assertIsSatisfied(context);

        Exchange exchange = mock.getReceivedExchanges().get(0);

        final byte[] convertedArray = exchange.getIn().getBody(byte[].class);

        Map<String, EntryMetadata> tarData = toEntries(convertedArray);
        assertTrue(tarData.containsKey("poems/"));
        assertTrue(tarData.containsKey("poems/poem.txt"));

        EntryMetadata entryFileMetadata = tarData.get("poems/poem.txt");
        assertEquals(TEXT.getBytes(StandardCharsets.UTF_8).length, entryFileMetadata.size);
        assertFalse(entryFileMetadata.isDirectory);

        EntryMetadata entryDirMetadata = tarData.get("poems/");
        assertTrue(entryDirMetadata.isDirectory);
    }