Tiny micro optimization on test data generation

This commit is contained in:
Trustin Lee 2008-08-29 00:26:54 +00:00
parent 8da05713fe
commit 79743b0528
3 changed files with 9 additions and 18 deletions

View File

@ -45,8 +45,6 @@ import org.jboss.netty.channel.ChannelStateEvent;
import org.jboss.netty.channel.ExceptionEvent; import org.jboss.netty.channel.ExceptionEvent;
import org.jboss.netty.channel.MessageEvent; import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.SimpleChannelHandler; import org.jboss.netty.channel.SimpleChannelHandler;
import org.jboss.netty.handler.codec.serialization.CompatibleObjectDecoder;
import org.jboss.netty.handler.codec.serialization.CompatibleObjectEncoder;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
@ -69,13 +67,12 @@ public abstract class AbstractSocketCompatibleObjectStreamEchoTest {
static { static {
for (int i = 0; i < data.length; i ++) { for (int i = 0; i < data.length; i ++) {
int eLen = random.nextInt(512); int eLen = random.nextInt(512);
StringBuilder e = new StringBuilder(eLen); char[] e = new char[eLen];
for (int j = 0; j < eLen; j ++) { for (int j = 0; j < eLen; j ++) {
e.append((char) ('a' + random.nextInt(26))); e[j] = (char) ('a' + random.nextInt(26));
} }
data[i] = e.toString(); data[i] = new String(e);
} }
} }

View File

@ -45,8 +45,6 @@ import org.jboss.netty.channel.ChannelStateEvent;
import org.jboss.netty.channel.ExceptionEvent; import org.jboss.netty.channel.ExceptionEvent;
import org.jboss.netty.channel.MessageEvent; import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.SimpleChannelHandler; import org.jboss.netty.channel.SimpleChannelHandler;
import org.jboss.netty.handler.codec.serialization.ObjectDecoder;
import org.jboss.netty.handler.codec.serialization.ObjectEncoder;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
@ -69,13 +67,12 @@ public abstract class AbstractSocketObjectStreamEchoTest {
static { static {
for (int i = 0; i < data.length; i ++) { for (int i = 0; i < data.length; i ++) {
int eLen = random.nextInt(512); int eLen = random.nextInt(512);
StringBuilder e = new StringBuilder(eLen); char[] e = new char[eLen];
for (int j = 0; j < eLen; j ++) { for (int j = 0; j < eLen; j ++) {
e.append((char) ('a' + random.nextInt(26))); e[j] = (char) ('a' + random.nextInt(26));
} }
data[i] = e.toString(); data[i] = new String(e);
} }
} }

View File

@ -47,8 +47,6 @@ import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.SimpleChannelHandler; import org.jboss.netty.channel.SimpleChannelHandler;
import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder; import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder;
import org.jboss.netty.handler.codec.frame.Delimiters; import org.jboss.netty.handler.codec.frame.Delimiters;
import org.jboss.netty.handler.codec.string.StringDecoder;
import org.jboss.netty.handler.codec.string.StringEncoder;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
@ -71,13 +69,12 @@ public abstract class AbstractSocketStringEchoTest {
static { static {
for (int i = 0; i < data.length; i ++) { for (int i = 0; i < data.length; i ++) {
int eLen = random.nextInt(512); int eLen = random.nextInt(512);
StringBuilder e = new StringBuilder(eLen); char[] e = new char[eLen];
for (int j = 0; j < eLen; j ++) { for (int j = 0; j < eLen; j ++) {
e.append((char) ('a' + random.nextInt(26))); e[j] = (char) ('a' + random.nextInt(26));
} }
data[i] = e.toString(); data[i] = new String(e);
} }
} }