You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "spark shen (JIRA)" <ji...@apache.org> on 2007/07/20 09:46:06 UTC

[jira] Created: (HARMONY-4505) [classlib][beans] Beans module needs a persistence delegate for java.util.Date class

[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


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.


[jira] Updated: (HARMONY-4505) [classlib][beans] Beans module needs a persistence delegate for java.util.Date class

Posted by "spark shen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-4505?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

spark shen updated HARMONY-4505:
--------------------------------

    Attachment: HY-4505.sh

> [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
>         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.


[jira] Resolved: (HARMONY-4505) [classlib][beans] Beans module needs a persistence delegate for java.util.Date class

Posted by "Tony Wu (JIRA)" <ji...@apache.org>.
     [ 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.


[jira] Updated: (HARMONY-4505) [classlib][beans] Beans module needs a persistence delegate for java.util.Date class

Posted by "spark shen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-4505?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

spark shen updated HARMONY-4505:
--------------------------------

    Attachment: HY-4505.patch

> [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
>         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.


[jira] Closed: (HARMONY-4505) [classlib][beans] Beans module needs a persistence delegate for java.util.Date class

Posted by "spark shen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-4505?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

spark shen closed HARMONY-4505.
-------------------------------


Verified at r558606.

> [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.


[jira] Assigned: (HARMONY-4505) [classlib][beans] Beans module needs a persistence delegate for java.util.Date class

Posted by "Tony Wu (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-4505?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tony Wu reassigned HARMONY-4505:
--------------------------------

    Assignee: Tony Wu

> [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.