package taylor.tops.test;

import java.io.*;
import java.util.*;
import org.apache.commons.logging.*;

public class TestRemote
    implements Serializable
{
  private static final Log log = LogFactory.getLog(TestRemote.class);

  public List getObjects( int number, int mapSize )
  {
    List data = new ArrayList();
    Random rnd = new Random();

    Map testData = new HashMap();
    for ( int j=0; j < mapSize; j++ )
      testData.put( "key" + rnd.nextInt(), "value" + rnd.nextInt() );
    TestParent parent = new TestParent( Integer.toString(rnd.nextInt()), rnd.nextInt(), "Test Object " + rnd.nextInt(), testData );

    testData = new HashMap();
    for ( int j=0; j < mapSize; j++ )
      testData.put( "key" + rnd.nextInt(), "value" + rnd.nextInt() );
    TestParent parent2 = new TestParent( Integer.toString(rnd.nextInt()), rnd.nextInt(), "Test Object " + rnd.nextInt(), testData );

    for ( int i=0; i < number; i++ )
    {
      testData = new HashMap();
      for ( int j=0; j < mapSize; j++ )
        testData.put( "key" + rnd.nextInt(), "value" + rnd.nextInt() );
      data.add( new TestRemotingObject( Integer.toString(rnd.nextInt()), rnd.nextInt(),
                                        "Test Object " + rnd.nextInt(), testData, parent, parent2 ));
    }
    return data;
  }

  public static class TestRemotingObject extends TestParent
  {
    public TestParent parent = null;
    public TestParent parent2 = null;
    public TestRemotingObject( String id, int number, String name, Map testData, TestParent parent, TestParent parent2 )
    {
      super( id, number, name, testData );
      this.parent = parent;
      this.parent2 = parent2;
    }
  }

  public static class TestParent
  {
    public String id;
    public int number;
    public String name;
    public Map testData;

    public TestParent( String id, int number, String name, Map testData )
    {
      this.id = id;
      this.number = number;
      this.name = name;
      this.testData = testData;
    }
  }
}
