1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package org.nuiton.jaxx.plugin;
24
25 import org.apache.commons.logging.Log;
26 import org.apache.commons.logging.LogFactory;
27 import org.apache.maven.plugin.MojoExecutionException;
28
29
30 import org.apache.maven.plugin.logging.SystemStreamLog;
31 import org.junit.Test;
32 import static org.junit.Assert.*;
33
34 public class Evolution74Test extends JaxxBaseTest {
35
36
37 private static final Log log = LogFactory.getLog(Evolution74Test.class);
38
39 @Test
40 public void ok() throws Exception {
41 GenerateMojo mojo = getMojo();
42 mojo.execute();
43 assertNumberJaxxFiles(6);
44
45 checkPattern(mojo, "JComboBox", true, "org/nuiton/jaxx/plugin/evolution74Test/ok/swingcombo.java");
46 checkPattern(mojo, "JComboBox", false, "org/nuiton/jaxx/plugin/evolution74Test/ok/jaxxcombo.java");
47 checkPattern(mojo, "JAXXComboBox", false, "org/nuiton/jaxx/plugin/evolution74Test/ok/swingcombo.java");
48 checkPattern(mojo, "JAXXComboBox", true, "org/nuiton/jaxx/plugin/evolution74Test/ok/jaxxcombo.java");
49
50 checkPattern(mojo, "JList", true, "org/nuiton/jaxx/plugin/evolution74Test/ok/swinglist.java");
51 checkPattern(mojo, "JList", false, "org/nuiton/jaxx/plugin/evolution74Test/ok/jaxxlist.java");
52 checkPattern(mojo, "JAXXList", false, "org/nuiton/jaxx/plugin/evolution74Test/ok/swinglist.java");
53 checkPattern(mojo, "JAXXList", true, "org/nuiton/jaxx/plugin/evolution74Test/ok/jaxxlist.java");
54
55 checkPattern(mojo, "JTree", true, "org/nuiton/jaxx/plugin/evolution74Test/ok/swingtree.java");
56 checkPattern(mojo, "JTree", false, "org/nuiton/jaxx/plugin/evolution74Test/ok/jaxxtree.java");
57 checkPattern(mojo, "JAXXTree", false, "org/nuiton/jaxx/plugin/evolution74Test/ok/swingtree.java");
58 checkPattern(mojo, "JAXXTree", true, "org/nuiton/jaxx/plugin/evolution74Test/ok/jaxxtree.java");
59 }
60
61 @SuppressWarnings({"unchecked"})
62 @Test
63 public void error() throws Exception {
64 GenerateMojo mojo = getMojo();
65
66 mojo.init();
67
68 assertNumberJaxxFiles(3);
69
70 mojo.setLog(new SystemStreamLog() {
71
72 @Override
73 public boolean isErrorEnabled() {
74 return false;
75 }
76
77 @Override
78 public void error(Throwable error) {
79
80 }
81
82 @Override
83 public void error(CharSequence content) {
84
85 }
86
87 @Override
88 public void error(CharSequence content, Throwable error) {
89
90 }
91 });
92
93
94 for (String file : mojo.files) {
95 log.info("test bad file " + file);
96 mojo.files = new String[]{file};
97 try {
98 mojo.doAction();
99
100 fail();
101 } catch (MojoExecutionException e) {
102
103 assertTrue(true);
104 assertError(mojo.getEngine(), file, 1);
105 }
106 }
107 }
108 }