CoerciveParsing extends AbstractDoSAttack { @Override public int compareTo( DoSAttack aThat ) { if ( this == aThat ) return EQUAL; if ( !aThat.getClass().equals( getClass() ) ) { return EQUAL; } CoerciveParsing that = (CoerciveParsing) aThat; if ( this.currentNumberOfTags < that.currentNumberOfTags ) return BEFORE; if ( this.currentNumberOfTags > that.currentNumberOfTags ) return AFTER; return EQUAL; } CoerciveParsing(); @Override String getName(); @Override PayloadPosition[] getPossiblePossitions(); IterateModel getNumberOfTagsIterator(); void setNumberOfTagsIterator( IterateModel iterateModel ); String[] getTagNames(); void setTagNames( String[] tagNames ); @Override boolean hasFurtherParams(); @Override void nextParam(); @Override List<DoSParam<?>> getCurrentParams(); @Override String getTamperedRequest( String xml, PayloadPosition payloadPosition ); @Override DoSAttack minimal(); @Override DoSAttack middle( DoSAttack aThat ); @Override void initialize(); @Override int compareTo( DoSAttack aThat );  }
@Test public void compareToTest() { coerciveParsing.nextParam(); assertThat( coerciveParsing.compareTo( coerciveParsing ), is( 0 ) ); assertThat( coerciveParsing.compareTo( new HashCollision() ), is( 0 ) ); CoerciveParsing cp = new CoerciveParsing(); cp.setNumberOfTagsIterator( IterateModel.custom().startAt( 500 ).build() ); cp.nextParam(); assertThat( coerciveParsing.compareTo( cp ), is( 1 ) ); cp = new CoerciveParsing(); cp.setNumberOfTagsIterator( IterateModel.custom().startAt( 5000 ).build() ); cp.nextParam(); assertThat( coerciveParsing.compareTo( cp ), is( -1 ) ); cp = new CoerciveParsing(); cp.setNumberOfTagsIterator( IterateModel.custom().startAt( 2500 ).build() ); cp.nextParam(); assertThat( coerciveParsing.compareTo( cp ), is( 0 ) ); }