diff options
author | Artur Signell <artur@vaadin.com> | 2012-08-31 13:54:26 +0300 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2012-09-09 11:23:04 +0300 |
commit | d8a5f96b36946ed315dcf48cc32701e0435bdfaa (patch) | |
tree | f7fcf075a47430a9f45cfda652d91f576e32c98c /server | |
parent | eef56b04b46c6ad202beef58c342dbb5ea0e4f5d (diff) | |
download | vaadin-framework-d8a5f96b36946ed315dcf48cc32701e0435bdfaa.tar.gz vaadin-framework-d8a5f96b36946ed315dcf48cc32701e0435bdfaa.zip |
Support running JUnit tests (#9299)
Diffstat (limited to 'server')
14 files changed, 465 insertions, 421 deletions
diff --git a/server/build.xml b/server/build.xml index b4609cd265..1d3f8a5938 100644 --- a/server/build.xml +++ b/server/build.xml @@ -12,10 +12,18 @@ <property name="module.name" value="vaadin-server" /> <property name="result.dir" value="result" /> <path id="classpath.compile.custom" /> + <path id="classpath.tests.custom" /> + + <union id="jar.includes"> + <union refid="server.gwt.includes" /> + <fileset dir="${vaadin.basedir}"> + <include name="WebContent/VAADIN/vaadinBootstrap.js" /> + </fileset> + </union> <target name="jar"> <antcall target="common.jar"> - <reference torefid="extra.jar.includes" refid="server.gwt.includes" /> + <reference torefid="extra.jar.includes" refid="jar.includes" /> </antcall> </target> @@ -26,4 +34,10 @@ <target name="clean"> <antcall target="common.clean" /> </target> + + <target name="tests"> + <antcall target="common.tests.run"/> + </target> + + </project>
\ No newline at end of file diff --git a/server/ivy.xml b/server/ivy.xml index 7f964f01f2..85278fa1d0 100644 --- a/server/ivy.xml +++ b/server/ivy.xml @@ -20,49 +20,45 @@ <!-- Liferay Portal Service --> <dependency org="com.liferay.portal" name="portal-service" - rev="6.0.2" conf="build-provided,ide -> master" /> + rev="6.0.2" conf="build-provided,ide -> default" /> <!--Servlet API version 2.5 --> <dependency org="javax.servlet" name="servlet-api" - rev="2.5" conf="build-provided,ide -> master" /> + rev="2.5" conf="build-provided,ide,tests -> default" /> <!--Portlet API version 2.0 (JSR-286) --> <dependency org="javax.portlet" name="portlet-api" - rev="2.0" conf="build-provided,ide -> master" /> + rev="2.0" conf="build-provided,ide,tests -> default" /> <!-- Google App Engine --> <dependency org="com.google.appengine" name="appengine-api-1.0-sdk" - rev="1.2.1" conf="build-provided,ide -> master" /> + rev="1.2.1" conf="build-provided,ide,tests -> default" /> <dependency org="javax.validation" name="validation-api" - rev="1.0.0.GA" conf="build-provided,ide -> master" /> + rev="1.0.0.GA" conf="build-provided,ide,tests -> default" /> <!-- LIBRARY DEPENDENCIES (compile time) --> <!-- Project modules --> <dependency org="com.vaadin" name="vaadin-shared" - rev="${vaadin.version}" conf="build"></dependency> + rev="${vaadin.version}" conf="build,tests" /> <dependency org="com.vaadin" name="vaadin-buildhelpers" - rev="${vaadin.version}" conf="build"></dependency> + rev="${vaadin.version}" conf="build,tests" /> <!-- Jsoup for BootstrapHandler --> <dependency org="org.jsoup" name="jsoup" rev="1.6.3" - conf="build,ide -> master" /> + conf="build,ide -> default" /> <!-- TESTING DEPENDENCIES --> - <!-- TestBench tests --> - <dependency org="commons-codec" name="commons-codec" - rev="1.5" conf="tests,ide->master" /> - <dependency org="org.mortbay.jetty" name="jetty" rev="6.1.11" - conf="tests,ide->master" /> - <dependency org="org.mortbay.jetty" name="jetty-util" - rev="6.1.11" conf="tests,ide->master" /> - <!-- Test frameworks & related --> <dependency org="junit" name="junit" rev="4.5" - conf="tests,ide -> master" /> + conf="tests,ide -> default" /> <dependency org="org.easymock" name="easymock" rev="3.0" - conf="tests,ide-> master" /> + conf="tests,ide-> default" transitive="true" /> <dependency org="org.hsqldb" name="hsqldb" rev="2.2.6" - conf="tests,ide -> master" /> + conf="tests,ide -> default" /> + <dependency org="commons-io" name="commons-io" rev="1.4" + conf="tests->default" /> + <dependency org="commons-lang" name="commons-lang" + rev="2.3" conf="tests->default" /> </dependencies> diff --git a/server/src/com/vaadin/ui/AbstractSelect.java b/server/src/com/vaadin/ui/AbstractSelect.java index 1e9db0a264..4de3f90d15 100644 --- a/server/src/com/vaadin/ui/AbstractSelect.java +++ b/server/src/com/vaadin/ui/AbstractSelect.java @@ -1055,7 +1055,6 @@ public abstract class AbstractSelect extends AbstractField<Object> implements * @return True if additions are allowed. */ public boolean isNewItemsAllowed() { - return allowNewOptions; } diff --git a/server/tests/src/com/vaadin/data/util/sqlcontainer/AllTests.java b/server/tests/src/com/vaadin/data/util/sqlcontainer/AllTests.java index 057527307f..d2c7ad85ed 100644 --- a/server/tests/src/com/vaadin/data/util/sqlcontainer/AllTests.java +++ b/server/tests/src/com/vaadin/data/util/sqlcontainer/AllTests.java @@ -12,10 +12,6 @@ import com.vaadin.data.util.sqlcontainer.generator.SQLGeneratorsTest; import com.vaadin.data.util.sqlcontainer.query.FreeformQueryTest; import com.vaadin.data.util.sqlcontainer.query.QueryBuilderTest; import com.vaadin.data.util.sqlcontainer.query.TableQueryTest; -import com.vaadin.data.util.sqlcontainer.query.generator.DefaultSQLGenerator; -import com.vaadin.data.util.sqlcontainer.query.generator.MSSQLGenerator; -import com.vaadin.data.util.sqlcontainer.query.generator.OracleGenerator; -import com.vaadin.data.util.sqlcontainer.query.generator.SQLGenerator; @RunWith(Suite.class) @SuiteClasses({ SimpleJDBCConnectionPoolTest.class, @@ -25,121 +21,4 @@ import com.vaadin.data.util.sqlcontainer.query.generator.SQLGenerator; TableQueryTest.class, SQLGeneratorsTest.class, UtilTest.class, TicketTests.class, BetweenTest.class, ReadOnlyRowIdTest.class }) public class AllTests { - /* Set the DB used for testing here! */ - public enum DB { - HSQLDB, MYSQL, POSTGRESQL, MSSQL, ORACLE; - } - - /* 0 = HSQLDB, 1 = MYSQL, 2 = POSTGRESQL, 3 = MSSQL, 4 = ORACLE */ - public static final DB db = DB.HSQLDB; - - /* Auto-increment column offset (HSQLDB = 0, MYSQL = 1, POSTGRES = 1) */ - public static int offset; - /* Garbage table creation query (=three queries for oracle) */ - public static String createGarbage; - public static String createGarbageSecond; - public static String createGarbageThird; - /* DB Drivers, urls, usernames and passwords */ - public static String dbDriver; - public static String dbURL; - public static String dbUser; - public static String dbPwd; - /* People -test table creation statement(s) */ - public static String peopleFirst; - public static String peopleSecond; - public static String peopleThird; - /* Versioned -test table createion statement(s) */ - public static String[] versionStatements; - /* SQL Generator used during the testing */ - public static SQLGenerator sqlGen; - - /* Set DB-specific settings based on selected DB */ - static { - sqlGen = new DefaultSQLGenerator(); - switch (db) { - case HSQLDB: - offset = 0; - createGarbage = "create table garbage (id integer generated always as identity, type varchar(32), PRIMARY KEY(id))"; - dbDriver = "org.hsqldb.jdbc.JDBCDriver"; - dbURL = "jdbc:hsqldb:mem:sqlcontainer"; - dbUser = "SA"; - dbPwd = ""; - peopleFirst = "create table people (id integer generated always as identity, name varchar(32), AGE INTEGER)"; - peopleSecond = "alter table people add primary key (id)"; - versionStatements = new String[] { - "create table versioned (id integer generated always as identity, text varchar(255), version tinyint default 0)", - "alter table versioned add primary key (id)" }; - break; - case MYSQL: - offset = 1; - createGarbage = "create table GARBAGE (ID integer auto_increment, type varchar(32), PRIMARY KEY(ID))"; - dbDriver = "com.mysql.jdbc.Driver"; - dbURL = "jdbc:mysql:///sqlcontainer"; - dbUser = "sqlcontainer"; - dbPwd = "sqlcontainer"; - peopleFirst = "create table PEOPLE (ID integer auto_increment not null, NAME varchar(32), AGE INTEGER, primary key(ID))"; - peopleSecond = null; - versionStatements = new String[] { - "create table VERSIONED (ID integer auto_increment not null, TEXT varchar(255), VERSION tinyint default 0, primary key(ID))", - "CREATE TRIGGER upd_version BEFORE UPDATE ON VERSIONED" - + " FOR EACH ROW SET NEW.VERSION = OLD.VERSION+1" }; - break; - case POSTGRESQL: - offset = 1; - createGarbage = "create table GARBAGE (\"ID\" serial PRIMARY KEY, \"TYPE\" varchar(32))"; - dbDriver = "org.postgresql.Driver"; - dbURL = "jdbc:postgresql://localhost:5432/test"; - dbUser = "postgres"; - dbPwd = "postgres"; - peopleFirst = "create table PEOPLE (\"ID\" serial primary key, \"NAME\" VARCHAR(32), \"AGE\" INTEGER)"; - peopleSecond = null; - versionStatements = new String[] { - "create table VERSIONED (\"ID\" serial primary key, \"TEXT\" VARCHAR(255), \"VERSION\" INTEGER DEFAULT 0)", - "CREATE OR REPLACE FUNCTION zz_row_version() RETURNS TRIGGER AS $$" - + "BEGIN" - + " IF TG_OP = 'UPDATE'" - + " AND NEW.\"VERSION\" = old.\"VERSION\"" - + " AND ROW(NEW.*) IS DISTINCT FROM ROW (old.*)" - + " THEN" - + " NEW.\"VERSION\" := NEW.\"VERSION\" + 1;" - + " END IF;" + " RETURN NEW;" + "END;" - + "$$ LANGUAGE plpgsql;", - "CREATE TRIGGER \"mytable_modify_dt_tr\" BEFORE UPDATE" - + " ON VERSIONED FOR EACH ROW" - + " EXECUTE PROCEDURE \"public\".\"zz_row_version\"();" }; - break; - case MSSQL: - offset = 1; - createGarbage = "create table GARBAGE (\"ID\" int identity(1,1) primary key, \"TYPE\" varchar(32))"; - dbDriver = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; - dbURL = "jdbc:sqlserver://localhost:1433;databaseName=tempdb;"; - dbUser = "sa"; - dbPwd = "sa"; - peopleFirst = "create table PEOPLE (\"ID\" int identity(1,1) primary key, \"NAME\" VARCHAR(32), \"AGE\" INTEGER)"; - peopleSecond = null; - versionStatements = new String[] { "create table VERSIONED (\"ID\" int identity(1,1) primary key, \"TEXT\" VARCHAR(255), \"VERSION\" rowversion not null)" }; - sqlGen = new MSSQLGenerator(); - break; - case ORACLE: - offset = 1; - createGarbage = "create table GARBAGE (\"ID\" integer primary key, \"TYPE\" varchar2(32))"; - createGarbageSecond = "create sequence garbage_seq start with 1 increment by 1 nomaxvalue"; - createGarbageThird = "create trigger garbage_trigger before insert on GARBAGE for each row begin select garbage_seq.nextval into :new.ID from dual; end;"; - dbDriver = "oracle.jdbc.OracleDriver"; - dbURL = "jdbc:oracle:thin:test/test@localhost:1521:XE"; - dbUser = "test"; - dbPwd = "test"; - peopleFirst = "create table PEOPLE (\"ID\" integer primary key, \"NAME\" VARCHAR2(32), \"AGE\" INTEGER)"; - peopleSecond = "create sequence people_seq start with 1 increment by 1 nomaxvalue"; - peopleThird = "create trigger people_trigger before insert on PEOPLE for each row begin select people_seq.nextval into :new.ID from dual; end;"; - versionStatements = new String[] { - "create table VERSIONED (\"ID\" integer primary key, \"TEXT\" VARCHAR(255), \"VERSION\" INTEGER DEFAULT 0)", - "create sequence versioned_seq start with 1 increment by 1 nomaxvalue", - "create trigger versioned_trigger before insert on VERSIONED for each row begin select versioned_seq.nextval into :new.ID from dual; end;", - "create sequence versioned_version start with 1 increment by 1 nomaxvalue", - "create trigger versioned_version_trigger before insert or update on VERSIONED for each row begin select versioned_version.nextval into :new.VERSION from dual; end;" }; - sqlGen = new OracleGenerator(); - break; - } - } } diff --git a/server/tests/src/com/vaadin/data/util/sqlcontainer/DataGenerator.java b/server/tests/src/com/vaadin/data/util/sqlcontainer/DataGenerator.java index 489f780d61..b76e3df10e 100644 --- a/server/tests/src/com/vaadin/data/util/sqlcontainer/DataGenerator.java +++ b/server/tests/src/com/vaadin/data/util/sqlcontainer/DataGenerator.java @@ -8,7 +8,7 @@ import java.sql.Statement; import org.junit.Assert; import org.junit.Test; -import com.vaadin.data.util.sqlcontainer.AllTests.DB; +import com.vaadin.data.util.sqlcontainer.SQLTestsConstants.DB; import com.vaadin.data.util.sqlcontainer.connection.JDBCConnectionPool; public class DataGenerator { @@ -25,21 +25,21 @@ public class DataGenerator { Statement statement = conn.createStatement(); try { statement.execute("drop table PEOPLE"); - if (AllTests.db == DB.ORACLE) { + if (SQLTestsConstants.db == DB.ORACLE) { statement.execute("drop sequence people_seq"); } } catch (SQLException e) { // Will fail if table doesn't exist, which is OK. conn.rollback(); } - statement.execute(AllTests.peopleFirst); - if (AllTests.peopleSecond != null) { - statement.execute(AllTests.peopleSecond); + statement.execute(SQLTestsConstants.peopleFirst); + if (SQLTestsConstants.peopleSecond != null) { + statement.execute(SQLTestsConstants.peopleSecond); } - if (AllTests.db == DB.ORACLE) { - statement.execute(AllTests.peopleThird); + if (SQLTestsConstants.db == DB.ORACLE) { + statement.execute(SQLTestsConstants.peopleThird); } - if (AllTests.db == DB.MSSQL) { + if (SQLTestsConstants.db == DB.MSSQL) { statement.executeUpdate("insert into people values('Ville', '23')"); statement.executeUpdate("insert into people values('Kalle', '7')"); statement.executeUpdate("insert into people values('Pelle', '18')"); @@ -68,7 +68,7 @@ public class DataGenerator { Connection conn = connectionPool.reserveConnection(); Statement statement = conn.createStatement(); for (int i = 4; i < 5000; i++) { - if (AllTests.db == DB.MSSQL) { + if (SQLTestsConstants.db == DB.MSSQL) { statement.executeUpdate("insert into people values('Person " + i + "', '" + i % 99 + "')"); } else { @@ -88,7 +88,7 @@ public class DataGenerator { Statement statement = conn.createStatement(); try { statement.execute("DROP TABLE VERSIONED"); - if (AllTests.db == DB.ORACLE) { + if (SQLTestsConstants.db == DB.ORACLE) { statement.execute("drop sequence versioned_seq"); statement.execute("drop sequence versioned_version"); } @@ -96,10 +96,10 @@ public class DataGenerator { // Will fail if table doesn't exist, which is OK. conn.rollback(); } - for (String stmtString : AllTests.versionStatements) { + for (String stmtString : SQLTestsConstants.versionStatements) { statement.execute(stmtString); } - if (AllTests.db == DB.MSSQL) { + if (SQLTestsConstants.db == DB.MSSQL) { statement .executeUpdate("insert into VERSIONED values('Junk', default)"); } else { @@ -121,17 +121,17 @@ public class DataGenerator { Statement statement = conn.createStatement(); try { statement.execute("drop table GARBAGE"); - if (AllTests.db == DB.ORACLE) { + if (SQLTestsConstants.db == DB.ORACLE) { statement.execute("drop sequence garbage_seq"); } } catch (SQLException e) { // Will fail if table doesn't exist, which is OK. conn.rollback(); } - statement.execute(AllTests.createGarbage); - if (AllTests.db == DB.ORACLE) { - statement.execute(AllTests.createGarbageSecond); - statement.execute(AllTests.createGarbageThird); + statement.execute(SQLTestsConstants.createGarbage); + if (SQLTestsConstants.db == DB.ORACLE) { + statement.execute(SQLTestsConstants.createGarbageSecond); + statement.execute(SQLTestsConstants.createGarbageThird); } conn.commit(); connectionPool.releaseConnection(conn); diff --git a/server/tests/src/com/vaadin/data/util/sqlcontainer/FreeformQueryUtil.java b/server/tests/src/com/vaadin/data/util/sqlcontainer/FreeformQueryUtil.java index b0e2a232ca..e30ff8f5da 100644 --- a/server/tests/src/com/vaadin/data/util/sqlcontainer/FreeformQueryUtil.java +++ b/server/tests/src/com/vaadin/data/util/sqlcontainer/FreeformQueryUtil.java @@ -5,7 +5,7 @@ import java.util.List; import org.junit.Test; import com.vaadin.data.Container.Filter; -import com.vaadin.data.util.sqlcontainer.AllTests.DB; +import com.vaadin.data.util.sqlcontainer.SQLTestsConstants.DB; import com.vaadin.data.util.sqlcontainer.query.generator.StatementHelper; import com.vaadin.data.util.sqlcontainer.query.generator.filter.QueryBuilder; @@ -20,7 +20,7 @@ public class FreeformQueryUtil { public static StatementHelper getQueryWithFilters(List<Filter> filters, int offset, int limit) { StatementHelper sh = new StatementHelper(); - if (AllTests.db == DB.MSSQL) { + if (SQLTestsConstants.db == DB.MSSQL) { if (limit > 1) { offset++; limit--; @@ -37,7 +37,7 @@ public class FreeformQueryUtil { .append(" AND ").append(Integer.toString(offset + limit)); sh.setQueryString(query.toString()); return sh; - } else if (AllTests.db == DB.ORACLE) { + } else if (SQLTestsConstants.db == DB.ORACLE) { if (limit > 1) { offset++; limit--; diff --git a/server/tests/src/com/vaadin/data/util/sqlcontainer/SQLContainerTableQueryTest.java b/server/tests/src/com/vaadin/data/util/sqlcontainer/SQLContainerTableQueryTest.java index 7b3d8a4cf2..d907f12321 100644 --- a/server/tests/src/com/vaadin/data/util/sqlcontainer/SQLContainerTableQueryTest.java +++ b/server/tests/src/com/vaadin/data/util/sqlcontainer/SQLContainerTableQueryTest.java @@ -18,7 +18,7 @@ import com.vaadin.data.Container.ItemSetChangeEvent; import com.vaadin.data.Container.ItemSetChangeListener; import com.vaadin.data.Item; import com.vaadin.data.util.filter.Like; -import com.vaadin.data.util.sqlcontainer.AllTests.DB; +import com.vaadin.data.util.sqlcontainer.SQLTestsConstants.DB; import com.vaadin.data.util.sqlcontainer.connection.JDBCConnectionPool; import com.vaadin.data.util.sqlcontainer.connection.SimpleJDBCConnectionPool; import com.vaadin.data.util.sqlcontainer.query.OrderBy; @@ -26,16 +26,17 @@ import com.vaadin.data.util.sqlcontainer.query.TableQuery; public class SQLContainerTableQueryTest { - private static final int offset = AllTests.offset; - private static final String createGarbage = AllTests.createGarbage; + private static final int offset = SQLTestsConstants.offset; + private static final String createGarbage = SQLTestsConstants.createGarbage; private JDBCConnectionPool connectionPool; @Before public void setUp() throws SQLException { try { - connectionPool = new SimpleJDBCConnectionPool(AllTests.dbDriver, - AllTests.dbURL, AllTests.dbUser, AllTests.dbPwd, 2, 2); + connectionPool = new SimpleJDBCConnectionPool( + SQLTestsConstants.dbDriver, SQLTestsConstants.dbURL, + SQLTestsConstants.dbUser, SQLTestsConstants.dbPwd, 2, 2); } catch (SQLException e) { e.printStackTrace(); Assert.fail(e.getMessage()); @@ -54,14 +55,14 @@ public class SQLContainerTableQueryTest { @Test public void constructor_withTableQuery_shouldSucceed() throws SQLException { new SQLContainer(new TableQuery("people", connectionPool, - AllTests.sqlGen)); + SQLTestsConstants.sqlGen)); } @Test public void containsId_withTableQueryAndExistingId_returnsTrue() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Assert.assertTrue(container.containsId(new RowId( new Object[] { 1 + offset }))); } @@ -70,7 +71,7 @@ public class SQLContainerTableQueryTest { public void containsId_withTableQueryAndNonexistingId_returnsFalse() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Assert.assertFalse(container.containsId(new RowId( new Object[] { 1337 + offset }))); } @@ -78,9 +79,10 @@ public class SQLContainerTableQueryTest { @Test public void getContainerProperty_tableExistingItemIdAndPropertyId_returnsProperty() throws SQLException { - TableQuery t = new TableQuery("people", connectionPool, AllTests.sqlGen); + TableQuery t = new TableQuery("people", connectionPool, + SQLTestsConstants.sqlGen); SQLContainer container = new SQLContainer(t); - if (AllTests.db == DB.ORACLE) { + if (SQLTestsConstants.db == DB.ORACLE) { Assert.assertEquals( "Ville", container @@ -100,7 +102,7 @@ public class SQLContainerTableQueryTest { public void getContainerProperty_tableExistingItemIdAndNonexistingPropertyId_returnsNull() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Assert.assertNull(container.getContainerProperty(new RowId( new Object[] { 1 + offset }), "asdf")); } @@ -109,7 +111,7 @@ public class SQLContainerTableQueryTest { public void getContainerProperty_tableNonexistingItemId_returnsNull() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Assert.assertNull(container.getContainerProperty(new RowId( new Object[] { 1337 + offset }), "NAME")); } @@ -118,7 +120,7 @@ public class SQLContainerTableQueryTest { public void getContainerPropertyIds_table_returnsIDAndNAME() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Collection<?> propertyIds = container.getContainerPropertyIds(); Assert.assertEquals(3, propertyIds.size()); Assert.assertArrayEquals(new String[] { "ID", "NAME", "AGE" }, @@ -128,9 +130,9 @@ public class SQLContainerTableQueryTest { @Test public void getItem_tableExistingItemId_returnsItem() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Item item; - if (AllTests.db == DB.ORACLE) { + if (SQLTestsConstants.db == DB.ORACLE) { item = container.getItem(new RowId(new Object[] { new BigDecimal( 0 + offset) })); } else { @@ -146,7 +148,7 @@ public class SQLContainerTableQueryTest { String NEW_VALUE = "OtherValue"; //$NON-NLS-1$ SQLContainer container = new SQLContainer(new TableQuery("people", //$NON-NLS-1$ - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object itemID = container.addItem(); Item item = container.getItem(itemID); item.getItemProperty("NAME").setValue(OLD_VALUE); //$NON-NLS-1$ @@ -174,11 +176,11 @@ public class SQLContainerTableQueryTest { throws SQLException { DataGenerator.addFiveThousandPeople(connectionPool); TableQuery query = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); SQLContainer container = new SQLContainer(query); Item item; - if (AllTests.db == DB.ORACLE) { + if (SQLTestsConstants.db == DB.ORACLE) { item = container.getItem(new RowId(new Object[] { new BigDecimal( 1337 + offset) })); Assert.assertNotNull(item); @@ -198,14 +200,14 @@ public class SQLContainerTableQueryTest { public void getItemIds_table_returnsItemIdsWithKeys0through3() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Collection<?> itemIds = container.getItemIds(); Assert.assertEquals(4, itemIds.size()); RowId zero = new RowId(new Object[] { 0 + offset }); RowId one = new RowId(new Object[] { 1 + offset }); RowId two = new RowId(new Object[] { 2 + offset }); RowId three = new RowId(new Object[] { 3 + offset }); - if (AllTests.db == DB.ORACLE) { + if (SQLTestsConstants.db == DB.ORACLE) { String[] correct = new String[] { "1", "2", "3", "4" }; List<String> oracle = new ArrayList<String>(); for (Object o : itemIds) { @@ -221,15 +223,15 @@ public class SQLContainerTableQueryTest { @Test public void getType_tableNAMEPropertyId_returnsString() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Assert.assertEquals(String.class, container.getType("NAME")); } @Test public void getType_tableIDPropertyId_returnsInteger() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); - if (AllTests.db == DB.ORACLE) { + connectionPool, SQLTestsConstants.sqlGen)); + if (SQLTestsConstants.db == DB.ORACLE) { Assert.assertEquals(BigDecimal.class, container.getType("ID")); } else { Assert.assertEquals(Integer.class, container.getType("ID")); @@ -240,14 +242,14 @@ public class SQLContainerTableQueryTest { public void getType_tableNonexistingPropertyId_returnsNull() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Assert.assertNull(container.getType("asdf")); } @Test public void size_table_returnsFour() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Assert.assertEquals(4, container.size()); } @@ -255,7 +257,7 @@ public class SQLContainerTableQueryTest { public void size_tableOneAddedItem_returnsFive() throws SQLException { Connection conn = connectionPool.reserveConnection(); Statement statement = conn.createStatement(); - if (AllTests.db == DB.MSSQL) { + if (SQLTestsConstants.db == DB.MSSQL) { statement.executeUpdate("insert into people values('Bengt', 30)"); } else { statement @@ -266,7 +268,7 @@ public class SQLContainerTableQueryTest { connectionPool.releaseConnection(conn); SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Assert.assertEquals(5, container.size()); } @@ -274,8 +276,8 @@ public class SQLContainerTableQueryTest { public void indexOfId_tableWithParameterThree_returnsThree() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); - if (AllTests.db == DB.ORACLE) { + connectionPool, SQLTestsConstants.sqlGen)); + if (SQLTestsConstants.db == DB.ORACLE) { Assert.assertEquals(3, container.indexOfId(new RowId( new Object[] { new BigDecimal(3 + offset) }))); } else { @@ -288,9 +290,10 @@ public class SQLContainerTableQueryTest { public void indexOfId_table5000RowsWithParameter1337_returns1337() throws SQLException { DataGenerator.addFiveThousandPeople(connectionPool); - TableQuery q = new TableQuery("people", connectionPool, AllTests.sqlGen); + TableQuery q = new TableQuery("people", connectionPool, + SQLTestsConstants.sqlGen); SQLContainer container = new SQLContainer(q); - if (AllTests.db == DB.ORACLE) { + if (SQLTestsConstants.db == DB.ORACLE) { container.getItem(new RowId(new Object[] { new BigDecimal( 1337 + offset) })); Assert.assertEquals(1337, container.indexOfId(new RowId( @@ -307,9 +310,9 @@ public class SQLContainerTableQueryTest { throws SQLException { DataGenerator.addFiveThousandPeople(connectionPool); SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object itemId = container.getIdByIndex(1337); - if (AllTests.db == DB.ORACLE) { + if (SQLTestsConstants.db == DB.ORACLE) { Assert.assertEquals( new RowId(new Object[] { 1337 + offset }).toString(), itemId.toString()); @@ -324,10 +327,10 @@ public class SQLContainerTableQueryTest { throws SQLException { DataGenerator.addFiveThousandPeople(connectionPool); TableQuery query = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); SQLContainer container = new SQLContainer(query); Object itemId = container.getIdByIndex(1337); - if (AllTests.db == DB.ORACLE) { + if (SQLTestsConstants.db == DB.ORACLE) { Assert.assertEquals( new RowId(new Object[] { 1337 + offset }).toString(), itemId.toString()); @@ -342,9 +345,9 @@ public class SQLContainerTableQueryTest { throws SQLException { DataGenerator.addFiveThousandPeople(connectionPool); SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object itemId = container.getIdByIndex(1337); - if (AllTests.db == DB.ORACLE) { + if (SQLTestsConstants.db == DB.ORACLE) { Assert.assertEquals( new RowId(new Object[] { 1338 + offset }).toString(), container.nextItemId(itemId).toString()); @@ -359,9 +362,9 @@ public class SQLContainerTableQueryTest { throws SQLException { DataGenerator.addFiveThousandPeople(connectionPool); SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object itemId = container.getIdByIndex(1337); - if (AllTests.db == DB.ORACLE) { + if (SQLTestsConstants.db == DB.ORACLE) { Assert.assertEquals( new RowId(new Object[] { 1336 + offset }).toString(), container.prevItemId(itemId).toString()); @@ -374,8 +377,8 @@ public class SQLContainerTableQueryTest { @Test public void firstItemId_table_returnsItemId0() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); - if (AllTests.db == DB.ORACLE) { + connectionPool, SQLTestsConstants.sqlGen)); + if (SQLTestsConstants.db == DB.ORACLE) { Assert.assertEquals( new RowId(new Object[] { 0 + offset }).toString(), container.firstItemId().toString()); @@ -391,8 +394,8 @@ public class SQLContainerTableQueryTest { DataGenerator.addFiveThousandPeople(connectionPool); SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); - if (AllTests.db == DB.ORACLE) { + connectionPool, SQLTestsConstants.sqlGen)); + if (SQLTestsConstants.db == DB.ORACLE) { Assert.assertEquals( new RowId(new Object[] { 4999 + offset }).toString(), container.lastItemId().toString()); @@ -405,8 +408,8 @@ public class SQLContainerTableQueryTest { @Test public void isFirstId_tableActualFirstId_returnsTrue() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); - if (AllTests.db == DB.ORACLE) { + connectionPool, SQLTestsConstants.sqlGen)); + if (SQLTestsConstants.db == DB.ORACLE) { Assert.assertTrue(container.isFirstId(new RowId( new Object[] { new BigDecimal(0 + offset) }))); } else { @@ -418,8 +421,8 @@ public class SQLContainerTableQueryTest { @Test public void isFirstId_tableSecondId_returnsFalse() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); - if (AllTests.db == DB.ORACLE) { + connectionPool, SQLTestsConstants.sqlGen)); + if (SQLTestsConstants.db == DB.ORACLE) { Assert.assertFalse(container.isFirstId(new RowId( new Object[] { new BigDecimal(1 + offset) }))); } else { @@ -431,8 +434,8 @@ public class SQLContainerTableQueryTest { @Test public void isLastId_tableSecondId_returnsFalse() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); - if (AllTests.db == DB.ORACLE) { + connectionPool, SQLTestsConstants.sqlGen)); + if (SQLTestsConstants.db == DB.ORACLE) { Assert.assertFalse(container.isLastId(new RowId( new Object[] { new BigDecimal(1 + offset) }))); } else { @@ -444,8 +447,8 @@ public class SQLContainerTableQueryTest { @Test public void isLastId_tableLastId_returnsTrue() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); - if (AllTests.db == DB.ORACLE) { + connectionPool, SQLTestsConstants.sqlGen)); + if (SQLTestsConstants.db == DB.ORACLE) { Assert.assertTrue(container.isLastId(new RowId( new Object[] { new BigDecimal(3 + offset) }))); } else { @@ -458,8 +461,8 @@ public class SQLContainerTableQueryTest { public void isLastId_table5000RowsLastId_returnsTrue() throws SQLException { DataGenerator.addFiveThousandPeople(connectionPool); SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); - if (AllTests.db == DB.ORACLE) { + connectionPool, SQLTestsConstants.sqlGen)); + if (SQLTestsConstants.db == DB.ORACLE) { Assert.assertTrue(container.isLastId(new RowId( new Object[] { new BigDecimal(4999 + offset) }))); } else { @@ -473,7 +476,7 @@ public class SQLContainerTableQueryTest { throws SQLException { DataGenerator.addFiveThousandPeople(connectionPool); SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); for (int i = 0; i < 5000; i++) { Assert.assertTrue(container.containsId(container.getIdByIndex(i))); } @@ -484,7 +487,7 @@ public class SQLContainerTableQueryTest { throws SQLException { DataGenerator.addFiveThousandPeople(connectionPool); SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); container.setAutoCommit(true); for (int i = 0; i < 5000; i++) { Assert.assertTrue(container.containsId(container.getIdByIndex(i))); @@ -494,7 +497,7 @@ public class SQLContainerTableQueryTest { @Test public void refresh_table_sizeShouldUpdate() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Assert.assertEquals(4, container.size()); DataGenerator.addFiveThousandPeople(connectionPool); container.refresh(); @@ -509,7 +512,7 @@ public class SQLContainerTableQueryTest { // make sure that the refresh method actually refreshes stuff and isn't // a NOP. SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Assert.assertEquals(4, container.size()); DataGenerator.addFiveThousandPeople(connectionPool); Assert.assertEquals(4, container.size()); @@ -518,7 +521,7 @@ public class SQLContainerTableQueryTest { @Test public void setAutoCommit_table_shouldSucceed() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); container.setAutoCommit(true); Assert.assertTrue(container.isAutoCommit()); container.setAutoCommit(false); @@ -528,14 +531,14 @@ public class SQLContainerTableQueryTest { @Test public void getPageLength_table_returnsDefault100() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Assert.assertEquals(100, container.getPageLength()); } @Test public void setPageLength_table_shouldSucceed() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); container.setPageLength(20); Assert.assertEquals(20, container.getPageLength()); container.setPageLength(200); @@ -545,7 +548,7 @@ public class SQLContainerTableQueryTest { @Test(expected = UnsupportedOperationException.class) public void addContainerProperty_normal_isUnsupported() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); container.addContainerProperty("asdf", String.class, ""); } @@ -553,14 +556,14 @@ public class SQLContainerTableQueryTest { public void removeContainerProperty_normal_isUnsupported() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); container.removeContainerProperty("asdf"); } @Test(expected = UnsupportedOperationException.class) public void addItemObject_normal_isUnsupported() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); container.addItem("asdf"); } @@ -568,35 +571,35 @@ public class SQLContainerTableQueryTest { public void addItemAfterObjectObject_normal_isUnsupported() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); container.addItemAfter("asdf", "foo"); } @Test(expected = UnsupportedOperationException.class) public void addItemAtIntObject_normal_isUnsupported() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); container.addItemAt(2, "asdf"); } @Test(expected = UnsupportedOperationException.class) public void addItemAtInt_normal_isUnsupported() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); container.addItemAt(2); } @Test(expected = UnsupportedOperationException.class) public void addItemAfterObject_normal_isUnsupported() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); container.addItemAfter("asdf"); } @Test public void addItem_tableAddOneNewItem_returnsItemId() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object itemId = container.addItem(); Assert.assertNotNull(itemId); } @@ -605,7 +608,7 @@ public class SQLContainerTableQueryTest { public void addItem_tableAddOneNewItem_autoCommit_returnsFinalItemId() throws SQLException { TableQuery query = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); SQLContainer container = new SQLContainer(query); container.setAutoCommit(true); Object itemId = container.addItem(); @@ -618,7 +621,7 @@ public class SQLContainerTableQueryTest { public void addItem_tableAddOneNewItem_autoCommit_sizeIsIncreased() throws SQLException { TableQuery query = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); SQLContainer container = new SQLContainer(query); container.setAutoCommit(true); int originalSize = container.size(); @@ -630,7 +633,7 @@ public class SQLContainerTableQueryTest { public void addItem_tableAddOneNewItem_shouldChangeSize() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); int size = container.size(); container.addItem(); Assert.assertEquals(size + 1, container.size()); @@ -640,7 +643,7 @@ public class SQLContainerTableQueryTest { public void addItem_tableAddTwoNewItems_shouldChangeSize() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); int size = container.size(); Object id1 = container.addItem(); Object id2 = container.addItem(); @@ -653,7 +656,7 @@ public class SQLContainerTableQueryTest { public void nextItemId_tableNewlyAddedItem_returnsNewlyAdded() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object lastId = container.lastItemId(); Object id = container.addItem(); Assert.assertEquals(id, container.nextItemId(lastId)); @@ -663,7 +666,7 @@ public class SQLContainerTableQueryTest { public void lastItemId_tableNewlyAddedItem_returnsNewlyAdded() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object lastId = container.lastItemId(); Object id = container.addItem(); Assert.assertEquals(id, container.lastItemId()); @@ -673,7 +676,7 @@ public class SQLContainerTableQueryTest { @Test public void indexOfId_tableNewlyAddedItem_returnsFour() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object id = container.addItem(); Assert.assertEquals(4, container.indexOfId(id)); } @@ -682,7 +685,7 @@ public class SQLContainerTableQueryTest { public void getItem_tableNewlyAddedItem_returnsNewlyAdded() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object id = container.addItem(); Assert.assertNotNull(container.getItem(id)); } @@ -691,7 +694,7 @@ public class SQLContainerTableQueryTest { public void getItemIds_tableNewlyAddedItem_containsNewlyAdded() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object id = container.addItem(); Assert.assertTrue(container.getItemIds().contains(id)); } @@ -700,7 +703,7 @@ public class SQLContainerTableQueryTest { public void getContainerProperty_tableNewlyAddedItem_returnsPropertyOfNewlyAddedItem() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object id = container.addItem(); Item item = container.getItem(id); item.getItemProperty("NAME").setValue("asdf"); @@ -712,7 +715,7 @@ public class SQLContainerTableQueryTest { public void containsId_tableNewlyAddedItem_returnsTrue() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object id = container.addItem(); Assert.assertTrue(container.containsId(id)); } @@ -721,7 +724,7 @@ public class SQLContainerTableQueryTest { public void prevItemId_tableTwoNewlyAddedItems_returnsFirstAddedItem() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object id1 = container.addItem(); Object id2 = container.addItem(); Assert.assertEquals(id1, container.prevItemId(id2)); @@ -732,7 +735,7 @@ public class SQLContainerTableQueryTest { throws SQLException { DataGenerator.createGarbage(connectionPool); SQLContainer container = new SQLContainer(new TableQuery("garbage", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object id = container.addItem(); Assert.assertSame(id, container.firstItemId()); } @@ -742,7 +745,7 @@ public class SQLContainerTableQueryTest { throws SQLException { DataGenerator.createGarbage(connectionPool); SQLContainer container = new SQLContainer(new TableQuery("garbage", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object id = container.addItem(); Assert.assertTrue(container.isFirstId(id)); } @@ -751,7 +754,7 @@ public class SQLContainerTableQueryTest { public void isLastId_tableOneItemAdded_returnsTrueForAddedItem() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object id = container.addItem(); Assert.assertTrue(container.isLastId(id)); } @@ -760,7 +763,7 @@ public class SQLContainerTableQueryTest { public void isLastId_tableTwoItemsAdded_returnsTrueForLastAddedItem() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); container.addItem(); Object id2 = container.addItem(); Assert.assertTrue(container.isLastId(id2)); @@ -770,7 +773,7 @@ public class SQLContainerTableQueryTest { public void getIdByIndex_tableOneItemAddedLastIndexInContainer_returnsAddedItem() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object id = container.addItem(); Assert.assertEquals(id, container.getIdByIndex(container.size() - 1)); } @@ -779,7 +782,7 @@ public class SQLContainerTableQueryTest { public void removeItem_tableNoAddedItems_removesItemFromContainer() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); int size = container.size(); Object id = container.firstItemId(); Assert.assertTrue(container.removeItem(id)); @@ -790,7 +793,7 @@ public class SQLContainerTableQueryTest { @Test public void containsId_tableRemovedItem_returnsFalse() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object id = container.firstItemId(); Assert.assertTrue(container.removeItem(id)); Assert.assertFalse(container.containsId(id)); @@ -800,7 +803,7 @@ public class SQLContainerTableQueryTest { public void removeItem_tableOneAddedItem_removesTheAddedItem() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object id = container.addItem(); int size = container.size(); Assert.assertTrue(container.removeItem(id)); @@ -811,7 +814,7 @@ public class SQLContainerTableQueryTest { @Test public void getItem_tableItemRemoved_returnsNull() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object id = container.firstItemId(); Assert.assertTrue(container.removeItem(id)); Assert.assertNull(container.getItem(id)); @@ -820,7 +823,7 @@ public class SQLContainerTableQueryTest { @Test public void getItem_tableAddedItemRemoved_returnsNull() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object id = container.addItem(); Assert.assertNotNull(container.getItem(id)); Assert.assertTrue(container.removeItem(id)); @@ -831,7 +834,7 @@ public class SQLContainerTableQueryTest { public void getItemIds_tableItemRemoved_shouldNotContainRemovedItem() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object id = container.firstItemId(); Assert.assertTrue(container.getItemIds().contains(id)); Assert.assertTrue(container.removeItem(id)); @@ -842,7 +845,7 @@ public class SQLContainerTableQueryTest { public void getItemIds_tableAddedItemRemoved_shouldNotContainRemovedItem() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object id = container.addItem(); Assert.assertTrue(container.getItemIds().contains(id)); Assert.assertTrue(container.removeItem(id)); @@ -852,7 +855,7 @@ public class SQLContainerTableQueryTest { @Test public void containsId_tableItemRemoved_returnsFalse() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object id = container.firstItemId(); Assert.assertTrue(container.containsId(id)); Assert.assertTrue(container.removeItem(id)); @@ -863,7 +866,7 @@ public class SQLContainerTableQueryTest { public void containsId_tableAddedItemRemoved_returnsFalse() throws SQLException { TableQuery query = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); SQLContainer container = new SQLContainer(query); Object id = container.addItem(); Assert.assertTrue(container.containsId(id)); @@ -875,7 +878,7 @@ public class SQLContainerTableQueryTest { public void nextItemId_tableItemRemoved_skipsRemovedItem() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object first = container.getIdByIndex(0); Object second = container.getIdByIndex(1); Object third = container.getIdByIndex(2); @@ -887,7 +890,7 @@ public class SQLContainerTableQueryTest { public void nextItemId_tableAddedItemRemoved_skipsRemovedItem() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object first = container.lastItemId(); Object second = container.addItem(); Object third = container.addItem(); @@ -899,7 +902,7 @@ public class SQLContainerTableQueryTest { public void prevItemId_tableItemRemoved_skipsRemovedItem() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object first = container.getIdByIndex(0); Object second = container.getIdByIndex(1); Object third = container.getIdByIndex(2); @@ -911,7 +914,7 @@ public class SQLContainerTableQueryTest { public void prevItemId_tableAddedItemRemoved_skipsRemovedItem() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object first = container.lastItemId(); Object second = container.addItem(); Object third = container.addItem(); @@ -923,7 +926,7 @@ public class SQLContainerTableQueryTest { public void firstItemId_tableFirstItemRemoved_resultChanges() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object first = container.firstItemId(); Assert.assertTrue(container.removeItem(first)); Assert.assertNotSame(first, container.firstItemId()); @@ -934,7 +937,7 @@ public class SQLContainerTableQueryTest { throws SQLException { DataGenerator.createGarbage(connectionPool); SQLContainer container = new SQLContainer(new TableQuery("garbage", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object first = container.addItem(); Object second = container.addItem(); Assert.assertSame(first, container.firstItemId()); @@ -946,7 +949,7 @@ public class SQLContainerTableQueryTest { public void lastItemId_tableLastItemRemoved_resultChanges() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object last = container.lastItemId(); Assert.assertTrue(container.removeItem(last)); Assert.assertNotSame(last, container.lastItemId()); @@ -956,7 +959,7 @@ public class SQLContainerTableQueryTest { public void lastItemId_tableAddedLastItemRemoved_resultChanges() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object last = container.addItem(); Assert.assertSame(last, container.lastItemId()); Assert.assertTrue(container.removeItem(last)); @@ -967,7 +970,7 @@ public class SQLContainerTableQueryTest { public void isFirstId_tableFirstItemRemoved_returnsFalse() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object first = container.firstItemId(); Assert.assertTrue(container.removeItem(first)); Assert.assertFalse(container.isFirstId(first)); @@ -978,7 +981,7 @@ public class SQLContainerTableQueryTest { throws SQLException { DataGenerator.createGarbage(connectionPool); SQLContainer container = new SQLContainer(new TableQuery("garbage", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object first = container.addItem(); container.addItem(); Assert.assertSame(first, container.firstItemId()); @@ -990,7 +993,7 @@ public class SQLContainerTableQueryTest { public void isLastId_tableLastItemRemoved_returnsFalse() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object last = container.lastItemId(); Assert.assertTrue(container.removeItem(last)); Assert.assertFalse(container.isLastId(last)); @@ -1000,7 +1003,7 @@ public class SQLContainerTableQueryTest { public void isLastId_tableAddedLastItemRemoved_returnsFalse() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object last = container.addItem(); Assert.assertSame(last, container.lastItemId()); Assert.assertTrue(container.removeItem(last)); @@ -1010,7 +1013,7 @@ public class SQLContainerTableQueryTest { @Test public void indexOfId_tableItemRemoved_returnsNegOne() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object id = container.getIdByIndex(2); Assert.assertTrue(container.removeItem(id)); Assert.assertEquals(-1, container.indexOfId(id)); @@ -1020,7 +1023,7 @@ public class SQLContainerTableQueryTest { public void indexOfId_tableAddedItemRemoved_returnsNegOne() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object id = container.addItem(); Assert.assertTrue(container.indexOfId(id) != -1); Assert.assertTrue(container.removeItem(id)); @@ -1031,7 +1034,7 @@ public class SQLContainerTableQueryTest { public void getIdByIndex_tableItemRemoved_resultChanges() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object id = container.getIdByIndex(2); Assert.assertTrue(container.removeItem(id)); Assert.assertNotSame(id, container.getIdByIndex(2)); @@ -1041,7 +1044,7 @@ public class SQLContainerTableQueryTest { public void getIdByIndex_tableAddedItemRemoved_resultChanges() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object id = container.addItem(); container.addItem(); int index = container.indexOfId(id); @@ -1052,7 +1055,7 @@ public class SQLContainerTableQueryTest { @Test public void removeAllItems_table_shouldSucceed() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Assert.assertTrue(container.removeAllItems()); Assert.assertEquals(0, container.size()); } @@ -1061,7 +1064,7 @@ public class SQLContainerTableQueryTest { public void removeAllItems_tableAddedItems_shouldSucceed() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); container.addItem(); container.addItem(); Assert.assertTrue(container.removeAllItems()); @@ -1071,7 +1074,7 @@ public class SQLContainerTableQueryTest { @Test public void commit_tableAddedItem_shouldBeWrittenToDB() throws SQLException { TableQuery query = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); SQLContainer container = new SQLContainer(query); Object id = container.addItem(); container.getContainerProperty(id, "NAME").setValue("New Name"); @@ -1088,7 +1091,7 @@ public class SQLContainerTableQueryTest { public void commit_tableTwoAddedItems_shouldBeWrittenToDB() throws SQLException { TableQuery query = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); SQLContainer container = new SQLContainer(query); Object id = container.addItem(); Object id2 = container.addItem(); @@ -1111,7 +1114,7 @@ public class SQLContainerTableQueryTest { public void commit_tableRemovedItem_shouldBeRemovedFromDB() throws SQLException { TableQuery query = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); SQLContainer container = new SQLContainer(query); Object last = container.lastItemId(); container.removeItem(last); @@ -1123,7 +1126,7 @@ public class SQLContainerTableQueryTest { public void commit_tableLastItemUpdated_shouldUpdateRowInDB() throws SQLException { TableQuery query = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); SQLContainer container = new SQLContainer(query); Object last = container.lastItemId(); container.getContainerProperty(last, "NAME").setValue("Donald"); @@ -1136,7 +1139,7 @@ public class SQLContainerTableQueryTest { @Test public void rollback_tableItemAdded_discardsAddedItem() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); int size = container.size(); Object id = container.addItem(); container.getContainerProperty(id, "NAME").setValue("foo"); @@ -1151,7 +1154,7 @@ public class SQLContainerTableQueryTest { public void rollback_tableItemRemoved_restoresRemovedItem() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); int size = container.size(); Object last = container.lastItemId(); container.removeItem(last); @@ -1164,7 +1167,7 @@ public class SQLContainerTableQueryTest { @Test public void rollback_tableItemChanged_discardsChanges() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object last = container.lastItemId(); container.getContainerProperty(last, "NAME").setValue("foo"); container.rollback(); @@ -1176,7 +1179,7 @@ public class SQLContainerTableQueryTest { public void itemChangeNotification_table_isModifiedReturnsTrue() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Assert.assertFalse(container.isModified()); RowItem last = (RowItem) container.getItem(container.lastItemId()); container.itemChangeNotification(last); @@ -1186,7 +1189,7 @@ public class SQLContainerTableQueryTest { @Test public void itemSetChangeListeners_table_shouldFire() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); ItemSetChangeListener listener = EasyMock .createMock(ItemSetChangeListener.class); listener.containerItemSetChange(EasyMock.isA(ItemSetChangeEvent.class)); @@ -1202,7 +1205,7 @@ public class SQLContainerTableQueryTest { public void itemSetChangeListeners_tableItemRemoved_shouldFire() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); ItemSetChangeListener listener = EasyMock .createMock(ItemSetChangeListener.class); listener.containerItemSetChange(EasyMock.isA(ItemSetChangeEvent.class)); @@ -1218,7 +1221,7 @@ public class SQLContainerTableQueryTest { @Test public void removeListener_table_shouldNotFire() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); ItemSetChangeListener listener = EasyMock .createMock(ItemSetChangeListener.class); EasyMock.replay(listener); @@ -1233,7 +1236,7 @@ public class SQLContainerTableQueryTest { @Test public void isModified_tableRemovedItem_returnsTrue() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Assert.assertFalse(container.isModified()); container.removeItem(container.lastItemId()); Assert.assertTrue(container.isModified()); @@ -1242,7 +1245,7 @@ public class SQLContainerTableQueryTest { @Test public void isModified_tableAddedItem_returnsTrue() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Assert.assertFalse(container.isModified()); container.addItem(); Assert.assertTrue(container.isModified()); @@ -1251,7 +1254,7 @@ public class SQLContainerTableQueryTest { @Test public void isModified_tableChangedItem_returnsTrue() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Assert.assertFalse(container.isModified()); container.getContainerProperty(container.lastItemId(), "NAME") .setValue("foo"); @@ -1262,13 +1265,14 @@ public class SQLContainerTableQueryTest { public void getSortableContainerPropertyIds_table_returnsAllPropertyIds() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Collection<?> sortableIds = container.getSortableContainerPropertyIds(); Assert.assertTrue(sortableIds.contains("ID")); Assert.assertTrue(sortableIds.contains("NAME")); Assert.assertTrue(sortableIds.contains("AGE")); Assert.assertEquals(3, sortableIds.size()); - if (AllTests.db == DB.MSSQL || AllTests.db == DB.ORACLE) { + if (SQLTestsConstants.db == DB.MSSQL + || SQLTestsConstants.db == DB.ORACLE) { Assert.assertFalse(sortableIds.contains("rownum")); } } @@ -1276,7 +1280,7 @@ public class SQLContainerTableQueryTest { @Test public void addOrderBy_table_shouldReorderResults() throws SQLException { TableQuery query = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); SQLContainer container = new SQLContainer(query); // Ville, Kalle, Pelle, Börje Assert.assertEquals("Ville", @@ -1299,14 +1303,14 @@ public class SQLContainerTableQueryTest { @Test(expected = IllegalArgumentException.class) public void addOrderBy_tableIllegalColumn_shouldFail() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); container.addOrderBy(new OrderBy("asdf", true)); } @Test public void sort_table_sortsByName() throws SQLException { TableQuery query = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); SQLContainer container = new SQLContainer(query); // Ville, Kalle, Pelle, Börje Assert.assertEquals("Ville", @@ -1330,7 +1334,7 @@ public class SQLContainerTableQueryTest { @Test public void addFilter_table_filtersResults() throws SQLException { TableQuery query = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); SQLContainer container = new SQLContainer(query); // Ville, Kalle, Pelle, Börje Assert.assertEquals(4, container.size()); @@ -1349,7 +1353,7 @@ public class SQLContainerTableQueryTest { @Test public void addContainerFilter_filtersResults() throws SQLException { TableQuery query = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); SQLContainer container = new SQLContainer(query); // Ville, Kalle, Pelle, Börje Assert.assertEquals(4, container.size()); @@ -1367,7 +1371,7 @@ public class SQLContainerTableQueryTest { public void addContainerFilter_ignoreCase_filtersResults() throws SQLException { TableQuery query = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); SQLContainer container = new SQLContainer(query); // Ville, Kalle, Pelle, Börje Assert.assertEquals(4, container.size()); @@ -1385,7 +1389,7 @@ public class SQLContainerTableQueryTest { public void removeAllContainerFilters_table_noFiltering() throws SQLException { TableQuery query = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); SQLContainer container = new SQLContainer(query); // Ville, Kalle, Pelle, Börje Assert.assertEquals(4, container.size()); @@ -1409,7 +1413,7 @@ public class SQLContainerTableQueryTest { @Test public void removeContainerFilters_table_noFiltering() throws SQLException { TableQuery query = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); SQLContainer container = new SQLContainer(query); // Ville, Kalle, Pelle, Börje Assert.assertEquals(4, container.size()); @@ -1434,7 +1438,7 @@ public class SQLContainerTableQueryTest { public void addFilter_tableBufferedItems_alsoFiltersBufferedItems() throws SQLException { TableQuery query = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); SQLContainer container = new SQLContainer(query); // Ville, Kalle, Pelle, Börje Assert.assertEquals(4, container.size()); @@ -1490,7 +1494,7 @@ public class SQLContainerTableQueryTest { public void sort_tableBufferedItems_sortsBufferedItemsLastInOrderAdded() throws SQLException { TableQuery query = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); SQLContainer container = new SQLContainer(query); // Ville, Kalle, Pelle, Börje Assert.assertEquals("Ville", diff --git a/server/tests/src/com/vaadin/data/util/sqlcontainer/SQLContainerTest.java b/server/tests/src/com/vaadin/data/util/sqlcontainer/SQLContainerTest.java index 0856b3c08c..64288326f0 100644 --- a/server/tests/src/com/vaadin/data/util/sqlcontainer/SQLContainerTest.java +++ b/server/tests/src/com/vaadin/data/util/sqlcontainer/SQLContainerTest.java @@ -24,7 +24,7 @@ import com.vaadin.data.Container.ItemSetChangeListener; import com.vaadin.data.Item; import com.vaadin.data.util.filter.Compare.Equal; import com.vaadin.data.util.filter.Like; -import com.vaadin.data.util.sqlcontainer.AllTests.DB; +import com.vaadin.data.util.sqlcontainer.SQLTestsConstants.DB; import com.vaadin.data.util.sqlcontainer.connection.JDBCConnectionPool; import com.vaadin.data.util.sqlcontainer.connection.SimpleJDBCConnectionPool; import com.vaadin.data.util.sqlcontainer.query.FreeformQuery; @@ -38,15 +38,16 @@ import com.vaadin.data.util.sqlcontainer.query.generator.StatementHelper; import com.vaadin.data.util.sqlcontainer.query.generator.filter.QueryBuilder; public class SQLContainerTest { - private static final int offset = AllTests.offset; + private static final int offset = SQLTestsConstants.offset; private JDBCConnectionPool connectionPool; @Before public void setUp() throws SQLException { try { - connectionPool = new SimpleJDBCConnectionPool(AllTests.dbDriver, - AllTests.dbURL, AllTests.dbUser, AllTests.dbPwd, 2, 2); + connectionPool = new SimpleJDBCConnectionPool( + SQLTestsConstants.dbDriver, SQLTestsConstants.dbURL, + SQLTestsConstants.dbUser, SQLTestsConstants.dbPwd, 2, 2); } catch (SQLException e) { e.printStackTrace(); Assert.fail(e.getMessage()); @@ -99,7 +100,7 @@ public class SQLContainerTest { throws SQLException { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); - if (AllTests.db == DB.ORACLE) { + if (SQLTestsConstants.db == DB.ORACLE) { Assert.assertEquals( "Ville", container @@ -150,7 +151,7 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Item item; - if (AllTests.db == DB.ORACLE) { + if (SQLTestsConstants.db == DB.ORACLE) { item = container.getItem(new RowId(new Object[] { new BigDecimal( 0 + offset) })); } else { @@ -167,7 +168,7 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Item item; - if (AllTests.db == DB.ORACLE) { + if (SQLTestsConstants.db == DB.ORACLE) { item = container.getItem(new RowId(new Object[] { new BigDecimal( 1337 + offset) })); Assert.assertNotNull(item); @@ -194,7 +195,7 @@ public class SQLContainerTest { RowId one = new RowId(new Object[] { 1 + offset }); RowId two = new RowId(new Object[] { 2 + offset }); RowId three = new RowId(new Object[] { 3 + offset }); - if (AllTests.db == DB.ORACLE) { + if (SQLTestsConstants.db == DB.ORACLE) { String[] correct = new String[] { "1", "2", "3", "4" }; List<String> oracle = new ArrayList<String>(); for (Object o : itemIds) { @@ -220,7 +221,7 @@ public class SQLContainerTest { throws SQLException { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); - if (AllTests.db == DB.ORACLE) { + if (SQLTestsConstants.db == DB.ORACLE) { Assert.assertEquals(BigDecimal.class, container.getType("ID")); } else { Assert.assertEquals(Integer.class, container.getType("ID")); @@ -246,7 +247,7 @@ public class SQLContainerTest { public void size_freeformOneAddedItem_returnsFive() throws SQLException { Connection conn = connectionPool.reserveConnection(); Statement statement = conn.createStatement(); - if (AllTests.db == DB.MSSQL) { + if (SQLTestsConstants.db == DB.MSSQL) { statement.executeUpdate("insert into people values('Bengt', '42')"); } else { statement @@ -266,7 +267,7 @@ public class SQLContainerTest { throws SQLException { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); - if (AllTests.db == DB.ORACLE) { + if (SQLTestsConstants.db == DB.ORACLE) { Assert.assertEquals(3, container.indexOfId(new RowId( new Object[] { new BigDecimal(3 + offset) }))); } else { @@ -282,7 +283,7 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people ORDER BY \"ID\" ASC", connectionPool, "ID")); - if (AllTests.db == DB.ORACLE) { + if (SQLTestsConstants.db == DB.ORACLE) { container.getItem(new RowId(new Object[] { new BigDecimal( 1337 + offset) })); Assert.assertEquals(1337, container.indexOfId(new RowId( @@ -302,7 +303,7 @@ public class SQLContainerTest { "SELECT * FROM people ORDER BY \"ID\" ASC", connectionPool, "ID")); Object itemId = container.getIdByIndex(1337); - if (AllTests.db == DB.ORACLE) { + if (SQLTestsConstants.db == DB.ORACLE) { Assert.assertEquals(new RowId(new Object[] { new BigDecimal( 1337 + offset) }), itemId); } else { @@ -328,7 +329,7 @@ public class SQLContainerTest { Object[] args = EasyMock.getCurrentArguments(); int offset = (Integer) (args[0]); int limit = (Integer) (args[1]); - if (AllTests.db == DB.MSSQL) { + if (SQLTestsConstants.db == DB.MSSQL) { int start = offset + 1; int end = offset + limit + 1; String q = "SELECT * FROM (SELECT row_number() OVER" @@ -337,7 +338,7 @@ public class SQLContainerTest { + start + " AND " + end; return q; - } else if (AllTests.db == DB.ORACLE) { + } else if (SQLTestsConstants.db == DB.ORACLE) { int start = offset + 1; int end = offset + limit + 1; String q = "SELECT * FROM (SELECT x.*, ROWNUM AS r FROM" @@ -367,7 +368,7 @@ public class SQLContainerTest { query.setDelegate(delegate); SQLContainer container = new SQLContainer(query); Object itemId = container.getIdByIndex(1337); - if (AllTests.db == DB.ORACLE) { + if (SQLTestsConstants.db == DB.ORACLE) { Assert.assertEquals( new RowId(new Object[] { 1337 + offset }).toString(), itemId.toString()); @@ -385,7 +386,7 @@ public class SQLContainerTest { "SELECT * FROM people ORDER BY \"ID\" ASC", connectionPool, "ID")); Object itemId = container.getIdByIndex(1337); - if (AllTests.db == DB.ORACLE) { + if (SQLTestsConstants.db == DB.ORACLE) { Assert.assertEquals( new RowId(new Object[] { 1338 + offset }).toString(), container.nextItemId(itemId).toString()); @@ -403,7 +404,7 @@ public class SQLContainerTest { "SELECT * FROM people ORDER BY \"ID\" ASC", connectionPool, "ID")); Object itemId = container.getIdByIndex(1337); - if (AllTests.db == DB.ORACLE) { + if (SQLTestsConstants.db == DB.ORACLE) { Assert.assertEquals( new RowId(new Object[] { 1336 + offset }).toString(), container.prevItemId(itemId).toString()); @@ -417,7 +418,7 @@ public class SQLContainerTest { public void firstItemId_freeform_returnsItemId0() throws SQLException { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); - if (AllTests.db == DB.ORACLE) { + if (SQLTestsConstants.db == DB.ORACLE) { Assert.assertEquals( new RowId(new Object[] { 0 + offset }).toString(), container.firstItemId().toString()); @@ -435,7 +436,7 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people ORDER BY \"ID\" ASC", connectionPool, "ID")); - if (AllTests.db == DB.ORACLE) { + if (SQLTestsConstants.db == DB.ORACLE) { Assert.assertEquals( new RowId(new Object[] { 4999 + offset }).toString(), container.lastItemId().toString()); @@ -450,7 +451,7 @@ public class SQLContainerTest { throws SQLException { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); - if (AllTests.db == DB.ORACLE) { + if (SQLTestsConstants.db == DB.ORACLE) { Assert.assertTrue(container.isFirstId(new RowId( new Object[] { new BigDecimal(0 + offset) }))); } else { @@ -463,7 +464,7 @@ public class SQLContainerTest { public void isFirstId_freeformSecondId_returnsFalse() throws SQLException { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); - if (AllTests.db == DB.ORACLE) { + if (SQLTestsConstants.db == DB.ORACLE) { Assert.assertFalse(container.isFirstId(new RowId( new Object[] { new BigDecimal(1 + offset) }))); } else { @@ -476,7 +477,7 @@ public class SQLContainerTest { public void isLastId_freeformSecondId_returnsFalse() throws SQLException { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); - if (AllTests.db == DB.ORACLE) { + if (SQLTestsConstants.db == DB.ORACLE) { Assert.assertFalse(container.isLastId(new RowId( new Object[] { new BigDecimal(1 + offset) }))); } else { @@ -489,7 +490,7 @@ public class SQLContainerTest { public void isLastId_freeformLastId_returnsTrue() throws SQLException { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); - if (AllTests.db == DB.ORACLE) { + if (SQLTestsConstants.db == DB.ORACLE) { Assert.assertTrue(container.isLastId(new RowId( new Object[] { new BigDecimal(3 + offset) }))); } else { @@ -505,7 +506,7 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people ORDER BY \"ID\" ASC", connectionPool, "ID")); - if (AllTests.db == DB.ORACLE) { + if (SQLTestsConstants.db == DB.ORACLE) { Assert.assertTrue(container.isLastId(new RowId( new Object[] { new BigDecimal(4999 + offset) }))); } else { @@ -1139,7 +1140,7 @@ public class SQLContainerTest { .getCurrentArguments()[0]; RowItem item = (RowItem) EasyMock.getCurrentArguments()[1]; Statement statement = conn.createStatement(); - if (AllTests.db == DB.MSSQL) { + if (SQLTestsConstants.db == DB.MSSQL) { statement .executeUpdate("insert into people values('" + item.getItemProperty("NAME") @@ -1170,7 +1171,7 @@ public class SQLContainerTest { Object[] args = EasyMock.getCurrentArguments(); int offset = (Integer) (args[0]); int limit = (Integer) (args[1]); - if (AllTests.db == DB.MSSQL) { + if (SQLTestsConstants.db == DB.MSSQL) { int start = offset + 1; int end = offset + limit + 1; String q = "SELECT * FROM (SELECT row_number() OVER" @@ -1179,7 +1180,7 @@ public class SQLContainerTest { + start + " AND " + end; return q; - } else if (AllTests.db == DB.ORACLE) { + } else if (SQLTestsConstants.db == DB.ORACLE) { int start = offset + 1; int end = offset + limit + 1; String q = "SELECT * FROM (SELECT x.*, ROWNUM AS r FROM" @@ -1240,7 +1241,7 @@ public class SQLContainerTest { .getCurrentArguments()[0]; RowItem item = (RowItem) EasyMock.getCurrentArguments()[1]; Statement statement = conn.createStatement(); - if (AllTests.db == DB.MSSQL) { + if (SQLTestsConstants.db == DB.MSSQL) { statement .executeUpdate("insert into people values('" + item.getItemProperty("NAME") @@ -1271,7 +1272,7 @@ public class SQLContainerTest { Object[] args = EasyMock.getCurrentArguments(); int offset = (Integer) (args[0]); int limit = (Integer) (args[1]); - if (AllTests.db == DB.MSSQL) { + if (SQLTestsConstants.db == DB.MSSQL) { int start = offset + 1; int end = offset + limit + 1; String q = "SELECT * FROM (SELECT row_number() OVER" @@ -1280,7 +1281,7 @@ public class SQLContainerTest { + start + " AND " + end; return q; - } else if (AllTests.db == DB.ORACLE) { + } else if (SQLTestsConstants.db == DB.ORACLE) { int start = offset + 1; int end = offset + limit + 1; String q = "SELECT * FROM (SELECT x.*, ROWNUM AS r FROM" @@ -1363,7 +1364,7 @@ public class SQLContainerTest { Object[] args = EasyMock.getCurrentArguments(); int offset = (Integer) (args[0]); int limit = (Integer) (args[1]); - if (AllTests.db == DB.MSSQL) { + if (SQLTestsConstants.db == DB.MSSQL) { int start = offset + 1; int end = offset + limit + 1; String q = "SELECT * FROM (SELECT row_number() OVER" @@ -1372,7 +1373,7 @@ public class SQLContainerTest { + start + " AND " + end; return q; - } else if (AllTests.db == DB.ORACLE) { + } else if (SQLTestsConstants.db == DB.ORACLE) { int start = offset + 1; int end = offset + limit + 1; String q = "SELECT * FROM (SELECT x.*, ROWNUM AS r FROM" @@ -1445,7 +1446,7 @@ public class SQLContainerTest { Object[] args = EasyMock.getCurrentArguments(); int offset = (Integer) (args[0]); int limit = (Integer) (args[1]); - if (AllTests.db == DB.MSSQL) { + if (SQLTestsConstants.db == DB.MSSQL) { int start = offset + 1; int end = offset + limit + 1; String q = "SELECT * FROM (SELECT row_number() OVER" @@ -1454,7 +1455,7 @@ public class SQLContainerTest { + start + " AND " + end; return q; - } else if (AllTests.db == DB.ORACLE) { + } else if (SQLTestsConstants.db == DB.ORACLE) { int start = offset + 1; int end = offset + limit + 1; String q = "SELECT * FROM (SELECT x.*, ROWNUM AS r FROM" @@ -1670,7 +1671,7 @@ public class SQLContainerTest { Object[] args = EasyMock.getCurrentArguments(); int offset = (Integer) (args[0]); int limit = (Integer) (args[1]); - if (AllTests.db == DB.MSSQL) { + if (SQLTestsConstants.db == DB.MSSQL) { SQLGenerator gen = new MSSQLGenerator(); if (orderBys == null || orderBys.isEmpty()) { List<OrderBy> ob = new ArrayList<OrderBy>(); @@ -1683,7 +1684,7 @@ public class SQLContainerTest { orderBys, offset, limit, null) .getQueryString(); } - } else if (AllTests.db == DB.ORACLE) { + } else if (SQLTestsConstants.db == DB.ORACLE) { SQLGenerator gen = new OracleGenerator(); if (orderBys == null || orderBys.isEmpty()) { List<OrderBy> ob = new ArrayList<OrderBy>(); @@ -1784,7 +1785,7 @@ public class SQLContainerTest { Object[] args = EasyMock.getCurrentArguments(); int offset = (Integer) (args[0]); int limit = (Integer) (args[1]); - if (AllTests.db == DB.MSSQL) { + if (SQLTestsConstants.db == DB.MSSQL) { SQLGenerator gen = new MSSQLGenerator(); if (orderBys == null || orderBys.isEmpty()) { List<OrderBy> ob = new ArrayList<OrderBy>(); @@ -1797,7 +1798,7 @@ public class SQLContainerTest { orderBys, offset, limit, null) .getQueryString(); } - } else if (AllTests.db == DB.ORACLE) { + } else if (SQLTestsConstants.db == DB.ORACLE) { SQLGenerator gen = new OracleGenerator(); if (orderBys == null || orderBys.isEmpty()) { List<OrderBy> ob = new ArrayList<OrderBy>(); @@ -2376,7 +2377,7 @@ public class SQLContainerTest { Object[] args = EasyMock.getCurrentArguments(); int offset = (Integer) (args[0]); int limit = (Integer) (args[1]); - if (AllTests.db == DB.MSSQL) { + if (SQLTestsConstants.db == DB.MSSQL) { SQLGenerator gen = new MSSQLGenerator(); if (orderBys == null || orderBys.isEmpty()) { List<OrderBy> ob = new ArrayList<OrderBy>(); @@ -2389,7 +2390,7 @@ public class SQLContainerTest { orderBys, offset, limit, null) .getQueryString(); } - } else if (AllTests.db == DB.ORACLE) { + } else if (SQLTestsConstants.db == DB.ORACLE) { SQLGenerator gen = new OracleGenerator(); if (orderBys == null || orderBys.isEmpty()) { List<OrderBy> ob = new ArrayList<OrderBy>(); diff --git a/server/tests/src/com/vaadin/data/util/sqlcontainer/SQLTestsConstants.java b/server/tests/src/com/vaadin/data/util/sqlcontainer/SQLTestsConstants.java new file mode 100755 index 0000000000..ae87bb8d7e --- /dev/null +++ b/server/tests/src/com/vaadin/data/util/sqlcontainer/SQLTestsConstants.java @@ -0,0 +1,143 @@ +/* + * Copyright 2011 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.data.util.sqlcontainer; + +import com.vaadin.data.util.sqlcontainer.query.generator.DefaultSQLGenerator; +import com.vaadin.data.util.sqlcontainer.query.generator.MSSQLGenerator; +import com.vaadin.data.util.sqlcontainer.query.generator.OracleGenerator; +import com.vaadin.data.util.sqlcontainer.query.generator.SQLGenerator; + +public class SQLTestsConstants { + + /* Set the DB used for testing here! */ + public enum DB { + HSQLDB, MYSQL, POSTGRESQL, MSSQL, ORACLE; + } + + /* 0 = HSQLDB, 1 = MYSQL, 2 = POSTGRESQL, 3 = MSSQL, 4 = ORACLE */ + public static final DB db = DB.HSQLDB; + + /* Auto-increment column offset (HSQLDB = 0, MYSQL = 1, POSTGRES = 1) */ + public static int offset; + /* Garbage table creation query (=three queries for oracle) */ + public static String createGarbage; + public static String createGarbageSecond; + public static String createGarbageThird; + /* DB Drivers, urls, usernames and passwords */ + public static String dbDriver; + public static String dbURL; + public static String dbUser; + public static String dbPwd; + /* People -test table creation statement(s) */ + public static String peopleFirst; + public static String peopleSecond; + public static String peopleThird; + /* Versioned -test table createion statement(s) */ + public static String[] versionStatements; + /* SQL Generator used during the testing */ + public static SQLGenerator sqlGen; + + /* Set DB-specific settings based on selected DB */ + static { + sqlGen = new DefaultSQLGenerator(); + switch (db) { + case HSQLDB: + offset = 0; + createGarbage = "create table garbage (id integer generated always as identity, type varchar(32), PRIMARY KEY(id))"; + dbDriver = "org.hsqldb.jdbc.JDBCDriver"; + dbURL = "jdbc:hsqldb:mem:sqlcontainer"; + dbUser = "SA"; + dbPwd = ""; + peopleFirst = "create table people (id integer generated always as identity, name varchar(32), AGE INTEGER)"; + peopleSecond = "alter table people add primary key (id)"; + versionStatements = new String[] { + "create table versioned (id integer generated always as identity, text varchar(255), version tinyint default 0)", + "alter table versioned add primary key (id)" }; + break; + case MYSQL: + offset = 1; + createGarbage = "create table GARBAGE (ID integer auto_increment, type varchar(32), PRIMARY KEY(ID))"; + dbDriver = "com.mysql.jdbc.Driver"; + dbURL = "jdbc:mysql:///sqlcontainer"; + dbUser = "sqlcontainer"; + dbPwd = "sqlcontainer"; + peopleFirst = "create table PEOPLE (ID integer auto_increment not null, NAME varchar(32), AGE INTEGER, primary key(ID))"; + peopleSecond = null; + versionStatements = new String[] { + "create table VERSIONED (ID integer auto_increment not null, TEXT varchar(255), VERSION tinyint default 0, primary key(ID))", + "CREATE TRIGGER upd_version BEFORE UPDATE ON VERSIONED" + + " FOR EACH ROW SET NEW.VERSION = OLD.VERSION+1" }; + break; + case POSTGRESQL: + offset = 1; + createGarbage = "create table GARBAGE (\"ID\" serial PRIMARY KEY, \"TYPE\" varchar(32))"; + dbDriver = "org.postgresql.Driver"; + dbURL = "jdbc:postgresql://localhost:5432/test"; + dbUser = "postgres"; + dbPwd = "postgres"; + peopleFirst = "create table PEOPLE (\"ID\" serial primary key, \"NAME\" VARCHAR(32), \"AGE\" INTEGER)"; + peopleSecond = null; + versionStatements = new String[] { + "create table VERSIONED (\"ID\" serial primary key, \"TEXT\" VARCHAR(255), \"VERSION\" INTEGER DEFAULT 0)", + "CREATE OR REPLACE FUNCTION zz_row_version() RETURNS TRIGGER AS $$" + + "BEGIN" + + " IF TG_OP = 'UPDATE'" + + " AND NEW.\"VERSION\" = old.\"VERSION\"" + + " AND ROW(NEW.*) IS DISTINCT FROM ROW (old.*)" + + " THEN" + + " NEW.\"VERSION\" := NEW.\"VERSION\" + 1;" + + " END IF;" + " RETURN NEW;" + "END;" + + "$$ LANGUAGE plpgsql;", + "CREATE TRIGGER \"mytable_modify_dt_tr\" BEFORE UPDATE" + + " ON VERSIONED FOR EACH ROW" + + " EXECUTE PROCEDURE \"public\".\"zz_row_version\"();" }; + break; + case MSSQL: + offset = 1; + createGarbage = "create table GARBAGE (\"ID\" int identity(1,1) primary key, \"TYPE\" varchar(32))"; + dbDriver = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; + dbURL = "jdbc:sqlserver://localhost:1433;databaseName=tempdb;"; + dbUser = "sa"; + dbPwd = "sa"; + peopleFirst = "create table PEOPLE (\"ID\" int identity(1,1) primary key, \"NAME\" VARCHAR(32), \"AGE\" INTEGER)"; + peopleSecond = null; + versionStatements = new String[] { "create table VERSIONED (\"ID\" int identity(1,1) primary key, \"TEXT\" VARCHAR(255), \"VERSION\" rowversion not null)" }; + sqlGen = new MSSQLGenerator(); + break; + case ORACLE: + offset = 1; + createGarbage = "create table GARBAGE (\"ID\" integer primary key, \"TYPE\" varchar2(32))"; + createGarbageSecond = "create sequence garbage_seq start with 1 increment by 1 nomaxvalue"; + createGarbageThird = "create trigger garbage_trigger before insert on GARBAGE for each row begin select garbage_seq.nextval into :new.ID from dual; end;"; + dbDriver = "oracle.jdbc.OracleDriver"; + dbURL = "jdbc:oracle:thin:test/test@localhost:1521:XE"; + dbUser = "test"; + dbPwd = "test"; + peopleFirst = "create table PEOPLE (\"ID\" integer primary key, \"NAME\" VARCHAR2(32), \"AGE\" INTEGER)"; + peopleSecond = "create sequence people_seq start with 1 increment by 1 nomaxvalue"; + peopleThird = "create trigger people_trigger before insert on PEOPLE for each row begin select people_seq.nextval into :new.ID from dual; end;"; + versionStatements = new String[] { + "create table VERSIONED (\"ID\" integer primary key, \"TEXT\" VARCHAR(255), \"VERSION\" INTEGER DEFAULT 0)", + "create sequence versioned_seq start with 1 increment by 1 nomaxvalue", + "create trigger versioned_trigger before insert on VERSIONED for each row begin select versioned_seq.nextval into :new.ID from dual; end;", + "create sequence versioned_version start with 1 increment by 1 nomaxvalue", + "create trigger versioned_version_trigger before insert or update on VERSIONED for each row begin select versioned_version.nextval into :new.VERSION from dual; end;" }; + sqlGen = new OracleGenerator(); + break; + } + } + +}
\ No newline at end of file diff --git a/server/tests/src/com/vaadin/data/util/sqlcontainer/TicketTests.java b/server/tests/src/com/vaadin/data/util/sqlcontainer/TicketTests.java index 6287d4c4fa..deebe9a08e 100644 --- a/server/tests/src/com/vaadin/data/util/sqlcontainer/TicketTests.java +++ b/server/tests/src/com/vaadin/data/util/sqlcontainer/TicketTests.java @@ -15,7 +15,7 @@ import org.junit.Test; import com.vaadin.data.Container.Filter; import com.vaadin.data.Item; import com.vaadin.data.util.filter.Compare.Equal; -import com.vaadin.data.util.sqlcontainer.AllTests.DB; +import com.vaadin.data.util.sqlcontainer.SQLTestsConstants.DB; import com.vaadin.data.util.sqlcontainer.connection.SimpleJDBCConnectionPool; import com.vaadin.data.util.sqlcontainer.query.FreeformQuery; import com.vaadin.data.util.sqlcontainer.query.FreeformStatementDelegate; @@ -31,8 +31,9 @@ public class TicketTests { @Before public void setUp() throws SQLException { - connectionPool = new SimpleJDBCConnectionPool(AllTests.dbDriver, - AllTests.dbURL, AllTests.dbUser, AllTests.dbPwd, 2, 2); + connectionPool = new SimpleJDBCConnectionPool( + SQLTestsConstants.dbDriver, SQLTestsConstants.dbURL, + SQLTestsConstants.dbUser, SQLTestsConstants.dbPwd, 2, 2); DataGenerator.addPeopleToDatabase(connectionPool); } @@ -116,7 +117,7 @@ public class TicketTests { Assert.assertEquals("Pelle", container.getContainerProperty(container.firstItemId(), "NAME") .getValue()); - if (AllTests.db == DB.ORACLE) { + if (SQLTestsConstants.db == DB.ORACLE) { Assert.assertEquals(new BigDecimal(18), container .getContainerProperty(container.firstItemId(), "AGE") .getValue()); @@ -133,7 +134,7 @@ public class TicketTests { @Test public void ticket6136_table_ageIs18() throws SQLException { TableQuery query = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); SQLContainer container = new SQLContainer(query); // Ville, Kalle, Pelle, Börje Assert.assertEquals(4, container.size()); @@ -145,7 +146,7 @@ public class TicketTests { Assert.assertEquals("Pelle", container.getContainerProperty(container.firstItemId(), "NAME") .getValue()); - if (AllTests.db == DB.ORACLE) { + if (SQLTestsConstants.db == DB.ORACLE) { Assert.assertEquals(new BigDecimal(18), container .getContainerProperty(container.firstItemId(), "AGE") .getValue()); @@ -161,7 +162,7 @@ public class TicketTests { public void ticket7434_getItem_Modified_Changed_Unchanged() throws SQLException { SQLContainer container = new SQLContainer(new TableQuery("people", - connectionPool, AllTests.sqlGen)); + connectionPool, SQLTestsConstants.sqlGen)); Object id = container.firstItemId(); Item item = container.getItem(id); diff --git a/server/tests/src/com/vaadin/data/util/sqlcontainer/connection/SimpleJDBCConnectionPoolTest.java b/server/tests/src/com/vaadin/data/util/sqlcontainer/connection/SimpleJDBCConnectionPoolTest.java index 7616abbc45..541ab8da5b 100644 --- a/server/tests/src/com/vaadin/data/util/sqlcontainer/connection/SimpleJDBCConnectionPoolTest.java +++ b/server/tests/src/com/vaadin/data/util/sqlcontainer/connection/SimpleJDBCConnectionPoolTest.java @@ -9,15 +9,16 @@ import org.easymock.EasyMock; import org.junit.Before; import org.junit.Test; -import com.vaadin.data.util.sqlcontainer.AllTests; +import com.vaadin.data.util.sqlcontainer.SQLTestsConstants; public class SimpleJDBCConnectionPoolTest { private JDBCConnectionPool connectionPool; @Before public void setUp() throws SQLException { - connectionPool = new SimpleJDBCConnectionPool(AllTests.dbDriver, - AllTests.dbURL, AllTests.dbUser, AllTests.dbPwd, 2, 2); + connectionPool = new SimpleJDBCConnectionPool( + SQLTestsConstants.dbDriver, SQLTestsConstants.dbURL, + SQLTestsConstants.dbUser, SQLTestsConstants.dbPwd, 2, 2); } @Test @@ -93,34 +94,37 @@ public class SimpleJDBCConnectionPoolTest { @Test(expected = IllegalArgumentException.class) public void construct_onlyDriverNameGiven_shouldFail() throws SQLException { SimpleJDBCConnectionPool cp = new SimpleJDBCConnectionPool( - AllTests.dbDriver, null, null, null); + SQLTestsConstants.dbDriver, null, null, null); } @Test(expected = IllegalArgumentException.class) public void construct_onlyDriverNameAndUrlGiven_shouldFail() throws SQLException { SimpleJDBCConnectionPool cp = new SimpleJDBCConnectionPool( - AllTests.dbDriver, AllTests.dbURL, null, null); + SQLTestsConstants.dbDriver, SQLTestsConstants.dbURL, null, null); } @Test(expected = IllegalArgumentException.class) public void construct_onlyDriverNameAndUrlAndUserGiven_shouldFail() throws SQLException { SimpleJDBCConnectionPool cp = new SimpleJDBCConnectionPool( - AllTests.dbDriver, AllTests.dbURL, AllTests.dbUser, null); + SQLTestsConstants.dbDriver, SQLTestsConstants.dbURL, + SQLTestsConstants.dbUser, null); } @Test(expected = RuntimeException.class) public void construct_nonExistingDriver_shouldFail() throws SQLException { SimpleJDBCConnectionPool cp = new SimpleJDBCConnectionPool("foo", - AllTests.dbURL, AllTests.dbUser, AllTests.dbPwd); + SQLTestsConstants.dbURL, SQLTestsConstants.dbUser, + SQLTestsConstants.dbPwd); } @Test public void reserveConnection_newConnectionOpened_shouldSucceed() throws SQLException { - connectionPool = new SimpleJDBCConnectionPool(AllTests.dbDriver, - AllTests.dbURL, AllTests.dbUser, AllTests.dbPwd, 0, 2); + connectionPool = new SimpleJDBCConnectionPool( + SQLTestsConstants.dbDriver, SQLTestsConstants.dbURL, + SQLTestsConstants.dbUser, SQLTestsConstants.dbPwd, 0, 2); Connection c = connectionPool.reserveConnection(); Assert.assertNotNull(c); } diff --git a/server/tests/src/com/vaadin/data/util/sqlcontainer/generator/SQLGeneratorsTest.java b/server/tests/src/com/vaadin/data/util/sqlcontainer/generator/SQLGeneratorsTest.java index e62a06e6e1..2db31dc13f 100644 --- a/server/tests/src/com/vaadin/data/util/sqlcontainer/generator/SQLGeneratorsTest.java +++ b/server/tests/src/com/vaadin/data/util/sqlcontainer/generator/SQLGeneratorsTest.java @@ -13,7 +13,7 @@ import org.junit.Test; import com.vaadin.data.Container.Filter; import com.vaadin.data.util.filter.Like; import com.vaadin.data.util.filter.Or; -import com.vaadin.data.util.sqlcontainer.AllTests; +import com.vaadin.data.util.sqlcontainer.SQLTestsConstants; import com.vaadin.data.util.sqlcontainer.DataGenerator; import com.vaadin.data.util.sqlcontainer.RowItem; import com.vaadin.data.util.sqlcontainer.SQLContainer; @@ -34,8 +34,9 @@ public class SQLGeneratorsTest { public void setUp() throws SQLException { try { - connectionPool = new SimpleJDBCConnectionPool(AllTests.dbDriver, - AllTests.dbURL, AllTests.dbUser, AllTests.dbPwd, 2, 2); + connectionPool = new SimpleJDBCConnectionPool( + SQLTestsConstants.dbDriver, SQLTestsConstants.dbURL, + SQLTestsConstants.dbUser, SQLTestsConstants.dbPwd, 2, 2); } catch (SQLException e) { e.printStackTrace(); Assert.fail(e.getMessage()); @@ -102,13 +103,13 @@ public class SQLGeneratorsTest { * No need to run this for Oracle/MSSQL generators since the * DefaultSQLGenerator method would be called anyway. */ - if (AllTests.sqlGen instanceof MSSQLGenerator - || AllTests.sqlGen instanceof OracleGenerator) { + if (SQLTestsConstants.sqlGen instanceof MSSQLGenerator + || SQLTestsConstants.sqlGen instanceof OracleGenerator) { return; } - SQLGenerator sg = AllTests.sqlGen; + SQLGenerator sg = SQLTestsConstants.sqlGen; TableQuery query = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); SQLContainer container = new SQLContainer(query); StatementHelper sh = sg.generateDeleteQuery( @@ -128,8 +129,8 @@ public class SQLGeneratorsTest { * No need to run this for Oracle/MSSQL generators since the * DefaultSQLGenerator method would be called anyway. */ - if (AllTests.sqlGen instanceof MSSQLGenerator - || AllTests.sqlGen instanceof OracleGenerator) { + if (SQLTestsConstants.sqlGen instanceof MSSQLGenerator + || SQLTestsConstants.sqlGen instanceof OracleGenerator) { return; } SQLGenerator sg = new DefaultSQLGenerator(); @@ -154,8 +155,8 @@ public class SQLGeneratorsTest { * No need to run this for Oracle/MSSQL generators since the * DefaultSQLGenerator method would be called anyway. */ - if (AllTests.sqlGen instanceof MSSQLGenerator - || AllTests.sqlGen instanceof OracleGenerator) { + if (SQLTestsConstants.sqlGen instanceof MSSQLGenerator + || SQLTestsConstants.sqlGen instanceof OracleGenerator) { return; } SQLGenerator sg = new DefaultSQLGenerator(); diff --git a/server/tests/src/com/vaadin/data/util/sqlcontainer/query/FreeformQueryTest.java b/server/tests/src/com/vaadin/data/util/sqlcontainer/query/FreeformQueryTest.java index 279f880e55..acb3651bd4 100644 --- a/server/tests/src/com/vaadin/data/util/sqlcontainer/query/FreeformQueryTest.java +++ b/server/tests/src/com/vaadin/data/util/sqlcontainer/query/FreeformQueryTest.java @@ -16,8 +16,8 @@ import org.junit.Test; import com.vaadin.data.Container.Filter; import com.vaadin.data.util.filter.Like; -import com.vaadin.data.util.sqlcontainer.AllTests; -import com.vaadin.data.util.sqlcontainer.AllTests.DB; +import com.vaadin.data.util.sqlcontainer.SQLTestsConstants; +import com.vaadin.data.util.sqlcontainer.SQLTestsConstants.DB; import com.vaadin.data.util.sqlcontainer.DataGenerator; import com.vaadin.data.util.sqlcontainer.RowId; import com.vaadin.data.util.sqlcontainer.RowItem; @@ -27,15 +27,16 @@ import com.vaadin.data.util.sqlcontainer.connection.SimpleJDBCConnectionPool; public class FreeformQueryTest { - private static final int offset = AllTests.offset; + private static final int offset = SQLTestsConstants.offset; private JDBCConnectionPool connectionPool; @Before public void setUp() throws SQLException { try { - connectionPool = new SimpleJDBCConnectionPool(AllTests.dbDriver, - AllTests.dbURL, AllTests.dbUser, AllTests.dbPwd, 2, 2); + connectionPool = new SimpleJDBCConnectionPool( + SQLTestsConstants.dbDriver, SQLTestsConstants.dbURL, + SQLTestsConstants.dbUser, SQLTestsConstants.dbPwd, 2, 2); } catch (SQLException e) { e.printStackTrace(); Assert.fail(e.getMessage()); @@ -113,7 +114,7 @@ public class FreeformQueryTest { // Add some people Connection conn = connectionPool.reserveConnection(); Statement statement = conn.createStatement(); - if (AllTests.db == DB.MSSQL) { + if (SQLTestsConstants.db == DB.MSSQL) { statement.executeUpdate("insert into people values('Bengt', 30)"); statement.executeUpdate("insert into people values('Ingvar', 50)"); } else { @@ -416,13 +417,13 @@ public class FreeformQueryTest { Arrays.asList("ID"), connectionPool); FreeformQueryDelegate delegate = EasyMock .createMock(FreeformQueryDelegate.class); - if (AllTests.db == DB.MSSQL) { + if (SQLTestsConstants.db == DB.MSSQL) { EasyMock.expect(delegate.getQueryString(0, 2)) .andReturn( "SELECT * FROM (SELECT row_number()" + "OVER (ORDER BY id ASC) AS rownum, * FROM people)" + " AS a WHERE a.rownum BETWEEN 0 AND 2"); - } else if (AllTests.db == DB.ORACLE) { + } else if (SQLTestsConstants.db == DB.ORACLE) { EasyMock.expect(delegate.getQueryString(0, 2)) .andReturn( "SELECT * FROM (SELECT x.*, ROWNUM AS r FROM" @@ -447,13 +448,13 @@ public class FreeformQueryTest { Arrays.asList("ID"), connectionPool); FreeformQueryDelegate delegate = EasyMock .createMock(FreeformQueryDelegate.class); - if (AllTests.db == DB.MSSQL) { + if (SQLTestsConstants.db == DB.MSSQL) { EasyMock.expect(delegate.getQueryString(0, 2)) .andReturn( "SELECT * FROM (SELECT row_number()" + "OVER (ORDER BY id ASC) AS rownum, * FROM people)" + " AS a WHERE a.rownum BETWEEN 0 AND 2"); - } else if (AllTests.db == DB.ORACLE) { + } else if (SQLTestsConstants.db == DB.ORACLE) { EasyMock.expect(delegate.getQueryString(0, 2)) .andReturn( "SELECT * FROM (SELECT x.*, ROWNUM AS r FROM" @@ -468,7 +469,7 @@ public class FreeformQueryTest { query.beginTransaction(); ResultSet rs = query.getResults(0, 2); int rsoffset = 0; - if (AllTests.db == DB.MSSQL) { + if (SQLTestsConstants.db == DB.MSSQL) { rsoffset++; } Assert.assertTrue(rs.next()); @@ -493,13 +494,13 @@ public class FreeformQueryTest { Arrays.asList("ID"), connectionPool); FreeformQueryDelegate delegate = EasyMock .createMock(FreeformQueryDelegate.class); - if (AllTests.db == DB.MSSQL) { + if (SQLTestsConstants.db == DB.MSSQL) { EasyMock.expect(delegate.getQueryString(200, 100)) .andReturn( "SELECT * FROM (SELECT row_number()" + "OVER (ORDER BY id ASC) AS rownum, * FROM people)" + " AS a WHERE a.rownum BETWEEN 201 AND 300"); - } else if (AllTests.db == DB.ORACLE) { + } else if (SQLTestsConstants.db == DB.ORACLE) { EasyMock.expect(delegate.getQueryString(200, 100)) .andReturn( "SELECT * FROM (SELECT x.*, ROWNUM AS r FROM" diff --git a/server/tests/src/com/vaadin/data/util/sqlcontainer/query/TableQueryTest.java b/server/tests/src/com/vaadin/data/util/sqlcontainer/query/TableQueryTest.java index e135894013..2b0e484b06 100644 --- a/server/tests/src/com/vaadin/data/util/sqlcontainer/query/TableQueryTest.java +++ b/server/tests/src/com/vaadin/data/util/sqlcontainer/query/TableQueryTest.java @@ -17,8 +17,8 @@ import org.junit.Test; import com.vaadin.data.Container.Filter; import com.vaadin.data.util.filter.Compare.Equal; import com.vaadin.data.util.filter.Like; -import com.vaadin.data.util.sqlcontainer.AllTests; -import com.vaadin.data.util.sqlcontainer.AllTests.DB; +import com.vaadin.data.util.sqlcontainer.SQLTestsConstants; +import com.vaadin.data.util.sqlcontainer.SQLTestsConstants.DB; import com.vaadin.data.util.sqlcontainer.DataGenerator; import com.vaadin.data.util.sqlcontainer.OptimisticLockException; import com.vaadin.data.util.sqlcontainer.RowItem; @@ -28,15 +28,16 @@ import com.vaadin.data.util.sqlcontainer.connection.SimpleJDBCConnectionPool; import com.vaadin.data.util.sqlcontainer.query.generator.DefaultSQLGenerator; public class TableQueryTest { - private static final int offset = AllTests.offset; + private static final int offset = SQLTestsConstants.offset; private JDBCConnectionPool connectionPool; @Before public void setUp() throws SQLException { try { - connectionPool = new SimpleJDBCConnectionPool(AllTests.dbDriver, - AllTests.dbURL, AllTests.dbUser, AllTests.dbPwd, 2, 2); + connectionPool = new SimpleJDBCConnectionPool( + SQLTestsConstants.dbDriver, SQLTestsConstants.dbURL, + SQLTestsConstants.dbUser, SQLTestsConstants.dbPwd, 2, 2); } catch (SQLException e) { e.printStackTrace(); Assert.fail(e.getMessage()); @@ -69,7 +70,7 @@ public class TableQueryTest { @Test public void construction_legalParameters_defaultGenerator_shouldSucceed() { TableQuery tQuery = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); Assert.assertArrayEquals(new Object[] { "ID" }, tQuery .getPrimaryKeyColumns().toArray()); boolean correctTableName = "people".equalsIgnoreCase(tQuery @@ -103,7 +104,7 @@ public class TableQueryTest { @Test public void getCount_simpleQuery_returnsFour() throws SQLException { TableQuery tQuery = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); Assert.assertEquals(4, tQuery.getCount()); } @@ -113,7 +114,7 @@ public class TableQueryTest { // Add some people Connection conn = connectionPool.reserveConnection(); Statement statement = conn.createStatement(); - if (AllTests.db == DB.MSSQL) { + if (SQLTestsConstants.db == DB.MSSQL) { statement.executeUpdate("insert into people values('Bengt', 30)"); statement.executeUpdate("insert into people values('Ingvar', 50)"); } else { @@ -127,7 +128,7 @@ public class TableQueryTest { connectionPool.releaseConnection(conn); TableQuery tQuery = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); Assert.assertEquals(6, tQuery.getCount()); } @@ -135,7 +136,7 @@ public class TableQueryTest { @Test public void getCount_normalState_releasesConnection() throws SQLException { TableQuery tQuery = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); tQuery.getCount(); tQuery.getCount(); Assert.assertNotNull(connectionPool.reserveConnection()); @@ -147,7 +148,7 @@ public class TableQueryTest { @Test public void getResults_simpleQuery_returnsFourRecords() throws SQLException { TableQuery tQuery = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); tQuery.beginTransaction(); ResultSet rs = tQuery.getResults(0, 0); @@ -177,7 +178,7 @@ public class TableQueryTest { DataGenerator.addFiveThousandPeople(connectionPool); TableQuery tQuery = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); tQuery.beginTransaction(); ResultSet rs = tQuery.getResults(0, 0); @@ -194,7 +195,7 @@ public class TableQueryTest { @Test public void beginTransaction_readOnly_shouldSucceed() throws SQLException { TableQuery tQuery = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); tQuery.beginTransaction(); } @@ -202,7 +203,7 @@ public class TableQueryTest { public void beginTransaction_transactionAlreadyActive_shouldFail() throws SQLException { TableQuery tQuery = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); tQuery.beginTransaction(); tQuery.beginTransaction(); @@ -211,7 +212,7 @@ public class TableQueryTest { @Test public void commit_readOnly_shouldSucceed() throws SQLException { TableQuery tQuery = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); tQuery.beginTransaction(); tQuery.commit(); } @@ -219,7 +220,7 @@ public class TableQueryTest { @Test public void rollback_readOnly_shouldSucceed() throws SQLException { TableQuery tQuery = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); tQuery.beginTransaction(); tQuery.rollback(); } @@ -227,14 +228,14 @@ public class TableQueryTest { @Test(expected = SQLException.class) public void commit_noActiveTransaction_shouldFail() throws SQLException { TableQuery tQuery = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); tQuery.commit(); } @Test(expected = SQLException.class) public void rollback_noActiveTransaction_shouldFail() throws SQLException { TableQuery tQuery = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); tQuery.rollback(); } @@ -245,7 +246,7 @@ public class TableQueryTest { public void containsRowWithKeys_existingKeys_returnsTrue() throws SQLException { TableQuery tQuery = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); Assert.assertTrue(tQuery.containsRowWithKey(1)); } @@ -253,7 +254,7 @@ public class TableQueryTest { public void containsRowWithKeys_nonexistingKeys_returnsTrue() throws SQLException { TableQuery tQuery = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); Assert.assertFalse(tQuery.containsRowWithKey(1337)); } @@ -262,7 +263,7 @@ public class TableQueryTest { public void containsRowWithKeys_invalidKeys_shouldFail() throws SQLException { TableQuery tQuery = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); boolean b = true; try { b = tQuery.containsRowWithKey("foo"); @@ -276,7 +277,7 @@ public class TableQueryTest { public void containsRowWithKeys_nullKeys_shouldFailAndReleaseConnections() throws SQLException { TableQuery tQuery = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); try { tQuery.containsRowWithKey(new Object[] { null }); org.junit.Assert @@ -294,7 +295,7 @@ public class TableQueryTest { @Test public void setFilters_shouldReturnCorrectCount() throws SQLException { TableQuery tQuery = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); List<Filter> filters = new ArrayList<Filter>(); filters.add(new Like("NAME", "%lle")); tQuery.setFilters(filters); @@ -305,7 +306,7 @@ public class TableQueryTest { public void setOrderByNameAscending_shouldReturnCorrectOrder() throws SQLException { TableQuery tQuery = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); List<OrderBy> orderBys = Arrays.asList(new OrderBy("NAME", true)); tQuery.setOrderBy(orderBys); @@ -338,7 +339,7 @@ public class TableQueryTest { public void setOrderByNameDescending_shouldReturnCorrectOrder() throws SQLException { TableQuery tQuery = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); List<OrderBy> orderBys = Arrays.asList(new OrderBy("NAME", false)); tQuery.setOrderBy(orderBys); @@ -370,14 +371,14 @@ public class TableQueryTest { @Test public void setFilters_nullParameter_shouldSucceed() { TableQuery tQuery = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); tQuery.setFilters(null); } @Test public void setOrderBy_nullParameter_shouldSucceed() { TableQuery tQuery = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); tQuery.setOrderBy(null); } @@ -388,7 +389,7 @@ public class TableQueryTest { public void removeRowThroughContainer_legalRowItem_shouldSucceed() throws SQLException { TableQuery tQuery = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); SQLContainer container = new SQLContainer(tQuery); container.setAutoCommit(false); Assert.assertTrue(container.removeItem(container.getItemIds() @@ -406,7 +407,7 @@ public class TableQueryTest { public void removeRowThroughContainer_nonexistingRowId_shouldFail() throws SQLException { TableQuery tQuery = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); SQLContainer container = new SQLContainer(tQuery); container.setAutoCommit(true); @@ -419,7 +420,7 @@ public class TableQueryTest { @Test public void insertRowThroughContainer_shouldSucceed() throws SQLException { TableQuery tQuery = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); tQuery.setVersionColumn("ID"); SQLContainer container = new SQLContainer(tQuery); @@ -439,7 +440,7 @@ public class TableQueryTest { @Test public void modifyRowThroughContainer_shouldSucceed() throws SQLException { TableQuery tQuery = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); // In this test the primary key is used as a version column tQuery.setVersionColumn("ID"); @@ -476,7 +477,7 @@ public class TableQueryTest { public void storeRow_noVersionColumn_shouldSucceed() throws UnsupportedOperationException, SQLException { TableQuery tQuery = new TableQuery("people", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); SQLContainer container = new SQLContainer(tQuery); Object id = container.addItem(); RowItem row = (RowItem) container.getItem(id); @@ -503,7 +504,7 @@ public class TableQueryTest { DataGenerator.addVersionedData(connectionPool); TableQuery tQuery = new TableQuery("versioned", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); tQuery.setVersionColumn("VERSION"); SQLContainer container = new SQLContainer(tQuery); RowItem row = (RowItem) container.getItem(container.firstItemId()); @@ -527,7 +528,7 @@ public class TableQueryTest { @Test(expected = OptimisticLockException.class) public void storeRow_versionSetAndLessThanDBValue_shouldThrowException() throws SQLException { - if (AllTests.db == DB.HSQLDB) { + if (SQLTestsConstants.db == DB.HSQLDB) { throw new OptimisticLockException( "HSQLDB doesn't support row versioning for optimistic locking - don't run this test.", null); @@ -535,7 +536,7 @@ public class TableQueryTest { DataGenerator.addVersionedData(connectionPool); TableQuery tQuery = new TableQuery("versioned", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); tQuery.setVersionColumn("VERSION"); SQLContainer container = new SQLContainer(tQuery); RowItem row = (RowItem) container.getItem(container.firstItemId()); @@ -563,7 +564,7 @@ public class TableQueryTest { DataGenerator.addVersionedData(connectionPool); TableQuery tQuery = new TableQuery("versioned", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); tQuery.setVersionColumn("VERSION"); SQLContainer container = new SQLContainer(tQuery); RowItem row = (RowItem) container.getItem(container.firstItemId()); @@ -587,7 +588,7 @@ public class TableQueryTest { @Test(expected = OptimisticLockException.class) public void removeRow_versionSetAndLessThanDBValue_shouldThrowException() throws SQLException { - if (AllTests.db == AllTests.DB.HSQLDB) { + if (SQLTestsConstants.db == SQLTestsConstants.DB.HSQLDB) { // HSQLDB doesn't support versioning, so this is to make the test // green. throw new OptimisticLockException(null); @@ -595,7 +596,7 @@ public class TableQueryTest { DataGenerator.addVersionedData(connectionPool); TableQuery tQuery = new TableQuery("versioned", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); tQuery.setVersionColumn("VERSION"); SQLContainer container = new SQLContainer(tQuery); RowItem row = (RowItem) container.getItem(container.firstItemId()); @@ -619,7 +620,7 @@ public class TableQueryTest { @Test public void removeRow_throwsOptimisticLockException_shouldStillWork() throws SQLException { - if (AllTests.db == AllTests.DB.HSQLDB) { + if (SQLTestsConstants.db == SQLTestsConstants.DB.HSQLDB) { // HSQLDB doesn't support versioning, so this is to make the test // green. return; @@ -627,7 +628,7 @@ public class TableQueryTest { DataGenerator.addVersionedData(connectionPool); TableQuery tQuery = new TableQuery("versioned", connectionPool, - AllTests.sqlGen); + SQLTestsConstants.sqlGen); tQuery.setVersionColumn("VERSION"); SQLContainer container = new SQLContainer(tQuery); RowItem row = (RowItem) container.getItem(container.firstItemId()); |