/tags/fest-swing-1.0b1/src/test/java/org/fest/swing/fixture/TableCellTest.java

http://fest.googlecode.com/ · Java · 68 lines · 38 code · 10 blank · 20 comment · 0 complexity · 7148bdedb09e0628430addb281318538 MD5 · raw file

  1. /*
  2. * Created on Sep 22, 2007
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
  5. * in compliance with the License. You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software distributed under the License
  10. * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
  11. * or implied. See the License for the specific language governing permissions and limitations under
  12. * the License.
  13. *
  14. * Copyright @2007-2008 the original author or authors.
  15. */
  16. package org.fest.swing.fixture;
  17. import javax.swing.JTable;
  18. import org.testng.annotations.Test;
  19. import static org.fest.assertions.Assertions.assertThat;
  20. /**
  21. * Tests for <code>{@link TableCell}</code>.
  22. *
  23. * @author Alex Ruiz
  24. */
  25. public class TableCellTest {
  26. @Test public void shouldCreateTableCellWithGivenRowAndColumn() {
  27. int row = 6;
  28. int column = 8;
  29. TableCell cell = TableCell.row(row).column(column);
  30. assertThat(cell.row).isEqualTo(row);
  31. assertThat(cell.column).isEqualTo(column);
  32. }
  33. @Test(expectedExceptions = IndexOutOfBoundsException.class)
  34. public void shouldThrowErrorIfTableIsEmpty() {
  35. TableCell cell = TableCell.row(2).column(3);
  36. cell.validateBoundsIn(new JTable());
  37. }
  38. @Test(expectedExceptions = IndexOutOfBoundsException.class)
  39. public void shouldThrowErrorIfRowIndexIsNegative() {
  40. TableCell cell = TableCell.row(-2).column(3);
  41. cell.validateBoundsIn(new JTable(4, 3));
  42. }
  43. @Test(expectedExceptions = IndexOutOfBoundsException.class)
  44. public void shouldThrowErrorIfColumnIndexIsNegative() {
  45. TableCell cell = TableCell.row(2).column(-3);
  46. cell.validateBoundsIn(new JTable(4, 3));
  47. }
  48. @Test(expectedExceptions = IndexOutOfBoundsException.class)
  49. public void shouldThrowErrorIfRowIsOutOfBounds() {
  50. TableCell cell = TableCell.row(4).column(2);
  51. cell.validateBoundsIn(new JTable(4, 3));
  52. }
  53. @Test(expectedExceptions = IndexOutOfBoundsException.class)
  54. public void shouldThrowErrorIfColumnIsOutOfBounds() {
  55. TableCell cell = TableCell.row(0).column(3);
  56. cell.validateBoundsIn(new JTable(4, 3));
  57. }
  58. }