@Before public void setUp() throws Exception { datasets = new ArrayList<InvDataset>(); catalog = new InvCatalogImpl("catalogName", "1.0", new URI("http://x.y")); InvDatasetImpl dapDataset = createDataset(catalog, "first", "OPENDAP"); datasets.add(dapDataset); catalogTree = new CatalogTree(null, new DefaultAppContext(""), null); }
@Before public void setUp() throws Exception { catalogTree = new CatalogTree(null, new DefaultAppContext(""), null); parentNode = (DefaultMutableTreeNode) ((JTree) catalogTree.getComponent()).getModel().getRoot(); }
catalogTree = new CatalogTree(new DefaultLeafSelectionListener(), appContext, this); useDatasetNameFilter = new JCheckBox("Use dataset name filter"); useTimeRangeFilter = new JCheckBox("Use time range filter");
@Before public void setUp() { Lm.verifyLicense("Brockmann Consult", "BEAM", "lCzfhklpZ9ryjomwWxfdupxIcuIoCxg2"); variableFilter = new VariableFilter(new JCheckBox(), new CatalogTree(null, new DefaultAppContext(""), null)); variableFilter.getUI(); leaf = new OpendapLeaf("leafName", new InvDataset(null, "") { }); DArrayDimension[] dArrayDimensions = {new DArrayDimension(10, "dimName")}; dapVariable = new DAPVariable("vName", "vType", "vDataType", dArrayDimensions); leaf.addDAPVariable(dapVariable); }
@Test public void testThatGetComponentGetsAWellDefinedJTreeComponent() { Assume.assumeTrue(!GraphicsEnvironment.isHeadless()); final CatalogTree catalogTree = new CatalogTree(null, new DefaultAppContext(""), null); final Component component = catalogTree.getComponent(); assertNotNull(component); assertTrue(component instanceof JTree); final JTree tree = (JTree) component; assertEquals(false, tree.isRootVisible()); assertNotNull(tree.getModel()); assertEquals(true, tree.getModel() instanceof DefaultTreeModel); final DefaultTreeModel model = (DefaultTreeModel) tree.getModel(); assertNotNull(model.getRoot()); assertEquals(true, model.getRoot() instanceof DefaultMutableTreeNode); final DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode) model.getRoot(); assertNotNull(rootNode.getUserObject()); assertEquals(true, rootNode.getUserObject() instanceof String); assertEquals("root", rootNode.getUserObject().toString()); }
@Test public void testGetLeaves() throws Exception { Assume.assumeTrue(!GraphicsEnvironment.isHeadless()); final CatalogTree catalogTree = new CatalogTree(null, new DefaultAppContext(""), null); List<InvDataset> datasets = new ArrayList<InvDataset>(); InvCatalog catalog = new InvCatalogImpl("catalogName", "1.0", new URI("http://x.y")); final InvDataset rootDataset = createDataset(catalog, "first", "OPENDAP"); rootDataset.getDatasets().add(createDataset(catalog, "second", "OPENDAP")); rootDataset.getDatasets().add(createDataset(catalog, "third", "OPENDAP")); datasets.add(rootDataset); catalogTree.setNewRootDatasets(datasets); OpendapLeaf[] leaves = catalogTree.getLeaves(); Arrays.sort(leaves, new Comparator<OpendapLeaf>() { @Override public int compare(OpendapLeaf o1, OpendapLeaf o2) { return o1.getName().compareTo(o2.getName()); } }); assertEquals(2, leaves.length); assertEquals("second", leaves[0].getName()); assertEquals("third", leaves[1].getName()); }
@Test public void testAppendThreeDapNodes() throws URISyntaxException { //preparation datasets.add(createDataset(catalog, "Name_1", "OPENDAP")); datasets.add(createDataset(catalog, "Name_2", "OPENDAP")); datasets.add(createDataset(catalog, "Name_3", "OPENDAP")); //execution new CatalogTree(null, new DefaultAppContext(""), null).appendToNode(new JTree(), datasets, parentNode, true); //verification assertEquals(3, parentNode.getChildCount()); for (int i = 0; i < parentNode.getChildCount(); i++) { final DefaultMutableTreeNode childAt = (DefaultMutableTreeNode) parentNode.getChildAt(i); final String indexMessage = "Index = " + i; assertEquals(indexMessage, true, childAt.isLeaf()); assertEquals(indexMessage, true, CatalogTreeUtils.isDapNode(childAt)); assertEquals(indexMessage, "Name_" + (i + 1), childAt.getUserObject().toString()); } }
@Test public void testThatAppendDatasetWithFileAccessOnlyIsResolvedToNodeWithFileAccess() throws URISyntaxException { // preparation final String serviceName = "FILE"; final InvDatasetImpl dapDataset = createDataset(new String[]{serviceName}); // execution new CatalogTree(null, new DefaultAppContext(""), null).appendLeafNode(parentNode, getDefaultTreeModel(), dapDataset); // verification testThatChildIsNodeWithFileAccess(parentNode); }
@Test public void testAppendDatasetWhichHasDapAccessAndAlsoFileAccess() throws URISyntaxException { // preparation final String dapServiceName = "OPENDAP"; final String fileServiceName = "FILE"; final InvDatasetImpl dapDataset = createDataset(new String[]{fileServiceName, dapServiceName}); // execution new CatalogTree(null, new DefaultAppContext(""), null).appendLeafNode(parentNode, getDefaultTreeModel(), dapDataset); // verification testThatChildIsDapNodeWhichHasFileAccessToo(parentNode); }
@Test public void testAppendFileNode() throws URISyntaxException { //preparation datasets.add(createDataset(catalog, "fileName", "file")); //execution new CatalogTree(null, new DefaultAppContext(""), null).appendToNode(new JTree(), datasets, parentNode, true); //verification assertEquals(1, parentNode.getChildCount()); assertEquals(true, parentNode.getChildAt(0).isLeaf()); assertEquals(false, CatalogTreeUtils.isDapNode(parentNode.getChildAt(0))); }
@Test public void testAppendAn_OPeNDAP_Node() throws URISyntaxException { // preparation final String serviceType = "OPENDAP"; final InvDatasetImpl dapDataset = createDataset(new String[]{serviceType}); // execution new CatalogTree(null, new DefaultAppContext(""), null).appendLeafNode(parentNode, getDefaultTreeModel(), dapDataset); // verification testThatChildIsOnlyDapNodeWithoutFileAccess(parentNode); }
@Test public void testAppendDapNode() throws URISyntaxException { // preparation datasets.add(createDataset(catalog, "first", "OPENDAP")); // execution new CatalogTree(null, new DefaultAppContext(""), null).appendToNode(new JTree(), datasets, parentNode, true); // verification assertEquals(1, parentNode.getChildCount()); assertEquals(true, parentNode.getChildAt(0).isLeaf()); assertEquals(true, CatalogTreeUtils.isDapNode(parentNode.getChildAt(0))); }
@Test public void testAppendingVariousDatasets() { //preparation datasets.add(createDataset(catalog, "dapName", "OPENDAP")); datasets.add(createDataset(catalog, "fileName", "FILE")); datasets.add(createCatalogRefDataset()); //execution new CatalogTree(null, new DefaultAppContext(""), null).appendToNode(new JTree(), datasets, parentNode, true); //verification assertEquals(3, parentNode.getChildCount()); assertEquals(true, CatalogTreeUtils.isDapNode(parentNode.getChildAt(0))); assertEquals(false, CatalogTreeUtils.isDapNode(parentNode.getChildAt(1))); assertEquals(false, CatalogTreeUtils.isCatalogReferenceNode(parentNode.getChildAt(1))); assertEquals(true, CatalogTreeUtils.isCatalogReferenceNode(parentNode.getChildAt(2).getChildAt(0))); }
@Test public void testAppendCatalogNode() throws URISyntaxException { //preparation datasets.add(createCatalogRefDataset()); //execution new CatalogTree(null, new DefaultAppContext(""), null).appendToNode(new JTree(), datasets, parentNode, true); //verification assertEquals(1, parentNode.getChildCount()); assertEquals(1, parentNode.getChildAt(0).getChildCount()); assertEquals(true, parentNode.getChildAt(0).getChildAt(0).isLeaf()); assertEquals(false, CatalogTreeUtils.isDapNode(parentNode.getChildAt(0))); assertEquals(false, CatalogTreeUtils.isCatalogReferenceNode(parentNode.getChildAt(0))); assertEquals(false, CatalogTreeUtils.isDapNode(parentNode.getChildAt(0).getChildAt(0))); assertEquals(true, CatalogTreeUtils.isCatalogReferenceNode(parentNode.getChildAt(0).getChildAt(0))); }