[testng] 272/355: Use generics for assertions

Eugene Zhukov eugene-guest at moszumanska.debian.org
Tue Aug 18 10:20:14 UTC 2015


This is an automated email from the git hooks/post-receive script.

eugene-guest pushed a commit to annotated tag OpenBSD
in repository testng.

commit 5f95d41c079737734fb3da2b029dc5ed2d307514
Author: Julien Herr <julien.herr at alcatel-lucent.com>
Date:   Thu May 7 14:10:34 2015 +0200

    Use generics for assertions
---
 src/main/java/org/testng/asserts/Assertion.java    | 376 ++++++++++-----------
 src/main/java/org/testng/asserts/IAssert.java      |   6 +-
 .../java/org/testng/asserts/IAssertLifecycle.java  |  12 +-
 .../java/org/testng/asserts/LoggingAssert.java     |   2 +-
 src/main/java/org/testng/asserts/SoftAssert.java   |   6 +-
 5 files changed, 201 insertions(+), 201 deletions(-)

diff --git a/src/main/java/org/testng/asserts/Assertion.java b/src/main/java/org/testng/asserts/Assertion.java
index 88c7af1..7ca9393 100644
--- a/src/main/java/org/testng/asserts/Assertion.java
+++ b/src/main/java/org/testng/asserts/Assertion.java
@@ -9,7 +9,7 @@ import java.util.Set;
  * by subclasses.
  */
 public class Assertion implements IAssertLifecycle {
-  protected void doAssert(IAssert assertCommand) {
+  protected void doAssert(IAssert<?> assertCommand) {
     onBeforeAssert(assertCommand);
     try {
       executeAssert(assertCommand);
@@ -26,7 +26,7 @@ public class Assertion implements IAssertLifecycle {
    * Run the assert command in parameter. Meant to be overridden by subclasses.
    */
   @Override
-  public void executeAssert(IAssert assertCommand) {
+  public void executeAssert(IAssert<?> assertCommand) {
     assertCommand.doAssert();
   }
 
@@ -34,7 +34,7 @@ public class Assertion implements IAssertLifecycle {
    * Invoked when an assert succeeds. Meant to be overridden by subclasses.
    */
   @Override
-  public void onAssertSuccess(IAssert assertCommand) {
+  public void onAssertSuccess(IAssert<?> assertCommand) {
   }
 
   /**
@@ -44,11 +44,11 @@ public class Assertion implements IAssertLifecycle {
    */
   @Deprecated
   @Override
-  public void onAssertFailure(IAssert assertCommand) {
+  public void onAssertFailure(IAssert<?> assertCommand) {
   }
   
   @Override
-  public void onAssertFailure(IAssert assertCommand, AssertionError ex) {
+  public void onAssertFailure(IAssert<?> assertCommand, AssertionError ex) {
       onAssertFailure(assertCommand);
   }
 
@@ -56,17 +56,17 @@ public class Assertion implements IAssertLifecycle {
    * Invoked before an assert is run. Meant to be overridden by subclasses.
    */
   @Override
-  public void onBeforeAssert(IAssert assertCommand) {
+  public void onBeforeAssert(IAssert<?> assertCommand) {
   }
 
   /**
    * Invoked after an assert is run. Meant to be overridden by subclasses.
    */
   @Override
-  public void onAfterAssert(IAssert assertCommand) {
+  public void onAfterAssert(IAssert<?> assertCommand) {
   }
 
-  abstract private static class SimpleAssert implements IAssert {
+  abstract private static class SimpleAssert<T> implements IAssert<T> {
     private final String m_message;
 
     public SimpleAssert(String message) {
@@ -79,12 +79,12 @@ public class Assertion implements IAssertLifecycle {
     }
 
     @Override
-    public Object getActual() {
+    public T getActual() {
         return null;
     }
 
     @Override
-    public Object getExpected() {
+    public T getExpected() {
         return null;
     }
 
@@ -94,83 +94,83 @@ public class Assertion implements IAssertLifecycle {
 
 
   public void assertTrue(final boolean condition, final String message) {
-    doAssert(new SimpleAssert(message) {
+    doAssert(new SimpleAssert<Boolean>(message) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertTrue(condition, message);
       }
 
       @Override
-      public Object getActual() {
+      public Boolean getActual() {
         return condition;
       }
 
       @Override
-      public Object getExpected() {
-        return true;
+      public Boolean getExpected() {
+        return Boolean.TRUE;
       }
     });
   }
   
 	public void assertTrue(final boolean condition) {
-		doAssert(new SimpleAssert(null) {
+		doAssert(new SimpleAssert<Boolean>(null) {
 			@Override
 			public void doAssert() {
 				org.testng.Assert.assertTrue(condition);
 			}
 
 			@Override
-			public Object getActual() {
+			public Boolean getActual() {
 				return condition;
 			}
 
 			@Override
-			public Object getExpected() {
-				return true;
+			public Boolean getExpected() {
+				return Boolean.TRUE;
 			}
 		});
 	}
 
   public void assertFalse(final boolean condition, final String message) {
-    doAssert(new SimpleAssert(message) {
+    doAssert(new SimpleAssert<Boolean>(message) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertFalse(condition, message);
       }
 
       @Override
-      public Object getActual() {
+      public Boolean getActual() {
         return condition;
       }
 
       @Override
-      public Object getExpected() {
-        return false;
+      public Boolean getExpected() {
+        return Boolean.FALSE;
       }
     });
   }
 
   public void assertFalse(final boolean condition) {
-    doAssert(new SimpleAssert(null) {
+    doAssert(new SimpleAssert<Boolean>(null) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertFalse(condition);
       }
 
       @Override
-      public Object getActual() {
+      public Boolean getActual() {
         return condition;
       }
 
       @Override
-      public Object getExpected() {
-        return false;
+      public Boolean getExpected() {
+        return Boolean.FALSE;
       }
     });
   }
 
   public void fail(final String message, final Throwable realCause) {
-    doAssert(new SimpleAssert(message) {
+    doAssert(new SimpleAssert<Object>(message) {
       @Override
       public void doAssert() {
         org.testng.Assert.fail(message, realCause);
@@ -179,7 +179,7 @@ public class Assertion implements IAssertLifecycle {
   }
 
   public void fail(final String message) {
-    doAssert(new SimpleAssert(message) {
+    doAssert(new SimpleAssert<Object>(message) {
       @Override
       public void doAssert() {
         org.testng.Assert.fail(message);
@@ -188,7 +188,7 @@ public class Assertion implements IAssertLifecycle {
   }
 
   public void fail() {
-    doAssert(new SimpleAssert(null) {
+    doAssert(new SimpleAssert<Object>(null) {
       @Override
       public void doAssert() {
         org.testng.Assert.fail();
@@ -196,76 +196,76 @@ public class Assertion implements IAssertLifecycle {
     });
   }
 
-  public void assertEquals(final Object actual, final Object expected, final String message) {
-    doAssert(new SimpleAssert(message) {
+  public <T> void assertEquals(final T actual, final T expected, final String message) {
+    doAssert(new SimpleAssert<T>(message) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertEquals(actual, expected, message);
       }
 
       @Override
-      public Object getActual() {
+      public T getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public T getExpected() {
           return expected;
       }
     });
   }
 
-  public void assertEquals(final Object actual, final Object expected) {
-    doAssert(new SimpleAssert(null) {
+  public <T> void assertEquals(final T actual, final T expected) {
+    doAssert(new SimpleAssert<T>(null) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertEquals(actual, expected);
       }
 
       @Override
-      public Object getActual() {
+      public T getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public T getExpected() {
           return expected;
       }
     });
   }
 
   public void assertEquals(final String actual, final String expected, final String message) {
-    doAssert(new SimpleAssert(message) {
+    doAssert(new SimpleAssert<String>(message) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertEquals(actual, expected, message);
       }
 
       @Override
-      public Object getActual() {
+      public String getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public String getExpected() {
           return expected;
       }
     });
   }
   public void assertEquals(final String actual, final String expected) {
-    doAssert(new SimpleAssert(null) {
+    doAssert(new SimpleAssert<String>(null) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertEquals(actual, expected);
       }
 
       @Override
-      public Object getActual() {
+      public String getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public String getExpected() {
           return expected;
       }
     });
@@ -273,38 +273,38 @@ public class Assertion implements IAssertLifecycle {
 
   public void assertEquals(final double actual, final double expected, final double delta,
       final String message) {
-    doAssert(new SimpleAssert(message) {
+    doAssert(new SimpleAssert<Double>(message) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertEquals(actual, expected, delta, message);
       }
 
       @Override
-      public Object getActual() {
+      public Double getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public Double getExpected() {
           return expected;
       }
     });
   }
 
   public void assertEquals(final double actual, final double expected, final double delta) {
-    doAssert(new SimpleAssert(null) {
+    doAssert(new SimpleAssert<Double>(null) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertEquals(actual, expected, delta);
       }
 
       @Override
-      public Object getActual() {
+      public Double getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public Double getExpected() {
           return expected;
       }
     });
@@ -312,273 +312,273 @@ public class Assertion implements IAssertLifecycle {
 
   public void assertEquals(final float actual, final float expected, final float delta,
       final String message) {
-    doAssert(new SimpleAssert(message) {
+    doAssert(new SimpleAssert<Float>(message) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertEquals(actual, expected, delta, message);
       }
 
       @Override
-      public Object getActual() {
+      public Float getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public Float getExpected() {
           return expected;
       }
     });
   }
 
   public void assertEquals(final float actual, final float expected, final float delta) {
-    doAssert(new SimpleAssert(null) {
+    doAssert(new SimpleAssert<Float>(null) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertEquals(actual, expected, delta);
       }
 
       @Override
-      public Object getActual() {
+      public Float getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public Float getExpected() {
           return expected;
       }
     });
   }
 
   public void assertEquals(final long actual, final long expected, final String message) {
-    doAssert(new SimpleAssert(message) {
+    doAssert(new SimpleAssert<Long>(message) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertEquals(actual, expected, message);
       }
 
       @Override
-      public Object getActual() {
+      public Long getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public Long getExpected() {
           return expected;
       }
     });
   }
 
   public void assertEquals(final long actual, final long expected) {
-    doAssert(new SimpleAssert(null) {
+    doAssert(new SimpleAssert<Long>(null) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertEquals(actual, expected);
       }
 
       @Override
-      public Object getActual() {
+      public Long getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public Long getExpected() {
           return expected;
       }
     });
   }
 
   public void assertEquals(final boolean actual, final boolean expected, final String message) {
-    doAssert(new SimpleAssert(message) {
+    doAssert(new SimpleAssert<Boolean>(message) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertEquals(actual, expected, message);
       }
 
       @Override
-      public Object getActual() {
+      public Boolean getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public Boolean getExpected() {
           return expected;
       }
     });
   }
 
   public void assertEquals(final boolean actual, final boolean expected) {
-    doAssert(new SimpleAssert(null) {
+    doAssert(new SimpleAssert<Boolean>(null) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertEquals(actual, expected);
       }
 
       @Override
-      public Object getActual() {
+      public Boolean getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public Boolean getExpected() {
           return expected;
       }
     });
   }
 
   public void assertEquals(final byte actual, final byte expected, final String message) {
-    doAssert(new SimpleAssert(message) {
+    doAssert(new SimpleAssert<Byte>(message) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertEquals(actual, expected, message);
       }
 
       @Override
-      public Object getActual() {
+      public Byte getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public Byte getExpected() {
           return expected;
       }
     });
   }
 
   public void assertEquals(final byte actual, final byte expected) {
-    doAssert(new SimpleAssert(null) {
+    doAssert(new SimpleAssert<Byte>(null) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertEquals(actual, expected);
       }
 
       @Override
-      public Object getActual() {
+      public Byte getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public Byte getExpected() {
           return expected;
       }
     });
   }
 
   public void assertEquals(final char actual, final char expected, final String message) {
-    doAssert(new SimpleAssert(message) {
+    doAssert(new SimpleAssert<Character>(message) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertEquals(actual, expected, message);
       }
 
       @Override
-      public Object getActual() {
+      public Character getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public Character getExpected() {
           return expected;
       }
     });
   }
 
   public void assertEquals(final char actual, final char expected) {
-    doAssert(new SimpleAssert(null) {
+    doAssert(new SimpleAssert<Character>(null) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertEquals(actual, expected);
       }
 
       @Override
-      public Object getActual() {
+      public Character getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public Character getExpected() {
           return expected;
       }
     });
   }
 
   public void assertEquals(final short actual, final short expected, final String message) {
-    doAssert(new SimpleAssert(message) {
+    doAssert(new SimpleAssert<Short>(message) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertEquals(actual, expected, message);
       }
 
       @Override
-      public Object getActual() {
+      public Short getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public Short getExpected() {
           return expected;
       }
     });
   }
 
   public void assertEquals(final short actual, final short expected) {
-    doAssert(new SimpleAssert(null) {
+    doAssert(new SimpleAssert<Short>(null) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertEquals(actual, expected);
       }
 
       @Override
-      public Object getActual() {
+      public Short getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public Short getExpected() {
           return expected;
       }
     });
   }
 
   public void assertEquals(final int actual, final  int expected, final String message) {
-    doAssert(new SimpleAssert(message) {
+    doAssert(new SimpleAssert<Integer>(message) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertEquals(actual, expected, message);
       }
 
       @Override
-      public Object getActual() {
+      public Integer getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public Integer getExpected() {
           return expected;
       }
     });
   }
 
   public void assertEquals(final int actual, final int expected) {
-    doAssert(new SimpleAssert(null) {
+    doAssert(new SimpleAssert<Integer>(null) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertEquals(actual, expected);
       }
 
       @Override
-      public Object getActual() {
+      public Integer getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public Integer getExpected() {
           return expected;
       }
     });
   }
 
   public void assertNotNull(final Object object) {
-    doAssert(new SimpleAssert(null) {
+    doAssert(new SimpleAssert<Object>(null) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertNotNull(object);
@@ -592,7 +592,7 @@ public class Assertion implements IAssertLifecycle {
   }
 
   public void assertNotNull(final Object object, final String message) {
-    doAssert(new SimpleAssert(message) {
+    doAssert(new SimpleAssert<Object>(message) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertNotNull(object, message);
@@ -606,7 +606,7 @@ public class Assertion implements IAssertLifecycle {
   }
 
   public void assertNull(final Object object) {
-    doAssert(new SimpleAssert(null) {
+    doAssert(new SimpleAssert<Object>(null) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertNull(object);
@@ -620,7 +620,7 @@ public class Assertion implements IAssertLifecycle {
   }
 
   public void assertNull(final Object object, final String message) {
-    doAssert(new SimpleAssert(message) {
+    doAssert(new SimpleAssert<Object>(message) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertNull(object, message);
@@ -634,7 +634,7 @@ public class Assertion implements IAssertLifecycle {
   }
 
   public void assertSame(final Object actual, final Object expected, final String message) {
-    doAssert(new SimpleAssert(message) {
+    doAssert(new SimpleAssert<Object>(message) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertSame(actual, expected, message);
@@ -653,7 +653,7 @@ public class Assertion implements IAssertLifecycle {
   }
 
   public void assertSame(final Object actual, final Object expected) {
-    doAssert(new SimpleAssert(null) {
+    doAssert(new SimpleAssert<Object>(null) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertSame(actual, expected);
@@ -672,7 +672,7 @@ public class Assertion implements IAssertLifecycle {
   }
 
   public void assertNotSame(final Object actual, final Object expected, final String message) {
-    doAssert(new SimpleAssert(message) {
+    doAssert(new SimpleAssert<Object>(message) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertNotSame(actual, expected, message);
@@ -691,7 +691,7 @@ public class Assertion implements IAssertLifecycle {
   }
 
   public void assertNotSame(final Object actual, final Object expected) {
-    doAssert(new SimpleAssert(null) {
+    doAssert(new SimpleAssert<Object>(null) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertNotSame(actual, expected);
@@ -710,19 +710,19 @@ public class Assertion implements IAssertLifecycle {
   }
 
   public void assertEquals(final Collection<?> actual, final Collection<?> expected) {
-    doAssert(new SimpleAssert(null) {
+    doAssert(new SimpleAssert<Collection<?>>(null) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertEquals(actual, expected);
       }
 
       @Override
-      public Object getActual() {
+      public Collection<?> getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public Collection<?> getExpected() {
           return expected;
       }
     });
@@ -730,38 +730,38 @@ public class Assertion implements IAssertLifecycle {
 
   public void assertEquals(final Collection<?> actual, final Collection<?> expected,
       final String message) {
-    doAssert(new SimpleAssert(message) {
+    doAssert(new SimpleAssert<Collection<?>>(message) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertEquals(actual, expected, message);
       }
 
       @Override
-      public Object getActual() {
+      public Collection<?> getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public Collection<?> getExpected() {
           return expected;
       }
     });
   }
 
   public void assertEquals(final Object[] actual, final Object[] expected, final String message) {
-    doAssert(new SimpleAssert(message) {
+    doAssert(new SimpleAssert<Object[]>(message) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertEquals(actual, expected, message);
       }
 
       @Override
-      public Object getActual() {
+      public Object[] getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public Object[] getExpected() {
           return expected;
       }
     });
@@ -769,76 +769,76 @@ public class Assertion implements IAssertLifecycle {
 
   public void assertEqualsNoOrder(final Object[] actual, final Object[] expected,
       final String message) {
-    doAssert(new SimpleAssert(message) {
+    doAssert(new SimpleAssert<Object[]>(message) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertEqualsNoOrder(actual, expected, message);
       }
 
       @Override
-      public Object getActual() {
+      public Object[] getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public Object[] getExpected() {
           return expected;
       }
     });
   }
 
   public void assertEquals(final Object[] actual, final Object[] expected) {
-    doAssert(new SimpleAssert(null) {
+    doAssert(new SimpleAssert<Object[]>(null) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertEquals(actual, expected);
       }
 
       @Override
-      public Object getActual() {
+      public Object[] getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public Object[] getExpected() {
           return expected;
       }
     });
   }
 
   public void assertEqualsNoOrder(final Object[] actual, final Object[] expected) {
-    doAssert(new SimpleAssert(null) {
+    doAssert(new SimpleAssert<Object[]>(null) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertEqualsNoOrder(actual, expected);
       }
 
       @Override
-      public Object getActual() {
+      public Object[] getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public Object[] getExpected() {
           return expected;
       }
     });
   }
 
   public void assertEquals(final byte[] actual, final byte[] expected) {
-    doAssert(new SimpleAssert(null) {
+    doAssert(new SimpleAssert<byte[]>(null) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertEquals(actual, expected);
       }
 
       @Override
-      public Object getActual() {
+      public byte[] getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public byte[] getExpected() {
           return expected;
       }
     });
@@ -846,83 +846,83 @@ public class Assertion implements IAssertLifecycle {
 
   public void assertEquals(final byte[] actual, final byte[] expected,
       final String message) {
-    doAssert(new SimpleAssert(message) {
+    doAssert(new SimpleAssert<byte[]>(message) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertEquals(actual, expected, message);
       }
 
       @Override
-      public Object getActual() {
+      public byte[] getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public byte[] getExpected() {
           return expected;
       }
     });
   }
 
   public void assertEquals(final Set<?> actual, final Set<?> expected) {
-    doAssert(new SimpleAssert(null) {
+    doAssert(new SimpleAssert<Set<?>>(null) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertEquals(actual, expected);
       }
 
       @Override
-      public Object getActual() {
+      public Set<?> getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public Set<?> getExpected() {
           return expected;
       }
     });
   }
 
   public void assertEquals(final Set<?> actual, final Set<?> expected, final String message) {
-    doAssert(new SimpleAssert(message) {
+    doAssert(new SimpleAssert<Set<?>>(message) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertEquals(actual, expected, message);
       }
 
       @Override
-      public Object getActual() {
+      public Set<?> getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public Set<?> getExpected() {
           return expected;
       }
     });
   }
 
   public void assertEquals(final Map<?, ?> actual, final Map<?, ?> expected) {
-    doAssert(new SimpleAssert(null) {
+    doAssert(new SimpleAssert<Map<?, ?>>(null) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertEquals(actual, expected);
       }
 
       @Override
-      public Object getActual() {
+      public Map<?, ?> getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public Map<?, ?> getExpected() {
           return expected;
       }
     });
   }
 
   public  void assertNotEquals(final Object actual, final Object expected, final String message) {
-    doAssert(new SimpleAssert(message) {
+    doAssert(new SimpleAssert<Object>(message) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertNotEquals(actual, expected, message);
@@ -941,7 +941,7 @@ public class Assertion implements IAssertLifecycle {
   }
 
   public void assertNotEquals(final Object actual, final Object expected) {
-    doAssert(new SimpleAssert(null) {
+    doAssert(new SimpleAssert<Object>(null) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertNotEquals(actual, expected);
@@ -960,266 +960,266 @@ public class Assertion implements IAssertLifecycle {
   }
 
   void assertNotEquals(final String actual, final String expected, final String message) {
-    doAssert(new SimpleAssert(message) {
+    doAssert(new SimpleAssert<String>(message) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertNotEquals(actual, expected, message);
       }
 
       @Override
-      public Object getActual() {
+      public String getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public String getExpected() {
           return expected;
       }
     });
   }
 
   void assertNotEquals(final String actual, final String expected) {
-    doAssert(new SimpleAssert(null) {
+    doAssert(new SimpleAssert<String>(null) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertNotEquals(actual, expected);
       }
 
       @Override
-      public Object getActual() {
+      public String getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public String getExpected() {
           return expected;
       }
     });
   }
 
   void assertNotEquals(final long actual, final long expected, final String message) {
-    doAssert(new SimpleAssert(message) {
+    doAssert(new SimpleAssert<Long>(message) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertNotEquals(actual, expected, message);
       }
 
       @Override
-      public Object getActual() {
+      public Long getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public Long getExpected() {
           return expected;
       }
     });
   }
 
   void assertNotEquals(final long actual, final long expected) {
-    doAssert(new SimpleAssert(null) {
+    doAssert(new SimpleAssert<Long>(null) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertNotEquals(actual, expected);
       }
 
       @Override
-      public Object getActual() {
+      public Long getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public Long getExpected() {
           return expected;
       }
     });
   }
 
   void assertNotEquals(final boolean actual, final boolean expected, final String message) {
-    doAssert(new SimpleAssert(message) {
+    doAssert(new SimpleAssert<Boolean>(message) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertNotEquals(actual, expected, message);
       }
 
       @Override
-      public Object getActual() {
+      public Boolean getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public Boolean getExpected() {
           return expected;
       }
     });
   }
 
   void assertNotEquals(final boolean actual, final boolean expected) {
-    doAssert(new SimpleAssert(null) {
+    doAssert(new SimpleAssert<Boolean>(null) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertNotEquals(actual, expected);
       }
 
       @Override
-      public Object getActual() {
+      public Boolean getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public Boolean getExpected() {
           return expected;
       }
     });
   }
 
   void assertNotEquals(final byte actual, final byte expected, final String message) {
-    doAssert(new SimpleAssert(message) {
+    doAssert(new SimpleAssert<Byte>(message) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertNotEquals(actual, expected, message);
       }
 
       @Override
-      public Object getActual() {
+      public Byte getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public Byte getExpected() {
           return expected;
       }
     });
   }
 
   void assertNotEquals(final byte actual, final byte expected) {
-    doAssert(new SimpleAssert(null) {
+    doAssert(new SimpleAssert<Byte>(null) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertNotEquals(actual, expected);
       }
 
       @Override
-      public Object getActual() {
+      public Byte getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public Byte getExpected() {
           return expected;
       }
     });
   }
 
   void assertNotEquals(final char actual, final char expected, final String message) {
-    doAssert(new SimpleAssert(message) {
+    doAssert(new SimpleAssert<Character>(message) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertNotEquals(actual, expected, message);
       }
 
       @Override
-      public Object getActual() {
+      public Character getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public Character getExpected() {
           return expected;
       }
     });
   }
 
   void assertNotEquals(final char actual, final char expected) {
-    doAssert(new SimpleAssert(null) {
+    doAssert(new SimpleAssert<Character>(null) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertNotEquals(actual, expected);
       }
 
       @Override
-      public Object getActual() {
+      public Character getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public Character getExpected() {
           return expected;
       }
     });
   }
 
   void assertNotEquals(final short actual, final short expected, final String message) {
-    doAssert(new SimpleAssert(message) {
+    doAssert(new SimpleAssert<Short>(message) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertNotEquals(actual, expected, message);
       }
 
       @Override
-      public Object getActual() {
+      public Short getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public Short getExpected() {
           return expected;
       }
     });
   }
 
   void assertNotEquals(final short actual, final short expected) {
-    doAssert(new SimpleAssert(null) {
+    doAssert(new SimpleAssert<Short>(null) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertNotEquals(actual, expected);
       }
 
       @Override
-      public Object getActual() {
+      public Short getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public Short getExpected() {
           return expected;
       }
     });
   }
 
   void assertNotEquals(final int actual, final int expected, final String message) {
-    doAssert(new SimpleAssert(message) {
+    doAssert(new SimpleAssert<Integer>(message) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertNotEquals(actual, expected, message);
       }
 
       @Override
-      public Object getActual() {
+      public Integer getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public Integer getExpected() {
           return expected;
       }
     });
   }
 
   void assertNotEquals(final int actual, final int expected) {
-    doAssert(new SimpleAssert(null) {
+    doAssert(new SimpleAssert<Integer>(null) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertNotEquals(actual, expected);
       }
 
       @Override
-      public Object getActual() {
+      public Integer getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public Integer getExpected() {
           return expected;
       }
     });
@@ -1227,38 +1227,38 @@ public class Assertion implements IAssertLifecycle {
 
   public void assertNotEquals(final float actual, final float expected, final float delta,
       final String message) {
-    doAssert(new SimpleAssert(message) {
+    doAssert(new SimpleAssert<Float>(message) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertNotEquals(actual, expected, delta, message);
       }
 
       @Override
-      public Object getActual() {
+      public Float getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public Float getExpected() {
           return expected;
       }
    });
   }
 
   public void assertNotEquals(final float actual, final float expected, final float delta) {
-    doAssert(new SimpleAssert(null) {
+    doAssert(new SimpleAssert<Float>(null) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertNotEquals(actual, expected, delta);
       }
 
       @Override
-      public Object getActual() {
+      public Float getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public Float getExpected() {
           return expected;
       }
     });
@@ -1266,38 +1266,38 @@ public class Assertion implements IAssertLifecycle {
 
   public void assertNotEquals(final double actual, final double expected, final double delta,
       final String message) {
-    doAssert(new SimpleAssert(message) {
+    doAssert(new SimpleAssert<Double>(message) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertNotEquals(actual, expected, delta, message);
       }
 
       @Override
-      public Object getActual() {
+      public Double getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public Double getExpected() {
           return expected;
       }
     });
   }
 
   public void assertNotEquals(final double actual, final double expected, final double delta) {
-    doAssert(new SimpleAssert(null) {
+    doAssert(new SimpleAssert<Double>(null) {
       @Override
       public void doAssert() {
         org.testng.Assert.assertNotEquals(actual, expected, delta);
       }
 
       @Override
-      public Object getActual() {
+      public Double getActual() {
           return actual;
       }
 
       @Override
-      public Object getExpected() {
+      public Double getExpected() {
           return expected;
       }
     });
diff --git a/src/main/java/org/testng/asserts/IAssert.java b/src/main/java/org/testng/asserts/IAssert.java
index ee364b0..b372454 100644
--- a/src/main/java/org/testng/asserts/IAssert.java
+++ b/src/main/java/org/testng/asserts/IAssert.java
@@ -1,8 +1,8 @@
 package org.testng.asserts;
 
-public interface IAssert {
+public interface IAssert<T> {
   String getMessage();
   void doAssert();
-  Object getActual();
-  Object getExpected();
+  T getActual();
+  T getExpected();
 }
diff --git a/src/main/java/org/testng/asserts/IAssertLifecycle.java b/src/main/java/org/testng/asserts/IAssertLifecycle.java
index c934087..095b0ee 100644
--- a/src/main/java/org/testng/asserts/IAssertLifecycle.java
+++ b/src/main/java/org/testng/asserts/IAssertLifecycle.java
@@ -7,33 +7,33 @@ public interface IAssertLifecycle {
   /**
    * Run the assert command in parameter.
    */
-  void executeAssert(IAssert assertCommand);
+  void executeAssert(IAssert<?> assertCommand);
 
   /**
    * Invoked when an assert succeeds.
    */
-  void onAssertSuccess(IAssert assertCommand);
+  void onAssertSuccess(IAssert<?> assertCommand);
 
   /**
    * Invoked when an assert fails.
    * 
    * @deprecated use onAssertFailure(IAssert assertCommand, AssertionError ex) instead of.
    */
-  void onAssertFailure(IAssert assertCommand);
+  void onAssertFailure(IAssert<?> assertCommand);
   
   /**
    * Invoked when an assert fails.
    * 
    */
-  void onAssertFailure(IAssert assertCommand, AssertionError ex);
+  void onAssertFailure(IAssert<?> assertCommand, AssertionError ex);
 
   /**
    * Invoked before an assert is run.
    */
-  void onBeforeAssert(IAssert assertCommand);
+  void onBeforeAssert(IAssert<?> assertCommand);
 
   /**
    * Invoked after an assert is run.
    */
-  void onAfterAssert(IAssert assertCommand);
+  void onAfterAssert(IAssert<?> assertCommand);
 }
diff --git a/src/main/java/org/testng/asserts/LoggingAssert.java b/src/main/java/org/testng/asserts/LoggingAssert.java
index e8e7080..6869b78 100644
--- a/src/main/java/org/testng/asserts/LoggingAssert.java
+++ b/src/main/java/org/testng/asserts/LoggingAssert.java
@@ -12,7 +12,7 @@ public class LoggingAssert extends Assertion {
   private List<String> m_messages = Lists.newArrayList();
 
   @Override
-  public void onBeforeAssert(IAssert a) {
+  public void onBeforeAssert(IAssert<?> a) {
     m_messages.add("Test:" + a.getMessage());
   }
 
diff --git a/src/main/java/org/testng/asserts/SoftAssert.java b/src/main/java/org/testng/asserts/SoftAssert.java
index f06f1d5..73dff19 100644
--- a/src/main/java/org/testng/asserts/SoftAssert.java
+++ b/src/main/java/org/testng/asserts/SoftAssert.java
@@ -11,10 +11,10 @@ import org.testng.collections.Maps;
  */
 public class SoftAssert extends Assertion {
   // LinkedHashMap to preserve the order
-  private Map<AssertionError, IAssert> m_errors = Maps.newLinkedHashMap();
+  private Map<AssertionError, IAssert<?>> m_errors = Maps.newLinkedHashMap();
 
   @Override
-  public void executeAssert(IAssert a) {
+  public void executeAssert(IAssert<?> a) {
     try {
       a.doAssert();
     } catch(AssertionError ex) {
@@ -27,7 +27,7 @@ public class SoftAssert extends Assertion {
     if (! m_errors.isEmpty()) {
       StringBuilder sb = new StringBuilder("The following asserts failed:\n");
       boolean first = true;
-      for (Map.Entry<AssertionError, IAssert> ae : m_errors.entrySet()) {
+      for (Map.Entry<AssertionError, IAssert<?>> ae : m_errors.entrySet()) {
         if (first) {
           first = false;
         } else {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/testng.git



More information about the pkg-java-commits mailing list