1 | package negotiator.repository.boa;
|
---|
2 |
|
---|
3 | import java.io.StringReader;
|
---|
4 | import java.io.StringWriter;
|
---|
5 |
|
---|
6 | import javax.xml.bind.JAXBContext;
|
---|
7 | import javax.xml.bind.JAXBException;
|
---|
8 | import javax.xml.bind.Marshaller;
|
---|
9 | import javax.xml.bind.Unmarshaller;
|
---|
10 |
|
---|
11 | import org.junit.Test;
|
---|
12 |
|
---|
13 | import genius.core.boaframework.AcceptanceStrategy;
|
---|
14 | import genius.core.repository.boa.BoaRepItem;
|
---|
15 | import genius.core.repository.boa.BoaWithSettingsRepItem;
|
---|
16 | import genius.core.repository.boa.ParameterList;
|
---|
17 |
|
---|
18 | public class BoaWithSettingsRepItemTest {
|
---|
19 |
|
---|
20 | @Test
|
---|
21 | public void testDeserialize() throws JAXBException {
|
---|
22 | JAXBContext jaxbContext = JAXBContext.newInstance(BoaWithSettingsRepItem.class);
|
---|
23 | Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
|
---|
24 | String TEXT = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><boawithsettings><parameters/><item classpath=\"class.path\"/></boawithsettings>";
|
---|
25 | StringReader reader = new StringReader(TEXT);
|
---|
26 | BoaWithSettingsRepItem element = (BoaWithSettingsRepItem) unmarshaller.unmarshal(reader);
|
---|
27 |
|
---|
28 | System.out.println(element);
|
---|
29 | }
|
---|
30 |
|
---|
31 | @Test
|
---|
32 | public void testSerialize() throws JAXBException {
|
---|
33 | BoaRepItem<AcceptanceStrategy> ac = new BoaRepItem<AcceptanceStrategy>("class.path");
|
---|
34 | ParameterList params = new ParameterList();
|
---|
35 | BoaWithSettingsRepItem<AcceptanceStrategy> elt = new BoaWithSettingsRepItem<AcceptanceStrategy>(ac, params);
|
---|
36 | StringWriter writer = new StringWriter();
|
---|
37 |
|
---|
38 | JAXBContext context = JAXBContext.newInstance(BoaWithSettingsRepItem.class);
|
---|
39 | Marshaller m = context.createMarshaller();
|
---|
40 | m.marshal(elt, writer);
|
---|
41 | System.out.println(writer.toString());
|
---|
42 | }
|
---|
43 | }
|
---|