@Test public void objectToXml()throws Exception { CastorSample.objectToXml(); FileReader reader = new FileReader("out/CastorSampe.xml"); BufferedReader br = new BufferedReader(reader); StringBuffer sb = new StringBuffer(""); String s; while ((s = br.readLine()) != null) { sb.append(s); } reader.close(); br.close(); assertXpathExists(" assertXpathExists(" assertXpathExists(" assertXpathExists(" }
public static void objectToXml() { try { User user = getUser(); FileWriter writer = new FileWriter("out/CastorSampe.xml"); Mapping mapping = new Mapping(); String mappingFile = ResourceUtils.getResourceFullPath( CastorSample.class, "mapping.xml"); mapping.loadMapping(mappingFile); Marshaller marshaller = new Marshaller(writer); marshaller.setMapping(mapping); marshaller.setEncoding("GBK"); marshaller.marshal(user); } catch (Exception e) { e.printStackTrace(System.err); } }
CastorSample { public static void objectToXml() { try { User user = getUser(); FileWriter writer = new FileWriter("out/CastorSampe.xml"); Mapping mapping = new Mapping(); String mappingFile = ResourceUtils.getResourceFullPath( CastorSample.class, "mapping.xml"); mapping.loadMapping(mappingFile); Marshaller marshaller = new Marshaller(writer); marshaller.setMapping(mapping); marshaller.setEncoding("GBK"); marshaller.marshal(user); } catch (Exception e) { e.printStackTrace(System.err); } } }
CastorSample { public static void objectToXml() { try { User user = getUser(); FileWriter writer = new FileWriter("out/CastorSampe.xml"); Mapping mapping = new Mapping(); String mappingFile = ResourceUtils.getResourceFullPath( CastorSample.class, "mapping.xml"); mapping.loadMapping(mappingFile); Marshaller marshaller = new Marshaller(writer); marshaller.setMapping(mapping); marshaller.setEncoding("GBK"); marshaller.marshal(user); } catch (Exception e) { e.printStackTrace(System.err); } }  }
CastorSample { public static void objectToXml() { try { User user = getUser(); FileWriter writer = new FileWriter("out/CastorSampe.xml"); Mapping mapping = new Mapping(); String mappingFile = ResourceUtils.getResourceFullPath( CastorSample.class, "mapping.xml"); mapping.loadMapping(mappingFile); Marshaller marshaller = new Marshaller(writer); marshaller.setMapping(mapping); marshaller.setEncoding("GBK"); marshaller.marshal(user); } catch (Exception e) { e.printStackTrace(System.err); } }  static User getUser(); static void objectToXml(); static User xmlToObject(); static void main(String[] args); }
CastorSample { public static void objectToXml() { try { User user = getUser(); FileWriter writer = new FileWriter("out/CastorSampe.xml"); Mapping mapping = new Mapping(); String mappingFile = ResourceUtils.getResourceFullPath( CastorSample.class, "mapping.xml"); mapping.loadMapping(mappingFile); Marshaller marshaller = new Marshaller(writer); marshaller.setMapping(mapping); marshaller.setEncoding("GBK"); marshaller.marshal(user); } catch (Exception e) { e.printStackTrace(System.err); } }  static User getUser(); static void objectToXml(); static User xmlToObject(); static void main(String[] args);  }