use of com.sldeditor.datasource.extension.filesystem.node.TransferableDataItem in project sldeditor by robward-scisys.
the class TransferableDataItemTest method testTransferableDataItem.
/**
* Test method for
* {@link com.sldeditor.datasource.extension.filesystem.node.TransferableDataItem#TransferableDataItem()}.
*/
@Test
public void testTransferableDataItem() {
Map<NodeInterface, TreePath> selectedData = new HashMap<NodeInterface, TreePath>();
FileTreeNode fileTreeNode1 = null;
FileTreeNode fileTreeNode2 = null;
FileTreeNode fileTreeNode3 = null;
FileTreeNode fileTreeNode4 = null;
try {
fileTreeNode1 = new FileTreeNode(new File(System.getProperty("user.dir")), "file1.txt");
fileTreeNode2 = new FileTreeNode(new File(System.getProperty("user.dir")), "file2.txt");
fileTreeNode3 = new FileTreeNode(new File(System.getProperty("user.dir")), "file3.txt");
fileTreeNode4 = new FileTreeNode(new File(System.getProperty("user.dir")), "file4.txt");
selectedData.put(fileTreeNode1, new TreePath(new DefaultMutableTreeNode("branch1")));
selectedData.put(fileTreeNode2, new TreePath(new DefaultMutableTreeNode("branch2")));
selectedData.put(fileTreeNode3, new TreePath(new DefaultMutableTreeNode("branch3")));
selectedData.put(fileTreeNode4, new TreePath(new DefaultMutableTreeNode("branch4")));
TransferableDataItem dataItem = new TransferableDataItem(selectedData);
DataFlavor dataFlavour = dataItem.getDataFlavour();
assertEquals(FileTreeNode.class, dataFlavour.getRepresentationClass());
try {
Object data = dataItem.getTransferData(DataFlavourManager.FOLDER_DATAITEM_FLAVOR);
assertTrue(data instanceof TransferredData);
assertEquals(selectedData.size(), ((TransferredData) data).getDataListSize());
assertFalse(dataItem.isDataFlavorSupported(BuiltInDataFlavour.GEOSERVER_DATAITEM_FLAVOUR));
assertTrue(dataItem.isDataFlavorSupported(DataFlavourManager.FOLDER_DATAITEM_FLAVOR));
} catch (UnsupportedFlavorException e) {
e.printStackTrace();
fail(e.getMessage());
} catch (IOException e) {
e.printStackTrace();
fail(e.getMessage());
}
} catch (SecurityException e) {
e.printStackTrace();
fail(e.getMessage());
} catch (FileNotFoundException e) {
e.printStackTrace();
fail(e.getMessage());
}
}
Aggregations