final HttpClient httpClient = new HttpClient();
final XmlRpcClient rpcClient = new XmlRpcClient();
final XmlRpcCommonsTransportFactory factory = new XmlRpcCommonsTransportFactory(rpcClient);
final XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();

factory.setHttpClient(httpClient);
rpcClient.setTransportFactory(factory);
config.setServerURL(new URL(“http://192.168.12.13/xmlrpc.cgi”));
rpcClient.setConfig(config);

// map of the login data
final Map<String, String> loginMap = new HashMap<String, String>();

loginMap.put(“login”, userName);

loginMap.put(“password”, password);
loginMap.put(“rememberlogin”, “Bugzilla_remember”);

// login to bugzilla
final Object loginResult = rpcClient.execute(“User.login”, new Object[] {loginMap});
System.out.println(“loginResult=” + loginResult);

final Map issueParamsMap = new HashMap<String, String>();
issueParamsMap.put(“product”, “TestProduct”);
issueParamsMap.put(“component”, “testComponent”);
issueParamsMap.put(“summary”, “Bug created from java xmlrpc”);
issueParamsMap.put(“description”, “This is text including stacktrace”);
issueParamsMap.put(“version”, “unspecified”);
issueParamsMap.put(“op_sys”, “Linux”);
issueParamsMap.put(“platform”, “PC”);
issueParamsMap.put(“priority”, “Highest”);
issueParamsMap.put(“severity”, “Normal”);
issueParamsMap.put(“status”, “NEW”);
issueParamsMap.put(“estimated_time”, “2”);

final Object createResult = rpcClient.execute(“Bug.create”, new Object[] {issueParamsMap});

System.out.println(“createResult = ” + createResult);

pom dependencies and plugins:

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>org.apache.xmlrpc</groupId>
<artifactId>xmlrpc-client</artifactId>
<version>3.1.3</version>
</dependency>
<dependency>
<!– com/open/jacekkowalczyk/xml-to-map/1.0-SNAPSHOT –>
<groupId>com.open.jacekkowalczyk</groupId>
<artifactId>xml-to-map</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>

</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<encoding>UTF-8</encoding>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.tomtom.cpu.coredb.xmlrpc.bugzilla.BugzillaIssuesCreator</mainClass>
</manifest>
<manifestEntries>
<buildVersion>${project.version}</buildVersion>
<SCM-Revision>${buildNumber}</SCM-Revision>
<SCM-Timestamp>${timestamp}</SCM-Timestamp>
</manifestEntries>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>
</build>

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s