FileDocCategorySizeDatePackage
Test.javaAPI DocAzureus 3.0.3.43306Thu Jan 11 07:45:30 GMT 2007com.aelitis.azureus.core.dht.router.impl

Test

public class Test extends Object
author
parg

Fields Summary
protected static long
next_sha1_seed
Constructors Summary
Methods Summary
protected static byte[]getSHA1()

	
	  
	
	
		return( new SHA1Simple().calculateHash( ( "" + ( next_sha1_seed++ )).getBytes()));
	
public static voidmain(java.lang.String[] args)

		randomTest();
	
protected static voidrandomTest()

		DHTRouter	router = DHTRouterFactory.create( 20, 5, 5, getSHA1(), null, com.aelitis.azureus.core.dht.impl.Test.getLogger());
		
		router.setAdapter( 
				new DHTRouterAdapter()
				{
					public void requestAdd(DHTRouterContact contact) {
						// TODO Auto-generated method stub
						
					}
					public void requestLookup(byte[] id, String description) {
						// TODO Auto-generated method stub
						
					}
					public void requestPing(DHTRouterContact contact) {
						// TODO Auto-generated method stub
						
					}
				});
		
		for (int i=0;i<1000000;i++){
			
			byte[]	id = getSHA1();
			
			DHTRouterContact cont = router.contactKnown( id, null);
		}
		
		router.print();
	
protected static voidsimpleTest()

		DHTRouter	router = DHTRouterFactory.create( 1, 1,1,  new byte[]{ 0 }, null, com.aelitis.azureus.core.dht.impl.Test.getLogger());
		
		router.setAdapter( 
			new DHTRouterAdapter()
			{
				public void requestAdd(DHTRouterContact contact) {
					// TODO Auto-generated method stub
					
				}
				public void requestLookup(byte[] id, String description) {
					// TODO Auto-generated method stub
					
				}
				public void requestPing(DHTRouterContact contact) {
					// TODO Auto-generated method stub
					
				}
			});
		
		byte[][]	node_ids ={ 
				{ toByte( "11111111" ) },		
				{ toByte( "01111111" ) },		
				{ toByte( "00101111" ) },		
				{ toByte( "00100111" ) },		
				//{ toByte( "00111111" ) },		
		};
		
		for (int i=0;i<node_ids.length;i++){
						
			router.contactKnown( node_ids[i], null );
		}

			// byte[]	node_id = new byte[]{ 1,1,1,1 }; //new SHA1Hasher().calculateHash( (""+i).getBytes());

		router.print();
	
protected static bytetoByte(java.lang.String str)

		int	res = 0;
		
		for (int i=0;i<8;i++){
		
			if ( str.charAt(i) == '1" ){
				
				res += 1<<(7-i);
			}
		}
		
		return((byte)res);