1
2
3
4 package org.whatsitcalled.maven.plugins;
5
6 import java.io.File;
7 import java.io.FileNotFoundException;
8 import java.io.IOException;
9 import java.net.MalformedURLException;
10 import java.net.URL;
11
12 import javax.xml.namespace.QName;
13
14 import org.apache.commons.io.FileUtils;
15 import org.apache.cxf.interceptor.LoggingInInterceptor;
16 import org.apache.cxf.interceptor.LoggingOutInterceptor;
17 import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
18 import org.apache.maven.plugin.AbstractMojo;
19 import org.apache.maven.plugin.MojoExecutionException;
20 import org.apache.maven.plugin.MojoFailureException;
21 import org.whatsitcalled.webflange.service.TestService;
22 import org.whatsitcalled.webflange.service.TestTO;
23
24
25
26
27
28 public class WebFlangeRunPlugin extends AbstractMojo {
29
30
31
32
33
34 private String serviceURL;
35
36
37
38
39 private File dir;
40
41
42
43
44 private String scriptName;
45
46
47
48
49 private String propertiesName;
50
51
52
53
54 private String testName;
55
56
57
58
59 private String projectName;
60
61
62
63
64 private String description;
65
66
67
68
69 public void execute() throws MojoExecutionException, MojoFailureException {
70
71 String properties = "";
72 try {
73 properties = FileUtils.readFileToString(new File(dir, propertiesName));
74 } catch (IOException e) {
75 getLog().error("Unable to read properties file: " + dir + "/" + propertiesName, e);
76 }
77
78
79 String scriptCode = "";
80 try {
81 scriptCode = FileUtils.readFileToString(new File(dir, scriptName));
82 } catch (IOException e) {
83 getLog().error("Unable to read script file: " + dir + "/" + scriptName, e);
84 }
85
86 TestTO request = new TestTO();
87 request.setDescription(description);
88 request.setProjectName(projectName);
89 request.setTestName(testName);
90 request.setProperties(properties);
91 request.setScript(scriptCode);
92
93 JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
94 factory.getInInterceptors().add(new LoggingInInterceptor());
95 factory.getOutInterceptors().add(new LoggingOutInterceptor());
96 factory.setServiceClass(TestService.class);
97 factory.setAddress(serviceURL);
98 TestService client = (TestService) factory.create();
99
100 getLog().debug("Invoking createLoadTest...");
101 java.lang.Long _createLoadTest__return = client.createAndRun(request);
102 getLog().debug("createLoadTest.result=" + _createLoadTest__return);
103
104 }
105
106 }