@Test void load() { Bundle bundle = new Bundle(); loader.load(bundle, createCassandraXml(DocumentTools.INSTANCE.getDocumentBuilder().newDocument(), true, true)); assertFalse(bundle.getCassandraConnections().isEmpty()); assertEquals(1, bundle.getCassandraConnections().size()); assertNotNull(bundle.getCassandraConnections().get("Test")); CassandraConnection entity = bundle.getCassandraConnections().get("Test"); assertNotNull(entity); assertEquals("id", entity.getId()); assertEquals("Test", entity.getKeyspace()); assertEquals("Test", entity.getContactPoint()); assertEquals(new Integer(1234), entity.getPort()); assertEquals("Test", entity.getUsername()); assertEquals("password", entity.getPasswordId()); assertEquals("Test", entity.getCompression()); assertEquals(true, entity.getSsl()); assertNotNull(entity.getTlsCiphers()); assertTrue(entity.getTlsCiphers().containsAll(getAlgorithms("Cipher"))); assertNotNull(entity.getProperties()); assertFalse(entity.getProperties().isEmpty()); assertEquals(1, entity.getProperties().size()); assertEquals("testValue", entity.getProperties().get("testProp")); }
@Override public void load(Bundle bundle, Element element) { final Element cassandraConnectionElement = getSingleChildElement(getSingleChildElement(element, RESOURCE), CASSANDRA_CONNECTION); final String name = getSingleChildElementTextContent(cassandraConnectionElement, NAME); CassandraConnection cassandraConnection = new CassandraConnection(); cassandraConnection.setName(name); cassandraConnection.setId(cassandraConnectionElement.getAttribute(ATTRIBUTE_ID)); cassandraConnection.setKeyspace(getSingleChildElementTextContent(cassandraConnectionElement, KEYSPACE)); cassandraConnection.setCompression(getSingleChildElementTextContent(cassandraConnectionElement, COMPRESSION)); cassandraConnection.setContactPoint(getSingleChildElementTextContent(cassandraConnectionElement, CONTACT_POINT)); cassandraConnection.setPort(Integer.parseInt(getSingleChildElementTextContent(cassandraConnectionElement, PORT))); cassandraConnection.setProperties(mapPropertiesElements(getSingleChildElement(cassandraConnectionElement, PROPERTIES, true), PROPERTIES)); cassandraConnection.setSsl(Boolean.parseBoolean(getSingleChildElementTextContent(cassandraConnectionElement, SSL))); cassandraConnection.setUsername(getSingleChildElementTextContent(cassandraConnectionElement, USERNAME)); final Element passwordIdElement = getSingleChildElement(cassandraConnectionElement, PASSWORD_ID, true); cassandraConnection.setPasswordId(passwordIdElement != null ? passwordIdElement.getTextContent() : null); Set<String> ciphers = null; final Element tlsCiphersElement = getSingleChildElement(cassandraConnectionElement, TLS_CIPHERS, true); final String ciphersAsString = tlsCiphersElement != null ? tlsCiphersElement.getTextContent() : null; if (isNotEmpty(ciphersAsString)) { ciphers = new HashSet<>(Arrays.asList(ciphersAsString.split(","))); } cassandraConnection.setTlsCiphers(ciphers); cassandraConnection.setProperties(mapPropertiesElements(getSingleChildElement(cassandraConnectionElement, PROPERTIES, true), PROPERTIES)); Set<Annotation> annotations = new HashSet<>(); Annotation bundleEntity = new Annotation(AnnotationType.BUNDLE_HINTS); bundleEntity.setId(cassandraConnectionElement.getAttribute(ATTRIBUTE_ID)); annotations.add(bundleEntity); cassandraConnection.setAnnotations(annotations); bundle.getCassandraConnections().put(name, cassandraConnection); }
CassandraConnectionsLoader implements BundleEntityLoader { @Override public void load(Bundle bundle, Element element) { final Element cassandraConnectionElement = getSingleChildElement(getSingleChildElement(element, RESOURCE), CASSANDRA_CONNECTION); final String name = getSingleChildElementTextContent(cassandraConnectionElement, NAME); CassandraConnection cassandraConnection = new CassandraConnection(); cassandraConnection.setName(name); cassandraConnection.setId(cassandraConnectionElement.getAttribute(ATTRIBUTE_ID)); cassandraConnection.setKeyspace(getSingleChildElementTextContent(cassandraConnectionElement, KEYSPACE)); cassandraConnection.setCompression(getSingleChildElementTextContent(cassandraConnectionElement, COMPRESSION)); cassandraConnection.setContactPoint(getSingleChildElementTextContent(cassandraConnectionElement, CONTACT_POINT)); cassandraConnection.setPort(Integer.parseInt(getSingleChildElementTextContent(cassandraConnectionElement, PORT))); cassandraConnection.setProperties(mapPropertiesElements(getSingleChildElement(cassandraConnectionElement, PROPERTIES, true), PROPERTIES)); cassandraConnection.setSsl(Boolean.parseBoolean(getSingleChildElementTextContent(cassandraConnectionElement, SSL))); cassandraConnection.setUsername(getSingleChildElementTextContent(cassandraConnectionElement, USERNAME)); final Element passwordIdElement = getSingleChildElement(cassandraConnectionElement, PASSWORD_ID, true); cassandraConnection.setPasswordId(passwordIdElement != null ? passwordIdElement.getTextContent() : null); Set<String> ciphers = null; final Element tlsCiphersElement = getSingleChildElement(cassandraConnectionElement, TLS_CIPHERS, true); final String ciphersAsString = tlsCiphersElement != null ? tlsCiphersElement.getTextContent() : null; if (isNotEmpty(ciphersAsString)) { ciphers = new HashSet<>(Arrays.asList(ciphersAsString.split(","))); } cassandraConnection.setTlsCiphers(ciphers); cassandraConnection.setProperties(mapPropertiesElements(getSingleChildElement(cassandraConnectionElement, PROPERTIES, true), PROPERTIES)); Set<Annotation> annotations = new HashSet<>(); Annotation bundleEntity = new Annotation(AnnotationType.BUNDLE_HINTS); bundleEntity.setId(cassandraConnectionElement.getAttribute(ATTRIBUTE_ID)); annotations.add(bundleEntity); cassandraConnection.setAnnotations(annotations); bundle.getCassandraConnections().put(name, cassandraConnection); } }
CassandraConnectionsLoader implements BundleEntityLoader { @Override public void load(Bundle bundle, Element element) { final Element cassandraConnectionElement = getSingleChildElement(getSingleChildElement(element, RESOURCE), CASSANDRA_CONNECTION); final String name = getSingleChildElementTextContent(cassandraConnectionElement, NAME); CassandraConnection cassandraConnection = new CassandraConnection(); cassandraConnection.setName(name); cassandraConnection.setId(cassandraConnectionElement.getAttribute(ATTRIBUTE_ID)); cassandraConnection.setKeyspace(getSingleChildElementTextContent(cassandraConnectionElement, KEYSPACE)); cassandraConnection.setCompression(getSingleChildElementTextContent(cassandraConnectionElement, COMPRESSION)); cassandraConnection.setContactPoint(getSingleChildElementTextContent(cassandraConnectionElement, CONTACT_POINT)); cassandraConnection.setPort(Integer.parseInt(getSingleChildElementTextContent(cassandraConnectionElement, PORT))); cassandraConnection.setProperties(mapPropertiesElements(getSingleChildElement(cassandraConnectionElement, PROPERTIES, true), PROPERTIES)); cassandraConnection.setSsl(Boolean.parseBoolean(getSingleChildElementTextContent(cassandraConnectionElement, SSL))); cassandraConnection.setUsername(getSingleChildElementTextContent(cassandraConnectionElement, USERNAME)); final Element passwordIdElement = getSingleChildElement(cassandraConnectionElement, PASSWORD_ID, true); cassandraConnection.setPasswordId(passwordIdElement != null ? passwordIdElement.getTextContent() : null); Set<String> ciphers = null; final Element tlsCiphersElement = getSingleChildElement(cassandraConnectionElement, TLS_CIPHERS, true); final String ciphersAsString = tlsCiphersElement != null ? tlsCiphersElement.getTextContent() : null; if (isNotEmpty(ciphersAsString)) { ciphers = new HashSet<>(Arrays.asList(ciphersAsString.split(","))); } cassandraConnection.setTlsCiphers(ciphers); cassandraConnection.setProperties(mapPropertiesElements(getSingleChildElement(cassandraConnectionElement, PROPERTIES, true), PROPERTIES)); Set<Annotation> annotations = new HashSet<>(); Annotation bundleEntity = new Annotation(AnnotationType.BUNDLE_HINTS); bundleEntity.setId(cassandraConnectionElement.getAttribute(ATTRIBUTE_ID)); annotations.add(bundleEntity); cassandraConnection.setAnnotations(annotations); bundle.getCassandraConnections().put(name, cassandraConnection); }  }
CassandraConnectionsLoader implements BundleEntityLoader { @Override public void load(Bundle bundle, Element element) { final Element cassandraConnectionElement = getSingleChildElement(getSingleChildElement(element, RESOURCE), CASSANDRA_CONNECTION); final String name = getSingleChildElementTextContent(cassandraConnectionElement, NAME); CassandraConnection cassandraConnection = new CassandraConnection(); cassandraConnection.setName(name); cassandraConnection.setId(cassandraConnectionElement.getAttribute(ATTRIBUTE_ID)); cassandraConnection.setKeyspace(getSingleChildElementTextContent(cassandraConnectionElement, KEYSPACE)); cassandraConnection.setCompression(getSingleChildElementTextContent(cassandraConnectionElement, COMPRESSION)); cassandraConnection.setContactPoint(getSingleChildElementTextContent(cassandraConnectionElement, CONTACT_POINT)); cassandraConnection.setPort(Integer.parseInt(getSingleChildElementTextContent(cassandraConnectionElement, PORT))); cassandraConnection.setProperties(mapPropertiesElements(getSingleChildElement(cassandraConnectionElement, PROPERTIES, true), PROPERTIES)); cassandraConnection.setSsl(Boolean.parseBoolean(getSingleChildElementTextContent(cassandraConnectionElement, SSL))); cassandraConnection.setUsername(getSingleChildElementTextContent(cassandraConnectionElement, USERNAME)); final Element passwordIdElement = getSingleChildElement(cassandraConnectionElement, PASSWORD_ID, true); cassandraConnection.setPasswordId(passwordIdElement != null ? passwordIdElement.getTextContent() : null); Set<String> ciphers = null; final Element tlsCiphersElement = getSingleChildElement(cassandraConnectionElement, TLS_CIPHERS, true); final String ciphersAsString = tlsCiphersElement != null ? tlsCiphersElement.getTextContent() : null; if (isNotEmpty(ciphersAsString)) { ciphers = new HashSet<>(Arrays.asList(ciphersAsString.split(","))); } cassandraConnection.setTlsCiphers(ciphers); cassandraConnection.setProperties(mapPropertiesElements(getSingleChildElement(cassandraConnectionElement, PROPERTIES, true), PROPERTIES)); Set<Annotation> annotations = new HashSet<>(); Annotation bundleEntity = new Annotation(AnnotationType.BUNDLE_HINTS); bundleEntity.setId(cassandraConnectionElement.getAttribute(ATTRIBUTE_ID)); annotations.add(bundleEntity); cassandraConnection.setAnnotations(annotations); bundle.getCassandraConnections().put(name, cassandraConnection); }  @Override void load(Bundle bundle, Element element); @Override String getEntityType(); }
CassandraConnectionsLoader implements BundleEntityLoader { @Override public void load(Bundle bundle, Element element) { final Element cassandraConnectionElement = getSingleChildElement(getSingleChildElement(element, RESOURCE), CASSANDRA_CONNECTION); final String name = getSingleChildElementTextContent(cassandraConnectionElement, NAME); CassandraConnection cassandraConnection = new CassandraConnection(); cassandraConnection.setName(name); cassandraConnection.setId(cassandraConnectionElement.getAttribute(ATTRIBUTE_ID)); cassandraConnection.setKeyspace(getSingleChildElementTextContent(cassandraConnectionElement, KEYSPACE)); cassandraConnection.setCompression(getSingleChildElementTextContent(cassandraConnectionElement, COMPRESSION)); cassandraConnection.setContactPoint(getSingleChildElementTextContent(cassandraConnectionElement, CONTACT_POINT)); cassandraConnection.setPort(Integer.parseInt(getSingleChildElementTextContent(cassandraConnectionElement, PORT))); cassandraConnection.setProperties(mapPropertiesElements(getSingleChildElement(cassandraConnectionElement, PROPERTIES, true), PROPERTIES)); cassandraConnection.setSsl(Boolean.parseBoolean(getSingleChildElementTextContent(cassandraConnectionElement, SSL))); cassandraConnection.setUsername(getSingleChildElementTextContent(cassandraConnectionElement, USERNAME)); final Element passwordIdElement = getSingleChildElement(cassandraConnectionElement, PASSWORD_ID, true); cassandraConnection.setPasswordId(passwordIdElement != null ? passwordIdElement.getTextContent() : null); Set<String> ciphers = null; final Element tlsCiphersElement = getSingleChildElement(cassandraConnectionElement, TLS_CIPHERS, true); final String ciphersAsString = tlsCiphersElement != null ? tlsCiphersElement.getTextContent() : null; if (isNotEmpty(ciphersAsString)) { ciphers = new HashSet<>(Arrays.asList(ciphersAsString.split(","))); } cassandraConnection.setTlsCiphers(ciphers); cassandraConnection.setProperties(mapPropertiesElements(getSingleChildElement(cassandraConnectionElement, PROPERTIES, true), PROPERTIES)); Set<Annotation> annotations = new HashSet<>(); Annotation bundleEntity = new Annotation(AnnotationType.BUNDLE_HINTS); bundleEntity.setId(cassandraConnectionElement.getAttribute(ATTRIBUTE_ID)); annotations.add(bundleEntity); cassandraConnection.setAnnotations(annotations); bundle.getCassandraConnections().put(name, cassandraConnection); }  @Override void load(Bundle bundle, Element element); @Override String getEntityType();  }