/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.daffodil.section11.content_framing_properties

import org.junit.Test
import org.apache.daffodil.tdml.Runner
import org.junit.AfterClass

object TestContentFramingProperties {
  private val testDir_01 = "/org/apache/daffodil/ibm-tests/"
  lazy val runner1 = Runner(testDir_01, "dpaext1.tdml")

  private val testDir_02 = "/org/apache/daffodil/section11/content_framing_properties/"
  lazy val runner2 = Runner(testDir_02, "ContentFramingProps.tdml")

  @AfterClass def shutdown {
    runner1.reset
    runner2.reset
  }
}

class TestContentFramingProperties {
  import TestContentFramingProperties._

  @Test def test_encoding_11_01() { runner1.runOneTest("encoding_11_01") }
  @Test def test_encoding_11_02() { runner1.runOneTest("encoding_11_02") }
  @Test def test_encoding_11_03() { runner1.runOneTest("encoding_11_03") }

  // Commented out due to 4byte char decode issue when implementing DFDL-951 - DFDL-965
  // @Test def test_xml_utf8_4byte_chars_01() { runner2.runOneTest("xml_utf8_4byte_chars_01") }
  // @Test def test_xml_utf8_4byte_chars() { runner2.runOneTest("xml_utf8_4byte_chars") }

  @Test def test_UTF_16_01() { runner2.runOneTest("UTF_16_01") }
  @Test def test_xml_illegal_chars_01() { runner2.runOneTest("xml_illegal_chars_01") }
  @Test def test_xml_illegal_chars_02() { runner2.runOneTest("xml_illegal_chars_02") }
  @Test def test_xml_illegal_chars() { runner2.runOneTest("xml_illegal_chars") }

  @Test def test_alignmentPacked7BitASCII() { runner2.runOneTest("alignmentPacked7BitASCII") }
  @Test def test_alignmentPacked7BitASCII_03() { runner2.runOneTest("alignmentPacked7BitASCII_03") }
  @Test def test_alignmentPacked7BitASCII_04() { runner2.runOneTest("alignmentPacked7BitASCII_04") }
  //  DFDL-751 - 7-bit ASCII alignment should be 1 bit, complains that it needs to be 8 bits
  //  @Test def test_alignmentPacked7BitASCII_02() { runner2.runOneTest("alignmentPacked7BitASCII_02") }
  //  @Test def test_alignmentPacked7BitASCII_05() { runner2.runOneTest("alignmentPacked7BitASCII_05") }

  /*** DFDL-379 X-DFDL-US-ASCII-7-BIT-PACKED text ***/
  @Test def test_packed7BitASCII1() { runner2.runOneTest("packed7BitASCII1") }
  @Test def test_packed7BitASCII2() { runner2.runOneTest("packed7BitASCII2") }
  @Test def test_packed7BitASCII3() = { runner2.runOneTest("packed7BitASCII3") }
  @Test def test_packed7BitASCII4() = { runner2.runOneTest("packed7BitASCII4") }
  @Test def test_packed7BitASCII5() = { runner2.runOneTest("packed7BitASCII5") }
  @Test def test_packed7BitASCII6() = { runner2.runOneTest("packed7BitASCII6") }

  @Test def test_packed7BitASCII7() = { runner2.runOneTest("packed7BitASCII7") }
  @Test def test_packed7BitASCII8() = { runner2.runOneTest("packed7BitASCII8") }
  @Test def test_packed7BitASCII9() = { runner2.runOneTest("packed7BitASCII9") }
  @Test def test_packed7BitASCII10() { runner2.runOneTest("packed7BitASCII10") }
  @Test def test_packed7BitASCII_unparse() { runner2.runOneTest("packed7BitASCII_unparse") }
  @Test def test_packed7BitASCII_unparse2() { runner2.runOneTest("packed7BitASCII_unparse2") }

  // DFDL-935 to re-enable, needs encodingErrorPolicy="error"
  //@Test def test_packed7BitASCII_unparse3() { runner2.runOneTest("packed7BitASCII_unparse3") }

  @Test def test_encoding_iso_8859_1() = { runner2.runOneTest("encoding_iso-8859-1") }

  @Test def test_encodingErrorReplace() { runner2.runOneTest("encodingErrorReplace") }
  // JIRA Ticket DFDL-1386 - 4-byte utf-8 characters/surrogate-pair issue.
  // @Test def test_encodingNoError() { runner2.runOneTest("encodingNoError") }
  @Test def test_encodingErrorReplace2() { runner2.runOneTest("encodingErrorReplace2") }
  @Test def test_encodingErrorReplace3() { runner2.runOneTest("encodingErrorReplace3") }
  @Test def test_encodingErrorReplace4() { runner2.runOneTest("encodingErrorReplace4") }
  @Test def test_encoding_property_expression() { runner2.runOneTest("encoding_property_expression") }

  @Test def test_mixedEncoding1() { runner2.runOneTest("mixedEncoding1") }
  @Test def test_mixedEncoding2() { runner2.runOneTest("mixedEncoding2") }

  // Added for JIRA Ticket DFDL-1288
  @Test def test_encodingErrorReplace_unparse() { runner2.runOneTest("encodingErrorReplace_unparse") }
  @Test def test_packed7BitASCII11() { runner2.runOneTest("packed7BitASCII11") }
  @Test def test_packed7BitASCII12() { runner2.runOneTest("packed7BitASCII12") }
  @Test def test_packed6BitASCII1() { runner2.runOneTest("packed6BitASCII1") }
  @Test def test_encoding_property_expression2() { runner2.runOneTest("encoding_property_expression2") }
  @Test def test_encoding_property_expression3() { runner2.runOneTest("encoding_property_expression3") }
  @Test def test_encoding_property_expression4() { runner2.runOneTest("encoding_property_expression4") }
  @Test def test_encoding_property_expression2_unparse() { runner2.runOneTest("encoding_property_expression2_unparse") }
  @Test def test_alignmentPacked6BitASCII() { runner2.runOneTest("alignmentPacked6BitASCII") }
  @Test def test_packed6BitASCII_unparse1() { runner2.runOneTest("packed6BitASCII_unparse1") }
  @Test def test_packed6BitASCII_unparse2() { runner2.runOneTest("packed6BitASCII_unparse2") }
  @Test def test_packed6BitASCII3() { runner2.runOneTest("packed6BitASCII3") }
  @Test def test_packed6BitASCII4() { runner2.runOneTest("packed6BitASCII4") }
  @Test def test_packed6BitASCII5() { runner2.runOneTest("packed6BitASCII5") }
  @Test def test_packed5Bit1() { runner2.runOneTest("packed5Bit1") }
  @Test def test_packed5Bit2() { runner2.runOneTest("packed5Bit2") }
  @Test def test_packed5Bit3() { runner2.runOneTest("packed5Bit3") }
  @Test def test_packed5Bit4() { runner2.runOneTest("packed5Bit4") }
  @Test def test_packed5Bit5() { runner2.runOneTest("packed5Bit5") }
  @Test def test_packed5Bit6() { runner2.runOneTest("packed5Bit6") }
  @Test def test_packed5Bit_unparse1() { runner2.runOneTest("packed5Bit_unparse1") }
  @Test def test_packed5Bit_unparse2() { runner2.runOneTest("packed5Bit_unparse2") }
  @Test def test_packed5Bit_unparse3() { runner2.runOneTest("packed5Bit_unparse3") }
  @Test def test_octalLSBF1() { runner2.runOneTest("octalLSBF1") }
  @Test def test_octalLSBF2() { runner2.runOneTest("octalLSBF2") }
  @Test def test_octalLSBF_unparse1() { runner2.runOneTest("octalLSBF_unparse1") }
  // DFDL-935 to re-enable, needs encodingErrorPolicy="error"
  //@Test def test_octalLSBF_unparse_error() { runner2.runOneTest("octalLSBF_unparse_error") }
  @Test def test_octalLSBF3() { runner2.runOneTest("octalLSBF3") }
  @Test def test_hexLSBF1() { runner2.runOneTest("hexLSBF1") }
  @Test def test_hexLSBF2() { runner2.runOneTest("hexLSBF2") }
  @Test def test_hexLSBF_unparse1() { runner2.runOneTest("hexLSBF_unparse1") }

}
