1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.mina.codec.delimited.serialization;
21
22 import java.io.Serializable;
23 import java.util.LinkedList;
24 import java.util.List;
25
26 import org.apache.mina.codec.delimited.IoBufferDecoder;
27 import org.apache.mina.codec.delimited.ByteBufferEncoder;
28
29
30
31
32
33
34 public class JavaNativeTest extends GenericSerializerTest<JavaNativeTest.TestBean> {
35 static public class TestBean implements Serializable {
36 private static final long serialVersionUID = 1L;
37
38 @Override
39 public int hashCode() {
40 final int prime = 31;
41 int result = 1;
42 result = prime * result + ((a == null) ? 0 : a.hashCode());
43 result = prime * result + b;
44 long temp;
45 temp = Double.doubleToLongBits(c);
46 result = prime * result + (int) (temp ^ (temp >>> 32));
47 return result;
48 }
49
50 @Override
51 public boolean equals(Object obj) {
52 if (this == obj) {
53 return true;
54 }
55 if (obj == null) {
56 return false;
57 }
58 if (getClass() != obj.getClass()) {
59 return false;
60 }
61 TestBean other = (TestBean) obj;
62 if (a == null) {
63 if (other.a != null) {
64 return false;
65 }
66 } else if (!a.equals(other.a)) {
67 return false;
68 }
69 if (b != other.b) {
70 return false;
71 }
72 if (Double.doubleToLongBits(c) != Double.doubleToLongBits(other.c)) {
73 return false;
74 }
75 return true;
76 }
77
78 public TestBean(String a, int b, double c) {
79 super();
80 this.a = a;
81 this.b = b;
82 this.c = c;
83 }
84
85 private final String a;
86
87 private final int b;
88
89 private final double c;
90 }
91
92 @Override
93 public List<TestBean> getObjects() {
94 List<TestBean> list = new LinkedList<TestBean>();
95 list.add(new TestBean("Hello", 86, 12.34));
96 list.add(new TestBean("MINA", 94, 67.89));
97 return list;
98 }
99
100 @Override
101 public IoBufferDecoder<TestBean> getDecoder() throws Exception {
102 return new JavaNativeMessageDecoder<TestBean>();
103 }
104
105 @Override
106 public ByteBufferEncoder<TestBean> getEncoder() throws Exception {
107 return new JavaNativeMessageEncoder<TestBean>();
108 }
109
110 }