1 package org.exoplatform.services.xml.querying.impl.xtas; 2 3 import junit.framework.TestCase; 4 import junit.framework.Test; 5 import junit.framework.TestSuite; 6 7 8 import java.io.*; 9 import org.exoplatform.services.xml.querying.impl.xtas.BaseStatement; 10 import org.exoplatform.services.xml.querying.impl.xtas.QueryType; 11 import org.exoplatform.services.xml.querying.impl.xtas.SimpleStatement; 12 import org.exoplatform.services.xml.querying.impl.xtas.XTASMLStatement; 13 14 19 23 public class TestQueryContent extends TestCase 24 { 25 protected BaseStatement qc = null; 26 27 public TestQueryContent(String name) 28 { 29 super(name); 30 } 31 32 public static Test suite() 33 { 34 return new TestSuite(TestQueryContent.class); 35 } 36 37 public void testLocalFileContent() 38 { 39 40 String f1 = "tmp/query.xml"; 41 42 try { 43 44 qc = new XTASMLStatement (f1); 45 assertNotNull( qc ); 47 49 } catch ( Exception e) { 50 fail( "Could not create QueryContent: "+e.toString()); 51 } 52 53 } 54 55 56 public void testUrlContent() 57 { 58 59 } 60 61 public void testSimpleStatement() 62 { 63 64 BaseStatement qc = null; 65 66 try { 67 68 qc = SimpleStatement.select("//security-identity/*", "tmp/ejb-jar.xml"); 70 71 assertEquals( QueryType.SELECT, qc.getInstructions()[0].getType() ); 72 73 assertEquals( true , qc.getInstructions()[0].isAtXml() ); 74 assertEquals( false , qc.getInstructions()[0].isAtResource() ); 75 76 78 qc = null; 79 String f1 = "tmp/created-xml.xml"; 80 qc = new SimpleStatement ("create", "tmp/created-xml.xml", "<test/>", null, null); 81 82 84 85 assertNotNull( qc.toString() ); 86 assertEquals( QueryType.CREATE, qc.getInstructions()[0].getType() ); 87 assertEquals( qc.toString()+" isAtXml(): ", false , qc.getInstructions()[0].isAtXml() ); 88 assertEquals( qc.toString()+" isAtResource(): ", true , qc.getInstructions()[0].isAtResource() ); 89 90 91 } catch ( Exception e) { 92 fail( "Could not create Query Statement: "+e.toString()+"("+qc+")"); 93 } 94 95 96 97 try { 98 99 qc = new SimpleStatement ("bad", "//security-identity/*"); 101 103 fail( "Query Statement created ! " +qc.toString()); 104 105 } catch ( Exception e) { 106 } 108 109 try { 110 111 qc = new SimpleStatement ("create", null, null); 112 114 117 fail( "Query Statement created ! " +qc.toString()); 118 119 } catch ( Exception e) { 120 } 122 123 124 } 125 126 127 } 128 | Popular Tags |