Remove junit.framework

Resolves #13805
This commit is contained in:
Jameson Williams
2024-11-20 00:59:40 -06:00
committed by Greyson Parrelli
parent ae46a3ab62
commit cf24b22de9
37 changed files with 183 additions and 188 deletions

View File

@@ -5,7 +5,7 @@ import org.thoughtcrime.securesms.mediasend.OrderEnforcer;
import java.util.concurrent.atomic.AtomicInteger;
import static junit.framework.Assert.assertEquals;
import static org.junit.Assert.assertEquals;
public class OrderEnforcerTest {

View File

@@ -2,9 +2,9 @@ package org.thoughtcrime.securesms.components.settings.app.subscription.boost
import android.app.Application
import android.text.SpannableStringBuilder
import junit.framework.Assert.assertEquals
import junit.framework.Assert.assertNotNull
import junit.framework.Assert.assertNull
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith

View File

@@ -1,6 +1,6 @@
package org.thoughtcrime.securesms.components.settings.app.subscription.currency
import junit.framework.Assert.assertEquals
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4

View File

@@ -1,7 +1,7 @@
package org.thoughtcrime.securesms.crypto.storage
import android.content.Context
import junit.framework.Assert.assertEquals
import org.junit.Assert.assertEquals
import org.junit.Before
import org.junit.Test
import org.mockito.Mockito.mock

View File

@@ -4,7 +4,7 @@ import org.junit.Test;
import java.util.Collections;
import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;

View File

@@ -11,7 +11,7 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Optional;
import static junit.framework.TestCase.assertEquals;
import static org.junit.Assert.assertEquals;
@RunWith(ParameterizedRobolectricTestRunner.class)
@Config(manifest = Config.NONE, application = Application.class)

View File

@@ -1,12 +1,11 @@
package org.thoughtcrime.securesms.phonenumbers;
import org.junit.Before;
import org.junit.Test;
import org.signal.core.util.logging.Log;
import org.thoughtcrime.securesms.testutil.EmptyLogger;
import static junit.framework.Assert.assertEquals;
import static org.junit.Assert.assertEquals;
public class PhoneNumberFormatterTest {
@@ -16,38 +15,38 @@ public class PhoneNumberFormatterTest {
}
@Test
public void testAddressString() throws Exception {
public void testAddressString() {
PhoneNumberFormatter formatter = new PhoneNumberFormatter("+14152222222");
assertEquals(formatter.format("bonbon"), "bonbon");
assertEquals("bonbon", formatter.format("bonbon"));
}
@Test
public void testAddressShortCode() throws Exception {
public void testAddressShortCode() {
PhoneNumberFormatter formatter = new PhoneNumberFormatter("+14152222222");
assertEquals(formatter.format("40404"), "40404");
assertEquals("40404", formatter.format("40404"));
}
@Test
public void testEmailAddress() throws Exception {
public void testEmailAddress() {
PhoneNumberFormatter formatter = new PhoneNumberFormatter("+14152222222");
assertEquals(formatter.format("junk@junk.net"), "junk@junk.net");
assertEquals("junk@junk.net", formatter.format("junk@junk.net"));
}
@Test
public void testNumberArbitrary() throws Exception {
public void testNumberArbitrary() {
PhoneNumberFormatter formatter = new PhoneNumberFormatter("+14152222222");
assertEquals(formatter.format("(415) 111-1122"), "+14151111122");
assertEquals(formatter.format("(415) 111 1123"), "+14151111123");
assertEquals(formatter.format("415-111-1124"), "+14151111124");
assertEquals(formatter.format("415.111.1125"), "+14151111125");
assertEquals(formatter.format("+1 415.111.1126"), "+14151111126");
assertEquals(formatter.format("+1 415 111 1127"), "+14151111127");
assertEquals(formatter.format("+1 (415) 111 1128"), "+14151111128");
assertEquals(formatter.format("911"), "911");
assertEquals(formatter.format("+456-7890"), "+4567890");
assertEquals("+14151111122", formatter.format("(415) 111-1122"));
assertEquals("+14151111123", formatter.format("(415) 111 1123"));
assertEquals("+14151111124", formatter.format("415-111-1124"));
assertEquals("+14151111125", formatter.format("415.111.1125"));
assertEquals("+14151111126", formatter.format("+1 415.111.1126"));
assertEquals("+14151111127", formatter.format("+1 415 111 1127"));
assertEquals("+14151111128", formatter.format("+1 (415) 111 1128"));
assertEquals("911", formatter.format("911"));
assertEquals("+4567890", formatter.format("+456-7890"));
formatter = new PhoneNumberFormatter("+442079460010");
assertEquals(formatter.format("(020) 7946 0018"), "+442079460018");
assertEquals("+442079460018", formatter.format("(020) 7946 0018"));
}
@Test
@@ -83,15 +82,15 @@ public class PhoneNumberFormatterTest {
}
@Test
public void testGroup() throws Exception {
public void testGroup() {
PhoneNumberFormatter formatter = new PhoneNumberFormatter("+14152222222");
assertEquals(formatter.format("__textsecure_group__!foobar"), "__textsecure_group__!foobar");
assertEquals("__textsecure_group__!foobar", formatter.format("__textsecure_group__!foobar"));
}
@Test
public void testLostLocalNumber() throws Exception {
public void testLostLocalNumber() {
PhoneNumberFormatter formatter = new PhoneNumberFormatter("US", true);
assertEquals(formatter.format("(415) 111-1122"), "+14151111122");
assertEquals("+14151111122", formatter.format("(415) 111-1122"));
}
@Test

View File

@@ -5,9 +5,9 @@
package org.thoughtcrime.securesms.storage
import junit.framework.TestCase.assertEquals
import okio.ByteString
import okio.ByteString.Companion.toByteString
import org.junit.Assert.assertEquals
import org.junit.Test
import org.thoughtcrime.securesms.util.Util
import org.whispersystems.signalservice.api.storage.SignalAccountRecord

View File

@@ -27,7 +27,7 @@ import java.util.Optional;
import okio.ByteString;
import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;

View File

@@ -14,7 +14,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
public final class TestHelpers {

View File

@@ -12,7 +12,7 @@ import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
import org.mockito.stubbing.Answer;
import static junit.framework.Assert.assertEquals;
import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.anyString;
public class DelimiterUtilTest {

View File

@@ -7,7 +7,7 @@ import org.junit.runners.Parameterized;
import java.util.Arrays;
import java.util.Collection;
import static junit.framework.TestCase.assertEquals;
import static org.junit.Assert.assertEquals;
@SuppressWarnings("NewClassNamingConvention")
@RunWith(Parameterized.class)

View File

@@ -1,6 +1,6 @@
package org.thoughtcrime.securesms.util
import junit.framework.TestCase
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
@@ -11,7 +11,7 @@ class LinkUtilTest_isValidPreviewUrl(private val input: String, private val outp
@Test
fun isLegal() {
TestCase.assertEquals(output, LinkUtil.isValidPreviewUrl(input))
assertEquals(output, LinkUtil.isValidPreviewUrl(input))
}
companion object {

View File

@@ -1,15 +1,14 @@
package org.thoughtcrime.securesms.util;
import junit.framework.AssertionFailedError;
import org.junit.Test;
import org.thoughtcrime.securesms.BaseUnitTest;
import org.whispersystems.signalservice.api.util.InvalidNumberException;
import org.whispersystems.signalservice.api.util.PhoneNumberFormatter;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertThrows;
public class PhoneNumberFormatterTest extends BaseUnitTest {
public class PhoneNumberFormatterTest {
private static final String LOCAL_NUMBER_US = "+15555555555";
private static final String NUMBER_CH = "+41446681800";
private static final String NUMBER_UK = "+442079460018";
@@ -20,48 +19,45 @@ public class PhoneNumberFormatterTest extends BaseUnitTest {
private static final String COUNTRY_CODE_DE = "49";
@Test
public void testFormatNumber() throws Exception, InvalidNumberException {
assertThat(PhoneNumberFormatter.formatNumber("(555) 555-5555", LOCAL_NUMBER_US)).isEqualTo(LOCAL_NUMBER_US);
assertThat(PhoneNumberFormatter.formatNumber("555-5555", LOCAL_NUMBER_US)).isEqualTo(LOCAL_NUMBER_US);
assertThat(PhoneNumberFormatter.formatNumber("(123) 555-5555", LOCAL_NUMBER_US)).isNotEqualTo(LOCAL_NUMBER_US);
public void testFormatNumber() throws InvalidNumberException {
assertEquals(LOCAL_NUMBER_US, PhoneNumberFormatter.formatNumber("(555) 555-5555", LOCAL_NUMBER_US));
assertEquals(LOCAL_NUMBER_US, PhoneNumberFormatter.formatNumber("555-5555", LOCAL_NUMBER_US));
assertNotEquals(LOCAL_NUMBER_US, PhoneNumberFormatter.formatNumber("(123) 555-5555", LOCAL_NUMBER_US));
}
@Test
public void testFormatNumberEmail() throws Exception {
try {
PhoneNumberFormatter.formatNumber("person@domain.com", LOCAL_NUMBER_US);
throw new AssertionFailedError("should have thrown on email");
} catch (InvalidNumberException ine) {
// success
}
public void testFormatNumberEmail() {
assertThrows(
"should have thrown on email",
InvalidNumberException.class,
() -> PhoneNumberFormatter.formatNumber("person@domain.com", LOCAL_NUMBER_US)
);
}
@Test
public void testFormatNumberE164() throws Exception, InvalidNumberException {
assertThat(PhoneNumberFormatter.formatE164(COUNTRY_CODE_UK, "(020) 7946 0018")).isEqualTo(NUMBER_UK);
// assertThat(PhoneNumberFormatter.formatE164(COUNTRY_CODE_UK, "044 20 7946 0018")).isEqualTo(NUMBER_UK);
assertThat(PhoneNumberFormatter.formatE164(COUNTRY_CODE_UK, "+442079460018")).isEqualTo(NUMBER_UK);
public void testFormatNumberE164() {
assertEquals(NUMBER_UK, PhoneNumberFormatter.formatE164(COUNTRY_CODE_UK, "(020) 7946 0018"));
// assertEquals(NUMBER_UK, PhoneNumberFormatter.formatE164(COUNTRY_CODE_UK, "044 20 7946 0018"));
assertEquals(NUMBER_UK, PhoneNumberFormatter.formatE164(COUNTRY_CODE_UK, "+442079460018"));
assertThat(PhoneNumberFormatter.formatE164(COUNTRY_CODE_CH, "+41 44 668 18 00")).isEqualTo(NUMBER_CH);
assertThat(PhoneNumberFormatter.formatE164(COUNTRY_CODE_CH, "+41 (044) 6681800")).isEqualTo(NUMBER_CH);
assertEquals(NUMBER_CH, PhoneNumberFormatter.formatE164(COUNTRY_CODE_CH, "+41 44 668 18 00"));
assertEquals(NUMBER_CH, PhoneNumberFormatter.formatE164(COUNTRY_CODE_CH, "+41 (044) 6681800"));
assertThat(PhoneNumberFormatter.formatE164(COUNTRY_CODE_DE, "0049 030 123456")).isEqualTo(NUMBER_DE);
assertThat(PhoneNumberFormatter.formatE164(COUNTRY_CODE_DE, "0049 (0)30123456")).isEqualTo(NUMBER_DE);
assertThat(PhoneNumberFormatter.formatE164(COUNTRY_CODE_DE, "0049((0)30)123456")).isEqualTo(NUMBER_DE);
assertThat(PhoneNumberFormatter.formatE164(COUNTRY_CODE_DE, "+49 (0) 30 1 2 3 45 6 ")).isEqualTo(NUMBER_DE);
assertThat(PhoneNumberFormatter.formatE164(COUNTRY_CODE_DE, "030 123456")).isEqualTo(NUMBER_DE);
assertEquals(NUMBER_DE, PhoneNumberFormatter.formatE164(COUNTRY_CODE_DE, "0049 030 123456"));
assertEquals(NUMBER_DE, PhoneNumberFormatter.formatE164(COUNTRY_CODE_DE, "0049 (0)30123456"));
assertEquals(NUMBER_DE, PhoneNumberFormatter.formatE164(COUNTRY_CODE_DE, "0049((0)30)123456"));
assertEquals(NUMBER_DE, PhoneNumberFormatter.formatE164(COUNTRY_CODE_DE, "+49 (0) 30 1 2 3 45 6 "));
assertEquals(NUMBER_DE, PhoneNumberFormatter.formatE164(COUNTRY_CODE_DE, "030 123456"));
assertThat(PhoneNumberFormatter.formatE164(COUNTRY_CODE_DE, "0171123456")).isEqualTo(NUMBER_MOBILE_DE);
assertThat(PhoneNumberFormatter.formatE164(COUNTRY_CODE_DE, "0171/123456")).isEqualTo(NUMBER_MOBILE_DE);
assertThat(PhoneNumberFormatter.formatE164(COUNTRY_CODE_DE, "+490171/123456")).isEqualTo(NUMBER_MOBILE_DE);
assertThat(PhoneNumberFormatter.formatE164(COUNTRY_CODE_DE, "00490171/123456")).isEqualTo(NUMBER_MOBILE_DE);
assertThat(PhoneNumberFormatter.formatE164(COUNTRY_CODE_DE, "0049171/123456")).isEqualTo(NUMBER_MOBILE_DE);
assertEquals(NUMBER_MOBILE_DE, PhoneNumberFormatter.formatE164(COUNTRY_CODE_DE, "0171123456"));
assertEquals(NUMBER_MOBILE_DE, PhoneNumberFormatter.formatE164(COUNTRY_CODE_DE, "0171/123456"));
assertEquals(NUMBER_MOBILE_DE, PhoneNumberFormatter.formatE164(COUNTRY_CODE_DE, "+490171/123456"));
assertEquals(NUMBER_MOBILE_DE, PhoneNumberFormatter.formatE164(COUNTRY_CODE_DE, "00490171/123456"));
assertEquals(NUMBER_MOBILE_DE, PhoneNumberFormatter.formatE164(COUNTRY_CODE_DE, "0049171/123456"));
}
@Test
public void testFormatRemoteNumberE164() throws Exception, InvalidNumberException {
assertThat(PhoneNumberFormatter.formatNumber("+4402079460018", LOCAL_NUMBER_US)).isEqualTo(NUMBER_UK);
public void testFormatRemoteNumberE164() throws InvalidNumberException {
assertEquals(NUMBER_UK, PhoneNumberFormatter.formatNumber("+4402079460018", LOCAL_NUMBER_US));
}
}

View File

@@ -11,7 +11,7 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.thoughtcrime.securesms.testutil.TestHelpers.mapOf;

View File

@@ -10,7 +10,7 @@ import org.thoughtcrime.securesms.testutil.EmptyLogger;
import java.util.Arrays;
import java.util.Collection;
import static junit.framework.TestCase.assertEquals;
import static org.junit.Assert.assertEquals;
@RunWith(Parameterized.class)
public class RemoteExpirationTest_getTimeUntilDeprecation {

View File

@@ -17,18 +17,17 @@
package org.thoughtcrime.securesms.util;
import junit.framework.AssertionFailedError;
import org.junit.Test;
import org.thoughtcrime.securesms.BaseUnitTest;
import java.net.URISyntaxException;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThrows;
public class Rfc5724UriTest extends BaseUnitTest {
@Test public void testInvalidPath() throws Exception {
@Test public void testInvalidPath() {
final String[] invalidSchemaUris = {
"",
":",
@@ -39,12 +38,11 @@ public class Rfc5724UriTest extends BaseUnitTest {
};
for (String uri : invalidSchemaUris) {
try {
new Rfc5724Uri(uri);
throw new AssertionFailedError("URISyntaxException should be thrown");
} catch (URISyntaxException e) {
// success
}
assertThrows(
"URISyntaxException should be thrown",
URISyntaxException.class,
() -> new Rfc5724Uri(uri)
);
}
}
@@ -59,7 +57,7 @@ public class Rfc5724UriTest extends BaseUnitTest {
for (String[] uriTestPair : uriTestPairs) {
final Rfc5724Uri testUri = new Rfc5724Uri(uriTestPair[0]);
assertTrue(testUri.getSchema().equals(uriTestPair[1]));
assertEquals(uriTestPair[1], testUri.getSchema());
}
}
@@ -78,7 +76,7 @@ public class Rfc5724UriTest extends BaseUnitTest {
for (String[] uriTestPair : uriTestPairs) {
final Rfc5724Uri testUri = new Rfc5724Uri(uriTestPair[0]);
assertTrue(testUri.getPath().equals(uriTestPair[1]));
assertEquals(uriTestPair[1], testUri.getPath());
}
}
@@ -97,9 +95,7 @@ public class Rfc5724UriTest extends BaseUnitTest {
for (String[] uriTestPair : uriTestPairs) {
final Rfc5724Uri testUri = new Rfc5724Uri(uriTestPair[0]);
final String paramResult = testUri.getQueryParams().get(uriTestPair[1]);
if (paramResult == null) assertTrue(uriTestPair[2] == null);
else assertTrue(paramResult.equals(uriTestPair[2]));
assertEquals(uriTestPair[2], paramResult);
}
}
}

View File

@@ -7,7 +7,7 @@ import org.junit.runners.Parameterized;
import java.util.Arrays;
import java.util.Collection;
import static junit.framework.TestCase.assertEquals;
import static org.junit.Assert.assertEquals;
@RunWith(Parameterized.class)
public class SemanticVersionTest_compareTo {

View File

@@ -7,7 +7,7 @@ import org.junit.runners.Parameterized;
import java.util.Arrays;
import java.util.Collection;
import static junit.framework.TestCase.assertEquals;
import static org.junit.Assert.assertEquals;
@RunWith(Parameterized.class)
public class SemanticVersionTest_parse {

View File

@@ -2,8 +2,8 @@ package org.thoughtcrime.securesms.util;
import org.junit.Test;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public class ShortCodeUtilTest {

View File

@@ -5,8 +5,8 @@ import androidx.test.core.app.ApplicationProvider
import io.mockk.every
import io.mockk.mockkObject
import io.mockk.unmockkAll
import junit.framework.TestCase
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@@ -39,7 +39,7 @@ class SignalMeUtilText_parseE164FromLink(private val input: String?, private val
@Test
fun parse() {
TestCase.assertEquals(output, parseE164FromLink(application, input))
assertEquals(output, parseE164FromLink(application, input))
}
companion object {

View File

@@ -7,7 +7,7 @@ import org.junit.runners.Parameterized;
import java.util.Arrays;
import java.util.Collection;
import static junit.framework.TestCase.assertEquals;
import static org.junit.Assert.assertEquals;
@RunWith(Parameterized.class)
public class SignalProxyUtilText_convertUserEnteredAddressToHost {

View File

@@ -7,7 +7,7 @@ import org.junit.runners.Parameterized;
import java.util.Arrays;
import java.util.Collection;
import static junit.framework.TestCase.assertEquals;
import static org.junit.Assert.assertEquals;
@RunWith(Parameterized.class)
public class SignalProxyUtilText_generateProxyUrl {

View File

@@ -7,7 +7,7 @@ import org.junit.runners.Parameterized;
import java.util.Arrays;
import java.util.Collection;
import static junit.framework.TestCase.assertEquals;
import static org.junit.Assert.assertEquals;
@RunWith(Parameterized.class)
public class SignalProxyUtilText_parseHostFromProxyDeepLink {