use of org.apache.thrift.transport.THttpClient in project sw360portal by sw360.
the class TestVendorClient method main.
public static void main(String[] args) throws TException, IOException {
THttpClient thriftClient = new THttpClient("http://127.0.0.1:8080/vendorservice/thrift");
TProtocol protocol = new TCompactProtocol(thriftClient);
VendorService.Iface client = new VendorService.Client(protocol);
List<Vendor> vendors = client.getAllVendors();
reportFindings(vendors);
System.out.println("Now looking for matches starting with 'm' from vendor service");
reportFindings(client.searchVendors("m"));
}
use of org.apache.thrift.transport.THttpClient in project sw360portal by sw360.
the class TestSearchClient method main.
public static void main(String[] args) throws TException, IOException {
THttpClient thriftClient = new THttpClient("http://127.0.0.1:8080/search/thrift");
TProtocol protocol = new TCompactProtocol(thriftClient);
SearchService.Iface client = new SearchService.Client(protocol);
List<SearchResult> results = client.search(searchtext, null);
// List<SearchResult> results = new SearchHandler().search(searchtext);
// http://localhost:5984/_fti/local/sw360db/_design/lucene/all?q=type:project%20AND%20P1*
System.out.println("Fetched " + results.size() + " from search service");
for (SearchResult result : results) {
System.out.println(result.getId() + "(" + result.getType() + "): " + result.getName() + " (" + result.getScore() + ")");
}
}
use of org.apache.thrift.transport.THttpClient in project sw360portal by sw360.
the class TestProjectClient method main.
public static void main(String[] args) throws TException, IOException {
THttpClient thriftClient = new THttpClient("http://127.0.0.1:8080/projects/thrift");
TProtocol protocol = new TCompactProtocol(thriftClient);
ProjectService.Iface client = new ProjectService.Client(protocol);
// User cedric = new User().setEmail("cedric.bodet@tngtech.com").setDepartment("CT BE OSS TNG CB");
// Project myProject = new Project().setName("First project").setDescription("My first project");
// client.addProject(myProject, cedric);
// List<Project> projects = client.getBUProjectsSummary("CT BE OSS");
// System.out.println("Fetched " + projects.size() + " from project service");
// for (Project project : projects) {
// System.out.println(project.toString());
// }
}
use of org.apache.thrift.transport.THttpClient in project sw360portal by sw360.
the class TestComponentClient method main.
public static void main(String[] args) throws TException, IOException {
THttpClient thriftClient = new THttpClient("http://127.0.0.1:8080/components/thrift");
TProtocol protocol = new TCompactProtocol(thriftClient);
ComponentService.Iface client = new ComponentService.Client(protocol);
// List<Component> components = client.getComponentSummary(user);
// List<Component> recentComponents = client.getRecentComponents();
// List<Release> releases = client.getReleaseSummary(user);
//
// System.out.println("Fetched " + components.size() + " components from license service");
// System.out.println("Fetched " + releases.size() + " releases from license service");
// System.out.println("Fetched " + recentComponents.size() + " recent components from license service");
//
// String referenceId =null;
// for (Component component : recentComponents) {
// if(referenceId==null) referenceId=component.getId();
// System.out.println(component.getId() + ": " + component.getName());
// }
//
// if(referenceId!=null) {
// System.out.println(client.getComponentById(referenceId, user).toString());
// Component component = new ComponentHandler("http://localhost:5984", "sw360db", "sw360attachments").getComponentById(referenceId, user);
// System.out.println(component.toString());
// System.out.println(client.getComponentById(referenceId, user).toString());
// }
//
// for(Release release : releases) {
// System.out.println(release.toString());
// }
// // This fails with a thrift error... debug!
// if(releases.size()>0) {
// String releaseNameStart = releases.get(0).getName().substring(0,1);
// System.out.println("The following releases start with " + releaseNameStart );
//
// List<Release> releases1 = client.searchReleaseByName(releaseNameStart);
// for(Release release : releases1) {
// System.out.println(release.toString());
// }
//
// }
// final Component cpe = client.getComponentForReportFromCPEId("cpe");
// System.out.println(cpe.toString());
}
use of org.apache.thrift.transport.THttpClient in project providence by morimekta.
the class ProvidenceServlet_ThriftClientTest method testThriftClient.
@Test
public void testThriftClient() throws TException, IOException, Failure {
ApacheHttpTransport transport = new ApacheHttpTransport();
THttpClient httpClient = new THttpClient(endpoint().toString(), transport.getHttpClient());
TBinaryProtocol protocol = new TBinaryProtocol(httpClient);
net.morimekta.test.thrift.service.TestService.Iface client = new net.morimekta.test.thrift.service.TestService.Client(protocol);
doAnswer(i -> new Response("reply")).when(impl).test(any(Request.class));
net.morimekta.test.thrift.service.Response response = client.test(new net.morimekta.test.thrift.service.Request("call"));
assertThat(response.getText(), is("reply"));
verify(impl).test(any(Request.class));
verify(instrumentation).onComplete(anyDouble(), any(PServiceCall.class), any(PServiceCall.class));
verifyNoMoreInteractions(impl, instrumentation);
}
Aggregations