@Test public void libraryIsProperlyWrittenAsFragment_withNonAsciiCharacters() { final ReferencedLibrary library = ReferencedLibrary.create(LibraryType.PYTHON, "module.ąęółżźćń", "path/ą/ę/module.py"); final String fragment = new RobotProjectConfigWriter().writeFragment(library); assertThat(fragment).doesNotContain("<%xml") .contains("<referencedLibrary") .contains("type=\"PYTHON\"") .contains("name=\"module.ąęółżźćń\"") .contains("path=\"path/ą/ę/module.py\""); }
public String writeFragment(final Object modelPart) { try { final StringWriter writer = new StringWriter(512); writeConfiguration(modelPart, writer, ImmutableMap.of(Marshaller.JAXB_FORMATTED_OUTPUT, true, Marshaller.JAXB_FRAGMENT, true)); final ByteArrayInputStream stream = new ByteArrayInputStream( writer.toString().getBytes(StandardCharsets.UTF_8)); return CharStreams.toString(new InputStreamReader(stream, StandardCharsets.UTF_8)); } catch (final IOException e) { throw new CannotWriteProjectConfigurationException( "Unable to write fragment of configuration for element of type '" + modelPart.getClass().getSimpleName() + "'", e); } }
RobotProjectConfigWriter { public String writeFragment(final Object modelPart) { try { final StringWriter writer = new StringWriter(512); writeConfiguration(modelPart, writer, ImmutableMap.of(Marshaller.JAXB_FORMATTED_OUTPUT, true, Marshaller.JAXB_FRAGMENT, true)); final ByteArrayInputStream stream = new ByteArrayInputStream( writer.toString().getBytes(StandardCharsets.UTF_8)); return CharStreams.toString(new InputStreamReader(stream, StandardCharsets.UTF_8)); } catch (final IOException e) { throw new CannotWriteProjectConfigurationException( "Unable to write fragment of configuration for element of type '" + modelPart.getClass().getSimpleName() + "'", e); } } }
RobotProjectConfigWriter { public String writeFragment(final Object modelPart) { try { final StringWriter writer = new StringWriter(512); writeConfiguration(modelPart, writer, ImmutableMap.of(Marshaller.JAXB_FORMATTED_OUTPUT, true, Marshaller.JAXB_FRAGMENT, true)); final ByteArrayInputStream stream = new ByteArrayInputStream( writer.toString().getBytes(StandardCharsets.UTF_8)); return CharStreams.toString(new InputStreamReader(stream, StandardCharsets.UTF_8)); } catch (final IOException e) { throw new CannotWriteProjectConfigurationException( "Unable to write fragment of configuration for element of type '" + modelPart.getClass().getSimpleName() + "'", e); } }  }
RobotProjectConfigWriter { public String writeFragment(final Object modelPart) { try { final StringWriter writer = new StringWriter(512); writeConfiguration(modelPart, writer, ImmutableMap.of(Marshaller.JAXB_FORMATTED_OUTPUT, true, Marshaller.JAXB_FRAGMENT, true)); final ByteArrayInputStream stream = new ByteArrayInputStream( writer.toString().getBytes(StandardCharsets.UTF_8)); return CharStreams.toString(new InputStreamReader(stream, StandardCharsets.UTF_8)); } catch (final IOException e) { throw new CannotWriteProjectConfigurationException( "Unable to write fragment of configuration for element of type '" + modelPart.getClass().getSimpleName() + "'", e); } }  InputStream writeConfiguration(final RobotProjectConfig configuration); String writeFragment(final Object modelPart); }
RobotProjectConfigWriter { public String writeFragment(final Object modelPart) { try { final StringWriter writer = new StringWriter(512); writeConfiguration(modelPart, writer, ImmutableMap.of(Marshaller.JAXB_FORMATTED_OUTPUT, true, Marshaller.JAXB_FRAGMENT, true)); final ByteArrayInputStream stream = new ByteArrayInputStream( writer.toString().getBytes(StandardCharsets.UTF_8)); return CharStreams.toString(new InputStreamReader(stream, StandardCharsets.UTF_8)); } catch (final IOException e) { throw new CannotWriteProjectConfigurationException( "Unable to write fragment of configuration for element of type '" + modelPart.getClass().getSimpleName() + "'", e); } }  InputStream writeConfiguration(final RobotProjectConfig configuration); String writeFragment(final Object modelPart);  }