Search in sources :

Example 16 with THttpClient

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"));
}
Also used : VendorService(org.eclipse.sw360.datahandler.thrift.vendors.VendorService) TProtocol(org.apache.thrift.protocol.TProtocol) THttpClient(org.apache.thrift.transport.THttpClient) Vendor(org.eclipse.sw360.datahandler.thrift.vendors.Vendor) TCompactProtocol(org.apache.thrift.protocol.TCompactProtocol) THttpClient(org.apache.thrift.transport.THttpClient)

Example 17 with THttpClient

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() + ")");
    }
}
Also used : TProtocol(org.apache.thrift.protocol.TProtocol) SearchService(org.eclipse.sw360.datahandler.thrift.search.SearchService) THttpClient(org.apache.thrift.transport.THttpClient) SearchResult(org.eclipse.sw360.datahandler.thrift.search.SearchResult) TCompactProtocol(org.apache.thrift.protocol.TCompactProtocol) THttpClient(org.apache.thrift.transport.THttpClient)

Example 18 with THttpClient

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());
// }
}
Also used : TProtocol(org.apache.thrift.protocol.TProtocol) THttpClient(org.apache.thrift.transport.THttpClient) ProjectService(org.eclipse.sw360.datahandler.thrift.projects.ProjectService) TCompactProtocol(org.apache.thrift.protocol.TCompactProtocol) THttpClient(org.apache.thrift.transport.THttpClient)

Example 19 with THttpClient

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());
}
Also used : TProtocol(org.apache.thrift.protocol.TProtocol) THttpClient(org.apache.thrift.transport.THttpClient) ComponentService(org.eclipse.sw360.datahandler.thrift.components.ComponentService) TCompactProtocol(org.apache.thrift.protocol.TCompactProtocol) THttpClient(org.apache.thrift.transport.THttpClient)

Example 20 with THttpClient

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);
}
Also used : TestService(net.morimekta.test.providence.service.TestService) Request(net.morimekta.test.providence.service.Request) THttpClient(org.apache.thrift.transport.THttpClient) Response(net.morimekta.test.providence.service.Response) TBinaryProtocol(org.apache.thrift.protocol.TBinaryProtocol) PServiceCall(net.morimekta.providence.PServiceCall) ApacheHttpTransport(com.google.api.client.http.apache.ApacheHttpTransport) THttpClient(org.apache.thrift.transport.THttpClient) Test(org.junit.Test)

Aggregations

THttpClient (org.apache.thrift.transport.THttpClient)51 TProtocol (org.apache.thrift.protocol.TProtocol)34 TCompactProtocol (org.apache.thrift.protocol.TCompactProtocol)18 TBinaryProtocol (org.apache.thrift.protocol.TBinaryProtocol)12 TJSONProtocol (org.apache.thrift.protocol.TJSONProtocol)9 Test (org.junit.Test)9 TTransport (org.apache.thrift.transport.TTransport)8 Hbase (org.apache.hadoop.hbase.thrift.generated.Hbase)5 DefaultHttpClient (org.apache.http.impl.client.DefaultHttpClient)5 RequestData (org.simbasecurity.api.service.thrift.RequestData)5 ApacheHttpTransport (com.google.api.client.http.apache.ApacheHttpTransport)4 IOException (java.io.IOException)4 PServiceCall (net.morimekta.providence.PServiceCall)4 TestService (net.morimekta.test.providence.service.TestService)4 Client (org.simbasecurity.api.service.thrift.AuthenticationFilterService.Client)4 HashMap (java.util.HashMap)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 TCLIService (org.apache.hive.service.rpc.thrift.TCLIService)3 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)3 ActionDescriptor (org.simbasecurity.api.service.thrift.ActionDescriptor)3