author | sundar |
Mon, 16 May 2016 14:50:43 +0530 | |
changeset 37951 | ce2744a0f1a7 |
parent 27490 | 271c130f59b7 |
permissions | -rw-r--r-- |
24497
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
1 |
/* |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
2 |
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
4 |
* |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
8 |
* |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
13 |
* accompanied this code). |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
14 |
* |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
18 |
* |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
21 |
* questions. |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
22 |
*/ |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
23 |
package util; |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
24 |
|
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
25 |
import java.io.Serializable; |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
26 |
import java.sql.SQLData; |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
27 |
import java.sql.SQLException; |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
28 |
import java.sql.SQLInput; |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
29 |
import java.sql.SQLOutput; |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
30 |
|
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
31 |
public class SuperHero implements SQLData, Serializable { |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
32 |
|
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
33 |
private String first; |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
34 |
private String last; |
27490
271c130f59b7
8064356: Add BaseRowSet, SQLInputImpl, and SQLOutputImpl tests
lancea
parents:
24497
diff
changeset
|
35 |
private String type = "SUPERHERO"; |
24497
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
36 |
private Integer firstYear; |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
37 |
private String secretIdentity; |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
38 |
|
27490
271c130f59b7
8064356: Add BaseRowSet, SQLInputImpl, and SQLOutputImpl tests
lancea
parents:
24497
diff
changeset
|
39 |
public SuperHero() { |
271c130f59b7
8064356: Add BaseRowSet, SQLInputImpl, and SQLOutputImpl tests
lancea
parents:
24497
diff
changeset
|
40 |
|
271c130f59b7
8064356: Add BaseRowSet, SQLInputImpl, and SQLOutputImpl tests
lancea
parents:
24497
diff
changeset
|
41 |
} |
271c130f59b7
8064356: Add BaseRowSet, SQLInputImpl, and SQLOutputImpl tests
lancea
parents:
24497
diff
changeset
|
42 |
|
24497
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
43 |
public SuperHero(String sqlType, String fname, String lname, Integer year, |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
44 |
String identity) { |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
45 |
first = fname; |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
46 |
last = lname; |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
47 |
type = sqlType; |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
48 |
firstYear = year; |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
49 |
secretIdentity = identity; |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
50 |
} |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
51 |
|
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
52 |
@Override |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
53 |
public String getSQLTypeName() throws SQLException { |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
54 |
return type; |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
55 |
} |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
56 |
|
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
57 |
@Override |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
58 |
public void readSQL(SQLInput stream, String typeName) throws SQLException { |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
59 |
first = stream.readString(); |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
60 |
last = stream.readString(); |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
61 |
firstYear = stream.readInt(); |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
62 |
secretIdentity = stream.readString(); |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
63 |
} |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
64 |
|
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
65 |
@Override |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
66 |
public void writeSQL(SQLOutput stream) throws SQLException { |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
67 |
stream.writeString(first); |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
68 |
stream.writeString(last); |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
69 |
stream.writeInt(firstYear); |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
70 |
stream.writeString(secretIdentity); |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
71 |
} |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
72 |
|
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
73 |
@Override |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
74 |
public String toString() { |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
75 |
return "[ name =" + first + " " + last + " " |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
76 |
+ firstYear + " " + secretIdentity + " ]"; |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
77 |
} |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
78 |
|
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
79 |
public void setIdentity(String identity) { |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
80 |
secretIdentity = identity; |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
81 |
} |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
82 |
|
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
83 |
public String getIdentity() { |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
84 |
return secretIdentity; |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
85 |
} |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
86 |
|
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
87 |
@Override |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
88 |
public boolean equals(Object obj) { |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
89 |
if (this == obj) { |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
90 |
return true; |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
91 |
} |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
92 |
if (obj instanceof SuperHero) { |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
93 |
SuperHero ss = (SuperHero) obj; |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
94 |
return first.equals(ss.first) && last.equals(ss.last) |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
95 |
&& firstYear.equals(ss.firstYear) |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
96 |
&& type.equals(ss.type) |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
97 |
&& secretIdentity.equals(ss.secretIdentity); |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
98 |
} |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
99 |
return false; |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
100 |
} |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
101 |
|
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
102 |
@Override |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
103 |
public int hashCode() { |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
104 |
return ((31 + first.hashCode()) * 31) * 31 |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
105 |
+ ((31 + last.hashCode()) * 31) * 31 |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
106 |
+ ((31 + firstYear.hashCode()) * 31) * 31 |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
107 |
+ ((31 + type.hashCode()) * 31) * 31 |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
108 |
+ secretIdentity.hashCode(); |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
109 |
} |
d51dff0b4aaf
8043278: Add initial unit tests for javax.sql.rowset.serial
lancea
parents:
diff
changeset
|
110 |
} |