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.

BaseTestBorderStyle.java 3.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* ====================================================================
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. 2012 - Alfresco Software, Ltd.
  15. Alfresco Software has modified source of this file
  16. The details of changes as svn diff can be found in svn at location root/projects/3rd-party/src
  17. ==================================================================== */
  18. package org.apache.poi.ss.usermodel;
  19. import static org.junit.Assert.assertEquals;
  20. import java.io.IOException;
  21. import org.apache.poi.ss.ITestDataProvider;
  22. import org.junit.Test;
  23. /**
  24. * Tests of {@link BorderStyle}
  25. */
  26. public class BaseTestBorderStyle {
  27. private final ITestDataProvider _testDataProvider;
  28. protected BaseTestBorderStyle(ITestDataProvider testDataProvider) {
  29. _testDataProvider = testDataProvider;
  30. }
  31. /**
  32. * Test that we use the specified locale when deciding
  33. * how to format normal numbers
  34. */
  35. @Test
  36. public void testBorderStyle() throws IOException {
  37. String ext = _testDataProvider.getStandardFileNameExtension();
  38. Workbook wb = _testDataProvider.openSampleWorkbook("59264."+ext);
  39. Sheet sh = wb.getSheetAt(0);
  40. assertBorderStyleEquals(BorderStyle.NONE, getDiagonalCell(sh, 0));
  41. assertBorderStyleEquals(BorderStyle.THIN, getDiagonalCell(sh, 1));
  42. assertBorderStyleEquals(BorderStyle.MEDIUM, getDiagonalCell(sh, 2));
  43. assertBorderStyleEquals(BorderStyle.DASHED, getDiagonalCell(sh, 3));
  44. assertBorderStyleEquals(BorderStyle.DOTTED, getDiagonalCell(sh, 4));
  45. assertBorderStyleEquals(BorderStyle.THICK, getDiagonalCell(sh, 5));
  46. assertBorderStyleEquals(BorderStyle.DOUBLE, getDiagonalCell(sh, 6));
  47. assertBorderStyleEquals(BorderStyle.HAIR, getDiagonalCell(sh, 7));
  48. assertBorderStyleEquals(BorderStyle.MEDIUM_DASHED, getDiagonalCell(sh, 8));
  49. assertBorderStyleEquals(BorderStyle.DASH_DOT, getDiagonalCell(sh, 9));
  50. assertBorderStyleEquals(BorderStyle.MEDIUM_DASH_DOT, getDiagonalCell(sh, 10));
  51. assertBorderStyleEquals(BorderStyle.DASH_DOT_DOT, getDiagonalCell(sh, 11));
  52. assertBorderStyleEquals(BorderStyle.MEDIUM_DASH_DOT_DOT, getDiagonalCell(sh, 12));
  53. assertBorderStyleEquals(BorderStyle.SLANTED_DASH_DOT, getDiagonalCell(sh, 13));
  54. wb.close();
  55. }
  56. private Cell getDiagonalCell(Sheet sheet, int n) {
  57. return sheet.getRow(n).getCell(n);
  58. }
  59. protected void assertBorderStyleEquals(BorderStyle expected, Cell cell) {
  60. CellStyle style = cell.getCellStyle();
  61. assertEquals(expected, style.getBorderTop());
  62. assertEquals(expected, style.getBorderBottom());
  63. assertEquals(expected, style.getBorderLeft());
  64. assertEquals(expected, style.getBorderRight());
  65. }
  66. }