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 HtmlCompressorTest.
27   */
28  class HtmlCompressorTest {
29  
30      /** The Constant LOG. */
31      private static final Logger LOG = LoggerFactory.getLogger(HtmlCompressorTest.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          HtmlCompressor htmlCompressor = new HtmlCompressor("src/test/resources/html", "target/test/htmlcompressor/0");
68          htmlCompressor.compress();
69          // TODO: test files where created and every one has the right contents
70  
71          htmlCompressor = new HtmlCompressor("src/test/resources/html", "target/test/htmlcompressor/1", true,
72                  "target/test/htmlcompressor/1/integration.js", "src/test/resources/html/integration.js");
73          htmlCompressor.compress();
74          // TODO: test json file was created and it has right contents
75  
76          htmlCompressor = new HtmlCompressor("src/test/resources/html", "target/test/htmlcompressor/2");
77          com.googlecode.htmlcompressor.compressor.HtmlCompressor htmlCompressorHandler = new com.googlecode.htmlcompressor.compressor.HtmlCompressor();
78          htmlCompressorHandler.setEnabled(false);
79          htmlCompressor.setHtmlCompressor(htmlCompressorHandler);
80          htmlCompressor.compress();
81          // TODO: verify if provided compression params are picked up
82  
83          LOG.info("Passed");
84      }
85  }