1
0
Fork 0
mirror of https://github.com/ethauvin/JSON-java.git synced 2025-06-17 16:00:51 -07:00

Adds new tests for testing bean->JSONObject mapping

This commit is contained in:
John J. Aylward 2017-07-09 17:35:46 -04:00
parent 0e3f23d7a1
commit 49117f33dc
6 changed files with 356 additions and 0 deletions

View file

@ -0,0 +1,81 @@
package org.json.junit.data;
/**
* Sample singleton for use with bean testing.
*
* @author John Aylward
*
*/
public final class Singleton {
/** */
private int someInt;
/** */
private String someString;
/** single instance. */
private static final Singleton INSTANCE = new Singleton();
/** @return the singleton instance. */
public static final Singleton getInstance() {
return INSTANCE;
}
/** */
private Singleton() {
if (INSTANCE != null) {
throw new IllegalStateException("Already instantiated");
}
}
@Override
protected Object clone() throws CloneNotSupportedException {
return INSTANCE;
}
/** @return someInt */
public int getSomeInt() {
return someInt;
}
/** sets someInt */
public void setSomeInt(int someInt) {
this.someInt = someInt;
}
/** @return someString */
public String getSomeString() {
return someString;
}
/** sets someString */
public void setSomeString(String someString) {
this.someString = someString;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + someInt;
result = prime * result + ((someString == null) ? 0 : someString.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;
Singleton other = (Singleton) obj;
if (someInt != other.someInt)
return false;
if (someString == null) {
if (other.someString != null)
return false;
} else if (!someString.equals(other.someString))
return false;
return true;
}
}