コード例 #1
0
 @Test
 public void testGetVariables() {
   DAPVariable variable =
       new DAPVariable(
           "vname",
           "vtype",
           "vdatatype",
           new DArrayDimension[] {new DArrayDimension(10, "dname")});
   opendapLeaf.addDAPVariable(variable);
   assertEquals(1, opendapLeaf.getDAPVariables().length);
   assertSame(variable, opendapLeaf.getDAPVariables()[0]);
 }
コード例 #2
0
  @Test
  public void testThatRendererRendersDifferentTypes() {
    final JTree jTree = new JTree();
    CatalogTreeUtils.addCellRenderer(jTree);
    final TreeCellRenderer dapCellRenderer = jTree.getCellRenderer();

    final OpendapLeaf opendapLeaf =
        new OpendapLeaf("This is A dap Node", new InvDataset(null, "") {});
    opendapLeaf.setDapAccess(true);
    final OpendapLeaf fileLeaf =
        new OpendapLeaf("This is A File Node", new InvDataset(null, "") {});
    fileLeaf.setFileAccess(true);
    final Object dapNode = new DefaultMutableTreeNode(opendapLeaf);
    final Object fileNode = new DefaultMutableTreeNode(fileLeaf);
    final Object noDapNode = new DefaultMutableTreeNode("otherNode");

    final Component component =
        dapCellRenderer.getTreeCellRendererComponent(
            jTree, noDapNode, false, false, true, 0, false);

    assertEquals(true, component instanceof DefaultTreeCellRenderer);
    final DefaultTreeCellRenderer tcr1 = (DefaultTreeCellRenderer) component;
    assertEquals("otherNode", tcr1.getText());
    assertEquals(true, tcr1.getIcon() instanceof ImageIcon);

    final Color foreground = tcr1.getForeground();
    final Color background = tcr1.getBackground();
    final Font font = tcr1.getFont();

    final Component component2 =
        dapCellRenderer.getTreeCellRendererComponent(jTree, dapNode, false, false, true, 0, false);

    assertSame(component, component2);

    assertEquals(true, component2 instanceof DefaultTreeCellRenderer);
    final DefaultTreeCellRenderer tcr2 = (DefaultTreeCellRenderer) component2;
    assertEquals("This is A dap Node", tcr2.getText());
    assertEquals(true, tcr2.getIcon() instanceof ImageIcon);
    final ImageIcon icon2 = (ImageIcon) tcr2.getIcon();
    // todo change the expected icon to a realistic icon
    assertEquals(
        "/DRsProduct16.png",
        icon2.getDescription().substring(icon2.getDescription().lastIndexOf("/")));

    assertEquals(foreground, tcr2.getForeground());
    assertEquals(background, tcr2.getBackground());
    assertEquals(font, tcr2.getFont());

    final Component component3 =
        dapCellRenderer.getTreeCellRendererComponent(jTree, fileNode, false, false, true, 0, false);

    assertSame(component, component3);

    assertEquals(true, component3 instanceof DefaultTreeCellRenderer);
    final DefaultTreeCellRenderer tcr3 = (DefaultTreeCellRenderer) component3;
    assertEquals("This is A File Node", tcr3.getText());
    assertEquals(true, tcr3.getIcon() instanceof ImageIcon);
    final ImageIcon icon3 = (ImageIcon) tcr3.getIcon();
    // todo change the expected icon to a realistic icon
    assertEquals(
        "/FRsProduct16.png",
        icon3.getDescription().substring(icon3.getDescription().lastIndexOf("/")));

    assertEquals(foreground, tcr3.getForeground());
    assertEquals(background, tcr3.getBackground());
    assertEquals(font, tcr3.getFont());
  }
コード例 #3
0
 @Test
 public void testGetFileURI() {
   assertEquals("http://domain/file_node", opendapLeaf.getFileUri());
 }
コード例 #4
0
 @Test
 public void testGetDodsURI() {
   assertEquals("http://domain/dap_node", opendapLeaf.getDapUri());
 }
コード例 #5
0
 @Test
 public void testGetDdxURI() {
   assertEquals("http://domain/dap_node.ddx", opendapLeaf.getDdxUri());
 }
コード例 #6
0
 @Before
 public void setUp() throws Exception {
   opendapLeaf = new OpendapLeaf("blah", new InvDataset(null, "") {});
   opendapLeaf.setDapUri("http://domain/dap_node");
   opendapLeaf.setFileUri("http://domain/file_node");
 }