/** * This test will send a request to the server using the greetServer method in GreetingService and * verify the response. */ public void testGreetingService() { // Create the service that we will test. GreetingServiceAsync greetingService = GWT.create(GreetingService.class); ServiceDefTarget target = (ServiceDefTarget) greetingService; target.setServiceEntryPoint(GWT.getModuleBaseURL() + "Project004/greet"); // Since RPC calls are asynchronous, we will need to wait for a response // after this test method returns. This line tells the test runner to wait // up to 10 seconds before timing out. delayTestFinish(10000); // Send a request to the server. greetingService.greetServer( "GWT User", new AsyncCallback<String>() { public void onFailure(Throwable caught) { // The request resulted in an unexpected error. fail("Request failure: " + caught.getMessage()); } public void onSuccess(String result) { // Verify that the response is correct. assertTrue(result.startsWith("Hello, GWT User!")); // Now that we have received a response, we need to tell the test runner // that the test is complete. You must call finishTest() after an // asynchronous test finishes successfully, or the test will time out. finishTest(); } }); }
public void inicializarUI() { greetingService.darCategorias( new AsyncCallback<Categorias[]>() { public void onFailure(Throwable caught) { System.out.println("Pailas"); caught.printStackTrace(); } public void onSuccess(Categorias[] result) { categorias = result; inicializarMenu(); } }); }
private void consultarAlgoritmosCategoria(final int pos, final int idCategoria) { greetingService.darAlgoritmosCategoria( idCategoria, new AsyncCallback<AlgoritmoCategoria[]>() { public void onFailure(Throwable caught) { caught.printStackTrace(); } public void onSuccess(AlgoritmoCategoria[] result) { algoritmos[pos] = new AlgoritmoCategoria[result.length]; for (int i = 0; i < result.length; ++i) agregarAlgoritmoCategoria(pos, algoritmos[pos][i] = result[i]); } }); }