Examples of DateWrapper


Examples of org.jboss.seam.remoting.wrapper.DateWrapper

   }

   @Test
   public void testDateWrapper() throws Exception
   {
      DateWrapper wrapper = new DateWrapper();
      String value = "20061231123045150";
      wrapper.setElement(createElement("date", value));

      Calendar cal = Calendar.getInstance();
      cal.set(Calendar.YEAR, 2006);
      cal.set(Calendar.MONTH, Calendar.DECEMBER);
      cal.set(Calendar.DATE, 31);
      cal.set(Calendar.HOUR_OF_DAY, 12);
      cal.set(Calendar.MINUTE, 30);
      cal.set(Calendar.SECOND, 45);
      cal.set(Calendar.MILLISECOND, 150);

      assertEquals(cal.getTime(), wrapper.convert(Date.class));

      ByteArrayOutputStream out = new ByteArrayOutputStream();
      wrapper.marshal(out);

      byte[] expected = ("<date>" + value + "</date>").getBytes();
      assertEquals(expected, out.toByteArray());

      try
      {
         // this should throw an exception
         wrapper.convert(InvalidClass.class);
         assert false;
      }
      catch (ConversionException ex)
      {
      }

      try
      {
         // this should throw an exception
         wrapper.setElement(createElement("date", "foobar"));
         wrapper.convert(Date.class);
         assert false;
      }
      catch (ConversionException ex)
      {
      }

      // test conversionScore() method
      assert ConversionScore.exact == wrapper.conversionScore(Date.class);
      assert ConversionScore.exact == wrapper
            .conversionScore(java.sql.Date.class);
      assert ConversionScore.compatible == wrapper
            .conversionScore(Object.class);
      assert ConversionScore.nomatch == wrapper
            .conversionScore(InvalidClass.class);
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.