control frames can not set rsv bits + tests

This commit is contained in:
Jesse McConnell 2012-06-27 10:14:51 -05:00
parent fb7b9b2c19
commit 43d048f691
2 changed files with 108 additions and 0 deletions

View File

@ -25,6 +25,33 @@ public abstract class ControlFrame extends BaseFrame
return false; // no control frames can be continuation return false; // no control frames can be continuation
} }
@Override
public void setRsv1(boolean rsv1)
{
if (rsv1)
{
throw new IllegalArgumentException("Cannot set RSV1 to true on a " + getOpCode().name());
}
}
@Override
public void setRsv2(boolean rsv2)
{
if (rsv2)
{
throw new IllegalArgumentException("Cannot set RSV2 to true on a " + getOpCode().name());
}
}
@Override
public void setRsv3(boolean rsv3)
{
if (rsv3)
{
throw new IllegalArgumentException("Cannot set RSV3 to true on a " + getOpCode().name());
}
}
@Override @Override
public void setPayload(ByteBuffer payload) public void setPayload(ByteBuffer payload)
{ {

View File

@ -0,0 +1,81 @@
package org.eclipse.jetty.websocket.ab;
import org.eclipse.jetty.websocket.frames.CloseFrame;
import org.eclipse.jetty.websocket.frames.PingFrame;
import org.eclipse.jetty.websocket.frames.PongFrame;
import org.junit.Test;
public class ABCase3
{
@Test( expected=IllegalArgumentException.class )
public void testGenerateRSV1PingFrame()
{
PingFrame pingFrame = new PingFrame();
pingFrame.setRsv1(true);
}
@Test( expected=IllegalArgumentException.class )
public void testGenerateRSV2PingFrame()
{
PingFrame pingFrame = new PingFrame();
pingFrame.setRsv2(true);
}
@Test( expected=IllegalArgumentException.class )
public void testGenerateRSV3PingFrame()
{
PingFrame pingFrame = new PingFrame();
pingFrame.setRsv3(true);
}
@Test( expected=IllegalArgumentException.class )
public void testGenerateRSV1PongFrame()
{
PongFrame pongFrame = new PongFrame();
pongFrame.setRsv1(true);
}
@Test( expected=IllegalArgumentException.class )
public void testGenerateRSV2PongFrame()
{
PongFrame pongFrame = new PongFrame();
pongFrame.setRsv2(true);
}
@Test( expected=IllegalArgumentException.class )
public void testGenerateRSV3PongFrame()
{
PongFrame pongFrame = new PongFrame();
pongFrame.setRsv3(true);
}
@Test( expected=IllegalArgumentException.class )
public void testGenerateRSV1CloseFrame()
{
CloseFrame closeFrame = new CloseFrame();
closeFrame.setRsv1(true);
}
@Test( expected=IllegalArgumentException.class )
public void testGenerateRSV2CloseFrame()
{
CloseFrame closeFrame = new CloseFrame();
closeFrame.setRsv2(true);
}
@Test( expected=IllegalArgumentException.class )
public void testGenerateRSV3CloseFrame()
{
CloseFrame closeFrame = new CloseFrame();
closeFrame.setRsv3(true);
}
}