1 22 package org.objectweb.petals.binding.xquarebc.listeners; 23 24 import java.io.FileInputStream ; 25 26 35 public class XQuareBCJBIProcessorTest extends XQuareBCTestTemplate { 36 37 38 @Override 39 public void setUp() throws Exception { 40 super.setUp(); 41 } 42 43 44 @Override 45 protected void tearDown() throws Exception { 46 super.tearDown(); 47 } 48 49 50 51 57 public void testInsertOneUser() throws Exception { 58 cleanDatabase(); 59 String testContent = XQuareBCTestTemplate.getStringFromInputStream(new FileInputStream (auctionDir + "auction_test_insert_one_user-message.xml")); 60 testOperation("insert", testContent, "<success/>", this.testXquareAuctionProperties); 61 int userNb = getSelectRowNb("select * from users"); 62 assertEquals(1, userNb); 63 } 64 65 public void testInsertSmall() throws Exception { 66 cleanDatabase(); 67 String testContent = XQuareBCTestTemplate.getStringFromInputStream(new FileInputStream (auctionDir + "auction_test_insert_small-message.xml")); 68 testOperation("insert", testContent, "<success/>", this.testXquareAuctionProperties); 69 int bidNb = getSelectRowNb("select * from bids"); 70 assertEquals(1, bidNb); 71 } 72 73 public void testInsertBig() throws Exception { 74 cleanDatabase(); 75 String testContent = XQuareBCTestTemplate.getStringFromInputStream(new FileInputStream (auctionDir + "auction_test_insert_big-message.xml")); 76 testOperation("insert", testContent, "<success/>", this.testXquareAuctionProperties); 77 int userNb = getSelectRowNb("select * from users"); 78 assertEquals(6, userNb); 79 int bidNb = getSelectRowNb("select * from items"); 80 assertEquals(8, bidNb); 81 int itemNb = getSelectRowNb("select * from bids"); 82 assertEquals(16, itemNb); 83 } 84 85 86 public void testQuery() throws Exception { 87 cleanDatabase(); 88 String bigDataContent = XQuareBCTestTemplate.getStringFromInputStream(new FileInputStream (auctionDir + "auction_test_insert_big-message.xml")); 89 testOperation("insert", bigDataContent, "<success/>", this.testXquareAuctionProperties); 90 91 String testContent = XQuareBCTestTemplate.getStringFromInputStream(new FileInputStream (auctionDir + "auction_test_query-message.xml")); 92 String testResults = XQuareBCTestTemplate.getStringFromInputStream(new FileInputStream (auctionDir + "auction_test_query-results.xml")); 93 testOperation("query", testContent, testResults, this.testXquareAuctionProperties); 94 int userNb = getSelectRowNb("select * from users"); 95 assertEquals(6, userNb); 96 } 97 98 public void testStoredQuery() throws Exception { 99 testXquareAuctionProperties.put(XQuareBCJBIProcessor.STORED_QUERY_PROP_PREFIX + 0, 100 XQuareBCTestTemplate.getStringFromInputStream(new FileInputStream (auctionDir + "auction_test_stored_query_with_mod.xml"))); 101 102 cleanDatabase(); 103 String bigDataContent = XQuareBCTestTemplate.getStringFromInputStream(new FileInputStream (auctionDir + "auction_test_insert_big-message.xml")); 104 testOperation("insert", bigDataContent, "<success/>", this.testXquareAuctionProperties); 105 106 String testContent = XQuareBCTestTemplate.getStringFromInputStream(new FileInputStream (auctionDir + "auction_test_stored_query_with_mod-message.xml")); 107 String testResults = XQuareBCTestTemplate.getStringFromInputStream(new FileInputStream (auctionDir + "auction_test_stored_query_with_mod-results.xml")); 108 testOperation("storedQuery", testContent, testResults, this.testXquareAuctionProperties); 109 int userNb = getSelectRowNb("select * from users"); 110 assertEquals(6, userNb); 111 } 112 113 114 public void testUpdateOneUser() throws Exception { 115 testInsertOneUser(); 117 String testContent = XQuareBCTestTemplate.getStringFromInputStream(new FileInputStream (auctionDir + "auction_test_update_one_user-message.xml")); 119 testOperation("insert", testContent, "<success/>", this.testXquareAuctionProperties); 120 121 int userNb = getSelectRowNb("select * from users"); 122 assertEquals(1, userNb); 123 int fRatingUserNb = getSelectRowNb("select * from users where rating='f'"); 124 assertEquals(1, fRatingUserNb); 125 } 126 127 128 public void testNewDataListener() throws Exception { 129 testInsertOneUser(); 131 132 134 String testContent = XQuareBCTestTemplate.getStringFromInputStream(new FileInputStream (auctionDir + "auction_test_update_one_user-message.xml")); 136 testOperation("insert", testContent, "<success/>", this.testXquareAuctionProperties); 137 138 int userNb = getSelectRowNb("select * from users"); 139 assertEquals(1, userNb); 140 int fRatingUserNb = getSelectRowNb("select * from users where rating='f'"); 141 assertEquals(1, fRatingUserNb); 142 } 143 144 145 146 } 147 | Popular Tags |