Java User Group Torino

JavaDay Roma 2010 English spoken people, click here
AltriJug
Articoli
Blog
Bookmarks
ChiSiamo
Cinema
Eventi
FAQ
IscriversiAlJug
FunnyJug
HobbiesAndSports
ImparareNuoveCose
JavaJobs
JavaTraining
Libri
MailingList
Meeting
News
ProgettiAttivita
Shop
Software
StoriaDelJug
SunItalia

RSS Feed
RSS Meetings Feed


I have joined Anti-IF Campaign


Spread Firefox Affiliate Button






CoordinamentoJug
PagineDiServizio
Manutenzione
LazyDb

LazyDb serve per creare un database in memory sfruttando hypersonic 2 (notare che ora è hypersonic 2), creare lo schema programmaticamente e passare quindi a usarlo nei propri test unitari. Ideato per fare del test-drivern-development comodo nella creazione degli schema (da qui il nome 'lazy').

Un esempio per dei tests di JUnit 4 :

@BeforeClass?
public void myDB() {

db = new DB();
Table insurances = Table.create("insurances", Column.integer("id").notNull());
insurances.add(Column.varchar("description"));
firmId = Column.integer("firm_id").notNull();
insurances.add(firmId);
db.addTable(insurances);

Table firms = Table.create("firms", firmId, Column.varchar("firm_name"));
db.addTable(firms);

Column customerName = Column.text("full_name");
Table customers = Table.create("customers", Column.serial("id"), customerName);
customers.add(Column.varchar("address"));
customers.add(Column.varchar("mail"));
db.addTable(customers);

}

Ora è anche possibile inserire valori nel db in-memory con una certa comodità :
db.evaluate(customerName.insert("peter").into(customers));

E si può anche interrogare il db con un sistema simile :
DBStatement retrieveCustomers = Retrieve.column(customerName).from(customers).now();
db.evaluate(retrieveCustomers);

Sono poche centinaia di linee di codice, quindi non aspettatevi troppe features, fa il minimo indispensabile.

Visto che si appoggia a hypersonic 2 è bene scaricarlo e aggiungerlo al classpath : http://www.h2database.com/h2-2007-09-15.zip

Il task di Ant che ricrea il DB definito nei propri tests, in un dump delle creazioni delle tabelle, usa invece commons-io di apache.

Dentro allo zip c'è anche il pom di maven 2, quindi se usate maven per i vostri progetti pensa lui a queste dipendenze.

In questo zip si trova tutto, jar, pom e javadoc

att:lazy-db-0.9.3.tar.gz


LazyDb is mentioned on: ProgettiAttivita

VQWiki includes notification systems; however, you have not yet become a member.



VeryQuickWiki Version 2.7.1 | Admin

Powered By...
Logo Csp

Content of this site is Copyright (C) 2003 JUG Torino and its members. Java and all Java based trademarks and logos are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. Other trademarks are registered by respective owners.