1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package com.puppycrawl.tools.checkstyle.checks;
20
21 import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
22 import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
23 import com.puppycrawl.tools.checkstyle.api.Configuration;
24 import java.io.File;
25 import org.junit.Test;
26
27 import static com.puppycrawl.tools.checkstyle.checks.TranslationCheck.MSG_KEY;
28
29 public class TranslationCheckTest
30 extends BaseCheckTestSupport
31 {
32 @Override
33 protected DefaultConfiguration createCheckerConfig(
34 Configuration checkConfig)
35 {
36 final DefaultConfiguration dc = new DefaultConfiguration("root");
37 dc.addChild(checkConfig);
38 return dc;
39 }
40
41 @Test
42 public void testTranslation() throws Exception
43 {
44 final Configuration checkConfig = createCheckConfig(TranslationCheck.class);
45 final String[] expected = {
46 "0: " + getCheckMessage(MSG_KEY, "only.english"),
47 };
48 final File[] propertyFiles = new File[] {
49 new File(getPath("messages_test_de.properties")),
50 new File(getPath("messages_test.properties")),
51 };
52 verify(
53 createChecker(checkConfig),
54 propertyFiles,
55 getPath("messages_test_de.properties"),
56 expected);
57 }
58
59
60
61
62
63
64
65
66 @Test
67 public void testBaseNameSeparator() throws Exception
68 {
69 final DefaultConfiguration checkConfig = createCheckConfig(TranslationCheck.class);
70 checkConfig.addAttribute("basenameSeparator", "-");
71 final String[] expected = {
72 "0: " + getCheckMessage(MSG_KEY, "only.english"),
73 };
74 final File[] propertyFiles = new File[] {
75 new File(getPath("app-dev.properties")),
76 new File(getPath("app-stage.properties")),
77 };
78 verify(
79 createChecker(checkConfig),
80 propertyFiles,
81 getPath("app-dev.properties"),
82 expected);
83 }
84
85 }