Search in sources :

Example 36 with XStream

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;
}
Also used : XStream(com.thoughtworks.xstream.XStream)

Example 37 with 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;
}
Also used : XStream(com.thoughtworks.xstream.XStream)

Example 38 with 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);
    }
}
Also used : XStream(com.thoughtworks.xstream.XStream) Element(org.jdom.Element) Test(org.junit.Test)

Example 39 with XStream

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();
    }
}
Also used : HgAnnotationLine(org.zmlx.hg4idea.provider.annotate.HgAnnotationLine) XStream(com.thoughtworks.xstream.XStream) FileReader(java.io.FileReader) File(java.io.File) BeforeClass(org.testng.annotations.BeforeClass)

Example 40 with XStream

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();
    }
}
Also used : Pattern(java.util.regex.Pattern) HgAnnotationLine(org.zmlx.hg4idea.provider.annotate.HgAnnotationLine) Matcher(java.util.regex.Matcher) XStream(com.thoughtworks.xstream.XStream) FileWriter(java.io.FileWriter) ArrayList(java.util.ArrayList) File(java.io.File)

Aggregations

XStream (com.thoughtworks.xstream.XStream)199 Test (org.junit.Test)55 IOException (java.io.IOException)33 InputStream (java.io.InputStream)29 WstxDriver (com.thoughtworks.xstream.io.xml.WstxDriver)22 Metacard (ddf.catalog.data.Metacard)21 DomDriver (com.thoughtworks.xstream.io.xml.DomDriver)17 HashMap (java.util.HashMap)14 ByteArrayInputStream (java.io.ByteArrayInputStream)13 StaxDriver (com.thoughtworks.xstream.io.xml.StaxDriver)12 XStreamUtils.createTrustingXStream (org.kie.soup.commons.xstream.XStreamUtils.createTrustingXStream)12 Matchers.anyString (org.mockito.Matchers.anyString)11 HierarchicalStreamWriter (com.thoughtworks.xstream.io.HierarchicalStreamWriter)10 CswRecordCollection (org.codice.ddf.spatial.ogc.csw.catalog.common.CswRecordCollection)10 FileNotFoundException (java.io.FileNotFoundException)9 Writer (java.io.Writer)8 ArrayList (java.util.ArrayList)8 GmlGeometryConverter (org.codice.ddf.spatial.ogc.wfs.catalog.converter.impl.GmlGeometryConverter)8 XStreamException (com.thoughtworks.xstream.XStreamException)7 MarshallingContext (com.thoughtworks.xstream.converters.MarshallingContext)7