package com.alibaba.json.bvt.bug;

import java.util.HashMap;
import java.util.Map;

import junit.framework.Assert;
import junit.framework.TestCase;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;

public class Bug_for_lenolix_9 extends TestCase {

    public void test_for_objectKey() throws Exception {
        Map<String, Object> submap4 = new HashMap<String, Object>();
        Address address = new Address();
        address.setCity("hangzhou");
        address.setStreet("wangshang.RD");
        address.setPostCode(310002);
        submap4.put("address1", address);
        submap4.put("address2", address);

        String mapString4 = JSON.toJSONString(submap4, SerializerFeature.WriteClassName,
                                              SerializerFeature.WriteMapNullValue);
        
        System.out.println(mapString4);
        Object object4 = JSON.parse(mapString4);
        Assert.assertNotNull(object4);
        
        Map<String, Object> map = (Map<String, Object>) object4;
        
        Assert.assertNotNull(map.get("address1"));
        Assert.assertNotNull(map.get("address2"));

    }

    public static class Address {

        private String city;
        private String street;
        private int postCode;

        public String getCity() {
            return city;
        }

        public void setCity(String city) {
            this.city = city;
        }

        public String getStreet() {
            return street;
        }

        public void setStreet(String street) {
            this.street = street;
        }

        public int getPostCode() {
            return postCode;
        }

        public void setPostCode(int postCode) {
            this.postCode = postCode;
        }

    }
}

@@ -650,24 +650,153 @@
  address);%0A%0A
+        Country country = new Country();%0A        country.setProvince(%22ZheJiang%22);%0A        %0A        address.setCountry(country);%0A%0A
         Stri
@@ -956,24 +956,16 @@
 Value);%0A
-        
 %0A       
@@ -1085,24 +1085,16 @@
 ject4);%0A
-        
 %0A       
@@ -1151,24 +1151,16 @@
 bject4;%0A
-        
 %0A       
@@ -1251,24 +1251,96 @@
 dress2%22));%0A%0A
+        Assert.assertTrue(map.get(%22address1%22) == map.get(%22address2%22));%0A%0A
     %7D%0A%0A    p
@@ -1388,24 +1388,25 @@
 vate String 
+ 
 city;%0A      
@@ -1418,24 +1418,25 @@
 vate String 
+ 
 street;%0A    
@@ -1447,24 +1447,28 @@
 private int 
+    
 postCode;%0A%0A 
@@ -1464,16 +1464,223 @@
 ostCode;
+%0A        private Country country;%0A%0A        public Country getCountry() %7B%0A            return country;%0A        %7D%0A%0A        public void setCountry(Country country) %7B%0A            this.country = country;%0A        %7D
 %0A%0A      
@@ -2161,20 +2161,274 @@
 %0A        %7D%0A%0A
+    %7D%0A%0A    public static class Country %7B%0A%0A        private String province;%0A%0A        public String getProvince() %7B%0A            return province;%0A        %7D%0A%0A        public void setProvince(String province) %7B%0A            this.province = province;%0A        %7D%0A%0A
     %7D%0A%7D%0A

add test