Search in sources :

Example 1 with Document

use of de.micromata.opengis.kml.v_2_2_0.Document in project k-9 by k9mail.

the class SettingsExporterTest method exportPreferences_setsFormatTo1.

@Test
public void exportPreferences_setsFormatTo1() throws Exception {
    Document document = exportPreferences(false, Collections.<String>emptySet());
    assertEquals("1", document.getRootElement().getAttributeValue("format"));
}
Also used : Document(org.jdom2.Document) Test(org.junit.Test)

Example 2 with Document

use of de.micromata.opengis.kml.v_2_2_0.Document in project k-9 by k9mail.

the class SettingsExporterTest method exportPreferences_setsVersionToLatest.

@Test
public void exportPreferences_setsVersionToLatest() throws Exception {
    Document document = exportPreferences(false, Collections.<String>emptySet());
    assertEquals(Integer.toString(Settings.VERSION), document.getRootElement().getAttributeValue("version"));
}
Also used : Document(org.jdom2.Document) Test(org.junit.Test)

Example 3 with Document

use of de.micromata.opengis.kml.v_2_2_0.Document in project k-9 by k9mail.

the class SettingsExporterTest method exportPreferences_ignoresGlobalSettingsWhenRequested.

@Test
public void exportPreferences_ignoresGlobalSettingsWhenRequested() throws Exception {
    Document document = exportPreferences(false, Collections.<String>emptySet());
    assertNull(document.getRootElement().getChild("global"));
}
Also used : Document(org.jdom2.Document) Test(org.junit.Test)

Example 4 with Document

use of de.micromata.opengis.kml.v_2_2_0.Document in project gocd by gocd.

the class GoControlLog method writeLogFile.

protected void writeLogFile(File file, Element element) throws IOException {
    // Write the log file out, let jdom care about the encoding by using
    // an OutputStream instead of a Writer.
    OutputStream logStream = null;
    try {
        Format format = Format.getPrettyFormat();
        XMLOutputter outputter = new XMLOutputter(format);
        IO.mkdirFor(file);
        file.setWritable(true);
        logStream = new BufferedOutputStream(new FileOutputStream(file));
        outputter.output(new Document(element), logStream);
    } finally {
        IO.close(logStream);
    }
}
Also used : XMLOutputter(org.jdom2.output.XMLOutputter) Format(org.jdom2.output.Format) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) BufferedOutputStream(java.io.BufferedOutputStream) FileOutputStream(java.io.FileOutputStream) Document(org.jdom2.Document) BufferedOutputStream(java.io.BufferedOutputStream)

Example 5 with Document

use of de.micromata.opengis.kml.v_2_2_0.Document in project gocd by gocd.

the class GoConfigMigrationIntegrationTest method shouldRemoveAllLuauConfigurationFromConfig.

@Test
public void shouldRemoveAllLuauConfigurationFromConfig() throws Exception {
    String configString = "<cruise schemaVersion='66'>" + "<server siteUrl='https://hostname'>" + "<security>" + "      <luau url='https://luau.url.com' clientKey='0d010cf97ec505ee3788a9b5b8cf71d482c394ae88d32f0333' authState='authorized' />" + "      <ldap uri='ldap' managerDn='managerDn' encryptedManagerPassword='+XhtUNvVAxJdHGF4qQGnWw==' searchFilter='(sAMAccountName={0})'>" + "        <bases>" + "          <base value='ou=Enterprise,ou=Principal,dc=corporate,dc=thoughtworks,dc=com' />" + "        </bases>" + "      </ldap>" + "      <roles>" + "         <role name='luau-role'><groups><luauGroup>luau-group</luauGroup></groups></role>" + "         <role name='ldap-role'><users><user>some-user</user></users></role>" + "</roles>" + "</security>" + "</server>" + "</cruise>";
    String migratedContent = migrateXmlString(configString, 66);
    Document document = new SAXBuilder().build(new StringReader(migratedContent));
    assertThat(document.getDescendants(new ElementFilter("luau")).hasNext(), is(false));
    assertThat(document.getDescendants(new ElementFilter("groups")).hasNext(), is(false));
}
Also used : SAXBuilder(org.jdom2.input.SAXBuilder) ElementFilter(org.jdom2.filter.ElementFilter) StringReader(java.io.StringReader) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Document(org.jdom2.Document) Test(org.junit.Test)

Aggregations

Document (org.jdom2.Document)86 Element (org.jdom2.Element)57 File (java.io.File)29 Test (org.junit.Test)24 DocType (org.jdom2.DocType)23 SAXBuilder (org.jdom2.input.SAXBuilder)20 IOException (java.io.IOException)16 XMLOutputter (org.jdom2.output.XMLOutputter)14 ProcessingInstruction (org.jdom2.ProcessingInstruction)13 XmlFile (jmri.jmrit.XmlFile)11 Document (com.google.cloud.language.v1beta2.Document)10 ApiException (com.google.api.gax.grpc.ApiException)9 Document (com.google.cloud.language.v1.Document)9 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)9 StatusRuntimeException (io.grpc.StatusRuntimeException)9 EncodingType (com.google.cloud.language.v1beta2.EncodingType)8 FileOutputStream (java.io.FileOutputStream)7 EncodingType (com.google.cloud.language.v1.EncodingType)6 FileNotFoundException (java.io.FileNotFoundException)6 JDOMException (org.jdom2.JDOMException)6