1   package org.sourceforge.xradar.statics;
2   
3   import static org.junit.Assert.assertTrue;
4   
5   import java.io.File;
6   import java.io.IOException;
7   import java.net.MalformedURLException;
8   
9   import org.junit.Ignore;
10  import org.junit.Test;
11  import org.sourceforge.xradar.AbstractTestForCommandLine;
12  import org.sourceforge.xradar.XRadarException;
13  
14  /**
15   * @author Zahir NUCKCHADY
16   **/
17  
18  public class BasicRunScenario extends AbstractTestForCommandLine {
19  		
20  	public BasicRunScenario() {
21  		super();
22  		testProductsDirectory = "targetStatics";
23  		target  = targetDirectory + File.separator + testProductsDirectory;
24  	}
25  
26  	/**
27  	 * Basic compulsory and optional arguments needed to run XRadar 
28  	 * and generate Static Reports
29  	 * Note: The Array size (arg) has to be modified prior to the number of arguments passed, else the reports won't be generated 
30  	 */
31  	@Test
32  	public void BasicCommands() throws MalformedURLException, IOException, XRadarException {
33  		// Contains Basic Commands
34  		String arg[]  = new String[9];
35  		arg[0] = "static";
36  		arg[1] = "--jdepend";
37  		arg[2] = "src/test/resources/jdepend_report.xml";
38  		arg[3] = "--xradarConfig";
39  		arg[4] = "src/test/resources/radar-config.xml";
40  		arg[5] = "--properties";
41  		arg[6] = "src/test/resources/release1.properties";
42  		arg[7] = "--target";
43  		arg[8] = target;
44  		assertTrue(this.runRadar(arg,""));		
45  	}
46  	
47  	@Ignore	//FIXME: Not ready yet , simply missing some appropriate classes files...
48  	@Test
49  	public void BasicCommandsWithoutJdepend() throws MalformedURLException, IOException, XRadarException {
50  		// Contains Basic Commands without jdepend
51  		String arg[]  = new String[9];
52  		arg[0] = "static";
53  		arg[1] = "--classes";
54  		arg[2] = ""; // A definir une classe
55  		arg[3] = "--xradarConfig";
56  		arg[4] = "src/test/resources/radar-config.xml";
57  		arg[5] = "--properties";
58  		arg[6] = "src/test/resources/release1.properties";
59  		arg[7] = "--target";
60  		arg[8] = target;
61  		assertTrue(this.runRadar(arg,""));		
62  	}
63  
64  	@Test
65  	public void jdependPmd() throws MalformedURLException, IOException, XRadarException {	
66  		/** Generate Jdepend & PMD reports */ 
67  		String arg[]  = new String[16];
68  		arg[0] = "static";
69  		arg[1] = "--jdepend";
70  		arg[2] = "src/test/resources/jdepend_report.xml";
71  		arg[3] = "--xradarConfig";
72  		arg[4] = "src/test/resources/radar-config.xml";
73  		arg[5] = "--properties";
74  		arg[6] = "src/test/resources/release1.properties";
75  		arg[7] = "--target";
76  		arg[8] = target;
77  		arg[9] = "--pmd";
78  		arg[10] = "src/test/resources/pmd_report.xml";
79  		arg[11] = "--javadocRoot";
80  		arg[12] = target; // FIXME: this is convenient but no really pertinent !
81  		arg[13] = "--javadocEnabled";
82  		arg[14] = "--online";
83  		arg[15] = "--debug";
84  		assertTrue(this.runRadar(arg,""));		
85  	}
86  
87  	@Test
88  	public void jdependPmdCkjm() throws MalformedURLException, IOException, XRadarException {	
89  		/** Generate Jdepend, PMD & CKJM reports */ 
90  		String arg[]  = new String[18];
91  		arg[0] = "static";
92  		arg[1] = "--jdepend";
93  		arg[2] = "src/test/resources/jdepend_report.xml";
94  		arg[3] = "--xradarConfig";
95  		arg[4] = "src/test/resources/radar-config.xml";
96  		arg[5] = "--properties";
97  		arg[6] = "src/test/resources/release1.properties";
98  		arg[7] = "--target";
99  		arg[8] = target;
100 		arg[9] = "--pmd";
101 		arg[10] = "src/test/resources/pmd_report.xml";
102 		arg[11] = "--ckjm";
103 		arg[12] = "src/test/resources/ckjm_report.xml";
104 		arg[13] = "--javadocRoot";
105 		arg[14] = target; // FIXME: this is convenient but no really pertinent !
106 		arg[15] = "--javadocEnabled";
107 		arg[16] = "--online";
108 		arg[17] = "--debug";
109 		assertTrue(this.runRadar(arg,""));		
110 	}
111 
112 	@Test
113 	public void jdependPmdCkjmCheckstyle() throws MalformedURLException, IOException, XRadarException {		
114 		/** Generate Jdepend, PMD, CKJM & Checkstyle reports */ 
115 		String arg[]  = new String[20];
116 		arg[0] = "static";
117 		arg[1] = "--jdepend";
118 		arg[2] = "src/test/resources/jdepend_report.xml";
119 		arg[3] = "--xradarConfig";
120 		arg[4] = "src/test/resources/radar-config.xml";
121 		arg[5] = "--properties";
122 		arg[6] = "src/test/resources/release1.properties";
123 		arg[7] = "--target";
124 		arg[8] = target;
125 		arg[9] = "--pmd";
126 		arg[10] = "src/test/resources/pmd_report.xml";
127 		arg[11] = "--ckjm";
128 		arg[12] = "src/test/resources/ckjm_report.xml";
129 		arg[13] = "--checkstyle";
130 		arg[14] = "src/test/resources/checkstyle_report.xml";
131 		arg[15] = "--javadocRoot";
132 		arg[16] = target; // FIXME: this is convenient but no really pertinent !
133 		arg[17] = "--javadocEnabled";
134 		arg[18] = "--online";
135 		arg[19] = "--debug";
136 		assertTrue(this.runRadar(arg,""));		
137 	}
138 
139 	@Test
140 	public void jdependPmdCkjmCheckstyleCpd() throws MalformedURLException, IOException, XRadarException {		
141 		/** Comment the Basic Commands and Uncomment this one to generate Jdepend, PMD, CKJM, Checkstyle & CPD reports */ 
142 		String arg[]  = new String[22];
143 		arg[0] = "static";
144 		arg[1] = "--jdepend";
145 		arg[2] = "src/test/resources/jdepend_report.xml";
146 		arg[3] = "--xradarConfig";
147 		arg[4] = "src/test/resources/radar-config.xml";
148 		arg[5] = "--properties";
149 		arg[6] = "src/test/resources/release1.properties";
150 		arg[7] = "--target";
151 		arg[8] = target;
152 		arg[9] = "--pmd";
153 		arg[10] = "src/test/resources/pmd_report.xml";
154 		arg[11] = "--ckjm";
155 		arg[12] = "src/test/resources/ckjm_report.xml";
156 		arg[13] = "--checkstyle";
157 		arg[14] = "src/test/resources/checkstyle_report.xml";
158 		arg[15] = "--cpd";
159 		arg[16] = "src/test/resources/cpd_report.xml";
160 		arg[17] = "--javadocRoot";
161 		arg[18] = target; // FIXME: this is convenient but no really pertinent !
162 		arg[19] = "--javadocEnabled";
163 		arg[20] = "--online";
164 		arg[21] = "--debug";
165 		assertTrue(this.runRadar(arg,""));		
166 	}
167 
168 	@Test
169 	public void jdependPmdCkjmCheckstyleCpdJavanCss() throws MalformedURLException, IOException, XRadarException {		
170 		/** Generate Jdepend, PMD, CKJM, Checkstyle, CPD & JavaNCSS reports */ 	
171 		String arg[]  = new String[24];
172 		arg[0] = "static";
173 		arg[1] = "--jdepend";
174 		arg[2] = "src/test/resources/jdepend_report.xml";
175 		arg[3] = "--xradarConfig";
176 		arg[4] = "src/test/resources/radar-config.xml";
177 		arg[5] = "--properties";
178 		arg[6] = "src/test/resources/release1.properties";
179 		arg[7] = "--target";
180 		arg[8] = target;
181 		arg[9] = "--pmd";
182 		arg[10] = "src/test/resources/pmd_report.xml";
183 		arg[11] = "--checkstyle";
184 		arg[12] = "src/test/resources/checkstyle_report.xml";
185 		arg[13] = "--cpd";
186 		arg[14] = "src/test/resources/cpd_report.xml";
187 		arg[15] = "--ckjm";
188 		arg[16] = "src/test/resources/ckjm_report.xml";
189 		arg[17] = "--javancss";
190 		arg[18] = "src/test/resources/javancss_report.xml";
191 		arg[19] = "--javadocRoot";
192 		arg[20] = target; // FIXME: this is convenient but no really pertinent !
193 		arg[21] = "--javadocEnabled";
194 		arg[22] = "--online";
195 		arg[23] = "--debug";
196 		assertTrue(this.runRadar(arg,""));		
197 	}
198 }