View Javadoc
1   /*
2    * Copyright (c) 2011-2023 Alex Tunyk <alex at tunyk.com>.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *   https://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,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   *
16   * See the NOTICE file distributed with this work for additional information
17   * regarding copyright ownership.
18   */
19  package com.tunyk.mvn.plugins.htmlcompressor;
20  
21  import org.junit.jupiter.api.AfterAll;
22  import org.junit.jupiter.api.BeforeAll;
23  import org.junit.jupiter.api.BeforeEach;
24  import org.junit.jupiter.api.Test;
25  import org.slf4j.Logger;
26  import org.slf4j.LoggerFactory;
27  
28  /**
29   * The Class XmlCompressorTest.
30   */
31  class XmlCompressorTest {
32  
33      /** The Constant LOG. */
34      private static final Logger LOG = LoggerFactory.getLogger(XmlCompressorTest.class);
35  
36      /**
37       * Sets the up class.
38       */
39      @BeforeAll
40      static void setUpClass() {
41          LOG.info("Setting up class...");
42      }
43  
44      /**
45       * Tear down class.
46       */
47      @AfterAll
48      static void tearDownClass() {
49          LOG.info("Test finished.");
50      }
51  
52      /**
53       * Sets the up.
54       */
55      @BeforeEach
56      void setUp() {
57          LOG.info("Setting up data for testing...");
58      }
59  
60      /**
61       * Test compress.
62       *
63       * @throws Exception
64       *             the exception
65       */
66      @Test
67      void testCompress() throws Exception {
68          LOG.info("Testing compress method...");
69  
70          XmlCompressor xmlCompressor = new XmlCompressor("src/test/resources/xml", "target/test/xmlcompressor/0");
71          xmlCompressor.compress();
72          // TODO: test files where created and every one has the right contents
73  
74          xmlCompressor = new XmlCompressor("src/test/resources/xml", "target/test/xmlcompressor/1");
75          com.googlecode.htmlcompressor.compressor.XmlCompressor xmlCompressorHandler = new com.googlecode.htmlcompressor.compressor.XmlCompressor();
76          xmlCompressorHandler.setEnabled(false);
77          xmlCompressor.setXmlCompressor(xmlCompressorHandler);
78          xmlCompressor.compress();
79          // TODO: verify if provided compression params are picked up
80  
81          LOG.info("Passed");
82      }
83  }