Disclaimer : I may be missing some fundamentals of J2ee/Jersey programming.
For some reason departureYear gets 0. I wonder why.
Request
http://localhost:8080/myendpoint/api/BOM/BLR/0/3/9/2015/6/10/2015/1/1/1/1
Request Junit Code
@Test
public void test1PostSearch() throws Exception {
ClientConfig config = new DefaultClientConfig();
Client client = Client.create(config);
URI url = UriBuilder
.fromUri(
"http://"
+ LOCALHOST
+ "/myendpoint/api/BOM/BLR/"
+ FlightSearchType.OneWay.ordinal()
+ "/3/9/2015" + "/6/10/2015/"
+ CabinClass.Economy.ordinal() + "/1/1/1")
.build();
WebResource service = client.resource(url);
System.out.println(url);
String status = (String) service.type(MediaType.APPLICATION_JSON).post(
String.class, new UserNamePassword("clientID", "password"));
assertNotNull(status);
}
** Server Side (Jersey 2.x) **
@POST
@Path("api/{origin}/{destination}/{flightSearchType}/{departureDayOfMonth}/{departureMonthOfYear}/{departureYear}/{returnDayOfMonth}/{returnMonthOfYear}/{returnYear}/{cabinClass}/{adultCount}/{childCount}/{infantCount}")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
public Response search(@PathParam("origin") String origin,
@PathParam("destination") String destination,
@PathParam("flightSearchType") int flightSearchType,
@PathParam("departureDayOfMonth") int departureDayOfMonth,
@PathParam("departureMonthOfYear") int departureMonthOfYear,
@PathParam("depatureYear") int depatureYear,
@PathParam("returnDayOfMonth") int returnDayOfMonth,
@PathParam("returnMonthOfYear") int returnMonthOfYear,
@PathParam("returnYear") int returnYear,
@PathParam("cabinClass") int cabinClass,
@PathParam("adultCount") int adultCount,
@PathParam("childCount") int childCount,
@PathParam("infantCount") int infantCount,
JAXBElement<UserNamePassword> userNamePassword) {
log.debug("EndPointConsolidation " + depatureYear + ":" + returnYear);
Output log
0 [http-bio-8080-exec-6] DEBUG com.EndPointConsolidation - EndPointConsolidation 0:2015
Question
Why is departureYear 0 ?
Aucun commentaire:
Enregistrer un commentaire