### Question:
DCTableCellRenderer implements TableCellRenderer { @Override public Component getTableCellRendererComponent(final JTable table, Object value, final boolean isSelected, final boolean hasFocus, final int row, final int column) { logger.debug("getTableCellRendererComponent({},{})", row, column); if (value != null && value.getClass().isArray()) { value = ArrayUtils.toString(value); } if (value instanceof Icon) { final JLabel label = new JLabel((Icon) value); label.setOpaque(true); value = label; } if (value instanceof Clob) { final Clob clob = (Clob) value; try { final Reader reader = clob.getCharacterStream(); value = FileHelper.readAsString(reader); } catch (final Exception e) { logger.error("Failed to read String from CLOB: {}", clob, e); } } final Component result; if (value instanceof JComponent) { final JComponent component = (JComponent) value; component.setOpaque(true); if (component.getMouseListeners().length == 0) { component.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(final MouseEvent e) { final MouseEvent newEvent = SwingUtilities.convertMouseEvent(component, e, _table); _table.consumeMouseClick(newEvent); } }); } result = component; } else { result = _delegate.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); assert result instanceof JLabel; } Alignment alignment = _alignmentOverrides.get(column); if (alignment == null) { alignment = Alignment.LEFT; } if (value instanceof JPanel) { final LayoutManager layout = ((JPanel) value).getLayout(); if (layout instanceof FlowLayout) { final FlowLayout flowLayout = (FlowLayout) layout; flowLayout.setAlignment(alignment.getFlowLayoutAlignment()); } } else if (result instanceof JLabel) { final JLabel label = (JLabel) result; label.setHorizontalAlignment(alignment.getSwingContstantsAlignment()); WidgetUtils.setAppropriateFont(label); } return result; } DCTableCellRenderer(final DCTable table); @Override Component getTableCellRendererComponent(final JTable table, Object value, final boolean isSelected,
            final boolean hasFocus, final int row, final int column); void setAlignment(final int column, final Alignment alignment);  }### Answer:
@Test public void testRenderClob() throws Exception { final Clob clob = new SerialClob("foo bar baz".toCharArray()); assertFalse("foo bar baz".equals(clob.toString())); final DCTableCellRenderer renderer = new DCTableCellRenderer(null); final Component component = renderer.getTableCellRendererComponent(new JTable(), clob, false, false, 1, 1); assertTrue(component instanceof JLabel); final JLabel label = (JLabel) component; assertEquals("foo bar baz", label.getText()); }
@Test public void testRenderIcon() throws Exception { final Image image = new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB); final Icon icon = new ImageIcon(image); final DCTableCellRenderer renderer = new DCTableCellRenderer(null); final Component component = renderer.getTableCellRendererComponent(new JTable(), icon, false, false, 1, 1); assertTrue(component instanceof JLabel); final JLabel label = (JLabel) component; assertEquals(icon, label.getIcon()); }
@Test public void testRenderJComponent() throws Exception { final JComponent inputComponent = DCLabel.dark("hello world"); final DCTableCellRenderer renderer = new DCTableCellRenderer(null); final Component component = renderer.getTableCellRendererComponent(new JTable(), inputComponent, false, false, 1, 1); assertTrue(component instanceof JLabel); assertSame(inputComponent, component); }