Exemplo n.º 1
0
  @Override
  public boolean doTest() {
    ArraySet<UserAgent> l = new ArraySet<UserAgent>();

    l.add(new UserAgent("", "", TicketTestHelper.user1, 8., 7., 6., 5.));
    l.add(new UserAgent("", "", TicketTestHelper.user2, 1., 2., 3., 4.));
    l.add(new UserAgent("", "", TicketTestHelper.user3, 9., 10., 11., 12.));

    ArraySet.sort(l, new socialComparator());

    return (l.get(2).getName() == TicketTestHelper.user3)
        && (l.get(1).getName() == TicketTestHelper.user1)
        && (l.get(0).getName() == TicketTestHelper.user2);
  }
  @Override
  public boolean doTest() throws Exception {
    LCServer aClient =
        new LCServer(
            DefaultTestClient.ipAddr,
            DefaultTestClient.EDCPort,
            DefaultTestClient.ipAddr,
            DefaultTestClient.HLCPort,
            9012,
            TicketTestHelper.user1,
            "");
    LCServer bClient =
        new LCServer(
            DefaultTestClient.ipAddr,
            DefaultTestClient.EDCPort,
            DefaultTestClient.ipAddr,
            DefaultTestClient.HLCPort,
            9013,
            TicketTestHelper.user2,
            "");

    aClient.start();
    bClient.start();

    String locationOfB = "localHost";
    int portOfB = 9013;
    aClient.registerUser(0., 0., 0., aClient.getPort());
    bClient.registerUser(0., 3., 0., bClient.getPort());

    TicketTestHelper.bindRequirement(aClient.client, 1.1, 2.3, 4, 1.);
    TicketTestHelper.bindRequirement(bClient.client, 1.1, 2.3, 4, 3.);

    aClient.client.GodModeCalcTKTS();

    final ArraySet<ElectricityTicket> a = aClient.client.getTickets();
    final ArraySet<ElectricityTicket> b = bClient.client.getTickets();
    UUID aID = UUID.fromString(a.get(0).id.toString());
    UUID bID = UUID.fromString(b.get(0).id.toString());

    aClient.registerClient(locationOfB, portOfB);
    ElectricityRequirement req = aClient.client.handler.getReqs().get(0);
    ArraySet<ElectricityTicket> competing =
        aClient.client.queryCompeting(locationOfB, portOfB, req);
    aClient.client.offer(
        locationOfB, portOfB, competing.get(0), aClient.client.handler.findMatchingTicket(req));

    ArraySet<ElectricityTicket> c = aClient.client.getTickets();
    ArraySet<ElectricityTicket> d = bClient.client.getTickets();

    Boolean temp1 =
        (c.get(0).getId().equals(aID.toString())) && (d.get(0).getId().equals(bID.toString()));

    bClient.setTicketAmplitudeModifiable(true);
    aClient.client.offer(
        locationOfB, portOfB, competing.get(0), aClient.client.handler.findMatchingTicket(req));

    ArraySet<ElectricityTicket> e = aClient.client.getTickets();
    ArraySet<ElectricityTicket> f = bClient.client.getTickets();

    Boolean temp2 =
        (e.get(0).getId().equals(bID.toString())) && (f.get(0).getId().equals(aID.toString()));

    aClient.client.wipeAll();
    aClient.close();
    bClient.close();
    return temp1 && temp2;
  }