use of com.enonic.xp.core.impl.export.writer.FileExportWriter in project xp by enonic.
the class NodeExportIntegrationTest method include_export_root_and_nested_children.
@Test
public void include_export_root_and_nested_children() throws Exception {
final Node root = createNode("mynode", NodePath.ROOT);
final Node child1 = createNode("child1", root.path());
createNode("child2", root.path());
final Node child1_1 = createNode("child1_1", child1.path());
createNode("child1_1_1", child1_1.path());
createNode("child1_1_2", child1_1.path());
nodeService.refresh(RefreshMode.ALL);
final NodeExportResult result = NodeExporter.create().nodeService(this.nodeService).nodeExportWriter(new FileExportWriter()).sourceNodePath(NodePath.create("/mynode/child1").build()).targetDirectory(this.temporaryFolder.resolve("myExport")).build().execute();
assertEquals(4, result.getExportedNodes().getSize());
assertFileExists("myExport/child1/_/node.xml");
assertFileExists("myExport/child1/child1_1/_/node.xml");
assertFileExists("myExport/child1/child1_1/child1_1_1/_/node.xml");
assertFileExists("myExport/child1/child1_1/child1_1_2/_/node.xml");
}
use of com.enonic.xp.core.impl.export.writer.FileExportWriter in project xp by enonic.
the class NodeExportIntegrationTest method create_binary_files.
// Wait with this until decided how to handle versions. Only in dump, or in export too?
@Disabled
@Test
public void create_binary_files() throws Exception {
final PropertyTree data = new PropertyTree();
final BinaryReference binaryRef1 = BinaryReference.from("image1.jpg");
final BinaryReference binaryRef2 = BinaryReference.from("image2.jpg");
data.addBinaryReference("my-image-1", binaryRef1);
data.addBinaryReference("my-image-2", binaryRef2);
this.nodeService.create(CreateNodeParams.create().name("my-node").parent(NodePath.ROOT).data(data).attachBinary(binaryRef1, ByteSource.wrap("this-is-the-binary-data-for-image1".getBytes())).attachBinary(binaryRef2, ByteSource.wrap("this-is-the-binary-data-for-image2".getBytes())).build());
final NodeExportResult result = NodeExporter.create().nodeService(this.nodeService).nodeExportWriter(new FileExportWriter()).sourceNodePath(NodePath.ROOT).targetDirectory(this.temporaryFolder.resolve("myExport")).build().execute();
assertEquals(2, result.getExportedNodes().getSize());
assertEquals(2, result.getExportedBinaries().size());
assertFileExists("myExport/_/node.xml");
assertFileExists("myExport/my-node/_/node.xml");
assertFileExists("myExport/my-node/_/bin/image1.jpg");
assertFileExists("myExport/my-node/_/bin/image2.jpg");
}
use of com.enonic.xp.core.impl.export.writer.FileExportWriter in project xp by enonic.
the class NodeExportIntegrationTest method export_from_child_of_child.
@Test
public void export_from_child_of_child() throws Exception {
final Node root = createNode("mynode", NodePath.ROOT);
final Node child1 = createNode("child1", root.path());
final Node child1_1 = createNode("child1_1", child1.path());
createNode("child1_1_1", child1_1.path());
createNode("child1_1_2", child1_1.path());
nodeService.refresh(RefreshMode.ALL);
final NodeExportResult result = NodeExporter.create().nodeService(this.nodeService).nodeExportWriter(new FileExportWriter()).sourceNodePath(NodePath.create("/mynode/child1/child1_1").build()).targetDirectory(this.temporaryFolder.resolve("myExport")).build().execute();
assertEquals(3, result.getExportedNodes().getSize());
assertFileExists("myExport/child1_1/_/node.xml");
assertFileExists("myExport/child1_1/child1_1_1/_/node.xml");
assertFileExists("myExport/child1_1/child1_1_2/_/node.xml");
}
use of com.enonic.xp.core.impl.export.writer.FileExportWriter in project xp by enonic.
the class NodeExportIntegrationTest method export_properties.
@Test
public void export_properties() throws Exception {
NodeExporter.create().nodeService(this.nodeService).nodeExportWriter(new FileExportWriter()).sourceNodePath(NodePath.ROOT).targetDirectory(this.temporaryFolder.resolve("myExport")).build().execute();
assertFileDoesNotExist("myExport/export.properties");
NodeExporter.create().nodeService(this.nodeService).nodeExportWriter(new FileExportWriter()).sourceNodePath(NodePath.ROOT).xpVersion("X.Y.Z-SNAPSHOT").rootDirectory(this.temporaryFolder.resolve("myRoot")).targetDirectory(this.temporaryFolder.resolve("myRoot").resolve("myExport")).build().execute();
assertFileExists("myRoot/export.properties");
}
use of com.enonic.xp.core.impl.export.writer.FileExportWriter in project xp by enonic.
the class NodeExportIntegrationTest method children_nodes.
@Test
public void children_nodes() throws Exception {
final Node root = createNode("mynode", NodePath.ROOT);
final Node child1 = createNode("child1", root.path());
createNode("child1_1", child1.path());
final Node child1_2 = createNode("child1_2", child1.path());
createNode("child1_2_1", child1_2.path());
createNode("child1_2_2", child1_2.path());
final Node child2 = createNode("child2", root.path());
createNode("child2_1", child2.path());
final NodeExportListener nodeExportListener = Mockito.mock(NodeExportListener.class);
nodeService.refresh(RefreshMode.ALL);
final NodeExportResult result = NodeExporter.create().nodeService(this.nodeService).nodeExportWriter(new FileExportWriter()).sourceNodePath(NodePath.ROOT).targetDirectory(this.temporaryFolder.resolve("myExport")).nodeExportListener(nodeExportListener).build().execute();
assertEquals(9, result.size());
assertFileExists("myExport/_/node.xml");
assertFileExists("myExport/mynode/_/node.xml");
assertFileExists("myExport/mynode/child1/_/node.xml");
assertFileExists("myExport/mynode/child1/child1_1/_/node.xml");
assertFileExists("myExport/mynode/child1/child1_2/_/node.xml");
assertFileExists("myExport/mynode/child1/child1_2/child1_2_1/_/node.xml");
assertFileExists("myExport/mynode/child1/child1_2/child1_2_2/_/node.xml");
assertFileExists("myExport/mynode/child2/_/node.xml");
assertFileExists("myExport/mynode/child2/child2_1/_/node.xml");
Mockito.verify(nodeExportListener).nodeResolved(9L);
Mockito.verify(nodeExportListener, Mockito.times(9)).nodeExported(1L);
}
Aggregations