diff --git a/dubbo-common/src/test/java/org/apache/dubbo/common/model/AnimalEnum.java b/dubbo-common/src/test/java/org/apache/dubbo/common/model/AnimalEnum.java deleted file mode 100644 index ddfc736e083..00000000000 --- a/dubbo-common/src/test/java/org/apache/dubbo/common/model/AnimalEnum.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.common.model; - -public enum AnimalEnum { - dog, cat, rat, cow, bull, horse; -} \ No newline at end of file diff --git a/dubbo-common/src/test/java/org/apache/dubbo/common/model/BizExceptionNoDefaultConstructor.java b/dubbo-common/src/test/java/org/apache/dubbo/common/model/BizExceptionNoDefaultConstructor.java deleted file mode 100644 index c3346ca7efa..00000000000 --- a/dubbo-common/src/test/java/org/apache/dubbo/common/model/BizExceptionNoDefaultConstructor.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.common.model; - -public class BizExceptionNoDefaultConstructor extends RuntimeException { - - private static final long serialVersionUID = 1L; - - public BizExceptionNoDefaultConstructor(String message) { - super(message); - } -} \ No newline at end of file diff --git a/dubbo-common/src/test/java/org/apache/dubbo/common/model/media/MediaContent.java b/dubbo-common/src/test/java/org/apache/dubbo/common/model/media/MediaContent.java deleted file mode 100644 index 7991f506101..00000000000 --- a/dubbo-common/src/test/java/org/apache/dubbo/common/model/media/MediaContent.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.common.model.media; - -import java.util.List; - -@SuppressWarnings("serial") -public class MediaContent implements java.io.Serializable { - public Media media; - public List images; - - public MediaContent() { - } - - public MediaContent(Media media, List images) { - this.media = media; - this.images = images; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - MediaContent that = (MediaContent) o; - - if (images != null ? !images.equals(that.images) : that.images != null) return false; - if (media != null ? !media.equals(that.media) : that.media != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = media != null ? media.hashCode() : 0; - result = 31 * result + (images != null ? images.hashCode() : 0); - return result; - } - - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("[MediaContent: "); - sb.append("media=").append(media); - sb.append(", images=").append(images); - sb.append("]"); - return sb.toString(); - } - - public Media getMedia() { - return media; - } - - public void setMedia(Media media) { - this.media = media; - } - - public List getImages() { - return images; - } - - public void setImages(List images) { - this.images = images; - } -} \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/org/apache/dubbo/common/serialize/fastjson/model/Image.java b/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/org/apache/dubbo/common/serialize/fastjson/model/Image.java deleted file mode 100644 index bb2dc06eb39..00000000000 --- a/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/org/apache/dubbo/common/serialize/fastjson/model/Image.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.common.serialize.fastjson.model; - -public class Image implements java.io.Serializable { - private static final long serialVersionUID = 1L; - private String uri; - private String title; - private int width; - private int height; - private Size size; - - public Image(String uri, String title, int width, int height, Size size) { - this.height = height; - this.title = title; - this.uri = uri; - this.width = width; - this.size = size; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Image image = (Image) o; - - if (height != image.height) return false; - if (width != image.width) return false; - if (size != image.size) return false; - if (title != null ? !title.equals(image.title) : image.title != null) return false; - if (uri != null ? !uri.equals(image.uri) : image.uri != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = uri != null ? uri.hashCode() : 0; - result = 31 * result + (title != null ? title.hashCode() : 0); - result = 31 * result + width; - result = 31 * result + height; - result = 31 * result + (size != null ? size.hashCode() : 0); - return result; - } - - public String getUri() { - return uri; - } - - public void setUri(String uri) { - this.uri = uri; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public int getWidth() { - return width; - } - - public void setWidth(int width) { - this.width = width; - } - - public int getHeight() { - return height; - } - - public void setHeight(int height) { - this.height = height; - } - - public Size getSize() { - return size; - } - - public void setSize(Size size) { - this.size = size; - } - - public enum Size { - SMALL, LARGE - } -} \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/org/apache/dubbo/common/serialize/fastjson/model/Person.java b/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/org/apache/dubbo/common/serialize/fastjson/model/Person.java deleted file mode 100644 index eadb684d15a..00000000000 --- a/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/org/apache/dubbo/common/serialize/fastjson/model/Person.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.common.serialize.fastjson.model; - -public class Person { - private String name; - private int age; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public int getAge() { - return age; - } - - public void setAge(int age) { - this.age = age; - } -} diff --git a/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/log4j.xml b/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/log4j.xml deleted file mode 100644 index d045b92c0de..00000000000 --- a/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/log4j.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-fst/src/test/java/org/apache/dubbo/common/serialize/fst/model/AnimalEnum.java b/dubbo-serialization/dubbo-serialization-fst/src/test/java/org/apache/dubbo/common/serialize/fst/model/AnimalEnum.java deleted file mode 100644 index 0f1b98bfc35..00000000000 --- a/dubbo-serialization/dubbo-serialization-fst/src/test/java/org/apache/dubbo/common/serialize/fst/model/AnimalEnum.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.common.serialize.fst.model; - -public enum AnimalEnum { - dog, cat, rat, cow, bull, horse; -} \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-fst/src/test/java/org/apache/dubbo/common/serialize/fst/model/FullAddress.java b/dubbo-serialization/dubbo-serialization-fst/src/test/java/org/apache/dubbo/common/serialize/fst/model/FullAddress.java deleted file mode 100644 index d3f88a93f90..00000000000 --- a/dubbo-serialization/dubbo-serialization-fst/src/test/java/org/apache/dubbo/common/serialize/fst/model/FullAddress.java +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.common.serialize.fst.model; - -import java.io.Serializable; - -public class FullAddress implements Serializable { - - private static final long serialVersionUID = 5163979984269419831L; - - private String countryId; - - private String countryName; - - private String provinceName; - - private String cityId; - - private String cityName; - - private String streetAddress; - - private String zipCode; - - public FullAddress(String countryId, String provinceName, String cityId, String streetAddress, - String zipCode) { - this.countryId = countryId; - this.countryName = countryId; - this.provinceName = provinceName; - this.cityId = cityId; - this.cityName = cityId; - this.streetAddress = streetAddress; - this.zipCode = zipCode; - } - - public FullAddress(String countryId, String countryName, String provinceName, String cityId, - String cityName, String streetAddress, String zipCode) { - this.countryId = countryId; - this.countryName = countryName; - this.provinceName = provinceName; - this.cityId = cityId; - this.cityName = cityName; - this.streetAddress = streetAddress; - this.zipCode = zipCode; - } - - public String getCountryId() { - return countryId; - } - - public void setCountryId(String countryId) { - this.countryId = countryId; - } - - public String getCountryName() { - return countryName; - } - - public void setCountryName(String countryName) { - this.countryName = countryName; - } - - public String getProvinceName() { - return provinceName; - } - - public void setProvinceName(String provinceName) { - this.provinceName = provinceName; - } - - public String getCityId() { - return cityId; - } - - public void setCityId(String cityId) { - this.cityId = cityId; - } - - public String getCityName() { - return cityName; - } - - public void setCityName(String cityName) { - this.cityName = cityName; - } - - public String getStreetAddress() { - return streetAddress; - } - - public void setStreetAddress(String streetAddress) { - this.streetAddress = streetAddress; - } - - public String getZipCode() { - return zipCode; - } - - public void setZipCode(String zipCode) { - this.zipCode = zipCode; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((cityId == null) ? 0 : cityId.hashCode()); - result = prime * result + ((cityName == null) ? 0 : cityName.hashCode()); - result = prime * result + ((countryId == null) ? 0 : countryId.hashCode()); - result = prime * result + ((countryName == null) ? 0 : countryName.hashCode()); - result = prime * result + ((provinceName == null) ? 0 : provinceName.hashCode()); - result = prime * result + ((streetAddress == null) ? 0 : streetAddress.hashCode()); - result = prime * result + ((zipCode == null) ? 0 : zipCode.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - FullAddress other = (FullAddress) obj; - if (cityId == null) { - if (other.cityId != null) - return false; - } else if (!cityId.equals(other.cityId)) - return false; - if (cityName == null) { - if (other.cityName != null) - return false; - } else if (!cityName.equals(other.cityName)) - return false; - if (countryId == null) { - if (other.countryId != null) - return false; - } else if (!countryId.equals(other.countryId)) - return false; - if (countryName == null) { - if (other.countryName != null) - return false; - } else if (!countryName.equals(other.countryName)) - return false; - if (provinceName == null) { - if (other.provinceName != null) - return false; - } else if (!provinceName.equals(other.provinceName)) - return false; - if (streetAddress == null) { - if (other.streetAddress != null) - return false; - } else if (!streetAddress.equals(other.streetAddress)) - return false; - if (zipCode == null) { - if (other.zipCode != null) - return false; - } else if (!zipCode.equals(other.zipCode)) - return false; - return true; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - if (countryName != null && countryName.length() > 0) { - sb.append(countryName); - } - if (provinceName != null && provinceName.length() > 0) { - sb.append(" "); - sb.append(provinceName); - } - if (cityName != null && cityName.length() > 0) { - sb.append(" "); - sb.append(cityName); - } - if (streetAddress != null && streetAddress.length() > 0) { - sb.append(" "); - sb.append(streetAddress); - } - return sb.toString(); - } - -} \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-fst/src/test/resources/log4j.xml b/dubbo-serialization/dubbo-serialization-fst/src/test/resources/log4j.xml deleted file mode 100644 index d045b92c0de..00000000000 --- a/dubbo-serialization/dubbo-serialization-fst/src/test/resources/log4j.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/model/AnimalEnum.java b/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/model/AnimalEnum.java deleted file mode 100644 index 760663fe04c..00000000000 --- a/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/model/AnimalEnum.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.common.model; - -public enum AnimalEnum { - dog, cat, rat, cow, bull, horse; -} \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/model/BizExceptionNoDefaultConstructor.java b/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/model/BizExceptionNoDefaultConstructor.java deleted file mode 100644 index f1ffadb0234..00000000000 --- a/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/model/BizExceptionNoDefaultConstructor.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.common.model; - -public class BizExceptionNoDefaultConstructor extends RuntimeException { - - private static final long serialVersionUID = 1L; - - public BizExceptionNoDefaultConstructor(String message) { - super(message); - } -} \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/model/Person.java b/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/model/Person.java deleted file mode 100644 index 5a551a7f36b..00000000000 --- a/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/model/Person.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.common.model; - -import java.util.Arrays; - -public class Person { - byte oneByte = 123; - private String name = "name1"; - private int age = 11; - - private String[] value = {"value1", "value2"}; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public byte getOneByte() { - return oneByte; - } - - public void setOneByte(byte b) { - this.oneByte = b; - } - - public int getAge() { - return age; - } - - public void setAge(int age) { - this.age = age; - } - - public String[] getValue() { - return value; - } - - public void setValue(String[] value) { - this.value = value; - } - - @Override - public String toString() { - return String.format("Person name(%s) age(%d) byte(%s) [value=%s]", name, age, oneByte, Arrays.toString(value)); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + age; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + Arrays.hashCode(value); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Person other = (Person) obj; - if (age != other.age) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (!Arrays.equals(value, other.value)) - return false; - return true; - } -} \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/model/SerializablePerson.java b/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/model/SerializablePerson.java deleted file mode 100644 index d78c5928ea8..00000000000 --- a/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/model/SerializablePerson.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.common.model; - -import java.io.Serializable; -import java.util.Arrays; - -public class SerializablePerson implements Serializable { - private static final long serialVersionUID = 1L; - byte oneByte = 123; - private String name = "name1"; - private int age = 11; - - private String[] value = {"value1", "value2"}; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public byte getOneByte() { - return oneByte; - } - - public void setOneByte(byte b) { - this.oneByte = b; - } - - public int getAge() { - return age; - } - - public void setAge(int age) { - this.age = age; - } - - public String[] getValue() { - return value; - } - - public void setValue(String[] value) { - this.value = value; - } - - @Override - public String toString() { - return String.format("Person name(%s) age(%d) byte(%s) [value=%s]", name, age, oneByte, Arrays.toString(value)); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + age; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + Arrays.hashCode(value); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - SerializablePerson other = (SerializablePerson) obj; - if (age != other.age) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (!Arrays.equals(value, other.value)) - return false; - return true; - } -} \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/model/media/Image.java b/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/model/media/Image.java deleted file mode 100644 index a59eff35be6..00000000000 --- a/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/model/media/Image.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.common.model.media; - - -public class Image implements java.io.Serializable { - private static final long serialVersionUID = 1L; - public String uri; - public String title; // Can be null - public int width; - public int height; - public Size size; - - public Image() { - } - - public Image(String uri, String title, int width, int height, Size size) { - this.height = height; - this.title = title; - this.uri = uri; - this.width = width; - this.size = size; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Image image = (Image) o; - - if (height != image.height) return false; - if (width != image.width) return false; - if (size != image.size) return false; - if (title != null ? !title.equals(image.title) : image.title != null) return false; - if (uri != null ? !uri.equals(image.uri) : image.uri != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = uri != null ? uri.hashCode() : 0; - result = 31 * result + (title != null ? title.hashCode() : 0); - result = 31 * result + width; - result = 31 * result + height; - result = 31 * result + (size != null ? size.hashCode() : 0); - return result; - } - - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("[Image "); - sb.append("uri=").append(uri); - sb.append(", title=").append(title); - sb.append(", width=").append(width); - sb.append(", height=").append(height); - sb.append(", size=").append(size); - sb.append("]"); - return sb.toString(); - } - - public String getUri() { - return uri; - } - - public void setUri(String uri) { - this.uri = uri; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public int getWidth() { - return width; - } - - public void setWidth(int width) { - this.width = width; - } - - public int getHeight() { - return height; - } - - public void setHeight(int height) { - this.height = height; - } - - public Size getSize() { - return size; - } - - public void setSize(Size size) { - this.size = size; - } - - public enum Size { - SMALL, LARGE - } -} \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/model/media/Media.java b/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/model/media/Media.java deleted file mode 100644 index 042a3a5273a..00000000000 --- a/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/model/media/Media.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.common.model.media; - -import java.util.List; - -@SuppressWarnings("serial") -public class Media implements java.io.Serializable { - public String uri; - public String title; // Can be unset. - public int width; - public int height; - public String format; - public long duration; - public long size; - public int bitrate; // Can be unset. - public boolean hasBitrate; - public List persons; - public Player player; - public String copyright; // Can be unset. - - public Media() { - } - - public Media(String uri, String title, int width, int height, String format, long duration, long size, int bitrate, boolean hasBitrate, List persons, Player player, String copyright) { - this.uri = uri; - this.title = title; - this.width = width; - this.height = height; - this.format = format; - this.duration = duration; - this.size = size; - this.bitrate = bitrate; - this.hasBitrate = hasBitrate; - this.persons = persons; - this.player = player; - this.copyright = copyright; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Media media = (Media) o; - - if (bitrate != media.bitrate) return false; - if (duration != media.duration) return false; - if (hasBitrate != media.hasBitrate) return false; - if (height != media.height) return false; - if (size != media.size) return false; - if (width != media.width) return false; - if (copyright != null ? !copyright.equals(media.copyright) : media.copyright != null) return false; - if (format != null ? !format.equals(media.format) : media.format != null) return false; - if (persons != null ? !persons.equals(media.persons) : media.persons != null) return false; - if (player != media.player) return false; - if (title != null ? !title.equals(media.title) : media.title != null) return false; - if (uri != null ? !uri.equals(media.uri) : media.uri != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = uri != null ? uri.hashCode() : 0; - result = 31 * result + (title != null ? title.hashCode() : 0); - result = 31 * result + width; - result = 31 * result + height; - result = 31 * result + (format != null ? format.hashCode() : 0); - result = 31 * result + (int) (duration ^ (duration >>> 32)); - result = 31 * result + (int) (size ^ (size >>> 32)); - result = 31 * result + bitrate; - result = 31 * result + (hasBitrate ? 1 : 0); - result = 31 * result + (persons != null ? persons.hashCode() : 0); - result = 31 * result + (player != null ? player.hashCode() : 0); - result = 31 * result + (copyright != null ? copyright.hashCode() : 0); - return result; - } - - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("[Media "); - sb.append("uri=").append(uri); - sb.append(", title=").append(title); - sb.append(", width=").append(width); - sb.append(", height=").append(height); - sb.append(", format=").append(format); - sb.append(", duration=").append(duration); - sb.append(", size=").append(size); - sb.append(", hasBitrate=").append(hasBitrate); - sb.append(", bitrate=").append(String.valueOf(bitrate)); - sb.append(", persons=").append(persons); - sb.append(", player=").append(player); - sb.append(", copyright=").append(copyright); - sb.append("]"); - return sb.toString(); - } - - public String getUri() { - return uri; - } - - public void setUri(String uri) { - this.uri = uri; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public int getWidth() { - return width; - } - - public void setWidth(int width) { - this.width = width; - } - - public int getHeight() { - return height; - } - - public void setHeight(int height) { - this.height = height; - } - - public String getFormat() { - return format; - } - - public void setFormat(String format) { - this.format = format; - } - - public long getDuration() { - return duration; - } - - public void setDuration(long duration) { - this.duration = duration; - } - - public long getSize() { - return size; - } - - public void setSize(long size) { - this.size = size; - } - - public int getBitrate() { - return bitrate; - } - - public void setBitrate(int bitrate) { - this.bitrate = bitrate; - this.hasBitrate = true; - } - - public List getPersons() { - return persons; - } - - public void setPersons(List persons) { - this.persons = persons; - } - - public Player getPlayer() { - return player; - } - - public void setPlayer(Player player) { - this.player = player; - } - - public String getCopyright() { - return copyright; - } - - public void setCopyright(String copyright) { - this.copyright = copyright; - } - - public enum Player { - JAVA, FLASH - } -} \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/model/media/MediaContent.java b/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/model/media/MediaContent.java deleted file mode 100644 index 7991f506101..00000000000 --- a/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/model/media/MediaContent.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.common.model.media; - -import java.util.List; - -@SuppressWarnings("serial") -public class MediaContent implements java.io.Serializable { - public Media media; - public List images; - - public MediaContent() { - } - - public MediaContent(Media media, List images) { - this.media = media; - this.images = images; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - MediaContent that = (MediaContent) o; - - if (images != null ? !images.equals(that.images) : that.images != null) return false; - if (media != null ? !media.equals(that.media) : that.media != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = media != null ? media.hashCode() : 0; - result = 31 * result + (images != null ? images.hashCode() : 0); - return result; - } - - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("[MediaContent: "); - sb.append("media=").append(media); - sb.append(", images=").append(images); - sb.append("]"); - return sb.toString(); - } - - public Media getMedia() { - return media; - } - - public void setMedia(Media media) { - this.media = media; - } - - public List getImages() { - return images; - } - - public void setImages(List images) { - this.images = images; - } -} \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/model/person/PersonInfo.java b/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/model/person/PersonInfo.java deleted file mode 100644 index 15f1238fe85..00000000000 --- a/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/model/person/PersonInfo.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.common.model.person; - -import java.io.Serializable; -import java.util.List; - -public class PersonInfo implements Serializable { - private static final long serialVersionUID = 7443011149612231882L; - - List phones; - - Phone fax; - - FullAddress fullAddress; - - String mobileNo; - - String name; - - boolean male; - - boolean female; - - String department; - - String jobTitle; - - String homepageUrl; - - public List getPhones() { - return phones; - } - - public void setPhones(List phones) { - this.phones = phones; - } - - public boolean isMale() { - return male; - } - - public void setMale(boolean male) { - this.male = male; - } - - public boolean isFemale() { - return female; - } - - public void setFemale(boolean female) { - this.female = female; - } - - public String getDepartment() { - return department; - } - - public void setDepartment(String department) { - this.department = department; - } - - public Phone getFax() { - return fax; - } - - public void setFax(Phone fax) { - this.fax = fax; - } - - public FullAddress getFullAddress() { - return fullAddress; - } - - public void setFullAddress(FullAddress fullAddress) { - this.fullAddress = fullAddress; - } - - public String getHomepageUrl() { - return homepageUrl; - } - - public void setHomepageUrl(String homepageUrl) { - this.homepageUrl = homepageUrl; - } - - public String getJobTitle() { - return jobTitle; - } - - public void setJobTitle(String jobTitle) { - this.jobTitle = jobTitle; - } - - public String getMobileNo() { - return mobileNo; - } - - public void setMobileNo(String mobileNo) { - this.mobileNo = mobileNo; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((department == null) ? 0 : department.hashCode()); - result = prime * result + ((fax == null) ? 0 : fax.hashCode()); - result = prime * result + (female ? 1231 : 1237); - result = prime * result + ((fullAddress == null) ? 0 : fullAddress.hashCode()); - result = prime * result + ((homepageUrl == null) ? 0 : homepageUrl.hashCode()); - result = prime * result + ((jobTitle == null) ? 0 : jobTitle.hashCode()); - result = prime * result + (male ? 1231 : 1237); - result = prime * result + ((mobileNo == null) ? 0 : mobileNo.hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((phones == null) ? 0 : phones.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - PersonInfo other = (PersonInfo) obj; - if (department == null) { - if (other.department != null) - return false; - } else if (!department.equals(other.department)) - return false; - if (fax == null) { - if (other.fax != null) - return false; - } else if (!fax.equals(other.fax)) - return false; - if (female != other.female) - return false; - if (fullAddress == null) { - if (other.fullAddress != null) - return false; - } else if (!fullAddress.equals(other.fullAddress)) - return false; - if (homepageUrl == null) { - if (other.homepageUrl != null) - return false; - } else if (!homepageUrl.equals(other.homepageUrl)) - return false; - if (jobTitle == null) { - if (other.jobTitle != null) - return false; - } else if (!jobTitle.equals(other.jobTitle)) - return false; - if (male != other.male) - return false; - if (mobileNo == null) { - if (other.mobileNo != null) - return false; - } else if (!mobileNo.equals(other.mobileNo)) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (phones == null) { - if (other.phones != null) - return false; - } else if (!phones.equals(other.phones)) - return false; - return true; - } - - @Override - public String toString() { - return "PersonInfo [phones=" + phones + ", fax=" + fax + ", fullAddress=" + fullAddress - + ", mobileNo=" + mobileNo + ", name=" + name + ", male=" + male + ", female=" - + female + ", department=" + department + ", jobTitle=" + jobTitle - + ", homepageUrl=" + homepageUrl + "]"; - } - -} diff --git a/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/model/person/PersonStatus.java b/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/model/person/PersonStatus.java deleted file mode 100644 index 62869c2b80b..00000000000 --- a/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/model/person/PersonStatus.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.common.model.person; - -public enum PersonStatus { - ENABLED, - DISABLED -} \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/model/person/Phone.java b/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/model/person/Phone.java deleted file mode 100644 index 41fd38a92df..00000000000 --- a/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/model/person/Phone.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.common.model.person; - -import java.io.Serializable; - -public class Phone implements Serializable { - - private static final long serialVersionUID = 4399060521859707703L; - - private String country; - - private String area; - - private String number; - - private String extensionNumber; - - public Phone() { - } - - public Phone(String country, String area, String number, String extensionNumber) { - this.country = country; - this.area = area; - this.number = number; - this.extensionNumber = extensionNumber; - } - - public String getCountry() { - return country; - } - - public void setCountry(String country) { - this.country = country; - } - - public String getArea() { - return area; - } - - public void setArea(String area) { - this.area = area; - } - - public String getNumber() { - return number; - } - - public void setNumber(String number) { - this.number = number; - } - - public String getExtensionNumber() { - return extensionNumber; - } - - public void setExtensionNumber(String extensionNumber) { - this.extensionNumber = extensionNumber; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((area == null) ? 0 : area.hashCode()); - result = prime * result + ((country == null) ? 0 : country.hashCode()); - result = prime * result + ((extensionNumber == null) ? 0 : extensionNumber.hashCode()); - result = prime * result + ((number == null) ? 0 : number.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Phone other = (Phone) obj; - if (area == null) { - if (other.area != null) - return false; - } else if (!area.equals(other.area)) - return false; - if (country == null) { - if (other.country != null) - return false; - } else if (!country.equals(other.country)) - return false; - if (extensionNumber == null) { - if (other.extensionNumber != null) - return false; - } else if (!extensionNumber.equals(other.extensionNumber)) - return false; - if (number == null) { - if (other.number != null) - return false; - } else if (!number.equals(other.number)) - return false; - return true; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - if (country != null && country.length() > 0) { - sb.append(country); - sb.append("-"); - } - if (area != null && area.length() > 0) { - sb.append(area); - sb.append("-"); - } - if (number != null && number.length() > 0) { - sb.append(number); - } - if (extensionNumber != null && extensionNumber.length() > 0) { - sb.append("-"); - sb.append(extensionNumber); - } - return sb.toString(); - } - -} \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/serialize/serialization/AbstractSerializationPersonFailTest.java b/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/serialize/serialization/AbstractSerializationPersonFailTest.java deleted file mode 100644 index 5d27bb56558..00000000000 --- a/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/serialize/serialization/AbstractSerializationPersonFailTest.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.common.serialize.serialization; - -import org.apache.dubbo.common.model.Person; -import org.apache.dubbo.common.serialize.ObjectOutput; - -import org.junit.Test; - -import java.io.NotSerializableException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; -import static org.junit.matchers.JUnitMatchers.containsString; - -public abstract class AbstractSerializationPersonFailTest extends AbstractSerializationTest { - @Test - public void test_Person() throws Exception { - try { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(new Person()); - fail(); - } catch (NotSerializableException expected) { - } catch (IllegalStateException expected) { - assertThat(expected.getMessage(), containsString("Serialized class org.apache.dubbo.common.model.Person must implement java.io.Serializable")); - } - } - - @Test - public void test_PersonList() throws Exception { - List args = new ArrayList(); - args.add(new Person()); - try { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(args); - fail(); - } catch (NotSerializableException expected) { - } catch (IllegalStateException expected) { - assertThat(expected.getMessage(), containsString("Serialized class org.apache.dubbo.common.model.Person must implement java.io.Serializable")); - } - } - - @Test - public void test_PersonSet() throws Exception { - Set args = new HashSet(); - args.add(new Person()); - try { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(args); - fail(); - } catch (NotSerializableException expected) { - } catch (IllegalStateException expected) { - assertThat(expected.getMessage(), containsString("Serialized class org.apache.dubbo.common.model.Person must implement java.io.Serializable")); - } - } - - @Test - public void test_IntPersonMap() throws Exception { - Map args = new HashMap(); - args.put(1, new Person()); - try { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(args); - fail(); - } catch (NotSerializableException expected) { - } catch (IllegalStateException expected) { - assertThat(expected.getMessage(), containsString("Serialized class org.apache.dubbo.common.model.Person must implement java.io.Serializable")); - } - } - - @Test - public void test_StringPersonMap() throws Exception { - Map args = new HashMap(); - args.put("1", new Person()); - try { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(args); - fail(); - } catch (NotSerializableException expected) { - } catch (IllegalStateException expected) { - assertThat(expected.getMessage(), containsString("Serialized class org.apache.dubbo.common.model.Person must implement java.io.Serializable")); - } - } - - @Test - public void test_StringPersonListMap() throws Exception { - Map> args = new HashMap>(); - - List sublist = new ArrayList(); - sublist.add(new Person()); - args.put("1", sublist); - try { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(args); - fail(); - } catch (NotSerializableException expected) { - } catch (IllegalStateException expected) { - assertThat(expected.getMessage(), containsString("Serialized class org.apache.dubbo.common.model.Person must implement java.io.Serializable")); - } - } - - @Test - public void test_PersonListList() throws Exception { - List> args = new ArrayList>(); - List sublist = new ArrayList(); - sublist.add(new Person()); - args.add(sublist); - try { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(args); - fail(); - } catch (NotSerializableException expected) { - } catch (IllegalStateException expected) { - assertThat(expected.getMessage(), containsString("Serialized class org.apache.dubbo.common.model.Person must implement java.io.Serializable")); - } - } -} \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/serialize/serialization/AbstractSerializationPersonOkTest.java b/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/serialize/serialization/AbstractSerializationPersonOkTest.java deleted file mode 100644 index 03395cb0cd9..00000000000 --- a/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/serialize/serialization/AbstractSerializationPersonOkTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.common.serialize.serialization; - -import org.apache.dubbo.common.model.Person; - -import org.junit.Test; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -public abstract class AbstractSerializationPersonOkTest extends AbstractSerializationTest { - @Test - public void test_Person() throws Exception { - assertObject(new Person()); - } - - @Test - public void test_Person_withType() throws Exception { - assertObjectWithType(new Person(), Person.class); - } - - @Test - public void test_PersonList() throws Exception { - List args = new ArrayList(); - args.add(new Person()); - - assertObject(args); - } - - @Test - public void test_PersonSet() throws Exception { - Set args = new HashSet(); - args.add(new Person()); - - assertObject(args); - } - - @Test - public void test_IntPersonMap() throws Exception { - Map args = new HashMap(); - args.put(1, new Person()); - - assertObject(args); - } - - @Test - public void test_StringPersonMap() throws Exception { - Map args = new HashMap(); - args.put("1", new Person()); - - assertObject(args); - } - - @Test - public void test_StringPersonListMap() throws Exception { - Map> args = new HashMap>(); - - List sublist = new ArrayList(); - sublist.add(new Person()); - args.put("1", sublist); - - assertObject(args); - } - - @Test - public void test_PersonListList() throws Exception { - List> args = new ArrayList>(); - List sublist = new ArrayList(); - sublist.add(new Person()); - args.add(sublist); - - assertObject(args); - } -} \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-hessian2/src/test/resources/log4j.xml b/dubbo-serialization/dubbo-serialization-hessian2/src/test/resources/log4j.xml deleted file mode 100644 index d045b92c0de..00000000000 --- a/dubbo-serialization/dubbo-serialization-hessian2/src/test/resources/log4j.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/model/AnimalEnum.java b/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/model/AnimalEnum.java deleted file mode 100644 index 760663fe04c..00000000000 --- a/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/model/AnimalEnum.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.common.model; - -public enum AnimalEnum { - dog, cat, rat, cow, bull, horse; -} \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/model/SerializablePerson.java b/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/model/SerializablePerson.java deleted file mode 100644 index d78c5928ea8..00000000000 --- a/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/model/SerializablePerson.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.common.model; - -import java.io.Serializable; -import java.util.Arrays; - -public class SerializablePerson implements Serializable { - private static final long serialVersionUID = 1L; - byte oneByte = 123; - private String name = "name1"; - private int age = 11; - - private String[] value = {"value1", "value2"}; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public byte getOneByte() { - return oneByte; - } - - public void setOneByte(byte b) { - this.oneByte = b; - } - - public int getAge() { - return age; - } - - public void setAge(int age) { - this.age = age; - } - - public String[] getValue() { - return value; - } - - public void setValue(String[] value) { - this.value = value; - } - - @Override - public String toString() { - return String.format("Person name(%s) age(%d) byte(%s) [value=%s]", name, age, oneByte, Arrays.toString(value)); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + age; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + Arrays.hashCode(value); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - SerializablePerson other = (SerializablePerson) obj; - if (age != other.age) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (!Arrays.equals(value, other.value)) - return false; - return true; - } -} \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/model/media/Image.java b/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/model/media/Image.java deleted file mode 100644 index a59eff35be6..00000000000 --- a/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/model/media/Image.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.common.model.media; - - -public class Image implements java.io.Serializable { - private static final long serialVersionUID = 1L; - public String uri; - public String title; // Can be null - public int width; - public int height; - public Size size; - - public Image() { - } - - public Image(String uri, String title, int width, int height, Size size) { - this.height = height; - this.title = title; - this.uri = uri; - this.width = width; - this.size = size; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Image image = (Image) o; - - if (height != image.height) return false; - if (width != image.width) return false; - if (size != image.size) return false; - if (title != null ? !title.equals(image.title) : image.title != null) return false; - if (uri != null ? !uri.equals(image.uri) : image.uri != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = uri != null ? uri.hashCode() : 0; - result = 31 * result + (title != null ? title.hashCode() : 0); - result = 31 * result + width; - result = 31 * result + height; - result = 31 * result + (size != null ? size.hashCode() : 0); - return result; - } - - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("[Image "); - sb.append("uri=").append(uri); - sb.append(", title=").append(title); - sb.append(", width=").append(width); - sb.append(", height=").append(height); - sb.append(", size=").append(size); - sb.append("]"); - return sb.toString(); - } - - public String getUri() { - return uri; - } - - public void setUri(String uri) { - this.uri = uri; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public int getWidth() { - return width; - } - - public void setWidth(int width) { - this.width = width; - } - - public int getHeight() { - return height; - } - - public void setHeight(int height) { - this.height = height; - } - - public Size getSize() { - return size; - } - - public void setSize(Size size) { - this.size = size; - } - - public enum Size { - SMALL, LARGE - } -} \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/model/person/BigPerson.java b/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/model/person/BigPerson.java deleted file mode 100644 index 4ce79008fb4..00000000000 --- a/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/model/person/BigPerson.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.common.model.person; - -import java.io.Serializable; - -public class BigPerson implements Serializable { - private static final long serialVersionUID = 1L; - - String personId; - - String loginName; - - PersonStatus status; - - String email; - - String penName; - - PersonInfo infoProfile; - - public BigPerson() { - - } - - public BigPerson(String id) { - this.personId = id; - } - - public String getPersonId() { - return personId; - } - - public void setPersonId(String personId) { - this.personId = personId; - } - - public PersonInfo getInfoProfile() { - return infoProfile; - } - - public void setInfoProfile(PersonInfo infoProfile) { - this.infoProfile = infoProfile; - } - - public String getEmail() { - return this.email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getLoginName() { - return this.loginName; - } - - public void setLoginName(String loginName) { - this.loginName = loginName; - } - - public PersonStatus getStatus() { - return this.status; - } - - public void setStatus(PersonStatus status) { - this.status = status; - } - - public String getPenName() { - return penName; - } - - public void setPenName(String penName) { - this.penName = penName; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((email == null) ? 0 : email.hashCode()); - result = prime * result + ((infoProfile == null) ? 0 : infoProfile.hashCode()); - result = prime * result + ((loginName == null) ? 0 : loginName.hashCode()); - result = prime * result + ((penName == null) ? 0 : penName.hashCode()); - result = prime * result + ((personId == null) ? 0 : personId.hashCode()); - result = prime * result + ((status == null) ? 0 : status.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - BigPerson other = (BigPerson) obj; - if (email == null) { - if (other.email != null) - return false; - } else if (!email.equals(other.email)) - return false; - if (infoProfile == null) { - if (other.infoProfile != null) - return false; - } else if (!infoProfile.equals(other.infoProfile)) - return false; - if (loginName == null) { - if (other.loginName != null) - return false; - } else if (!loginName.equals(other.loginName)) - return false; - if (penName == null) { - if (other.penName != null) - return false; - } else if (!penName.equals(other.penName)) - return false; - if (personId == null) { - if (other.personId != null) - return false; - } else if (!personId.equals(other.personId)) - return false; - if (status != other.status) - return false; - return true; - } - - @Override - public String toString() { - return "BigPerson [personId=" + personId + ", loginName=" + loginName + ", status=" - + status + ", email=" + email + ", penName=" + penName + ", infoProfile=" - + infoProfile + "]"; - } - -} \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/model/person/FullAddress.java b/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/model/person/FullAddress.java deleted file mode 100644 index 38921670f97..00000000000 --- a/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/model/person/FullAddress.java +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.common.model.person; - -import java.io.Serializable; - -public class FullAddress implements Serializable { - - private static final long serialVersionUID = 5163979984269419831L; - - private String countryId; - - private String countryName; - - private String provinceName; - - private String cityId; - - private String cityName; - - private String streetAddress; - - private String zipCode; - - public FullAddress() { - } - - public FullAddress(String countryId, String provinceName, String cityId, String streetAddress, - String zipCode) { - this.countryId = countryId; - this.countryName = countryId; - this.provinceName = provinceName; - this.cityId = cityId; - this.cityName = cityId; - this.streetAddress = streetAddress; - this.zipCode = zipCode; - } - - public FullAddress(String countryId, String countryName, String provinceName, String cityId, - String cityName, String streetAddress, String zipCode) { - this.countryId = countryId; - this.countryName = countryName; - this.provinceName = provinceName; - this.cityId = cityId; - this.cityName = cityName; - this.streetAddress = streetAddress; - this.zipCode = zipCode; - } - - public String getCountryId() { - return countryId; - } - - public void setCountryId(String countryId) { - this.countryId = countryId; - } - - public String getCountryName() { - return countryName; - } - - public void setCountryName(String countryName) { - this.countryName = countryName; - } - - public String getProvinceName() { - return provinceName; - } - - public void setProvinceName(String provinceName) { - this.provinceName = provinceName; - } - - public String getCityId() { - return cityId; - } - - public void setCityId(String cityId) { - this.cityId = cityId; - } - - public String getCityName() { - return cityName; - } - - public void setCityName(String cityName) { - this.cityName = cityName; - } - - public String getStreetAddress() { - return streetAddress; - } - - public void setStreetAddress(String streetAddress) { - this.streetAddress = streetAddress; - } - - public String getZipCode() { - return zipCode; - } - - public void setZipCode(String zipCode) { - this.zipCode = zipCode; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((cityId == null) ? 0 : cityId.hashCode()); - result = prime * result + ((cityName == null) ? 0 : cityName.hashCode()); - result = prime * result + ((countryId == null) ? 0 : countryId.hashCode()); - result = prime * result + ((countryName == null) ? 0 : countryName.hashCode()); - result = prime * result + ((provinceName == null) ? 0 : provinceName.hashCode()); - result = prime * result + ((streetAddress == null) ? 0 : streetAddress.hashCode()); - result = prime * result + ((zipCode == null) ? 0 : zipCode.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - FullAddress other = (FullAddress) obj; - if (cityId == null) { - if (other.cityId != null) - return false; - } else if (!cityId.equals(other.cityId)) - return false; - if (cityName == null) { - if (other.cityName != null) - return false; - } else if (!cityName.equals(other.cityName)) - return false; - if (countryId == null) { - if (other.countryId != null) - return false; - } else if (!countryId.equals(other.countryId)) - return false; - if (countryName == null) { - if (other.countryName != null) - return false; - } else if (!countryName.equals(other.countryName)) - return false; - if (provinceName == null) { - if (other.provinceName != null) - return false; - } else if (!provinceName.equals(other.provinceName)) - return false; - if (streetAddress == null) { - if (other.streetAddress != null) - return false; - } else if (!streetAddress.equals(other.streetAddress)) - return false; - if (zipCode == null) { - if (other.zipCode != null) - return false; - } else if (!zipCode.equals(other.zipCode)) - return false; - return true; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - if (countryName != null && countryName.length() > 0) { - sb.append(countryName); - } - if (provinceName != null && provinceName.length() > 0) { - sb.append(" "); - sb.append(provinceName); - } - if (cityName != null && cityName.length() > 0) { - sb.append(" "); - sb.append(cityName); - } - if (streetAddress != null && streetAddress.length() > 0) { - sb.append(" "); - sb.append(streetAddress); - } - return sb.toString(); - } - -} \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/model/person/PersonStatus.java b/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/model/person/PersonStatus.java deleted file mode 100644 index 62869c2b80b..00000000000 --- a/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/model/person/PersonStatus.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.common.model.person; - -public enum PersonStatus { - ENABLED, - DISABLED -} \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/model/person/Phone.java b/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/model/person/Phone.java deleted file mode 100644 index 41fd38a92df..00000000000 --- a/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/model/person/Phone.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.common.model.person; - -import java.io.Serializable; - -public class Phone implements Serializable { - - private static final long serialVersionUID = 4399060521859707703L; - - private String country; - - private String area; - - private String number; - - private String extensionNumber; - - public Phone() { - } - - public Phone(String country, String area, String number, String extensionNumber) { - this.country = country; - this.area = area; - this.number = number; - this.extensionNumber = extensionNumber; - } - - public String getCountry() { - return country; - } - - public void setCountry(String country) { - this.country = country; - } - - public String getArea() { - return area; - } - - public void setArea(String area) { - this.area = area; - } - - public String getNumber() { - return number; - } - - public void setNumber(String number) { - this.number = number; - } - - public String getExtensionNumber() { - return extensionNumber; - } - - public void setExtensionNumber(String extensionNumber) { - this.extensionNumber = extensionNumber; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((area == null) ? 0 : area.hashCode()); - result = prime * result + ((country == null) ? 0 : country.hashCode()); - result = prime * result + ((extensionNumber == null) ? 0 : extensionNumber.hashCode()); - result = prime * result + ((number == null) ? 0 : number.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Phone other = (Phone) obj; - if (area == null) { - if (other.area != null) - return false; - } else if (!area.equals(other.area)) - return false; - if (country == null) { - if (other.country != null) - return false; - } else if (!country.equals(other.country)) - return false; - if (extensionNumber == null) { - if (other.extensionNumber != null) - return false; - } else if (!extensionNumber.equals(other.extensionNumber)) - return false; - if (number == null) { - if (other.number != null) - return false; - } else if (!number.equals(other.number)) - return false; - return true; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - if (country != null && country.length() > 0) { - sb.append(country); - sb.append("-"); - } - if (area != null && area.length() > 0) { - sb.append(area); - sb.append("-"); - } - if (number != null && number.length() > 0) { - sb.append(number); - } - if (extensionNumber != null && extensionNumber.length() > 0) { - sb.append("-"); - sb.append(extensionNumber); - } - return sb.toString(); - } - -} \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/serialize/serialization/AbstractSerializationTest.java b/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/serialize/serialization/AbstractSerializationTest.java deleted file mode 100644 index a40e3780944..00000000000 --- a/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/serialize/serialization/AbstractSerializationTest.java +++ /dev/null @@ -1,1210 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.common.serialize.serialization; - -import org.apache.dubbo.common.URL; -import org.apache.dubbo.common.model.AnimalEnum; -import org.apache.dubbo.common.model.BizException; -import org.apache.dubbo.common.model.BizExceptionNoDefaultConstructor; -import org.apache.dubbo.common.model.SerializablePerson; -import org.apache.dubbo.common.model.media.Image; -import org.apache.dubbo.common.model.media.Image.Size; -import org.apache.dubbo.common.model.media.Media; -import org.apache.dubbo.common.model.media.Media.Player; -import org.apache.dubbo.common.model.media.MediaContent; -import org.apache.dubbo.common.model.person.BigPerson; -import org.apache.dubbo.common.model.person.FullAddress; -import org.apache.dubbo.common.model.person.PersonInfo; -import org.apache.dubbo.common.model.person.PersonStatus; -import org.apache.dubbo.common.model.person.Phone; -import org.apache.dubbo.common.serialize.ObjectInput; -import org.apache.dubbo.common.serialize.ObjectOutput; -import org.apache.dubbo.common.serialize.Serialization; - -import org.junit.Test; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.sql.Time; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Random; -import java.util.Set; - -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -public abstract class AbstractSerializationTest { - static Random random = new Random(); - Serialization serialization; - URL url = new URL("protocol", "1.1.1.1", 1234); - ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - - // ================ Primitive Type ================ - BigPerson bigPerson; - MediaContent mediaContent; - - { - bigPerson = new BigPerson(); - bigPerson.setPersonId("superman111"); - bigPerson.setLoginName("superman"); - bigPerson.setStatus(PersonStatus.ENABLED); - bigPerson.setEmail("sm@1.com"); - bigPerson.setPenName("pname"); - - ArrayList phones = new ArrayList(); - Phone phone1 = new Phone("86", "0571", "87654321", "001"); - Phone phone2 = new Phone("86", "0571", "87654322", "002"); - phones.add(phone1); - phones.add(phone2); - - PersonInfo pi = new PersonInfo(); - pi.setPhones(phones); - Phone fax = new Phone("86", "0571", "87654321", null); - pi.setFax(fax); - FullAddress addr = new FullAddress("CN", "zj", "3480", "wensanlu", "315000"); - pi.setFullAddress(addr); - pi.setMobileNo("13584652131"); - pi.setMale(true); - pi.setDepartment("b2b"); - pi.setHomepageUrl("www.capcom.com"); - pi.setJobTitle("qa"); - pi.setName("superman"); - - bigPerson.setInfoProfile(pi); - } - - { - Media media = new Media(); - media.setUri("uri://中华人民共和国"); - media.setTitle("title"); - media.setWidth(1239); - media.setHeight(1938); - media.setFormat("format-xxxx"); - media.setDuration(93419235); - media.setSize(3477897); - media.setBitrate(94523); - List persons = new ArrayList(); - persons.add("jerry"); - persons.add("tom"); - persons.add("lucy"); - media.setPersons(persons); - media.setCopyright("1999-2011"); - media.setPlayer(Player.FLASH); - - List images = new ArrayList(); - for (int i = 0; i < 10; ++i) { - Image image = new Image(); - image.setUri("url" + i); - if (i % 2 == 0) image.setTitle("title" + i); - image.setWidth(34 + i); - image.setHeight(2323 + i); - image.setSize((i % 2 == 0) ? Size.SMALL : Size.LARGE); - - images.add(image); - } - - mediaContent = new MediaContent(media, images); - } - - @Test - public void test_Bool() throws Exception { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeBool(false); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertFalse(deserialize.readBool()); - - try { - deserialize.readBool(); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_Bool_Multi() throws Exception { - boolean[] array = new boolean[100]; - for (int i = 0; i < array.length; i++) { - array[i] = random.nextBoolean(); - } - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - for (boolean b : array) { - objectOutput.writeBool(b); - } - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - for (boolean b : array) { - assertEquals(b, deserialize.readBool()); - } - - try { - deserialize.readBool(); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_Byte() throws Exception { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeByte((byte) 123); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertEquals((byte) 123, deserialize.readByte()); - - try { - deserialize.readByte(); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_Byte_Multi() throws Exception { - byte[] array = new byte[100]; - random.nextBytes(array); - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - for (byte b : array) { - objectOutput.writeByte(b); - } - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - for (byte b : array) { - assertEquals(b, deserialize.readByte()); - } - - try { - deserialize.readByte(); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_Short() throws Exception { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeShort((short) 123); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertEquals((short) 123, deserialize.readShort()); - - try { - deserialize.readShort(); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_Integer() throws Exception { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeInt(1); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - int i = deserialize.readInt(); - assertEquals(1, i); - - try { - deserialize.readInt(); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_Long() throws Exception { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeLong(123L); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertEquals(123L, deserialize.readLong()); - - try { - deserialize.readLong(); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_Float() throws Exception { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeFloat(1.28F); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertTrue(1.28F == deserialize.readFloat()); - - try { - deserialize.readFloat(); - fail(); - } catch (IOException expected) { - } - } - - // ================== Util methods ================== - - @Test - public void test_Double() throws Exception { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeDouble(1.28); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertTrue(1.28 == deserialize.readDouble()); - - try { - deserialize.readDouble(); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_UtfString() throws Exception { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeUTF("123中华人民共和国"); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertEquals("123中华人民共和国", deserialize.readUTF()); - - try { - deserialize.readUTF(); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_Bytes() throws Exception { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeBytes("123中华人民共和国".getBytes()); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertArrayEquals("123中华人民共和国".getBytes(), deserialize.readBytes()); - - try { - deserialize.readBytes(); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_BytesRange() throws Exception { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeBytes("123中华人民共和国-新疆维吾尔自治区".getBytes(), 1, 9); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - byte[] expectedArray = new byte[9]; - System.arraycopy("123中华人民共和国-新疆维吾尔自治区".getBytes(), 1, expectedArray, 0, expectedArray.length); - assertArrayEquals(expectedArray, deserialize.readBytes()); - - try { - deserialize.readBytes(); - fail(); - } catch (IOException expected) { - } - } - - // ================ Array Type ================ - - void assertObjectArray(T[] data, Class clazz) throws Exception { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(data); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertArrayEquals(data, clazz.cast(deserialize.readObject())); - - try { - deserialize.readObject(); - fail(); - } catch (IOException expected) { - } - } - - void assertObjectArrayWithType(T[] data, Class clazz) throws Exception { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(data); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertArrayEquals(data, clazz.cast(deserialize.readObject(clazz))); - - try { - deserialize.readObject(clazz); - fail(); - } catch (IOException expected) { - } - } - - @SuppressWarnings("unchecked") - void assertObject(T data) throws Exception { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(data); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertEquals(data, (T) deserialize.readObject()); - - try { - deserialize.readObject(); - fail(); - } catch (IOException expected) { - } - } - - void assertObjectWithType(T data, Class clazz) throws Exception { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(data); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertEquals(data, (T) deserialize.readObject(clazz)); - - try { - deserialize.readObject(clazz); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_boolArray() throws Exception { - boolean[] data = new boolean[]{true, false, true}; - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(data); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertTrue(Arrays.equals(data, (boolean[]) deserialize.readObject())); - - try { - deserialize.readObject(); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_boolArray_withType() throws Exception { - boolean[] data = new boolean[]{true, false, true}; - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(data); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertTrue(Arrays.equals(data, (boolean[]) deserialize.readObject(boolean[].class))); - - try { - deserialize.readObject(boolean[].class); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_charArray() throws Exception { - char[] data = new char[]{'a', '中', '无'}; - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(data); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertArrayEquals(data, (char[]) deserialize.readObject()); - - try { - deserialize.readObject(); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_charArray_withType() throws Exception { - char[] data = new char[]{'a', '中', '无'}; - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(data); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertArrayEquals(data, (char[]) deserialize.readObject(char[].class)); - - try { - deserialize.readObject(char[].class); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_shortArray() throws Exception { - short[] data = new short[]{37, 39, 12}; - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(data); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertArrayEquals(data, (short[]) deserialize.readObject()); - - try { - deserialize.readObject(); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_shortArray_withType() throws Exception { - short[] data = new short[]{37, 39, 12}; - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(data); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertArrayEquals(data, (short[]) deserialize.readObject(short[].class)); - - try { - deserialize.readObject(short[].class); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_intArray() throws Exception { - int[] data = new int[]{234, 0, -1}; - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(data); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertArrayEquals(data, (int[]) deserialize.readObject()); - - try { - deserialize.readObject(); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_intArray_withType() throws Exception { - int[] data = new int[]{234, 0, -1}; - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(data); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertArrayEquals(data, (int[]) deserialize.readObject(int[].class)); - - try { - deserialize.readObject(int[].class); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_longArray() throws Exception { - long[] data = new long[]{234, 0, -1}; - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(data); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertArrayEquals(data, (long[]) deserialize.readObject()); - - try { - deserialize.readObject(); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_longArray_withType() throws Exception { - long[] data = new long[]{234, 0, -1}; - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(data); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertArrayEquals(data, (long[]) deserialize.readObject(long[].class)); - - try { - deserialize.readObject(long[].class); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_floatArray() throws Exception { - float[] data = new float[]{37F, -3.14F, 123456.7F}; - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(data); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertArrayEquals(data, (float[]) deserialize.readObject(), 0.0001F); - - try { - deserialize.readObject(); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_floatArray_withType() throws Exception { - float[] data = new float[]{37F, -3.14F, 123456.7F}; - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(data); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertArrayEquals(data, (float[]) deserialize.readObject(float[].class), 0.0001F); - - try { - deserialize.readObject(float[].class); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_doubleArray() throws Exception { - double[] data = new double[]{37D, -3.14D, 123456.7D}; - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(data); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertArrayEquals(data, (double[]) deserialize.readObject(), 0.0001); - - try { - deserialize.readObject(); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_doubleArray_withType() throws Exception { - double[] data = new double[]{37D, -3.14D, 123456.7D}; - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(data); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertArrayEquals(data, (double[]) deserialize.readObject(double[].class), 0.0001); - - try { - deserialize.readObject(double[].class); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_StringArray() throws Exception { - assertObjectArray(new String[]{"1", "b"}, String[].class); - } - - @Test - public void test_StringArray_withType() throws Exception { - assertObjectArrayWithType(new String[]{"1", "b"}, String[].class); - } - - // ================ Simple Type ================ - - @Test - public void test_IntegerArray() throws Exception { - assertObjectArray(new Integer[]{234, 0, -1}, Integer[].class); - } - - @Test - public void test_IntegerArray_withType() throws Exception { - assertObjectArrayWithType(new Integer[]{234, 0, -1}, Integer[].class); - } - - @Test - public void test_EnumArray() throws Exception { - assertObjectArray(new AnimalEnum[]{AnimalEnum.bull, AnimalEnum.cat, AnimalEnum.dog, AnimalEnum.horse}, AnimalEnum[].class); - } - - @Test - public void test_EnumArray_withType() throws Exception { - assertObjectArrayWithType(new AnimalEnum[]{AnimalEnum.bull, AnimalEnum.cat, AnimalEnum.dog, AnimalEnum.horse}, AnimalEnum[].class); - } - - @Test - public void test_SPerson() throws Exception { - assertObject(new SerializablePerson()); - } - - @Test - public void test_SPerson_withType() throws Exception { - assertObjectWithType(new SerializablePerson(), SerializablePerson.class); - } - - @Test - public void test_BizException() throws Exception { - BizException e = new BizException("Hello"); - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(e); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - Object read = deserialize.readObject(); - assertEquals("Hello", ((BizException) read).getMessage()); - } - - @Test - public void test_BizException_WithType() throws Exception { - BizException e = new BizException("Hello"); - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(e); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - Object read = deserialize.readObject(BizException.class); - assertEquals("Hello", ((BizException) read).getMessage()); - } - - @Test - public void test_BizExceptionNoDefaultConstructor() throws Exception { - BizExceptionNoDefaultConstructor e = new BizExceptionNoDefaultConstructor("Hello"); - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(e); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - Object read = deserialize.readObject(); - assertEquals("Hello", ((BizExceptionNoDefaultConstructor) read).getMessage()); - } - - @Test - public void test_BizExceptionNoDefaultConstructor_WithType() throws Exception { - BizExceptionNoDefaultConstructor e = new BizExceptionNoDefaultConstructor("Hello"); - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(e); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - Object read = deserialize.readObject(BizExceptionNoDefaultConstructor.class); - assertEquals("Hello", ((BizExceptionNoDefaultConstructor) read).getMessage()); - } - - @Test - public void test_enum() throws Exception { - assertObject(AnimalEnum.dog); - } - - @Test - public void test_enum_withType() throws Exception { - assertObjectWithType(AnimalEnum.dog, AnimalEnum.class); - } - - @Test - public void test_Date() throws Exception { - assertObject(new Date()); - } - - @Test - public void test_Date_withType() throws Exception { - assertObjectWithType(new Date(), Date.class); - } - - @Test - public void test_Time() throws Exception { - assertObject(new Time(System.currentTimeMillis())); - } - - @Test - public void test_Time_withType() throws Exception { - assertObjectWithType(new Time(System.currentTimeMillis()), Time.class); - } - - @Test - public void test_ByteWrap() throws Exception { - assertObject(new Byte((byte) 12)); - } - - @Test - public void test_ByteWrap_withType() throws Exception { - assertObjectWithType(new Byte((byte) 12), Byte.class); - } - - @Test - public void test_LongWrap() throws Exception { - assertObject(new Long(12)); - } - - @Test - public void test_LongWrap_withType() throws Exception { - assertObjectWithType(new Long(12), Long.class); - } - - @Test - public void test_BigInteger() throws Exception { - assertObject(new BigInteger("23423434234234234")); - } - - @Test - public void test_BigInteger_withType() throws Exception { - assertObjectWithType(new BigInteger("23423434234234234"), BigInteger.class); - } - - @Test - public void test_BigDecimal() throws Exception { - assertObject(new BigDecimal("23423434234234234.341274832341234235")); - } - - @Test - public void test_BigDecimal_withType() throws Exception { - assertObjectWithType(new BigDecimal("23423434234234234.341274832341234235"), BigDecimal.class); - } - - @Test - public void test_StringList_asListReturn() throws Exception { - List args = Arrays.asList(new String[]{"1", "b"}); - - assertObject(args); - } - - @Test - public void test_StringArrayList() throws Exception { - List args = new ArrayList(Arrays.asList(new String[]{"1", "b"})); - - assertObject(args); - } - - @Test - public void test_StringSet() throws Exception { - Set args = new HashSet(); - args.add("1"); - - assertObject(args); - } - - @Test - public void test_LinkedHashMap() throws Exception { - LinkedHashMap data = new LinkedHashMap(); - data.put("1", "a"); - data.put("2", "b"); - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(data); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - Object read = deserialize.readObject(); - assertTrue(read instanceof LinkedHashMap); - @SuppressWarnings("unchecked") - String key1 = ((LinkedHashMap) read).entrySet().iterator().next().getKey(); - assertEquals("1", key1); - - assertEquals(data, read); - - try { - deserialize.readObject(); - fail(); - } catch (IOException expected) { - } - } - - // ================ Complex Collection Type ================ - - @Test - public void test_SPersonList() throws Exception { - List args = new ArrayList(); - args.add(new SerializablePerson()); - - assertObject(args); - } - - @Test - public void test_SPersonSet() throws Exception { - Set args = new HashSet(); - args.add(new SerializablePerson()); - - assertObject(args); - } - - // ================ complex POJO ============= - - @Test - public void test_IntSPersonMap() throws Exception { - Map args = new HashMap(); - args.put(1, new SerializablePerson()); - - assertObject(args); - } - - @Test - public void test_StringSPersonMap() throws Exception { - Map args = new HashMap(); - args.put("1", new SerializablePerson()); - - assertObject(args); - } - - @Test - public void test_StringSPersonListMap() throws Exception { - Map> args = new HashMap>(); - - List sublist = new ArrayList(); - sublist.add(new SerializablePerson()); - args.put("1", sublist); - - assertObject(args); - } - - @Test - public void test_SPersonListList() throws Exception { - List> args = new ArrayList>(); - List sublist = new ArrayList(); - sublist.add(new SerializablePerson()); - args.add(sublist); - - assertObject(args); - } - - @Test - public void test_BigPerson() throws Exception { - assertObject(bigPerson); - } - - @Test - public void test_BigPerson_WithType() throws Exception { - assertObjectWithType(bigPerson, BigPerson.class); - } - - @Test - public void test_MediaContent() throws Exception { - assertObject(mediaContent); - } - - @Test - public void test_MediaContent_WithType() throws Exception { - assertObjectWithType(mediaContent, MediaContent.class); - } - - @Test - public void test_MultiObject() throws Exception { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeBool(false); - objectOutput.writeObject(bigPerson); - objectOutput.writeByte((byte) 23); - objectOutput.writeObject(mediaContent); - objectOutput.writeInt(-23); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertEquals(false, deserialize.readBool()); - assertEquals(bigPerson, deserialize.readObject()); - assertEquals((byte) 23, deserialize.readByte()); - assertEquals(mediaContent, deserialize.readObject()); - assertEquals(-23, deserialize.readInt()); - - try { - deserialize.readObject(); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_MultiObject_WithType() throws Exception { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeBool(false); - objectOutput.writeObject(bigPerson); - objectOutput.writeByte((byte) 23); - objectOutput.writeObject(mediaContent); - objectOutput.writeInt(-23); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertEquals(false, deserialize.readBool()); - assertEquals(bigPerson, deserialize.readObject(BigPerson.class)); - assertEquals((byte) 23, deserialize.readByte()); - assertEquals(mediaContent, deserialize.readObject(MediaContent.class)); - assertEquals(-23, deserialize.readInt()); - - try { - deserialize.readObject(); - fail(); - } catch (IOException expected) { - } - } - - - // abnormal case - - @Test - public void test_MediaContent_badStream() throws Exception { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(mediaContent); - objectOutput.flushBuffer(); - - byte[] byteArray = byteArrayOutputStream.toByteArray(); - for (int i = 0; i < byteArray.length; i++) { - if (i % 3 == 0) { - byteArray[i] = (byte) ~byteArray[i]; - } - } - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArray); - - try { - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - @SuppressWarnings("unused") // local variable, convenient for debug - Object read = deserialize.readObject(); - fail(); - } catch (IOException expected) { - System.out.println(expected); - } - } - - @Test - public void test_MediaContent_WithType_badStream() throws Exception { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(mediaContent); - objectOutput.flushBuffer(); - - byte[] byteArray = byteArrayOutputStream.toByteArray(); - for (int i = 0; i < byteArray.length; i++) { - if (i % 3 == 0) { - byteArray[i] = (byte) ~byteArray[i]; - } - } - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArray); - - try { - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - @SuppressWarnings("unused") // local variable, convenient for debug - Object read = deserialize.readObject(MediaContent.class); - fail(); - } catch (IOException expected) { - System.out.println(expected); - } - } - - - @Test(timeout = 3000) - public void test_LoopReference() throws Exception { - Map map = new HashMap(); - map.put("k1", "v1"); - map.put("self", map); - - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(map); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - @SuppressWarnings("unchecked") - Map output = (Map) deserialize.readObject(); - - assertEquals("v1", output.get("k1")); - assertSame(output, output.get("self")); - } - - // ================ final field test ================ - - @Test - public void test_URL_mutable_withType() throws Exception { - URL data = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan&noValue"); - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(data); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - URL actual = (URL) deserialize.readObject(URL.class); - assertEquals(data, actual); - assertEquals(data.getParameters(), actual.getParameters()); - - try { - deserialize.readObject(); - fail(); - } catch (IOException expected) { - } - } -} \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-jdk/src/test/resources/log4j.xml b/dubbo-serialization/dubbo-serialization-jdk/src/test/resources/log4j.xml deleted file mode 100644 index d045b92c0de..00000000000 --- a/dubbo-serialization/dubbo-serialization-jdk/src/test/resources/log4j.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-jdk/src/test/resources/org/apache/dubbo/common/serialize/dubbo/SimpleDO.fc b/dubbo-serialization/dubbo-serialization-jdk/src/test/resources/org/apache/dubbo/common/serialize/dubbo/SimpleDO.fc deleted file mode 100644 index c8c083c17eb..00000000000 --- a/dubbo-serialization/dubbo-serialization-jdk/src/test/resources/org/apache/dubbo/common/serialize/dubbo/SimpleDO.fc +++ /dev/null @@ -1,2 +0,0 @@ -a,d,e,b,c -str3,str2 \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/model/BizException.java b/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/model/BizException.java deleted file mode 100644 index 95f4046afa0..00000000000 --- a/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/model/BizException.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.common.model; - -public class BizException extends RuntimeException { - - private static final long serialVersionUID = 1L; - - public BizException(String message) { - super(message); - } - - public BizException() { - } -} \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/model/BizExceptionNoDefaultConstructor.java b/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/model/BizExceptionNoDefaultConstructor.java deleted file mode 100644 index f1ffadb0234..00000000000 --- a/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/model/BizExceptionNoDefaultConstructor.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.common.model; - -public class BizExceptionNoDefaultConstructor extends RuntimeException { - - private static final long serialVersionUID = 1L; - - public BizExceptionNoDefaultConstructor(String message) { - super(message); - } -} \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/model/Person.java b/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/model/Person.java deleted file mode 100644 index 5a551a7f36b..00000000000 --- a/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/model/Person.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.common.model; - -import java.util.Arrays; - -public class Person { - byte oneByte = 123; - private String name = "name1"; - private int age = 11; - - private String[] value = {"value1", "value2"}; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public byte getOneByte() { - return oneByte; - } - - public void setOneByte(byte b) { - this.oneByte = b; - } - - public int getAge() { - return age; - } - - public void setAge(int age) { - this.age = age; - } - - public String[] getValue() { - return value; - } - - public void setValue(String[] value) { - this.value = value; - } - - @Override - public String toString() { - return String.format("Person name(%s) age(%d) byte(%s) [value=%s]", name, age, oneByte, Arrays.toString(value)); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + age; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + Arrays.hashCode(value); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Person other = (Person) obj; - if (age != other.age) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (!Arrays.equals(value, other.value)) - return false; - return true; - } -} \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/model/media/Media.java b/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/model/media/Media.java deleted file mode 100644 index 042a3a5273a..00000000000 --- a/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/model/media/Media.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.common.model.media; - -import java.util.List; - -@SuppressWarnings("serial") -public class Media implements java.io.Serializable { - public String uri; - public String title; // Can be unset. - public int width; - public int height; - public String format; - public long duration; - public long size; - public int bitrate; // Can be unset. - public boolean hasBitrate; - public List persons; - public Player player; - public String copyright; // Can be unset. - - public Media() { - } - - public Media(String uri, String title, int width, int height, String format, long duration, long size, int bitrate, boolean hasBitrate, List persons, Player player, String copyright) { - this.uri = uri; - this.title = title; - this.width = width; - this.height = height; - this.format = format; - this.duration = duration; - this.size = size; - this.bitrate = bitrate; - this.hasBitrate = hasBitrate; - this.persons = persons; - this.player = player; - this.copyright = copyright; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Media media = (Media) o; - - if (bitrate != media.bitrate) return false; - if (duration != media.duration) return false; - if (hasBitrate != media.hasBitrate) return false; - if (height != media.height) return false; - if (size != media.size) return false; - if (width != media.width) return false; - if (copyright != null ? !copyright.equals(media.copyright) : media.copyright != null) return false; - if (format != null ? !format.equals(media.format) : media.format != null) return false; - if (persons != null ? !persons.equals(media.persons) : media.persons != null) return false; - if (player != media.player) return false; - if (title != null ? !title.equals(media.title) : media.title != null) return false; - if (uri != null ? !uri.equals(media.uri) : media.uri != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = uri != null ? uri.hashCode() : 0; - result = 31 * result + (title != null ? title.hashCode() : 0); - result = 31 * result + width; - result = 31 * result + height; - result = 31 * result + (format != null ? format.hashCode() : 0); - result = 31 * result + (int) (duration ^ (duration >>> 32)); - result = 31 * result + (int) (size ^ (size >>> 32)); - result = 31 * result + bitrate; - result = 31 * result + (hasBitrate ? 1 : 0); - result = 31 * result + (persons != null ? persons.hashCode() : 0); - result = 31 * result + (player != null ? player.hashCode() : 0); - result = 31 * result + (copyright != null ? copyright.hashCode() : 0); - return result; - } - - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("[Media "); - sb.append("uri=").append(uri); - sb.append(", title=").append(title); - sb.append(", width=").append(width); - sb.append(", height=").append(height); - sb.append(", format=").append(format); - sb.append(", duration=").append(duration); - sb.append(", size=").append(size); - sb.append(", hasBitrate=").append(hasBitrate); - sb.append(", bitrate=").append(String.valueOf(bitrate)); - sb.append(", persons=").append(persons); - sb.append(", player=").append(player); - sb.append(", copyright=").append(copyright); - sb.append("]"); - return sb.toString(); - } - - public String getUri() { - return uri; - } - - public void setUri(String uri) { - this.uri = uri; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public int getWidth() { - return width; - } - - public void setWidth(int width) { - this.width = width; - } - - public int getHeight() { - return height; - } - - public void setHeight(int height) { - this.height = height; - } - - public String getFormat() { - return format; - } - - public void setFormat(String format) { - this.format = format; - } - - public long getDuration() { - return duration; - } - - public void setDuration(long duration) { - this.duration = duration; - } - - public long getSize() { - return size; - } - - public void setSize(long size) { - this.size = size; - } - - public int getBitrate() { - return bitrate; - } - - public void setBitrate(int bitrate) { - this.bitrate = bitrate; - this.hasBitrate = true; - } - - public List getPersons() { - return persons; - } - - public void setPersons(List persons) { - this.persons = persons; - } - - public Player getPlayer() { - return player; - } - - public void setPlayer(Player player) { - this.player = player; - } - - public String getCopyright() { - return copyright; - } - - public void setCopyright(String copyright) { - this.copyright = copyright; - } - - public enum Player { - JAVA, FLASH - } -} \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/model/media/MediaContent.java b/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/model/media/MediaContent.java deleted file mode 100644 index 7991f506101..00000000000 --- a/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/model/media/MediaContent.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.common.model.media; - -import java.util.List; - -@SuppressWarnings("serial") -public class MediaContent implements java.io.Serializable { - public Media media; - public List images; - - public MediaContent() { - } - - public MediaContent(Media media, List images) { - this.media = media; - this.images = images; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - MediaContent that = (MediaContent) o; - - if (images != null ? !images.equals(that.images) : that.images != null) return false; - if (media != null ? !media.equals(that.media) : that.media != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = media != null ? media.hashCode() : 0; - result = 31 * result + (images != null ? images.hashCode() : 0); - return result; - } - - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("[MediaContent: "); - sb.append("media=").append(media); - sb.append(", images=").append(images); - sb.append("]"); - return sb.toString(); - } - - public Media getMedia() { - return media; - } - - public void setMedia(Media media) { - this.media = media; - } - - public List getImages() { - return images; - } - - public void setImages(List images) { - this.images = images; - } -} \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/model/person/BigPerson.java b/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/model/person/BigPerson.java deleted file mode 100644 index 4ce79008fb4..00000000000 --- a/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/model/person/BigPerson.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.common.model.person; - -import java.io.Serializable; - -public class BigPerson implements Serializable { - private static final long serialVersionUID = 1L; - - String personId; - - String loginName; - - PersonStatus status; - - String email; - - String penName; - - PersonInfo infoProfile; - - public BigPerson() { - - } - - public BigPerson(String id) { - this.personId = id; - } - - public String getPersonId() { - return personId; - } - - public void setPersonId(String personId) { - this.personId = personId; - } - - public PersonInfo getInfoProfile() { - return infoProfile; - } - - public void setInfoProfile(PersonInfo infoProfile) { - this.infoProfile = infoProfile; - } - - public String getEmail() { - return this.email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getLoginName() { - return this.loginName; - } - - public void setLoginName(String loginName) { - this.loginName = loginName; - } - - public PersonStatus getStatus() { - return this.status; - } - - public void setStatus(PersonStatus status) { - this.status = status; - } - - public String getPenName() { - return penName; - } - - public void setPenName(String penName) { - this.penName = penName; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((email == null) ? 0 : email.hashCode()); - result = prime * result + ((infoProfile == null) ? 0 : infoProfile.hashCode()); - result = prime * result + ((loginName == null) ? 0 : loginName.hashCode()); - result = prime * result + ((penName == null) ? 0 : penName.hashCode()); - result = prime * result + ((personId == null) ? 0 : personId.hashCode()); - result = prime * result + ((status == null) ? 0 : status.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - BigPerson other = (BigPerson) obj; - if (email == null) { - if (other.email != null) - return false; - } else if (!email.equals(other.email)) - return false; - if (infoProfile == null) { - if (other.infoProfile != null) - return false; - } else if (!infoProfile.equals(other.infoProfile)) - return false; - if (loginName == null) { - if (other.loginName != null) - return false; - } else if (!loginName.equals(other.loginName)) - return false; - if (penName == null) { - if (other.penName != null) - return false; - } else if (!penName.equals(other.penName)) - return false; - if (personId == null) { - if (other.personId != null) - return false; - } else if (!personId.equals(other.personId)) - return false; - if (status != other.status) - return false; - return true; - } - - @Override - public String toString() { - return "BigPerson [personId=" + personId + ", loginName=" + loginName + ", status=" - + status + ", email=" + email + ", penName=" + penName + ", infoProfile=" - + infoProfile + "]"; - } - -} \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/model/person/FullAddress.java b/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/model/person/FullAddress.java deleted file mode 100644 index 38921670f97..00000000000 --- a/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/model/person/FullAddress.java +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.common.model.person; - -import java.io.Serializable; - -public class FullAddress implements Serializable { - - private static final long serialVersionUID = 5163979984269419831L; - - private String countryId; - - private String countryName; - - private String provinceName; - - private String cityId; - - private String cityName; - - private String streetAddress; - - private String zipCode; - - public FullAddress() { - } - - public FullAddress(String countryId, String provinceName, String cityId, String streetAddress, - String zipCode) { - this.countryId = countryId; - this.countryName = countryId; - this.provinceName = provinceName; - this.cityId = cityId; - this.cityName = cityId; - this.streetAddress = streetAddress; - this.zipCode = zipCode; - } - - public FullAddress(String countryId, String countryName, String provinceName, String cityId, - String cityName, String streetAddress, String zipCode) { - this.countryId = countryId; - this.countryName = countryName; - this.provinceName = provinceName; - this.cityId = cityId; - this.cityName = cityName; - this.streetAddress = streetAddress; - this.zipCode = zipCode; - } - - public String getCountryId() { - return countryId; - } - - public void setCountryId(String countryId) { - this.countryId = countryId; - } - - public String getCountryName() { - return countryName; - } - - public void setCountryName(String countryName) { - this.countryName = countryName; - } - - public String getProvinceName() { - return provinceName; - } - - public void setProvinceName(String provinceName) { - this.provinceName = provinceName; - } - - public String getCityId() { - return cityId; - } - - public void setCityId(String cityId) { - this.cityId = cityId; - } - - public String getCityName() { - return cityName; - } - - public void setCityName(String cityName) { - this.cityName = cityName; - } - - public String getStreetAddress() { - return streetAddress; - } - - public void setStreetAddress(String streetAddress) { - this.streetAddress = streetAddress; - } - - public String getZipCode() { - return zipCode; - } - - public void setZipCode(String zipCode) { - this.zipCode = zipCode; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((cityId == null) ? 0 : cityId.hashCode()); - result = prime * result + ((cityName == null) ? 0 : cityName.hashCode()); - result = prime * result + ((countryId == null) ? 0 : countryId.hashCode()); - result = prime * result + ((countryName == null) ? 0 : countryName.hashCode()); - result = prime * result + ((provinceName == null) ? 0 : provinceName.hashCode()); - result = prime * result + ((streetAddress == null) ? 0 : streetAddress.hashCode()); - result = prime * result + ((zipCode == null) ? 0 : zipCode.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - FullAddress other = (FullAddress) obj; - if (cityId == null) { - if (other.cityId != null) - return false; - } else if (!cityId.equals(other.cityId)) - return false; - if (cityName == null) { - if (other.cityName != null) - return false; - } else if (!cityName.equals(other.cityName)) - return false; - if (countryId == null) { - if (other.countryId != null) - return false; - } else if (!countryId.equals(other.countryId)) - return false; - if (countryName == null) { - if (other.countryName != null) - return false; - } else if (!countryName.equals(other.countryName)) - return false; - if (provinceName == null) { - if (other.provinceName != null) - return false; - } else if (!provinceName.equals(other.provinceName)) - return false; - if (streetAddress == null) { - if (other.streetAddress != null) - return false; - } else if (!streetAddress.equals(other.streetAddress)) - return false; - if (zipCode == null) { - if (other.zipCode != null) - return false; - } else if (!zipCode.equals(other.zipCode)) - return false; - return true; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - if (countryName != null && countryName.length() > 0) { - sb.append(countryName); - } - if (provinceName != null && provinceName.length() > 0) { - sb.append(" "); - sb.append(provinceName); - } - if (cityName != null && cityName.length() > 0) { - sb.append(" "); - sb.append(cityName); - } - if (streetAddress != null && streetAddress.length() > 0) { - sb.append(" "); - sb.append(streetAddress); - } - return sb.toString(); - } - -} \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/model/person/PersonInfo.java b/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/model/person/PersonInfo.java deleted file mode 100644 index 15f1238fe85..00000000000 --- a/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/model/person/PersonInfo.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.common.model.person; - -import java.io.Serializable; -import java.util.List; - -public class PersonInfo implements Serializable { - private static final long serialVersionUID = 7443011149612231882L; - - List phones; - - Phone fax; - - FullAddress fullAddress; - - String mobileNo; - - String name; - - boolean male; - - boolean female; - - String department; - - String jobTitle; - - String homepageUrl; - - public List getPhones() { - return phones; - } - - public void setPhones(List phones) { - this.phones = phones; - } - - public boolean isMale() { - return male; - } - - public void setMale(boolean male) { - this.male = male; - } - - public boolean isFemale() { - return female; - } - - public void setFemale(boolean female) { - this.female = female; - } - - public String getDepartment() { - return department; - } - - public void setDepartment(String department) { - this.department = department; - } - - public Phone getFax() { - return fax; - } - - public void setFax(Phone fax) { - this.fax = fax; - } - - public FullAddress getFullAddress() { - return fullAddress; - } - - public void setFullAddress(FullAddress fullAddress) { - this.fullAddress = fullAddress; - } - - public String getHomepageUrl() { - return homepageUrl; - } - - public void setHomepageUrl(String homepageUrl) { - this.homepageUrl = homepageUrl; - } - - public String getJobTitle() { - return jobTitle; - } - - public void setJobTitle(String jobTitle) { - this.jobTitle = jobTitle; - } - - public String getMobileNo() { - return mobileNo; - } - - public void setMobileNo(String mobileNo) { - this.mobileNo = mobileNo; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((department == null) ? 0 : department.hashCode()); - result = prime * result + ((fax == null) ? 0 : fax.hashCode()); - result = prime * result + (female ? 1231 : 1237); - result = prime * result + ((fullAddress == null) ? 0 : fullAddress.hashCode()); - result = prime * result + ((homepageUrl == null) ? 0 : homepageUrl.hashCode()); - result = prime * result + ((jobTitle == null) ? 0 : jobTitle.hashCode()); - result = prime * result + (male ? 1231 : 1237); - result = prime * result + ((mobileNo == null) ? 0 : mobileNo.hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((phones == null) ? 0 : phones.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - PersonInfo other = (PersonInfo) obj; - if (department == null) { - if (other.department != null) - return false; - } else if (!department.equals(other.department)) - return false; - if (fax == null) { - if (other.fax != null) - return false; - } else if (!fax.equals(other.fax)) - return false; - if (female != other.female) - return false; - if (fullAddress == null) { - if (other.fullAddress != null) - return false; - } else if (!fullAddress.equals(other.fullAddress)) - return false; - if (homepageUrl == null) { - if (other.homepageUrl != null) - return false; - } else if (!homepageUrl.equals(other.homepageUrl)) - return false; - if (jobTitle == null) { - if (other.jobTitle != null) - return false; - } else if (!jobTitle.equals(other.jobTitle)) - return false; - if (male != other.male) - return false; - if (mobileNo == null) { - if (other.mobileNo != null) - return false; - } else if (!mobileNo.equals(other.mobileNo)) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (phones == null) { - if (other.phones != null) - return false; - } else if (!phones.equals(other.phones)) - return false; - return true; - } - - @Override - public String toString() { - return "PersonInfo [phones=" + phones + ", fax=" + fax + ", fullAddress=" + fullAddress - + ", mobileNo=" + mobileNo + ", name=" + name + ", male=" + male + ", female=" - + female + ", department=" + department + ", jobTitle=" + jobTitle - + ", homepageUrl=" + homepageUrl + "]"; - } - -} diff --git a/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/serialize/serialization/AbstractSerializationPersonFailTest.java b/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/serialize/serialization/AbstractSerializationPersonFailTest.java deleted file mode 100644 index 5d27bb56558..00000000000 --- a/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/serialize/serialization/AbstractSerializationPersonFailTest.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.common.serialize.serialization; - -import org.apache.dubbo.common.model.Person; -import org.apache.dubbo.common.serialize.ObjectOutput; - -import org.junit.Test; - -import java.io.NotSerializableException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; -import static org.junit.matchers.JUnitMatchers.containsString; - -public abstract class AbstractSerializationPersonFailTest extends AbstractSerializationTest { - @Test - public void test_Person() throws Exception { - try { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(new Person()); - fail(); - } catch (NotSerializableException expected) { - } catch (IllegalStateException expected) { - assertThat(expected.getMessage(), containsString("Serialized class org.apache.dubbo.common.model.Person must implement java.io.Serializable")); - } - } - - @Test - public void test_PersonList() throws Exception { - List args = new ArrayList(); - args.add(new Person()); - try { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(args); - fail(); - } catch (NotSerializableException expected) { - } catch (IllegalStateException expected) { - assertThat(expected.getMessage(), containsString("Serialized class org.apache.dubbo.common.model.Person must implement java.io.Serializable")); - } - } - - @Test - public void test_PersonSet() throws Exception { - Set args = new HashSet(); - args.add(new Person()); - try { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(args); - fail(); - } catch (NotSerializableException expected) { - } catch (IllegalStateException expected) { - assertThat(expected.getMessage(), containsString("Serialized class org.apache.dubbo.common.model.Person must implement java.io.Serializable")); - } - } - - @Test - public void test_IntPersonMap() throws Exception { - Map args = new HashMap(); - args.put(1, new Person()); - try { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(args); - fail(); - } catch (NotSerializableException expected) { - } catch (IllegalStateException expected) { - assertThat(expected.getMessage(), containsString("Serialized class org.apache.dubbo.common.model.Person must implement java.io.Serializable")); - } - } - - @Test - public void test_StringPersonMap() throws Exception { - Map args = new HashMap(); - args.put("1", new Person()); - try { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(args); - fail(); - } catch (NotSerializableException expected) { - } catch (IllegalStateException expected) { - assertThat(expected.getMessage(), containsString("Serialized class org.apache.dubbo.common.model.Person must implement java.io.Serializable")); - } - } - - @Test - public void test_StringPersonListMap() throws Exception { - Map> args = new HashMap>(); - - List sublist = new ArrayList(); - sublist.add(new Person()); - args.put("1", sublist); - try { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(args); - fail(); - } catch (NotSerializableException expected) { - } catch (IllegalStateException expected) { - assertThat(expected.getMessage(), containsString("Serialized class org.apache.dubbo.common.model.Person must implement java.io.Serializable")); - } - } - - @Test - public void test_PersonListList() throws Exception { - List> args = new ArrayList>(); - List sublist = new ArrayList(); - sublist.add(new Person()); - args.add(sublist); - try { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(args); - fail(); - } catch (NotSerializableException expected) { - } catch (IllegalStateException expected) { - assertThat(expected.getMessage(), containsString("Serialized class org.apache.dubbo.common.model.Person must implement java.io.Serializable")); - } - } -} \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/serialize/serialization/AbstractSerializationPersonOkTest.java b/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/serialize/serialization/AbstractSerializationPersonOkTest.java deleted file mode 100644 index 03395cb0cd9..00000000000 --- a/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/serialize/serialization/AbstractSerializationPersonOkTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.common.serialize.serialization; - -import org.apache.dubbo.common.model.Person; - -import org.junit.Test; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -public abstract class AbstractSerializationPersonOkTest extends AbstractSerializationTest { - @Test - public void test_Person() throws Exception { - assertObject(new Person()); - } - - @Test - public void test_Person_withType() throws Exception { - assertObjectWithType(new Person(), Person.class); - } - - @Test - public void test_PersonList() throws Exception { - List args = new ArrayList(); - args.add(new Person()); - - assertObject(args); - } - - @Test - public void test_PersonSet() throws Exception { - Set args = new HashSet(); - args.add(new Person()); - - assertObject(args); - } - - @Test - public void test_IntPersonMap() throws Exception { - Map args = new HashMap(); - args.put(1, new Person()); - - assertObject(args); - } - - @Test - public void test_StringPersonMap() throws Exception { - Map args = new HashMap(); - args.put("1", new Person()); - - assertObject(args); - } - - @Test - public void test_StringPersonListMap() throws Exception { - Map> args = new HashMap>(); - - List sublist = new ArrayList(); - sublist.add(new Person()); - args.put("1", sublist); - - assertObject(args); - } - - @Test - public void test_PersonListList() throws Exception { - List> args = new ArrayList>(); - List sublist = new ArrayList(); - sublist.add(new Person()); - args.add(sublist); - - assertObject(args); - } -} \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/serialize/serialization/AbstractSerializationTest.java b/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/serialize/serialization/AbstractSerializationTest.java deleted file mode 100644 index 411627f0dd6..00000000000 --- a/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/serialize/serialization/AbstractSerializationTest.java +++ /dev/null @@ -1,1215 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.common.serialize.serialization; - -import org.apache.dubbo.common.URL; -import org.apache.dubbo.common.model.AnimalEnum; -import org.apache.dubbo.common.model.BizException; -import org.apache.dubbo.common.model.BizExceptionNoDefaultConstructor; -import org.apache.dubbo.common.model.SerializablePerson; -import org.apache.dubbo.common.model.media.Image; -import org.apache.dubbo.common.model.media.Image.Size; -import org.apache.dubbo.common.model.media.Media; -import org.apache.dubbo.common.model.media.Media.Player; -import org.apache.dubbo.common.model.media.MediaContent; -import org.apache.dubbo.common.model.person.BigPerson; -import org.apache.dubbo.common.model.person.FullAddress; -import org.apache.dubbo.common.model.person.PersonInfo; -import org.apache.dubbo.common.model.person.PersonStatus; -import org.apache.dubbo.common.model.person.Phone; -import org.apache.dubbo.common.serialize.ObjectInput; -import org.apache.dubbo.common.serialize.ObjectOutput; -import org.apache.dubbo.common.serialize.Serialization; -import org.junit.Test; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.sql.Time; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Random; -import java.util.Set; - -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -public abstract class AbstractSerializationTest { - static Random random = new Random(); - Serialization serialization; - URL url = new URL("protocol", "1.1.1.1", 1234); - ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - - // ================ Primitive Type ================ - BigPerson bigPerson; - MediaContent mediaContent; - - { - bigPerson = new BigPerson(); - bigPerson.setPersonId("superman111"); - bigPerson.setLoginName("superman"); - bigPerson.setStatus(PersonStatus.ENABLED); - bigPerson.setEmail("sm@1.com"); - bigPerson.setPenName("pname"); - - ArrayList phones = new ArrayList(); - Phone phone1 = new Phone("86", "0571", "87654321", "001"); - Phone phone2 = new Phone("86", "0571", "87654322", "002"); - phones.add(phone1); - phones.add(phone2); - - PersonInfo pi = new PersonInfo(); - pi.setPhones(phones); - Phone fax = new Phone("86", "0571", "87654321", null); - pi.setFax(fax); - FullAddress addr = new FullAddress("CN", "zj", "3480", "wensanlu", "315000"); - pi.setFullAddress(addr); - pi.setMobileNo("13584652131"); - pi.setMale(true); - pi.setDepartment("b2b"); - pi.setHomepageUrl("www.capcom.com"); - pi.setJobTitle("qa"); - pi.setName("superman"); - - bigPerson.setInfoProfile(pi); - } - - { - Media media = new Media(); - media.setUri("uri://中华人民共和国"); - media.setTitle("title"); - media.setWidth(1239); - media.setHeight(1938); - media.setFormat("format-xxxx"); - media.setDuration(93419235); - media.setSize(3477897); - media.setBitrate(94523); - List persons = new ArrayList(); - persons.add("jerry"); - persons.add("tom"); - persons.add("lucy"); - media.setPersons(persons); - media.setCopyright("1999-2011"); - media.setPlayer(Player.FLASH); - - List images = new ArrayList(); - for (int i = 0; i < 10; ++i) { - Image image = new Image(); - image.setUri("url" + i); - if (i % 2 == 0) image.setTitle("title" + i); - image.setWidth(34 + i); - image.setHeight(2323 + i); - image.setSize((i % 2 == 0) ? Size.SMALL : Size.LARGE); - - images.add(image); - } - - mediaContent = new MediaContent(media, images); - } - - @Test - public void test_Bool() throws Exception { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeBool(false); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertFalse(deserialize.readBool()); - - try { - deserialize.readBool(); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_Bool_Multi() throws Exception { - boolean[] array = new boolean[100]; - for (int i = 0; i < array.length; i++) { - array[i] = random.nextBoolean(); - } - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - for (boolean b : array) { - objectOutput.writeBool(b); - } - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - for (boolean b : array) { - assertEquals(b, deserialize.readBool()); - } - - try { - deserialize.readBool(); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_Byte() throws Exception { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeByte((byte) 123); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertEquals((byte) 123, deserialize.readByte()); - - try { - deserialize.readByte(); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_Byte_Multi() throws Exception { - byte[] array = new byte[100]; - random.nextBytes(array); - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - for (byte b : array) { - objectOutput.writeByte(b); - } - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - for (byte b : array) { - assertEquals(b, deserialize.readByte()); - } - - try { - deserialize.readByte(); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_Short() throws Exception { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeShort((short) 123); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertEquals((short) 123, deserialize.readShort()); - - try { - deserialize.readShort(); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_Integer() throws Exception { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeInt(1); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - int i = deserialize.readInt(); - assertEquals(1, i); - - try { - deserialize.readInt(); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_Long() throws Exception { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeLong(123L); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertEquals(123L, deserialize.readLong()); - - try { - deserialize.readLong(); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_Float() throws Exception { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeFloat(1.28F); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertTrue(1.28F == deserialize.readFloat()); - - try { - deserialize.readFloat(); - fail(); - } catch (IOException expected) { - } - } - - // ================== Util methods ================== - - @Test - public void test_Double() throws Exception { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeDouble(1.28); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertTrue(1.28 == deserialize.readDouble()); - - try { - deserialize.readDouble(); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_UtfString() throws Exception { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeUTF("123中华人民共和国"); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertEquals("123中华人民共和国", deserialize.readUTF()); - - try { - deserialize.readUTF(); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_Bytes() throws Exception { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeBytes("123中华人民共和国".getBytes()); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertArrayEquals("123中华人民共和国".getBytes(), deserialize.readBytes()); - - try { - deserialize.readBytes(); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_BytesRange() throws Exception { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeBytes("123中华人民共和国-新疆维吾尔自治区".getBytes(), 1, 9); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - byte[] expectedArray = new byte[9]; - System.arraycopy("123中华人民共和国-新疆维吾尔自治区".getBytes(), 1, expectedArray, 0, expectedArray.length); - assertArrayEquals(expectedArray, deserialize.readBytes()); - - try { - deserialize.readBytes(); - fail(); - } catch (IOException expected) { - } - } - - // ================ Array Type ================ - - void assertObjectArray(T[] data, Class clazz) throws Exception { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(data); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertArrayEquals(data, clazz.cast(deserialize.readObject())); - - try { - deserialize.readObject(); - fail(); - } catch (IOException expected) { - } - } - - void assertObjectArrayWithType(T[] data, Class clazz) throws Exception { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(data); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertArrayEquals(data, clazz.cast(deserialize.readObject(clazz))); - - try { - deserialize.readObject(clazz); - fail(); - } catch (IOException expected) { - } - } - - @SuppressWarnings("unchecked") - void assertObject(T data) throws Exception { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(data); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertEquals(data, (T) deserialize.readObject()); - - try { - deserialize.readObject(); - fail(); - } catch (IOException expected) { - } - } - - void assertObjectWithType(T data, Class clazz) throws Exception { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(data); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertEquals(data, (T) deserialize.readObject(clazz)); - - try { - deserialize.readObject(clazz); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_boolArray() throws Exception { - boolean[] data = new boolean[]{true, false, true}; - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(data); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertTrue(Arrays.equals(data, (boolean[]) deserialize.readObject())); - - try { - deserialize.readObject(); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_boolArray_withType() throws Exception { - boolean[] data = new boolean[]{true, false, true}; - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(data); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertTrue(Arrays.equals(data, (boolean[]) deserialize.readObject(boolean[].class))); - - try { - deserialize.readObject(boolean[].class); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_charArray() throws Exception { - char[] data = new char[]{'a', '中', '无'}; - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(data); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertArrayEquals(data, (char[]) deserialize.readObject()); - - try { - deserialize.readObject(); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_charArray_withType() throws Exception { - char[] data = new char[]{'a', '中', '无'}; - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(data); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertArrayEquals(data, (char[]) deserialize.readObject(char[].class)); - - try { - deserialize.readObject(char[].class); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_shortArray() throws Exception { - short[] data = new short[]{37, 39, 12}; - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(data); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertArrayEquals(data, (short[]) deserialize.readObject()); - - try { - deserialize.readObject(); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_shortArray_withType() throws Exception { - short[] data = new short[]{37, 39, 12}; - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(data); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertArrayEquals(data, (short[]) deserialize.readObject(short[].class)); - - try { - deserialize.readObject(short[].class); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_intArray() throws Exception { - int[] data = new int[]{234, 0, -1}; - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(data); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertArrayEquals(data, (int[]) deserialize.readObject()); - - try { - deserialize.readObject(); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_intArray_withType() throws Exception { - int[] data = new int[]{234, 0, -1}; - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(data); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertArrayEquals(data, (int[]) deserialize.readObject(int[].class)); - - try { - deserialize.readObject(int[].class); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_longArray() throws Exception { - long[] data = new long[]{234, 0, -1}; - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(data); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertArrayEquals(data, (long[]) deserialize.readObject()); - - try { - deserialize.readObject(); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_longArray_withType() throws Exception { - long[] data = new long[]{234, 0, -1}; - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(data); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertArrayEquals(data, (long[]) deserialize.readObject(long[].class)); - - try { - deserialize.readObject(long[].class); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_floatArray() throws Exception { - float[] data = new float[]{37F, -3.14F, 123456.7F}; - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(data); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertArrayEquals(data, (float[]) deserialize.readObject(), 0.0001F); - - try { - deserialize.readObject(); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_floatArray_withType() throws Exception { - float[] data = new float[]{37F, -3.14F, 123456.7F}; - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(data); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertArrayEquals(data, (float[]) deserialize.readObject(float[].class), 0.0001F); - - try { - deserialize.readObject(float[].class); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_doubleArray() throws Exception { - double[] data = new double[]{37D, -3.14D, 123456.7D}; - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(data); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertArrayEquals(data, (double[]) deserialize.readObject(), 0.0001); - - try { - deserialize.readObject(); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_doubleArray_withType() throws Exception { - double[] data = new double[]{37D, -3.14D, 123456.7D}; - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(data); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertArrayEquals(data, (double[]) deserialize.readObject(double[].class), 0.0001); - - try { - deserialize.readObject(double[].class); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_StringArray() throws Exception { - assertObjectArray(new String[]{"1", "b"}, String[].class); - } - - @Test - public void test_StringArray_withType() throws Exception { - assertObjectArrayWithType(new String[]{"1", "b"}, String[].class); - } - - // ================ Simple Type ================ - - @Test - public void test_IntegerArray() throws Exception { - assertObjectArray(new Integer[]{234, 0, -1}, Integer[].class); - } - - @Test - public void test_IntegerArray_withType() throws Exception { - assertObjectArrayWithType(new Integer[]{234, 0, -1}, Integer[].class); - } - - @Test - public void test_EnumArray() throws Exception { - assertObjectArray(new AnimalEnum[]{AnimalEnum.bull, AnimalEnum.cat, AnimalEnum.dog, AnimalEnum.horse}, AnimalEnum[].class); - } - - @Test - public void test_EnumArray_withType() throws Exception { - assertObjectArrayWithType(new AnimalEnum[]{AnimalEnum.bull, AnimalEnum.cat, AnimalEnum.dog, AnimalEnum.horse}, AnimalEnum[].class); - } - - @Test - public void test_SPerson() throws Exception { - assertObject(new SerializablePerson()); - } - - @Test - public void test_SPerson_withType() throws Exception { - assertObjectWithType(new SerializablePerson(), SerializablePerson.class); - } - - @Test - public void test_BizException() throws Exception { - BizException e = new BizException("Hello"); - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(e); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - Object read = deserialize.readObject(); - assertEquals("Hello", ((BizException) read).getMessage()); - } - - @Test - public void test_BizException_WithType() throws Exception { - BizException e = new BizException("Hello"); - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(e); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - Object read = deserialize.readObject(BizException.class); - assertEquals("Hello", ((BizException) read).getMessage()); - } - - @Test - public void test_BizExceptionNoDefaultConstructor() throws Exception { - BizExceptionNoDefaultConstructor e = new BizExceptionNoDefaultConstructor("Hello"); - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(e); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - Object read = deserialize.readObject(); - assertEquals("Hello", ((BizExceptionNoDefaultConstructor) read).getMessage()); - } - - @Test - public void test_BizExceptionNoDefaultConstructor_WithType() throws Exception { - BizExceptionNoDefaultConstructor e = new BizExceptionNoDefaultConstructor("Hello"); - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(e); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - Object read = deserialize.readObject(BizExceptionNoDefaultConstructor.class); - assertEquals("Hello", ((BizExceptionNoDefaultConstructor) read).getMessage()); - } - - @Test - public void test_LocalDateTime() throws Exception { - assertObject(LocalDateTime.now()); - } - - @Test - public void test_enum() throws Exception { - assertObject(AnimalEnum.dog); - } - - @Test - public void test_enum_withType() throws Exception { - assertObjectWithType(AnimalEnum.dog, AnimalEnum.class); - } - - @Test - public void test_Date() throws Exception { - assertObject(new Date()); - } - - @Test - public void test_Date_withType() throws Exception { - assertObjectWithType(new Date(), Date.class); - } - - @Test - public void test_Time() throws Exception { - assertObject(new Time(System.currentTimeMillis())); - } - - @Test - public void test_Time_withType() throws Exception { - assertObjectWithType(new Time(System.currentTimeMillis()), Time.class); - } - - @Test - public void test_ByteWrap() throws Exception { - assertObject(new Byte((byte) 12)); - } - - @Test - public void test_ByteWrap_withType() throws Exception { - assertObjectWithType(new Byte((byte) 12), Byte.class); - } - - @Test - public void test_LongWrap() throws Exception { - assertObject(new Long(12)); - } - - @Test - public void test_LongWrap_withType() throws Exception { - assertObjectWithType(new Long(12), Long.class); - } - - @Test - public void test_BigInteger() throws Exception { - assertObject(new BigInteger("23423434234234234")); - } - - @Test - public void test_BigInteger_withType() throws Exception { - assertObjectWithType(new BigInteger("23423434234234234"), BigInteger.class); - } - - @Test - public void test_BigDecimal() throws Exception { - assertObject(new BigDecimal("23423434234234234.341274832341234235")); - } - - @Test - public void test_BigDecimal_withType() throws Exception { - assertObjectWithType(new BigDecimal("23423434234234234.341274832341234235"), BigDecimal.class); - } - - @Test - public void test_StringList_asListReturn() throws Exception { - List args = Arrays.asList(new String[]{"1", "b"}); - - assertObject(args); - } - - @Test - public void test_StringArrayList() throws Exception { - List args = new ArrayList(Arrays.asList(new String[]{"1", "b"})); - - assertObject(args); - } - - @Test - public void test_StringSet() throws Exception { - Set args = new HashSet(); - args.add("1"); - - assertObject(args); - } - - @Test - public void test_LinkedHashMap() throws Exception { - LinkedHashMap data = new LinkedHashMap(); - data.put("1", "a"); - data.put("2", "b"); - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(data); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - Object read = deserialize.readObject(); - assertTrue(read instanceof LinkedHashMap); - @SuppressWarnings("unchecked") - String key1 = ((LinkedHashMap) read).entrySet().iterator().next().getKey(); - assertEquals("1", key1); - - assertEquals(data, read); - - try { - deserialize.readObject(); - fail(); - } catch (IOException expected) { - } - } - - // ================ Complex Collection Type ================ - - @Test - public void test_SPersonList() throws Exception { - List args = new ArrayList(); - args.add(new SerializablePerson()); - - assertObject(args); - } - - @Test - public void test_SPersonSet() throws Exception { - Set args = new HashSet(); - args.add(new SerializablePerson()); - - assertObject(args); - } - - // ================ complex POJO ============= - - @Test - public void test_IntSPersonMap() throws Exception { - Map args = new HashMap(); - args.put(1, new SerializablePerson()); - - assertObject(args); - } - - @Test - public void test_StringSPersonMap() throws Exception { - Map args = new HashMap(); - args.put("1", new SerializablePerson()); - - assertObject(args); - } - - @Test - public void test_StringSPersonListMap() throws Exception { - Map> args = new HashMap>(); - - List sublist = new ArrayList(); - sublist.add(new SerializablePerson()); - args.put("1", sublist); - - assertObject(args); - } - - @Test - public void test_SPersonListList() throws Exception { - List> args = new ArrayList>(); - List sublist = new ArrayList(); - sublist.add(new SerializablePerson()); - args.add(sublist); - - assertObject(args); - } - - @Test - public void test_BigPerson() throws Exception { - assertObject(bigPerson); - } - - @Test - public void test_BigPerson_WithType() throws Exception { - assertObjectWithType(bigPerson, BigPerson.class); - } - - @Test - public void test_MediaContent() throws Exception { - assertObject(mediaContent); - } - - @Test - public void test_MediaContent_WithType() throws Exception { - assertObjectWithType(mediaContent, MediaContent.class); - } - - @Test - public void test_MultiObject() throws Exception { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeBool(false); - objectOutput.writeObject(bigPerson); - objectOutput.writeByte((byte) 23); - objectOutput.writeObject(mediaContent); - objectOutput.writeInt(-23); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertEquals(false, deserialize.readBool()); - assertEquals(bigPerson, deserialize.readObject()); - assertEquals((byte) 23, deserialize.readByte()); - assertEquals(mediaContent, deserialize.readObject()); - assertEquals(-23, deserialize.readInt()); - - try { - deserialize.readObject(); - fail(); - } catch (IOException expected) { - } - } - - @Test - public void test_MultiObject_WithType() throws Exception { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeBool(false); - objectOutput.writeObject(bigPerson); - objectOutput.writeByte((byte) 23); - objectOutput.writeObject(mediaContent); - objectOutput.writeInt(-23); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - assertEquals(false, deserialize.readBool()); - assertEquals(bigPerson, deserialize.readObject(BigPerson.class)); - assertEquals((byte) 23, deserialize.readByte()); - assertEquals(mediaContent, deserialize.readObject(MediaContent.class)); - assertEquals(-23, deserialize.readInt()); - - try { - deserialize.readObject(); - fail(); - } catch (IOException expected) { - } - } - - - // abnormal case - - @Test - public void test_MediaContent_badStream() throws Exception { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(mediaContent); - objectOutput.flushBuffer(); - - byte[] byteArray = byteArrayOutputStream.toByteArray(); - for (int i = 0; i < byteArray.length; i++) { - if (i % 3 == 0) { - byteArray[i] = (byte) ~byteArray[i]; - } - } - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArray); - - try { - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - @SuppressWarnings("unused") // local variable, convenient for debug - Object read = deserialize.readObject(); - fail(); - } catch (IOException expected) { - System.out.println(expected); - } - } - - @Test - public void test_MediaContent_WithType_badStream() throws Exception { - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(mediaContent); - objectOutput.flushBuffer(); - - byte[] byteArray = byteArrayOutputStream.toByteArray(); - for (int i = 0; i < byteArray.length; i++) { - if (i % 3 == 0) { - byteArray[i] = (byte) ~byteArray[i]; - } - } - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArray); - - try { - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - @SuppressWarnings("unused") // local variable, convenient for debug - Object read = deserialize.readObject(MediaContent.class); - fail(); - } catch (IOException expected) { - System.out.println(expected); - } - } - - - @Test(timeout = 3000) - public void test_LoopReference() throws Exception { - Map map = new HashMap(); - map.put("k1", "v1"); - map.put("self", map); - - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(map); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - @SuppressWarnings("unchecked") - Map output = (Map) deserialize.readObject(); - - assertEquals("v1", output.get("k1")); - assertSame(output, output.get("self")); - } - - // ================ final field test ================ - - @Test - public void test_URL_mutable_withType() throws Exception { - URL data = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan&noValue"); - - ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); - objectOutput.writeObject(data); - objectOutput.flushBuffer(); - - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( - byteArrayOutputStream.toByteArray()); - ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); - - URL actual = (URL) deserialize.readObject(URL.class); - assertEquals(data, actual); - assertEquals(data.getParameters(), actual.getParameters()); - - try { - deserialize.readObject(); - fail(); - } catch (IOException expected) { - } - } -} \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-kryo/src/test/resources/log4j.xml b/dubbo-serialization/dubbo-serialization-kryo/src/test/resources/log4j.xml deleted file mode 100644 index d045b92c0de..00000000000 --- a/dubbo-serialization/dubbo-serialization-kryo/src/test/resources/log4j.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-kryo/src/test/resources/org/apache/dubbo/common/serialize/dubbo/SimpleDO.fc b/dubbo-serialization/dubbo-serialization-kryo/src/test/resources/org/apache/dubbo/common/serialize/dubbo/SimpleDO.fc deleted file mode 100644 index c8c083c17eb..00000000000 --- a/dubbo-serialization/dubbo-serialization-kryo/src/test/resources/org/apache/dubbo/common/serialize/dubbo/SimpleDO.fc +++ /dev/null @@ -1,2 +0,0 @@ -a,d,e,b,c -str3,str2 \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-test/pom.xml b/dubbo-serialization/dubbo-serialization-test/pom.xml new file mode 100644 index 00000000000..8c8b8fadca0 --- /dev/null +++ b/dubbo-serialization/dubbo-serialization-test/pom.xml @@ -0,0 +1,68 @@ + + + + + dubbo-serialization + org.apache.dubbo + 2.7.0-SNAPSHOT + + 4.0.0 + + dubbo-serialization-test + jar + ${project.artifactId} + The test serialization module of dubbo project + + false + + + + + org.apache.dubbo + dubbo-serialization-fastjson + ${project.parent.version} + + + org.apache.dubbo + dubbo-serialization-fst + ${project.parent.version} + + + org.apache.dubbo + dubbo-serialization-hessian2 + ${project.parent.version} + + + org.apache.dubbo + dubbo-serialization-jdk + ${project.parent.version} + + + org.apache.dubbo + dubbo-serialization-kryo + ${project.parent.version} + + + org.apache.dubbo + dubbo-serialization-api + ${project.parent.version} + + + \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/serialize/serialization/AbstractSerializationPersonFailTest.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/base/AbstractSerializationPersonFailTest.java similarity index 79% rename from dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/serialize/serialization/AbstractSerializationPersonFailTest.java rename to dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/base/AbstractSerializationPersonFailTest.java index 5d27bb56558..64df509bad3 100644 --- a/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/serialize/serialization/AbstractSerializationPersonFailTest.java +++ b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/base/AbstractSerializationPersonFailTest.java @@ -14,11 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.common.serialize.serialization; +package org.apache.dubbo.common.serialize.base; -import org.apache.dubbo.common.model.Person; import org.apache.dubbo.common.serialize.ObjectOutput; - +import org.apache.dubbo.common.serialize.model.Person; import org.junit.Test; import java.io.NotSerializableException; @@ -34,6 +33,9 @@ import static org.junit.matchers.JUnitMatchers.containsString; public abstract class AbstractSerializationPersonFailTest extends AbstractSerializationTest { + + protected static final String FAIL_STRING = "Serialized class org.apache.dubbo.common.serialize.model.Person must implement java.io.Serializable"; + @Test public void test_Person() throws Exception { try { @@ -42,7 +44,7 @@ public void test_Person() throws Exception { fail(); } catch (NotSerializableException expected) { } catch (IllegalStateException expected) { - assertThat(expected.getMessage(), containsString("Serialized class org.apache.dubbo.common.model.Person must implement java.io.Serializable")); + assertThat(expected.getMessage(), containsString(FAIL_STRING)); } } @@ -56,7 +58,7 @@ public void test_PersonList() throws Exception { fail(); } catch (NotSerializableException expected) { } catch (IllegalStateException expected) { - assertThat(expected.getMessage(), containsString("Serialized class org.apache.dubbo.common.model.Person must implement java.io.Serializable")); + assertThat(expected.getMessage(), containsString(FAIL_STRING)); } } @@ -70,7 +72,8 @@ public void test_PersonSet() throws Exception { fail(); } catch (NotSerializableException expected) { } catch (IllegalStateException expected) { - assertThat(expected.getMessage(), containsString("Serialized class org.apache.dubbo.common.model.Person must implement java.io.Serializable")); + System.out.println("--------" + expected.getMessage()); + assertThat(expected.getMessage(), containsString(FAIL_STRING)); } } @@ -84,7 +87,7 @@ public void test_IntPersonMap() throws Exception { fail(); } catch (NotSerializableException expected) { } catch (IllegalStateException expected) { - assertThat(expected.getMessage(), containsString("Serialized class org.apache.dubbo.common.model.Person must implement java.io.Serializable")); + assertThat(expected.getMessage(), containsString(FAIL_STRING)); } } @@ -98,7 +101,7 @@ public void test_StringPersonMap() throws Exception { fail(); } catch (NotSerializableException expected) { } catch (IllegalStateException expected) { - assertThat(expected.getMessage(), containsString("Serialized class org.apache.dubbo.common.model.Person must implement java.io.Serializable")); + assertThat(expected.getMessage(), containsString(FAIL_STRING)); } } @@ -115,7 +118,7 @@ public void test_StringPersonListMap() throws Exception { fail(); } catch (NotSerializableException expected) { } catch (IllegalStateException expected) { - assertThat(expected.getMessage(), containsString("Serialized class org.apache.dubbo.common.model.Person must implement java.io.Serializable")); + assertThat(expected.getMessage(), containsString(FAIL_STRING)); } } @@ -131,7 +134,7 @@ public void test_PersonListList() throws Exception { fail(); } catch (NotSerializableException expected) { } catch (IllegalStateException expected) { - assertThat(expected.getMessage(), containsString("Serialized class org.apache.dubbo.common.model.Person must implement java.io.Serializable")); + assertThat(expected.getMessage(), containsString(FAIL_STRING)); } } } \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/serialize/serialization/AbstractSerializationPersonOkTest.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/base/AbstractSerializationPersonOkTest.java similarity index 66% rename from dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/serialize/serialization/AbstractSerializationPersonOkTest.java rename to dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/base/AbstractSerializationPersonOkTest.java index 03395cb0cd9..6b8b77a8214 100644 --- a/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/serialize/serialization/AbstractSerializationPersonOkTest.java +++ b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/base/AbstractSerializationPersonOkTest.java @@ -14,10 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.common.serialize.serialization; - -import org.apache.dubbo.common.model.Person; +package org.apache.dubbo.common.serialize.base; +import org.apache.dubbo.common.serialize.model.person.Phone; import org.junit.Test; import java.util.ArrayList; @@ -29,53 +28,53 @@ public abstract class AbstractSerializationPersonOkTest extends AbstractSerializationTest { @Test - public void test_Person() throws Exception { - assertObject(new Person()); + public void test_Phone() throws Exception { + assertObject(new Phone()); } @Test public void test_Person_withType() throws Exception { - assertObjectWithType(new Person(), Person.class); + assertObjectWithType(new Phone(), Phone.class); } @Test public void test_PersonList() throws Exception { - List args = new ArrayList(); - args.add(new Person()); + List args = new ArrayList(); + args.add(new Phone()); assertObject(args); } @Test public void test_PersonSet() throws Exception { - Set args = new HashSet(); - args.add(new Person()); + Set args = new HashSet(); + args.add(new Phone()); assertObject(args); } @Test public void test_IntPersonMap() throws Exception { - Map args = new HashMap(); - args.put(1, new Person()); + Map args = new HashMap(); + args.put(1, new Phone()); assertObject(args); } @Test public void test_StringPersonMap() throws Exception { - Map args = new HashMap(); - args.put("1", new Person()); + Map args = new HashMap(); + args.put("1", new Phone()); assertObject(args); } @Test public void test_StringPersonListMap() throws Exception { - Map> args = new HashMap>(); + Map> args = new HashMap>(); - List sublist = new ArrayList(); - sublist.add(new Person()); + List sublist = new ArrayList(); + sublist.add(new Phone()); args.put("1", sublist); assertObject(args); @@ -83,9 +82,9 @@ public void test_StringPersonListMap() throws Exception { @Test public void test_PersonListList() throws Exception { - List> args = new ArrayList>(); - List sublist = new ArrayList(); - sublist.add(new Person()); + List> args = new ArrayList>(); + List sublist = new ArrayList(); + sublist.add(new Phone()); args.add(sublist); assertObject(args); diff --git a/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/serialize/serialization/AbstractSerializationTest.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/base/AbstractSerializationTest.java similarity index 96% rename from dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/serialize/serialization/AbstractSerializationTest.java rename to dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/base/AbstractSerializationTest.java index a40e3780944..f543a9e699f 100644 --- a/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/serialize/serialization/AbstractSerializationTest.java +++ b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/base/AbstractSerializationTest.java @@ -14,27 +14,25 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.common.serialize.serialization; +package org.apache.dubbo.common.serialize.base; import org.apache.dubbo.common.URL; -import org.apache.dubbo.common.model.AnimalEnum; -import org.apache.dubbo.common.model.BizException; -import org.apache.dubbo.common.model.BizExceptionNoDefaultConstructor; -import org.apache.dubbo.common.model.SerializablePerson; -import org.apache.dubbo.common.model.media.Image; -import org.apache.dubbo.common.model.media.Image.Size; -import org.apache.dubbo.common.model.media.Media; -import org.apache.dubbo.common.model.media.Media.Player; -import org.apache.dubbo.common.model.media.MediaContent; -import org.apache.dubbo.common.model.person.BigPerson; -import org.apache.dubbo.common.model.person.FullAddress; -import org.apache.dubbo.common.model.person.PersonInfo; -import org.apache.dubbo.common.model.person.PersonStatus; -import org.apache.dubbo.common.model.person.Phone; import org.apache.dubbo.common.serialize.ObjectInput; import org.apache.dubbo.common.serialize.ObjectOutput; import org.apache.dubbo.common.serialize.Serialization; - +import org.apache.dubbo.common.serialize.model.AnimalEnum; +import org.apache.dubbo.common.serialize.model.BizException; +import org.apache.dubbo.common.serialize.model.BizExceptionNoDefaultConstructor; +import org.apache.dubbo.common.serialize.model.SerializablePerson; +import org.apache.dubbo.common.serialize.model.media.Image; +import org.apache.dubbo.common.serialize.model.media.Media; +import org.apache.dubbo.common.serialize.model.media.MediaContent; +import org.apache.dubbo.common.serialize.model.person.BigPerson; +import org.apache.dubbo.common.serialize.model.person.FullAddress; +import org.apache.dubbo.common.serialize.model.person.PersonInfo; +import org.apache.dubbo.common.serialize.model.person.PersonStatus; +import org.apache.dubbo.common.serialize.model.person.Phone; +import org.junit.After; import org.junit.Test; import java.io.ByteArrayInputStream; @@ -62,14 +60,14 @@ import static org.junit.Assert.fail; public abstract class AbstractSerializationTest { - static Random random = new Random(); - Serialization serialization; - URL url = new URL("protocol", "1.1.1.1", 1234); - ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + protected static Random random = new Random(); + protected Serialization serialization; + protected URL url = new URL("protocol", "1.1.1.1", 1234); + protected ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); // ================ Primitive Type ================ - BigPerson bigPerson; - MediaContent mediaContent; + protected BigPerson bigPerson; + protected MediaContent mediaContent; { bigPerson = new BigPerson(); @@ -117,7 +115,7 @@ public abstract class AbstractSerializationTest { persons.add("lucy"); media.setPersons(persons); media.setCopyright("1999-2011"); - media.setPlayer(Player.FLASH); + media.setPlayer(Media.Player.FLASH); List images = new ArrayList(); for (int i = 0; i < 10; ++i) { @@ -126,7 +124,7 @@ public abstract class AbstractSerializationTest { if (i % 2 == 0) image.setTitle("title" + i); image.setWidth(34 + i); image.setHeight(2323 + i); - image.setSize((i % 2 == 0) ? Size.SMALL : Size.LARGE); + image.setSize((i % 2 == 0) ? Image.Size.SMALL : Image.Size.LARGE); images.add(image); } @@ -422,7 +420,7 @@ void assertObjectArrayWithType(T[] data, Class clazz) throws Exception } @SuppressWarnings("unchecked") - void assertObject(T data) throws Exception { + public void assertObject(T data) throws Exception { ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); objectOutput.writeObject(data); objectOutput.flushBuffer(); @@ -440,7 +438,7 @@ void assertObject(T data) throws Exception { } } - void assertObjectWithType(T data, Class clazz) throws Exception { + public void assertObjectWithType(T data, Class clazz) throws Exception { ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); objectOutput.writeObject(data); objectOutput.flushBuffer(); diff --git a/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/org/apache/dubbo/common/serialize/fastjson/FastJsonObjectInputTest.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/fastjson/FastJsonObjectInputTest.java similarity index 98% rename from dubbo-serialization/dubbo-serialization-fastjson/src/test/java/org/apache/dubbo/common/serialize/fastjson/FastJsonObjectInputTest.java rename to dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/fastjson/FastJsonObjectInputTest.java index 185d24fc28d..a115636ac58 100644 --- a/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/org/apache/dubbo/common/serialize/fastjson/FastJsonObjectInputTest.java +++ b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/fastjson/FastJsonObjectInputTest.java @@ -16,8 +16,8 @@ */ package org.apache.dubbo.common.serialize.fastjson; -import org.apache.dubbo.common.serialize.fastjson.model.Person; import com.alibaba.fastjson.JSONObject; +import org.apache.dubbo.common.serialize.model.Person; import org.junit.Test; import java.io.ByteArrayInputStream; diff --git a/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/org/apache/dubbo/common/serialize/fastjson/FastJsonObjectOutputTest.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/fastjson/FastJsonObjectOutputTest.java similarity index 95% rename from dubbo-serialization/dubbo-serialization-fastjson/src/test/java/org/apache/dubbo/common/serialize/fastjson/FastJsonObjectOutputTest.java rename to dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/fastjson/FastJsonObjectOutputTest.java index 6cf0c35e8f2..6fca19f215c 100644 --- a/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/org/apache/dubbo/common/serialize/fastjson/FastJsonObjectOutputTest.java +++ b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/fastjson/FastJsonObjectOutputTest.java @@ -16,7 +16,7 @@ */ package org.apache.dubbo.common.serialize.fastjson; -import org.apache.dubbo.common.serialize.fastjson.model.Image; +import org.apache.dubbo.common.serialize.model.media.Image; import org.junit.Before; import org.junit.Test; @@ -24,7 +24,9 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; -import static org.hamcrest.CoreMatchers.*; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.CoreMatchers.nullValue; import static org.junit.Assert.assertThat; public class FastJsonObjectOutputTest { diff --git a/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/org/apache/dubbo/common/serialize/fastjson/FastJsonSerializationTest.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/fastjson/FastJsonSerializationTest.java similarity index 91% rename from dubbo-serialization/dubbo-serialization-fastjson/src/test/java/org/apache/dubbo/common/serialize/fastjson/FastJsonSerializationTest.java rename to dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/fastjson/FastJsonSerializationTest.java index 298f05bfc2f..802c2ef96bf 100644 --- a/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/org/apache/dubbo/common/serialize/fastjson/FastJsonSerializationTest.java +++ b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/fastjson/FastJsonSerializationTest.java @@ -18,9 +18,6 @@ import org.apache.dubbo.common.serialize.ObjectInput; import org.apache.dubbo.common.serialize.ObjectOutput; -import org.apache.dubbo.common.serialize.fastjson.FastJsonObjectInput; -import org.apache.dubbo.common.serialize.fastjson.FastJsonObjectOutput; -import org.apache.dubbo.common.serialize.fastjson.FastJsonSerialization; import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; diff --git a/dubbo-serialization/dubbo-serialization-fst/src/test/java/org/apache/dubbo/common/serialize/fst/FstFactoryTest.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/fst/FstFactoryTest.java similarity index 100% rename from dubbo-serialization/dubbo-serialization-fst/src/test/java/org/apache/dubbo/common/serialize/fst/FstFactoryTest.java rename to dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/fst/FstFactoryTest.java diff --git a/dubbo-serialization/dubbo-serialization-fst/src/test/java/org/apache/dubbo/common/serialize/fst/FstObjectInputTest.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/fst/FstObjectInputTest.java similarity index 91% rename from dubbo-serialization/dubbo-serialization-fst/src/test/java/org/apache/dubbo/common/serialize/fst/FstObjectInputTest.java rename to dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/fst/FstObjectInputTest.java index 849e838630a..fa7e95cf3d7 100644 --- a/dubbo-serialization/dubbo-serialization-fst/src/test/java/org/apache/dubbo/common/serialize/fst/FstObjectInputTest.java +++ b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/fst/FstObjectInputTest.java @@ -16,15 +16,14 @@ */ package org.apache.dubbo.common.serialize.fst; -import org.apache.dubbo.common.serialize.fst.model.AnimalEnum; -import org.apache.dubbo.common.serialize.fst.model.FullAddress; +import org.apache.dubbo.common.serialize.model.person.FullAddress; import org.junit.Test; import java.io.ByteArrayInputStream; import java.io.IOException; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.*; +import static org.junit.Assert.assertThat; public class FstObjectInputTest { private FstObjectInput fstObjectInput; diff --git a/dubbo-serialization/dubbo-serialization-fst/src/test/java/org/apache/dubbo/common/serialize/fst/FstObjectOutputTest.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/fst/FstObjectOutputTest.java similarity index 97% rename from dubbo-serialization/dubbo-serialization-fst/src/test/java/org/apache/dubbo/common/serialize/fst/FstObjectOutputTest.java rename to dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/fst/FstObjectOutputTest.java index d2796ab6679..ecf2335d88f 100644 --- a/dubbo-serialization/dubbo-serialization-fst/src/test/java/org/apache/dubbo/common/serialize/fst/FstObjectOutputTest.java +++ b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/fst/FstObjectOutputTest.java @@ -16,8 +16,8 @@ */ package org.apache.dubbo.common.serialize.fst; -import org.apache.dubbo.common.serialize.fst.model.AnimalEnum; -import org.apache.dubbo.common.serialize.fst.model.FullAddress; +import org.apache.dubbo.common.serialize.model.AnimalEnum; +import org.apache.dubbo.common.serialize.model.person.FullAddress; import org.junit.Before; import org.junit.Test; @@ -27,7 +27,7 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.*; +import static org.junit.Assert.assertThat; public class FstObjectOutputTest { private FstObjectOutput fstObjectOutput; diff --git a/dubbo-serialization/dubbo-serialization-fst/src/test/java/org/apache/dubbo/common/serialize/fst/FstSerializationTest.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/fst/FstSerializationTest.java similarity index 100% rename from dubbo-serialization/dubbo-serialization-fst/src/test/java/org/apache/dubbo/common/serialize/fst/FstSerializationTest.java rename to dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/fst/FstSerializationTest.java diff --git a/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/hessian2/Hessian2PersonOkTest.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/hessian2/Hessian2PersonOkTest.java new file mode 100644 index 00000000000..35ecb449c44 --- /dev/null +++ b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/hessian2/Hessian2PersonOkTest.java @@ -0,0 +1,212 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.dubbo.common.serialize.hessian2; + +import org.apache.dubbo.common.serialize.ObjectInput; +import org.apache.dubbo.common.serialize.ObjectOutput; +import org.apache.dubbo.common.serialize.base.AbstractSerializationPersonOkTest; +import org.apache.dubbo.common.serialize.java.JavaSerialization; +import org.junit.Ignore; +import org.junit.Test; + +import java.io.ByteArrayInputStream; +import java.util.Arrays; + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +/** + * JdkPersonOkTest + */ +public class Hessian2PersonOkTest extends AbstractSerializationPersonOkTest { + + { + serialization = new Hessian2Serialization(); + } + + @Test + public void test_boolArray_withType() throws Exception { + boolean[] data = new boolean[]{true, false, true}; + + ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); + objectOutput.writeObject(data); + objectOutput.flushBuffer(); + + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( + byteArrayOutputStream.toByteArray()); + ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); + + assertTrue(Arrays.equals(data, (boolean[]) deserialize.readObject(boolean[].class))); + + try { + deserialize.readObject(boolean[].class); + fail(); + } catch (ArrayIndexOutOfBoundsException e) { + } + // NOTE: Hessian2 throws ArrayIndexOutOfBoundsException instead of IOException, let's live with this. + } + + @Ignore("type missing, char[] -> String") + @Test + public void test_charArray() throws Exception { + } + + @Test + public void test_shortArray_withType() throws Exception { + short[] data = new short[]{37, 39, 12}; + + ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); + objectOutput.writeObject(data); + objectOutput.flushBuffer(); + + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( + byteArrayOutputStream.toByteArray()); + ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); + + assertArrayEquals(data, (short[]) deserialize.readObject(short[].class)); + + try { + deserialize.readObject(short[].class); + fail(); + } catch (ArrayIndexOutOfBoundsException e) { + } + // NOTE: Hessian2 throws ArrayIndexOutOfBoundsException instead of IOException, let's live with this. + } + + @Test + public void test_intArray_withType() throws Exception { + int[] data = new int[]{234, 0, -1}; + + ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); + objectOutput.writeObject(data); + objectOutput.flushBuffer(); + + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( + byteArrayOutputStream.toByteArray()); + ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); + + assertArrayEquals(data, (int[]) deserialize.readObject()); + + try { + deserialize.readObject(int[].class); + fail(); + } catch (ArrayIndexOutOfBoundsException e) { + } + // NOTE: Hessian2 throws ArrayIndexOutOfBoundsException instead of IOException, let's live with this. + } + + @Test + public void test_longArray_withType() throws Exception { + long[] data = new long[]{234, 0, -1}; + + ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); + objectOutput.writeObject(data); + objectOutput.flushBuffer(); + + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( + byteArrayOutputStream.toByteArray()); + ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); + + assertArrayEquals(data, (long[]) deserialize.readObject()); + + try { + deserialize.readObject(long[].class); + fail(); + } catch (ArrayIndexOutOfBoundsException e) { + } + // NOTE: Hessian2 throws ArrayIndexOutOfBoundsException instead of IOException, let's live with this. + } + + @Test + public void test_floatArray_withType() throws Exception { + float[] data = new float[]{37F, -3.14F, 123456.7F}; + + ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); + objectOutput.writeObject(data); + objectOutput.flushBuffer(); + + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( + byteArrayOutputStream.toByteArray()); + ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); + + assertArrayEquals(data, (float[]) deserialize.readObject(), 0.0001F); + + try { + deserialize.readObject(float[].class); + fail(); + } catch (ArrayIndexOutOfBoundsException e) { + } + // NOTE: Hessian2 throws ArrayIndexOutOfBoundsException instead of IOException, let's live with this. + } + + @Test + public void test_doubleArray_withType() throws Exception { + double[] data = new double[]{37D, -3.14D, 123456.7D}; + + ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); + objectOutput.writeObject(data); + objectOutput.flushBuffer(); + + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( + byteArrayOutputStream.toByteArray()); + ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); + + assertArrayEquals(data, (double[]) deserialize.readObject(double[].class), 0.0001); + + try { + deserialize.readObject(double[].class); + fail(); + } catch (ArrayIndexOutOfBoundsException e) { + } + // NOTE: Hessian2 throws ArrayIndexOutOfBoundsException instead of IOException, let's live with this. + } + + @Test + public void test_StringArray_withType() throws Exception { + + String[] data = new String[]{"1", "b"}; + + + ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream); + objectOutput.writeObject(data); + objectOutput.flushBuffer(); + + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( + byteArrayOutputStream.toByteArray()); + ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream); + + assertArrayEquals(data, deserialize.readObject(String[].class)); + + try { + deserialize.readObject(String[].class); + fail(); + } catch (ArrayIndexOutOfBoundsException e) { + } + // NOTE: Hessian2 throws ArrayIndexOutOfBoundsException instead of IOException, let's live with this. + } + + @Ignore("type missing, Byte -> Integer") + @Test + public void test_ByteWrap() throws Exception { + } + + @Ignore("Bad Stream read other type data") + @Test + public void test_MediaContent_badStream() throws Exception { + } +} diff --git a/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/serialize/serialization/Hessian2SerializationTest.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/hessian2/Hessian2SerializationTest.java similarity index 98% rename from dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/serialize/serialization/Hessian2SerializationTest.java rename to dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/hessian2/Hessian2SerializationTest.java index e70dfd9f633..94e61873152 100644 --- a/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/serialize/serialization/Hessian2SerializationTest.java +++ b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/hessian2/Hessian2SerializationTest.java @@ -14,12 +14,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.common.serialize.serialization; +package org.apache.dubbo.common.serialize.hessian2; import org.apache.dubbo.common.serialize.ObjectInput; import org.apache.dubbo.common.serialize.ObjectOutput; -import org.apache.dubbo.common.serialize.hessian2.Hessian2Serialization; - +import org.apache.dubbo.common.serialize.base.AbstractSerializationPersonFailTest; import org.junit.Ignore; import org.junit.Test; diff --git a/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/serialize/serialization/CompactedJavaSerializationTest.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/jdk/CompactedJavaSerializationTest.java similarity index 88% rename from dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/serialize/serialization/CompactedJavaSerializationTest.java rename to dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/jdk/CompactedJavaSerializationTest.java index 86ebb5ee060..551a4280a4c 100644 --- a/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/serialize/serialization/CompactedJavaSerializationTest.java +++ b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/jdk/CompactedJavaSerializationTest.java @@ -14,9 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.common.serialize.serialization; +package org.apache.dubbo.common.serialize.jdk; +import org.apache.dubbo.common.serialize.base.AbstractSerializationPersonFailTest; import org.apache.dubbo.common.serialize.java.CompactedJavaSerialization; public class CompactedJavaSerializationTest extends AbstractSerializationPersonFailTest { diff --git a/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/serialize/serialization/JavaSerializationTest.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/jdk/JavaSerializationTest.java similarity index 88% rename from dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/serialize/serialization/JavaSerializationTest.java rename to dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/jdk/JavaSerializationTest.java index 058f60512ec..4f7ca2b5d2e 100644 --- a/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/serialize/serialization/JavaSerializationTest.java +++ b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/jdk/JavaSerializationTest.java @@ -14,9 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.common.serialize.serialization; +package org.apache.dubbo.common.serialize.jdk; +import org.apache.dubbo.common.serialize.base.AbstractSerializationPersonFailTest; import org.apache.dubbo.common.serialize.java.JavaSerialization; public class JavaSerializationTest extends AbstractSerializationPersonFailTest { diff --git a/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/model/BizException.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/jdk/JdkPersonOkTest.java similarity index 69% rename from dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/model/BizException.java rename to dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/jdk/JdkPersonOkTest.java index 95f4046afa0..b5da9204727 100644 --- a/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/model/BizException.java +++ b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/jdk/JdkPersonOkTest.java @@ -14,16 +14,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.common.model; +package org.apache.dubbo.common.serialize.jdk; -public class BizException extends RuntimeException { +import org.apache.dubbo.common.serialize.base.AbstractSerializationPersonOkTest; +import org.apache.dubbo.common.serialize.java.JavaSerialization; - private static final long serialVersionUID = 1L; - - public BizException(String message) { - super(message); - } +/** + * JdkPersonOkTest + */ +public class JdkPersonOkTest extends AbstractSerializationPersonOkTest { - public BizException() { + { + serialization = new JavaSerialization(); } -} \ No newline at end of file +} diff --git a/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/serialize/serialization/NativeJavaSerializationTest.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/jdk/NativeJavaSerializationTest.java similarity index 88% rename from dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/serialize/serialization/NativeJavaSerializationTest.java rename to dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/jdk/NativeJavaSerializationTest.java index d090890f4ef..a491cd630c2 100644 --- a/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/serialize/serialization/NativeJavaSerializationTest.java +++ b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/jdk/NativeJavaSerializationTest.java @@ -14,8 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.common.serialize.serialization; +package org.apache.dubbo.common.serialize.jdk; +import org.apache.dubbo.common.serialize.base.AbstractSerializationPersonFailTest; import org.apache.dubbo.common.serialize.nativejava.NativeJavaSerialization; public class NativeJavaSerializationTest extends AbstractSerializationPersonFailTest { diff --git a/dubbo-common/src/test/java/org/apache/dubbo/common/model/BizException.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/kryo/KryoPersonOkTest.java similarity index 73% rename from dubbo-common/src/test/java/org/apache/dubbo/common/model/BizException.java rename to dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/kryo/KryoPersonOkTest.java index 51fd04b7b88..6ed863603ad 100644 --- a/dubbo-common/src/test/java/org/apache/dubbo/common/model/BizException.java +++ b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/kryo/KryoPersonOkTest.java @@ -1,29 +1,29 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.dubbo.common.model; - -public class BizException extends RuntimeException { - - private static final long serialVersionUID = 1L; - - public BizException(String message) { - super(message); - } - - public BizException() { - } -} \ No newline at end of file +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.dubbo.common.serialize.kryo; + +import org.apache.dubbo.common.serialize.base.AbstractSerializationPersonOkTest; + +/** + * KryoPersonOkTest + */ +public class KryoPersonOkTest extends AbstractSerializationPersonOkTest { + + { + serialization = new KryoSerialization(); + } +} diff --git a/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/serialize/serialization/KyroSerializationTest.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/kryo/KyroSerializationTest.java similarity index 88% rename from dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/serialize/serialization/KyroSerializationTest.java rename to dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/kryo/KyroSerializationTest.java index a4fe5850262..f6f318a6c0b 100644 --- a/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/serialize/serialization/KyroSerializationTest.java +++ b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/kryo/KyroSerializationTest.java @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.common.serialize.serialization; +package org.apache.dubbo.common.serialize.kryo; -import org.apache.dubbo.common.serialize.kryo.KryoSerialization; +import org.apache.dubbo.common.serialize.base.AbstractSerializationTest; public class KyroSerializationTest extends AbstractSerializationTest { diff --git a/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/serialize/serialization/ReflectionUtilsTest.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/kryo/ReflectionUtilsTest.java similarity index 96% rename from dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/serialize/serialization/ReflectionUtilsTest.java rename to dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/kryo/ReflectionUtilsTest.java index 39d0bccb8be..c596753fc17 100644 --- a/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/serialize/serialization/ReflectionUtilsTest.java +++ b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/kryo/ReflectionUtilsTest.java @@ -14,10 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.common.serialize.serialization; +package org.apache.dubbo.common.serialize.kryo; import org.apache.dubbo.common.serialize.kryo.utils.ReflectionUtils; - import org.junit.Test; import static org.junit.Assert.assertFalse; diff --git a/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/model/AnimalEnum.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/model/AnimalEnum.java similarity index 94% rename from dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/model/AnimalEnum.java rename to dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/model/AnimalEnum.java index 760663fe04c..db16dd9d773 100644 --- a/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/model/AnimalEnum.java +++ b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/model/AnimalEnum.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.common.model; +package org.apache.dubbo.common.serialize.model; public enum AnimalEnum { dog, cat, rat, cow, bull, horse; diff --git a/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/model/BizException.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/model/BizException.java similarity index 95% rename from dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/model/BizException.java rename to dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/model/BizException.java index 95f4046afa0..96657e776f6 100644 --- a/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/model/BizException.java +++ b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/model/BizException.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.common.model; +package org.apache.dubbo.common.serialize.model; public class BizException extends RuntimeException { diff --git a/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/model/BizExceptionNoDefaultConstructor.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/model/BizExceptionNoDefaultConstructor.java similarity index 95% rename from dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/model/BizExceptionNoDefaultConstructor.java rename to dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/model/BizExceptionNoDefaultConstructor.java index f1ffadb0234..ab41fd52b56 100644 --- a/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/model/BizExceptionNoDefaultConstructor.java +++ b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/model/BizExceptionNoDefaultConstructor.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.common.model; +package org.apache.dubbo.common.serialize.model; public class BizExceptionNoDefaultConstructor extends RuntimeException { diff --git a/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/model/Person.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/model/Person.java similarity index 98% rename from dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/model/Person.java rename to dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/model/Person.java index 5a551a7f36b..5498622e3d5 100644 --- a/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/model/Person.java +++ b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/model/Person.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.common.model; +package org.apache.dubbo.common.serialize.model; import java.util.Arrays; diff --git a/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/model/SerializablePerson.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/model/SerializablePerson.java similarity index 98% rename from dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/model/SerializablePerson.java rename to dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/model/SerializablePerson.java index d78c5928ea8..b5ecad9883f 100644 --- a/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/model/SerializablePerson.java +++ b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/model/SerializablePerson.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.common.model; +package org.apache.dubbo.common.serialize.model; import java.io.Serializable; import java.util.Arrays; diff --git a/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/model/media/Image.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/model/media/Image.java similarity index 98% rename from dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/model/media/Image.java rename to dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/model/media/Image.java index a59eff35be6..da235d2cccf 100644 --- a/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/model/media/Image.java +++ b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/model/media/Image.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.common.model.media; +package org.apache.dubbo.common.serialize.model.media; public class Image implements java.io.Serializable { diff --git a/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/model/media/Media.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/model/media/Media.java similarity index 99% rename from dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/model/media/Media.java rename to dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/model/media/Media.java index 042a3a5273a..555f847f052 100644 --- a/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/model/media/Media.java +++ b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/model/media/Media.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.common.model.media; +package org.apache.dubbo.common.serialize.model.media; import java.util.List; diff --git a/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/model/media/MediaContent.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/model/media/MediaContent.java similarity index 97% rename from dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/model/media/MediaContent.java rename to dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/model/media/MediaContent.java index 7991f506101..3b65e9994da 100644 --- a/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/model/media/MediaContent.java +++ b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/model/media/MediaContent.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.common.model.media; +package org.apache.dubbo.common.serialize.model.media; import java.util.List; diff --git a/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/model/person/BigPerson.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/model/person/BigPerson.java similarity index 98% rename from dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/model/person/BigPerson.java rename to dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/model/person/BigPerson.java index 4ce79008fb4..063f5a97ba1 100644 --- a/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/model/person/BigPerson.java +++ b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/model/person/BigPerson.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.common.model.person; +package org.apache.dubbo.common.serialize.model.person; import java.io.Serializable; diff --git a/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/model/person/FullAddress.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/model/person/FullAddress.java similarity index 99% rename from dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/model/person/FullAddress.java rename to dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/model/person/FullAddress.java index 38921670f97..4f762cffbdd 100644 --- a/dubbo-serialization/dubbo-serialization-hessian2/src/test/java/org/apache/dubbo/common/model/person/FullAddress.java +++ b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/model/person/FullAddress.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.common.model.person; +package org.apache.dubbo.common.serialize.model.person; import java.io.Serializable; diff --git a/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/model/person/PersonInfo.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/model/person/PersonInfo.java similarity index 99% rename from dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/model/person/PersonInfo.java rename to dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/model/person/PersonInfo.java index 15f1238fe85..5377d7771ae 100644 --- a/dubbo-serialization/dubbo-serialization-jdk/src/test/java/org/apache/dubbo/common/model/person/PersonInfo.java +++ b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/model/person/PersonInfo.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.common.model.person; +package org.apache.dubbo.common.serialize.model.person; import java.io.Serializable; import java.util.List; diff --git a/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/model/person/PersonStatus.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/model/person/PersonStatus.java similarity index 93% rename from dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/model/person/PersonStatus.java rename to dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/model/person/PersonStatus.java index 62869c2b80b..f5ae72c8309 100644 --- a/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/model/person/PersonStatus.java +++ b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/model/person/PersonStatus.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.common.model.person; +package org.apache.dubbo.common.serialize.model.person; public enum PersonStatus { ENABLED, diff --git a/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/model/person/Phone.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/model/person/Phone.java similarity index 98% rename from dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/model/person/Phone.java rename to dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/model/person/Phone.java index 41fd38a92df..1822eaeb01e 100644 --- a/dubbo-serialization/dubbo-serialization-kryo/src/test/java/org/apache/dubbo/common/model/person/Phone.java +++ b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/model/person/Phone.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.common.model.person; +package org.apache.dubbo.common.serialize.model.person; import java.io.Serializable; diff --git a/dubbo-serialization/dubbo-serialization-api/src/test/java/org/apache/dubbo/common/serialize/support/SerializableClassRegistryTest.java b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/support/SerializableClassRegistryTest.java similarity index 80% rename from dubbo-serialization/dubbo-serialization-api/src/test/java/org/apache/dubbo/common/serialize/support/SerializableClassRegistryTest.java rename to dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/support/SerializableClassRegistryTest.java index efde85c6bc2..4a3a4ad56f9 100644 --- a/dubbo-serialization/dubbo-serialization-api/src/test/java/org/apache/dubbo/common/serialize/support/SerializableClassRegistryTest.java +++ b/dubbo-serialization/dubbo-serialization-test/src/test/java/org/apache/dubbo/common/serialize/support/SerializableClassRegistryTest.java @@ -16,8 +16,11 @@ */ package org.apache.dubbo.common.serialize.support; +import org.apache.dubbo.common.serialize.model.SerializablePerson; +import org.apache.dubbo.common.serialize.model.person.Phone; import org.junit.Test; +import java.io.Serializable; import java.util.Map; import static org.hamcrest.Matchers.equalTo; @@ -26,16 +29,10 @@ public class SerializableClassRegistryTest { @Test public void testAddClasses() { - SerializableClassRegistry.registerClass(A.class); - SerializableClassRegistry.registerClass(B.class); + SerializableClassRegistry.registerClass(SerializablePerson.class); + SerializableClassRegistry.registerClass(Phone.class); Map registeredClasses = SerializableClassRegistry.getRegisteredClasses(); assertThat(registeredClasses.size(), equalTo(2)); } - - private class A { - } - - private class B { - } } \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-test/src/test/resources/log4j.xml b/dubbo-serialization/dubbo-serialization-test/src/test/resources/log4j.xml new file mode 100644 index 00000000000..f71c5535c14 --- /dev/null +++ b/dubbo-serialization/dubbo-serialization-test/src/test/resources/log4j.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/dubbo-serialization/dubbo-serialization-hessian2/src/test/resources/org/apache/dubbo/common/serialize/dubbo/SimpleDO.fc b/dubbo-serialization/dubbo-serialization-test/src/test/resources/org.apache.dubbo.common.serialize.dubbo/SimpleDO.fc similarity index 100% rename from dubbo-serialization/dubbo-serialization-hessian2/src/test/resources/org/apache/dubbo/common/serialize/dubbo/SimpleDO.fc rename to dubbo-serialization/dubbo-serialization-test/src/test/resources/org.apache.dubbo.common.serialize.dubbo/SimpleDO.fc diff --git a/dubbo-serialization/pom.xml b/dubbo-serialization/pom.xml index 3201877ea53..9c2e8694d77 100644 --- a/dubbo-serialization/pom.xml +++ b/dubbo-serialization/pom.xml @@ -24,7 +24,7 @@ dubbo-serialization pom ${project.artifactId} - The rpc module of dubbo project + The serialization module of dubbo project false @@ -35,5 +35,6 @@ dubbo-serialization-kryo dubbo-serialization-fst dubbo-serialization-jdk + dubbo-serialization-test