From: Dave B. <bla...@us...> - 2013-11-29 17:24:25
|
Update of /cvsroot/sblim/jsr48-client/utst/org/sblim/cimclient/unittest/http In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv18949/utst/org/sblim/cimclient/unittest/http Modified Files: Tag: Experimental HttpHeaderTest.java Log Message: 2718 Bad CIMStatusCode generates NumberFormatException Index: HttpHeaderTest.java =================================================================== RCS file: /cvsroot/sblim/jsr48-client/utst/org/sblim/cimclient/unittest/http/HttpHeaderTest.java,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -u -d -r1.1.2.5 -r1.1.2.6 --- HttpHeaderTest.java 27 Feb 2009 14:16:36 -0000 1.1.2.5 +++ HttpHeaderTest.java 29 Nov 2013 17:24:23 -0000 1.1.2.6 @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2005, 2009 + * (C) Copyright IBM Corp. 2005, 2013 * * THIS FILE IS PROVIDED UNDER THE TERMS OF THE ECLIPSE PUBLIC LICENSE * ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE @@ -16,6 +16,7 @@ * 2003590 2008-06-30 blaschke-oss Change licensing from CPL to EPL * 2524131 2009-01-21 raman_arora Upgrade client to JDK 1.5 (Phase 1) * 2641758 2009-02-27 blaschke-oss CIM Client does not recognize HTTP extension headers + * 2718 2013-11-29 blaschke-oss Bad CIMStatusCode generates NumberFormatException */ package org.sblim.cimclient.unittest.http; @@ -60,6 +61,7 @@ } catch (TrailerException e) { verify("Status code", EQUAL, new Integer(e.getWBEMException().getID()), new Integer(1)); + verify("Status description", e.getWBEMException().getMessage() == null); } catch (Exception e) { throw e; } @@ -94,6 +96,7 @@ } catch (TrailerException e) { verify("Status code", EQUAL, new Integer(e.getWBEMException().getID()), new Integer(19)); + verify("Status description", e.getWBEMException().getMessage() == null); } catch (Exception e) { throw e; } @@ -109,6 +112,60 @@ } catch (TrailerException e) { verify("Status code", EQUAL, new Integer(e.getWBEMException().getID()), new Integer(1)); + verify("Status description", e.getWBEMException().getMessage() == null); + } catch (Exception e) { + throw e; + } + } + + { + ByteArrayInputStream stream = new ByteArrayInputStream("12-CIMStatusCode: one\n\n" + .getBytes()); + HttpHeader header = new HttpHeader(stream); + try { + header.examineTrailer(); + fail("No TrailerException thrown on status code 1 with HTTP extension"); + } catch (TrailerException e) { + verify("Status code", EQUAL, new Integer(e.getWBEMException().getID()), + new Integer(1)); + verify("Status description", e.getWBEMException().getMessage() != null + && e.getWBEMException().getMessage().contains("\"one\"")); + } catch (Exception e) { + throw e; + } + } + + { + ByteArrayInputStream stream = new ByteArrayInputStream( + "12-CIMStatusCode: one\n12-CIMStatusCodeDescription: something failed\n\n" + .getBytes()); + HttpHeader header = new HttpHeader(stream); + try { + header.examineTrailer(); + fail("No TrailerException thrown on status code 1 with HTTP extension"); + } catch (TrailerException e) { + verify("Status code", EQUAL, new Integer(e.getWBEMException().getID()), + new Integer(1)); + verify("Status description", "something failed".equalsIgnoreCase(e + .getWBEMException().getMessage())); + } catch (Exception e) { + throw e; + } + } + + { + ByteArrayInputStream stream = new ByteArrayInputStream( + "12-CIMStatusCodeDescription: something failed\n12-CIMStatusCode: one\n\n" + .getBytes()); + HttpHeader header = new HttpHeader(stream); + try { + header.examineTrailer(); + fail("No TrailerException thrown on status code 1 with HTTP extension"); + } catch (TrailerException e) { + verify("Status code", EQUAL, new Integer(e.getWBEMException().getID()), + new Integer(1)); + verify("Status description", "something failed".equalsIgnoreCase(e + .getWBEMException().getMessage())); } catch (Exception e) { throw e; } |