@Test void load() { ListenPortLoader loader = new ListenPortLoader(); Bundle bundle = new Bundle(); loader.load(bundle, buildListenPortElement(DocumentTools.INSTANCE.getDocumentBuilder().newDocument(), true)); assertFalse(bundle.getListenPorts().isEmpty()); assertEquals(1, bundle.getListenPorts().size()); ListenPort listenPort = bundle.getListenPorts().get("port"); assertNotNull(listenPort); assertEquals(1234, listenPort.getPort()); assertEquals("http", listenPort.getProtocol()); assertTrue(SetUtils.isEqualSet(listenPort.getEnabledFeatures(), Stream.of(Feature.values()).map(Feature::name).collect(Collectors.toSet()))); assertEquals("Service", listenPort.getTargetServiceReference()); assertNotNull(listenPort.getTlsSettings()); ListenPortTlsSettings tlsSettings = listenPort.getTlsSettings(); Assertions.assertEquals(ClientAuthentication.REQUIRED, tlsSettings.getClientAuthentication()); assertTrue(SetUtils.isEqualSet(tlsSettings.getEnabledCipherSuites(), ListenPort.DEFAULT_RECOMMENDED_CIPHERS)); assertTrue(SetUtils.isEqualSet(tlsSettings.getEnabledVersions(), ListenPort.TLS_VERSIONS)); assertEquals("Key", tlsSettings.getPrivateKey()); assertPropertiesContent(Collections.emptyMap(), tlsSettings.getProperties()); assertPropertiesContent(ImmutableMap.of("prop", "value"), listenPort.getProperties()); }
@Override public void load(final Bundle bundle, final Element element) { final Element listenPortElement = getSingleChildElement(getSingleChildElement(element, RESOURCE), LISTEN_PORT); final String name = getSingleChildElementTextContent(listenPortElement, NAME); final String protocol = getSingleChildElementTextContent(listenPortElement, PROTOCOL); final Integer port = parseInt(getSingleChildElementTextContent(listenPortElement, PORT)); final Set<String> enabledFeatures = getChildElementsTextContents(getSingleChildElement(listenPortElement, ENABLED_FEATURES), STRING_VALUE); final String targetServiceReference = getTargetServiceReferenceId(listenPortElement); final ListenPortTlsSettings tlsSettings = getTlsSettings(listenPortElement); Map<String, Object> properties = mapPropertiesElements(getSingleChildElement(listenPortElement, PROPERTIES, true), PROPERTIES); if (!equalsAny(protocol, PROTOCOL_FTP, PROTOCOL_FTPS)) { properties.remove(USE_EXTENDED_FTP_COMMAND_SET); if (properties.isEmpty()) { properties = null; } } ListenPort listenPort = new ListenPort(); listenPort.setId(listenPortElement.getAttribute(ATTRIBUTE_ID)); listenPort.setName(name); listenPort.setProtocol(protocol); listenPort.setPort(port); listenPort.setEnabledFeatures(enabledFeatures); listenPort.setTargetServiceReference(targetServiceReference); listenPort.setTlsSettings(tlsSettings); listenPort.setProperties(properties); bundle.getListenPorts().put(name, listenPort); }
ListenPortLoader implements BundleEntityLoader { @Override public void load(final Bundle bundle, final Element element) { final Element listenPortElement = getSingleChildElement(getSingleChildElement(element, RESOURCE), LISTEN_PORT); final String name = getSingleChildElementTextContent(listenPortElement, NAME); final String protocol = getSingleChildElementTextContent(listenPortElement, PROTOCOL); final Integer port = parseInt(getSingleChildElementTextContent(listenPortElement, PORT)); final Set<String> enabledFeatures = getChildElementsTextContents(getSingleChildElement(listenPortElement, ENABLED_FEATURES), STRING_VALUE); final String targetServiceReference = getTargetServiceReferenceId(listenPortElement); final ListenPortTlsSettings tlsSettings = getTlsSettings(listenPortElement); Map<String, Object> properties = mapPropertiesElements(getSingleChildElement(listenPortElement, PROPERTIES, true), PROPERTIES); if (!equalsAny(protocol, PROTOCOL_FTP, PROTOCOL_FTPS)) { properties.remove(USE_EXTENDED_FTP_COMMAND_SET); if (properties.isEmpty()) { properties = null; } } ListenPort listenPort = new ListenPort(); listenPort.setId(listenPortElement.getAttribute(ATTRIBUTE_ID)); listenPort.setName(name); listenPort.setProtocol(protocol); listenPort.setPort(port); listenPort.setEnabledFeatures(enabledFeatures); listenPort.setTargetServiceReference(targetServiceReference); listenPort.setTlsSettings(tlsSettings); listenPort.setProperties(properties); bundle.getListenPorts().put(name, listenPort); } }
ListenPortLoader implements BundleEntityLoader { @Override public void load(final Bundle bundle, final Element element) { final Element listenPortElement = getSingleChildElement(getSingleChildElement(element, RESOURCE), LISTEN_PORT); final String name = getSingleChildElementTextContent(listenPortElement, NAME); final String protocol = getSingleChildElementTextContent(listenPortElement, PROTOCOL); final Integer port = parseInt(getSingleChildElementTextContent(listenPortElement, PORT)); final Set<String> enabledFeatures = getChildElementsTextContents(getSingleChildElement(listenPortElement, ENABLED_FEATURES), STRING_VALUE); final String targetServiceReference = getTargetServiceReferenceId(listenPortElement); final ListenPortTlsSettings tlsSettings = getTlsSettings(listenPortElement); Map<String, Object> properties = mapPropertiesElements(getSingleChildElement(listenPortElement, PROPERTIES, true), PROPERTIES); if (!equalsAny(protocol, PROTOCOL_FTP, PROTOCOL_FTPS)) { properties.remove(USE_EXTENDED_FTP_COMMAND_SET); if (properties.isEmpty()) { properties = null; } } ListenPort listenPort = new ListenPort(); listenPort.setId(listenPortElement.getAttribute(ATTRIBUTE_ID)); listenPort.setName(name); listenPort.setProtocol(protocol); listenPort.setPort(port); listenPort.setEnabledFeatures(enabledFeatures); listenPort.setTargetServiceReference(targetServiceReference); listenPort.setTlsSettings(tlsSettings); listenPort.setProperties(properties); bundle.getListenPorts().put(name, listenPort); }  }
ListenPortLoader implements BundleEntityLoader { @Override public void load(final Bundle bundle, final Element element) { final Element listenPortElement = getSingleChildElement(getSingleChildElement(element, RESOURCE), LISTEN_PORT); final String name = getSingleChildElementTextContent(listenPortElement, NAME); final String protocol = getSingleChildElementTextContent(listenPortElement, PROTOCOL); final Integer port = parseInt(getSingleChildElementTextContent(listenPortElement, PORT)); final Set<String> enabledFeatures = getChildElementsTextContents(getSingleChildElement(listenPortElement, ENABLED_FEATURES), STRING_VALUE); final String targetServiceReference = getTargetServiceReferenceId(listenPortElement); final ListenPortTlsSettings tlsSettings = getTlsSettings(listenPortElement); Map<String, Object> properties = mapPropertiesElements(getSingleChildElement(listenPortElement, PROPERTIES, true), PROPERTIES); if (!equalsAny(protocol, PROTOCOL_FTP, PROTOCOL_FTPS)) { properties.remove(USE_EXTENDED_FTP_COMMAND_SET); if (properties.isEmpty()) { properties = null; } } ListenPort listenPort = new ListenPort(); listenPort.setId(listenPortElement.getAttribute(ATTRIBUTE_ID)); listenPort.setName(name); listenPort.setProtocol(protocol); listenPort.setPort(port); listenPort.setEnabledFeatures(enabledFeatures); listenPort.setTargetServiceReference(targetServiceReference); listenPort.setTlsSettings(tlsSettings); listenPort.setProperties(properties); bundle.getListenPorts().put(name, listenPort); }  @Override void load(final Bundle bundle, final Element element); @Override String getEntityType(); }
ListenPortLoader implements BundleEntityLoader { @Override public void load(final Bundle bundle, final Element element) { final Element listenPortElement = getSingleChildElement(getSingleChildElement(element, RESOURCE), LISTEN_PORT); final String name = getSingleChildElementTextContent(listenPortElement, NAME); final String protocol = getSingleChildElementTextContent(listenPortElement, PROTOCOL); final Integer port = parseInt(getSingleChildElementTextContent(listenPortElement, PORT)); final Set<String> enabledFeatures = getChildElementsTextContents(getSingleChildElement(listenPortElement, ENABLED_FEATURES), STRING_VALUE); final String targetServiceReference = getTargetServiceReferenceId(listenPortElement); final ListenPortTlsSettings tlsSettings = getTlsSettings(listenPortElement); Map<String, Object> properties = mapPropertiesElements(getSingleChildElement(listenPortElement, PROPERTIES, true), PROPERTIES); if (!equalsAny(protocol, PROTOCOL_FTP, PROTOCOL_FTPS)) { properties.remove(USE_EXTENDED_FTP_COMMAND_SET); if (properties.isEmpty()) { properties = null; } } ListenPort listenPort = new ListenPort(); listenPort.setId(listenPortElement.getAttribute(ATTRIBUTE_ID)); listenPort.setName(name); listenPort.setProtocol(protocol); listenPort.setPort(port); listenPort.setEnabledFeatures(enabledFeatures); listenPort.setTargetServiceReference(targetServiceReference); listenPort.setTlsSettings(tlsSettings); listenPort.setProperties(properties); bundle.getListenPorts().put(name, listenPort); }  @Override void load(final Bundle bundle, final Element element); @Override String getEntityType();  }