mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-12-07 13:41:08 +01:00
Use StandardCharsets.(UTF_8|US_ASCII)
This also gets rid of a ton of UnsupportedEncodingException s.
This commit is contained in:
parent
2a4d110b22
commit
d2f5efcb20
33 changed files with 125 additions and 227 deletions
|
|
@ -18,11 +18,12 @@ package org.jivesoftware.smackx.bob;
|
|||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
import org.jivesoftware.smack.packet.StreamOpen;
|
||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
|
||||
import org.jivesoftware.smackx.bob.element.BoBIQ;
|
||||
|
||||
|
|
@ -55,7 +56,7 @@ public class BoBIQTest extends SmackTestSuite {
|
|||
BoBIQ bobIQ = PacketParserUtils.parseStanza(sampleBoBIQResponse);
|
||||
|
||||
BoBHash bobHash = new BoBHash("8f35fef110ffc5df08d579a50083ff9308fb6242", "sha1");
|
||||
BoBData bobData = new BoBData("image/png", "sarasade2354j2".getBytes(StringUtils.UTF8), 86400);
|
||||
BoBData bobData = new BoBData("image/png", "sarasade2354j2".getBytes(StandardCharsets.UTF_8), 86400);
|
||||
|
||||
BoBIQ createdBoBIQ = new BoBIQ(bobHash, bobData);
|
||||
createdBoBIQ.setStanzaId("sarasa");
|
||||
|
|
|
|||
|
|
@ -20,11 +20,9 @@ import static org.jivesoftware.smack.test.util.XmlUnitUtils.assertXmlSimilar;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
|
||||
import org.jivesoftware.smackx.InitExtensions;
|
||||
|
||||
import com.jamesmurty.utils.XMLBuilder;
|
||||
|
|
@ -71,13 +69,13 @@ public class DataPacketExtensionTest extends InitExtensions {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void shouldReturnNullIfDataIsInvalid() throws UnsupportedEncodingException {
|
||||
public void shouldReturnNullIfDataIsInvalid() {
|
||||
// pad character is not at end of data
|
||||
DataPacketExtension data = new DataPacketExtension("sessionID", 0, "BBBB=CCC");
|
||||
assertNull(data.getDecodedData());
|
||||
|
||||
// invalid Base64 character
|
||||
data = new DataPacketExtension("sessionID", 0, new String(new byte[] { 123 }, StringUtils.UTF8));
|
||||
data = new DataPacketExtension("sessionID", 0, new String(new byte[] { 123 }, StandardCharsets.UTF_8));
|
||||
assertNull(data.getDecodedData());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,10 +25,10 @@ import java.io.DataInputStream;
|
|||
import java.io.DataOutputStream;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.util.NetworkUtil;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
|
||||
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream.StreamHost;
|
||||
|
||||
|
|
@ -238,7 +238,7 @@ public class Socks5ClientTest {
|
|||
// reply with full SOCKS5 message with an error code (01 = general SOCKS server
|
||||
// failure)
|
||||
out.write(new byte[] { (byte) 0x05, (byte) 0x01, (byte) 0x00, (byte) 0x03 });
|
||||
byte[] address = digest.getBytes(StringUtils.UTF8);
|
||||
byte[] address = digest.getBytes(StandardCharsets.UTF_8);
|
||||
out.write(address.length);
|
||||
out.write(address);
|
||||
out.write(new byte[] { (byte) 0x00, (byte) 0x00 });
|
||||
|
|
@ -297,7 +297,7 @@ public class Socks5ClientTest {
|
|||
out.write(new byte[] { (byte) 0x05, (byte) 0x00 });
|
||||
out.flush();
|
||||
|
||||
byte[] address = digest.getBytes(StringUtils.UTF8);
|
||||
byte[] address = digest.getBytes(StandardCharsets.UTF_8);
|
||||
|
||||
assertEquals((byte) 0x05, (byte) in.read()); // version
|
||||
assertEquals((byte) 0x01, (byte) in.read()); // connect request
|
||||
|
|
|
|||
|
|
@ -29,13 +29,12 @@ import java.net.ServerSocket;
|
|||
import java.net.Socket;
|
||||
import java.net.SocketException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
|
||||
|
|
@ -281,7 +280,7 @@ public class Socks5ProxyTest {
|
|||
proxy.start();
|
||||
|
||||
assertTrue(proxy.isRunning());
|
||||
String digest = new String(new byte[] { (byte) 0xAA }, StringUtils.UTF8);
|
||||
String digest = new String(new byte[] { (byte) 0xAA }, StandardCharsets.UTF_8);
|
||||
|
||||
// add digest to allow connection
|
||||
proxy.addTransfer(digest);
|
||||
|
|
|
|||
|
|
@ -24,13 +24,13 @@ import java.net.ServerSocket;
|
|||
import java.net.Socket;
|
||||
import java.net.SocketException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Simple SOCKS5 proxy for testing purposes. It is almost the same as the Socks5Proxy class but the
|
||||
|
|
@ -297,7 +297,7 @@ public final class Socks5TestProxy {
|
|||
byte[] connectionRequest = Socks5Utils.receiveSocks5Message(in);
|
||||
|
||||
// extract digest
|
||||
String responseDigest = new String(connectionRequest, 5, connectionRequest[4], StringUtils.UTF8);
|
||||
String responseDigest = new String(connectionRequest, 5, connectionRequest[4], StandardCharsets.UTF_8);
|
||||
|
||||
connectionRequest[1] = (byte) 0x00; // set return status to 0 (success)
|
||||
out.write(connectionRequest);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue