use of org.apache.xmlrpc.client.XmlRpcClient in project maven-plugins by apache.
the class TracDownloader method getIssueList.
public List<Issue> getIssueList() throws MalformedURLException, XmlRpcException {
// Create and configure an XML-RPC client
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
try {
config.setServerURL(new URL(getUrl() + "/login/xmlrpc"));
} catch (MalformedURLException e) {
throw new MalformedURLException("The Trac URL is incorrect.");
}
config.setBasicUserName(tracUser);
config.setBasicPassword(tracPassword);
XmlRpcClient client = new XmlRpcClient();
client.setConfig(config);
client.setTransportFactory(new XmlRpcCommonsTransportFactory(client));
// Fetch issues
String qstr = "";
if (!StringUtils.isEmpty(query)) {
qstr = query;
}
Object[] params = new Object[] { qstr };
Object[] queryResult;
ArrayList<Issue> issueList = new ArrayList<Issue>();
try {
queryResult = (Object[]) client.execute("ticket.query", params);
for (Object aQueryResult : queryResult) {
params = new Object[] { aQueryResult };
Object[] ticketGetResult;
ticketGetResult = (Object[]) client.execute("ticket.get", params);
issueList.add(createIssue(ticketGetResult));
}
} catch (XmlRpcException e) {
throw new XmlRpcException("XmlRpc Error.", e);
}
return issueList;
}
use of org.apache.xmlrpc.client.XmlRpcClient in project cloudstack by apache.
the class Connection method getXmlClient.
private XmlRpcClient getXmlClient() {
XmlRpcClient client = new XmlRpcClient();
URL url;
try {
url = new URL("http://" + _ip + ":" + _port.toString());
_config.setTimeZone(TimeZone.getTimeZone("UTC"));
_config.setServerURL(url);
// disable, we use asyncexecute to control timeout
_config.setReplyTimeout(0);
_config.setConnectionTimeout(6000);
_config.setBasicUserName(_username);
_config.setBasicPassword(_password);
client.setConfig(_config);
} catch (MalformedURLException e) {
throw new CloudRuntimeException(e.getMessage());
}
return client;
}
use of org.apache.xmlrpc.client.XmlRpcClient in project cloudstack by apache.
the class NotAValidCommand method testMaintainCommand.
@Test
public void testMaintainCommand() {
// This test needs further work.
final String uuid = "befc4dcd-f5c6-4015-8791-3c18622b7c7f";
final Connection conn = Mockito.mock(Connection.class);
final XsHost xsHost = Mockito.mock(XsHost.class);
final XmlRpcClient client = Mockito.mock(XmlRpcClient.class);
// final Host.Record hr = PowerMockito.mock(Host.Record.class);
// final Host host = PowerMockito.mock(Host.class);
final MaintainCommand maintainCommand = new MaintainCommand();
final Map<String, Object> map = new Hashtable<String, Object>();
map.put("Value", "Xen");
final Map<String, Object> spiedMap = spy(map);
final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
assertNotNull(wrapper);
when(citrixResourceBase.getConnection()).thenReturn(conn);
when(citrixResourceBase.getHost()).thenReturn(xsHost);
when(xsHost.getUuid()).thenReturn(uuid);
when(conn.getSessionReference()).thenReturn("befc4dcd");
try {
final Object[] params = { Marshalling.toXMLRPC("befc4dcd"), Marshalling.toXMLRPC(uuid) };
when(client.execute("host.get_by_uuid", new Object[] { "befc4dcd", uuid })).thenReturn(spiedMap);
PowerMockito.when(conn, "dispatch", "host.get_by_uuid", params).thenReturn(spiedMap);
} catch (final Exception e) {
fail(e.getMessage());
}
// try {
// PowerMockito.mockStatic(Host.class);
// //BDDMockito.given(Host.getByUuid(conn,
// xsHost.getUuid())).willReturn(host);
// PowerMockito.when(Host.getByUuid(conn,
// xsHost.getUuid())).thenReturn(host);
// PowerMockito.verifyStatic(times(1));
// } catch (final BadServerResponse e) {
// fail(e.getMessage());
// } catch (final XenAPIException e) {
// fail(e.getMessage());
// } catch (final XmlRpcException e) {
// fail(e.getMessage());
// }
//
// PowerMockito.mockStatic(Types.class);
// PowerMockito.when(Types.toHostRecord(spiedMap)).thenReturn(hr);
// PowerMockito.verifyStatic(times(1));
//
// try {
// PowerMockito.mockStatic(Host.Record.class);
// when(host.getRecord(conn)).thenReturn(hr);
// verify(host, times(1)).getRecord(conn);
// } catch (final BadServerResponse e) {
// fail(e.getMessage());
// } catch (final XenAPIException e) {
// fail(e.getMessage());
// } catch (final XmlRpcException e) {
// fail(e.getMessage());
// }
final Answer answer = wrapper.execute(maintainCommand, citrixResourceBase);
assertFalse(answer.getResult());
}
use of org.apache.xmlrpc.client.XmlRpcClient in project dubbo by alibaba.
the class XmlRpcProxyFactoryBean method afterPropertiesSet.
/**
* {@inheritDoc}
*/
@Override
@SuppressWarnings("unchecked")
public void afterPropertiesSet() {
super.afterPropertiesSet();
// create proxy
proxyObject = ProxyFactory.getProxy(getServiceInterface(), this);
// create XmlRpcHttpClient
try {
xmlRpcClient = new XmlRpcClient();
XmlRpcClientConfigImpl xmlRpcClientConfig = new XmlRpcClientConfigImpl();
xmlRpcClientConfig.setServerURL(new URL(getServiceUrl()));
xmlRpcClient.setConfig(xmlRpcClientConfig);
} catch (MalformedURLException mue) {
throw new RpcException(mue);
}
}
use of org.apache.xmlrpc.client.XmlRpcClient in project camel by apache.
the class XmlRpcEndpointTest method testClientConfigurer.
@Test
public void testClientConfigurer() throws Exception {
camelContext.start();
XmlRpcEndpoint endpoint = (XmlRpcEndpoint) camelContext.getEndpoint("xmlrpc:http://www.example.com?clientConfigurer=#myClientConfigurer");
XmlRpcClient client = endpoint.createClient();
assertEquals("Get a worng maxThreads", 10, client.getMaxThreads());
assertEquals("Get a wrong value of enabledForExtensions", true, ((XmlRpcClientConfigImpl) client.getClientConfig()).isEnabledForExtensions());
}
Aggregations