View Javadoc
1   /**
2    * SpamSchutz - simple way to protect your mail addresses from naïve spammers
3    * Copyright (C) 2011, Aiki IT
4    * <p>
5    * This program is free software: you can redistribute it and/or modify
6    * it under the terms of the GNU General Public License as published by
7    * the Free Software Foundation, either version 3 of the License, or
8    * (at your option) any later version.
9    * <p>
10   * This program is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   * GNU General Public License for more details.
14   * <p>
15   * You should have received a copy of the GNU General Public License
16   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17   */
18  package de.aikiit.spamprotector;
19  
20  import org.apache.logging.log4j.LogManager;
21  import org.apache.logging.log4j.Logger;
22  import org.junit.Test;
23  import org.junit.experimental.categories.Category;
24  
25  import static de.aikiit.spamprotector.util.LocalizationHelper.getParameterizedBundleString;
26  import static org.junit.Assert.*;
27  
28  /**
29   * Verifies the UI components work properly.
30   */
31  @Category(UITest.class)
32  public class GUITest {
33  
34      /**
35       * Logger.
36       */
37      private static final Logger LOG =
38              LogManager.getLogger(GUITest.class);
39  
40      @Test
41      public final void startGui() {
42          GUI gui = new GUI();
43          assertNotNull(gui);
44      }
45  
46      @Test
47      public final void ensureYearIs4digits() {
48          String year = String.valueOf(GUI.now.getYear());
49          assertEquals(4, year.length());
50  
51          String msg = getParameterizedBundleString("spamschutz.ui.help.text",
52                  year,
53                  de.aikiit.spamprotector.util.Version.VERSION);
54  
55          LOG.debug(msg);
56  
57          assertFalse(msg.contains(year.charAt(0) + "."));
58      }
59  }