View Javadoc
1   /*
2    *    Copyright 2011-2025 the original author or authors.
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  package com.tunyk.mvn.plugins.htmlcompressor;
17  
18  import org.junit.jupiter.api.AfterAll;
19  import org.junit.jupiter.api.BeforeAll;
20  import org.junit.jupiter.api.BeforeEach;
21  import org.junit.jupiter.api.Test;
22  import org.slf4j.Logger;
23  import org.slf4j.LoggerFactory;
24  
25  /**
26   * The Class XmlCompressorTest.
27   */
28  class XmlCompressorTest {
29  
30      /** The Constant LOG. */
31      private static final Logger LOG = LoggerFactory.getLogger(XmlCompressorTest.class);
32  
33      /**
34       * Sets the up class.
35       */
36      @BeforeAll
37      static void setUpClass() {
38          LOG.info("Setting up class...");
39      }
40  
41      /**
42       * Tear down class.
43       */
44      @AfterAll
45      static void tearDownClass() {
46          LOG.info("Test finished.");
47      }
48  
49      /**
50       * Sets the up.
51       */
52      @BeforeEach
53      void setUp() {
54          LOG.info("Setting up data for testing...");
55      }
56  
57      /**
58       * Test compress.
59       *
60       * @throws Exception
61       *             the exception
62       */
63      @Test
64      void testCompress() throws Exception {
65          LOG.info("Testing compress method...");
66  
67          XmlCompressor xmlCompressor = new XmlCompressor("src/test/resources/xml", "target/test/xmlcompressor/0");
68          xmlCompressor.compress();
69          // TODO: test files where created and every one has the right contents
70  
71          xmlCompressor = new XmlCompressor("src/test/resources/xml", "target/test/xmlcompressor/1");
72          com.googlecode.htmlcompressor.compressor.XmlCompressor xmlCompressorHandler = new com.googlecode.htmlcompressor.compressor.XmlCompressor();
73          xmlCompressorHandler.setEnabled(false);
74          xmlCompressor.setXmlCompressor(xmlCompressorHandler);
75          xmlCompressor.compress();
76          // TODO: verify if provided compression params are picked up
77  
78          LOG.info("Passed");
79      }
80  }