forked from spring-projects/spring-framework
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge class-level and method-level @SQL declarations
- Loading branch information
Showing
5 changed files
with
137 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
spring-test/src/test/java/org/springframework/test/context/jdbc/SqlMethodMergeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.springframework.test.context.jdbc; | ||
|
||
import org.junit.Test; | ||
import org.springframework.test.annotation.DirtiesContext; | ||
import org.springframework.test.context.ContextConfiguration; | ||
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
/** | ||
* Test to verify method level merge of @Sql annotations. | ||
* | ||
* @author Dmitry Semukhin | ||
*/ | ||
@ContextConfiguration(classes = EmptyDatabaseConfig.class) | ||
@Sql(value = {"schema.sql", "data-add-catbert.sql"}) | ||
@DirtiesContext | ||
public class SqlMethodMergeTest extends AbstractTransactionalJUnit4SpringContextTests { | ||
|
||
@Test | ||
@Sql(value = "data-add-dogbert.sql", mergeMode = Sql.MergeMode.MERGE) | ||
public void testMerge() { | ||
assertNumUsers(2); | ||
} | ||
|
||
protected void assertNumUsers(int expected) { | ||
assertEquals("Number of rows in the 'user' table.", expected, countRowsInTable("user")); | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
spring-test/src/test/java/org/springframework/test/context/jdbc/SqlMethodOverrideTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.springframework.test.context.jdbc; | ||
|
||
import org.junit.Test; | ||
import org.springframework.test.annotation.DirtiesContext; | ||
import org.springframework.test.context.ContextConfiguration; | ||
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
/** | ||
* Test to verify method level override of @Sql annotations. | ||
* | ||
* @author Dmitry Semukhin | ||
*/ | ||
@ContextConfiguration(classes = EmptyDatabaseConfig.class) | ||
@Sql(value = {"schema.sql", "data-add-catbert.sql"}) | ||
@DirtiesContext | ||
public class SqlMethodOverrideTest extends AbstractTransactionalJUnit4SpringContextTests { | ||
|
||
@Test | ||
@Sql(value = {"schema.sql", "data.sql", "data-add-dogbert.sql", "data-add-catbert.sql"}, mergeMode = Sql.MergeMode.OVERRIDE) | ||
public void testMerge() { | ||
assertNumUsers(3); | ||
} | ||
|
||
protected void assertNumUsers(int expected) { | ||
assertEquals("Number of rows in the 'user' table.", expected, countRowsInTable("user")); | ||
} | ||
|
||
} |