You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2011/10/22 23:23:12 UTC
svn commit: r1187806 [3/5] - in /tomcat/trunk/test: javax/el/
javax/servlet/jsp/ org/apache/catalina/authenticator/
org/apache/catalina/connector/ org/apache/catalina/core/
org/apache/catalina/deploy/ org/apache/catalina/filters/
org/apache/catalina/ha...
Modified: tomcat/trunk/test/org/apache/catalina/tribes/demos/CoordinationDemo.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribes/demos/CoordinationDemo.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/tribes/demos/CoordinationDemo.java (original)
+++ tomcat/trunk/test/org/apache/catalina/tribes/demos/CoordinationDemo.java Sat Oct 22 21:23:07 2011
@@ -47,13 +47,13 @@ public class CoordinationDemo {
public CoordinationDemo() {
// Default constructor
}
-
+
public void init() {
reader = new BufferedReader(new InputStreamReader(System.in));
status = new Status[CHANNEL_COUNT];
}
-
-
+
+
public void clearScreen() {
StringBuilder buf = new StringBuilder(700);
for (int i=0; i<CLEAR_SCREEN; i++ ) buf.append("\n");
@@ -68,7 +68,7 @@ public class CoordinationDemo {
System.out.println("\tquit");
System.out.print("Enter command:");
}
-
+
public synchronized void printScreen() {
clearScreen();
System.out.println(" ###."+getHeader());
@@ -79,9 +79,9 @@ public class CoordinationDemo {
System.out.println("\n\n");
System.out.println("Overall status:"+statusLine);
printMenuOptions();
-
+
}
-
+
public String getHeader() {
//member - 30
//running- 10
@@ -96,19 +96,19 @@ public class CoordinationDemo {
buf.append(leftfill("View-id(short)",24," "));
buf.append(leftfill("Count",8," "));
buf.append("\n");
-
+
buf.append(rightfill("==="+new java.sql.Timestamp(System.currentTimeMillis()).toString(),SCREEN_WIDTH,"="));
buf.append("\n");
return buf.toString();
}
-
+
public String[] tokenize(String line) {
StringTokenizer tz = new StringTokenizer(line," ");
String[] result = new String[tz.countTokens()];
for (int i=0; i<result.length; i++ ) result[i] = tz.nextToken();
return result;
}
-
+
public void waitForInput() throws IOException {
for ( int i=0; i<status.length; i++ ) status[i] = new Status(this);
printScreen();
@@ -150,7 +150,7 @@ public class CoordinationDemo {
}
for (int i = 0; i < status.length; i++) if (MULTI_THREAD ) t[i].start(); else t[i].run();
setSystemStatus("System stopped.");
- } else {
+ } else {
int index = -1;
try { index = Integer.parseInt(args[1])-1;}catch ( Exception x ) {setSystemStatus("Invalid index:"+args[1]);}
if ( index >= 0 ) {
@@ -176,7 +176,7 @@ public class CoordinationDemo {
}
for (int i = 0; i < status.length; i++) if (MULTI_THREAD ) t[i].start(); else t[i].run();
setSystemStatus("System started.");
- } else {
+ } else {
int index = -1;
try { index = Integer.parseInt(args[1])-1;}catch ( Exception x ) {setSystemStatus("Invalid index:"+args[1]);}
if ( index >= 0 ) {
@@ -201,7 +201,7 @@ public class CoordinationDemo {
VIEW_EVENTS[idx] = true;
}
}
-
+
public static void run(String[] args,CoordinationDemo demo) throws Exception {
usage();
java.util.Arrays.fill(VIEW_EVENTS,true);
@@ -221,7 +221,7 @@ public class CoordinationDemo {
}
demo.init();
demo.waitForInput();
- }
+ }
private static void usage() {
System.out.println("Usage:");
@@ -237,14 +237,14 @@ public class CoordinationDemo {
CoordinationDemo demo = new CoordinationDemo();
run(args,demo);
}
-
+
public static String leftfill(String value, int length, String ch) {
return fill(value,length,ch,true);
}
-
+
public static String rightfill(String value, int length, String ch) {
return fill(value,length,ch,false);
- }
+ }
public static String fill(String value, int length, String ch, boolean left) {
StringBuilder buf = new StringBuilder();
@@ -253,8 +253,8 @@ public class CoordinationDemo {
if ( left ) buf.append(value.trim());
return buf.toString();
}
-
-
+
+
public static class Status {
public CoordinationDemo parent;
public GroupChannel channel;
@@ -262,11 +262,11 @@ public class CoordinationDemo {
public String status;
public Exception error;
public String startstatus = "new";
-
+
public Status(CoordinationDemo parent) {
this.parent = parent;
}
-
+
public String getStatusLine() {
//member - 30
//running- 10
@@ -297,12 +297,12 @@ public class CoordinationDemo {
buf.append("\n");
return buf.toString();
}
-
+
public String getByteString(byte[] b) {
if ( b == null ) return "{}";
return Arrays.toString(b,0,Math.min(b.length,4));
}
-
+
public void start() {
try {
if ( channel == null ) {
@@ -329,7 +329,7 @@ public class CoordinationDemo {
interceptor = null;
}
}
-
+
public void stop() {
try {
if ( channel != null ) {
@@ -353,7 +353,7 @@ public class CoordinationDemo {
interceptor = null;
}
}
-
+
public GroupChannel createChannel() {
channel = new GroupChannel();
((ReceiverBase)channel.getChannelReceiver()).setAutoBind(100);
Modified: tomcat/trunk/test/org/apache/catalina/tribes/demos/EchoRpcTest.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribes/demos/EchoRpcTest.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/tribes/demos/EchoRpcTest.java (original)
+++ tomcat/trunk/test/org/apache/catalina/tribes/demos/EchoRpcTest.java Sat Oct 22 21:23:07 2011
@@ -37,7 +37,7 @@ import org.apache.catalina.tribes.group.
* @version 1.0
*/
public class EchoRpcTest implements RpcCallback, Runnable {
-
+
Channel channel;
int count;
String message;
@@ -46,7 +46,7 @@ public class EchoRpcTest implements RpcC
int options;
long timeout;
String name;
-
+
public EchoRpcTest(Channel channel, String name, int count, String message, long pause, int options, long timeout) {
this.channel = channel;
this.count = count;
@@ -85,7 +85,7 @@ public class EchoRpcTest implements RpcC
System.out.println("Received a reply request message from ["+sender.getName()+"] with data ["+msg+"]");
return "Reply("+name+"):"+msg;
}
-
+
@Override
public void run() {
long counter = 0;
@@ -105,7 +105,7 @@ public class EchoRpcTest implements RpcC
}
}
}
-
+
public static void usage() {
System.out.println("Tribes RPC tester.");
System.out.println("Usage:\n\t"+
@@ -127,7 +127,7 @@ public class EchoRpcTest implements RpcC
"java EchoRpcTest -bind 192.168.0.45 -port 4005\n\t"+
"java EchoRpcTest -bind 192.168.0.45 -port 4005 -mbind 192.168.0.45 -count 100 -stats 10\n");
}
-
+
public static void main(String[] args) throws Exception {
long pause = 3000;
int count = 1000000;
@@ -170,24 +170,24 @@ public class EchoRpcTest implements RpcC
System.exit(1);
}
}
-
-
+
+
ManagedChannel channel = (ManagedChannel)ChannelCreator.createChannel(args);
EchoRpcTest test = new EchoRpcTest(channel,name,count,message,pause,options,timeout);
channel.start(Channel.DEFAULT);
Runtime.getRuntime().addShutdownHook(new Shutdown(channel));
test.run();
-
+
System.out.println("System test complete, sleeping to let threads finish.");
Thread.sleep(60*1000*60);
- }
-
+ }
+
public static class Shutdown extends Thread {
ManagedChannel channel = null;
public Shutdown(ManagedChannel channel) {
this.channel = channel;
}
-
+
@Override
public void run() {
System.out.println("Shutting down...");
@@ -196,7 +196,7 @@ public class EchoRpcTest implements RpcC
exit.start();
try {
channel.stop(Channel.DEFAULT);
-
+
}catch ( Exception x ) {
x.printStackTrace();
}
@@ -216,6 +216,6 @@ public class EchoRpcTest implements RpcC
x.printStackTrace();
}
System.exit(0);
-
+
}
}}
\ No newline at end of file
Modified: tomcat/trunk/test/org/apache/catalina/tribes/demos/IntrospectionUtils.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribes/demos/IntrospectionUtils.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/tribes/demos/IntrospectionUtils.java (original)
+++ tomcat/trunk/test/org/apache/catalina/tribes/demos/IntrospectionUtils.java Sat Oct 22 21:23:07 2011
@@ -37,10 +37,10 @@ import java.util.Vector;
*/
public final class IntrospectionUtils {
-
+
private static final org.apache.juli.logging.Log log=
org.apache.juli.logging.LogFactory.getLog( IntrospectionUtils.class );
-
+
/**
* Call execute() - any ant-like task should work
*/
@@ -134,7 +134,7 @@ public final class IntrospectionUtils {
* Guess a product install/home by analyzing the class path. It works for
* product using the pattern: lib/executable.jar or if executable.jar is
* included in classpath by a shell script. ( java -jar also works )
- *
+ *
* Insures both "install" and "home" System properties are set. If either or
* both System properties are unset, "install" and "home" will be set to the
* same value. This value will be the other System property that is set, or
@@ -343,9 +343,9 @@ public final class IntrospectionUtils {
if (methods[i].getReturnType()==Boolean.TYPE){
setPropertyMethodBool = methods[i];
}else {
- setPropertyMethodVoid = methods[i];
+ setPropertyMethodVoid = methods[i];
}
-
+
}
}
@@ -440,7 +440,7 @@ public final class IntrospectionUtils {
return null;
}
- /**
+ /**
*/
public static void setProperty(Object o, String name) {
String setter = "set" + capitalize(name);
@@ -628,7 +628,7 @@ public final class IntrospectionUtils {
* Add elements from the classpath <i>cp </i> to a Vector <i>jars </i> as
* file URLs (We use Vector for JDK 1.1 compat).
* <p>
- *
+ *
* @param jars The jar list
* @param cp a String classpath of directory or jar file elements
* separated by path.separator delimiters.
@@ -700,7 +700,7 @@ public final class IntrospectionUtils {
public static void clear() {
objectMethods.clear();
}
-
+
static Hashtable<Class<?>,Method[]> objectMethods =
new Hashtable<Class<?>,Method[]>();
@@ -866,7 +866,7 @@ public final class IntrospectionUtils {
}
return result;
}
-
+
// -------------------- Get property --------------------
// This provides a layer of abstraction
Modified: tomcat/trunk/test/org/apache/catalina/tribes/demos/LoadTest.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribes/demos/LoadTest.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/tribes/demos/LoadTest.java (original)
+++ tomcat/trunk/test/org/apache/catalina/tribes/demos/LoadTest.java Sat Oct 22 21:23:07 2011
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -45,7 +45,7 @@ public class LoadTest implements Members
public static int size = 24000;
public static Object mutex = new Object();
public boolean doRun = true;
-
+
public long bytesReceived = 0;
public float mBytesReceived = 0;
public int messagesReceived = 0;
@@ -59,30 +59,30 @@ public class LoadTest implements Members
public boolean async = false;
public long receiveStart = 0;
public int channelOptions = Channel.SEND_OPTIONS_DEFAULT;
-
+
static int messageSize = 0;
-
+
public static long messagesSent = 0;
public static long messageStartSendTime = 0;
public static long messageEndSendTime = 0;
public static int threadCount = 0;
-
+
public static synchronized void startTest() {
threadCount++;
if ( messageStartSendTime == 0 ) messageStartSendTime = System.currentTimeMillis();
}
-
+
public static synchronized void endTest() {
threadCount--;
if ( messageEndSendTime == 0 && threadCount==0 ) messageEndSendTime = System.currentTimeMillis();
}
-
+
public static synchronized long addSendStats(long count) {
messagesSent+=count;
return 0l;
- }
-
+ }
+
private static void printSendStats(long counter, int messageSize) {
float cnt = counter;
float size = messageSize;
@@ -96,7 +96,7 @@ public class LoadTest implements Members
}
- public LoadTest(ManagedChannel channel,
+ public LoadTest(ManagedChannel channel,
boolean send,
int msgCount,
boolean debug,
@@ -115,11 +115,11 @@ public class LoadTest implements Members
@Override
public void run() {
-
+
long counter = 0;
long total = 0;
LoadMessage msg = new LoadMessage();
-
+
try {
startTest();
while (total < msgCount) {
@@ -158,7 +158,7 @@ public class LoadTest implements Members
//print from the global counter
//printSendStats(LoadTest.messagesSent, LoadTest.messageSize, LoadTest.messageSendTime);
printSendStats(LoadTest.messagesSent, LoadTest.messageSize);
-
+
}
}
@@ -197,29 +197,29 @@ public class LoadTest implements Members
public void memberDisappeared(Member member) {
log.info("Member disappeared:"+member);
}
-
+
@Override
- public boolean accept(Serializable msg, Member mbr){
+ public boolean accept(Serializable msg, Member mbr){
return (msg instanceof LoadMessage) || (msg instanceof ByteMessage);
}
-
+
@Override
- public void messageReceived(Serializable msg, Member mbr){
+ public void messageReceived(Serializable msg, Member mbr){
if ( receiveStart == 0 ) receiveStart = System.currentTimeMillis();
if ( debug ) {
if ( msg instanceof LoadMessage ) {
printArray(((LoadMessage)msg).getMessage());
}
}
-
+
if ( msg instanceof ByteMessage && !(msg instanceof LoadMessage)) {
LoadMessage tmp = new LoadMessage();
tmp.setMessage(((ByteMessage)msg).getMessage());
msg = tmp;
tmp = null;
}
-
-
+
+
bytesReceived+=((LoadMessage)msg).getMessage().length;
mBytesReceived+=(((LoadMessage)msg).getMessage().length)/1024f/1024f;
messagesReceived++;
@@ -237,8 +237,8 @@ public class LoadTest implements Members
}
}
-
-
+
+
public static void printArray(byte[] data) {
System.out.print("{");
for (int i=0; i<data.length; i++ ) {
@@ -250,7 +250,7 @@ public class LoadTest implements Members
public static class LoadMessage extends ByteMessage {
-
+
public static byte[] outdata = new byte[size];
public static Random r = new Random();
public static int getMessageSize (LoadMessage msg) {
@@ -259,13 +259,13 @@ public class LoadTest implements Members
static {
r.nextBytes(outdata);
}
-
+
protected byte[] message = getMessage();
-
+
public LoadMessage() {
// Default constructor
}
-
+
@Override
public byte[] getMessage() {
if ( message == null ) {
@@ -273,13 +273,13 @@ public class LoadTest implements Members
}
return message;
}
-
+
@Override
public void setMessage(byte[] data) {
this.message = data;
}
}
-
+
public static void usage() {
System.out.println("Tribes Load tester.");
System.out.println("The load tester can be used in sender or received mode or both");
@@ -304,7 +304,7 @@ public class LoadTest implements Members
"java LoadTest -bind 192.168.0.45 -port 4005\n\t"+
"java LoadTest -bind 192.168.0.45 -port 4005 -mbind 192.168.0.45 -count 100 -stats 10\n");
}
-
+
public static void main(String[] args) throws Exception {
boolean send = true;
boolean debug = false;
@@ -347,19 +347,19 @@ public class LoadTest implements Members
if ( "receive".equals(args[++i]) ) send = false;
} else if ("-debug".equals(args[i])) {
debug = true;
- } else if ("-help".equals(args[i]))
+ } else if ("-help".equals(args[i]))
{
usage();
System.exit(1);
}
}
-
+
ManagedChannel channel = (ManagedChannel)ChannelCreator.createChannel(args);
-
+
LoadTest test = new LoadTest(channel,send,count,debug,pause,stats,breakOnEx);
test.channelOptions = channelOptions;
LoadMessage msg = new LoadMessage();
-
+
messageSize = LoadMessage.getMessageSize(msg);
channel.addChannelListener(test);
channel.addMembershipListener(test);
@@ -377,14 +377,14 @@ public class LoadTest implements Members
if ( shutdown && send ) channel.stop(Channel.DEFAULT);
System.out.println("System test complete, sleeping to let threads finish.");
Thread.sleep(60*1000*60);
- }
-
+ }
+
public static class Shutdown extends Thread {
ManagedChannel channel = null;
public Shutdown(ManagedChannel channel) {
this.channel = channel;
}
-
+
@Override
public void run() {
System.out.println("Shutting down...");
@@ -393,7 +393,7 @@ public class LoadTest implements Members
exit.start();
try {
channel.stop(Channel.DEFAULT);
-
+
}catch ( Exception x ) {
x.printStackTrace();
}
@@ -416,5 +416,5 @@ public class LoadTest implements Members
}
}
-
+
}
\ No newline at end of file
Modified: tomcat/trunk/test/org/apache/catalina/tribes/demos/MapDemo.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribes/demos/MapDemo.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/tribes/demos/MapDemo.java (original)
+++ tomcat/trunk/test/org/apache/catalina/tribes/demos/MapDemo.java Sat Oct 22 21:23:07 2011
@@ -46,23 +46,23 @@ import org.apache.catalina.tribes.Member
import org.apache.catalina.tribes.tipis.LazyReplicatedMap;
/**
- * Example of how the lazy replicated map works, also shows how the BackupManager
+ * Example of how the lazy replicated map works, also shows how the BackupManager
* works in a Tomcat cluster
* @author fhanik
* @version 1.1
*/
public class MapDemo implements ChannelListener, MembershipListener{
-
+
/**
* The Map containing the replicated data
*/
protected LazyReplicatedMap map;
-
+
/**
* Table to be displayed in Swing
*/
protected SimpleTableDemo table;
-
+
/**
* Constructs a map demo object.
* @param channel - the Tribes channel object to be used for communication
@@ -80,10 +80,10 @@ public class MapDemo implements ChannelL
//initialize the map by receiving a fake message
this.messageReceived(null,null);
}
-
+
/**
* Decides if the messageReceived should be invoked
- * will always return false since we rely on the
+ * will always return false since we rely on the
* lazy map to do all the messaging for us
*/
@Override
@@ -92,7 +92,7 @@ public class MapDemo implements ChannelL
table.dataModel.getValueAt(-1,-1);
return false;
}
-
+
/**
* Invoked if accept returns true.
* No op for now
@@ -103,7 +103,7 @@ public class MapDemo implements ChannelL
public void messageReceived(Serializable msg, Member source) {
// NOOP
}
-
+
/**
* Invoked when a member is added to the group
*/
@@ -111,7 +111,7 @@ public class MapDemo implements ChannelL
public void memberAdded(Member member) {
// NOOP
}
-
+
/**
* Invoked when a member leaves the group
*/
@@ -120,13 +120,13 @@ public class MapDemo implements ChannelL
//just refresh the table model
table.dataModel.getValueAt(-1,-1);
}
-
+
/**
* Prints usage
*/
public static void usage() {
System.out.println("Tribes MapDemo.");
- System.out.println("Usage:\n\t" +
+ System.out.println("Usage:\n\t" +
"java MapDemo [channel options] mapName\n\t" +
"\tChannel options:" +
ChannelCreator.usage());
@@ -153,7 +153,7 @@ public class MapDemo implements ChannelL
Runtime.getRuntime().addShutdownHook(new Shutdown(channel));
//create a map demo object
new MapDemo(channel,mapName);
-
+
//put the main thread to sleep until we are done
System.out.println("System test complete, time to start="+(System.currentTimeMillis()-start)+" ms. Sleeping to let threads finish.");
Thread.sleep(60 * 1000 * 60);
@@ -165,12 +165,12 @@ public class MapDemo implements ChannelL
public static class Shutdown extends Thread {
//the channel running in this demo
ManagedChannel channel = null;
-
+
public Shutdown(ManagedChannel channel) {
this.channel = channel;
}
-
+
@Override
public void run() {
System.out.println("Shutting down...");
@@ -211,12 +211,12 @@ public class MapDemo implements ChannelL
private static final long serialVersionUID = 1L;
private static int WIDTH = 550;
-
+
private LazyReplicatedMap map;
private boolean DEBUG = false;
AbstractTableModel dataModel = new AbstractTableModel() {
-
-
+
+
private static final long serialVersionUID = 1L;
String[] columnNames = {
"Rownum",
@@ -230,10 +230,10 @@ public class MapDemo implements ChannelL
@Override
public int getColumnCount() { return columnNames.length; }
-
+
@Override
public int getRowCount() {return map.sizeFull() +1; }
-
+
public StringBuilder getMemberNames(Member[] members){
StringBuilder buf = new StringBuilder();
if ( members!=null ) {
@@ -244,7 +244,7 @@ public class MapDemo implements ChannelL
}
return buf;
}
-
+
@Override
public Object getValueAt(int row, int col) {
if ( row==-1 ) {
@@ -266,25 +266,25 @@ public class MapDemo implements ChannelL
case 7: return Boolean.valueOf(entry.isBackup());
default: return "";
}
-
+
}
-
+
public void update() {
fireTableDataChanged();
}
};
-
+
JTextField txtAddKey = new JTextField(20);
JTextField txtAddValue = new JTextField(20);
JTextField txtRemoveKey = new JTextField(20);
JTextField txtChangeKey = new JTextField(20);
JTextField txtChangeValue = new JTextField(20);
-
+
JTable table = null;
public SimpleTableDemo(LazyReplicatedMap map) {
super();
this.map = map;
-
+
this.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
//final JTable table = new JTable(data, columnNames);
@@ -305,7 +305,7 @@ public class MapDemo implements ChannelL
}
});
}
-
+
//setLayout(new GridLayout(5, 0));
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
@@ -314,7 +314,7 @@ public class MapDemo implements ChannelL
//Add the scroll pane to this panel.
add(scrollPane);
-
+
//create a add value button
JPanel addpanel = new JPanel();
addpanel.setPreferredSize(new Dimension(WIDTH,30));
@@ -323,7 +323,7 @@ public class MapDemo implements ChannelL
addpanel.add(txtAddValue);
addpanel.setMaximumSize(new Dimension(WIDTH,30));
add(addpanel);
-
+
//create a remove value button
JPanel removepanel = new JPanel( );
removepanel.setPreferredSize(new Dimension(WIDTH,30));
@@ -353,14 +353,14 @@ public class MapDemo implements ChannelL
}
-
+
public JButton createButton(String text, String command) {
JButton button = new JButton(text);
button.setActionCommand(command);
button.addActionListener(this);
return button;
}
-
+
@Override
public void actionPerformed(ActionEvent e) {
System.out.println(e.getActionCommand());
@@ -408,7 +408,7 @@ public class MapDemo implements ChannelL
};
t.start();
}
-
+
if ( "replicate".equals(e.getActionCommand()) ) {
System.out.println("Replicating out to the other nodes.");
map.replicate(true);
@@ -432,10 +432,10 @@ public class MapDemo implements ChannelL
end = Integer.MAX_VALUE;
}
}
-
+
char[] buffer = new char[count];
int gap = end - start;
-
+
while (count-- != 0) {
char ch;
if (chars == null) {
@@ -445,7 +445,7 @@ public class MapDemo implements ChannelL
}
if ((letters && Character.isLetter(ch))
|| (numbers && Character.isDigit(ch))
- || (!letters && !numbers))
+ || (!letters && !numbers))
{
if(ch >= 56320 && ch <= 57343) {
if(count == 0) {
@@ -520,9 +520,9 @@ public class MapDemo implements ChannelL
return newContentPane;
}
}
-
+
static class ColorRenderer extends DefaultTableCellRenderer {
-
+
private static final long serialVersionUID = 1L;
public ColorRenderer() {
@@ -548,8 +548,8 @@ public class MapDemo implements ChannelL
}
return cell;
}
-
-
+
+
}
Modified: tomcat/trunk/test/org/apache/catalina/tribes/demos/MembersWithProperties.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribes/demos/MembersWithProperties.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/tribes/demos/MembersWithProperties.java (original)
+++ tomcat/trunk/test/org/apache/catalina/tribes/demos/MembersWithProperties.java Sat Oct 22 21:23:07 2011
@@ -36,13 +36,13 @@ public class MembersWithProperties imple
ManagedChannel mchannel = (ManagedChannel)channel;
mchannel.getMembershipService().setPayload(getPayload(props));
}
-
+
byte[] getPayload(Properties props) throws IOException {
ByteArrayOutputStream bout = new ByteArrayOutputStream();
props.store(bout,"");
return bout.toByteArray();
}
-
+
Properties getProperties(byte[] payload) throws IOException {
ByteArrayInputStream bin = new ByteArrayInputStream(payload);
Properties props = new Properties();
@@ -60,7 +60,7 @@ public class MembersWithProperties imple
x.printStackTrace();
}
}
-
+
@Override
public void memberDisappeared(Member member) {
try {
Modified: tomcat/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelOptionFlag.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelOptionFlag.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelOptionFlag.java (original)
+++ tomcat/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelOptionFlag.java Sat Oct 22 21:23:07 2011
@@ -28,12 +28,12 @@ import org.apache.catalina.tribes.Channe
import org.apache.catalina.tribes.ChannelInterceptor;
/**
- * <p>Title: </p>
- *
- * <p>Description: </p>
- *
+ * <p>Title: </p>
+ *
+ * <p>Description: </p>
+ *
* <p>Company: </p>
- *
+ *
* @author not attributable
* @version 1.0
*/
@@ -89,7 +89,7 @@ public class TestGroupChannelOptionFlag
}
assertFalse(error);
}
-
+
public static class TestInterceptor extends ChannelInterceptorBase {
// Just use base class
}
Modified: tomcat/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelSenderConnections.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelSenderConnections.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelSenderConnections.java (original)
+++ tomcat/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelSenderConnections.java Sat Oct 22 21:23:07 2011
@@ -98,7 +98,7 @@ public class TestGroupChannelSenderConne
}
}
-
+
public static class TestMsg implements Serializable {
private static final long serialVersionUID = 1L;
static Random r = new Random();
@@ -119,13 +119,13 @@ public class TestGroupChannelSenderConne
public TestMsgListener(String name) {
this.name = name;
}
-
+
@Override
public void messageReceived(Serializable msg, Member sender) {
System.out.println("["+name+"] Received message:"+msg+" from " + sender.getName());
}
-
+
@Override
public boolean accept(Serializable msg, Member sender) {
return true;
Modified: tomcat/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelStartStop.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelStartStop.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelStartStop.java (original)
+++ tomcat/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelStartStop.java Sat Oct 22 21:23:07 2011
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Modified: tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestOrderInterceptor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestOrderInterceptor.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestOrderInterceptor.java (original)
+++ tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestOrderInterceptor.java Sat Oct 22 21:23:07 2011
@@ -56,7 +56,7 @@ public class TestOrderInterceptor {
threads = new Thread[channelCount];
for ( int i=0; i<channelCount; i++ ) {
channels[i] = new GroupChannel();
-
+
orderitcs[i] = new OrderInterceptor();
mangleitcs[i] = new MangleOrderInterceptor();
orderitcs[i].setExpire(Long.MAX_VALUE);
@@ -125,7 +125,7 @@ public class TestOrderInterceptor {
threads[i].join();
}
if (!exceptionQueue.isEmpty()) {
- fail("Exception while sending in threads: "
+ fail("Exception while sending in threads: "
+ exceptionQueue.remove().toString());
}
Thread.sleep(5000);
@@ -145,7 +145,7 @@ public class TestOrderInterceptor {
public static void main(String[] args) {
org.junit.runner.JUnitCore.main(TestOrderInterceptor.class.getName());
}
-
+
public static class TestListener implements ChannelListener {
int id = -1;
public TestListener(int id) {
@@ -169,7 +169,7 @@ public class TestOrderInterceptor {
return (msg instanceof Integer);
}
}
-
+
public static class MangleOrderInterceptor extends ChannelInterceptorBase {
ChannelMessage hold = null;
Member[] dest = null;
Modified: tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestTcpFailureDetector.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestTcpFailureDetector.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestTcpFailureDetector.java (original)
+++ tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestTcpFailureDetector.java Sat Oct 22 21:23:07 2011
@@ -34,12 +34,12 @@ import org.apache.catalina.tribes.Member
import org.apache.catalina.tribes.group.GroupChannel;
/**
- * <p>Title: </p>
- *
- * <p>Description: </p>
- *
+ * <p>Title: </p>
+ *
+ * <p>Description: </p>
+ *
* <p>Company: </p>
- *
+ *
* @author not attributable
* @version 1.0
*/
@@ -66,7 +66,7 @@ public class TestTcpFailureDetector {
channel1.addMembershipListener(mbrlist1);
channel2.addMembershipListener(mbrlist2);
}
-
+
public void clear() {
mbrlist1.members.clear();
mbrlist2.members.clear();
@@ -139,7 +139,7 @@ public class TestTcpFailureDetector {
try { channel2.stop(Channel.DEFAULT);}catch (Exception ignore){ /* Ignore */ }
channel2 = null;
}
-
+
public static class TestMbrListener implements MembershipListener {
public String name = null;
public TestMbrListener(String name) {
@@ -157,7 +157,7 @@ public class TestTcpFailureDetector {
}
}
}
-
+
@Override
public void memberDisappeared(Member member) {
if ( members.contains(member) ) {
@@ -169,7 +169,7 @@ public class TestTcpFailureDetector {
}
}
}
-
+
}
}
Modified: tomcat/trunk/test/org/apache/catalina/tribes/membership/TestMemberImplSerialization.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribes/membership/TestMemberImplSerialization.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/tribes/membership/TestMemberImplSerialization.java (original)
+++ tomcat/trunk/test/org/apache/catalina/tribes/membership/TestMemberImplSerialization.java Sat Oct 22 21:23:07 2011
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -75,7 +75,7 @@ public class TestMemberImplSerialization
MemberImpl a1 = MemberImpl.getMember(md1);
MemberImpl a2 = MemberImpl.getMember(md2);
-
+
assertTrue(a1.getUdpPort()==a2.getUdpPort());
assertTrue(a1.getUdpPort()==udpPort);
}
@@ -94,7 +94,7 @@ public class TestMemberImplSerialization
assertFalse(Arrays.equals(md1,mda1));
ma1 = MemberImpl.getMember(mda1);
assertTrue(compareMembers(p1,ma1));
-
+
md1 = m.getData(true,true);
Thread.sleep(50);
mda1 = m.getData(true,true);
@@ -102,10 +102,10 @@ public class TestMemberImplSerialization
MemberImpl a2 = MemberImpl.getMember(mda1);
assertTrue(a1.equals(a2));
assertFalse(Arrays.equals(md1,mda1));
-
-
+
+
}
-
+
public boolean compareMembers(MemberImpl impl1, MemberImpl impl2) {
boolean result = true;
result = result && Arrays.equals(impl1.getHost(),impl2.getHost());
Modified: tomcat/trunk/test/org/apache/catalina/tribes/test/NioSenderTest.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribes/test/NioSenderTest.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/tribes/test/NioSenderTest.java (original)
+++ tomcat/trunk/test/org/apache/catalina/tribes/test/NioSenderTest.java Sat Oct 22 21:23:07 2011
@@ -45,17 +45,17 @@ public class NioSenderTest {
public NioSenderTest() {
// Default constructor
}
-
+
public synchronized int inc() {
return ++counter;
}
-
+
public synchronized ChannelData getMessage(Member mbr) {
String msg = "Thread-"+Thread.currentThread().getName()+" Message:"+inc();
ChannelData data = new ChannelData(true);
data.setMessage(new XByteBuffer(msg.getBytes(),false));
data.setAddress(mbr);
-
+
return data;
}
@@ -102,7 +102,7 @@ public class NioSenderTest {
sender.reset();
sender.setMessage(XByteBuffer.createDataPackage(getMessage(mbr)));
}
-
+
} catch (Throwable t) {
t.printStackTrace();
Modified: tomcat/trunk/test/org/apache/catalina/tribes/test/channel/TestMulticastPackages.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribes/test/channel/TestMulticastPackages.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/tribes/test/channel/TestMulticastPackages.java (original)
+++ tomcat/trunk/test/org/apache/catalina/tribes/test/channel/TestMulticastPackages.java Sat Oct 22 21:23:07 2011
@@ -83,7 +83,7 @@ public class TestMulticastPackages {
AbstractSender s2 =(AbstractSender) ((ReplicationTransmitter)channel2.getChannelSender()).getTransport();
s1.setTimeout(Long.MAX_VALUE); //for debugging
s2.setTimeout(Long.MAX_VALUE); //for debugging
-
+
System.err.println("Starting Single package NO_ACK");
channel1.send(new Member[] {channel2.getLocalMember(false)}, Data.createRandomData(1024),Channel.SEND_OPTIONS_MULTICAST);
Thread.sleep(500);
@@ -91,7 +91,7 @@ public class TestMulticastPackages {
assertEquals("Checking success messages.",1,listener1.count.get());
}
-
+
public static void printMissingMsgs(int[] msgs, int maxIdx) {
for (int i=0; i<maxIdx && i<msgs.length; i++) {
if (msgs[i]==0) System.out.print(i+", ");
@@ -128,7 +128,7 @@ public class TestMulticastPackages {
}
}
};
- }
+ }
for (int x=0; x<threads.length; x++ ) { threads[x].start();}
for (int x=0; x<threads.length; x++ ) { threads[x].join();}
//sleep for 50 sec, let the other messages in
@@ -218,7 +218,7 @@ public class TestMulticastPackages {
public static Data createRandomData(int size) {
return createRandomData(size,-1);
}
-
+
public static Data createRandomData(int size, int number) {
int i = r.nextInt();
i = ( i % 127 );
@@ -236,7 +236,7 @@ public class TestMulticastPackages {
}
return d;
}
-
+
public int getNumber() {
if (!hasNr) return -1;
return XByteBuffer.toInt(this.data, 0);
Modified: tomcat/trunk/test/org/apache/catalina/tribes/test/channel/TestRemoteProcessException.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribes/test/channel/TestRemoteProcessException.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/tribes/test/channel/TestRemoteProcessException.java (original)
+++ tomcat/trunk/test/org/apache/catalina/tribes/test/channel/TestRemoteProcessException.java Sat Oct 22 21:23:07 2011
@@ -33,12 +33,12 @@ import org.apache.catalina.tribes.Member
import org.apache.catalina.tribes.group.GroupChannel;
/**
- * <p>Title: </p>
- *
- * <p>Description: </p>
- *
+ * <p>Title: </p>
+ *
+ * <p>Description: </p>
+ *
* <p>Company: </p>
- *
+ *
* @author not attributable
* @version 1.0
*/
Modified: tomcat/trunk/test/org/apache/catalina/tribes/test/channel/TestUdpPackages.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribes/test/channel/TestUdpPackages.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/tribes/test/channel/TestUdpPackages.java (original)
+++ tomcat/trunk/test/org/apache/catalina/tribes/test/channel/TestUdpPackages.java Sat Oct 22 21:23:07 2011
@@ -83,7 +83,7 @@ public class TestUdpPackages {
AbstractSender s2 =(AbstractSender) ((ReplicationTransmitter)channel2.getChannelSender()).getTransport();
s1.setTimeout(Long.MAX_VALUE); //for debugging
s2.setTimeout(Long.MAX_VALUE); //for debugging
-
+
System.err.println("Starting Single package NO_ACK");
channel1.send(new Member[] {channel2.getLocalMember(false)}, Data.createRandomData(1024),Channel.SEND_OPTIONS_UDP);
Thread.sleep(500);
@@ -120,7 +120,7 @@ public class TestUdpPackages {
}
}
};
- }
+ }
for (int x=0; x<threads.length; x++ ) { threads[x].start();}
for (int x=0; x<threads.length; x++ ) { threads[x].join();}
//sleep for 50 sec, let the other messages in
@@ -132,7 +132,7 @@ public class TestUdpPackages {
printMissingMsgs(listener1.nrs,counter.get());
assertEquals("Checking success messages.",msgCount*threadCount,listener1.count.get());
}
-
+
public static void printMissingMsgs(int[] msgs, int maxIdx) {
for (int i=0; i<maxIdx && i<msgs.length; i++) {
if (msgs[i]==0) System.out.print(i+", ");
@@ -169,7 +169,7 @@ public class TestUdpPackages {
}
}
};
- }
+ }
for (int x=0; x<threads.length; x++ ) { threads[x].start();}
for (int x=0; x<threads.length; x++ ) { threads[x].join();}
//sleep for 50 sec, let the other messages in
@@ -259,7 +259,7 @@ public class TestUdpPackages {
public static Data createRandomData(int size) {
return createRandomData(size,-1);
}
-
+
public static Data createRandomData(int size, int number) {
int i = r.nextInt();
i = ( i % 127 );
@@ -277,7 +277,7 @@ public class TestUdpPackages {
}
return d;
}
-
+
public int getNumber() {
if (!hasNr) return -1;
return XByteBuffer.toInt(this.data, 0);
Modified: tomcat/trunk/test/org/apache/catalina/tribes/test/transport/SocketNioReceive.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribes/test/transport/SocketNioReceive.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/tribes/test/transport/SocketNioReceive.java (original)
+++ tomcat/trunk/test/org/apache/catalina/tribes/test/transport/SocketNioReceive.java Sat Oct 22 21:23:07 2011
@@ -64,11 +64,11 @@ public class SocketNioReceive {
}
}
}
-
+
public static class MyList implements MessageListener {
boolean first = true;
-
-
+
+
@Override
public void messageReceived(ChannelMessage msg) {
if (first) {
@@ -82,7 +82,7 @@ public class SocketNioReceive {
seconds = ( (double) (time - start)) / 1000;
System.out.println("Throughput " + df.format(mb / seconds) + " MB/seconds, messages "+count+", total "+mb+" MB.");
}
- }
+ }
@Override
public boolean accept(ChannelMessage msg) {
Modified: tomcat/trunk/test/org/apache/catalina/tribes/test/transport/SocketNioValidateSend.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribes/test/transport/SocketNioValidateSend.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/tribes/test/transport/SocketNioValidateSend.java (original)
+++ tomcat/trunk/test/org/apache/catalina/tribes/test/transport/SocketNioValidateSend.java Sat Oct 22 21:23:07 2011
@@ -49,7 +49,7 @@ public class SocketNioValidateSend {
double mb = 0;
boolean first = true;
int count = 0;
-
+
DecimalFormat df = new DecimalFormat("##.00");
while (count<100000) {
if (first) {
Modified: tomcat/trunk/test/org/apache/catalina/tribes/test/transport/SocketReceive.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribes/test/transport/SocketReceive.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/tribes/test/transport/SocketReceive.java (original)
+++ tomcat/trunk/test/org/apache/catalina/tribes/test/transport/SocketReceive.java Sat Oct 22 21:23:07 2011
@@ -32,9 +32,9 @@ public class SocketReceive {
static BigDecimal total = new BigDecimal(0);
static BigDecimal bytes = new BigDecimal(32871);
-
+
public static void main(String[] args) throws Exception {
-
+
ServerSocket srvSocket = new ServerSocket(9999);
System.out.println("Listening on 9999");
Socket socket = srvSocket.accept();
@@ -70,7 +70,7 @@ public class SocketReceive {
printStats(start, mb, count, df, total);
}
}
-
+
}
private static void printStats(long start, double mb, int count, DecimalFormat df, BigDecimal total) {
Modified: tomcat/trunk/test/org/apache/catalina/tribes/test/transport/SocketSend.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribes/test/transport/SocketSend.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/tribes/test/transport/SocketSend.java (original)
+++ tomcat/trunk/test/org/apache/catalina/tribes/test/transport/SocketSend.java Sat Oct 22 21:23:07 2011
@@ -30,8 +30,8 @@ import org.apache.catalina.tribes.member
public class SocketSend {
public static void main(String[] args) throws Exception {
-
-
+
+
Member mbr = new MemberImpl("localhost", 9999, 0);
ChannelData data = new ChannelData();
data.setOptions(Channel.SEND_OPTIONS_BYTE_MESSAGE);
@@ -62,7 +62,7 @@ public class SocketSend {
System.out.println("Throughput "+df.format(mb/seconds)+" MB/seconds messages "+count+", total "+mb+" MB, total "+total+" bytes.");
}
}
- out.flush();
+ out.flush();
System.out.println("Complete, sleeping 5 seconds");
Thread.sleep(5000);
Modified: tomcat/trunk/test/org/apache/catalina/tribes/test/transport/SocketTribesReceive.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribes/test/transport/SocketTribesReceive.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/tribes/test/transport/SocketTribesReceive.java (original)
+++ tomcat/trunk/test/org/apache/catalina/tribes/test/transport/SocketTribesReceive.java Sat Oct 22 21:23:07 2011
@@ -35,7 +35,7 @@ public class SocketTribesReceive {
static BigDecimal total = new BigDecimal((double)0);
static BigDecimal bytes = new BigDecimal((double)32871);
-
+
public static void main(String[] args) throws Exception {
int size = 43800;
if (args.length > 0 ) try {size=Integer.parseInt(args[0]);}catch(Exception x){ /* Ignore */ }
@@ -78,7 +78,7 @@ public class SocketTribesReceive {
printStats(start, mb, count, df, total);
}
}
-
+
}
private static void printStats(long start, double mb, int count, DecimalFormat df, BigDecimal total) {
Modified: tomcat/trunk/test/org/apache/catalina/tribes/test/transport/SocketValidateReceive.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribes/test/transport/SocketValidateReceive.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/tribes/test/transport/SocketValidateReceive.java (original)
+++ tomcat/trunk/test/org/apache/catalina/tribes/test/transport/SocketValidateReceive.java Sat Oct 22 21:23:07 2011
@@ -32,11 +32,11 @@ public class SocketValidateReceive {
static BigDecimal total = new BigDecimal(0);
static BigDecimal bytes = new BigDecimal(32871);
-
+
public static void main(String[] args) throws Exception {
int size = 43800;
if (args.length > 0 ) try {size=Integer.parseInt(args[0]);}catch(Exception x){ /* Ignore */ }
-
+
ServerSocket srvSocket = new ServerSocket(9999);
System.out.println("Listening on 9999");
Socket socket = srvSocket.accept();
@@ -65,7 +65,7 @@ public class SocketValidateReceive {
System.exit(1);
}
count += reader.append(buf,0,len);
-
+
if ( bytes.intValue() != len ) bytes = new BigDecimal((double)len);
total = total.add(bytes);
mb += ( (double) len) / 1024 / 1024;
@@ -73,7 +73,7 @@ public class SocketValidateReceive {
printStats(start, mb, count, df, total);
}
}
-
+
}
private static void printStats(long start, double mb, int count, DecimalFormat df, BigDecimal total) {
@@ -81,7 +81,7 @@ public class SocketValidateReceive {
double seconds = ((double)(time-start))/1000;
System.out.println("Throughput "+df.format(mb/seconds)+" MB/seconds messages "+count+", total "+mb+" MB, total "+total+" bytes.");
}
-
+
public static class MyDataReader {
int length = 10;
int cur = 0;
@@ -89,10 +89,10 @@ public class SocketValidateReceive {
public MyDataReader(int len) {
length = len;
}
-
+
public int append(byte[] b, int off, int len) throws Exception {
int packages = 0;
- for ( int i=off; i<len; i++ ) {
+ for ( int i=off; i<len; i++ ) {
if ( cur == length ) {
cur = 0;
seq++;
Modified: tomcat/trunk/test/org/apache/catalina/util/TestContextName.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/util/TestContextName.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/util/TestContextName.java (original)
+++ tomcat/trunk/test/org/apache/catalina/util/TestContextName.java Sat Oct 22 21:23:07 2011
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -40,7 +40,7 @@ public class TestContextName {
private ContextName cn14;
private ContextName cn15;
private ContextName cn16;
-
+
@Before
public void setUp() throws Exception {
cn1 = new ContextName(null, null);
@@ -186,7 +186,7 @@ public class TestContextName {
doCompare(src, new ContextName(src.getDisplayName()));
doCompare(src, new ContextName(src.getName()));
}
-
+
private void doCompare(ContextName cn1, ContextName cn2) {
assertEquals(cn1.getBaseName(), cn2.getBaseName());
assertEquals(cn1.getDisplayName(), cn2.getDisplayName());
Modified: tomcat/trunk/test/org/apache/catalina/util/TestRequestUtil.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/util/TestRequestUtil.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/util/TestRequestUtil.java (original)
+++ tomcat/trunk/test/org/apache/catalina/util/TestRequestUtil.java Sat Oct 22 21:23:07 2011
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -52,7 +52,7 @@ public class TestRequestUtil {
}
assertTrue(exception instanceof IllegalArgumentException);
}
-
+
@Test
public void testURLDecodeStringValidIso88591Start() {
Modified: tomcat/trunk/test/org/apache/catalina/util/TestServerInfo.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/util/TestServerInfo.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/util/TestServerInfo.java (original)
+++ tomcat/trunk/test/org/apache/catalina/util/TestServerInfo.java Sat Oct 22 21:23:07 2011
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,7 +22,7 @@ import org.junit.Test;
public class TestServerInfo {
/**
- * Test that prints the server version info.
+ * Test that prints the server version info.
*/
@Test
public void testServerInfo() {
Modified: tomcat/trunk/test/org/apache/catalina/valves/Benchmarks.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/valves/Benchmarks.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/valves/Benchmarks.java (original)
+++ tomcat/trunk/test/org/apache/catalina/valves/Benchmarks.java Sat Oct 22 21:23:07 2011
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Modified: tomcat/trunk/test/org/apache/catalina/valves/TestRemoteIpValve.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/valves/TestRemoteIpValve.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/valves/TestRemoteIpValve.java (original)
+++ tomcat/trunk/test/org/apache/catalina/valves/TestRemoteIpValve.java Sat Oct 22 21:23:07 2011
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -39,22 +39,22 @@ import org.apache.catalina.connector.Res
* {@link RemoteIpValve} Tests
*/
public class TestRemoteIpValve {
-
+
static class RemoteAddrAndHostTrackerValve extends ValveBase {
private String remoteAddr;
private String remoteHost;
private String scheme;
private boolean secure;
private int serverPort;
-
+
public String getRemoteAddr() {
return remoteAddr;
}
-
+
public String getRemoteHost() {
return remoteHost;
}
-
+
public String getScheme() {
return scheme;
}
@@ -66,7 +66,7 @@ public class TestRemoteIpValve {
public boolean isSecure() {
return secure;
}
-
+
@Override
public void invoke(Request request, Response response) throws IOException, ServletException {
this.remoteHost = request.getRemoteHost();
@@ -90,20 +90,20 @@ public class TestRemoteIpValve {
String actual = RemoteIpValve.listToCommaDelimitedString(elements);
assertEquals("element1, element2, element3", actual);
}
-
+
@Test
public void testListToCommaDelimitedStringEmptyList() {
List<String> elements = new ArrayList<String>();
String actual = RemoteIpValve.listToCommaDelimitedString(elements);
assertEquals("", actual);
}
-
+
@Test
public void testCommaDelimitedListToStringArrayNullList() {
String actual = RemoteIpValve.listToCommaDelimitedString(null);
assertEquals("", actual);
}
-
+
@Test
public void testInvokeAllowedRemoteAddrWithNullRemoteIpHeader() throws Exception {
// PREPARE
@@ -114,39 +114,39 @@ public class TestRemoteIpValve {
remoteIpValve.setProxiesHeader("x-forwarded-by");
RemoteAddrAndHostTrackerValve remoteAddrAndHostTrackerValve = new RemoteAddrAndHostTrackerValve();
remoteIpValve.setNext(remoteAddrAndHostTrackerValve);
-
+
Request request = new MockRequest();
request.setCoyoteRequest(new org.apache.coyote.Request());
request.setRemoteAddr("192.168.0.10");
request.setRemoteHost("remote-host-original-value");
-
+
// TEST
remoteIpValve.invoke(request, null);
-
+
// VERIFY
String actualXForwardedFor = request.getHeader("x-forwarded-for");
assertNull("x-forwarded-for must be null", actualXForwardedFor);
-
+
String actualXForwardedBy = request.getHeader("x-forwarded-by");
assertNull("x-forwarded-by must be null", actualXForwardedBy);
-
+
String actualRemoteAddr = remoteAddrAndHostTrackerValve.getRemoteAddr();
assertEquals("remoteAddr", "192.168.0.10", actualRemoteAddr);
-
+
String actualRemoteHost = remoteAddrAndHostTrackerValve.getRemoteHost();
assertEquals("remoteHost", "remote-host-original-value", actualRemoteHost);
-
+
String actualPostInvokeRemoteAddr = request.getRemoteAddr();
assertEquals("postInvoke remoteAddr", "192.168.0.10", actualPostInvokeRemoteAddr);
-
+
String actualPostInvokeRemoteHost = request.getRemoteHost();
assertEquals("postInvoke remoteAddr", "remote-host-original-value", actualPostInvokeRemoteHost);
-
+
}
-
+
@Test
public void testInvokeAllProxiesAreTrusted() throws Exception {
-
+
// PREPARE
RemoteIpValve remoteIpValve = new RemoteIpValve();
remoteIpValve.setInternalProxies("192\\.168\\.0\\.10|192\\.168\\.0\\.11");
@@ -155,39 +155,39 @@ public class TestRemoteIpValve {
remoteIpValve.setProxiesHeader("x-forwarded-by");
RemoteAddrAndHostTrackerValve remoteAddrAndHostTrackerValve = new RemoteAddrAndHostTrackerValve();
remoteIpValve.setNext(remoteAddrAndHostTrackerValve);
-
+
Request request = new MockRequest();
request.setCoyoteRequest(new org.apache.coyote.Request());
request.setRemoteAddr("192.168.0.10");
request.setRemoteHost("remote-host-original-value");
request.getCoyoteRequest().getMimeHeaders().addValue("x-forwarded-for").setString("140.211.11.130, proxy1, proxy2");
-
+
// TEST
remoteIpValve.invoke(request, null);
-
+
// VERIFY
String actualXForwardedFor = request.getHeader("x-forwarded-for");
assertNull("all proxies are trusted, x-forwarded-for must be null", actualXForwardedFor);
-
+
String actualXForwardedBy = request.getHeader("x-forwarded-by");
assertEquals("all proxies are trusted, they must appear in x-forwarded-by", "proxy1, proxy2", actualXForwardedBy);
-
+
String actualRemoteAddr = remoteAddrAndHostTrackerValve.getRemoteAddr();
assertEquals("remoteAddr", "140.211.11.130", actualRemoteAddr);
-
+
String actualRemoteHost = remoteAddrAndHostTrackerValve.getRemoteHost();
assertEquals("remoteHost", "140.211.11.130", actualRemoteHost);
-
+
String actualPostInvokeRemoteAddr = request.getRemoteAddr();
assertEquals("postInvoke remoteAddr", "192.168.0.10", actualPostInvokeRemoteAddr);
-
+
String actualPostInvokeRemoteHost = request.getRemoteHost();
assertEquals("postInvoke remoteAddr", "remote-host-original-value", actualPostInvokeRemoteHost);
}
-
+
@Test
public void testInvokeAllProxiesAreTrustedOrInternal() throws Exception {
-
+
// PREPARE
RemoteIpValve remoteIpValve = new RemoteIpValve();
remoteIpValve.setInternalProxies("192\\.168\\.0\\.10|192\\.168\\.0\\.11");
@@ -196,40 +196,40 @@ public class TestRemoteIpValve {
remoteIpValve.setProxiesHeader("x-forwarded-by");
RemoteAddrAndHostTrackerValve remoteAddrAndHostTrackerValve = new RemoteAddrAndHostTrackerValve();
remoteIpValve.setNext(remoteAddrAndHostTrackerValve);
-
+
Request request = new MockRequest();
request.setCoyoteRequest(new org.apache.coyote.Request());
request.setRemoteAddr("192.168.0.10");
request.setRemoteHost("remote-host-original-value");
request.getCoyoteRequest().getMimeHeaders().addValue("x-forwarded-for")
.setString("140.211.11.130, proxy1, proxy2, 192.168.0.10, 192.168.0.11");
-
+
// TEST
remoteIpValve.invoke(request, null);
-
+
// VERIFY
String actualXForwardedFor = request.getHeader("x-forwarded-for");
assertNull("all proxies are trusted, x-forwarded-for must be null", actualXForwardedFor);
-
+
String actualXForwardedBy = request.getHeader("x-forwarded-by");
assertEquals("all proxies are trusted, they must appear in x-forwarded-by", "proxy1, proxy2", actualXForwardedBy);
-
+
String actualRemoteAddr = remoteAddrAndHostTrackerValve.getRemoteAddr();
assertEquals("remoteAddr", "140.211.11.130", actualRemoteAddr);
-
+
String actualRemoteHost = remoteAddrAndHostTrackerValve.getRemoteHost();
assertEquals("remoteHost", "140.211.11.130", actualRemoteHost);
-
+
String actualPostInvokeRemoteAddr = request.getRemoteAddr();
assertEquals("postInvoke remoteAddr", "192.168.0.10", actualPostInvokeRemoteAddr);
-
+
String actualPostInvokeRemoteHost = request.getRemoteHost();
assertEquals("postInvoke remoteAddr", "remote-host-original-value", actualPostInvokeRemoteHost);
}
-
+
@Test
public void testInvokeAllProxiesAreInternal() throws Exception {
-
+
// PREPARE
RemoteIpValve remoteIpValve = new RemoteIpValve();
remoteIpValve.setInternalProxies("192\\.168\\.0\\.10|192\\.168\\.0\\.11");
@@ -238,39 +238,39 @@ public class TestRemoteIpValve {
remoteIpValve.setProxiesHeader("x-forwarded-by");
RemoteAddrAndHostTrackerValve remoteAddrAndHostTrackerValve = new RemoteAddrAndHostTrackerValve();
remoteIpValve.setNext(remoteAddrAndHostTrackerValve);
-
+
Request request = new MockRequest();
request.setCoyoteRequest(new org.apache.coyote.Request());
request.setRemoteAddr("192.168.0.10");
request.setRemoteHost("remote-host-original-value");
request.getCoyoteRequest().getMimeHeaders().addValue("x-forwarded-for").setString("140.211.11.130, 192.168.0.10, 192.168.0.11");
-
+
// TEST
remoteIpValve.invoke(request, null);
-
+
// VERIFY
String actualXForwardedFor = request.getHeader("x-forwarded-for");
assertNull("all proxies are internal, x-forwarded-for must be null", actualXForwardedFor);
-
+
String actualXForwardedBy = request.getHeader("x-forwarded-by");
assertNull("all proxies are internal, x-forwarded-by must be null", actualXForwardedBy);
-
+
String actualRemoteAddr = remoteAddrAndHostTrackerValve.getRemoteAddr();
assertEquals("remoteAddr", "140.211.11.130", actualRemoteAddr);
-
+
String actualRemoteHost = remoteAddrAndHostTrackerValve.getRemoteHost();
assertEquals("remoteHost", "140.211.11.130", actualRemoteHost);
-
+
String actualPostInvokeRemoteAddr = request.getRemoteAddr();
assertEquals("postInvoke remoteAddr", "192.168.0.10", actualPostInvokeRemoteAddr);
-
+
String actualPostInvokeRemoteHost = request.getRemoteHost();
assertEquals("postInvoke remoteAddr", "remote-host-original-value", actualPostInvokeRemoteHost);
}
-
+
@Test
public void testInvokeAllProxiesAreTrustedAndRemoteAddrMatchRegexp() throws Exception {
-
+
// PREPARE
RemoteIpValve remoteIpValve = new RemoteIpValve();
remoteIpValve.setInternalProxies("127\\.0\\.0\\.1|192\\.168\\..*|another-internal-proxy");
@@ -279,7 +279,7 @@ public class TestRemoteIpValve {
remoteIpValve.setProxiesHeader("x-forwarded-by");
RemoteAddrAndHostTrackerValve remoteAddrAndHostTrackerValve = new RemoteAddrAndHostTrackerValve();
remoteIpValve.setNext(remoteAddrAndHostTrackerValve);
-
+
Request request = new MockRequest();
request.setCoyoteRequest(new org.apache.coyote.Request());
request.setRemoteAddr("192.168.0.10");
@@ -287,40 +287,40 @@ public class TestRemoteIpValve {
request.getCoyoteRequest().getMimeHeaders().addValue("x-forwarded-for").setString("140.211.11.130");
request.getCoyoteRequest().getMimeHeaders().addValue("x-forwarded-for").setString("proxy1");
request.getCoyoteRequest().getMimeHeaders().addValue("x-forwarded-for").setString("proxy2");
-
+
// TEST
remoteIpValve.invoke(request, null);
-
+
// VERIFY
String actualXForwardedFor = request.getHeader("x-forwarded-for");
assertNull("all proxies are trusted, x-forwarded-for must be null", actualXForwardedFor);
-
+
String actualXForwardedBy = request.getHeader("x-forwarded-by");
assertEquals("all proxies are trusted, they must appear in x-forwarded-by", "proxy1, proxy2", actualXForwardedBy);
-
+
String actualRemoteAddr = remoteAddrAndHostTrackerValve.getRemoteAddr();
assertEquals("remoteAddr", "140.211.11.130", actualRemoteAddr);
-
+
String actualRemoteHost = remoteAddrAndHostTrackerValve.getRemoteHost();
assertEquals("remoteHost", "140.211.11.130", actualRemoteHost);
-
+
String actualPostInvokeRemoteAddr = request.getRemoteAddr();
assertEquals("postInvoke remoteAddr", "192.168.0.10", actualPostInvokeRemoteAddr);
-
+
String actualPostInvokeRemoteHost = request.getRemoteHost();
assertEquals("postInvoke remoteAddr", "remote-host-original-value", actualPostInvokeRemoteHost);
}
-
+
@Test
public void testInvokeXforwardedProtoSaysHttpsForIncomingHttpRequest() throws Exception {
-
+
// PREPARE
RemoteIpValve remoteIpValve = new RemoteIpValve();
remoteIpValve.setRemoteIpHeader("x-forwarded-for");
remoteIpValve.setProtocolHeader("x-forwarded-proto");
RemoteAddrAndHostTrackerValve remoteAddrAndHostTrackerValve = new RemoteAddrAndHostTrackerValve();
remoteIpValve.setNext(remoteAddrAndHostTrackerValve);
-
+
Request request = new MockRequest();
request.setCoyoteRequest(new org.apache.coyote.Request());
// client ip
@@ -332,37 +332,37 @@ public class TestRemoteIpValve {
request.setSecure(false);
request.setServerPort(8080);
request.getCoyoteRequest().scheme().setString("http");
-
+
// TEST
remoteIpValve.invoke(request, null);
-
+
// VERIFY
// client ip
String actualXForwardedFor = request.getHeader("x-forwarded-for");
assertNull("no intermediate non-trusted proxy, x-forwarded-for must be null", actualXForwardedFor);
-
+
String actualXForwardedBy = request.getHeader("x-forwarded-by");
assertNull("no intermediate trusted proxy", actualXForwardedBy);
-
+
String actualRemoteAddr = remoteAddrAndHostTrackerValve.getRemoteAddr();
assertEquals("remoteAddr", "140.211.11.130", actualRemoteAddr);
-
+
String actualRemoteHost = remoteAddrAndHostTrackerValve.getRemoteHost();
assertEquals("remoteHost", "140.211.11.130", actualRemoteHost);
-
+
String actualPostInvokeRemoteAddr = request.getRemoteAddr();
assertEquals("postInvoke remoteAddr", "192.168.0.10", actualPostInvokeRemoteAddr);
-
+
String actualPostInvokeRemoteHost = request.getRemoteHost();
assertEquals("postInvoke remoteAddr", "192.168.0.10", actualPostInvokeRemoteHost);
-
+
// protocol
String actualScheme = remoteAddrAndHostTrackerValve.getScheme();
assertEquals("x-forwarded-proto says https", "https", actualScheme);
-
+
int actualServerPort = remoteAddrAndHostTrackerValve.getServerPort();
assertEquals("x-forwarded-proto says https", 443, actualServerPort);
-
+
boolean actualSecure = remoteAddrAndHostTrackerValve.isSecure();
assertTrue("x-forwarded-proto says https", actualSecure);
@@ -375,17 +375,17 @@ public class TestRemoteIpValve {
String actualPostInvokeScheme = request.getScheme();
assertEquals("postInvoke scheme", "http", actualPostInvokeScheme);
}
-
+
@Test
public void testInvokeXforwardedProtoIsNullForIncomingHttpRequest() throws Exception {
-
+
// PREPARE
RemoteIpValve remoteIpValve = new RemoteIpValve();
remoteIpValve.setRemoteIpHeader("x-forwarded-for");
remoteIpValve.setProtocolHeader("x-forwarded-proto");
RemoteAddrAndHostTrackerValve remoteAddrAndHostTrackerValve = new RemoteAddrAndHostTrackerValve();
remoteIpValve.setNext(remoteAddrAndHostTrackerValve);
-
+
Request request = new MockRequest();
request.setCoyoteRequest(new org.apache.coyote.Request());
// client ip
@@ -397,37 +397,37 @@ public class TestRemoteIpValve {
request.setSecure(false);
request.setServerPort(8080);
request.getCoyoteRequest().scheme().setString("http");
-
+
// TEST
remoteIpValve.invoke(request, null);
-
+
// VERIFY
// client ip
String actualXForwardedFor = request.getHeader("x-forwarded-for");
assertNull("no intermediate non-trusted proxy, x-forwarded-for must be null", actualXForwardedFor);
-
+
String actualXForwardedBy = request.getHeader("x-forwarded-by");
assertNull("no intermediate trusted proxy", actualXForwardedBy);
-
+
String actualRemoteAddr = remoteAddrAndHostTrackerValve.getRemoteAddr();
assertEquals("remoteAddr", "140.211.11.130", actualRemoteAddr);
-
+
String actualRemoteHost = remoteAddrAndHostTrackerValve.getRemoteHost();
assertEquals("remoteHost", "140.211.11.130", actualRemoteHost);
-
+
String actualPostInvokeRemoteAddr = request.getRemoteAddr();
assertEquals("postInvoke remoteAddr", "192.168.0.10", actualPostInvokeRemoteAddr);
-
+
String actualPostInvokeRemoteHost = request.getRemoteHost();
assertEquals("postInvoke remoteAddr", "192.168.0.10", actualPostInvokeRemoteHost);
-
+
// protocol
String actualScheme = remoteAddrAndHostTrackerValve.getScheme();
assertEquals("x-forwarded-proto is null", "http", actualScheme);
-
+
int actualServerPort = remoteAddrAndHostTrackerValve.getServerPort();
assertEquals("x-forwarded-proto is null", 8080, actualServerPort);
-
+
boolean actualSecure = remoteAddrAndHostTrackerValve.isSecure();
assertFalse("x-forwarded-proto is null", actualSecure);
@@ -440,17 +440,17 @@ public class TestRemoteIpValve {
String actualPostInvokeScheme = request.getScheme();
assertEquals("postInvoke scheme", "http", actualPostInvokeScheme);
}
-
+
@Test
public void testInvokeXforwardedProtoSaysHttpForIncomingHttpsRequest() throws Exception {
-
+
// PREPARE
RemoteIpValve remoteIpValve = new RemoteIpValve();
remoteIpValve.setRemoteIpHeader("x-forwarded-for");
remoteIpValve.setProtocolHeader("x-forwarded-proto");
RemoteAddrAndHostTrackerValve remoteAddrAndHostTrackerValve = new RemoteAddrAndHostTrackerValve();
remoteIpValve.setNext(remoteAddrAndHostTrackerValve);
-
+
Request request = new MockRequest();
request.setCoyoteRequest(new org.apache.coyote.Request());
// client ip
@@ -462,37 +462,37 @@ public class TestRemoteIpValve {
request.setSecure(true);
request.setServerPort(8443);
request.getCoyoteRequest().scheme().setString("https");
-
+
// TEST
remoteIpValve.invoke(request, null);
-
+
// VERIFY
// client ip
String actualXForwardedFor = request.getHeader("x-forwarded-for");
assertNull("no intermediate non-trusted proxy, x-forwarded-for must be null", actualXForwardedFor);
-
+
String actualXForwardedBy = request.getHeader("x-forwarded-by");
assertNull("no intermediate trusted proxy", actualXForwardedBy);
-
+
String actualRemoteAddr = remoteAddrAndHostTrackerValve.getRemoteAddr();
assertEquals("remoteAddr", "140.211.11.130", actualRemoteAddr);
-
+
String actualRemoteHost = remoteAddrAndHostTrackerValve.getRemoteHost();
assertEquals("remoteHost", "140.211.11.130", actualRemoteHost);
-
+
String actualPostInvokeRemoteAddr = request.getRemoteAddr();
assertEquals("postInvoke remoteAddr", "192.168.0.10", actualPostInvokeRemoteAddr);
-
+
String actualPostInvokeRemoteHost = request.getRemoteHost();
assertEquals("postInvoke remoteAddr", "192.168.0.10", actualPostInvokeRemoteHost);
-
+
// protocol
String actualScheme = remoteAddrAndHostTrackerValve.getScheme();
assertEquals("x-forwarded-proto says http", "http", actualScheme);
-
+
int actualServerPort = remoteAddrAndHostTrackerValve.getServerPort();
assertEquals("x-forwarded-proto says http", 80, actualServerPort);
-
+
boolean actualSecure = remoteAddrAndHostTrackerValve.isSecure();
assertFalse("x-forwarded-proto says http", actualSecure);
@@ -505,17 +505,17 @@ public class TestRemoteIpValve {
String actualPostInvokeScheme = request.getScheme();
assertEquals("postInvoke scheme", "https", actualPostInvokeScheme);
}
-
+
@Test
public void testInvokeXforwardedProtoIsNullForIncomingHttpsRequest() throws Exception {
-
+
// PREPARE
RemoteIpValve remoteIpValve = new RemoteIpValve();
remoteIpValve.setRemoteIpHeader("x-forwarded-for");
remoteIpValve.setProtocolHeader("x-forwarded-proto");
RemoteAddrAndHostTrackerValve remoteAddrAndHostTrackerValve = new RemoteAddrAndHostTrackerValve();
remoteIpValve.setNext(remoteAddrAndHostTrackerValve);
-
+
Request request = new MockRequest();
request.setCoyoteRequest(new org.apache.coyote.Request());
// client ip
@@ -527,37 +527,37 @@ public class TestRemoteIpValve {
request.setSecure(true);
request.setServerPort(8443);
request.getCoyoteRequest().scheme().setString("https");
-
+
// TEST
remoteIpValve.invoke(request, null);
-
+
// VERIFY
// client ip
String actualXForwardedFor = request.getHeader("x-forwarded-for");
assertNull("no intermediate non-trusted proxy, x-forwarded-for must be null", actualXForwardedFor);
-
+
String actualXForwardedBy = request.getHeader("x-forwarded-by");
assertNull("no intermediate trusted proxy", actualXForwardedBy);
-
+
String actualRemoteAddr = remoteAddrAndHostTrackerValve.getRemoteAddr();
assertEquals("remoteAddr", "140.211.11.130", actualRemoteAddr);
-
+
String actualRemoteHost = remoteAddrAndHostTrackerValve.getRemoteHost();
assertEquals("remoteHost", "140.211.11.130", actualRemoteHost);
-
+
String actualPostInvokeRemoteAddr = request.getRemoteAddr();
assertEquals("postInvoke remoteAddr", "192.168.0.10", actualPostInvokeRemoteAddr);
-
+
String actualPostInvokeRemoteHost = request.getRemoteHost();
assertEquals("postInvoke remoteAddr", "192.168.0.10", actualPostInvokeRemoteHost);
-
+
// protocol
String actualScheme = remoteAddrAndHostTrackerValve.getScheme();
assertEquals("x-forwarded-proto is null", "https", actualScheme);
-
+
int actualServerPort = remoteAddrAndHostTrackerValve.getServerPort();
assertEquals("x-forwarded-proto is null", 8443, actualServerPort);
-
+
boolean actualSecure = remoteAddrAndHostTrackerValve.isSecure();
assertTrue("x-forwarded-proto is null", actualSecure);
@@ -570,7 +570,7 @@ public class TestRemoteIpValve {
String actualPostInvokeScheme = request.getScheme();
assertEquals("postInvoke scheme", "https", actualPostInvokeScheme);
}
-
+
@Test
public void testInvokeNotAllowedRemoteAddr() throws Exception {
// PREPARE
@@ -581,36 +581,36 @@ public class TestRemoteIpValve {
remoteIpValve.setProxiesHeader("x-forwarded-by");
RemoteAddrAndHostTrackerValve remoteAddrAndHostTrackerValve = new RemoteAddrAndHostTrackerValve();
remoteIpValve.setNext(remoteAddrAndHostTrackerValve);
-
+
Request request = new MockRequest();
request.setCoyoteRequest(new org.apache.coyote.Request());
request.setRemoteAddr("not-allowed-internal-proxy");
request.setRemoteHost("not-allowed-internal-proxy-host");
request.getCoyoteRequest().getMimeHeaders().addValue("x-forwarded-for").setString("140.211.11.130, proxy1, proxy2");
-
+
// TEST
remoteIpValve.invoke(request, null);
-
+
// VERIFY
String actualXForwardedFor = request.getHeader("x-forwarded-for");
assertEquals("x-forwarded-for must be unchanged", "140.211.11.130, proxy1, proxy2", actualXForwardedFor);
-
+
String actualXForwardedBy = request.getHeader("x-forwarded-by");
assertNull("x-forwarded-by must be null", actualXForwardedBy);
-
+
String actualRemoteAddr = remoteAddrAndHostTrackerValve.getRemoteAddr();
assertEquals("remoteAddr", "not-allowed-internal-proxy", actualRemoteAddr);
-
+
String actualRemoteHost = remoteAddrAndHostTrackerValve.getRemoteHost();
assertEquals("remoteHost", "not-allowed-internal-proxy-host", actualRemoteHost);
-
+
String actualPostInvokeRemoteAddr = request.getRemoteAddr();
assertEquals("postInvoke remoteAddr", "not-allowed-internal-proxy", actualPostInvokeRemoteAddr);
-
+
String actualPostInvokeRemoteHost = request.getRemoteHost();
assertEquals("postInvoke remoteAddr", "not-allowed-internal-proxy-host", actualPostInvokeRemoteHost);
}
-
+
@Test
public void testInvokeUntrustedProxyInTheChain() throws Exception {
// PREPARE
@@ -621,37 +621,37 @@ public class TestRemoteIpValve {
remoteIpValve.setProxiesHeader("x-forwarded-by");
RemoteAddrAndHostTrackerValve remoteAddrAndHostTrackerValve = new RemoteAddrAndHostTrackerValve();
remoteIpValve.setNext(remoteAddrAndHostTrackerValve);
-
+
Request request = new MockRequest();
request.setCoyoteRequest(new org.apache.coyote.Request());
request.setRemoteAddr("192.168.0.10");
request.setRemoteHost("remote-host-original-value");
request.getCoyoteRequest().getMimeHeaders().addValue("x-forwarded-for")
.setString("140.211.11.130, proxy1, untrusted-proxy, proxy2");
-
+
// TEST
remoteIpValve.invoke(request, null);
-
+
// VERIFY
String actualXForwardedFor = request.getHeader("x-forwarded-for");
assertEquals("ip/host before untrusted-proxy must appear in x-forwarded-for", "140.211.11.130, proxy1", actualXForwardedFor);
-
+
String actualXForwardedBy = request.getHeader("x-forwarded-by");
assertEquals("ip/host after untrusted-proxy must appear in x-forwarded-by", "proxy2", actualXForwardedBy);
-
+
String actualRemoteAddr = remoteAddrAndHostTrackerValve.getRemoteAddr();
assertEquals("remoteAddr", "untrusted-proxy", actualRemoteAddr);
-
+
String actualRemoteHost = remoteAddrAndHostTrackerValve.getRemoteHost();
assertEquals("remoteHost", "untrusted-proxy", actualRemoteHost);
-
+
String actualPostInvokeRemoteAddr = request.getRemoteAddr();
assertEquals("postInvoke remoteAddr", "192.168.0.10", actualPostInvokeRemoteAddr);
-
+
String actualPostInvokeRemoteHost = request.getRemoteHost();
assertEquals("postInvoke remoteAddr", "remote-host-original-value", actualPostInvokeRemoteHost);
}
-
+
@Test
public void testCommaDelimitedListToStringArray() {
String[] actual = RemoteIpValve.commaDelimitedListToStringArray("element1, element2, element3");
@@ -660,7 +660,7 @@ public class TestRemoteIpValve {
};
assertArrayEquals(expected, actual);
}
-
+
@Test
public void testCommaDelimitedListToStringArrayMixedSpaceChars() {
String[] actual = RemoteIpValve.commaDelimitedListToStringArray("element1 , element2,\t element3");
@@ -669,7 +669,7 @@ public class TestRemoteIpValve {
};
assertArrayEquals(expected, actual);
}
-
+
private void assertArrayEquals(String[] expected, String[] actual) {
if (expected == null) {
assertNull(actual);
@@ -681,7 +681,7 @@ public class TestRemoteIpValve {
e.addAll(Arrays.asList(expected));
List<String> a = new ArrayList<String>();
a.addAll(Arrays.asList(actual));
-
+
for (String entry : e) {
assertTrue(a.remove(entry));
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org