1   package test.wsmo4j.parser.xml;
2   
3   
4   import org.wsmo.common.TopEntity;
5   import org.wsmo.factory.Factory;
6   import org.wsmo.wsml.Parser;
7   import org.wsmo.wsml.Serializer;
8   import test.wsmo4j.Utils;
9   import test.wsmo4j.Wsmo4jTestCase;
10  
11  import java.io.InputStreamReader;
12  import java.io.StringReader;
13  import java.io.StringWriter;
14  import java.util.Map;
15  import java.util.TreeMap;
16  
17  public class TestCase_XMLWSML extends Wsmo4jTestCase {
18      private Parser wsmlParser;
19      private Serializer wsmlSerializer;
20      private Parser wsmlXmlParser;
21      private Serializer wsmlXmlserializer;
22  
23      public void setUp() throws Exception {
24          super.setUp();
25          Map<String, Object> properties = new TreeMap<String, Object>();
26          properties.put(Factory.PROVIDER_CLASS, "com.ontotext.wsmo4j.parser.xml.WsmlXmlParser");
27          properties.put(Factory.WSMO_FACTORY, factory);
28          properties.put(Factory.LE_FACTORY, leFactory);
29          wsmlXmlParser = Factory.createParser(properties);
30          properties = new TreeMap<String, Object>();
31          properties.put(Factory.PROVIDER_CLASS,
32                  "com.ontotext.wsmo4j.serializer.xml.WsmlXmlSerializer");
33          wsmlXmlserializer = Factory.createSerializer(properties);
34  
35          wsmlParser = Factory.createParser(null);
36          wsmlSerializer = Factory.createSerializer(null);
37      }
38  
39      public void test_WsmlToXml() throws Exception {
40          TopEntity[] parseResult = wsmlParser.parse(new InputStreamReader(Utils.getStream("test/wsmo4j/parser/xml/0070410_sBPMN-v1.0.wsml")));
41          
42          StringWriter original = new StringWriter();
43          wsmlSerializer.serialize(parseResult, original);
44  
45          StringWriter out = new StringWriter();
46          wsmlXmlserializer.serialize(parseResult, out);
47          parseResult = wsmlXmlParser.parse(new StringReader(out.toString()));
48          
49          StringWriter result = new StringWriter();        
50          wsmlSerializer.serialize(parseResult, result);        
51  //        System.out.println("original ->" + original + " result->" + result.toString());
52  //        assertEquals(original.toString(), result.toString());                
53      }        
54  }