@Test public void testGetDecoratorForSD() throws JAXBException, IOException { URL resource = getClass().getResource("/test-resources/sd.xml"); List<ServiceDecorationType> elements = new DecorationParser().getDecorations(resource); assertEquals(1, elements.size()); ServiceDecorationType decoration = elements.get(0); assertEquals(1, decoration.getMatch().size()); MatchType match = decoration.getMatch().get(0); assertEquals("org.acme.foo.*", match.getInterface()); assertEquals(1, match.getMatchProperty().size()); MatchPropertyType matchProp = match.getMatchProperty().get(0); assertEquals("test.prop", matchProp.getName()); assertEquals("xyz", matchProp.getValue()); assertEquals(1, match.getAddProperty().size()); AddPropertyType addProp = match.getAddProperty().get(0); assertEquals("test.too", addProp.getName()); assertEquals("ahaha", addProp.getValue()); assertEquals("java.lang.String", addProp.getType()); }
List<ServiceDecorationType> getDecorations(URL resourceURL) throws JAXBException, IOException { if (resourceURL == null || !decorationType(resourceURL)) { return new ArrayList<>(); } Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); unmarshaller.setSchema(schema); InputStream is = resourceURL.openStream(); Source source = new StreamSource(is); JAXBElement<ServiceDecorationsType> jaxb = unmarshaller.unmarshal(source, ServiceDecorationsType.class); ServiceDecorationsType decorations = jaxb.getValue(); return decorations.getServiceDecoration(); }
DecorationParser { List<ServiceDecorationType> getDecorations(URL resourceURL) throws JAXBException, IOException { if (resourceURL == null || !decorationType(resourceURL)) { return new ArrayList<>(); } Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); unmarshaller.setSchema(schema); InputStream is = resourceURL.openStream(); Source source = new StreamSource(is); JAXBElement<ServiceDecorationsType> jaxb = unmarshaller.unmarshal(source, ServiceDecorationsType.class); ServiceDecorationsType decorations = jaxb.getValue(); return decorations.getServiceDecoration(); } }
DecorationParser { List<ServiceDecorationType> getDecorations(URL resourceURL) throws JAXBException, IOException { if (resourceURL == null || !decorationType(resourceURL)) { return new ArrayList<>(); } Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); unmarshaller.setSchema(schema); InputStream is = resourceURL.openStream(); Source source = new StreamSource(is); JAXBElement<ServiceDecorationsType> jaxb = unmarshaller.unmarshal(source, ServiceDecorationsType.class); ServiceDecorationsType decorations = jaxb.getValue(); return decorations.getServiceDecoration(); } DecorationParser(); }
DecorationParser { List<ServiceDecorationType> getDecorations(URL resourceURL) throws JAXBException, IOException { if (resourceURL == null || !decorationType(resourceURL)) { return new ArrayList<>(); } Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); unmarshaller.setSchema(schema); InputStream is = resourceURL.openStream(); Source source = new StreamSource(is); JAXBElement<ServiceDecorationsType> jaxb = unmarshaller.unmarshal(source, ServiceDecorationsType.class); ServiceDecorationsType decorations = jaxb.getValue(); return decorations.getServiceDecoration(); } DecorationParser();  }
DecorationParser { List<ServiceDecorationType> getDecorations(URL resourceURL) throws JAXBException, IOException { if (resourceURL == null || !decorationType(resourceURL)) { return new ArrayList<>(); } Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); unmarshaller.setSchema(schema); InputStream is = resourceURL.openStream(); Source source = new StreamSource(is); JAXBElement<ServiceDecorationsType> jaxb = unmarshaller.unmarshal(source, ServiceDecorationsType.class); ServiceDecorationsType decorations = jaxb.getValue(); return decorations.getServiceDecoration(); } DecorationParser();   }