Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

ContainerSizeAssertTest.java 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright 2000-2016 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.data.util;
  17. import org.junit.Test;
  18. import com.vaadin.data.Container;
  19. import com.vaadin.ui.Table;
  20. public class ContainerSizeAssertTest {
  21. @Test(expected = AssertionError.class)
  22. public void testNegativeSizeAssert() {
  23. Table table = createAttachedTable();
  24. table.setContainerDataSource(createNegativeSizeContainer());
  25. }
  26. @Test
  27. public void testZeroSizeNoAssert() {
  28. Table table = createAttachedTable();
  29. table.setContainerDataSource(new IndexedContainer());
  30. }
  31. private Container createNegativeSizeContainer() {
  32. return new IndexedContainer() {
  33. @Override
  34. public int size() {
  35. return -1;
  36. }
  37. };
  38. }
  39. private Table createAttachedTable() {
  40. return new Table() {
  41. private boolean initialized = true;
  42. @Override
  43. public boolean isAttached() {
  44. // This returns false until the super constructor has finished
  45. return initialized;
  46. }
  47. };
  48. }
  49. }