Java Code Examples for org.jdom.output.Format#getCompactFormat()

The following examples show how to use org.jdom.output.Format#getCompactFormat() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlazeAndroidBinaryRunConfigurationStateTest.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Test
public void repeatedWriteShouldNotChangeElement() throws WriteExternalException {
  final XMLOutputter xmlOutputter = new XMLOutputter(Format.getCompactFormat());

  BlazeAndroidRunConfigurationCommonState commonState = state.getCommonState();
  commonState.getBlazeFlagsState().setRawFlags(ImmutableList.of("--flag1", "--flag2"));
  commonState.setNativeDebuggingEnabled(true);

  state.setActivityClass("com.example.TestActivity");
  state.setMode(BlazeAndroidBinaryRunConfigurationState.LAUNCH_SPECIFIC_ACTIVITY);
  state.setLaunchMethod(AndroidBinaryLaunchMethod.MOBILE_INSTALL);
  state.setUseSplitApksIfPossible(false);
  state.setUseWorkProfileIfPresent(true);
  state.setUserId(2);
  state.setShowLogcatAutomatically(true);
  state.setDeepLink("http://deeplink");

  Element firstWrite = new Element("test");
  state.writeExternal(firstWrite);
  Element secondWrite = firstWrite.clone();
  state.writeExternal(secondWrite);

  assertThat(xmlOutputter.outputString(secondWrite))
      .isEqualTo(xmlOutputter.outputString(firstWrite));
}
 
Example 2
Source File: BlazeAndroidTestRunConfigurationStateTest.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Test
public void repeatedWriteShouldNotChangeElement() throws WriteExternalException {
  final XMLOutputter xmlOutputter = new XMLOutputter(Format.getCompactFormat());

  BlazeAndroidRunConfigurationCommonState commonState = state.getCommonState();
  commonState.getBlazeFlagsState().setRawFlags(ImmutableList.of("--flag1", "--flag2"));
  commonState.setNativeDebuggingEnabled(true);

  state.setTestingType(BlazeAndroidTestRunConfigurationState.TEST_METHOD);
  state.setInstrumentationRunnerClass("com.example.TestRunner");
  state.setMethodName("fooMethod");
  state.setClassName("BarClass");
  state.setPackageName("com.test.package.name");
  state.setLaunchMethod(AndroidTestLaunchMethod.MOBILE_INSTALL);
  state.setExtraOptions("--option");

  Element firstWrite = new Element("test");
  state.writeExternal(firstWrite);
  Element secondWrite = firstWrite.clone();
  state.writeExternal(secondWrite);

  assertThat(xmlOutputter.outputString(secondWrite))
      .isEqualTo(xmlOutputter.outputString(firstWrite));
}
 
Example 3
Source File: BlazeAndroidRunConfigurationCommonStateTest.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Test
public void repeatedWriteShouldNotChangeElement() throws WriteExternalException {
  final XMLOutputter xmlOutputter = new XMLOutputter(Format.getCompactFormat());

  state.getBlazeFlagsState().setRawFlags(ImmutableList.of("--flag1", "--flag2"));
  state.getExeFlagsState().setRawFlags(ImmutableList.of("--exe1", "--exe2"));
  state.setNativeDebuggingEnabled(true);

  Element firstWrite = new Element("test");
  state.writeExternal(firstWrite);
  Element secondWrite = firstWrite.clone();
  state.writeExternal(secondWrite);

  assertThat(xmlOutputter.outputString(secondWrite))
      .isEqualTo(xmlOutputter.outputString(firstWrite));
}
 
Example 4
Source File: BlazeCommandRunConfigurationCommonStateTest.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Test
public void repeatedWriteShouldNotChangeElement() throws Exception {
  final XMLOutputter xmlOutputter = new XMLOutputter(Format.getCompactFormat());

  state.getCommandState().setCommand(COMMAND);
  state.getBlazeFlagsState().setRawFlags(ImmutableList.of("--flag1", "--flag2"));
  state.getExeFlagsState().setRawFlags(ImmutableList.of("--exeFlag1"));
  state.getBlazeBinaryState().setBlazeBinary("/usr/bin/blaze");

  Element firstWrite = new Element("test");
  state.writeExternal(firstWrite);
  Element secondWrite = firstWrite.clone();
  state.writeExternal(secondWrite);

  assertThat(xmlOutputter.outputString(secondWrite))
      .isEqualTo(xmlOutputter.outputString(firstWrite));
}
 
Example 5
Source File: BlazeCommandRunConfigurationRunManagerImplTest.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Test
public void loadStateAndGetStateElementShouldMatchAfterChangeAndRevert() {
  final XMLOutputter xmlOutputter = new XMLOutputter(Format.getCompactFormat());
  final Label label = Label.create("//package:rule");
  configuration.setTarget(label);

  final Element initialElement = runManager.getState();
  runManager.loadState(initialElement);
  final BlazeCommandRunConfiguration modifiedConfiguration =
      (BlazeCommandRunConfiguration) runManager.getAllConfigurations()[0];
  modifiedConfiguration.setTarget(Label.create("//new:label"));

  final Element modifiedElement = runManager.getState();
  assertThat(xmlOutputter.outputString(modifiedElement))
      .isNotEqualTo(xmlOutputter.outputString(initialElement));
  runManager.loadState(modifiedElement);
  final BlazeCommandRunConfiguration revertedConfiguration =
      (BlazeCommandRunConfiguration) runManager.getAllConfigurations()[0];
  revertedConfiguration.setTarget(label);

  final Element revertedElement = runManager.getState();
  assertThat(xmlOutputter.outputString(revertedElement))
      .isEqualTo(xmlOutputter.outputString(initialElement));
}
 
Example 6
Source File: BlazeCommandRunConfigurationRunManagerImplTest.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Test
public void getStateElementShouldMatchAfterEditorApplyToAndResetFrom()
    throws ConfigurationException {
  final XMLOutputter xmlOutputter = new XMLOutputter(Format.getCompactFormat());
  final BlazeCommandRunConfigurationSettingsEditor editor =
      new BlazeCommandRunConfigurationSettingsEditor(configuration);
  configuration.setTarget(Label.create("//package:rule"));

  final Element initialElement = runManager.getState();
  editor.resetFrom(configuration);
  editor.applyEditorTo(configuration);
  final Element newElement = runManager.getState();

  assertThat(xmlOutputter.outputString(newElement))
      .isEqualTo(xmlOutputter.outputString(initialElement));

  Disposer.dispose(editor);
}
 
Example 7
Source File: RunConfigurationSerializerTest.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Test
public void testRunConfigurationUnalteredBySerializationRoundTrip() throws InvalidDataException {
  configuration.setTarget(Label.create("//package:rule"));
  configuration.setKeepInSync(true);

  Element initialElement = runManager.getState();

  Element element = RunConfigurationSerializer.writeToXml(configuration);
  assertThat(RunConfigurationSerializer.findExisting(getProject(), element)).isNotNull();

  clearRunManager(); // remove configuration from project
  RunConfigurationSerializer.loadFromXmlElementIgnoreExisting(getProject(), element);

  Element newElement = runManager.getState();
  XMLOutputter xmlOutputter = new XMLOutputter(Format.getCompactFormat());
  assertThat(xmlOutputter.outputString(newElement))
      .isEqualTo(xmlOutputter.outputString(initialElement));
}
 
Example 8
Source File: GenericXMLOutputter.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void init() {
    // this prevents an excess build up of whitespace
    Format compactFormat = Format.getCompactFormat();
    compactFormat.setIndent( DEFAULT_INDENT );
    compactFormat.setTextMode( TextMode.NORMALIZE );
    setFormat( compactFormat );
}
 
Example 9
Source File: ExportRunConfigurationDialog.java    From intellij with Apache License 2.0 5 votes vote down vote up
private static void writeConfiguration(RunConfiguration configuration, File outputFile) {
  try (FileOutputStream writer = new FileOutputStream(outputFile, false)) {
    XMLOutputter xmlOutputter = new XMLOutputter(Format.getCompactFormat());
    xmlOutputter.output(RunConfigurationSerializer.writeToXml(configuration), writer);
  } catch (IOException e) {
    throw new RuntimeException("Error exporting run configuration to file: " + outputFile);
  }
}
 
Example 10
Source File: BlazeCommandRunConfigurationRunManagerImplTest.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Test
public void loadStateAndGetStateElementShouldMatch() {
  final XMLOutputter xmlOutputter = new XMLOutputter(Format.getCompactFormat());
  configuration.setTarget(Label.create("//package:rule"));

  final Element initialElement = runManager.getState();
  runManager.loadState(initialElement);
  final Element newElement = runManager.getState();

  assertThat(xmlOutputter.outputString(newElement))
      .isEqualTo(xmlOutputter.outputString(initialElement));
}
 
Example 11
Source File: JDOMUtil.java    From geoserver-shell with MIT License 4 votes vote down vote up
public static String toString(Element element) {
    XMLOutputter xmlOutputter = new XMLOutputter(Format.getCompactFormat());
    return xmlOutputter.outputString(element);
}