[1] | 1 | package negotiator.config;
|
---|
| 2 |
|
---|
| 3 | import static org.junit.Assert.assertFalse;
|
---|
| 4 |
|
---|
| 5 | import java.io.ByteArrayOutputStream;
|
---|
| 6 | import java.io.File;
|
---|
| 7 | import java.util.ArrayList;
|
---|
| 8 | import java.util.List;
|
---|
| 9 |
|
---|
| 10 | import javax.xml.bind.JAXBException;
|
---|
| 11 |
|
---|
| 12 | import org.junit.Test;
|
---|
| 13 |
|
---|
| 14 | import genius.core.Deadline;
|
---|
| 15 | import genius.core.DeadlineType;
|
---|
| 16 | import genius.core.config.MultilateralTournamentConfiguration;
|
---|
| 17 | import genius.core.config.MultilateralTournamentsConfiguration;
|
---|
| 18 | import genius.core.exceptions.InstantiateException;
|
---|
| 19 | import genius.core.persistent.PersistentDataType;
|
---|
| 20 | import genius.core.repository.MultiPartyProtocolRepItem;
|
---|
| 21 | import genius.core.repository.ParticipantRepItem;
|
---|
| 22 | import genius.core.repository.PartyRepItem;
|
---|
| 23 | import genius.core.repository.ProfileRepItem;
|
---|
| 24 | import genius.core.repository.boa.BoaPartyRepItem;
|
---|
| 25 |
|
---|
| 26 | /**
|
---|
| 27 | * Try to read n a configuration
|
---|
| 28 | *
|
---|
| 29 | */
|
---|
| 30 | public class MultilateralTournamentsConfigurationTest {
|
---|
| 31 | private final static String RESOURCES = "src/test/resources/";
|
---|
| 32 |
|
---|
| 33 | @Test
|
---|
| 34 | public void smokeTest() throws JAXBException {
|
---|
| 35 |
|
---|
| 36 | File file = new File(RESOURCES + "tournamentconfig.xml");
|
---|
| 37 | MultilateralTournamentsConfiguration.load(file);
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | @Test
|
---|
| 41 | public void writeSimpleTournamentConfig() throws InstantiateException {
|
---|
| 42 | MultiPartyProtocolRepItem protocol = new MultiPartyProtocolRepItem();
|
---|
| 43 | Deadline deadline2 = new Deadline(180, DeadlineType.ROUND);
|
---|
| 44 | PartyRepItem mediator = new PartyRepItem("unknown.path");
|
---|
| 45 | List<ParticipantRepItem> parties = new ArrayList<>();
|
---|
| 46 |
|
---|
| 47 | parties.add(new PartyRepItem("simple.party"));
|
---|
| 48 | parties.add(new BoaPartyRepItem("boaparty"));
|
---|
| 49 |
|
---|
| 50 | List<ProfileRepItem> profiles = new ArrayList<>();
|
---|
| 51 | List<ParticipantRepItem> partiesB = new ArrayList<>();
|
---|
| 52 | List<ProfileRepItem> profilesB = new ArrayList<>();
|
---|
| 53 | int nrepeats = 1;
|
---|
| 54 | int nparties = 2;
|
---|
| 55 | boolean repeatParties = false;
|
---|
| 56 | boolean isRandomSessionOrder = false;
|
---|
| 57 | PersistentDataType type = PersistentDataType.DISABLED;
|
---|
| 58 | boolean enablePrint = false;
|
---|
| 59 | MultilateralTournamentConfiguration config = new MultilateralTournamentConfiguration(protocol, deadline2,
|
---|
| 60 | mediator, parties, profiles, partiesB, profilesB, nrepeats, nparties, repeatParties,
|
---|
| 61 | isRandomSessionOrder, type, enablePrint);
|
---|
| 62 |
|
---|
| 63 | ByteArrayOutputStream out = new ByteArrayOutputStream();
|
---|
| 64 | config.save(out);
|
---|
| 65 |
|
---|
| 66 | String result = new String(out.toByteArray());
|
---|
| 67 | System.out.println(result);
|
---|
| 68 |
|
---|
| 69 | assertFalse("serialization must not contain xmlns:", result.contains("xmlns:"));
|
---|
| 70 | assertFalse("serialization must not contain xsi:", result.contains("xsi:"));
|
---|
| 71 |
|
---|
| 72 | }
|
---|
| 73 | }
|
---|