equals doesn't check null

This commit is contained in:
Adrian Cole 2013-01-12 08:01:31 -08:00
parent 21f6431f50
commit 2f5e38d237
2 changed files with 14 additions and 16 deletions

View File

@ -19,7 +19,6 @@
package org.jclouds.internal;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expect;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotEquals;
import static org.testng.Assert.fail;
@ -29,7 +28,6 @@ import org.jclouds.providers.ProviderMetadata;
import org.jclouds.rest.Utils;
import org.testng.annotations.Test;
import com.google.common.base.Objects;
import com.google.common.reflect.TypeToken;
/**
@ -44,14 +42,8 @@ public class BaseViewTest {
super("water", createMock(ProviderMetadata.class), "identity", createMock(Utils.class), createMock(Closer.class));
}
@Override
public void close() {
}
@Override
public boolean equals(Object in){
return Objects.equal(in.getClass(), getClass());
}
}
private static class PeanutButter extends ContextImpl {
@ -60,14 +52,8 @@ public class BaseViewTest {
super("peanutbutter", createMock(ProviderMetadata.class), "identity", createMock(Utils.class), createMock(Closer.class));
}
@Override
public void close() {
}
@Override
public boolean equals(Object in){
return Objects.equal(in.getClass(), getClass());
}
}
private static class Wine extends BaseView {
@ -80,8 +66,8 @@ public class BaseViewTest {
public void testWaterTurnedIntoWine() {
Wine wine = new Wine();
assertEquals(wine.getBackendType(), TypeToken.of(Water.class));
assertEquals(wine.unwrap(TypeToken.of(Water.class)), new Water());
assertEquals(wine.unwrap(), new Water());
assertEquals(wine.unwrap(TypeToken.of(Water.class)).getClass(), Water.class);
assertEquals(wine.unwrap().getClass(), Water.class);
}
public void testPeanutButterDidntTurnIntoWine() {

View File

@ -86,6 +86,10 @@ public final class DeserializationConstructorAndReflectiveTypeAdapterFactoryTest
@Override
public boolean equals(Object obj) {
if (obj == null)
return false;
if (obj == this)
return true;
DefaultConstructor other = DefaultConstructor.class.cast(obj);
if (bar != other.bar)
return false;
@ -158,6 +162,10 @@ public final class DeserializationConstructorAndReflectiveTypeAdapterFactoryTest
@Override
public boolean equals(Object obj) {
if (obj == null)
return false;
if (obj == this)
return true;
ValidatedConstructor other = ValidatedConstructor.class.cast(obj);
if (bar != other.bar)
return false;
@ -224,6 +232,10 @@ public final class DeserializationConstructorAndReflectiveTypeAdapterFactoryTest
@Override
public boolean equals(Object obj) {
if (obj == null)
return false;
if (obj == this)
return true;
RenamedFields other = RenamedFields.class.cast(obj);
if (bar != other.bar)
return false;