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

@@ -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 {