-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
InjectJaxbContextTest.java
53 lines (39 loc) · 1.29 KB
/
InjectJaxbContextTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package io.quarkus.jaxb.deployment;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.io.StringWriter;
import javax.inject.Inject;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import org.junit.jupiter.api.Test;
import io.quarkus.test.junit.QuarkusTest;
@QuarkusTest
public class InjectJaxbContextTest {
@Inject
JAXBContext jaxbContext;
@Inject
Marshaller marshaller;
@Inject
Unmarshaller unmarshaller;
@Test
public void shouldInjectJaxbBeans() {
assertNotNull(jaxbContext);
assertNotNull(marshaller);
assertNotNull(unmarshaller);
}
@Test
public void shouldPersonBeInTheJaxbContext() throws JAXBException {
Person person = new Person();
person.setFirst("first");
person.setLast("last");
StringWriter sw = new StringWriter();
marshaller.marshal(person, sw);
assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"
+ "<person>\n"
+ " <first>first</first>\n"
+ " <last>last</last>\n"
+ "</person>\n", sw.toString());
}
}