MutableLocatable implements BareLocatable, Serializable { @XmlTransient @Override @Nullable public Location getLocation() { return location; } protected  MutableLocatable(); protected  MutableLocatable(BareLocatable original, CopyOption[] copyOptions); @Override boolean equals(@Nullable Object otherObject); @Override int hashCode(); @XmlTransient @Override @Nullable Location getLocation(); D setLocation(@Nullable Location location);  }
@Test public void locationTest() throws XMLStreamException, JAXBException { JAXBContext jaxbContext = JAXBContext.newInstance(MutableExecutable.class); XMLInputFactory inputFactory = XMLInputFactory.newFactory(); StreamSource source = new StreamSource(getClass().getResourceAsStream("MutableLocatableTest.xml"), "file:/tmp/MutableLocatableTest.xml"); XMLStreamReader streamReader = inputFactory.createXMLStreamReader(source); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); unmarshaller.setListener(new SourceCodeLocationListener(streamReader)); MutableExecutable executable = (MutableExecutable) unmarshaller.unmarshal(streamReader); Location location; location = executable.getLocation(); Assert.assertEquals(location.getSystemId(), "file:/tmp/MutableLocatableTest.xml"); Assert.assertEquals(location.getLineNumber(), 2); Assert.assertTrue(location.getColumnNumber() >= 59 && location.getColumnNumber() <= 60); location = executable.getModule().getLocation(); Assert.assertEquals(location.getSystemId(), "file:/tmp/MutableLocatableTest.xml"); Assert.assertEquals(location.getLineNumber(), 7); Assert.assertTrue(location.getColumnNumber() >= 33 && location.getColumnNumber() <= 34); }