CollisionDJBX implements CollisionInterface { @Override public void genNCollisions( int numberAttributes, StringBuilder sb, boolean useNamespace ) { Scanner scanner = null; try { InputStream is = CollisionDJBX.class.getResourceAsStream( "/RubyCollisions/RubyCollisions.txt" ); scanner = new Scanner( is, Charset.defaultCharset().name() ); String prefix = ""; if ( useNamespace == true ) { prefix = "xmlns:"; } for ( int i = 0; i < numberAttributes; i++ ) { String collision = scanner.nextLine(); sb.append( prefix ).append( collision ).append( "=\"" ).append( collision ).append( "\" " ); } } catch ( Exception e ) { e.printStackTrace(); } finally { if ( scanner != null ) { scanner.close(); } } }  int getLengthString(); void setLengthString( int lengthString ); int getLengthSuffix(); void setLengthSuffix( int lengthSuffix ); @Override int getHash( String s ); int hashForth( String s ); int hashBack( String s, int target ); @Override void genNCollisions( int numberAttributes, StringBuilder sb, boolean useNamespace ); @Override String getCollisionString( int i, int n ); Set<String> generateCollionsMeetInTheMiddle( long numberCollisions ); String getIthNCharString( int i, int n );  }
@Test public void genNCollisionsTest() { StringBuilder sb = new StringBuilder(); collisionDJBX.genNCollisions( 2, sb, false ); assertThat( sb.toString(), is( "qqSD2u3H1h=\"qqSD2u3H1h\" DhOXtEllgi=\"DhOXtEllgi\" " ) ); sb = new StringBuilder(); collisionDJBX.genNCollisions( 2, sb, true ); assertThat( sb.toString(), is( "xmlns:qqSD2u3H1h=\"qqSD2u3H1h\" xmlns:DhOXtEllgi=\"DhOXtEllgi\" " ) ); }