forked from arquillian/arquillian-extension-persistence
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
69 additions
and
7 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,12 @@ | |
package org.jboss.arquillian.persistence.dbunit.replacer; | ||
|
||
import org.dbunit.dataset.IDataSet; | ||
import org.dbunit.dataset.xml.FlatDtdDataSet; | ||
import org.dbunit.dataset.xml.FlatXmlDataSet; | ||
import org.dbunit.dataset.xml.FlatXmlDataSetBuilder; | ||
import org.dbunit.dataset.xml.XmlDataSet; | ||
import org.jboss.arquillian.persistence.dbunit.data.replacement.DataSetScriptReplacer; | ||
import org.jboss.arquillian.persistence.dbunit.dataset.json.JsonDataSet; | ||
import org.jboss.arquillian.persistence.dbunit.dataset.yaml.YamlDataSet; | ||
import org.jboss.arquillian.persistence.testutils.FileLoader; | ||
import org.jboss.arquillian.persistence.testutils.TableAssert; | ||
|
@@ -38,7 +43,7 @@ public void closeStream() { | |
} | ||
|
||
@Test | ||
public void should_load_all_rows_with_content_for_table_from_yaml_file() throws Exception { | ||
public void should_load_all_rows_with_script_content_from_yaml_file() throws Exception { | ||
// given | ||
input = FileLoader.load("scriptable.yml"); | ||
|
||
|
@@ -52,4 +57,34 @@ public void should_load_all_rows_with_content_for_table_from_yaml_file() throws | |
.hasRow("id: 2", "firstname: Clark", "lastname: Kent", "username: superman", "password: kryptonite", "email: [email protected]", "birthdate: "+new Date()); | ||
} | ||
|
||
@Test | ||
public void should_load_all_rows_with_script_content_from_json_file() throws Exception { | ||
// given | ||
input = FileLoader.load("scriptable.json"); | ||
|
||
// when | ||
IDataSet jsonDataSet = new JsonDataSet(input); | ||
jsonDataSet = new DataSetScriptReplacer().replace(jsonDataSet); | ||
|
||
// then | ||
TableAssert.assertThat(jsonDataSet.getTable("useraccount")) | ||
.hasRow("id: 1", "firstname: John", "lastname: Smith", "username: doovde", "password: password", "age: 42.0") | ||
.hasRow("id: 2", "firstname: Clark", "lastname: Kent", "username: superman", "password: kryptonite", "email: [email protected]", "birthdate: "+new Date()); | ||
} | ||
|
||
@Test | ||
public void should_load_all_rows_with_script_content_from_xml_file() throws Exception { | ||
// given | ||
input = FileLoader.load("scriptable.xml"); | ||
|
||
// when | ||
IDataSet xmlDataSet = new FlatXmlDataSetBuilder().build(input); | ||
xmlDataSet = new DataSetScriptReplacer().replace(xmlDataSet); | ||
|
||
// then | ||
TableAssert.assertThat(xmlDataSet.getTable("useraccount")) | ||
.hasRow("id: 1", "firstname: John", "lastname: Smith", "username: doovde", "password: password", "age: 42.0", "email: \"\" ", "birthdate: \"\" ") | ||
.hasRow("id: 2", "firstname: Clark", "lastname: Kent", "username: superman", "password: kryptonite", "age: \"\" ", "email: [email protected]", "birthdate: "+new Date()); | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"useraccount": [ | ||
{ | ||
"id": 1, | ||
"firstname": "John", | ||
"lastname": "Smith", | ||
"username": "doovde", | ||
"password": "password", | ||
"age" : "js:var a=1;var b=1; 40 + a + b" | ||
}, | ||
{ | ||
"id": 2, | ||
"firstname": "Clark", | ||
"lastname": "Kent", | ||
"username": "superman", | ||
"password": "kryptonite", | ||
"email": "[email protected]", | ||
"birthdate": "groovy: new Date()" | ||
} | ||
] | ||
} |
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,4 @@ | ||
<dataset> | ||
<useraccount id="1" firstname="John" lastname="Smith" username="doovde" password="password" age="js:var a=1;var b=1; 40 + a + b" email="" birthdate=""/> | ||
<useraccount id="2" firstname="Clark" lastname="Kent" username="superman" password="kryptonite" age="" email="[email protected]" birthdate="groovy: new Date()"/> | ||
</dataset> |
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