| 1,3 → 1,27 |
| /** |
| * JOnAS: Java(TM) Open Application Server |
| * Copyright (C) 2012 Bull S.A.S. |
| * Contact: jonas-team@ow2.org |
| * |
| * This library is free software; you can redistribute it and/or |
| * modify it under the terms of the GNU Lesser General Public |
| * License as published by the Free Software Foundation; either |
| * version 2.1 of the License, or (at your option) any later version. |
| * |
| * This library is distributed in the hope that it will be useful, |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| * Lesser General Public License for more details. |
| * |
| * You should have received a copy of the GNU Lesser General Public |
| * License along with this library; if not, write to the Free Software |
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
| * |
| * -------------------------------------------------------------------------- |
| * $Id: WebServicesAuditTestCase.java 22467 2012-05-31 14:22:14Z benebrice $ |
| * -------------------------------------------------------------------------- |
| */ |
| |
| package org.ow2.jonas.tests.applications.wsadd.ws; |
| |
| import java.io.IOException; |
| 35,8 → 59,8 |
| boolean ok = false; |
| GenericAuditReport report; |
| protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { |
| this.req=req; |
| this.resp=resp; |
| this.req = req; |
| this.resp = resp; |
| |
| try { |
| InitialContext ic = new InitialContext(); |
| 47,30 → 71,32 |
| sendEvent(); |
| } catch (Exception e) { |
| throw new IllegalStateException("Error on audit tests", e); |
| } finally { |
| unregister(); |
| } |
| |
| } |
| |
| public void register(){ |
| |
| if(eventService.getDispatcher("JAXWS")==null) { |
| EventDispatcher d= new EventDispatcher(); |
| d.setNbWorkers(2); |
| d.start(); |
| eventService.registerDispatcher("JAXWS", d); |
| } |
| // if(eventService.getDispatcher("JAXWS") == null) { |
| // EventDispatcher d= new EventDispatcher(); |
| // d.setNbWorkers(2); |
| // d.start(); |
| // eventService.registerDispatcher("JAXWS", d); |
| // } |
| eventService.registerListener(this, "JAXWS"); |
| } |
| |
| public void sendEvent(){ |
| //Call the webservice |
| try{ |
| String serviceURL = "http://localhost:" + req.getParameter("port") + "/wsadd-sample/WSAddService"; |
| |
| try { |
| String serviceURL = req.getScheme() + "://" + req.getLocalAddr() + ":" + req.getServerPort() + "/wsadd-sample/WSAddService"; |
| |
| // Trigger the report generation |
| DefaultHttpClient client = new DefaultHttpClient(); |
| HttpPost post = new HttpPost(serviceURL); |
| InputStreamEntity entity = new InputStreamEntity(getClass().getResourceAsStream("/WEB-INF/soap-request-add.xml"), -1); |
| InputStreamEntity entity = new InputStreamEntity(getClass().getResourceAsStream("/soap-request-add.xml"), -1); |
| entity.setContentType("application/soap+xml"); |
| post.setEntity(entity); |
| client.execute(post); |
| 81,7 → 107,7 |
| int i = 0; |
| int times = 20; |
| int sleepTime = 500; |
| while((report == null) && (i < times)) { |
| while ((report == null) && (i < times)) { |
| Thread.sleep(sleepTime); |
| i++; |
| } |
| 90,30 → 116,29 |
| if (!ok) { |
| resp.getWriter().println("Report was not generated after " + ((i * sleepTime) / 1000) + " seconds"); |
| } |
| } catch (Exception e) { |
| throw new IllegalStateException("Error send JAXWS event on test", e); |
| } |
| catch(Exception e){ |
| throw new IllegalStateException("Error send JAXWS event on test",e); |
| } |
| |
| } |
| |
| |
| |
| public void unregister(){ |
| public void unregister() { |
| eventService.unregisterListener(this); |
| } |
| |
| public boolean accept(IEvent event){ |
| public boolean accept(IEvent event) { |
| return true; |
| } |
| |
| public EventPriority getPriority(){ |
| public EventPriority getPriority() { |
| return EventPriority.ASYNC_HIGH; |
| } |
| |
| public void handle(IEvent event){ |
| report=(GenericAuditReport) ((Event) event).getReport(); |
| ok=true; |
| public void handle(IEvent event) { |
| report = (GenericAuditReport) ((Event) event).getReport(); |
| ok = true; |
| } |
| |
| } |