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.

PDFAModeTestCase.java 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /* $Id$ */
  18. package org.apache.fop.pdf;
  19. import org.junit.Test;
  20. import static org.junit.Assert.assertEquals;
  21. import static org.junit.Assert.assertFalse;
  22. import static org.junit.Assert.assertTrue;
  23. public class PDFAModeTestCase {
  24. private static class PDFAModeChecker {
  25. private final PDFAMode mode;
  26. PDFAModeChecker(PDFAMode mode) {
  27. this.mode = mode;
  28. }
  29. PDFAModeChecker isEnabled() {
  30. assertTrue(mode.isEnabled());
  31. return this;
  32. }
  33. PDFAModeChecker isDisabled() {
  34. assertFalse(mode.isEnabled());
  35. return this;
  36. }
  37. PDFAModeChecker isPart1() {
  38. assertEquals(1, mode.getPart());
  39. assertTrue(mode.isPart1());
  40. return this;
  41. }
  42. PDFAModeChecker isNotPart1() {
  43. assertFalse(mode.getPart() == 1);
  44. assertFalse(mode.isPart1());
  45. return this;
  46. }
  47. PDFAModeChecker isPart2() {
  48. assertTrue(mode.getPart() == 1 || mode.getPart() == 2);
  49. assertTrue(mode.isPart2());
  50. return this;
  51. }
  52. PDFAModeChecker isNotPart2() {
  53. assertFalse(mode.getPart() == 2);
  54. assertFalse(mode.isPart2());
  55. return this;
  56. }
  57. PDFAModeChecker hasConformanceLevel(char level) {
  58. assertEquals(level, mode.getConformanceLevel());
  59. return this;
  60. }
  61. PDFAModeChecker isLevelA() {
  62. assertEquals('A', mode.getConformanceLevel());
  63. assertTrue(mode.isLevelA());
  64. return this;
  65. }
  66. PDFAModeChecker isNotLevelA() {
  67. assertFalse(mode.getConformanceLevel() == 'A');
  68. assertFalse(mode.isLevelA());
  69. return this;
  70. }
  71. }
  72. @Test
  73. public void checkDisabled() {
  74. new PDFAModeChecker(PDFAMode.DISABLED)
  75. .isDisabled()
  76. .isNotPart1()
  77. .isNotPart2()
  78. .isNotLevelA();
  79. }
  80. @Test
  81. public void checkPDFA1a() {
  82. new PDFAModeChecker(PDFAMode.PDFA_1A)
  83. .isEnabled()
  84. .isPart1()
  85. .isPart2()
  86. .isLevelA();
  87. }
  88. @Test
  89. public void checkPDFA1b() {
  90. new PDFAModeChecker(PDFAMode.PDFA_1B)
  91. .isEnabled()
  92. .isPart1()
  93. .isPart2()
  94. .isNotLevelA();
  95. }
  96. @Test
  97. public void checkPDFA2a() {
  98. new PDFAModeChecker(PDFAMode.PDFA_2A)
  99. .isEnabled()
  100. .isNotPart1()
  101. .isPart2()
  102. .isLevelA();
  103. }
  104. @Test
  105. public void checkPDFA2b() {
  106. new PDFAModeChecker(PDFAMode.PDFA_2B)
  107. .isEnabled()
  108. .isNotPart1()
  109. .isPart2()
  110. .isNotLevelA();
  111. }
  112. @Test
  113. public void checkPDFA2u() {
  114. new PDFAModeChecker(PDFAMode.PDFA_2U)
  115. .isEnabled()
  116. .isNotPart1()
  117. .isPart2()
  118. .isNotLevelA()
  119. .hasConformanceLevel('U');
  120. }
  121. }