You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ContainerSizeAssertTest.java 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package com.vaadin.v7.data.util;
  2. import org.junit.Test;
  3. import com.vaadin.v7.data.Container;
  4. import com.vaadin.v7.ui.Table;
  5. public class ContainerSizeAssertTest {
  6. @Test(expected = AssertionError.class)
  7. public void testNegativeSizeAssert() {
  8. Table table = createAttachedTable();
  9. table.setContainerDataSource(createNegativeSizeContainer());
  10. }
  11. @Test
  12. public void testZeroSizeNoAssert() {
  13. Table table = createAttachedTable();
  14. table.setContainerDataSource(new IndexedContainer());
  15. }
  16. private Container createNegativeSizeContainer() {
  17. return new IndexedContainer() {
  18. @Override
  19. public int size() {
  20. return -1;
  21. }
  22. };
  23. }
  24. private Table createAttachedTable() {
  25. return new Table() {
  26. private boolean initialized = true;
  27. @Override
  28. public boolean isAttached() {
  29. // This returns false until the super constructor has finished
  30. return initialized;
  31. }
  32. };
  33. }
  34. }