This is an automated email from the ASF dual-hosted git repository.

amichai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/aries-rsa.git

commit 5821905f6aa0abb454816581ee389aa1bf2553cb
Author: Amichai Rothman <[email protected]>
AuthorDate: Mon Jun 3 16:02:51 2024 +0300

    Simplify tests
---
 .../local/EndpointDescriptionBundleParserTest.java | 13 +++++++------
 .../aries/rsa/eapub/EventAdminHelperTest.java      |  8 ++++----
 .../aries/rsa/provider/fastbin/InvocationTest.java |  2 +-
 .../fastbin/tcp/LengthPrefixedCodecTest.java       | 22 +++++++++++-----------
 .../rsa/provider/tcp/TcpProviderPrimitiveTest.java |  2 +-
 .../aries/rsa/core/ClientServiceFactoryTest.java   |  9 +++++----
 .../aries/rsa/core/ImportRegistrationImplTest.java |  8 +++-----
 .../aries/rsa/core/OverlayPropertiesTest.java      | 10 ++++------
 .../importer/local/EndpointListenerImplTest.java   |  6 +++---
 9 files changed, 39 insertions(+), 41 deletions(-)

diff --git 
a/discovery/local/src/test/java/org/apache/aries/rsa/discovery/local/EndpointDescriptionBundleParserTest.java
 
b/discovery/local/src/test/java/org/apache/aries/rsa/discovery/local/EndpointDescriptionBundleParserTest.java
index a6d81e19..f83f437a 100644
--- 
a/discovery/local/src/test/java/org/apache/aries/rsa/discovery/local/EndpointDescriptionBundleParserTest.java
+++ 
b/discovery/local/src/test/java/org/apache/aries/rsa/discovery/local/EndpointDescriptionBundleParserTest.java
@@ -36,14 +36,13 @@ import javax.xml.transform.stream.StreamResult;
 import javax.xml.transform.stream.StreamSource;
 
 import org.easymock.EasyMock;
-import org.junit.Assert;
 import org.junit.Test;
 import org.osgi.framework.Bundle;
 import org.osgi.service.remoteserviceadmin.EndpointDescription;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.*;
 
-public class EndpointDescriptionBundleParserTest extends TestCase {
+public class EndpointDescriptionBundleParserTest {
 
     private Bundle createBundleContaining(URL ed1URL) {
         Bundle b = EasyMock.createNiceMock(Bundle.class);
@@ -61,9 +60,10 @@ public class EndpointDescriptionBundleParserTest extends 
TestCase {
         EasyMock.replay(b);
 
         List<EndpointDescription> rsElements = new 
EndpointDescriptionBundleParser().getAllEndpointDescriptions(b);
-        Assert.assertEquals(0, rsElements.size());
+        assertEquals(0, rsElements.size());
     }
 
+    @Test
     public void testAllEndpoints1() {
         URL ed1URL = getClass().getResource("/ed1.xml");
 
@@ -91,6 +91,7 @@ public class EndpointDescriptionBundleParserTest extends 
TestCase {
         assertEquals(Arrays.asList("SomeOtherService", 
"WithSomeSecondInterface"), endpoint3.getInterfaces());
     }
 
+    @Test
     public void testAllEndpoints2() throws Exception {
         URL ed2URL = getClass().getResource("/ed2.xml");
 
@@ -134,10 +135,10 @@ public class EndpointDescriptionBundleParserTest extends 
TestCase {
         assertEquals('X', props.get("Character2"));
 
         int[] intArray = (int[]) props.get("int-array");
-        assertTrue(Arrays.equals(new int[] {1, 2}, intArray));
+        assertArrayEquals(new int[]{1, 2}, intArray);
 
         Integer[] integerArray = (Integer[]) props.get("Integer-array");
-        assertTrue(Arrays.equals(new Integer[] {2, 1}, integerArray));
+        assertArrayEquals(new Integer[]{2, 1}, integerArray);
 
         assertEquals(Arrays.asList(true, false), props.get("bool-list"));
         assertEquals(new HashSet<>(), props.get("long-set"));
diff --git 
a/eapub/src/test/java/org/apache/aries/rsa/eapub/EventAdminHelperTest.java 
b/eapub/src/test/java/org/apache/aries/rsa/eapub/EventAdminHelperTest.java
index 2590dd1d..0965b164 100644
--- a/eapub/src/test/java/org/apache/aries/rsa/eapub/EventAdminHelperTest.java
+++ b/eapub/src/test/java/org/apache/aries/rsa/eapub/EventAdminHelperTest.java
@@ -85,8 +85,8 @@ public class EventAdminHelperTest {
                 Assert.assertEquals(Long.MAX_VALUE, 
event.getProperty("service.remote.id"));
                 Assert.assertEquals(uuid, 
event.getProperty("service.remote.uuid"));
                 Assert.assertEquals("foo://bar", 
event.getProperty("service.remote.uri"));
-                Assert.assertTrue(Arrays.equals(interfaces.toArray(new 
String[] {}),
-                                                (String[]) 
event.getProperty("objectClass")));
+                Assert.assertArrayEquals(interfaces.toArray(new String[]{}),
+                        (String[]) event.getProperty("objectClass"));
 
                 Assert.assertNotNull(event.getProperty("timestamp"));
 
@@ -157,8 +157,8 @@ public class EventAdminHelperTest {
                 Assert.assertEquals(new Version("0"), 
event.getProperty("bundle.version"));
                 Assert.assertSame(exportException, event.getProperty("cause"));
                 Assert.assertEquals(epd, 
event.getProperty("export.registration"));
-                Assert.assertTrue(Arrays.equals(new String[] {"org.foo.Bar"},
-                                                (String[]) 
event.getProperty("objectClass")));
+                Assert.assertArrayEquals(new String[]{"org.foo.Bar"},
+                        (String[]) event.getProperty("objectClass"));
 
                 RemoteServiceAdminEvent rsae = (RemoteServiceAdminEvent) 
event.getProperty("event");
                 Assert.assertSame(exportException, rsae.getException());
diff --git 
a/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/InvocationTest.java
 
b/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/InvocationTest.java
index 3a62c620..6b35f314 100644
--- 
a/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/InvocationTest.java
+++ 
b/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/InvocationTest.java
@@ -299,7 +299,7 @@ public class InvocationTest {
                 threads[t].join(10000);
                 System.err.format("REQUEST: %d of %d%n", requests.get(), 
BENCHMARK_CLIENTS);
                 System.err.format("RESPONSES: %d of %d%n", responses.get(), 
BENCHMARK_CLIENTS);
-                assertEquals(threads[t].isAlive(), false);
+                assertFalse(threads[t].isAlive());
             }
 
             assertEquals(BENCHMARK_CLIENTS, requests.get());
diff --git 
a/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/tcp/LengthPrefixedCodecTest.java
 
b/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/tcp/LengthPrefixedCodecTest.java
index 58e4e9d8..7a5ceddb 100644
--- 
a/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/tcp/LengthPrefixedCodecTest.java
+++ 
b/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/tcp/LengthPrefixedCodecTest.java
@@ -37,7 +37,7 @@ import static org.easymock.EasyMock.createMock;
 import static org.easymock.EasyMock.expect;
 import static org.easymock.EasyMock.getCurrentArguments;
 import static org.easymock.EasyMock.replay;
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.*;
 
 public class LengthPrefixedCodecTest {
     private ReadableByteChannel readableByteChannel = 
createMock(ReadableByteChannel.class);
@@ -62,12 +62,12 @@ public class LengthPrefixedCodecTest {
 
     @Test
     public void testFull() throws Exception {
-        assertEquals(false, codec.full());
+        assertFalse(codec.full());
     }
 
     @Test
     public void testEmpty() throws Exception {
-        assertEquals(true, codec.empty());
+        assertTrue(codec.empty());
     }
 
     @Test
@@ -87,8 +87,8 @@ public class LengthPrefixedCodecTest {
         final BufferState state = codec.write(value);
 
         assertEquals(BufferState.WAS_EMPTY, state);
-        assertEquals(false, codec.full());
-        assertEquals(false, codec.empty());
+        assertFalse(codec.full());
+        assertFalse(codec.empty());
         assertEquals(0L, codec.getWriteCounter());
     }
 
@@ -101,8 +101,8 @@ public class LengthPrefixedCodecTest {
         final BufferState state = codec.write(value2);
 
         assertEquals(BufferState.NOT_EMPTY, state);
-        assertEquals(false, codec.full());
-        assertEquals(false, codec.empty());
+        assertFalse(codec.full());
+        assertFalse(codec.empty());
         assertEquals(0L, codec.getWriteCounter());
     }
 
@@ -117,8 +117,8 @@ public class LengthPrefixedCodecTest {
         final BufferState state = codec.flush();
 
         assertEquals(BufferState.EMPTY, state);
-        assertEquals(false, codec.full());
-        assertEquals(true, codec.empty());
+        assertFalse(codec.full());
+        assertTrue(codec.empty());
         assertEquals(bytesThatWillBeWritten, codec.getWriteCounter());
 
         assertEquals(BufferState.WAS_EMPTY, codec.flush());
@@ -135,8 +135,8 @@ public class LengthPrefixedCodecTest {
         final BufferState state = codec.flush();
 
         assertEquals(BufferState.NOT_EMPTY, state);
-        assertEquals(false, codec.full());
-        assertEquals(false, codec.empty());
+        assertFalse(codec.full());
+        assertFalse(codec.empty());
         assertEquals(bytesThatWillBeWritten, codec.getWriteCounter());
     }
 
diff --git 
a/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderPrimitiveTest.java
 
b/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderPrimitiveTest.java
index 6528e8b9..5ddd77d4 100644
--- 
a/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderPrimitiveTest.java
+++ 
b/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderPrimitiveTest.java
@@ -104,7 +104,7 @@ public class TcpProviderPrimitiveTest {
 
     @Test
     public void testBoolean() {
-        Assert.assertEquals(true, myServiceProxy.callBoolean(true));
+        Assert.assertTrue(myServiceProxy.callBoolean(true));
     }
 
     @Test
diff --git 
a/rsa/src/test/java/org/apache/aries/rsa/core/ClientServiceFactoryTest.java 
b/rsa/src/test/java/org/apache/aries/rsa/core/ClientServiceFactoryTest.java
index f0c321a0..2f45d13f 100644
--- a/rsa/src/test/java/org/apache/aries/rsa/core/ClientServiceFactoryTest.java
+++ b/rsa/src/test/java/org/apache/aries/rsa/core/ClientServiceFactoryTest.java
@@ -20,6 +20,7 @@ package org.apache.aries.rsa.core;
 
 import static org.easymock.EasyMock.anyObject;
 import static org.easymock.EasyMock.isA;
+import static org.junit.Assert.assertSame;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -27,6 +28,7 @@ import java.util.Map;
 import org.apache.aries.rsa.spi.DistributionProvider;
 import org.easymock.EasyMock;
 import org.easymock.IMocksControl;
+import org.junit.Test;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
@@ -35,10 +37,9 @@ import org.osgi.framework.wiring.BundleWiring;
 import org.osgi.service.remoteserviceadmin.EndpointDescription;
 import org.osgi.service.remoteserviceadmin.RemoteConstants;
 
-import junit.framework.TestCase;
-
-public class ClientServiceFactoryTest extends TestCase {
+public class ClientServiceFactoryTest {
 
+    @Test
     @SuppressWarnings("rawtypes")
     public void testGetService() throws ClassNotFoundException {
         final Object myTestProxyObject = new Object();
@@ -64,7 +65,7 @@ public class ClientServiceFactoryTest extends TestCase {
 
     /**
      * Creating dummy class as I was not able to really mock it
-     * @param myTestProxyObject
+     * @param proxy
      * @return
      */
     private DistributionProvider mockDistributionProvider(final Object proxy) {
diff --git 
a/rsa/src/test/java/org/apache/aries/rsa/core/ImportRegistrationImplTest.java 
b/rsa/src/test/java/org/apache/aries/rsa/core/ImportRegistrationImplTest.java
index 077a0196..dd398a12 100644
--- 
a/rsa/src/test/java/org/apache/aries/rsa/core/ImportRegistrationImplTest.java
+++ 
b/rsa/src/test/java/org/apache/aries/rsa/core/ImportRegistrationImplTest.java
@@ -18,10 +18,6 @@
  */
 package org.apache.aries.rsa.core;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
 import org.easymock.EasyMock;
 import org.easymock.IMocksControl;
 import org.junit.Test;
@@ -29,6 +25,8 @@ import org.osgi.framework.ServiceReference;
 import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.remoteserviceadmin.EndpointDescription;
 
+import static org.junit.Assert.*;
+
 public class ImportRegistrationImplTest {
 
     @Test
@@ -81,7 +79,7 @@ public class ImportRegistrationImplTest {
 
         try {
             i2.setImportedServiceRegistration(sr);
-            assertTrue("An exception should be thrown here !", false);
+            fail("An exception should be thrown here !");
         } catch (IllegalStateException e) {
             // must be thrown here
         }
diff --git 
a/rsa/src/test/java/org/apache/aries/rsa/core/OverlayPropertiesTest.java 
b/rsa/src/test/java/org/apache/aries/rsa/core/OverlayPropertiesTest.java
index d48bd0a0..6bfb7f87 100644
--- a/rsa/src/test/java/org/apache/aries/rsa/core/OverlayPropertiesTest.java
+++ b/rsa/src/test/java/org/apache/aries/rsa/core/OverlayPropertiesTest.java
@@ -18,10 +18,6 @@
  */
 package org.apache.aries.rsa.core;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
@@ -29,6 +25,8 @@ import java.util.Map;
 import org.junit.Test;
 import org.osgi.framework.Constants;
 
+import static org.junit.Assert.*;
+
 public class OverlayPropertiesTest {
 
     @Test
@@ -57,8 +55,8 @@ public class OverlayPropertiesTest {
         assertEquals("achanged", sProps.get("aaa"));
         assertEquals("bval", sProps.get("bbb"));
         assertEquals("CVAL", sProps.get("CCC"));
-        assertTrue("Should not be possible to override the objectClass 
property",
-                Arrays.equals(new String[] {"X"}, (Object[]) 
sProps.get(Constants.OBJECTCLASS)));
+        assertArrayEquals("Should not be possible to override the objectClass 
property",
+                new String[]{"X"}, (Object[]) 
sProps.get(Constants.OBJECTCLASS));
         assertEquals("Should not be possible to override the service.id 
property",
                 17L, sProps.get(Constants.SERVICE_ID));
     }
diff --git 
a/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/importer/local/EndpointListenerImplTest.java
 
b/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/importer/local/EndpointListenerImplTest.java
index 7864ce44..3290285b 100644
--- 
a/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/importer/local/EndpointListenerImplTest.java
+++ 
b/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/importer/local/EndpointListenerImplTest.java
@@ -73,15 +73,15 @@ public class EndpointListenerImplTest extends Assert {
                     break;
                 case 4:
                     assertEquals("adding second entry failed", 2, 
scope.size());
-                    assertNotNull(scope.contains("(a=b)"));
-                    assertNotNull(scope.contains("(c=d)"));
+                    assertTrue(scope.contains("(a=b)"));
+                    assertTrue(scope.contains("(c=d)"));
                     break;
                 case 5:
                     assertEquals("remove failed", 1, scope.size());
                     assertEquals("(c=d)", scope.get(0));
                     break;
                 default:
-                    assertTrue("This should not happen!", false);
+                    fail("This should not happen!");
                 }
                 return null;
             }

Reply via email to