Revision 10627 trunk/libraries/libGDBMS/src/test/java/com/hardcode/gdbms/engine/strategies/OperationTest.java

View differences:

OperationTest.java
15 15
import com.hardcode.gdbms.parser.ParseException;
16 16

  
17 17
/**
18
 * 
18
 *
19 19
 */
20 20
public class OperationTest extends DataSourceTestCase {
21 21
	static {
22 22
		QueryManager.registerQuery(new SumQuery());
23 23
	}
24
	
24

  
25 25
	public void testOrderOperationDataSource() throws Exception{
26 26
    	DataSource d = ds.executeSQL("(select id, nombre, apellido from persona) union (select  id, nombre, apellido from persona);",
27 27
    			DataSourceFactory.MANUAL_OPENING);
28
    	
28

  
29 29
    	String sql = "select * from '" + d.getName() + "' order by id;";
30
    	
30

  
31 31
    	d.getDataSourceFactory().executeSQL(sql, DataSourceFactory.MANUAL_OPENING);
32
        
32

  
33 33
    }
34
	
34

  
35 35
    /**
36 36
     * test a union query
37 37
     *
......
43 43
    	d.start();
44 44
    	String aux = d.getAsString();
45 45
    	d.stop();
46
    
46

  
47 47
    	FileInputStream fis = new FileInputStream("src/test/resources/union.txt");
48 48
    	byte[] correcto = new byte[aux.getBytes().length];
49 49
    	fis.read(correcto);
50 50
    	fis.close();
51
    
51

  
52 52
    	assertTrue("La uni?n no es correcta",
53 53
    		aux.toString().equals(new String(correcto)));
54 54
    }
......
61 61
    public void testSelect() throws Throwable {
62 62
    	DataSource d = ds.executeSQL("select apellido, PK from persona where nombre='fernando';",
63 63
    			DataSourceFactory.MANUAL_OPENING);
64
    
64

  
65 65
    	d.start();
66 66
    	String aux = d.getAsString();
67 67
    	d.stop();
68
    
68

  
69 69
    	FileInputStream fis = new FileInputStream("src/test/resources/select.txt");
70 70
    	byte[] correcto = new byte[aux.getBytes().length];
71 71
    	fis.read(correcto);
72 72
    	fis.close();
73
    
73

  
74 74
    	assertTrue("La select no es correcta", aux.equals(new String(correcto)));
75 75
    }
76 76

  
......
84 84
     * @throws IOException DOCUMENT ME!
85 85
     */
86 86
    public void testCustomQuery()
87
    	throws Exception, 
87
    	throws Exception,
88 88
    		SemanticException, IOException {
89 89
    	DataSource d = ds.executeSQL("custom sumquery tables persona values (id);",
90 90
    			DataSourceFactory.MANUAL_OPENING);
91
    
91

  
92 92
    	d.start();
93 93
    	assertTrue(((BooleanValue) d.getFieldValue(0, 0).equals(ValueFactory.createValue(
94 94
    				3))).getValue());

Also available in: Unified diff