use of com.thoughtworks.xstream.XStream in project weixin-java-tools by chanjarster.
the class XStreamTransformer method config_WxCpXmlOutNewsMessage.
private static XStream config_WxCpXmlOutNewsMessage() {
XStream xstream = XStreamInitializer.getInstance();
xstream.processAnnotations(WxCpXmlOutMessage.class);
xstream.processAnnotations(WxCpXmlOutNewsMessage.class);
xstream.processAnnotations(WxCpXmlOutNewsMessage.Item.class);
return xstream;
}
use of com.thoughtworks.xstream.XStream in project weixin-java-tools by chanjarster.
the class XStreamTransformer method config_WxCpXmlMessage.
private static XStream config_WxCpXmlMessage() {
XStream xstream = XStreamInitializer.getInstance();
xstream.processAnnotations(WxCpXmlMessage.class);
xstream.processAnnotations(WxCpXmlMessage.ScanCodeInfo.class);
xstream.processAnnotations(WxCpXmlMessage.SendPicsInfo.class);
xstream.processAnnotations(WxCpXmlMessage.SendPicsInfo.Item.class);
xstream.processAnnotations(WxCpXmlMessage.SendLocationInfo.class);
return xstream;
}
use of com.thoughtworks.xstream.XStream in project intellij-plugins by StepicOrg.
the class StudySerializationUtilsTest method convertToFourthVersion.
@Test
public void convertToFourthVersion() throws Exception {
for (int i = 1; i <= SOURCES_COUNT; i++) {
Element stateVersion3 = readSourceXmlFile(3, i);
Element stateVersion4 = StudySerializationUtils.convertToFourthVersion(stateVersion3);
XStream xs = StepikProjectManager.getXStream();
Object obj = xs.fromXML(outputter.outputString(stateVersion4.getChild(MAIN_ELEMENT)));
//outputter.outputString(stateVersion4);
String actual = xs.toXML(obj);
String expected = readSourceTextFile(4, i);
assertEquals("#" + i, expected, actual);
}
}
use of com.thoughtworks.xstream.XStream in project intellij-community by JetBrains.
the class HgAnnotateCommandTest method loadEthalonAnnotations.
@BeforeClass
private void loadEthalonAnnotations() throws IOException {
myPluginRoot = new File(PluginPathManager.getPluginHomePath(HgVcs.VCS_NAME));
myAnnotateDataDir = new File(myPluginRoot, "testData/annotate");
myOutputsDir = new File(myAnnotateDataDir, "outputs");
final File etalonFile = new File(myAnnotateDataDir, "etalon");
XStream xStream = new XStream();
FileReader reader = new FileReader(etalonFile);
try {
myAnnotations = (List<HgAnnotationLine>) xStream.fromXML(reader);
} finally {
reader.close();
}
}
use of com.thoughtworks.xstream.XStream in project intellij-community by JetBrains.
the class HgAnnotateCommandTest method generateCorrectAnnotation.
//@Test
public void generateCorrectAnnotation() throws IOException {
final File etalonFile = new File(myAnnotateDataDir, "etalon");
File outputFile = new File(myOutputsDir, "hg_1.9.0");
String output = FileUtil.loadFile(outputFile);
String[] split = output.split("(\n|\r|\r\n)");
List<HgAnnotationLine> annotationLines = new ArrayList<>(split.length);
Pattern pattern = Pattern.compile("\\s*(.+)\\s+(\\d+)\\s+([a-fA-F0-9]+)\\s+(\\d{4}-\\d{2}-\\d{2}):\\s*(\\d+): ?(.*)");
for (String line : split) {
Matcher matcher = pattern.matcher(line);
if (!matcher.matches()) {
fail("Couldn't parse line [ " + line + " ]");
}
String user = matcher.group(1);
String shortRev = matcher.group(2);
String fullRev = matcher.group(3);
String date = matcher.group(4);
String lineNum = matcher.group(5);
String content = matcher.group(6);
annotationLines.add(new HgAnnotationLine(user, HgRevisionNumber.getInstance(shortRev, fullRev), date, Integer.parseInt(lineNum), content));
}
XStream xStream = new XStream();
FileWriter writer = new FileWriter(etalonFile);
try {
xStream.toXML(annotationLines, writer);
} finally {
writer.close();
}
}
Aggregations