repo_name
stringlengths
7
104
file_path
stringlengths
13
198
context
stringlengths
67
7.15k
import_statement
stringlengths
16
4.43k
code
stringlengths
40
6.98k
prompt
stringlengths
227
8.27k
next_line
stringlengths
8
795
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/CleanInsertTearDownOnMethod.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/CleanInsertTearDownOnMethod.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
AfterTearDownDbUnitTestExecutionListener.class })
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/CleanInsertTearDownOnMethod.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @Transactional public class CleanInsertTearDownOnMethod { @Autowired
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/CleanInsertTearDownOnMethod.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @Transactional public class CleanInsertTearDownOnMethod { @Autowired
private EntityAssert entityAssert;
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/CleanInsertTearDownOnMethod.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @Transactional public class CleanInsertTearDownOnMethod { @Autowired private EntityAssert entityAssert; @Test
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/CleanInsertTearDownOnMethod.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @Transactional public class CleanInsertTearDownOnMethod { @Autowired private EntityAssert entityAssert; @Test
@DatabaseTearDown(type = DatabaseOperation.CLEAN_INSERT, value = "/META-INF/db/insert.xml")
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/DeleteSetupOnMethodTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/DeleteSetupOnMethodTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
TransactionDbUnitTestExecutionListener.class })
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/DeleteSetupOnMethodTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @Transactional public class DeleteSetupOnMethodTest { @Autowired
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/DeleteSetupOnMethodTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @Transactional public class DeleteSetupOnMethodTest { @Autowired
private EntityAssert entityAssert;
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/DeleteSetupOnMethodTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @Transactional public class DeleteSetupOnMethodTest { @Autowired private EntityAssert entityAssert; @Test
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/DeleteSetupOnMethodTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @Transactional public class DeleteSetupOnMethodTest { @Autowired private EntityAssert entityAssert; @Test
@DatabaseSetup(type = DatabaseOperation.DELETE, value = "/META-INF/db/delete.xml")
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/UpdateTearDownOnMethod.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/UpdateTearDownOnMethod.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
AfterTearDownDbUnitTestExecutionListener.class })
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/UpdateTearDownOnMethod.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @Transactional public class UpdateTearDownOnMethod { @Autowired
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/UpdateTearDownOnMethod.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @Transactional public class UpdateTearDownOnMethod { @Autowired
private EntityAssert entityAssert;
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/UpdateTearDownOnMethod.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @Transactional public class UpdateTearDownOnMethod { @Autowired private EntityAssert entityAssert; @Test
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/UpdateTearDownOnMethod.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @Transactional public class UpdateTearDownOnMethod { @Autowired private EntityAssert entityAssert; @Test
@DatabaseTearDown(type = DatabaseOperation.UPDATE, value = "/META-INF/db/update.xml")
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/UpdateTearDownOnClass.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/UpdateTearDownOnClass.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
AfterTearDownDbUnitTestExecutionListener.class })
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/UpdateTearDownOnClass.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class })
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/UpdateTearDownOnClass.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class })
@DatabaseTearDown(type = DatabaseOperation.UPDATE, value = "/META-INF/db/update.xml")
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/UpdateTearDownOnClass.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @DatabaseTearDown(type = DatabaseOperation.UPDATE, value = "/META-INF/db/update.xml") @Transactional public class UpdateTearDownOnClass { @Autowired
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/UpdateTearDownOnClass.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @DatabaseTearDown(type = DatabaseOperation.UPDATE, value = "/META-INF/db/update.xml") @Transactional public class UpdateTearDownOnClass { @Autowired
private EntityAssert entityAssert;
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/TruncateSetupOnMethodTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/TruncateSetupOnMethodTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
TransactionDbUnitTestExecutionListener.class })
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/TruncateSetupOnMethodTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @Transactional public class TruncateSetupOnMethodTest { @Autowired
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/TruncateSetupOnMethodTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @Transactional public class TruncateSetupOnMethodTest { @Autowired
private EntityAssert entityAssert;
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/TruncateSetupOnMethodTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @Transactional public class TruncateSetupOnMethodTest { @Autowired private EntityAssert entityAssert; @Test
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/TruncateSetupOnMethodTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @Transactional public class TruncateSetupOnMethodTest { @Autowired private EntityAssert entityAssert; @Test
@DatabaseSetup(type = DatabaseOperation.TRUNCATE_TABLE, value = "/META-INF/db/delete.xml")
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/InsertTearDownOnClass.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/InsertTearDownOnClass.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
AfterTearDownDbUnitTestExecutionListener.class })
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/InsertTearDownOnClass.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class })
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/InsertTearDownOnClass.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class })
@DatabaseTearDown(type = DatabaseOperation.INSERT, value = "/META-INF/db/insert.xml")
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/InsertTearDownOnClass.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @DatabaseTearDown(type = DatabaseOperation.INSERT, value = "/META-INF/db/insert.xml") @Transactional public class InsertTearDownOnClass { @Autowired
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/InsertTearDownOnClass.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @DatabaseTearDown(type = DatabaseOperation.INSERT, value = "/META-INF/db/insert.xml") @Transactional public class InsertTearDownOnClass { @Autowired
private EntityAssert entityAssert;
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/dataset/ReplacementDataSetLoaderTest.java
// Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/ExtendedTestContextManager.java // public class ExtendedTestContextManager extends TestContextManager { // // private Object testInstance; // // public ExtendedTestContextManager(Class<?> testClass) throws Exception { // super(testClass); // getTestContext().markApplicationContextDirty(HierarchyMode.CURRENT_LEVEL); // Constructor<?> constructor = testClass.getDeclaredConstructor(); // constructor.setAccessible(true); // this.testInstance = constructor.newInstance(); // } // // public void prepareTestInstance() throws Exception { // prepareTestInstance(this.testInstance); // } // // public Object getTestContextAttribute(String name) { // return getTestContext().getAttribute(name); // } // // public TestContext accessTestContext() { // return getTestContext(); // } // // }
import static org.junit.Assert.*; import org.dbunit.dataset.IDataSet; import org.dbunit.dataset.ITable; import org.junit.Before; import org.junit.Test; import org.springframework.test.context.TestContext; import com.github.springtestdbunit.testutils.ExtendedTestContextManager;
package com.github.springtestdbunit.dataset; /** * Tests for {@link ReplacementDataSetLoader}. * * @author Stijn Van Bael */ public class ReplacementDataSetLoaderTest { private TestContext testContext; private ReplacementDataSetLoader loader; @Before public void setup() throws Exception { this.loader = new ReplacementDataSetLoader();
// Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/ExtendedTestContextManager.java // public class ExtendedTestContextManager extends TestContextManager { // // private Object testInstance; // // public ExtendedTestContextManager(Class<?> testClass) throws Exception { // super(testClass); // getTestContext().markApplicationContextDirty(HierarchyMode.CURRENT_LEVEL); // Constructor<?> constructor = testClass.getDeclaredConstructor(); // constructor.setAccessible(true); // this.testInstance = constructor.newInstance(); // } // // public void prepareTestInstance() throws Exception { // prepareTestInstance(this.testInstance); // } // // public Object getTestContextAttribute(String name) { // return getTestContext().getAttribute(name); // } // // public TestContext accessTestContext() { // return getTestContext(); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/dataset/ReplacementDataSetLoaderTest.java import static org.junit.Assert.*; import org.dbunit.dataset.IDataSet; import org.dbunit.dataset.ITable; import org.junit.Before; import org.junit.Test; import org.springframework.test.context.TestContext; import com.github.springtestdbunit.testutils.ExtendedTestContextManager; package com.github.springtestdbunit.dataset; /** * Tests for {@link ReplacementDataSetLoader}. * * @author Stijn Van Bael */ public class ReplacementDataSetLoaderTest { private TestContext testContext; private ReplacementDataSetLoader loader; @Before public void setup() throws Exception { this.loader = new ReplacementDataSetLoader();
ExtendedTestContextManager manager = new ExtendedTestContextManager(getClass());
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/TruncateTearDownOnClass.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/TruncateTearDownOnClass.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
AfterTearDownDbUnitTestExecutionListener.class })
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/TruncateTearDownOnClass.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class })
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/TruncateTearDownOnClass.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class })
@DatabaseTearDown(type = DatabaseOperation.TRUNCATE_TABLE, value = "/META-INF/db/delete.xml")
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/TruncateTearDownOnClass.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @DatabaseTearDown(type = DatabaseOperation.TRUNCATE_TABLE, value = "/META-INF/db/delete.xml") @Transactional public class TruncateTearDownOnClass { @Autowired
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/TruncateTearDownOnClass.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @DatabaseTearDown(type = DatabaseOperation.TRUNCATE_TABLE, value = "/META-INF/db/delete.xml") @Transactional public class TruncateTearDownOnClass { @Autowired
private EntityAssert entityAssert;
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/DeleteAllTearDownOnMethod.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/DeleteAllTearDownOnMethod.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
AfterTearDownDbUnitTestExecutionListener.class })
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/DeleteAllTearDownOnMethod.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @Transactional public class DeleteAllTearDownOnMethod { @Autowired
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/DeleteAllTearDownOnMethod.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @Transactional public class DeleteAllTearDownOnMethod { @Autowired
private EntityAssert entityAssert;
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/DeleteAllTearDownOnMethod.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @Transactional public class DeleteAllTearDownOnMethod { @Autowired private EntityAssert entityAssert; @Test
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/DeleteAllTearDownOnMethod.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @Transactional public class DeleteAllTearDownOnMethod { @Autowired private EntityAssert entityAssert; @Test
@DatabaseTearDown(type = DatabaseOperation.DELETE, value = "/META-INF/db/delete.xml")
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/expected/DoesNotSwallowExpectedFailureTest.java
// Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/MustNoSwallowTestExecutionListener.java // public class MustNoSwallowTestExecutionListener extends TransactionDbUnitTestExecutionListener { // // @Override // public void afterTestMethod(TestContext testContext) throws Exception { // Assert.assertTrue(testContext.getTestException() instanceof NotSwallowedException); // try { // super.afterTestMethod(testContext); // } catch (Throwable ex) { // Assert.fail("Throw exception"); // } // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/MustNotSwallowSpringJUnit4ClassRunner.java // public class MustNotSwallowSpringJUnit4ClassRunner extends SpringJUnit4ClassRunner { // // public MustNotSwallowSpringJUnit4ClassRunner(Class<?> clazz) throws InitializationError { // super(clazz); // } // // @Override // public void run(RunNotifier notifier) { // AdvisedSupport config = new AdvisedSupport(); // config.setTarget(notifier); // config.addAdvice(new org.aopalliance.intercept.MethodInterceptor() { // public Object invoke(MethodInvocation invocation) throws Throwable { // if ("fireTestFailure".equals(invocation.getMethod().getName())) { // Failure failure = (Failure) invocation.getArguments()[0]; // if (failure.getException() instanceof NotSwallowedException) { // // We expect this // return null; // } // } // return invocation.proceed(); // } // }); // DefaultAopProxyFactory aopProxyFactory = new DefaultAopProxyFactory(); // RunNotifier runNotifierProxy = (RunNotifier) aopProxyFactory.createAopProxy(config).getProxy(); // super.run(runNotifierProxy); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/NotSwallowedException.java // public class NotSwallowedException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.ExpectedDatabase; import com.github.springtestdbunit.testutils.MustNoSwallowTestExecutionListener; import com.github.springtestdbunit.testutils.MustNotSwallowSpringJUnit4ClassRunner; import com.github.springtestdbunit.testutils.NotSwallowedException;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.expected; @RunWith(MustNotSwallowSpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml")
// Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/MustNoSwallowTestExecutionListener.java // public class MustNoSwallowTestExecutionListener extends TransactionDbUnitTestExecutionListener { // // @Override // public void afterTestMethod(TestContext testContext) throws Exception { // Assert.assertTrue(testContext.getTestException() instanceof NotSwallowedException); // try { // super.afterTestMethod(testContext); // } catch (Throwable ex) { // Assert.fail("Throw exception"); // } // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/MustNotSwallowSpringJUnit4ClassRunner.java // public class MustNotSwallowSpringJUnit4ClassRunner extends SpringJUnit4ClassRunner { // // public MustNotSwallowSpringJUnit4ClassRunner(Class<?> clazz) throws InitializationError { // super(clazz); // } // // @Override // public void run(RunNotifier notifier) { // AdvisedSupport config = new AdvisedSupport(); // config.setTarget(notifier); // config.addAdvice(new org.aopalliance.intercept.MethodInterceptor() { // public Object invoke(MethodInvocation invocation) throws Throwable { // if ("fireTestFailure".equals(invocation.getMethod().getName())) { // Failure failure = (Failure) invocation.getArguments()[0]; // if (failure.getException() instanceof NotSwallowedException) { // // We expect this // return null; // } // } // return invocation.proceed(); // } // }); // DefaultAopProxyFactory aopProxyFactory = new DefaultAopProxyFactory(); // RunNotifier runNotifierProxy = (RunNotifier) aopProxyFactory.createAopProxy(config).getProxy(); // super.run(runNotifierProxy); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/NotSwallowedException.java // public class NotSwallowedException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/expected/DoesNotSwallowExpectedFailureTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.ExpectedDatabase; import com.github.springtestdbunit.testutils.MustNoSwallowTestExecutionListener; import com.github.springtestdbunit.testutils.MustNotSwallowSpringJUnit4ClassRunner; import com.github.springtestdbunit.testutils.NotSwallowedException; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.expected; @RunWith(MustNotSwallowSpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml")
@TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, MustNoSwallowTestExecutionListener.class })
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/expected/DoesNotSwallowExpectedFailureTest.java
// Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/MustNoSwallowTestExecutionListener.java // public class MustNoSwallowTestExecutionListener extends TransactionDbUnitTestExecutionListener { // // @Override // public void afterTestMethod(TestContext testContext) throws Exception { // Assert.assertTrue(testContext.getTestException() instanceof NotSwallowedException); // try { // super.afterTestMethod(testContext); // } catch (Throwable ex) { // Assert.fail("Throw exception"); // } // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/MustNotSwallowSpringJUnit4ClassRunner.java // public class MustNotSwallowSpringJUnit4ClassRunner extends SpringJUnit4ClassRunner { // // public MustNotSwallowSpringJUnit4ClassRunner(Class<?> clazz) throws InitializationError { // super(clazz); // } // // @Override // public void run(RunNotifier notifier) { // AdvisedSupport config = new AdvisedSupport(); // config.setTarget(notifier); // config.addAdvice(new org.aopalliance.intercept.MethodInterceptor() { // public Object invoke(MethodInvocation invocation) throws Throwable { // if ("fireTestFailure".equals(invocation.getMethod().getName())) { // Failure failure = (Failure) invocation.getArguments()[0]; // if (failure.getException() instanceof NotSwallowedException) { // // We expect this // return null; // } // } // return invocation.proceed(); // } // }); // DefaultAopProxyFactory aopProxyFactory = new DefaultAopProxyFactory(); // RunNotifier runNotifierProxy = (RunNotifier) aopProxyFactory.createAopProxy(config).getProxy(); // super.run(runNotifierProxy); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/NotSwallowedException.java // public class NotSwallowedException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.ExpectedDatabase; import com.github.springtestdbunit.testutils.MustNoSwallowTestExecutionListener; import com.github.springtestdbunit.testutils.MustNotSwallowSpringJUnit4ClassRunner; import com.github.springtestdbunit.testutils.NotSwallowedException;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.expected; @RunWith(MustNotSwallowSpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, MustNoSwallowTestExecutionListener.class }) @Transactional public class DoesNotSwallowExpectedFailureTest { @Test @ExpectedDatabase("/META-INF/db/expectedfail.xml") public void test() throws Exception {
// Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/MustNoSwallowTestExecutionListener.java // public class MustNoSwallowTestExecutionListener extends TransactionDbUnitTestExecutionListener { // // @Override // public void afterTestMethod(TestContext testContext) throws Exception { // Assert.assertTrue(testContext.getTestException() instanceof NotSwallowedException); // try { // super.afterTestMethod(testContext); // } catch (Throwable ex) { // Assert.fail("Throw exception"); // } // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/MustNotSwallowSpringJUnit4ClassRunner.java // public class MustNotSwallowSpringJUnit4ClassRunner extends SpringJUnit4ClassRunner { // // public MustNotSwallowSpringJUnit4ClassRunner(Class<?> clazz) throws InitializationError { // super(clazz); // } // // @Override // public void run(RunNotifier notifier) { // AdvisedSupport config = new AdvisedSupport(); // config.setTarget(notifier); // config.addAdvice(new org.aopalliance.intercept.MethodInterceptor() { // public Object invoke(MethodInvocation invocation) throws Throwable { // if ("fireTestFailure".equals(invocation.getMethod().getName())) { // Failure failure = (Failure) invocation.getArguments()[0]; // if (failure.getException() instanceof NotSwallowedException) { // // We expect this // return null; // } // } // return invocation.proceed(); // } // }); // DefaultAopProxyFactory aopProxyFactory = new DefaultAopProxyFactory(); // RunNotifier runNotifierProxy = (RunNotifier) aopProxyFactory.createAopProxy(config).getProxy(); // super.run(runNotifierProxy); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/NotSwallowedException.java // public class NotSwallowedException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/expected/DoesNotSwallowExpectedFailureTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.ExpectedDatabase; import com.github.springtestdbunit.testutils.MustNoSwallowTestExecutionListener; import com.github.springtestdbunit.testutils.MustNotSwallowSpringJUnit4ClassRunner; import com.github.springtestdbunit.testutils.NotSwallowedException; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.expected; @RunWith(MustNotSwallowSpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, MustNoSwallowTestExecutionListener.class }) @Transactional public class DoesNotSwallowExpectedFailureTest { @Test @ExpectedDatabase("/META-INF/db/expectedfail.xml") public void test() throws Exception {
throw new NotSwallowedException();
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/DeleteAllTearDownOnClass.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/DeleteAllTearDownOnClass.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
AfterTearDownDbUnitTestExecutionListener.class })
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/DeleteAllTearDownOnClass.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class })
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/DeleteAllTearDownOnClass.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class })
@DatabaseTearDown(type = DatabaseOperation.DELETE, value = "/META-INF/db/delete.xml")
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/DeleteAllTearDownOnClass.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @DatabaseTearDown(type = DatabaseOperation.DELETE, value = "/META-INF/db/delete.xml") @Transactional public class DeleteAllTearDownOnClass { @Autowired
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/DeleteAllTearDownOnClass.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @DatabaseTearDown(type = DatabaseOperation.DELETE, value = "/META-INF/db/delete.xml") @Transactional public class DeleteAllTearDownOnClass { @Autowired
private EntityAssert entityAssert;
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/TruncateSetupOnClassTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/TruncateSetupOnClassTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
TransactionDbUnitTestExecutionListener.class })
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/TruncateSetupOnClassTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @Transactional
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/TruncateSetupOnClassTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @Transactional
@DatabaseSetup(type = DatabaseOperation.TRUNCATE_TABLE, value = "/META-INF/db/delete.xml")
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/TruncateSetupOnClassTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @Transactional @DatabaseSetup(type = DatabaseOperation.TRUNCATE_TABLE, value = "/META-INF/db/delete.xml") public class TruncateSetupOnClassTest { @Autowired
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/TruncateSetupOnClassTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @Transactional @DatabaseSetup(type = DatabaseOperation.TRUNCATE_TABLE, value = "/META-INF/db/delete.xml") public class TruncateSetupOnClassTest { @Autowired
private EntityAssert entityAssert;
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/UpdateSetupOnClassTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/UpdateSetupOnClassTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
TransactionDbUnitTestExecutionListener.class })
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/UpdateSetupOnClassTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class })
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/UpdateSetupOnClassTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class })
@DatabaseSetup(type = DatabaseOperation.UPDATE, value = "/META-INF/db/update.xml")
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/UpdateSetupOnClassTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @DatabaseSetup(type = DatabaseOperation.UPDATE, value = "/META-INF/db/update.xml") @Transactional public class UpdateSetupOnClassTest { @Autowired
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/UpdateSetupOnClassTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @DatabaseSetup(type = DatabaseOperation.UPDATE, value = "/META-INF/db/update.xml") @Transactional public class UpdateSetupOnClassTest { @Autowired
private EntityAssert entityAssert;
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/expected/ExpectedOnClassAndMethodWithoutOverrideTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/assertion/DatabaseAssertionMode.java // public enum DatabaseAssertionMode { // // /** // * Will use default DbUnit data sets assertions. // */ // DEFAULT(new DefaultDatabaseAssertion()), // // /** // * Allows specifying only specific columns and tables in expected data set. Unspecified tables and columns are // * ignored. // * <p> // * <strong>Notes:</strong> // * <ul> // * <li>Expected row order must match order in actual data set.</li> // * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row // * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all // * rows.</li> // * </ul> // */ // NON_STRICT(new NonStrictDatabaseAssertion()), // // /** // * Allows specifying only specific columns and tables in expected data set and ignoring row orders in expected and // * actual data set. Unspecified tables and columns are ignored. Row orders in expected and actual data sets are // * ignored. // * <p> // * <strong>Notes:</strong> // * <ul> // * <li>Expected row order does not need to match order in actual data set.</li> // * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row // * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all // * rows.</li> // * </ul> // */ // NON_STRICT_UNORDERED(new NonStrictUnorderedDatabaseAssertion()); // // private DatabaseAssertion databaseAssertion; // // private DatabaseAssertionMode(DatabaseAssertion databaseAssertion) { // this.databaseAssertion = databaseAssertion; // } // // public DatabaseAssertion getDatabaseAssertion() { // return this.databaseAssertion; // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/MustFailDbUnitTestExecutionListener.java // public class MustFailDbUnitTestExecutionListener extends TransactionDbUnitTestExecutionListener { // // @Override // public void afterTestMethod(TestContext testContext) throws Exception { // Throwable caught = null; // try { // super.afterTestMethod(testContext); // } catch (Throwable ex) { // caught = ex; // } // Assert.assertNotNull("Test did not fail", caught); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.ExpectedDatabase; import com.github.springtestdbunit.assertion.DatabaseAssertionMode; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.MustFailDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.expected; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml")
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/assertion/DatabaseAssertionMode.java // public enum DatabaseAssertionMode { // // /** // * Will use default DbUnit data sets assertions. // */ // DEFAULT(new DefaultDatabaseAssertion()), // // /** // * Allows specifying only specific columns and tables in expected data set. Unspecified tables and columns are // * ignored. // * <p> // * <strong>Notes:</strong> // * <ul> // * <li>Expected row order must match order in actual data set.</li> // * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row // * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all // * rows.</li> // * </ul> // */ // NON_STRICT(new NonStrictDatabaseAssertion()), // // /** // * Allows specifying only specific columns and tables in expected data set and ignoring row orders in expected and // * actual data set. Unspecified tables and columns are ignored. Row orders in expected and actual data sets are // * ignored. // * <p> // * <strong>Notes:</strong> // * <ul> // * <li>Expected row order does not need to match order in actual data set.</li> // * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row // * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all // * rows.</li> // * </ul> // */ // NON_STRICT_UNORDERED(new NonStrictUnorderedDatabaseAssertion()); // // private DatabaseAssertion databaseAssertion; // // private DatabaseAssertionMode(DatabaseAssertion databaseAssertion) { // this.databaseAssertion = databaseAssertion; // } // // public DatabaseAssertion getDatabaseAssertion() { // return this.databaseAssertion; // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/MustFailDbUnitTestExecutionListener.java // public class MustFailDbUnitTestExecutionListener extends TransactionDbUnitTestExecutionListener { // // @Override // public void afterTestMethod(TestContext testContext) throws Exception { // Throwable caught = null; // try { // super.afterTestMethod(testContext); // } catch (Throwable ex) { // caught = ex; // } // Assert.assertNotNull("Test did not fail", caught); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/expected/ExpectedOnClassAndMethodWithoutOverrideTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.ExpectedDatabase; import com.github.springtestdbunit.assertion.DatabaseAssertionMode; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.MustFailDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.expected; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml")
@TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, MustFailDbUnitTestExecutionListener.class })
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/expected/ExpectedOnClassAndMethodWithoutOverrideTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/assertion/DatabaseAssertionMode.java // public enum DatabaseAssertionMode { // // /** // * Will use default DbUnit data sets assertions. // */ // DEFAULT(new DefaultDatabaseAssertion()), // // /** // * Allows specifying only specific columns and tables in expected data set. Unspecified tables and columns are // * ignored. // * <p> // * <strong>Notes:</strong> // * <ul> // * <li>Expected row order must match order in actual data set.</li> // * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row // * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all // * rows.</li> // * </ul> // */ // NON_STRICT(new NonStrictDatabaseAssertion()), // // /** // * Allows specifying only specific columns and tables in expected data set and ignoring row orders in expected and // * actual data set. Unspecified tables and columns are ignored. Row orders in expected and actual data sets are // * ignored. // * <p> // * <strong>Notes:</strong> // * <ul> // * <li>Expected row order does not need to match order in actual data set.</li> // * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row // * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all // * rows.</li> // * </ul> // */ // NON_STRICT_UNORDERED(new NonStrictUnorderedDatabaseAssertion()); // // private DatabaseAssertion databaseAssertion; // // private DatabaseAssertionMode(DatabaseAssertion databaseAssertion) { // this.databaseAssertion = databaseAssertion; // } // // public DatabaseAssertion getDatabaseAssertion() { // return this.databaseAssertion; // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/MustFailDbUnitTestExecutionListener.java // public class MustFailDbUnitTestExecutionListener extends TransactionDbUnitTestExecutionListener { // // @Override // public void afterTestMethod(TestContext testContext) throws Exception { // Throwable caught = null; // try { // super.afterTestMethod(testContext); // } catch (Throwable ex) { // caught = ex; // } // Assert.assertNotNull("Test did not fail", caught); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.ExpectedDatabase; import com.github.springtestdbunit.assertion.DatabaseAssertionMode; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.MustFailDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.expected; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, MustFailDbUnitTestExecutionListener.class }) @ExpectedDatabase(value = "/META-INF/db/expectedfail.xml") @Transactional public class ExpectedOnClassAndMethodWithoutOverrideTest { @Autowired
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/assertion/DatabaseAssertionMode.java // public enum DatabaseAssertionMode { // // /** // * Will use default DbUnit data sets assertions. // */ // DEFAULT(new DefaultDatabaseAssertion()), // // /** // * Allows specifying only specific columns and tables in expected data set. Unspecified tables and columns are // * ignored. // * <p> // * <strong>Notes:</strong> // * <ul> // * <li>Expected row order must match order in actual data set.</li> // * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row // * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all // * rows.</li> // * </ul> // */ // NON_STRICT(new NonStrictDatabaseAssertion()), // // /** // * Allows specifying only specific columns and tables in expected data set and ignoring row orders in expected and // * actual data set. Unspecified tables and columns are ignored. Row orders in expected and actual data sets are // * ignored. // * <p> // * <strong>Notes:</strong> // * <ul> // * <li>Expected row order does not need to match order in actual data set.</li> // * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row // * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all // * rows.</li> // * </ul> // */ // NON_STRICT_UNORDERED(new NonStrictUnorderedDatabaseAssertion()); // // private DatabaseAssertion databaseAssertion; // // private DatabaseAssertionMode(DatabaseAssertion databaseAssertion) { // this.databaseAssertion = databaseAssertion; // } // // public DatabaseAssertion getDatabaseAssertion() { // return this.databaseAssertion; // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/MustFailDbUnitTestExecutionListener.java // public class MustFailDbUnitTestExecutionListener extends TransactionDbUnitTestExecutionListener { // // @Override // public void afterTestMethod(TestContext testContext) throws Exception { // Throwable caught = null; // try { // super.afterTestMethod(testContext); // } catch (Throwable ex) { // caught = ex; // } // Assert.assertNotNull("Test did not fail", caught); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/expected/ExpectedOnClassAndMethodWithoutOverrideTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.ExpectedDatabase; import com.github.springtestdbunit.assertion.DatabaseAssertionMode; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.MustFailDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.expected; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, MustFailDbUnitTestExecutionListener.class }) @ExpectedDatabase(value = "/META-INF/db/expectedfail.xml") @Transactional public class ExpectedOnClassAndMethodWithoutOverrideTest { @Autowired
private EntityAssert entityAssert;
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/expected/ExpectedOnClassAndMethodWithoutOverrideTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/assertion/DatabaseAssertionMode.java // public enum DatabaseAssertionMode { // // /** // * Will use default DbUnit data sets assertions. // */ // DEFAULT(new DefaultDatabaseAssertion()), // // /** // * Allows specifying only specific columns and tables in expected data set. Unspecified tables and columns are // * ignored. // * <p> // * <strong>Notes:</strong> // * <ul> // * <li>Expected row order must match order in actual data set.</li> // * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row // * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all // * rows.</li> // * </ul> // */ // NON_STRICT(new NonStrictDatabaseAssertion()), // // /** // * Allows specifying only specific columns and tables in expected data set and ignoring row orders in expected and // * actual data set. Unspecified tables and columns are ignored. Row orders in expected and actual data sets are // * ignored. // * <p> // * <strong>Notes:</strong> // * <ul> // * <li>Expected row order does not need to match order in actual data set.</li> // * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row // * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all // * rows.</li> // * </ul> // */ // NON_STRICT_UNORDERED(new NonStrictUnorderedDatabaseAssertion()); // // private DatabaseAssertion databaseAssertion; // // private DatabaseAssertionMode(DatabaseAssertion databaseAssertion) { // this.databaseAssertion = databaseAssertion; // } // // public DatabaseAssertion getDatabaseAssertion() { // return this.databaseAssertion; // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/MustFailDbUnitTestExecutionListener.java // public class MustFailDbUnitTestExecutionListener extends TransactionDbUnitTestExecutionListener { // // @Override // public void afterTestMethod(TestContext testContext) throws Exception { // Throwable caught = null; // try { // super.afterTestMethod(testContext); // } catch (Throwable ex) { // caught = ex; // } // Assert.assertNotNull("Test did not fail", caught); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.ExpectedDatabase; import com.github.springtestdbunit.assertion.DatabaseAssertionMode; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.MustFailDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.expected; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, MustFailDbUnitTestExecutionListener.class }) @ExpectedDatabase(value = "/META-INF/db/expectedfail.xml") @Transactional public class ExpectedOnClassAndMethodWithoutOverrideTest { @Autowired private EntityAssert entityAssert; @Test
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/assertion/DatabaseAssertionMode.java // public enum DatabaseAssertionMode { // // /** // * Will use default DbUnit data sets assertions. // */ // DEFAULT(new DefaultDatabaseAssertion()), // // /** // * Allows specifying only specific columns and tables in expected data set. Unspecified tables and columns are // * ignored. // * <p> // * <strong>Notes:</strong> // * <ul> // * <li>Expected row order must match order in actual data set.</li> // * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row // * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all // * rows.</li> // * </ul> // */ // NON_STRICT(new NonStrictDatabaseAssertion()), // // /** // * Allows specifying only specific columns and tables in expected data set and ignoring row orders in expected and // * actual data set. Unspecified tables and columns are ignored. Row orders in expected and actual data sets are // * ignored. // * <p> // * <strong>Notes:</strong> // * <ul> // * <li>Expected row order does not need to match order in actual data set.</li> // * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row // * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all // * rows.</li> // * </ul> // */ // NON_STRICT_UNORDERED(new NonStrictUnorderedDatabaseAssertion()); // // private DatabaseAssertion databaseAssertion; // // private DatabaseAssertionMode(DatabaseAssertion databaseAssertion) { // this.databaseAssertion = databaseAssertion; // } // // public DatabaseAssertion getDatabaseAssertion() { // return this.databaseAssertion; // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/MustFailDbUnitTestExecutionListener.java // public class MustFailDbUnitTestExecutionListener extends TransactionDbUnitTestExecutionListener { // // @Override // public void afterTestMethod(TestContext testContext) throws Exception { // Throwable caught = null; // try { // super.afterTestMethod(testContext); // } catch (Throwable ex) { // caught = ex; // } // Assert.assertNotNull("Test did not fail", caught); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/expected/ExpectedOnClassAndMethodWithoutOverrideTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.ExpectedDatabase; import com.github.springtestdbunit.assertion.DatabaseAssertionMode; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.MustFailDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.expected; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, MustFailDbUnitTestExecutionListener.class }) @ExpectedDatabase(value = "/META-INF/db/expectedfail.xml") @Transactional public class ExpectedOnClassAndMethodWithoutOverrideTest { @Autowired private EntityAssert entityAssert; @Test
@ExpectedDatabase(value = "/META-INF/db/expected_nonstrict.xml", assertionMode = DatabaseAssertionMode.NON_STRICT, override = false)
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/MixedTearDownOnClassAndMethodTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/MixedTearDownOnClassAndMethodTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
AfterTearDownDbUnitTestExecutionListener.class })
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/MixedTearDownOnClassAndMethodTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @DatabaseTearDown("/META-INF/db/insert.xml") @Transactional public class MixedTearDownOnClassAndMethodTest { @Autowired
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/MixedTearDownOnClassAndMethodTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @DatabaseTearDown("/META-INF/db/insert.xml") @Transactional public class MixedTearDownOnClassAndMethodTest { @Autowired
private EntityAssert entityAssert;
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/MixedTearDownOnClassAndMethodTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @DatabaseTearDown("/META-INF/db/insert.xml") @Transactional public class MixedTearDownOnClassAndMethodTest { @Autowired private EntityAssert entityAssert; @Test
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/MixedTearDownOnClassAndMethodTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @DatabaseTearDown("/META-INF/db/insert.xml") @Transactional public class MixedTearDownOnClassAndMethodTest { @Autowired private EntityAssert entityAssert; @Test
@DatabaseTearDown(value = "/META-INF/db/insert2.xml", type = DatabaseOperation.INSERT)
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/main/java/com/github/springtestdbunit/DbUnitTestContext.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/dataset/DataSetLoader.java // public interface DataSetLoader { // // /** // * Load and return {@link IDataSet dataset} from the specified. If the dataset cannot be found <tt>null</tt> may be // * returned. // * @param testClass The class under test // * @param location The location to load // * @return a {@link IDataSet dataset} or <tt>null</tt> // * @throws Exception If the {@link IDataSet dataset} cannot be loaded // */ // public IDataSet loadDataSet(Class<?> testClass, String location) throws Exception; // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/operation/DatabaseOperationLookup.java // public interface DatabaseOperationLookup { // // /** // * Returns the DBUnit {@link org.dbunit.operation.DatabaseOperation Database Operation} that should be used for the // * specified enum or {@code null} if the operation is not supported. // * @param operation the enum value // * @return the DBUnit databsae operation or {@code null}. // */ // org.dbunit.operation.DatabaseOperation get(DatabaseOperation operation); // // }
import java.lang.reflect.Method; import org.dbunit.database.IDatabaseConnection; import org.dbunit.dataset.IDataSet; import com.github.springtestdbunit.dataset.DataSetLoader; import com.github.springtestdbunit.operation.DatabaseOperationLookup;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit; /** * Provides context for the {@link DbUnitRunner}. * * @author Phillip Webb */ public interface DbUnitTestContext { /** * Returns the {@link IDatabaseConnection} that should be used when performing database setup and teardown. * @return The connection */ DatabaseConnections getConnections(); /** * Returns the {@link DataSetLoader} that should be used to load {@link IDataSet}s. * @return The dataset loader */
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/dataset/DataSetLoader.java // public interface DataSetLoader { // // /** // * Load and return {@link IDataSet dataset} from the specified. If the dataset cannot be found <tt>null</tt> may be // * returned. // * @param testClass The class under test // * @param location The location to load // * @return a {@link IDataSet dataset} or <tt>null</tt> // * @throws Exception If the {@link IDataSet dataset} cannot be loaded // */ // public IDataSet loadDataSet(Class<?> testClass, String location) throws Exception; // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/operation/DatabaseOperationLookup.java // public interface DatabaseOperationLookup { // // /** // * Returns the DBUnit {@link org.dbunit.operation.DatabaseOperation Database Operation} that should be used for the // * specified enum or {@code null} if the operation is not supported. // * @param operation the enum value // * @return the DBUnit databsae operation or {@code null}. // */ // org.dbunit.operation.DatabaseOperation get(DatabaseOperation operation); // // } // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/DbUnitTestContext.java import java.lang.reflect.Method; import org.dbunit.database.IDatabaseConnection; import org.dbunit.dataset.IDataSet; import com.github.springtestdbunit.dataset.DataSetLoader; import com.github.springtestdbunit.operation.DatabaseOperationLookup; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit; /** * Provides context for the {@link DbUnitRunner}. * * @author Phillip Webb */ public interface DbUnitTestContext { /** * Returns the {@link IDatabaseConnection} that should be used when performing database setup and teardown. * @return The connection */ DatabaseConnections getConnections(); /** * Returns the {@link DataSetLoader} that should be used to load {@link IDataSet}s. * @return The dataset loader */
DataSetLoader getDataSetLoader();
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/main/java/com/github/springtestdbunit/DbUnitTestContext.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/dataset/DataSetLoader.java // public interface DataSetLoader { // // /** // * Load and return {@link IDataSet dataset} from the specified. If the dataset cannot be found <tt>null</tt> may be // * returned. // * @param testClass The class under test // * @param location The location to load // * @return a {@link IDataSet dataset} or <tt>null</tt> // * @throws Exception If the {@link IDataSet dataset} cannot be loaded // */ // public IDataSet loadDataSet(Class<?> testClass, String location) throws Exception; // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/operation/DatabaseOperationLookup.java // public interface DatabaseOperationLookup { // // /** // * Returns the DBUnit {@link org.dbunit.operation.DatabaseOperation Database Operation} that should be used for the // * specified enum or {@code null} if the operation is not supported. // * @param operation the enum value // * @return the DBUnit databsae operation or {@code null}. // */ // org.dbunit.operation.DatabaseOperation get(DatabaseOperation operation); // // }
import java.lang.reflect.Method; import org.dbunit.database.IDatabaseConnection; import org.dbunit.dataset.IDataSet; import com.github.springtestdbunit.dataset.DataSetLoader; import com.github.springtestdbunit.operation.DatabaseOperationLookup;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit; /** * Provides context for the {@link DbUnitRunner}. * * @author Phillip Webb */ public interface DbUnitTestContext { /** * Returns the {@link IDatabaseConnection} that should be used when performing database setup and teardown. * @return The connection */ DatabaseConnections getConnections(); /** * Returns the {@link DataSetLoader} that should be used to load {@link IDataSet}s. * @return The dataset loader */ DataSetLoader getDataSetLoader(); /** * Returns the {@link DatabaseOperationLookup} that should be used to lookup database operations. * @return the database operation lookup */
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/dataset/DataSetLoader.java // public interface DataSetLoader { // // /** // * Load and return {@link IDataSet dataset} from the specified. If the dataset cannot be found <tt>null</tt> may be // * returned. // * @param testClass The class under test // * @param location The location to load // * @return a {@link IDataSet dataset} or <tt>null</tt> // * @throws Exception If the {@link IDataSet dataset} cannot be loaded // */ // public IDataSet loadDataSet(Class<?> testClass, String location) throws Exception; // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/operation/DatabaseOperationLookup.java // public interface DatabaseOperationLookup { // // /** // * Returns the DBUnit {@link org.dbunit.operation.DatabaseOperation Database Operation} that should be used for the // * specified enum or {@code null} if the operation is not supported. // * @param operation the enum value // * @return the DBUnit databsae operation or {@code null}. // */ // org.dbunit.operation.DatabaseOperation get(DatabaseOperation operation); // // } // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/DbUnitTestContext.java import java.lang.reflect.Method; import org.dbunit.database.IDatabaseConnection; import org.dbunit.dataset.IDataSet; import com.github.springtestdbunit.dataset.DataSetLoader; import com.github.springtestdbunit.operation.DatabaseOperationLookup; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit; /** * Provides context for the {@link DbUnitRunner}. * * @author Phillip Webb */ public interface DbUnitTestContext { /** * Returns the {@link IDatabaseConnection} that should be used when performing database setup and teardown. * @return The connection */ DatabaseConnections getConnections(); /** * Returns the {@link DataSetLoader} that should be used to load {@link IDataSet}s. * @return The dataset loader */ DataSetLoader getDataSetLoader(); /** * Returns the {@link DatabaseOperationLookup} that should be used to lookup database operations. * @return the database operation lookup */
DatabaseOperationLookup getDatbaseOperationLookup();
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/multiconnection/MultiConnectionTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import static org.junit.Assert.assertEquals; import java.util.Arrays; import java.util.HashSet; import java.util.List; import javax.sql.DataSource; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.annotation.DbUnitConfiguration; import com.github.springtestdbunit.annotation.ExpectedDatabase; import com.github.springtestdbunit.entity.EntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.multiconnection; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/multiconnection/MultiConnectionTest.java import static org.junit.Assert.assertEquals; import java.util.Arrays; import java.util.HashSet; import java.util.List; import javax.sql.DataSource; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.annotation.DbUnitConfiguration; import com.github.springtestdbunit.annotation.ExpectedDatabase; import com.github.springtestdbunit.entity.EntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.multiconnection; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
TransactionDbUnitTestExecutionListener.class, })
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/multiconnection/MultiConnectionTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import static org.junit.Assert.assertEquals; import java.util.Arrays; import java.util.HashSet; import java.util.List; import javax.sql.DataSource; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.annotation.DbUnitConfiguration; import com.github.springtestdbunit.annotation.ExpectedDatabase; import com.github.springtestdbunit.entity.EntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.multiconnection; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class, }) @DbUnitConfiguration(databaseConnection = { "dataSource", "dataSource2" }) @DatabaseSetup("/META-INF/db/insert.xml") @DatabaseSetup(connection = "dataSource2", value = "/META-INF/db/multi-insert.xml") @Transactional public class MultiConnectionTest { @Autowired
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/multiconnection/MultiConnectionTest.java import static org.junit.Assert.assertEquals; import java.util.Arrays; import java.util.HashSet; import java.util.List; import javax.sql.DataSource; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.annotation.DbUnitConfiguration; import com.github.springtestdbunit.annotation.ExpectedDatabase; import com.github.springtestdbunit.entity.EntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.multiconnection; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class, }) @DbUnitConfiguration(databaseConnection = { "dataSource", "dataSource2" }) @DatabaseSetup("/META-INF/db/insert.xml") @DatabaseSetup(connection = "dataSource2", value = "/META-INF/db/multi-insert.xml") @Transactional public class MultiConnectionTest { @Autowired
private EntityAssert entityAssert;
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/multiconnection/MultiConnectionTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import static org.junit.Assert.assertEquals; import java.util.Arrays; import java.util.HashSet; import java.util.List; import javax.sql.DataSource; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.annotation.DbUnitConfiguration; import com.github.springtestdbunit.annotation.ExpectedDatabase; import com.github.springtestdbunit.entity.EntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.multiconnection; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class, }) @DbUnitConfiguration(databaseConnection = { "dataSource", "dataSource2" }) @DatabaseSetup("/META-INF/db/insert.xml") @DatabaseSetup(connection = "dataSource2", value = "/META-INF/db/multi-insert.xml") @Transactional public class MultiConnectionTest { @Autowired private EntityAssert entityAssert; @Autowired @Qualifier("dataSource2") private DataSource dataSource; @Test
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/multiconnection/MultiConnectionTest.java import static org.junit.Assert.assertEquals; import java.util.Arrays; import java.util.HashSet; import java.util.List; import javax.sql.DataSource; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.annotation.DbUnitConfiguration; import com.github.springtestdbunit.annotation.ExpectedDatabase; import com.github.springtestdbunit.entity.EntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.multiconnection; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class, }) @DbUnitConfiguration(databaseConnection = { "dataSource", "dataSource2" }) @DatabaseSetup("/META-INF/db/insert.xml") @DatabaseSetup(connection = "dataSource2", value = "/META-INF/db/multi-insert.xml") @Transactional public class MultiConnectionTest { @Autowired private EntityAssert entityAssert; @Autowired @Qualifier("dataSource2") private DataSource dataSource; @Test
@DatabaseSetup(value = "/META-INF/db/insert2.xml", type = DatabaseOperation.INSERT)
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/InsertSetupOnClassTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/InsertSetupOnClassTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
TransactionDbUnitTestExecutionListener.class })
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/InsertSetupOnClassTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class })
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/InsertSetupOnClassTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class })
@DatabaseSetup(type = DatabaseOperation.INSERT, value = "/META-INF/db/insert.xml")
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/InsertSetupOnClassTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @DatabaseSetup(type = DatabaseOperation.INSERT, value = "/META-INF/db/insert.xml") @Transactional public class InsertSetupOnClassTest { @Autowired
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/InsertSetupOnClassTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @DatabaseSetup(type = DatabaseOperation.INSERT, value = "/META-INF/db/insert.xml") @Transactional public class InsertSetupOnClassTest { @Autowired
private EntityAssert entityAssert;
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/MixedSetupOnClassAndMethodTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/MixedSetupOnClassAndMethodTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
TransactionDbUnitTestExecutionListener.class })
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/MixedSetupOnClassAndMethodTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @DatabaseSetup("/META-INF/db/insert.xml") @Transactional public class MixedSetupOnClassAndMethodTest { @Autowired
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/MixedSetupOnClassAndMethodTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @DatabaseSetup("/META-INF/db/insert.xml") @Transactional public class MixedSetupOnClassAndMethodTest { @Autowired
private EntityAssert entityAssert;
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/MixedSetupOnClassAndMethodTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @DatabaseSetup("/META-INF/db/insert.xml") @Transactional public class MixedSetupOnClassAndMethodTest { @Autowired private EntityAssert entityAssert; @Test
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/MixedSetupOnClassAndMethodTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @DatabaseSetup("/META-INF/db/insert.xml") @Transactional public class MixedSetupOnClassAndMethodTest { @Autowired private EntityAssert entityAssert; @Test
@DatabaseSetup(value = "/META-INF/db/insert2.xml", type = DatabaseOperation.INSERT)
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/DeleteSetupOnClassTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/DeleteSetupOnClassTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
TransactionDbUnitTestExecutionListener.class })
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/DeleteSetupOnClassTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class })
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/DeleteSetupOnClassTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class })
@DatabaseSetup(type = DatabaseOperation.DELETE, value = "/META-INF/db/delete.xml")
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/DeleteSetupOnClassTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @DatabaseSetup(type = DatabaseOperation.DELETE, value = "/META-INF/db/delete.xml") @Transactional public class DeleteSetupOnClassTest { @Autowired
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/DeleteSetupOnClassTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @DatabaseSetup(type = DatabaseOperation.DELETE, value = "/META-INF/db/delete.xml") @Transactional public class DeleteSetupOnClassTest { @Autowired
private EntityAssert entityAssert;
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/operation/MicrosoftSqlDatabaseOperationLookupTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // }
import static org.junit.Assert.assertSame; import org.dbunit.ext.mssql.InsertIdentityOperation; import org.junit.Test; import com.github.springtestdbunit.annotation.DatabaseOperation;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.operation; /** * Tests for {@link MicrosoftSqlDatabaseOperationLookup}. * * @author Phillip Webb */ public class MicrosoftSqlDatabaseOperationLookupTest { @Test public void shouldLookup() throws Exception { DefaultDatabaseOperationLookup lookup = new MicrosoftSqlDatabaseOperationLookup();
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/operation/MicrosoftSqlDatabaseOperationLookupTest.java import static org.junit.Assert.assertSame; import org.dbunit.ext.mssql.InsertIdentityOperation; import org.junit.Test; import com.github.springtestdbunit.annotation.DatabaseOperation; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.operation; /** * Tests for {@link MicrosoftSqlDatabaseOperationLookup}. * * @author Phillip Webb */ public class MicrosoftSqlDatabaseOperationLookupTest { @Test public void shouldLookup() throws Exception { DefaultDatabaseOperationLookup lookup = new MicrosoftSqlDatabaseOperationLookup();
assertSame(org.dbunit.operation.DatabaseOperation.UPDATE, lookup.get(DatabaseOperation.UPDATE));
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/expected/ExpectedFailureOnMethodWithRepeatableTest.java
// Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/MustFailDbUnitTestExecutionListener.java // public class MustFailDbUnitTestExecutionListener extends TransactionDbUnitTestExecutionListener { // // @Override // public void afterTestMethod(TestContext testContext) throws Exception { // Throwable caught = null; // try { // super.afterTestMethod(testContext); // } catch (Throwable ex) { // caught = ex; // } // Assert.assertNotNull("Test did not fail", caught); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.ExpectedDatabase; import com.github.springtestdbunit.annotation.ExpectedDatabases; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.MustFailDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.expected; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml")
// Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/MustFailDbUnitTestExecutionListener.java // public class MustFailDbUnitTestExecutionListener extends TransactionDbUnitTestExecutionListener { // // @Override // public void afterTestMethod(TestContext testContext) throws Exception { // Throwable caught = null; // try { // super.afterTestMethod(testContext); // } catch (Throwable ex) { // caught = ex; // } // Assert.assertNotNull("Test did not fail", caught); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/expected/ExpectedFailureOnMethodWithRepeatableTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.ExpectedDatabase; import com.github.springtestdbunit.annotation.ExpectedDatabases; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.MustFailDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.expected; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml")
@TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, MustFailDbUnitTestExecutionListener.class })
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/expected/ExpectedFailureOnMethodWithRepeatableTest.java
// Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/MustFailDbUnitTestExecutionListener.java // public class MustFailDbUnitTestExecutionListener extends TransactionDbUnitTestExecutionListener { // // @Override // public void afterTestMethod(TestContext testContext) throws Exception { // Throwable caught = null; // try { // super.afterTestMethod(testContext); // } catch (Throwable ex) { // caught = ex; // } // Assert.assertNotNull("Test did not fail", caught); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.ExpectedDatabase; import com.github.springtestdbunit.annotation.ExpectedDatabases; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.MustFailDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.expected; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, MustFailDbUnitTestExecutionListener.class }) @Transactional public class ExpectedFailureOnMethodWithRepeatableTest { @Autowired
// Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/MustFailDbUnitTestExecutionListener.java // public class MustFailDbUnitTestExecutionListener extends TransactionDbUnitTestExecutionListener { // // @Override // public void afterTestMethod(TestContext testContext) throws Exception { // Throwable caught = null; // try { // super.afterTestMethod(testContext); // } catch (Throwable ex) { // caught = ex; // } // Assert.assertNotNull("Test did not fail", caught); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/expected/ExpectedFailureOnMethodWithRepeatableTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.ExpectedDatabase; import com.github.springtestdbunit.annotation.ExpectedDatabases; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.MustFailDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.expected; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, MustFailDbUnitTestExecutionListener.class }) @Transactional public class ExpectedFailureOnMethodWithRepeatableTest { @Autowired
private EntityAssert entityAssert;
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/RefereshSetupOnMethodTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/RefereshSetupOnMethodTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
TransactionDbUnitTestExecutionListener.class })
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/RefereshSetupOnMethodTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @Transactional public class RefereshSetupOnMethodTest { @Autowired
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/RefereshSetupOnMethodTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @Transactional public class RefereshSetupOnMethodTest { @Autowired
private EntityAssert entityAssert;
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/RefereshSetupOnMethodTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @Transactional public class RefereshSetupOnMethodTest { @Autowired private EntityAssert entityAssert; @Test
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/RefereshSetupOnMethodTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @Transactional public class RefereshSetupOnMethodTest { @Autowired private EntityAssert entityAssert; @Test
@DatabaseSetup(type = DatabaseOperation.REFRESH, value = "/META-INF/db/refresh.xml")
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/TruncateTearDownOnMethod.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/TruncateTearDownOnMethod.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
AfterTearDownDbUnitTestExecutionListener.class })
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/TruncateTearDownOnMethod.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @Transactional public class TruncateTearDownOnMethod { @Autowired
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/TruncateTearDownOnMethod.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @Transactional public class TruncateTearDownOnMethod { @Autowired
private EntityAssert entityAssert;
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/TruncateTearDownOnMethod.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @Transactional public class TruncateTearDownOnMethod { @Autowired private EntityAssert entityAssert; @Test
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/TruncateTearDownOnMethod.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @Transactional public class TruncateTearDownOnMethod { @Autowired private EntityAssert entityAssert; @Test
@DatabaseTearDown(type = DatabaseOperation.TRUNCATE_TABLE, value = "/META-INF/db/delete.xml")
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/DeleteAllSetupOnMethodTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/DeleteAllSetupOnMethodTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
TransactionDbUnitTestExecutionListener.class })
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/DeleteAllSetupOnMethodTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @Transactional public class DeleteAllSetupOnMethodTest { @Autowired
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/DeleteAllSetupOnMethodTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @Transactional public class DeleteAllSetupOnMethodTest { @Autowired
private EntityAssert entityAssert;
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/DeleteAllSetupOnMethodTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @Transactional public class DeleteAllSetupOnMethodTest { @Autowired private EntityAssert entityAssert; @Test
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/DeleteAllSetupOnMethodTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @Transactional public class DeleteAllSetupOnMethodTest { @Autowired private EntityAssert entityAssert; @Test
@DatabaseSetup(type = DatabaseOperation.DELETE_ALL, value = "/META-INF/db/delete.xml")
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/CleanInsertSetupOnMethodTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/OtherEntityAssert.java // public class OtherEntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<OtherSampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(OtherSampleEntity.class); // Root<OtherSampleEntity> from = this.criteriaQuery.from(OtherSampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<OtherSampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<OtherSampleEntity> results = query.getResultList(); // for (OtherSampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.entity.OtherEntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/OtherEntityAssert.java // public class OtherEntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<OtherSampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(OtherSampleEntity.class); // Root<OtherSampleEntity> from = this.criteriaQuery.from(OtherSampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<OtherSampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<OtherSampleEntity> results = query.getResultList(); // for (OtherSampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/CleanInsertSetupOnMethodTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.entity.OtherEntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
TransactionDbUnitTestExecutionListener.class })
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/CleanInsertSetupOnMethodTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/OtherEntityAssert.java // public class OtherEntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<OtherSampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(OtherSampleEntity.class); // Root<OtherSampleEntity> from = this.criteriaQuery.from(OtherSampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<OtherSampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<OtherSampleEntity> results = query.getResultList(); // for (OtherSampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.entity.OtherEntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @Transactional public class CleanInsertSetupOnMethodTest { @Autowired
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/OtherEntityAssert.java // public class OtherEntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<OtherSampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(OtherSampleEntity.class); // Root<OtherSampleEntity> from = this.criteriaQuery.from(OtherSampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<OtherSampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<OtherSampleEntity> results = query.getResultList(); // for (OtherSampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/CleanInsertSetupOnMethodTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.entity.OtherEntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @Transactional public class CleanInsertSetupOnMethodTest { @Autowired
private EntityAssert entityAssert;
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/CleanInsertSetupOnMethodTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/OtherEntityAssert.java // public class OtherEntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<OtherSampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(OtherSampleEntity.class); // Root<OtherSampleEntity> from = this.criteriaQuery.from(OtherSampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<OtherSampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<OtherSampleEntity> results = query.getResultList(); // for (OtherSampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.entity.OtherEntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @Transactional public class CleanInsertSetupOnMethodTest { @Autowired private EntityAssert entityAssert; @Autowired
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/OtherEntityAssert.java // public class OtherEntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<OtherSampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(OtherSampleEntity.class); // Root<OtherSampleEntity> from = this.criteriaQuery.from(OtherSampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<OtherSampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<OtherSampleEntity> results = query.getResultList(); // for (OtherSampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/CleanInsertSetupOnMethodTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.entity.OtherEntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @Transactional public class CleanInsertSetupOnMethodTest { @Autowired private EntityAssert entityAssert; @Autowired
private OtherEntityAssert otherEntityAssert;
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/InsertTearDownOnMethod.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/InsertTearDownOnMethod.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
AfterTearDownDbUnitTestExecutionListener.class })
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/InsertTearDownOnMethod.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @Transactional public class InsertTearDownOnMethod { @Autowired
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/InsertTearDownOnMethod.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @Transactional public class InsertTearDownOnMethod { @Autowired
private EntityAssert entityAssert;
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/InsertTearDownOnMethod.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @Transactional public class InsertTearDownOnMethod { @Autowired private EntityAssert entityAssert; @Test
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/InsertTearDownOnMethod.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @Transactional public class InsertTearDownOnMethod { @Autowired private EntityAssert entityAssert; @Test
@DatabaseTearDown(type = DatabaseOperation.INSERT, value = "/META-INF/db/insert.xml")
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/expected/ExpectedQueryFailureOnMethodTest.java
// Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/MustFailDbUnitTestExecutionListener.java // public class MustFailDbUnitTestExecutionListener extends TransactionDbUnitTestExecutionListener { // // @Override // public void afterTestMethod(TestContext testContext) throws Exception { // Throwable caught = null; // try { // super.afterTestMethod(testContext); // } catch (Throwable ex) { // caught = ex; // } // Assert.assertNotNull("Test did not fail", caught); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.ExpectedDatabase; import com.github.springtestdbunit.testutils.MustFailDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.expected; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml")
// Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/MustFailDbUnitTestExecutionListener.java // public class MustFailDbUnitTestExecutionListener extends TransactionDbUnitTestExecutionListener { // // @Override // public void afterTestMethod(TestContext testContext) throws Exception { // Throwable caught = null; // try { // super.afterTestMethod(testContext); // } catch (Throwable ex) { // caught = ex; // } // Assert.assertNotNull("Test did not fail", caught); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/expected/ExpectedQueryFailureOnMethodTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.ExpectedDatabase; import com.github.springtestdbunit.testutils.MustFailDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.expected; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml")
@TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, MustFailDbUnitTestExecutionListener.class })
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/RefreshTearDownOnMethod.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/RefreshTearDownOnMethod.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
AfterTearDownDbUnitTestExecutionListener.class })
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/RefreshTearDownOnMethod.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @Transactional public class RefreshTearDownOnMethod { @Autowired
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/RefreshTearDownOnMethod.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @Transactional public class RefreshTearDownOnMethod { @Autowired
private EntityAssert entityAssert;
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/RefreshTearDownOnMethod.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @Transactional public class RefreshTearDownOnMethod { @Autowired private EntityAssert entityAssert; @Test
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/RefreshTearDownOnMethod.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @Transactional public class RefreshTearDownOnMethod { @Autowired private EntityAssert entityAssert; @Test
@DatabaseTearDown(type = DatabaseOperation.REFRESH, value = "/META-INF/db/refresh.xml")
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/DeleteAllSetupOnClassTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/DeleteAllSetupOnClassTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
TransactionDbUnitTestExecutionListener.class })
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/DeleteAllSetupOnClassTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @Transactional
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/DeleteAllSetupOnClassTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @Transactional
@DatabaseSetup(type = DatabaseOperation.DELETE_ALL, value = "/META-INF/db/delete.xml")
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/DeleteAllSetupOnClassTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @Transactional @DatabaseSetup(type = DatabaseOperation.DELETE_ALL, value = "/META-INF/db/delete.xml") public class DeleteAllSetupOnClassTest { @Autowired
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/DeleteAllSetupOnClassTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @Transactional @DatabaseSetup(type = DatabaseOperation.DELETE_ALL, value = "/META-INF/db/delete.xml") public class DeleteAllSetupOnClassTest { @Autowired
private EntityAssert entityAssert;
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/DeleteTearDownOnMethod.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/DeleteTearDownOnMethod.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
AfterTearDownDbUnitTestExecutionListener.class })
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/DeleteTearDownOnMethod.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @Transactional public class DeleteTearDownOnMethod { @Autowired
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/DeleteTearDownOnMethod.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @Transactional public class DeleteTearDownOnMethod { @Autowired
private EntityAssert entityAssert;
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/DeleteTearDownOnMethod.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @Transactional public class DeleteTearDownOnMethod { @Autowired private EntityAssert entityAssert; @Test
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/DeleteTearDownOnMethod.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @Transactional public class DeleteTearDownOnMethod { @Autowired private EntityAssert entityAssert; @Test
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/META-INF/db/delete.xml")
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/InsertSetupOnMethodTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/InsertSetupOnMethodTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
TransactionDbUnitTestExecutionListener.class })
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/InsertSetupOnMethodTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @Transactional public class InsertSetupOnMethodTest { @Autowired
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/InsertSetupOnMethodTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @Transactional public class InsertSetupOnMethodTest { @Autowired
private EntityAssert entityAssert;
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/InsertSetupOnMethodTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @Transactional public class InsertSetupOnMethodTest { @Autowired private EntityAssert entityAssert; @Test
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/InsertSetupOnMethodTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @Transactional public class InsertSetupOnMethodTest { @Autowired private EntityAssert entityAssert; @Test
@DatabaseSetup(type = DatabaseOperation.INSERT, value = "/META-INF/db/insert.xml")
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/CleanInsertTearDownOnClass.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/CleanInsertTearDownOnClass.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
AfterTearDownDbUnitTestExecutionListener.class })
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/CleanInsertTearDownOnClass.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class })
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/CleanInsertTearDownOnClass.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class })
@DatabaseTearDown(type = DatabaseOperation.CLEAN_INSERT, value = "/META-INF/db/insert.xml")
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/CleanInsertTearDownOnClass.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @DatabaseTearDown(type = DatabaseOperation.CLEAN_INSERT, value = "/META-INF/db/insert.xml") @Transactional public class CleanInsertTearDownOnClass { @Autowired
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/CleanInsertTearDownOnClass.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @DatabaseTearDown(type = DatabaseOperation.CLEAN_INSERT, value = "/META-INF/db/insert.xml") @Transactional public class CleanInsertTearDownOnClass { @Autowired
private EntityAssert entityAssert;
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/RefreshTearDownOnClass.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/RefreshTearDownOnClass.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
AfterTearDownDbUnitTestExecutionListener.class })
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/RefreshTearDownOnClass.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class })
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/RefreshTearDownOnClass.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class })
@DatabaseTearDown(type = DatabaseOperation.REFRESH, value = "/META-INF/db/refresh.xml")
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/RefreshTearDownOnClass.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @DatabaseTearDown(type = DatabaseOperation.REFRESH, value = "/META-INF/db/refresh.xml") @Transactional public class RefreshTearDownOnClass { @Autowired
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/AfterTearDownDbUnitTestExecutionListener.java // public class AfterTearDownDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?> CHAIN[] = { TransactionalTestExecutionListener.class, // CallAfterTestMethodExecutionListener.class, DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/teardown/RefreshTearDownOnClass.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseTearDown; import com.github.springtestdbunit.entity.EntityAssert; import com.github.springtestdbunit.testutils.AfterTearDownDbUnitTestExecutionListener; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.teardown; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, AfterTearDownDbUnitTestExecutionListener.class }) @DatabaseTearDown(type = DatabaseOperation.REFRESH, value = "/META-INF/db/refresh.xml") @Transactional public class RefreshTearDownOnClass { @Autowired
private EntityAssert entityAssert;
springtestdbunit/spring-test-dbunit
spring-test-dbunit-sample/src/main/java/com/github/springtestdbunit/sample/service/PersonService.java
// Path: spring-test-dbunit-sample/src/main/java/com/github/springtestdbunit/sample/entity/Person.java // @Entity // @NamedQueries({ @NamedQuery(name = "Person.find", query = "SELECT p from Person p where p.firstName like :name " // + "or p.lastName like :name") }) // public class Person { // // @Id // private int id; // // private String title; // // private String firstName; // // private String lastName; // // public int getId() { // return this.id; // } // // public String getTitle() { // return this.title; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getFirstName() { // return this.firstName; // } // // public void setFirstName(String firstName) { // this.firstName = firstName; // } // // public String getLastName() { // return this.lastName; // } // // public void setLastName(String lastName) { // this.lastName = lastName; // } // }
import java.util.List; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import javax.persistence.Query; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.sample.entity.Person;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.sample.service; @Service @Transactional public class PersonService { @PersistenceContext private EntityManager entityManager; @SuppressWarnings("unchecked")
// Path: spring-test-dbunit-sample/src/main/java/com/github/springtestdbunit/sample/entity/Person.java // @Entity // @NamedQueries({ @NamedQuery(name = "Person.find", query = "SELECT p from Person p where p.firstName like :name " // + "or p.lastName like :name") }) // public class Person { // // @Id // private int id; // // private String title; // // private String firstName; // // private String lastName; // // public int getId() { // return this.id; // } // // public String getTitle() { // return this.title; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getFirstName() { // return this.firstName; // } // // public void setFirstName(String firstName) { // this.firstName = firstName; // } // // public String getLastName() { // return this.lastName; // } // // public void setLastName(String lastName) { // this.lastName = lastName; // } // } // Path: spring-test-dbunit-sample/src/main/java/com/github/springtestdbunit/sample/service/PersonService.java import java.util.List; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import javax.persistence.Query; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.sample.entity.Person; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.sample.service; @Service @Transactional public class PersonService { @PersistenceContext private EntityManager entityManager; @SuppressWarnings("unchecked")
public List<Person> find(String name) {
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/CleanInsertSetupOnClassTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/CleanInsertSetupOnClassTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
TransactionDbUnitTestExecutionListener.class })
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/CleanInsertSetupOnClassTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class })
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/CleanInsertSetupOnClassTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class })
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/META-INF/db/insert.xml")
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/CleanInsertSetupOnClassTest.java
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // }
import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert;
/* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/META-INF/db/insert.xml") @Transactional public class CleanInsertSetupOnClassTest { @Autowired
// Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/TransactionDbUnitTestExecutionListener.java // public class TransactionDbUnitTestExecutionListener extends TestExecutionListenerChain { // // private static final Class<?>[] CHAIN = { TransactionalTestExecutionListener.class, // DbUnitTestExecutionListener.class }; // // @Override // protected Class<?>[] getChain() { // return CHAIN; // } // // } // // Path: spring-test-dbunit/src/main/java/com/github/springtestdbunit/annotation/DatabaseOperation.java // public enum DatabaseOperation { // // /** // * Updates the contents of existing database tables from the dataset. // */ // UPDATE, // // /** // * Inserts new database tables and contents from the dataset. // */ // INSERT, // // /** // * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any // * database rows that are not in the dataset remain unaffected. // */ // REFRESH, // // /** // * Deletes database table rows that matches rows from the dataset. // */ // DELETE, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset remain unaffected. // * @see #TRUNCATE_TABLE // */ // DELETE_ALL, // // /** // * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not // * in the dataset are unaffected. Identical to {@link #DELETE_ALL} expect this operation cannot be rolled back and // * is supported by less database vendors. // * @see #DELETE_ALL // */ // TRUNCATE_TABLE, // // /** // * Deletes all rows from a database table when the tables is specified in the dataset and subsequently insert new // * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}. // */ // CLEAN_INSERT; // // } // // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/entity/EntityAssert.java // public class EntityAssert implements InitializingBean { // // @PersistenceContext // private EntityManager entityManager; // // private CriteriaQuery<SampleEntity> criteriaQuery; // // public void afterPropertiesSet() throws Exception { // CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); // this.criteriaQuery = cb.createQuery(SampleEntity.class); // Root<SampleEntity> from = this.criteriaQuery.from(SampleEntity.class); // this.criteriaQuery.orderBy(cb.asc(from.get("value").as(String.class))); // } // // public void assertValues(String... values) { // SortedSet<String> expected = new TreeSet<String>(Arrays.asList(values)); // SortedSet<String> actual = new TreeSet<String>(); // TypedQuery<SampleEntity> query = this.entityManager.createQuery(this.criteriaQuery); // List<SampleEntity> results = query.getResultList(); // for (SampleEntity sampleEntity : results) { // actual.add(sampleEntity.getValue()); // this.entityManager.detach(sampleEntity); // } // assertEquals(expected, actual); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/setup/CleanInsertSetupOnClassTest.java import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.transaction.annotation.Transactional; import com.github.springtestdbunit.TransactionDbUnitTestExecutionListener; import com.github.springtestdbunit.annotation.DatabaseOperation; import com.github.springtestdbunit.annotation.DatabaseSetup; import com.github.springtestdbunit.entity.EntityAssert; /* * Copyright 2002-2016 the original author or authors * * 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.github.springtestdbunit.setup; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/META-INF/dbunit-context.xml") @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class }) @DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/META-INF/db/insert.xml") @Transactional public class CleanInsertSetupOnClassTest { @Autowired
private EntityAssert entityAssert;
springtestdbunit/spring-test-dbunit
spring-test-dbunit/src/test/java/com/github/springtestdbunit/dataset/XmlDataSetLoaderTest.java
// Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/ExtendedTestContextManager.java // public class ExtendedTestContextManager extends TestContextManager { // // private Object testInstance; // // public ExtendedTestContextManager(Class<?> testClass) throws Exception { // super(testClass); // getTestContext().markApplicationContextDirty(HierarchyMode.CURRENT_LEVEL); // Constructor<?> constructor = testClass.getDeclaredConstructor(); // constructor.setAccessible(true); // this.testInstance = constructor.newInstance(); // } // // public void prepareTestInstance() throws Exception { // prepareTestInstance(this.testInstance); // } // // public Object getTestContextAttribute(String name) { // return getTestContext().getAttribute(name); // } // // public TestContext accessTestContext() { // return getTestContext(); // } // // }
import static org.junit.Assert.*; import org.dbunit.dataset.IDataSet; import org.junit.Before; import org.junit.Test; import org.springframework.test.context.TestContext; import com.github.springtestdbunit.testutils.ExtendedTestContextManager;
package com.github.springtestdbunit.dataset; /** * Tests for {@link XmlDataSetLoader}. * * @author Phillip Webb */ public class XmlDataSetLoaderTest { private TestContext testContext; private XmlDataSetLoader loader; @Before public void setup() throws Exception { this.loader = new XmlDataSetLoader();
// Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/testutils/ExtendedTestContextManager.java // public class ExtendedTestContextManager extends TestContextManager { // // private Object testInstance; // // public ExtendedTestContextManager(Class<?> testClass) throws Exception { // super(testClass); // getTestContext().markApplicationContextDirty(HierarchyMode.CURRENT_LEVEL); // Constructor<?> constructor = testClass.getDeclaredConstructor(); // constructor.setAccessible(true); // this.testInstance = constructor.newInstance(); // } // // public void prepareTestInstance() throws Exception { // prepareTestInstance(this.testInstance); // } // // public Object getTestContextAttribute(String name) { // return getTestContext().getAttribute(name); // } // // public TestContext accessTestContext() { // return getTestContext(); // } // // } // Path: spring-test-dbunit/src/test/java/com/github/springtestdbunit/dataset/XmlDataSetLoaderTest.java import static org.junit.Assert.*; import org.dbunit.dataset.IDataSet; import org.junit.Before; import org.junit.Test; import org.springframework.test.context.TestContext; import com.github.springtestdbunit.testutils.ExtendedTestContextManager; package com.github.springtestdbunit.dataset; /** * Tests for {@link XmlDataSetLoader}. * * @author Phillip Webb */ public class XmlDataSetLoaderTest { private TestContext testContext; private XmlDataSetLoader loader; @Before public void setup() throws Exception { this.loader = new XmlDataSetLoader();
ExtendedTestContextManager manager = new ExtendedTestContextManager(getClass());
yiding-he/hydrogen-ssdb
src/test/java/com/hyd/ssdb/MasterSlaveTest.java
// Path: src/main/java/com/hyd/ssdb/conf/Server.java // public class Server { // // private String host; // 服务器地址 // // private int port; // 服务器端口 // // private String pass; // 服务器校验密码(可选) // // private boolean master = true; // 是否是主服务器。 // // private GenericObjectPoolConfig<Connection> poolConfig = createDefaultPoolConfig(); // 连接池配置参数 // // private SocketConfig socketConfig = new SocketConfig(); // 网络配置参数 // // public Server() { // } // // public Server(String host, int port) { // this.host = host; // this.port = port; // } // // public Server(String host, int port, boolean master) { // this.host = host; // this.port = port; // this.master = master; // } // // public Server(String host, int port, String pass) { // this.host = host; // this.port = port; // this.pass = pass; // } // // public Server(String host, int port, int timeoutSeconds) { // this.host = host; // this.port = port; // this.socketConfig.setSoTimeout(timeoutSeconds * 1000); // } // // public Server(String host, int port, SocketConfig socketConfig) { // this.host = host; // this.port = port; // this.socketConfig = socketConfig; // } // // public Server(String host, int port, int timeoutSeconds, int bufferSize) { // this.host = host; // this.port = port; // this.socketConfig.setSoTimeout(timeoutSeconds * 1000); // this.socketConfig.setSoBufferSize(bufferSize); // } // // public Server(String host, int port, String pass, boolean master) { // this.host = host; // this.port = port; // this.pass = pass; // this.master = master; // } // // public Server(String host, int port, String pass, boolean master, int timeoutSeconds, int poolMaxTotal) { // this.host = host; // this.port = port; // this.pass = pass; // this.master = master; // this.socketConfig.setSoTimeout(timeoutSeconds * 1000); // this.poolConfig.setMaxTotal(poolMaxTotal); // } // // public Server(String host, int port, String pass, boolean master, SocketConfig socketConfig) { // this.host = host; // this.port = port; // this.pass = pass; // this.master = master; // // if (socketConfig != null) { // this.socketConfig = socketConfig; // } // } // // public Server(String host, int port, String pass, boolean master, // SocketConfig socketConfig, GenericObjectPoolConfig<Connection> poolConfig) { // // this.host = host; // this.port = port; // this.pass = pass; // this.master = master; // // if (socketConfig != null) { // this.socketConfig = socketConfig; // } // // if (poolConfig != null) { // this.poolConfig = poolConfig; // } // } // // // private GenericObjectPoolConfig<Connection> createDefaultPoolConfig() { // GenericObjectPoolConfig<Connection> config = new GenericObjectPoolConfig<>(); // config.setMaxIdle(1); // return config; // } // // public GenericObjectPoolConfig<Connection> getPoolConfig() { // return poolConfig; // } // // public void setPoolConfig(GenericObjectPoolConfig<Connection> poolConfig) { // this.poolConfig = poolConfig; // } // // public SocketConfig getSocketConfig() { // return socketConfig; // } // // public void setSocketConfig(SocketConfig socketConfig) { // this.socketConfig = socketConfig; // } // // public boolean isMaster() { // return master; // } // // public void setMaster(boolean master) { // this.master = master; // } // // public String getHost() { // return host; // } // // public void setHost(String host) { // this.host = host; // } // // public int getPort() { // return port; // } // // public void setPort(int port) { // this.port = port; // } // // public String getPass() { // return pass; // } // // public void setPass(String pass) { // this.pass = pass; // } // // @SuppressWarnings("SimplifiableIfStatement") // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Server)) return false; // // Server server = (Server) o; // // if (getPort() != server.getPort()) return false; // return getHost().equals(server.getHost()); // // } // // @Override // public int hashCode() { // int result = getHost().hashCode(); // result = 31 * result + getPort(); // return result; // } // // @Override // public String toString() { // return "Server{" + // "host='" + host + '\'' + // ", port=" + port + // ", master=" + master + // '}'; // } // }
import com.hyd.ssdb.conf.Server; import java.util.Arrays; import java.util.List;
package com.hyd.ssdb; /** * (description) * created at 15-12-4 * * @author Yiding */ public class MasterSlaveTest { public static void main(String[] args) {
// Path: src/main/java/com/hyd/ssdb/conf/Server.java // public class Server { // // private String host; // 服务器地址 // // private int port; // 服务器端口 // // private String pass; // 服务器校验密码(可选) // // private boolean master = true; // 是否是主服务器。 // // private GenericObjectPoolConfig<Connection> poolConfig = createDefaultPoolConfig(); // 连接池配置参数 // // private SocketConfig socketConfig = new SocketConfig(); // 网络配置参数 // // public Server() { // } // // public Server(String host, int port) { // this.host = host; // this.port = port; // } // // public Server(String host, int port, boolean master) { // this.host = host; // this.port = port; // this.master = master; // } // // public Server(String host, int port, String pass) { // this.host = host; // this.port = port; // this.pass = pass; // } // // public Server(String host, int port, int timeoutSeconds) { // this.host = host; // this.port = port; // this.socketConfig.setSoTimeout(timeoutSeconds * 1000); // } // // public Server(String host, int port, SocketConfig socketConfig) { // this.host = host; // this.port = port; // this.socketConfig = socketConfig; // } // // public Server(String host, int port, int timeoutSeconds, int bufferSize) { // this.host = host; // this.port = port; // this.socketConfig.setSoTimeout(timeoutSeconds * 1000); // this.socketConfig.setSoBufferSize(bufferSize); // } // // public Server(String host, int port, String pass, boolean master) { // this.host = host; // this.port = port; // this.pass = pass; // this.master = master; // } // // public Server(String host, int port, String pass, boolean master, int timeoutSeconds, int poolMaxTotal) { // this.host = host; // this.port = port; // this.pass = pass; // this.master = master; // this.socketConfig.setSoTimeout(timeoutSeconds * 1000); // this.poolConfig.setMaxTotal(poolMaxTotal); // } // // public Server(String host, int port, String pass, boolean master, SocketConfig socketConfig) { // this.host = host; // this.port = port; // this.pass = pass; // this.master = master; // // if (socketConfig != null) { // this.socketConfig = socketConfig; // } // } // // public Server(String host, int port, String pass, boolean master, // SocketConfig socketConfig, GenericObjectPoolConfig<Connection> poolConfig) { // // this.host = host; // this.port = port; // this.pass = pass; // this.master = master; // // if (socketConfig != null) { // this.socketConfig = socketConfig; // } // // if (poolConfig != null) { // this.poolConfig = poolConfig; // } // } // // // private GenericObjectPoolConfig<Connection> createDefaultPoolConfig() { // GenericObjectPoolConfig<Connection> config = new GenericObjectPoolConfig<>(); // config.setMaxIdle(1); // return config; // } // // public GenericObjectPoolConfig<Connection> getPoolConfig() { // return poolConfig; // } // // public void setPoolConfig(GenericObjectPoolConfig<Connection> poolConfig) { // this.poolConfig = poolConfig; // } // // public SocketConfig getSocketConfig() { // return socketConfig; // } // // public void setSocketConfig(SocketConfig socketConfig) { // this.socketConfig = socketConfig; // } // // public boolean isMaster() { // return master; // } // // public void setMaster(boolean master) { // this.master = master; // } // // public String getHost() { // return host; // } // // public void setHost(String host) { // this.host = host; // } // // public int getPort() { // return port; // } // // public void setPort(int port) { // this.port = port; // } // // public String getPass() { // return pass; // } // // public void setPass(String pass) { // this.pass = pass; // } // // @SuppressWarnings("SimplifiableIfStatement") // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof Server)) return false; // // Server server = (Server) o; // // if (getPort() != server.getPort()) return false; // return getHost().equals(server.getHost()); // // } // // @Override // public int hashCode() { // int result = getHost().hashCode(); // result = 31 * result + getPort(); // return result; // } // // @Override // public String toString() { // return "Server{" + // "host='" + host + '\'' + // ", port=" + port + // ", master=" + master + // '}'; // } // } // Path: src/test/java/com/hyd/ssdb/MasterSlaveTest.java import com.hyd.ssdb.conf.Server; import java.util.Arrays; import java.util.List; package com.hyd.ssdb; /** * (description) * created at 15-12-4 * * @author Yiding */ public class MasterSlaveTest { public static void main(String[] args) {
List<Server> servers = Arrays.asList(
yiding-he/hydrogen-ssdb
src/main/java/com/hyd/ssdb/protocol/Block.java
// Path: src/main/java/com/hyd/ssdb/util/Bytes.java // public class Bytes { // // private static final String[] HEX_ARRAY = { // "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "0A", "0B", "0C", "0D", "0E", "0F", // "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "1A", "1B", "1C", "1D", "1E", "1F", // "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "2A", "2B", "2C", "2D", "2E", "2F", // "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "3A", "3B", "3C", "3D", "3E", "3F", // "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "4A", "4B", "4C", "4D", "4E", "4F", // "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "5A", "5B", "5C", "5D", "5E", "5F", // "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "6A", "6B", "6C", "6D", "6E", "6F", // "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "7A", "7B", "7C", "7D", "7E", "7F", // "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "8A", "8B", "8C", "8D", "8E", "8F", // "90", "91", "92", "93", "94", "95", "96", "97", "98", "99", "9A", "9B", "9C", "9D", "9E", "9F", // "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9", "AA", "AB", "AC", "AD", "AE", "AF", // "B0", "B1", "B2", "B3", "B4", "B5", "B6", "B7", "B8", "B9", "BA", "BB", "BC", "BD", "BE", "BF", // "C0", "C1", "C2", "C3", "C4", "C5", "C6", "C7", "C8", "C9", "CA", "CB", "CC", "CD", "CE", "CF", // "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7", "D8", "D9", "DA", "DB", "DC", "DD", "DE", "DF", // "E0", "E1", "E2", "E3", "E4", "E5", "E6", "E7", "E8", "E9", "EA", "EB", "EC", "ED", "EE", "EF", // "F0", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "FA", "FB", "FC", "FD", "FE", "FF"}; // // private Bytes() { // } // // /** // * 组合多个 byte[] 数组 // * // * @param byteArrays 要组合的数组 // * // * @return 组合的结果 // */ // public static byte[] concat(byte[]... byteArrays) { // int totalLength = 0; // for (byte[] byteArray : byteArrays) { // totalLength += byteArray.length; // } // // byte[] result = new byte[totalLength]; // int counter = 0; // for (byte[] byteArray : byteArrays) { // System.arraycopy(byteArray, 0, result, counter, byteArray.length); // counter += byteArray.length; // } // // return result; // } // // /** // * 字节串生成16进制字符串(最笨但最快的办法) // * // * @param bytes 要转换的字节串 // * // * @return 转换后的字符串 // */ // public static String toString(byte[] bytes) { // StringBuilder sb = new StringBuilder(bytes.length * 2); // for (byte b : bytes) { // sb.append(HEX_ARRAY[0xFF & b]); // } // return sb.toString(); // } // // }
import com.hyd.ssdb.util.Bytes; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets;
package com.hyd.ssdb.protocol; /** * 一个区块。当发送区块时,按照 '长度\n内容\n' 的格式发送 * created at 15-11-30 * * @author Yiding */ public class Block { private byte[] data; public Block(byte[] data) { this.data = data; } /** * 生成要发送的字节串 * * @return 要发送的字节串 */ public byte[] toBytes() { byte[] length = (data.length + "\n").getBytes();
// Path: src/main/java/com/hyd/ssdb/util/Bytes.java // public class Bytes { // // private static final String[] HEX_ARRAY = { // "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "0A", "0B", "0C", "0D", "0E", "0F", // "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "1A", "1B", "1C", "1D", "1E", "1F", // "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "2A", "2B", "2C", "2D", "2E", "2F", // "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "3A", "3B", "3C", "3D", "3E", "3F", // "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "4A", "4B", "4C", "4D", "4E", "4F", // "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "5A", "5B", "5C", "5D", "5E", "5F", // "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "6A", "6B", "6C", "6D", "6E", "6F", // "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "7A", "7B", "7C", "7D", "7E", "7F", // "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "8A", "8B", "8C", "8D", "8E", "8F", // "90", "91", "92", "93", "94", "95", "96", "97", "98", "99", "9A", "9B", "9C", "9D", "9E", "9F", // "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9", "AA", "AB", "AC", "AD", "AE", "AF", // "B0", "B1", "B2", "B3", "B4", "B5", "B6", "B7", "B8", "B9", "BA", "BB", "BC", "BD", "BE", "BF", // "C0", "C1", "C2", "C3", "C4", "C5", "C6", "C7", "C8", "C9", "CA", "CB", "CC", "CD", "CE", "CF", // "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7", "D8", "D9", "DA", "DB", "DC", "DD", "DE", "DF", // "E0", "E1", "E2", "E3", "E4", "E5", "E6", "E7", "E8", "E9", "EA", "EB", "EC", "ED", "EE", "EF", // "F0", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "FA", "FB", "FC", "FD", "FE", "FF"}; // // private Bytes() { // } // // /** // * 组合多个 byte[] 数组 // * // * @param byteArrays 要组合的数组 // * // * @return 组合的结果 // */ // public static byte[] concat(byte[]... byteArrays) { // int totalLength = 0; // for (byte[] byteArray : byteArrays) { // totalLength += byteArray.length; // } // // byte[] result = new byte[totalLength]; // int counter = 0; // for (byte[] byteArray : byteArrays) { // System.arraycopy(byteArray, 0, result, counter, byteArray.length); // counter += byteArray.length; // } // // return result; // } // // /** // * 字节串生成16进制字符串(最笨但最快的办法) // * // * @param bytes 要转换的字节串 // * // * @return 转换后的字符串 // */ // public static String toString(byte[] bytes) { // StringBuilder sb = new StringBuilder(bytes.length * 2); // for (byte b : bytes) { // sb.append(HEX_ARRAY[0xFF & b]); // } // return sb.toString(); // } // // } // Path: src/main/java/com/hyd/ssdb/protocol/Block.java import com.hyd.ssdb.util.Bytes; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; package com.hyd.ssdb.protocol; /** * 一个区块。当发送区块时,按照 '长度\n内容\n' 的格式发送 * created at 15-11-30 * * @author Yiding */ public class Block { private byte[] data; public Block(byte[] data) { this.data = data; } /** * 生成要发送的字节串 * * @return 要发送的字节串 */ public byte[] toBytes() { byte[] length = (data.length + "\n").getBytes();
return Bytes.concat(length, data, new byte[]{'\n'});