harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tony Wu (JIRA)" <j...@apache.org>
Subject [jira] Resolved: (HARMONY-4505) [classlib][beans] Beans module needs a persistence delegate for java.util.Date class
Date Mon, 23 Jul 2007 05:38:31 GMT

     [ https://issues.apache.org/jira/browse/HARMONY-4505?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Tony Wu resolved HARMONY-4505.
------------------------------

    Resolution: Fixed

Patch applied at r558606 thanks for your contribution, please check if it is fixed as you
expected.

> [classlib][beans] Beans module needs a persistence delegate for java.util.Date class
> ------------------------------------------------------------------------------------
>
>                 Key: HARMONY-4505
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4505
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: spark shen
>            Assignee: Tony Wu
>         Attachments: HY-4505.patch, HY-4505.sh
>
>
> The following test case will fail on Harmony, but pass on RI.
> public static class DummyBean {
> 		private String value;
> 		public DummyBean() {
> 		}
> 		public DummyBean(String s) {
> 			value = s;
> 		}
> 		public String getDummyValue() {
> 			return value;
> 		}
> 		public void setDummyValue(String s) {
> 			value = s;
> 		}
> 		
> 		public boolean equals(Object bean) {
> 			if (!(bean instanceof DummyBean)) {
> 	            return false;
> 	        }
> 			DummyBean aBean = (DummyBean) bean;
> 			
> 			if (aBean.value == null && value != null || value != null
> 	                && aBean.value == null) {
> 	            return false;
> 	        } else if(value != null && aBean.value != null){
> 	        	return value.equals(aBean.value);
> 	        }
> 			return true;
> 		}
> 	}
> 	public void test_writeExpression_writeObject() {
> 		ByteArrayOutputStream output = new ByteArrayOutputStream();
>         XMLEncoder encoder = new XMLEncoder( output );
>         Date date = new Date(2007, 06, 26);
>         Expression expression = new Expression( date, "toString", null );
>         String date_string = null;
>         try {
>                 date_string = (String) expression.getValue();
>         } catch (Exception e ) {
>                 System.out.println("Failed to get the date value.");
>                 e.printStackTrace();
>         }
>         DummyBean bean = new DummyBean( date_string );
>         // The expression knows about the date object.
>         encoder.writeExpression( expression );
>         encoder.writeObject( date );
>         // The value for the bean is already part of the expression
>         // so instead of writing the value we write a reference to
>         // the extpression.
>         encoder.writeObject( bean );
>         encoder.flush();
>         encoder.close();
>         
>         DataInputStream stream = new DataInputStream(new ByteArrayInputStream(
> 				output.toByteArray()));
> 		XMLDecoder decoder = new XMLDecoder(stream);
> 		Date aDate = (Date) decoder.readObject();
> 		assertEquals(date, aDate);
> 		
> 		DummyBean aBean = (DummyBean) decoder.readObject();
> 		assertEquals(bean, aBean);
> 	}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message