axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject cvs commit: ws-axis/java/test/encoding TestDeser2001.java TestDeser.java
Date Wed, 24 Dec 2003 12:36:50 GMT
stevel      2003/12/24 04:36:50

  Modified:    java/test/encoding TestDeser2001.java TestDeser.java
  Log:
  demonstrations of things not working. I dont think it is a GMT problem any more, as it shows
up in PST decoding too.
  Much of the changes here are merely better reporting of state to the log and hence the report
pages.
  
  Revision  Changes    Path
  1.27      +52 -7     ws-axis/java/test/encoding/TestDeser2001.java
  
  Index: TestDeser2001.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/test/encoding/TestDeser2001.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- TestDeser2001.java	11 Dec 2002 22:40:15 -0000	1.26
  +++ TestDeser2001.java	24 Dec 2003 12:36:50 -0000	1.27
  @@ -114,23 +114,68 @@
                        "</result>",
                        time);
       }
  -    public void testTimeTZ() throws Exception {
  +
  +    public void testTimePacific() throws Exception {
  +        deserializeCalendar(TimeZone.getTimeZone("PST8PDT"));
  +    }
  +    
  +    /**
  +     * test that this works in Wintertime
  +     * @throws Exception
  +     */
  +    public void testTimeLocal() throws Exception {
  +        deserializeCalendar(TimeZone.getDefault());
  +    }
  +
  +    /**
  +     * test that this works in Wintertime
  +     * @throws Exception
  +     */
  +    public void testTimeUK() throws Exception {
  +        deserializeCalendar(TimeZone.getTimeZone("GMT0BST"));
  +    }
  +
  +
  +    private void deserializeCalendar(TimeZone tz) throws Exception {
  +        deserializeCalendar(2004, 1, 1, tz);
  +        deserializeCalendar(2004, 7, 1, tz);
  +    }
  +
  +    private void deserializeCalendar(int year, int month,int day,TimeZone tz) throws Exception
{
           Calendar date = Calendar.getInstance();
  +        date.set(Calendar.YEAR, year);
  +        date.set(Calendar.MONTH, month);
  +        date.set(Calendar.DAY_OF_MONTH, day);
           date.set(Calendar.HOUR_OF_DAY, 12);
           date.set(Calendar.MINUTE, 01);
           date.set(Calendar.SECOND, 30);
  -        date.set(Calendar.MILLISECOND,150);
  -        date.setTimeZone(TimeZone.getDefault());
  +        date.set(Calendar.MILLISECOND, 150);
  +        date.setTimeZone(tz);
           Time time = new Time(date);
  +        String offset = calcGMTOffset(date);
  +        String comment=" [time="+time.toString()+"; tz="+tz.getDisplayName()+"]";
  +
           deserialize("<result xsi:type=\"xsd:time\">" +
  -                       "12:01:30.150" + calcGMTOffset(date) +
  +                       "12:01:30.150" + offset +
                        "</result>",
  -                     time);
  +                     time,
  +                    false,
  +                    comment);
       }
   
  -    private final int msecsInMinute = 60000;
  -    private final int msecsInHour = 60 * msecsInMinute;
   
  +    private static final int msecsInMinute = 60000;
  +    private static final int msecsInHour = 60 * msecsInMinute;
  +
  +    /**
  +     *
  +     * calculate the offset from GMT of the current time zone.
  +     * If the underlying time zone of the calendar contains historical
  +     * summer time information, the offset will be corrected for summertime
  +     * if the date of the calendar is a summertime date
  +     * @param cal
  +     * @return an offset string such as +3:00 or -2:30. GMT is returned as -00:00
  +     */
       private String calcGMTOffset(Calendar cal) {
           int msecOffset = cal.get(Calendar.ZONE_OFFSET) +
                   cal.get(Calendar.DST_OFFSET);
  
  
  
  1.46      +27 -6     ws-axis/java/test/encoding/TestDeser.java
  
  Index: TestDeser.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/test/encoding/TestDeser.java,v
  retrieving revision 1.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- TestDeser.java	10 Dec 2003 02:50:05 -0000	1.45
  +++ TestDeser.java	24 Dec 2003 12:36:50 -0000	1.46
  @@ -146,35 +146,56 @@
           throws Exception {
           deserialize(data, expected, false);
       }
  +
       protected void deserialize(String data, Object expected, boolean tryConvert)
  +            throws Exception {
  +        deserialize(data, expected,tryConvert,"");
  +    }
  +
  +
  +    /**
  +     * Verify that a given XML deserialized produces the expected result
  +     * @param data
  +     * @param expected
  +     * @param tryConvert
  +     * @param comment extra text to add
  +     * @throws Exception
  +     */
  +    protected void deserialize(String data, Object expected, boolean tryConvert, String
comment)
          throws Exception
       {
          Message message = new Message(header + data + footer);
          message.setMessageContext(new MessageContext(server));
  +       String postfix="";
  +       if(comment!=null) {
  +           postfix=" "+comment;
  +       }
   
          SOAPEnvelope envelope = (SOAPEnvelope)message.getSOAPEnvelope();
  -       assertNotNull("SOAP envelope should not be null", envelope);
  +       assertNotNull("SOAP envelope should not be null"+ postfix, envelope);
   
          RPCElement body = (RPCElement)envelope.getFirstBody();
  -       assertNotNull("SOAP body should not be null", body);
  +       assertNotNull("SOAP body should not be null" + postfix, body);
   
          Vector arglist = body.getParams();
          assertNotNull("arglist", arglist);
  -       assertTrue("param.size()<=0 {Should be > 0}", arglist.size()>0);
  +       assertTrue("param.size()<=0 {Should be > 0}" + postfix, arglist.size()>0);
   
          RPCParam param = (RPCParam) arglist.get(0);
  -       assertNotNull("SOAP param should not be null", param);
  +       assertNotNull("SOAP param should not be null" + postfix, param);
   
          Object result = param.getValue();
          if (!equals(result, expected)) {
  +           String errorText = "Failed to decode " + data + postfix+" : ";
              // Try to convert to the expected class
              if (tryConvert) {
                  Object result2 = JavaUtils.convert(result, expected.getClass());
                  if (!equals(result2, expected)) {
  -                   assertEquals("The result is not what is expected.", expected, result);
  +
  +                   assertEquals(errorText, expected, result);
                  }
              } else {
  -               assertEquals("The result is not what is expected.", expected, result);
  +               assertEquals(errorText, expected, result);
              }
          }
       }
  
  
  

Mime
View raw message