Java Reference
In-Depth Information
finalProposal # new Proposal(lastProposal);
finalProposal.merge(initialProposal());
} else
finalProposal # null ;
}
}
20.4.4
Test
The test can be carried out by running a negotiation. The following code is
the driver for the test; it must be completed by writing the following methods:
the defineSpecification() method creates the specification, e.g. reading it
from a file;
the createClientPref() method creates the preferences for the client;
the createProviderPref() method creates the preferences for the service
provider.
import Negotiation.*;
public class TestDefinition {
public static final int MAX_ITERATIONS # 10;
public static void main(String []args) throws Exception {
// define the specification of the problem that consists
// of attributes and the enumeration of their possible
// values
Specification spec # defineSpecification();
System.out.println(spec);
// define the preference map of the client
PreferenceMap clientPref # createClientPref(spec);
// creates the client negotiator
Negotiator client # new BasicNegotiator(clientPref);
// define the preference map of the server
PreferenceMap providerPref # createProvider Pref(spec);
// creates the server negotiator
Negotiator provider # new BasicNegotiator(provider Pref);
// carry out the negotiation
Mediator mediator # new Mediator(10);
// print the result if successful
if (mediator.startNegotiation(client,provider)){
System.out.println("Client " !
mediator.getClient() !
clientPref.evaluate (mediator.getClient()));
System.out.println ("Provider " !
mediator.getProvider() !
providerPref.evaluate (mediator.getProvider()));
}
}
 
Search WWH ::




Custom Search