From 2f5e38d237b174b11f345b69fe5f9c1eff699d36 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Sat, 12 Jan 2013 08:01:31 -0800 Subject: [PATCH] equals doesn't check null --- .../org/jclouds/internal/BaseViewTest.java | 18 ++---------------- ...torAndReflectiveTypeAdapterFactoryTest.java | 12 ++++++++++++ 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/core/src/test/java/org/jclouds/internal/BaseViewTest.java b/core/src/test/java/org/jclouds/internal/BaseViewTest.java index 8dc4488628..2c5313df25 100644 --- a/core/src/test/java/org/jclouds/internal/BaseViewTest.java +++ b/core/src/test/java/org/jclouds/internal/BaseViewTest.java @@ -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() { diff --git a/core/src/test/java/org/jclouds/json/internal/DeserializationConstructorAndReflectiveTypeAdapterFactoryTest.java b/core/src/test/java/org/jclouds/json/internal/DeserializationConstructorAndReflectiveTypeAdapterFactoryTest.java index 18909c413f..048c2a58b0 100644 --- a/core/src/test/java/org/jclouds/json/internal/DeserializationConstructorAndReflectiveTypeAdapterFactoryTest.java +++ b/core/src/test/java/org/jclouds/json/internal/DeserializationConstructorAndReflectiveTypeAdapterFactoryTest.java @@ -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;