You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by il...@apache.org on 2018/05/03 05:52:10 UTC
[incubator-dubbo] branch master updated: add test for serialization
api & fastjson & fst module (#1718)
This is an automated email from the ASF dual-hosted git repository.
iluo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git
The following commit(s) were added to refs/heads/master by this push:
new 6784375 add test for serialization api & fastjson & fst module (#1718)
6784375 is described below
commit 6784375811518a200685e635ee51edc548629971
Author: Huang YunKun <ht...@gmail.com>
AuthorDate: Thu May 3 13:52:08 2018 +0800
add test for serialization api & fastjson & fst module (#1718)
---
.../support/SerializableClassRegistryTest.java} | 25 +-
.../serialize/fastjson/FastJsonObjectInput.java | 58 +-
.../serialize/fastjson/FastJsonObjectOutput.java | 3 -
.../serialize/fastjson/FastJsonSerialization.java | 3 -
.../com/alibaba/dubbo/common/model/AnimalEnum.java | 21 -
.../com/alibaba/dubbo/common/model/Person.java | 95 --
.../dubbo/common/model/SerializablePerson.java | 97 --
.../alibaba/dubbo/common/model/media/Image.java | 120 --
.../alibaba/dubbo/common/model/media/Media.java | 205 ----
.../dubbo/common/model/media/MediaContent.java | 78 --
.../dubbo/common/model/person/BigPerson.java | 151 ---
.../dubbo/common/model/person/PersonInfo.java | 206 ----
.../dubbo/common/model/person/PersonStatus.java | 22 -
.../alibaba/dubbo/common/model/person/Phone.java | 139 ---
.../fastjson/FastJsonObjectInputTest.java | 147 +++
.../fastjson/FastJsonObjectOutputTest.java | 139 +++
.../fastjson/FastJsonSerializationTest.java | 65 ++
.../common/serialize/fastjson/model}/Image.java | 28 +-
.../fastjson/model/Person.java} | 23 +-
.../AbstractSerializationPersionFailTest.java | 137 ---
.../AbstractSerializationPersionOkTest.java | 93 --
.../serialization/AbstractSerializationTest.java | 1210 --------------------
.../serialization/FastJsonSerializationTest.java | 305 -----
...bo.common.extensionloader.activate.ActivateExt1 | 4 -
....common.extensionloader.adaptive.HasAdaptiveExt | 2 -
...common.extensionloader.compatible.CompatibleExt | 2 -
...aba.dubbo.common.extensionloader.ext1.SimpleExt | 4 -
....alibaba.dubbo.common.extensionloader.ext2.Ext2 | 3 -
...o.common.extensionloader.ext3.UseProtocolKeyExt | 3 -
...dubbo.common.extensionloader.ext4.NoUrlParamExt | 2 -
...common.extensionloader.ext5.NoAdaptiveMethodExt | 2 -
...a.dubbo.common.extensionloader.ext6_inject.Ext6 | 2 -
...bbo.common.extensionloader.ext6_wrap.WrappedExt | 4 -
....dubbo.common.extensionloader.ext7.InitErrorExt | 2 -
...a.dubbo.common.extensionloader.ext8_add.AddExt1 | 1 -
.../com.alibaba.dubbo.common.status.StatusChecker | 1 -
...bo.common.extensionloader.activate.ActivateExt1 | 1 -
.../src/test/resources/StreamUtilsTest.txt | 1 -
.../dubbo/common/serialize/dubbo/SimpleDO.fc | 2 -
.../src/test/resources/json.flex | 68 --
.../src/test/resources/properties.load | 3 -
.../model/BizExceptionNoDefaultConstructor.java | 26 -
.../com/alibaba/dubbo/common/model/Person.java | 95 --
.../dubbo/common/model/SerializablePerson.java | 97 --
.../alibaba/dubbo/common/model/media/Media.java | 205 ----
.../dubbo/common/model/media/MediaContent.java | 78 --
.../dubbo/common/model/person/BigPerson.java | 151 ---
.../dubbo/common/model/person/FullAddress.java | 202 ----
.../dubbo/common/model/person/PersonInfo.java | 206 ----
.../dubbo/common/model/person/PersonStatus.java | 22 -
.../alibaba/dubbo/common/model/person/Phone.java | 139 ---
.../fst/FstFactoryTest.java} | 17 +-
.../common/serialize/fst/FstObjectInputTest.java | 48 +
.../common/serialize/fst/FstObjectOutputTest.java | 180 +++
.../common/serialize/fst/FstSerializationTest.java | 62 +
.../{ => serialize/fst}/model/AnimalEnum.java | 2 +-
.../common/serialize/fst/model}/FullAddress.java | 5 +-
.../serialization/FstSerializationTest.java | 1124 ------------------
pom.xml | 7 +
59 files changed, 715 insertions(+), 5428 deletions(-)
diff --git a/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/model/BizExceptionNoDefaultConstructor.java b/dubbo-serialization/dubbo-serialization-api/src/test/java/com/alibaba/dubbo/common/serialize/support/SerializableClassRegistryTest.java
similarity index 57%
rename from dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/model/BizExceptionNoDefaultConstructor.java
rename to dubbo-serialization/dubbo-serialization-api/src/test/java/com/alibaba/dubbo/common/serialize/support/SerializableClassRegistryTest.java
index 29db6e0..156e52f 100644
--- a/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/model/BizExceptionNoDefaultConstructor.java
+++ b/dubbo-serialization/dubbo-serialization-api/src/test/java/com/alibaba/dubbo/common/serialize/support/SerializableClassRegistryTest.java
@@ -14,13 +14,28 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.alibaba.dubbo.common.model;
+package com.alibaba.dubbo.common.serialize.support;
-public class BizExceptionNoDefaultConstructor extends RuntimeException {
+import org.junit.Test;
- private static final long serialVersionUID = 1L;
+import java.util.Set;
- public BizExceptionNoDefaultConstructor(String message) {
- super(message);
+import static org.hamcrest.Matchers.hasSize;
+import static org.junit.Assert.assertThat;
+
+public class SerializableClassRegistryTest {
+ @Test
+ public void testAddClasses() {
+ SerializableClassRegistry.registerClass(A.class);
+ SerializableClassRegistry.registerClass(B.class);
+
+ Set<Class> registeredClasses = SerializableClassRegistry.getRegisteredClasses();
+ assertThat(registeredClasses, hasSize(2));
+ }
+
+ private class A {
+ }
+
+ private class B {
}
}
\ No newline at end of file
diff --git a/dubbo-serialization/dubbo-serialization-fastjson/src/main/java/com/alibaba/dubbo/common/serialize/fastjson/FastJsonObjectInput.java b/dubbo-serialization/dubbo-serialization-fastjson/src/main/java/com/alibaba/dubbo/common/serialize/fastjson/FastJsonObjectInput.java
index 27de7ed..3ef50ce 100644
--- a/dubbo-serialization/dubbo-serialization-fastjson/src/main/java/com/alibaba/dubbo/common/serialize/fastjson/FastJsonObjectInput.java
+++ b/dubbo-serialization/dubbo-serialization-fastjson/src/main/java/com/alibaba/dubbo/common/serialize/fastjson/FastJsonObjectInput.java
@@ -28,9 +28,6 @@ import java.io.InputStreamReader;
import java.io.Reader;
import java.lang.reflect.Type;
-/**
- * JsonObjectInput
- */
public class FastJsonObjectInput implements ObjectInput {
private final BufferedReader reader;
@@ -45,74 +42,42 @@ public class FastJsonObjectInput implements ObjectInput {
@Override
public boolean readBool() throws IOException {
- try {
- return readObject(boolean.class);
- } catch (ClassNotFoundException e) {
- throw new IOException(e.getMessage());
- }
+ return read(boolean.class);
}
@Override
public byte readByte() throws IOException {
- try {
- return readObject(byte.class);
- } catch (ClassNotFoundException e) {
- throw new IOException(e.getMessage());
- }
+ return read(byte.class);
}
@Override
public short readShort() throws IOException {
- try {
- return readObject(short.class);
- } catch (ClassNotFoundException e) {
- throw new IOException(e.getMessage());
- }
+ return read(short.class);
}
@Override
public int readInt() throws IOException {
- try {
- return readObject(int.class);
- } catch (ClassNotFoundException e) {
- throw new IOException(e.getMessage());
- }
+ return read(int.class);
}
@Override
public long readLong() throws IOException {
- try {
- return readObject(long.class);
- } catch (ClassNotFoundException e) {
- throw new IOException(e.getMessage());
- }
+ return read(long.class);
}
@Override
public float readFloat() throws IOException {
- try {
- return readObject(float.class);
- } catch (ClassNotFoundException e) {
- throw new IOException(e.getMessage());
- }
+ return read(float.class);
}
@Override
public double readDouble() throws IOException {
- try {
- return readObject(double.class);
- } catch (ClassNotFoundException e) {
- throw new IOException(e.getMessage());
- }
+ return read(double.class);
}
@Override
public String readUTF() throws IOException {
- try {
- return readObject(String.class);
- } catch (ClassNotFoundException e) {
- throw new IOException(e.getMessage());
- }
+ return read(String.class);
}
@Override
@@ -128,8 +93,7 @@ public class FastJsonObjectInput implements ObjectInput {
@Override
public <T> T readObject(Class<T> cls) throws IOException, ClassNotFoundException {
- String json = readLine();
- return JSON.parseObject(json, cls);
+ return read(cls);
}
@Override
@@ -145,4 +109,8 @@ public class FastJsonObjectInput implements ObjectInput {
return line;
}
+ private <T> T read(Class<T> cls) throws IOException {
+ String json = readLine();
+ return JSON.parseObject(json, cls);
+ }
}
diff --git a/dubbo-serialization/dubbo-serialization-fastjson/src/main/java/com/alibaba/dubbo/common/serialize/fastjson/FastJsonObjectOutput.java b/dubbo-serialization/dubbo-serialization-fastjson/src/main/java/com/alibaba/dubbo/common/serialize/fastjson/FastJsonObjectOutput.java
index 4979339..91d9171 100644
--- a/dubbo-serialization/dubbo-serialization-fastjson/src/main/java/com/alibaba/dubbo/common/serialize/fastjson/FastJsonObjectOutput.java
+++ b/dubbo-serialization/dubbo-serialization-fastjson/src/main/java/com/alibaba/dubbo/common/serialize/fastjson/FastJsonObjectOutput.java
@@ -27,9 +27,6 @@ import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;
-/**
- * JsonObjectOutput
- */
public class FastJsonObjectOutput implements ObjectOutput {
private final PrintWriter writer;
diff --git a/dubbo-serialization/dubbo-serialization-fastjson/src/main/java/com/alibaba/dubbo/common/serialize/fastjson/FastJsonSerialization.java b/dubbo-serialization/dubbo-serialization-fastjson/src/main/java/com/alibaba/dubbo/common/serialize/fastjson/FastJsonSerialization.java
index 3f73434..15daf8e 100644
--- a/dubbo-serialization/dubbo-serialization-fastjson/src/main/java/com/alibaba/dubbo/common/serialize/fastjson/FastJsonSerialization.java
+++ b/dubbo-serialization/dubbo-serialization-fastjson/src/main/java/com/alibaba/dubbo/common/serialize/fastjson/FastJsonSerialization.java
@@ -25,9 +25,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-/**
- * FastJsonSerialization
- */
public class FastJsonSerialization implements Serialization {
@Override
diff --git a/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/model/AnimalEnum.java b/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/model/AnimalEnum.java
deleted file mode 100644
index f920a0c..0000000
--- a/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/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 com.alibaba.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-fastjson/src/test/java/com/alibaba/dubbo/common/model/Person.java b/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/model/Person.java
deleted file mode 100644
index 6383706..0000000
--- a/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/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 com.alibaba.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-fastjson/src/test/java/com/alibaba/dubbo/common/model/SerializablePerson.java b/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/model/SerializablePerson.java
deleted file mode 100644
index e7dd248..0000000
--- a/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/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 com.alibaba.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-fastjson/src/test/java/com/alibaba/dubbo/common/model/media/Image.java b/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/model/media/Image.java
deleted file mode 100644
index 0d6a74a..0000000
--- a/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/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 com.alibaba.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-fastjson/src/test/java/com/alibaba/dubbo/common/model/media/Media.java b/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/model/media/Media.java
deleted file mode 100644
index 8a78f6d..0000000
--- a/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/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 com.alibaba.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<String> 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<String> 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<String> getPersons() {
- return persons;
- }
-
- public void setPersons(List<String> 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-fastjson/src/test/java/com/alibaba/dubbo/common/model/media/MediaContent.java b/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/model/media/MediaContent.java
deleted file mode 100644
index 9664116..0000000
--- a/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/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 com.alibaba.dubbo.common.model.media;
-
-import java.util.List;
-
-@SuppressWarnings("serial")
-public class MediaContent implements java.io.Serializable {
- public Media media;
- public List<Image> images;
-
- public MediaContent() {
- }
-
- public MediaContent(Media media, List<Image> 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<Image> getImages() {
- return images;
- }
-
- public void setImages(List<Image> images) {
- this.images = images;
- }
-}
\ No newline at end of file
diff --git a/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/model/person/BigPerson.java b/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/model/person/BigPerson.java
deleted file mode 100644
index 70bc793..0000000
--- a/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/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 com.alibaba.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-fastjson/src/test/java/com/alibaba/dubbo/common/model/person/PersonInfo.java b/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/model/person/PersonInfo.java
deleted file mode 100644
index f1ff041..0000000
--- a/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/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 com.alibaba.dubbo.common.model.person;
-
-import java.io.Serializable;
-import java.util.List;
-
-public class PersonInfo implements Serializable {
- private static final long serialVersionUID = 7443011149612231882L;
-
- List<Phone> phones;
-
- Phone fax;
-
- FullAddress fullAddress;
-
- String mobileNo;
-
- String name;
-
- boolean male;
-
- boolean female;
-
- String department;
-
- String jobTitle;
-
- String homepageUrl;
-
- public List<Phone> getPhones() {
- return phones;
- }
-
- public void setPhones(List<Phone> 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-fastjson/src/test/java/com/alibaba/dubbo/common/model/person/PersonStatus.java b/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/model/person/PersonStatus.java
deleted file mode 100644
index 66b67c9..0000000
--- a/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/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 com.alibaba.dubbo.common.model.person;
-
-public enum PersonStatus {
- ENABLED,
- DISABLED
-}
\ No newline at end of file
diff --git a/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/model/person/Phone.java b/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/model/person/Phone.java
deleted file mode 100644
index f7da708..0000000
--- a/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/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 com.alibaba.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-fastjson/src/test/java/com/alibaba/dubbo/common/serialize/fastjson/FastJsonObjectInputTest.java b/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/serialize/fastjson/FastJsonObjectInputTest.java
new file mode 100644
index 0000000..06e6bc6
--- /dev/null
+++ b/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/serialize/fastjson/FastJsonObjectInputTest.java
@@ -0,0 +1,147 @@
+/*
+ * 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 com.alibaba.dubbo.common.serialize.fastjson;
+
+import com.alibaba.dubbo.common.serialize.fastjson.model.Person;
+import com.alibaba.fastjson.JSONObject;
+import org.junit.Test;
+
+import java.io.ByteArrayInputStream;
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.StringReader;
+
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+public class FastJsonObjectInputTest {
+ private FastJsonObjectInput fastJsonObjectInput;
+
+ @Test
+ public void testReadBool() throws IOException {
+ fastJsonObjectInput = new FastJsonObjectInput(new ByteArrayInputStream("true".getBytes()));
+ boolean result = fastJsonObjectInput.readBool();
+
+ assertThat(result, is(true));
+
+ fastJsonObjectInput = new FastJsonObjectInput(new StringReader("false"));
+ result = fastJsonObjectInput.readBool();
+
+ assertThat(result, is(false));
+ }
+
+ @Test
+ public void testReadByte() throws IOException {
+ fastJsonObjectInput = new FastJsonObjectInput(new ByteArrayInputStream("123".getBytes()));
+ Byte result = fastJsonObjectInput.readByte();
+
+ assertThat(result, is(Byte.parseByte("123")));
+ }
+
+ @Test
+ public void testReadBytes() throws IOException {
+ fastJsonObjectInput = new FastJsonObjectInput(new ByteArrayInputStream("123456".getBytes()));
+ byte[] result = fastJsonObjectInput.readBytes();
+
+ assertThat(result, is("123456".getBytes()));
+ }
+
+ @Test
+ public void testReadShort() throws IOException {
+ fastJsonObjectInput = new FastJsonObjectInput(new StringReader("1"));
+ short result = fastJsonObjectInput.readShort();
+
+ assertThat(result, is((short) 1));
+ }
+
+ @Test
+ public void testReadInt() throws IOException {
+ fastJsonObjectInput = new FastJsonObjectInput(new StringReader("1"));
+ Integer result = fastJsonObjectInput.readInt();
+
+ assertThat(result, is(1));
+ }
+
+ @Test
+ public void testReadDouble() throws IOException {
+ fastJsonObjectInput = new FastJsonObjectInput(new StringReader("1.88"));
+ Double result = fastJsonObjectInput.readDouble();
+
+ assertThat(result, is(1.88d));
+ }
+
+ @Test
+ public void testReadLong() throws IOException {
+ fastJsonObjectInput = new FastJsonObjectInput(new StringReader("10"));
+ Long result = fastJsonObjectInput.readLong();
+
+ assertThat(result, is(10L));
+ }
+
+ @Test
+ public void testReadFloat() throws IOException {
+ fastJsonObjectInput = new FastJsonObjectInput(new StringReader("1.66"));
+ Float result = fastJsonObjectInput.readFloat();
+
+ assertThat(result, is(1.66F));
+ }
+
+ @Test
+ public void testReadUTF() throws IOException {
+ fastJsonObjectInput = new FastJsonObjectInput(new StringReader("\"wording\""));
+ String result = fastJsonObjectInput.readUTF();
+
+ assertThat(result, is("wording"));
+ }
+
+ @Test
+ public void testReadObject() throws IOException, ClassNotFoundException {
+ fastJsonObjectInput = new FastJsonObjectInput(new StringReader("{ \"name\":\"John\", \"age\":30 }"));
+ Person result = fastJsonObjectInput.readObject(Person.class);
+
+ assertThat(result, not(nullValue()));
+ assertThat(result.getName(), is("John"));
+ assertThat(result.getAge(), is(30));
+ }
+
+ @Test(expected = EOFException.class)
+ public void testEmptyLine() throws IOException, ClassNotFoundException {
+ fastJsonObjectInput = new FastJsonObjectInput(new StringReader(""));
+
+ fastJsonObjectInput.readObject();
+ }
+
+ @Test(expected = EOFException.class)
+ public void testEmptySpace() throws IOException, ClassNotFoundException {
+ fastJsonObjectInput = new FastJsonObjectInput(new StringReader(" "));
+
+ fastJsonObjectInput.readObject();
+ }
+
+ @Test
+ public void testReadObjectWithoutClass() throws IOException, ClassNotFoundException {
+ fastJsonObjectInput = new FastJsonObjectInput(new StringReader("{ \"name\":\"John\", \"age\":30 }"));
+
+ JSONObject readObject = (JSONObject) fastJsonObjectInput.readObject();
+
+ assertThat(readObject, not(nullValue()));
+ assertThat(readObject.getString("name"), is("John"));
+ assertThat(readObject.getInteger("age"), is(30));
+ }
+}
\ No newline at end of file
diff --git a/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/serialize/fastjson/FastJsonObjectOutputTest.java b/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/serialize/fastjson/FastJsonObjectOutputTest.java
new file mode 100644
index 0000000..f8cda1d
--- /dev/null
+++ b/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/serialize/fastjson/FastJsonObjectOutputTest.java
@@ -0,0 +1,139 @@
+/*
+ * 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 com.alibaba.dubbo.common.serialize.fastjson;
+
+import com.alibaba.dubbo.common.serialize.fastjson.model.Image;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.assertThat;
+
+public class FastJsonObjectOutputTest {
+ private FastJsonObjectOutput fastJsonObjectOutput;
+ private FastJsonObjectInput fastJsonObjectInput;
+ private ByteArrayOutputStream byteArrayOutputStream;
+ private ByteArrayInputStream byteArrayInputStream;
+
+ @Before
+ public void setUp() throws Exception {
+ this.byteArrayOutputStream = new ByteArrayOutputStream();
+ this.fastJsonObjectOutput = new FastJsonObjectOutput(byteArrayOutputStream);
+ }
+
+ @Test
+ public void testWriteBool() throws IOException {
+ this.fastJsonObjectOutput.writeBool(true);
+ this.flushToInput();
+
+ assertThat(fastJsonObjectInput.readBool(), is(true));
+ }
+
+ @Test
+ public void testWriteShort() throws IOException {
+ this.fastJsonObjectOutput.writeShort((short) 2);
+ this.flushToInput();
+
+ assertThat(fastJsonObjectInput.readShort(), is((short) 2));
+ }
+
+ @Test
+ public void testWriteInt() throws IOException {
+ this.fastJsonObjectOutput.writeInt(1);
+ this.flushToInput();
+
+ assertThat(fastJsonObjectInput.readInt(), is(1));
+ }
+
+ @Test
+ public void testWriteLong() throws IOException {
+ this.fastJsonObjectOutput.writeLong(1000L);
+ this.flushToInput();
+
+ assertThat(fastJsonObjectInput.readLong(), is(1000L));
+ }
+
+ @Test
+ public void testWriteUTF() throws IOException {
+ this.fastJsonObjectOutput.writeUTF("Pace Hasîtî 和平 Мир");
+ this.flushToInput();
+
+ assertThat(fastJsonObjectInput.readUTF(), is("Pace Hasîtî 和平 Мир"));
+ }
+
+
+ @Test
+ public void testWriteFloat() throws IOException {
+ this.fastJsonObjectOutput.writeFloat(1.88f);
+ this.flushToInput();
+
+ assertThat(this.fastJsonObjectInput.readFloat(), is(1.88f));
+ }
+
+ @Test
+ public void testWriteDouble() throws IOException {
+ this.fastJsonObjectOutput.writeDouble(1.66d);
+ this.flushToInput();
+
+ assertThat(this.fastJsonObjectInput.readDouble(), is(1.66d));
+ }
+
+ @Test
+ public void testWriteBytes() throws IOException {
+ this.fastJsonObjectOutput.writeBytes("hello".getBytes());
+ this.flushToInput();
+
+ assertThat(this.fastJsonObjectInput.readBytes(), is("hello".getBytes()));
+ }
+
+ @Test
+ public void testWriteBytesWithSubLength() throws IOException {
+ this.fastJsonObjectOutput.writeBytes("hello".getBytes(), 2, 2);
+ this.flushToInput();
+
+ assertThat(this.fastJsonObjectInput.readBytes(), is("ll".getBytes()));
+ }
+
+ @Test
+ public void testWriteByte() throws IOException {
+ this.fastJsonObjectOutput.writeByte((byte) 123);
+ this.flushToInput();
+
+ assertThat(this.fastJsonObjectInput.readByte(), is((byte) 123));
+ }
+
+ @Test
+ public void testWriteObject() throws IOException, ClassNotFoundException {
+ Image image = new Image("http://dubbo.io/logo.png", "logo", 300, 480, Image.Size.SMALL);
+ this.fastJsonObjectOutput.writeObject(image);
+ this.flushToInput();
+
+ Image readObjectForImage = fastJsonObjectInput.readObject(Image.class);
+ assertThat(readObjectForImage, not(nullValue()));
+ assertThat(readObjectForImage, is(image));
+ }
+
+ private void flushToInput() throws IOException {
+ this.fastJsonObjectOutput.flushBuffer();
+ this.byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
+ this.fastJsonObjectInput = new FastJsonObjectInput(byteArrayInputStream);
+ }
+}
\ No newline at end of file
diff --git a/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/serialize/fastjson/FastJsonSerializationTest.java b/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/serialize/fastjson/FastJsonSerializationTest.java
new file mode 100644
index 0000000..e4297b3
--- /dev/null
+++ b/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/serialize/fastjson/FastJsonSerializationTest.java
@@ -0,0 +1,65 @@
+/*
+ * 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 com.alibaba.dubbo.common.serialize.fastjson;
+
+import com.alibaba.dubbo.common.serialize.ObjectInput;
+import com.alibaba.dubbo.common.serialize.ObjectOutput;
+import com.alibaba.dubbo.common.serialize.fastjson.FastJsonObjectInput;
+import com.alibaba.dubbo.common.serialize.fastjson.FastJsonObjectOutput;
+import com.alibaba.dubbo.common.serialize.fastjson.FastJsonSerialization;
+import org.hamcrest.Matchers;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.mock;
+
+public class FastJsonSerializationTest {
+ private FastJsonSerialization fastJsonSerialization;
+
+ @Before
+ public void setUp() {
+ this.fastJsonSerialization = new FastJsonSerialization();
+ }
+
+ @Test
+ public void testContentType() {
+ assertThat(fastJsonSerialization.getContentType(), is("text/json"));
+ }
+
+ @Test
+ public void testContentTypeId() {
+ assertThat(fastJsonSerialization.getContentTypeId(), is((byte) 6));
+ }
+
+ @Test
+ public void testObjectOutput() throws IOException {
+ ObjectOutput objectOutput = fastJsonSerialization.serialize(null, mock(OutputStream.class));
+ assertThat(objectOutput, Matchers.<ObjectOutput>instanceOf(FastJsonObjectOutput.class));
+ }
+
+ @Test
+ public void testObjectInput() throws IOException {
+ ObjectInput objectInput = fastJsonSerialization.deserialize(null, mock(InputStream.class));
+ assertThat(objectInput, Matchers.<ObjectInput>instanceOf(FastJsonObjectInput.class));
+ }
+}
\ No newline at end of file
diff --git a/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/model/media/Image.java b/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/serialize/fastjson/model/Image.java
similarity index 82%
rename from dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/model/media/Image.java
rename to dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/serialize/fastjson/model/Image.java
index 0d6a74a..5debe9c 100644
--- a/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/model/media/Image.java
+++ b/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/serialize/fastjson/model/Image.java
@@ -14,19 +14,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.alibaba.dubbo.common.model.media;
-
+package com.alibaba.dubbo.common.serialize.fastjson.model;
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() {
- }
+ 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;
@@ -62,18 +58,6 @@ public class Image implements java.io.Serializable {
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;
}
diff --git a/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/model/BizException.java b/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/serialize/fastjson/model/Person.java
similarity index 69%
rename from dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/model/BizException.java
rename to dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/serialize/fastjson/model/Person.java
index b6eb1f4..329ce94 100644
--- a/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/model/BizException.java
+++ b/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/serialize/fastjson/model/Person.java
@@ -14,16 +14,25 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.alibaba.dubbo.common.model;
+package com.alibaba.dubbo.common.serialize.fastjson.model;
-public class BizException extends RuntimeException {
+public class Person {
+ private String name;
+ private int age;
- private static final long serialVersionUID = 1L;
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
- public BizException(String message) {
- super(message);
+ public int getAge() {
+ return age;
}
- public BizException() {
+ public void setAge(int age) {
+ this.age = age;
}
-}
\ No newline at end of file
+}
diff --git a/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/serialize/serialization/AbstractSerializationPersionFailTest.java b/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/serialize/serialization/AbstractSerializationPersionFailTest.java
deleted file mode 100644
index 6806033..0000000
--- a/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/serialize/serialization/AbstractSerializationPersionFailTest.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 com.alibaba.dubbo.common.serialize.serialization;
-
-import com.alibaba.dubbo.common.model.Person;
-import com.alibaba.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 AbstractSerializationPersionFailTest 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 com.alibaba.dubbo.common.model.Person must implement java.io.Serializable"));
- }
- }
-
- @Test
- public void test_PersonList() throws Exception {
- List<Person> args = new ArrayList<Person>();
- 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 com.alibaba.dubbo.common.model.Person must implement java.io.Serializable"));
- }
- }
-
- @Test
- public void test_PersonSet() throws Exception {
- Set<Person> args = new HashSet<Person>();
- 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 com.alibaba.dubbo.common.model.Person must implement java.io.Serializable"));
- }
- }
-
- @Test
- public void test_IntPersonMap() throws Exception {
- Map<Integer, Person> args = new HashMap<Integer, Person>();
- 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 com.alibaba.dubbo.common.model.Person must implement java.io.Serializable"));
- }
- }
-
- @Test
- public void test_StringPersonMap() throws Exception {
- Map<String, Person> args = new HashMap<String, Person>();
- 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 com.alibaba.dubbo.common.model.Person must implement java.io.Serializable"));
- }
- }
-
- @Test
- public void test_StringPersonListMap() throws Exception {
- Map<String, List<Person>> args = new HashMap<String, List<Person>>();
-
- List<Person> sublist = new ArrayList<Person>();
- 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 com.alibaba.dubbo.common.model.Person must implement java.io.Serializable"));
- }
- }
-
- @Test
- public void test_PersonListList() throws Exception {
- List<List<Person>> args = new ArrayList<List<Person>>();
- List<Person> sublist = new ArrayList<Person>();
- 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 com.alibaba.dubbo.common.model.Person must implement java.io.Serializable"));
- }
- }
-}
\ No newline at end of file
diff --git a/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/serialize/serialization/AbstractSerializationPersionOkTest.java b/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/serialize/serialization/AbstractSerializationPersionOkTest.java
deleted file mode 100644
index 32ff6e4..0000000
--- a/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/serialize/serialization/AbstractSerializationPersionOkTest.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 com.alibaba.dubbo.common.serialize.serialization;
-
-import com.alibaba.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 AbstractSerializationPersionOkTest 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<Person> args = new ArrayList<Person>();
- args.add(new Person());
-
- assertObject(args);
- }
-
- @Test
- public void test_PersonSet() throws Exception {
- Set<Person> args = new HashSet<Person>();
- args.add(new Person());
-
- assertObject(args);
- }
-
- @Test
- public void test_IntPersonMap() throws Exception {
- Map<Integer, Person> args = new HashMap<Integer, Person>();
- args.put(1, new Person());
-
- assertObject(args);
- }
-
- @Test
- public void test_StringPersonMap() throws Exception {
- Map<String, Person> args = new HashMap<String, Person>();
- args.put("1", new Person());
-
- assertObject(args);
- }
-
- @Test
- public void test_StringPersonListMap() throws Exception {
- Map<String, List<Person>> args = new HashMap<String, List<Person>>();
-
- List<Person> sublist = new ArrayList<Person>();
- sublist.add(new Person());
- args.put("1", sublist);
-
- assertObject(args);
- }
-
- @Test
- public void test_PersonListList() throws Exception {
- List<List<Person>> args = new ArrayList<List<Person>>();
- List<Person> sublist = new ArrayList<Person>();
- sublist.add(new Person());
- args.add(sublist);
-
- assertObject(args);
- }
-}
\ No newline at end of file
diff --git a/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/serialize/serialization/AbstractSerializationTest.java b/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/serialize/serialization/AbstractSerializationTest.java
deleted file mode 100644
index 3219603..0000000
--- a/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/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 com.alibaba.dubbo.common.serialize.serialization;
-
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.common.model.AnimalEnum;
-import com.alibaba.dubbo.common.model.BizException;
-import com.alibaba.dubbo.common.model.BizExceptionNoDefaultConstructor;
-import com.alibaba.dubbo.common.model.SerializablePerson;
-import com.alibaba.dubbo.common.model.media.Image;
-import com.alibaba.dubbo.common.model.media.Image.Size;
-import com.alibaba.dubbo.common.model.media.Media;
-import com.alibaba.dubbo.common.model.media.Media.Player;
-import com.alibaba.dubbo.common.model.media.MediaContent;
-import com.alibaba.dubbo.common.model.person.BigPerson;
-import com.alibaba.dubbo.common.model.person.FullAddress;
-import com.alibaba.dubbo.common.model.person.PersonInfo;
-import com.alibaba.dubbo.common.model.person.PersonStatus;
-import com.alibaba.dubbo.common.model.person.Phone;
-import com.alibaba.dubbo.common.serialize.ObjectInput;
-import com.alibaba.dubbo.common.serialize.ObjectOutput;
-import com.alibaba.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("protocl", "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<Phone> phones = new ArrayList<Phone>();
- 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<String> persons = new ArrayList<String>();
- persons.add("jerry");
- persons.add("tom");
- persons.add("lucy");
- media.setPersons(persons);
- media.setCopyright("1999-2011");
- media.setPlayer(Player.FLASH);
-
- List<Image> images = new ArrayList<Image>();
- 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 ================
-
- <T> void assertObjectArray(T[] data, Class<T[]> 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) {
- }
- }
-
- <T> void assertObjectArrayWithType(T[] data, Class<T[]> 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")
- <T> 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) {
- }
- }
-
- <T> void assertObjectWithType(T data, Class<T> 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<String> args = Arrays.asList(new String[]{"1", "b"});
-
- assertObject(args);
- }
-
- @Test
- public void test_StringArrayList() throws Exception {
- List<String> args = new ArrayList<String>(Arrays.asList(new String[]{"1", "b"}));
-
- assertObject(args);
- }
-
- @Test
- public void test_StringSet() throws Exception {
- Set<String> args = new HashSet<String>();
- args.add("1");
-
- assertObject(args);
- }
-
- @Test
- public void test_LinkedHashMap() throws Exception {
- LinkedHashMap<String, String> data = new LinkedHashMap<String, String>();
- 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<String, String>) 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<SerializablePerson> args = new ArrayList<SerializablePerson>();
- args.add(new SerializablePerson());
-
- assertObject(args);
- }
-
- @Test
- public void test_SPersonSet() throws Exception {
- Set<SerializablePerson> args = new HashSet<SerializablePerson>();
- args.add(new SerializablePerson());
-
- assertObject(args);
- }
-
- // ================ complex POJO =============
-
- @Test
- public void test_IntSPersonMap() throws Exception {
- Map<Integer, SerializablePerson> args = new HashMap<Integer, SerializablePerson>();
- args.put(1, new SerializablePerson());
-
- assertObject(args);
- }
-
- @Test
- public void test_StringSPersonMap() throws Exception {
- Map<String, SerializablePerson> args = new HashMap<String, SerializablePerson>();
- args.put("1", new SerializablePerson());
-
- assertObject(args);
- }
-
- @Test
- public void test_StringSPersonListMap() throws Exception {
- Map<String, List<SerializablePerson>> args = new HashMap<String, List<SerializablePerson>>();
-
- List<SerializablePerson> sublist = new ArrayList<SerializablePerson>();
- sublist.add(new SerializablePerson());
- args.put("1", sublist);
-
- assertObject(args);
- }
-
- @Test
- public void test_SPersonListList() throws Exception {
- List<List<SerializablePerson>> args = new ArrayList<List<SerializablePerson>>();
- List<SerializablePerson> sublist = new ArrayList<SerializablePerson>();
- 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<String, Object> map = new HashMap<String, Object>();
- 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<String, Object> output = (Map<String, Object>) 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-fastjson/src/test/java/com/alibaba/dubbo/common/serialize/serialization/FastJsonSerializationTest.java b/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/serialize/serialization/FastJsonSerializationTest.java
deleted file mode 100644
index 5044d42..0000000
--- a/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/serialize/serialization/FastJsonSerializationTest.java
+++ /dev/null
@@ -1,305 +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 com.alibaba.dubbo.common.serialize.serialization;
-
-import com.alibaba.dubbo.common.model.media.MediaContent;
-import com.alibaba.dubbo.common.serialize.ObjectInput;
-import com.alibaba.dubbo.common.serialize.ObjectOutput;
-import com.alibaba.dubbo.common.serialize.fastjson.FastJsonSerialization;
-import com.alibaba.fastjson.JSONException;
-
-import org.junit.Ignore;
-import org.junit.Test;
-
-import java.io.ByteArrayInputStream;
-
-import static org.junit.Assert.fail;
-
-public class FastJsonSerializationTest extends AbstractSerializationPersionOkTest {
- {
- serialization = new FastJsonSerialization();
- }
-
- @Ignore // FIXME
- @Test
- public void test_BytesRange() throws Exception {
- }
-
- @Ignore("bool[] type missing to JSONArray")
- @Test
- public void test_boolArray() throws Exception {
- }
-
- @Ignore("FastJson bug: com.alibaba.fastjson.JSONException: create asm serilizer error, class char")
- @Test
- public void test_charArray() throws Exception {
- }
-
- @Ignore("FastJson bug: com.alibaba.fastjson.JSONException: create asm serilizer error, class char")
- @Test
- public void test_charArray_withType() throws Exception {
- }
-
- @Ignore("short[] type missing to JSONArray")
- @Test
- public void test_shortArray() throws Exception {
- }
-
- @Ignore("int[] type missing to JSONArray")
- @Test
- public void test_intArray() throws Exception {
- }
-
- @Ignore("long[] type missing to JSONArray")
- @Test
- public void test_longArray() throws Exception {
- }
-
- @Ignore("float[] type missing to JSONArray")
- @Test
- public void test_floatArray() throws Exception {
- }
-
- @Ignore("double[] type missing to JSONArray")
- @Test
- public void test_doubleArray() throws Exception {
- }
-
- @Ignore("String[] type missing to JSONArray")
- @Test
- public void test_StringArray() throws Exception {
- }
-
- @Ignore("Integer[] type missing to JSONArray")
- @Test
- public void test_IntegerArray() throws Exception {
- }
-
- @Ignore("Integer[] type missing to JSONArray")
- @Test
- public void test_EnumArray() throws Exception {
- }
-
- @Ignore("type mising to Long")
- @Test
- public void test_Date() throws Exception {
- }
-
- @Ignore("type mising to Long")
- @Test
- public void test_Time() throws Exception {
- }
-
- @Ignore("com.alibaba.fastjson.JSONException: create asm deserializer error, java.sql.Time")
- @Test
- public void test_Time_withType() throws Exception {
- }
-
- @Ignore("type mising to Integer")
- @Test
- public void test_ByteWrap() throws Exception {
- }
-
- @Ignore("type mising to Integer")
- @Test
- public void test_LongWrap() throws Exception {
- }
-
- @Ignore("type mising to Long")
- @Test
- public void test_BigInteger() throws Exception {
- }
-
- @Ignore("SPerson type missing")
- @Test
- public void test_SPerson() throws Exception {
- }
-
- @Ignore("BizException type missing to Map")
- @Test
- public void test_BizException() throws Exception {
- }
-
- @Ignore("BizExceptionNoDefaultConstructor type missing to Map")
- @Test
- public void test_BizExceptionNoDefaultConstructor() throws Exception {
- }
-
- // FIXME fail when there's no default constructor
- @Ignore("NoDefaultConstructor")
- @Test
- public void test_BizExceptionNoDefaultConstructor_WithType() throws Exception {
- }
-
- @Ignore("Enum type missing to String")
- @Test
- public void test_enum() throws Exception {
- }
-
- @Ignore("String set missing to JSONArray")
- @Test
- public void test_StringSet() throws Exception {
- }
-
- @Ignore("LinkedHashMap type missing to Map")
- @Test
- public void test_LinkedHashMap() throws Exception {
- }
-
-
- @Ignore("person type missing")
- @Test
- public void test_SPersonList() throws Exception {
- }
-
- @Ignore("person type missing")
- @Test
- public void test_SPersonSet() throws Exception {
- }
-
- @Ignore("FastJson bug: com.alibaba.fastjson.JSONException: illegal identifier : 1")
- @Test
- public void test_IntSPersonMap() throws Exception {
- }
-
- @Ignore("person type missing")
- @Test
- public void test_StringSPersonMap() throws Exception {
- }
-
- @Ignore("person type missing")
- @Test
- public void test_StringSPersonListMap() throws Exception {
- }
-
- @Ignore("person type missing")
- @Test
- public void test_SPersonListList() throws Exception {
- }
-
- @Ignore("BigPerson type missing")
- @Test
- public void test_BigPerson() throws Exception {
- }
-
- @Ignore("MediaContent type missing")
- @Test
- public void test_MediaContent() throws Exception {
- }
-
- @Ignore("type missing")
- @Test
- public void test_MultiObject() throws Exception {
- }
-
- @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 (JSONException 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 (JSONException expected) {
- System.out.println(expected);
- }
- }
-
- // FIXME DUBBO-63
- @Ignore
- @Test
- public void test_URL_mutable_withType() throws Exception {
- }
-
- @Ignore
- @Test(timeout = 3000)
- public void test_LoopReference() throws Exception {
- }
-
- // ========== Person
-
- @Ignore("person type missing")
- @Test
- public void test_Person() throws Exception {
- }
-
- @Ignore("person type missing")
- @Test
- public void test_PersonList() throws Exception {
- }
-
- @Ignore("person type missing")
- @Test
- public void test_PersonSet() throws Exception {
- }
-
- @Ignore("FastJson bug: com.alibaba.fastjson.JSONException: illegal identifier : 1")
- @Test
- public void test_IntPersonMap() throws Exception {
- }
-
- @Ignore("person type missing")
- @Test
- public void test_StringPersonMap() throws Exception {
- }
-
- @Ignore("person type missing")
- @Test
- public void test_StringPersonListMap() throws Exception {
- }
-
- @Ignore("person type missing")
- @Test
- public void test_PersonListList() throws Exception {
- }
-
-}
\ No newline at end of file
diff --git a/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.extensionloader.activate.ActivateExt1 b/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.extensionloader.activate.ActivateExt1
deleted file mode 100644
index 8ff8934..0000000
--- a/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.extensionloader.activate.ActivateExt1
+++ /dev/null
@@ -1,4 +0,0 @@
-group=com.alibaba.dubbo.common.extensionloader.activate.impl.GroupActivateExtImpl
-value=com.alibaba.dubbo.common.extensionloader.activate.impl.ValueActivateExtImpl
-order1=com.alibaba.dubbo.common.extensionloader.activate.impl.OrderActivateExtImpl1
-order2=com.alibaba.dubbo.common.extensionloader.activate.impl.OrderActivateExtImpl2
\ No newline at end of file
diff --git a/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.extensionloader.adaptive.HasAdaptiveExt b/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.extensionloader.adaptive.HasAdaptiveExt
deleted file mode 100644
index c700dbd..0000000
--- a/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.extensionloader.adaptive.HasAdaptiveExt
+++ /dev/null
@@ -1,2 +0,0 @@
-adaptive=com.alibaba.dubbo.common.extensionloader.adaptive.impl.HasAdaptiveExt_ManualAdaptive
-impl1=com.alibaba.dubbo.common.extensionloader.adaptive.impl.HasAdaptiveExtImpl1
\ No newline at end of file
diff --git a/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.extensionloader.compatible.CompatibleExt b/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.extensionloader.compatible.CompatibleExt
deleted file mode 100644
index 9f176b7..0000000
--- a/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.extensionloader.compatible.CompatibleExt
+++ /dev/null
@@ -1,2 +0,0 @@
-com.alibaba.dubbo.common.extensionloader.compatible.impl.CompatibleExtImpl1
-impl2=com.alibaba.dubbo.common.extensionloader.compatible.impl.CompatibleExtImpl2
\ No newline at end of file
diff --git a/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.extensionloader.ext1.SimpleExt b/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.extensionloader.ext1.SimpleExt
deleted file mode 100644
index f91b958..0000000
--- a/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.extensionloader.ext1.SimpleExt
+++ /dev/null
@@ -1,4 +0,0 @@
-# Comment 1
-impl1=com.alibaba.dubbo.common.extensionloader.ext1.impl.SimpleExtImpl1#Hello World
-impl2=com.alibaba.dubbo.common.extensionloader.ext1.impl.SimpleExtImpl2 # Comment 2
- impl3=com.alibaba.dubbo.common.extensionloader.ext1.impl.SimpleExtImpl3 # with head space
\ No newline at end of file
diff --git a/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.extensionloader.ext2.Ext2 b/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.extensionloader.ext2.Ext2
deleted file mode 100644
index 37bb715..0000000
--- a/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.extensionloader.ext2.Ext2
+++ /dev/null
@@ -1,3 +0,0 @@
-impl1=com.alibaba.dubbo.common.extensionloader.ext2.impl.Ext2Impl1
-impl2=com.alibaba.dubbo.common.extensionloader.ext2.impl.Ext2Impl2
-impl3=com.alibaba.dubbo.common.extensionloader.ext2.impl.Ext2Impl3
\ No newline at end of file
diff --git a/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.extensionloader.ext3.UseProtocolKeyExt b/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.extensionloader.ext3.UseProtocolKeyExt
deleted file mode 100644
index 08dc3d7..0000000
--- a/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.extensionloader.ext3.UseProtocolKeyExt
+++ /dev/null
@@ -1,3 +0,0 @@
-impl1=com.alibaba.dubbo.common.extensionloader.ext3.impl.UseProtocolKeyExtImpl1
-impl2=com.alibaba.dubbo.common.extensionloader.ext3.impl.UseProtocolKeyExtImpl2
-impl3=com.alibaba.dubbo.common.extensionloader.ext3.impl.UseProtocolKeyExtImpl3
\ No newline at end of file
diff --git a/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.extensionloader.ext4.NoUrlParamExt b/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.extensionloader.ext4.NoUrlParamExt
deleted file mode 100644
index 97aa383..0000000
--- a/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.extensionloader.ext4.NoUrlParamExt
+++ /dev/null
@@ -1,2 +0,0 @@
-impl1=com.alibaba.dubbo.common.extensionloader.ext4.impl.Ext4Impl1
-impl2=com.alibaba.dubbo.common.extensionloader.ext4.impl.Ext4Impl2
\ No newline at end of file
diff --git a/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.extensionloader.ext5.NoAdaptiveMethodExt b/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.extensionloader.ext5.NoAdaptiveMethodExt
deleted file mode 100644
index a416f9d..0000000
--- a/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.extensionloader.ext5.NoAdaptiveMethodExt
+++ /dev/null
@@ -1,2 +0,0 @@
-impl1=com.alibaba.dubbo.common.extensionloader.ext5.impl.Ext5Impl1
-impl2=com.alibaba.dubbo.common.extensionloader.ext5.impl.Ext5Impl2
diff --git a/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.extensionloader.ext6_inject.Ext6 b/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.extensionloader.ext6_inject.Ext6
deleted file mode 100644
index 833274f..0000000
--- a/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.extensionloader.ext6_inject.Ext6
+++ /dev/null
@@ -1,2 +0,0 @@
-impl1=com.alibaba.dubbo.common.extensionloader.ext6_inject.impl.Ext6Impl1
-impl2=com.alibaba.dubbo.common.extensionloader.ext6_inject.impl.Ext6Impl2
\ No newline at end of file
diff --git a/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.extensionloader.ext6_wrap.WrappedExt b/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.extensionloader.ext6_wrap.WrappedExt
deleted file mode 100644
index e0897cd..0000000
--- a/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.extensionloader.ext6_wrap.WrappedExt
+++ /dev/null
@@ -1,4 +0,0 @@
-impl1=com.alibaba.dubbo.common.extensionloader.ext6_wrap.impl.Ext5Impl1
-impl2=com.alibaba.dubbo.common.extensionloader.ext6_wrap.impl.Ext5Impl2
-wrapper1=com.alibaba.dubbo.common.extensionloader.ext6_wrap.impl.Ext5Wrapper1
-wrapper2=com.alibaba.dubbo.common.extensionloader.ext6_wrap.impl.Ext5Wrapper2
\ No newline at end of file
diff --git a/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.extensionloader.ext7.InitErrorExt b/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.extensionloader.ext7.InitErrorExt
deleted file mode 100644
index 549094e..0000000
--- a/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.extensionloader.ext7.InitErrorExt
+++ /dev/null
@@ -1,2 +0,0 @@
-error=com.alibaba.dubbo.common.extensionloader.ext7.impl.Ext7InitErrorImpl
-ok=com.alibaba.dubbo.common.extensionloader.ext7.impl.Ext7Impl
diff --git a/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.extensionloader.ext8_add.AddExt1 b/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.extensionloader.ext8_add.AddExt1
deleted file mode 100644
index 02ee0c0..0000000
--- a/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.extensionloader.ext8_add.AddExt1
+++ /dev/null
@@ -1 +0,0 @@
-impl1=com.alibaba.dubbo.common.extensionloader.ext8_add.impl.AddExt1Impl1
\ No newline at end of file
diff --git a/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.status.StatusChecker b/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.status.StatusChecker
deleted file mode 100644
index 82d8158..0000000
--- a/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.status.StatusChecker
+++ /dev/null
@@ -1 +0,0 @@
-aa=12
\ No newline at end of file
diff --git a/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/services/com.alibaba.dubbo.common.extensionloader.activate.ActivateExt1 b/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/services/com.alibaba.dubbo.common.extensionloader.activate.ActivateExt1
deleted file mode 100644
index 2e16c11..0000000
--- a/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/META-INF/services/com.alibaba.dubbo.common.extensionloader.activate.ActivateExt1
+++ /dev/null
@@ -1 +0,0 @@
-com.alibaba.dubbo.common.extensionloader.activate.impl.ActivateExt1Impl1
\ No newline at end of file
diff --git a/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/StreamUtilsTest.txt b/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/StreamUtilsTest.txt
deleted file mode 100644
index ad47100..0000000
--- a/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/StreamUtilsTest.txt
+++ /dev/null
@@ -1 +0,0 @@
-0123456789
\ No newline at end of file
diff --git a/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/com/alibaba/dubbo/common/serialize/dubbo/SimpleDO.fc b/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/com/alibaba/dubbo/common/serialize/dubbo/SimpleDO.fc
deleted file mode 100644
index c8c083c..0000000
--- a/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/com/alibaba/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-fastjson/src/test/resources/json.flex b/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/json.flex
deleted file mode 100644
index c6d4015..0000000
--- a/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/json.flex
+++ /dev/null
@@ -1,68 +0,0 @@
-package com.alibaba.dubbo.common.json;
-%%
-
-%{
-private StringBuffer sb;
-%}
-
-%table
-%unicode
-%state STR1,STR2
-
-%yylexthrow ParseException
-
-HEX = [a-fA-F0-9]
-HEX4 = {HEX}{HEX}{HEX}{HEX}
-
-IDENT = [a-zA-Z_$] [a-zA-Z0-9_$]*
-INT_LITERAL = [-]? [0-9]+
-FLOAT_LITERAL = {INT_LITERAL} ( ( \.[0-9]+ ) ? ( [eE][-+]? [0-9]+ )? )
-
-ESC1 = [^\"\\]
-ESC2 = [^\'\\]
-
-SKIP = [ \t\r\n]
-OTHERS = .
-%%
-
-<STR1>{
- \" { yybegin(YYINITIAL); return new JSONToken(JSONToken.STRING, sb.toString()); }
- {ESC1}+ { sb.append(yytext()); }
- \\\" { sb.append('"'); }
-}
-
-<STR2>{
- \' { yybegin(YYINITIAL); return new JSONToken(JSONToken.STRING, sb.toString()); }
- {ESC2}+ { sb.append(yytext()); }
- \\\' { sb.append('\''); }
-}
-
-<STR1,STR2>{
- \\\\ { sb.append('\\'); }
- \\\/ { sb.append('/'); }
- \\b { sb.append('\b'); }
- \\f { sb.append('\f'); }
- \\n { sb.append('\n'); }
- \\r { sb.append('\r'); }
- \\t { sb.append('\t'); }
- \\u{HEX4} { try{ sb.append((char)Integer.parseInt(yytext().substring(2),16)); }catch(Exception e){ throw new ParseException(e.getMessage()); } }
-}
-
-<YYINITIAL>{
- \" { sb = new StringBuffer(); yybegin(STR1); }
- \' { sb = new StringBuffer(); yybegin(STR2); }
- {INT_LITERAL} { Long val = Long.valueOf(yytext()); return new JSONToken(JSONToken.INT, val); }
- {FLOAT_LITERAL} { Double val = Double.valueOf(yytext()); return new JSONToken(JSONToken.FLOAT, val); }
- "true"|"TRUE" { return new JSONToken(JSONToken.BOOL, Boolean.TRUE); }
- "false"|"FALSE" { return new JSONToken(JSONToken.BOOL, Boolean.FALSE); }
- "null"|"NULL" { return new JSONToken(JSONToken.NULL, null); }
- {IDENT} { return new JSONToken(JSONToken.IDENT, yytext()); }
- "{" { return new JSONToken(JSONToken.LBRACE); }
- "}" { return new JSONToken(JSONToken.RBRACE); }
- "[" { return new JSONToken(JSONToken.LSQUARE); }
- "]" { return new JSONToken(JSONToken.RSQUARE); }
- "," { return new JSONToken(JSONToken.COMMA); }
- ":" { return new JSONToken(JSONToken.COLON); }
- {SKIP}+ {}
- {OTHERS} { throw new ParseException("Unexpected char [" + yytext() +"]"); }
-}
diff --git a/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/properties.load b/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/properties.load
deleted file mode 100644
index 43bf492..0000000
--- a/dubbo-serialization/dubbo-serialization-fastjson/src/test/resources/properties.load
+++ /dev/null
@@ -1,3 +0,0 @@
-a=12
-b=34
-c=56
\ No newline at end of file
diff --git a/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/model/BizExceptionNoDefaultConstructor.java b/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/model/BizExceptionNoDefaultConstructor.java
deleted file mode 100644
index 29db6e0..0000000
--- a/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/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 com.alibaba.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-fst/src/test/java/com/alibaba/dubbo/common/model/Person.java b/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/model/Person.java
deleted file mode 100644
index 6383706..0000000
--- a/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/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 com.alibaba.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-fst/src/test/java/com/alibaba/dubbo/common/model/SerializablePerson.java b/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/model/SerializablePerson.java
deleted file mode 100644
index e7dd248..0000000
--- a/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/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 com.alibaba.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-fst/src/test/java/com/alibaba/dubbo/common/model/media/Media.java b/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/model/media/Media.java
deleted file mode 100644
index 8a78f6d..0000000
--- a/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/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 com.alibaba.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<String> 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<String> 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<String> getPersons() {
- return persons;
- }
-
- public void setPersons(List<String> 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-fst/src/test/java/com/alibaba/dubbo/common/model/media/MediaContent.java b/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/model/media/MediaContent.java
deleted file mode 100644
index 9664116..0000000
--- a/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/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 com.alibaba.dubbo.common.model.media;
-
-import java.util.List;
-
-@SuppressWarnings("serial")
-public class MediaContent implements java.io.Serializable {
- public Media media;
- public List<Image> images;
-
- public MediaContent() {
- }
-
- public MediaContent(Media media, List<Image> 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<Image> getImages() {
- return images;
- }
-
- public void setImages(List<Image> images) {
- this.images = images;
- }
-}
\ No newline at end of file
diff --git a/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/model/person/BigPerson.java b/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/model/person/BigPerson.java
deleted file mode 100644
index 70bc793..0000000
--- a/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/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 com.alibaba.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-fst/src/test/java/com/alibaba/dubbo/common/model/person/FullAddress.java b/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/model/person/FullAddress.java
deleted file mode 100644
index dcc93cf..0000000
--- a/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/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 com.alibaba.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-fst/src/test/java/com/alibaba/dubbo/common/model/person/PersonInfo.java b/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/model/person/PersonInfo.java
deleted file mode 100644
index f1ff041..0000000
--- a/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/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 com.alibaba.dubbo.common.model.person;
-
-import java.io.Serializable;
-import java.util.List;
-
-public class PersonInfo implements Serializable {
- private static final long serialVersionUID = 7443011149612231882L;
-
- List<Phone> phones;
-
- Phone fax;
-
- FullAddress fullAddress;
-
- String mobileNo;
-
- String name;
-
- boolean male;
-
- boolean female;
-
- String department;
-
- String jobTitle;
-
- String homepageUrl;
-
- public List<Phone> getPhones() {
- return phones;
- }
-
- public void setPhones(List<Phone> 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-fst/src/test/java/com/alibaba/dubbo/common/model/person/PersonStatus.java b/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/model/person/PersonStatus.java
deleted file mode 100644
index 66b67c9..0000000
--- a/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/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 com.alibaba.dubbo.common.model.person;
-
-public enum PersonStatus {
- ENABLED,
- DISABLED
-}
\ No newline at end of file
diff --git a/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/model/person/Phone.java b/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/model/person/Phone.java
deleted file mode 100644
index f7da708..0000000
--- a/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/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 com.alibaba.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-fst/src/test/java/com/alibaba/dubbo/common/model/BizException.java b/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/serialize/fst/FstFactoryTest.java
similarity index 67%
rename from dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/model/BizException.java
rename to dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/serialize/fst/FstFactoryTest.java
index b6eb1f4..4541a18 100644
--- a/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/model/BizException.java
+++ b/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/serialize/fst/FstFactoryTest.java
@@ -14,16 +14,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.alibaba.dubbo.common.model;
+package com.alibaba.dubbo.common.serialize.fst;
-public class BizException extends RuntimeException {
+import org.junit.Test;
- private static final long serialVersionUID = 1L;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.assertThat;
- public BizException(String message) {
- super(message);
- }
+public class FstFactoryTest {
+ @Test
+ public void testDefaultFactory() {
+ FstFactory factory = FstFactory.getDefaultFactory();
- public BizException() {
+ assertThat(factory, not(nullValue()));
}
}
\ No newline at end of file
diff --git a/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/serialize/fst/FstObjectInputTest.java b/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/serialize/fst/FstObjectInputTest.java
new file mode 100644
index 0000000..96332a7
--- /dev/null
+++ b/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/serialize/fst/FstObjectInputTest.java
@@ -0,0 +1,48 @@
+/*
+ * 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 com.alibaba.dubbo.common.serialize.fst;
+
+import com.alibaba.dubbo.common.serialize.fst.model.AnimalEnum;
+import com.alibaba.dubbo.common.serialize.fst.model.FullAddress;
+import org.junit.Test;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.*;
+
+public class FstObjectInputTest {
+ private FstObjectInput fstObjectInput;
+
+ @Test(expected = IOException.class)
+ public void testWrongClassInput() throws IOException, ClassNotFoundException {
+ this.fstObjectInput = new FstObjectInput(new ByteArrayInputStream("{animal: 'cat'}".getBytes()));
+
+ fstObjectInput.readObject(FullAddress.class);
+ }
+
+ @Test
+ public void testEmptyByteArrayForEmptyInput() throws IOException {
+ this.fstObjectInput = new FstObjectInput(new ByteArrayInputStream("".getBytes()));
+
+ byte[] bytes = fstObjectInput.readBytes();
+ assertThat(bytes.length, is(0));
+ }
+
+
+}
\ No newline at end of file
diff --git a/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/serialize/fst/FstObjectOutputTest.java b/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/serialize/fst/FstObjectOutputTest.java
new file mode 100644
index 0000000..88afe23
--- /dev/null
+++ b/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/serialize/fst/FstObjectOutputTest.java
@@ -0,0 +1,180 @@
+/*
+ * 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 com.alibaba.dubbo.common.serialize.fst;
+
+import com.alibaba.dubbo.common.serialize.fst.model.AnimalEnum;
+import com.alibaba.dubbo.common.serialize.fst.model.FullAddress;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.*;
+
+public class FstObjectOutputTest {
+ private FstObjectOutput fstObjectOutput;
+ private FstObjectInput fstObjectInput;
+ private ByteArrayOutputStream byteArrayOutputStream;
+ private ByteArrayInputStream byteArrayInputStream;
+
+ @Before
+ public void setUp() {
+ this.byteArrayOutputStream = new ByteArrayOutputStream();
+ this.fstObjectOutput = new FstObjectOutput(byteArrayOutputStream);
+ }
+
+
+ @Test
+ public void testWriteBool() throws IOException {
+ this.fstObjectOutput.writeBool(false);
+ this.flushToInput();
+
+ boolean result = this.fstObjectInput.readBool();
+ assertThat(result, is(false));
+ }
+
+
+ @Test
+ public void testWriteUTF() throws IOException {
+ this.fstObjectOutput.writeUTF("I don’t know 知りません Не знаю");
+ this.flushToInput();
+
+ String result = this.fstObjectInput.readUTF();
+ assertThat(result, is("I don’t know 知りません Не знаю"));
+ }
+
+ @Test
+ public void testWriteShort() throws IOException {
+ this.fstObjectOutput.writeShort((short) 1);
+ this.flushToInput();
+
+ Short result = this.fstObjectInput.readShort();
+ assertThat(result, is((short) 1));
+ }
+
+ @Test
+ public void testWriteLong() throws IOException {
+ this.fstObjectOutput.writeLong(12345678L);
+ this.flushToInput();
+
+ Long result = this.fstObjectInput.readLong();
+ assertThat(result, is(12345678L));
+ }
+
+ @Test
+ public void testWriteDouble() throws IOException {
+ this.fstObjectOutput.writeDouble(-1.66d);
+ this.flushToInput();
+
+ Double result = this.fstObjectInput.readDouble();
+ assertThat(result, is(-1.66d));
+ }
+
+
+ @Test
+ public void testWriteInt() throws IOException {
+ this.fstObjectOutput.writeInt(1);
+ this.flushToInput();
+
+ Integer result = this.fstObjectInput.readInt();
+ assertThat(result, is(1));
+ }
+
+ @Test
+ public void testWriteByte() throws IOException {
+ this.fstObjectOutput.writeByte((byte) 222);
+ this.flushToInput();
+
+ Byte result = this.fstObjectInput.readByte();
+ assertThat(result, is(((byte) 222)));
+ }
+
+ @Test
+ public void testWriteBytesWithSubLength() throws IOException {
+ this.fstObjectOutput.writeBytes("who are you".getBytes(), 4, 3);
+ this.flushToInput();
+
+ byte[] result = this.fstObjectInput.readBytes();
+ assertThat(result, is("are".getBytes()));
+ }
+
+ @Test
+ public void testWriteBytes() throws IOException {
+ this.fstObjectOutput.writeBytes("who are you".getBytes());
+ this.flushToInput();
+
+ byte[] result = this.fstObjectInput.readBytes();
+ assertThat(result, is("who are you".getBytes()));
+ }
+
+ @Test
+ public void testWriteFloat() throws IOException {
+ this.fstObjectOutput.writeFloat(-666.66f);
+ this.flushToInput();
+
+ Float result = this.fstObjectInput.readFloat();
+ assertThat(result, is(-666.66f));
+ }
+
+ @Test
+ public void testWriteNullBytesWithSubLength() throws IOException {
+ this.fstObjectOutput.writeBytes(null, 4, 3);
+ this.flushToInput();
+
+ byte[] result = this.fstObjectInput.readBytes();
+ assertThat(result, is(nullValue()));
+ }
+
+ @Test
+ public void testWriteNullBytes() throws IOException {
+ this.fstObjectOutput.writeBytes(null);
+ this.flushToInput();
+
+ byte[] result = this.fstObjectInput.readBytes();
+ assertThat(result, is(nullValue()));
+ }
+
+
+ @Test
+ public void testWriteObject() throws IOException, ClassNotFoundException {
+ FullAddress fullAddress = new FullAddress("cId", "pN", "cityId", "Nan Long Street", "51000");
+ this.fstObjectOutput.writeObject(fullAddress);
+ this.flushToInput();
+
+ FullAddress result = this.fstObjectInput.readObject(FullAddress.class);
+ assertThat(result, is(fullAddress));
+ }
+
+ @Test
+ public void testWriteEnum() throws IOException, ClassNotFoundException {
+ this.fstObjectOutput.writeObject(AnimalEnum.cat);
+ this.flushToInput();
+
+ AnimalEnum animalEnum = (AnimalEnum) this.fstObjectInput.readObject();
+ assertThat(animalEnum, is(AnimalEnum.cat));
+ }
+
+ private void flushToInput() throws IOException {
+ this.fstObjectOutput.flushBuffer();
+ this.byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
+ this.fstObjectInput = new FstObjectInput(byteArrayInputStream);
+ }
+}
\ No newline at end of file
diff --git a/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/serialize/fst/FstSerializationTest.java b/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/serialize/fst/FstSerializationTest.java
new file mode 100644
index 0000000..63e1aa1
--- /dev/null
+++ b/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/serialize/fst/FstSerializationTest.java
@@ -0,0 +1,62 @@
+/*
+ * 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 com.alibaba.dubbo.common.serialize.fst;
+
+import com.alibaba.dubbo.common.serialize.ObjectInput;
+import com.alibaba.dubbo.common.serialize.ObjectOutput;
+import org.hamcrest.Matchers;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.mockito.Mockito.mock;
+
+public class FstSerializationTest {
+ private FstSerialization fstSerialization;
+
+ @Before
+ public void setUp() {
+ this.fstSerialization = new FstSerialization();
+ }
+
+ @Test
+ public void testContentTypeId() {
+ assertThat(fstSerialization.getContentTypeId(), is((byte) 9));
+ }
+
+ @Test
+ public void testContentType() {
+ assertThat(fstSerialization.getContentType(), is("x-application/fst"));
+ }
+
+ @Test
+ public void testSerialize() throws IOException {
+ ObjectOutput objectOutput = fstSerialization.serialize(null, mock(OutputStream.class));
+ assertThat(objectOutput, Matchers.<ObjectOutput>instanceOf(FstObjectOutput.class));
+ }
+
+ @Test
+ public void testDeserialize() throws IOException {
+ ObjectInput objectInput = fstSerialization.deserialize(null, mock(InputStream.class));
+ assertThat(objectInput, Matchers.<ObjectInput>instanceOf(FstObjectInput.class));
+ }
+}
\ No newline at end of file
diff --git a/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/model/AnimalEnum.java b/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/serialize/fst/model/AnimalEnum.java
similarity index 94%
rename from dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/model/AnimalEnum.java
rename to dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/serialize/fst/model/AnimalEnum.java
index f920a0c..c979df6 100644
--- a/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/model/AnimalEnum.java
+++ b/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/serialize/fst/model/AnimalEnum.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.alibaba.dubbo.common.model;
+package com.alibaba.dubbo.common.serialize.fst.model;
public enum AnimalEnum {
dog, cat, rat, cow, bull, horse;
diff --git a/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/model/person/FullAddress.java b/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/serialize/fst/model/FullAddress.java
similarity index 98%
rename from dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/model/person/FullAddress.java
rename to dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/serialize/fst/model/FullAddress.java
index dcc93cf..44d21a6 100644
--- a/dubbo-serialization/dubbo-serialization-fastjson/src/test/java/com/alibaba/dubbo/common/model/person/FullAddress.java
+++ b/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/serialize/fst/model/FullAddress.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.alibaba.dubbo.common.model.person;
+package com.alibaba.dubbo.common.serialize.fst.model;
import java.io.Serializable;
@@ -36,9 +36,6 @@ public class FullAddress implements Serializable {
private String zipCode;
- public FullAddress() {
- }
-
public FullAddress(String countryId, String provinceName, String cityId, String streetAddress,
String zipCode) {
this.countryId = countryId;
diff --git a/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/serialize/serialization/FstSerializationTest.java b/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/serialize/serialization/FstSerializationTest.java
deleted file mode 100644
index 5f6427d..0000000
--- a/dubbo-serialization/dubbo-serialization-fst/src/test/java/com/alibaba/dubbo/common/serialize/serialization/FstSerializationTest.java
+++ /dev/null
@@ -1,1124 +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 com.alibaba.dubbo.common.serialize.serialization;
-
-import com.alibaba.dubbo.common.URL;
-import com.alibaba.dubbo.common.model.AnimalEnum;
-import com.alibaba.dubbo.common.model.BizException;
-import com.alibaba.dubbo.common.model.BizExceptionNoDefaultConstructor;
-import com.alibaba.dubbo.common.model.SerializablePerson;
-import com.alibaba.dubbo.common.model.media.Image;
-import com.alibaba.dubbo.common.model.media.Media;
-import com.alibaba.dubbo.common.model.media.MediaContent;
-import com.alibaba.dubbo.common.model.person.BigPerson;
-import com.alibaba.dubbo.common.model.person.FullAddress;
-import com.alibaba.dubbo.common.model.person.PersonInfo;
-import com.alibaba.dubbo.common.model.person.PersonStatus;
-import com.alibaba.dubbo.common.model.person.Phone;
-import com.alibaba.dubbo.common.serialize.ObjectInput;
-import com.alibaba.dubbo.common.serialize.ObjectOutput;
-import com.alibaba.dubbo.common.serialize.Serialization;
-import com.alibaba.dubbo.common.serialize.fst.FstSerialization;
-
-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 class FstSerializationTest {
-
- static Random random = new Random();
- Serialization serialization = new FstSerialization();
- URL url = new URL("protocl", "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<Phone> phones = new ArrayList<Phone>();
- 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<String> persons = new ArrayList<String>();
- persons.add("jerry");
- persons.add("tom");
- persons.add("lucy");
- media.setPersons(persons);
- media.setCopyright("1999-2011");
- media.setPlayer(Media.Player.FLASH);
-
- List<Image> images = new ArrayList<Image>();
- 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) ? Image.Size.SMALL : Image.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());
- }
-
- @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());
- }
- }
-
- @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());
- }
-
- @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());
- }
- }
-
- @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 {
- assertEquals(0, deserialize.readInt());
- } 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());
- }
-
- @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());
- }
-
- // ================== 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());
-
- }
-
- @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());
- }
-
- @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());
-
- }
-
- @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());
-
- }
-
- // ================ Array Type ================
-
- <T> void assertObjectArray(T[] data, Class<T[]> 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()));
- }
-
- <T> void assertObjectArrayWithType(T[] data, Class<T[]> 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)));
- }
-
- @SuppressWarnings("unchecked")
- <T> 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());
-
- }
-
- <T> void assertObjectWithType(T data, Class<T> 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));
-
- }
-
- @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());
- }
-
- @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<String> args = Arrays.asList(new String[]{"1", "b"});
-
- assertObject(args);
- }
-
- @Test
- public void test_StringArrayList() throws Exception {
- List<String> args = new ArrayList<String>(Arrays.asList(new String[]{"1", "b"}));
-
- assertObject(args);
- }
-
- @Test
- public void test_StringSet() throws Exception {
- Set<String> args = new HashSet<String>();
- args.add("1");
-
- assertObject(args);
- }
-
- @Test
- public void test_LinkedHashMap() throws Exception {
- LinkedHashMap<String, String> data = new LinkedHashMap<String, String>();
- 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<String, String>) 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<SerializablePerson> args = new ArrayList<SerializablePerson>();
- args.add(new SerializablePerson());
-
- assertObject(args);
- }
-
- @Test
- public void test_SPersonSet() throws Exception {
- Set<SerializablePerson> args = new HashSet<SerializablePerson>();
- args.add(new SerializablePerson());
-
- assertObject(args);
- }
-
- // ================ complex POJO =============
-
- @Test
- public void test_IntSPersonMap() throws Exception {
- Map<Integer, SerializablePerson> args = new HashMap<Integer, SerializablePerson>();
- args.put(1, new SerializablePerson());
-
- assertObject(args);
- }
-
- @Test
- public void test_StringSPersonMap() throws Exception {
- Map<String, SerializablePerson> args = new HashMap<String, SerializablePerson>();
- args.put("1", new SerializablePerson());
-
- assertObject(args);
- }
-
- @Test
- public void test_StringSPersonListMap() throws Exception {
- Map<String, List<SerializablePerson>> args = new HashMap<String, List<SerializablePerson>>();
-
- List<SerializablePerson> sublist = new ArrayList<SerializablePerson>();
- sublist.add(new SerializablePerson());
- args.put("1", sublist);
-
- assertObject(args);
- }
-
- @Test
- public void test_SPersonListList() throws Exception {
- List<List<SerializablePerson>> args = new ArrayList<List<SerializablePerson>>();
- List<SerializablePerson> sublist = new ArrayList<SerializablePerson>();
- 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();
- assertEquals(null, read);
- } 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);
- assertEquals(null, read);
- } catch (IOException expected) {
- System.out.println(expected);
- }
- }
-
-
- @Test(timeout = 3000)
- public void test_LoopReference() throws Exception {
- Map<String, Object> map = new HashMap<String, Object>();
- 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<String, Object> output = (Map<String, Object>) 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) {
- }
- }
-}
diff --git a/pom.xml b/pom.xml
index e3f0242..2b2d371 100644
--- a/pom.xml
+++ b/pom.xml
@@ -89,6 +89,7 @@
<properties>
<!-- Test libs -->
<junit_version>4.12</junit_version>
+ <hamcrest_version>1.3</hamcrest_version>
<cglib_version>2.2</cglib_version>
<mockito_version>2.18.3</mockito_version>
<!-- Build args -->
@@ -156,6 +157,12 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-all</artifactId>
+ <version>${hamcrest_version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito_version}</version>
--
To stop receiving notification emails like this one, please contact
iluo@apache.org.