forked from I2P_Developers/i2p.i2p
Replaces instances of getBytes() in apps classes
This commit is contained in:
@ -40,12 +40,12 @@ public class TestCreateSessionDatagram {
|
||||
try {
|
||||
Socket s = new Socket(host, port);
|
||||
OutputStream out = s.getOutputStream();
|
||||
out.write("HELLO VERSION MIN=1.0 MAX=1.0\n".getBytes());
|
||||
out.write(DataHelper.getASCII("HELLO VERSION MIN=1.0 MAX=1.0\n"));
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(s.getInputStream()));
|
||||
String line = reader.readLine();
|
||||
_log.debug("line read for valid version: " + line);
|
||||
String req = "SESSION CREATE STYLE=DATAGRAM DESTINATION=" + destName + " " + conOptions + "\n";
|
||||
out.write(req.getBytes());
|
||||
out.write(DataHelper.getASCII(req));
|
||||
line = reader.readLine();
|
||||
_log.info("Response to creating the session with destination " + destName + ": " + line);
|
||||
_log.debug("The above should contain SESSION STATUS RESULT=OK\n\n\n");
|
||||
|
@ -56,12 +56,12 @@ public class TestCreateSessionRaw {
|
||||
try {
|
||||
Socket s = new Socket(host, port);
|
||||
OutputStream out = s.getOutputStream();
|
||||
out.write("HELLO VERSION MIN=1.0 MAX=1.0\n".getBytes());
|
||||
out.write(DataHelper.getASCII("HELLO VERSION MIN=1.0 MAX=1.0\n"));
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(s.getInputStream()));
|
||||
String line = reader.readLine();
|
||||
//_log.debug("line read for valid version: " + line);
|
||||
String req = "SESSION CREATE STYLE=RAW DESTINATION=" + destName + " " + conOptions + "\n";
|
||||
out.write(req.getBytes());
|
||||
out.write(DataHelper.getASCII(req));
|
||||
line = reader.readLine();
|
||||
_log.info("Response to creating the session with destination " + destName + ": " + line);
|
||||
_log.debug("The above should contain SESSION STATUS RESULT=OK");
|
||||
|
@ -5,6 +5,7 @@ import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.util.Log;
|
||||
|
||||
public class TestCreateSessionStream {
|
||||
@ -40,12 +41,12 @@ public class TestCreateSessionStream {
|
||||
try {
|
||||
Socket s = new Socket(host, port);
|
||||
OutputStream out = s.getOutputStream();
|
||||
out.write("HELLO VERSION MIN=1.0 MAX=1.0\n".getBytes());
|
||||
out.write(DataHelper.getASCII("HELLO VERSION MIN=1.0 MAX=1.0\n"));
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(s.getInputStream()));
|
||||
String line = reader.readLine();
|
||||
_log.debug("line read for valid version: " + line);
|
||||
String req = "SESSION CREATE STYLE=STREAM DESTINATION=" + destName + " " + conOptions + "\n";
|
||||
out.write(req.getBytes());
|
||||
out.write(DataHelper.getASCII(req));
|
||||
line = reader.readLine();
|
||||
_log.info("Response to creating the session with destination " + destName + ": " + line);
|
||||
_log.debug("The above should contain SESSION STATUS RESULT=OK\n\n\n");
|
||||
|
@ -7,6 +7,7 @@ import java.net.Socket;
|
||||
import java.util.Properties;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.util.Log;
|
||||
|
||||
public class TestDatagramTransfer {
|
||||
@ -22,17 +23,17 @@ public class TestDatagramTransfer {
|
||||
try {
|
||||
Socket s = new Socket(host, port);
|
||||
OutputStream out = s.getOutputStream();
|
||||
out.write("HELLO VERSION MIN=1.0 MAX=1.0\n".getBytes());
|
||||
out.write(DataHelper.getASCII("HELLO VERSION MIN=1.0 MAX=1.0\n"));
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(s.getInputStream()));
|
||||
String line = reader.readLine();
|
||||
_log.debug("line read for valid version: " + line);
|
||||
String req = "SESSION CREATE STYLE=DATAGRAM DESTINATION=" + destName + " " + conOptions + "\n";
|
||||
out.write(req.getBytes());
|
||||
out.write(DataHelper.getASCII(req));
|
||||
line = reader.readLine();
|
||||
_log.info("Response to creating the session with destination " + destName + ": " + line);
|
||||
_log.debug("The above should contain SESSION STATUS RESULT=OK\n\n\n");
|
||||
String lookup = "NAMING LOOKUP NAME=ME\n";
|
||||
out.write(lookup.getBytes());
|
||||
out.write(DataHelper.getASCII(lookup));
|
||||
line = reader.readLine();
|
||||
_log.info("Response from the lookup for ME: " + line);
|
||||
_log.debug("The above should be a NAMING REPLY");
|
||||
@ -50,7 +51,7 @@ public class TestDatagramTransfer {
|
||||
}
|
||||
|
||||
String send = "DATAGRAM SEND DESTINATION=" + value + " SIZE=3\nYo!";
|
||||
out.write(send.getBytes());
|
||||
out.write(DataHelper.getASCII(send));
|
||||
line = reader.readLine();
|
||||
tok = new StringTokenizer(line);
|
||||
maj = tok.nextToken();
|
||||
|
@ -19,17 +19,17 @@ public class TestDest {
|
||||
try {
|
||||
Socket s = new Socket(host, port);
|
||||
OutputStream out = s.getOutputStream();
|
||||
out.write("HELLO VERSION MIN=1.0 MAX=1.0\n".getBytes());
|
||||
out.write(DataHelper.getASCII("HELLO VERSION MIN=1.0 MAX=1.0\n"));
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(s.getInputStream()));
|
||||
String line = reader.readLine();
|
||||
_log.debug("line read for valid version: " + line);
|
||||
String req = "SESSION CREATE STYLE=STREAM DESTINATION=testNaming " + conOptions + "\n";
|
||||
out.write(req.getBytes());
|
||||
out.write(DataHelper.getASCII(req));
|
||||
line = reader.readLine();
|
||||
_log.debug("Response to creating the session with destination testNaming: " + line);
|
||||
_log.debug("The above should contain SESSION STATUS RESULT=OK\n\n\n");
|
||||
String lookup = "DEST GENERATE\n";
|
||||
out.write(lookup.getBytes());
|
||||
out.write(DataHelper.getASCII(lookup));
|
||||
line = reader.readLine();
|
||||
_log.info("Response from the dest generate: " + line);
|
||||
_log.debug("The abouve should be a DEST REPLY");
|
||||
|
@ -5,6 +5,7 @@ import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.util.Log;
|
||||
|
||||
public class TestHello {
|
||||
@ -21,7 +22,7 @@ public class TestHello {
|
||||
try {
|
||||
Socket s = new Socket(host, port);
|
||||
OutputStream out = s.getOutputStream();
|
||||
out.write("HELLO VERSION MIN=1.0 MAX=1.0\n".getBytes());
|
||||
out.write(DataHelper.getASCII("HELLO VERSION MIN=1.0 MAX=1.0\n"));
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(s.getInputStream()));
|
||||
String line = reader.readLine();
|
||||
_log.info("line read for valid version: " + line);
|
||||
@ -36,7 +37,7 @@ public class TestHello {
|
||||
try {
|
||||
Socket s = new Socket(host, port);
|
||||
OutputStream out = s.getOutputStream();
|
||||
out.write("HELLO VERSION MIN=9.0 MAX=8.3\n".getBytes());
|
||||
out.write(DataHelper.getASCII("HELLO VERSION MIN=9.0 MAX=8.3\n"));
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(s.getInputStream()));
|
||||
String line = reader.readLine();
|
||||
_log.info("line read for invalid version: " + line);
|
||||
@ -51,7 +52,7 @@ public class TestHello {
|
||||
try {
|
||||
Socket s = new Socket(host, port);
|
||||
OutputStream out = s.getOutputStream();
|
||||
out.write("HELLO h0 h0 h0\n".getBytes());
|
||||
out.write(DataHelper.getASCII("HELLO h0 h0 h0\n"));
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(s.getInputStream()));
|
||||
String line = reader.readLine();
|
||||
_log.info("line read for valid version: " + line);
|
||||
|
@ -39,17 +39,17 @@ public class TestNaming {
|
||||
try {
|
||||
Socket s = new Socket(host, port);
|
||||
OutputStream out = s.getOutputStream();
|
||||
out.write("HELLO VERSION MIN=1.0 MAX=1.0\n".getBytes());
|
||||
out.write(DataHelper.getASCII("HELLO VERSION MIN=1.0 MAX=1.0\n"));
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(s.getInputStream()));
|
||||
String line = reader.readLine();
|
||||
_log.debug("line read for valid version: " + line);
|
||||
String req = "SESSION CREATE STYLE=STREAM DESTINATION=testNaming " + conOptions + "\n";
|
||||
out.write(req.getBytes());
|
||||
out.write(DataHelper.getASCII(req));
|
||||
line = reader.readLine();
|
||||
_log.debug("Response to creating the session with destination testNaming: " + line);
|
||||
_log.debug("The above should contain SESSION STATUS RESULT=OK\n\n\n");
|
||||
String lookup = "NAMING LOOKUP NAME=" + name + "\n";
|
||||
out.write(lookup.getBytes());
|
||||
out.write(DataHelper.getASCII(lookup));
|
||||
line = reader.readLine();
|
||||
_log.info("Response from the lookup for [" + name +"]: " + line);
|
||||
_log.debug("The abouve should be a NAMING REPLY");
|
||||
|
@ -22,17 +22,17 @@ public class TestRawTransfer {
|
||||
try {
|
||||
Socket s = new Socket(host, port);
|
||||
OutputStream out = s.getOutputStream();
|
||||
out.write("HELLO VERSION MIN=1.0 MAX=1.0\n".getBytes());
|
||||
out.write(DataHelper.getASCII("HELLO VERSION MIN=1.0 MAX=1.0\n"));
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(s.getInputStream()));
|
||||
String line = reader.readLine();
|
||||
_log.debug("line read for valid version: " + line);
|
||||
String req = "SESSION CREATE STYLE=RAW DESTINATION=" + destName + " " + conOptions + "\n";
|
||||
out.write(req.getBytes());
|
||||
out.write(DataHelper.getASCII(req));
|
||||
line = reader.readLine();
|
||||
_log.info("Response to creating the session with destination " + destName + ": " + line);
|
||||
_log.debug("The above should contain SESSION STATUS RESULT=OK\n\n\n");
|
||||
String lookup = "NAMING LOOKUP NAME=ME\n";
|
||||
out.write(lookup.getBytes());
|
||||
out.write(DataHelper.getASCII(lookup));
|
||||
line = reader.readLine();
|
||||
_log.info("Response from the lookup for ME: " + line);
|
||||
_log.debug("The above should be a NAMING REPLY");
|
||||
@ -50,7 +50,7 @@ public class TestRawTransfer {
|
||||
}
|
||||
|
||||
String send = "RAW SEND DESTINATION=" + value + " SIZE=3\nYo!";
|
||||
out.write(send.getBytes());
|
||||
out.write(DataHelper.getASCII(send));
|
||||
line = reader.readLine();
|
||||
try {
|
||||
tok = new StringTokenizer(line);
|
||||
|
@ -11,6 +11,7 @@ import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.util.I2PThread;
|
||||
import net.i2p.util.Log;
|
||||
|
||||
@ -62,17 +63,17 @@ public class TestStreamTransfer {
|
||||
try {
|
||||
Socket s = new Socket(host, port);
|
||||
OutputStream out = s.getOutputStream();
|
||||
out.write("HELLO VERSION MIN=1.0 MAX=1.0\n".getBytes());
|
||||
out.write(DataHelper.getASCII("HELLO VERSION MIN=1.0 MAX=1.0\n"));
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(s.getInputStream()));
|
||||
String line = reader.readLine();
|
||||
_log.debug("line read for valid version: " + line);
|
||||
String req = "SESSION CREATE STYLE=STREAM DESTINATION=Alice " + conOptions + "\n";
|
||||
out.write(req.getBytes());
|
||||
out.write(DataHelper.getASCII(req));
|
||||
line = reader.readLine();
|
||||
_log.info("Response to creating the session with destination Alice: " + line);
|
||||
|
||||
req = "NAMING LOOKUP NAME=ME\n";
|
||||
out.write(req.getBytes());
|
||||
out.write(DataHelper.getASCII(req));
|
||||
line = reader.readLine();
|
||||
StringTokenizer tok = new StringTokenizer(line);
|
||||
String maj = tok.nextToken();
|
||||
@ -212,16 +213,16 @@ public class TestStreamTransfer {
|
||||
try {
|
||||
Socket s = new Socket(host, port);
|
||||
OutputStream out = s.getOutputStream();
|
||||
out.write("HELLO VERSION MIN=1.0 MAX=1.0\n".getBytes());
|
||||
out.write(DataHelper.getASCII("HELLO VERSION MIN=1.0 MAX=1.0\n"));
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(s.getInputStream()));
|
||||
String line = reader.readLine();
|
||||
_log.debug("line read for valid version: " + line);
|
||||
String req = "SESSION CREATE STYLE=STREAM DESTINATION=" + sessionName + " " + conOptions + "\n";
|
||||
out.write(req.getBytes());
|
||||
out.write(DataHelper.getASCII(req));
|
||||
line = reader.readLine();
|
||||
_log.info("Response to creating the session with destination "+ sessionName+": " + line);
|
||||
req = "STREAM CONNECT ID=42 DESTINATION=" + _alice + "\n";
|
||||
out.write(req.getBytes());
|
||||
out.write(DataHelper.getASCII(req));
|
||||
line = reader.readLine();
|
||||
_log.info("Response to the stream connect from "+sessionName+" to Alice: " + line);
|
||||
StringTokenizer tok = new StringTokenizer(line);
|
||||
@ -238,18 +239,18 @@ public class TestStreamTransfer {
|
||||
try { Thread.sleep(5*1000) ; } catch (InterruptedException ie) {}
|
||||
req = "STREAM SEND ID=42 SIZE=10\nBlahBlah!!";
|
||||
_log.info("\n** Sending BlahBlah!!");
|
||||
out.write(req.getBytes());
|
||||
out.write(DataHelper.getASCII(req));
|
||||
out.flush();
|
||||
try { Thread.sleep(5*1000) ; } catch (InterruptedException ie) {}
|
||||
req = "STREAM SEND ID=42 SIZE=10\nFooBarBaz!";
|
||||
_log.info("\n** Sending FooBarBaz!");
|
||||
out.write(req.getBytes());
|
||||
out.write(DataHelper.getASCII(req));
|
||||
out.flush();
|
||||
/* Don't delay here, so we can test whether all data is
|
||||
sent even if we do a STREAM CLOSE immediately. */
|
||||
_log.info("Sending close");
|
||||
req = "STREAM CLOSE ID=42\n";
|
||||
out.write(req.getBytes());
|
||||
out.write(DataHelper.getASCII(req));
|
||||
out.flush();
|
||||
synchronized (_counterLock) {
|
||||
_closeCounter++;
|
||||
|
@ -140,7 +140,7 @@ public class TestSwarm {
|
||||
private String handshake() {
|
||||
synchronized (_samOut) {
|
||||
try {
|
||||
_samOut.write("HELLO VERSION MIN=1.0 MAX=1.0\n".getBytes());
|
||||
_samOut.write(DataHelper.getASCII("HELLO VERSION MIN=1.0 MAX=1.0\n"));
|
||||
_samOut.flush();
|
||||
_log.debug("Hello sent");
|
||||
boolean ok = _eventHandler.waitForHelloReply();
|
||||
@ -148,14 +148,14 @@ public class TestSwarm {
|
||||
if (!ok)
|
||||
throw new IOException("wtf, hello failed?");
|
||||
String req = "SESSION CREATE STYLE=STREAM DESTINATION=" + _destFile + " " + _conOptions + "\n";
|
||||
_samOut.write(req.getBytes());
|
||||
_samOut.write(DataHelper.getUTF8(req));
|
||||
_samOut.flush();
|
||||
_log.debug("Session create sent");
|
||||
ok = _eventHandler.waitForSessionCreateReply();
|
||||
_log.debug("Session create reply found: " + ok);
|
||||
|
||||
req = "NAMING LOOKUP NAME=ME\n";
|
||||
_samOut.write(req.getBytes());
|
||||
_samOut.write(DataHelper.getASCII(req));
|
||||
_samOut.flush();
|
||||
_log.debug("Naming lookup sent");
|
||||
String destination = _eventHandler.waitForNamingReply("ME");
|
||||
@ -177,7 +177,7 @@ public class TestSwarm {
|
||||
private boolean writeDest(String dest) {
|
||||
try {
|
||||
FileOutputStream fos = new FileOutputStream(_destFile);
|
||||
fos.write(dest.getBytes());
|
||||
fos.write(DataHelper.getASCII(dest));
|
||||
fos.close();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
@ -203,7 +203,7 @@ public class TestSwarm {
|
||||
_remotePeers.put(new Integer(con), flooder);
|
||||
}
|
||||
|
||||
byte msg[] = ("STREAM CONNECT ID=" + con + " DESTINATION=" + remDest + "\n").getBytes();
|
||||
byte msg[] = (DataHelper.getUTF8("STREAM CONNECT ID=" + con + " DESTINATION=" + remDest + "\n"));
|
||||
synchronized (_samOut) {
|
||||
_samOut.write(msg);
|
||||
_samOut.flush();
|
||||
@ -257,7 +257,7 @@ public class TestSwarm {
|
||||
long value = 0;
|
||||
long lastSend = _context.clock().now();
|
||||
while (!_closed) {
|
||||
byte msg[] = ("STREAM SEND ID=" + _connectionId + " SIZE=" + data.length + "\n").getBytes();
|
||||
byte msg[] = (DataHelper.getASCII("STREAM SEND ID=" + _connectionId + " SIZE=" + data.length + "\n"));
|
||||
DataHelper.toLong(data, 0, 4, value);
|
||||
try {
|
||||
synchronized (_samOut) {
|
||||
|
Reference in New Issue
Block a user