У меня не работает простой пример с DBUnit.
public class UserTest extends DBTestCase {
private IDatabaseTester databaseTester;
public UserTest(String testName) throws Exception {
super(testName);
System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_DRIVER_CLASS,
"com.mysql.jdbc.Driver");
System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_CONNECTION_URL,
"jdbc:mysql://localhost:3632");
System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_USERNAME,
"root");
System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_PASSWORD,
"root");
System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_SCHEMA,
"sqllab");
}
@Override
protected void setUp() throws Exception
{
databaseTester = new JdbcDatabaseTester("com.mysql.jdbc.Driver",
"jdbc:mysql://localhost:3632/sqllab", "root", "root");
databaseTester.setDataSet(getDataSet());
databaseTester.onSetup();
}
@Override
protected IDataSet getDataSet() throws Exception {
// InputStream is = getClass().getResourceAsStream("/user.xml");
FileInputStream is = new FileInputStream("src/test/resources/user.xml");
return new FlatXmlDataSetBuilder().build(is);
}
public void test() throws Exception {
// UserService userService = new UserService();
// userService.delete();
IDataSet databaseDataSet = getConnection().createDataSet();
ITable actualTable = databaseDataSet.getTable("user");
System.out.println(actualTable);
IDataSet expectedDataSet = new FlatXmlDataSet(getClass().getResourceAsStream("/user.xml"));
ITable expectedTable = expectedDataSet.getTable("user");
ITable filteredActualTable = DefaultColumnFilter.includedColumnsTable(actualTable, expectedTable.getTableMetaData().getColumns());
Assertion.assertEquals(expectedTable, filteredActualTable);
}
}
после запуска тестов, я получаю NPE в строке:
return new FlatXmlDataSetBuilder().build(is);
сам StackTrace:
java.lang.NullPointerException
at org.dbunit.dataset.xml.FlatXmlProducer.isNewTable(FlatXmlProducer.java:255)
at org.dbunit.dataset.xml.FlatXmlProducer.startElement(FlatXmlProducer.java:429)
at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:509)
at java.xml/com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.startElement(XMLDTDValidator.java:746)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1395)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$ContentDriver.scanRootElementHook(XMLDocumentScannerImpl.java:1252)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3058)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:821)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:602)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:532)
at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:888)
at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:824)
at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:635)
at org.dbunit.dataset.xml.FlatXmlProducer.produce(FlatXmlProducer.java:365)
at org.dbunit.dataset.CachedDataSet.<init>(CachedDataSet.java:80)
at org.dbunit.dataset.xml.FlatXmlDataSet.<init>(FlatXmlDataSet.java:110)
at org.dbunit.dataset.xml.FlatXmlDataSetBuilder.buildInternal(FlatXmlDataSetBuilder.java:264)
at org.dbunit.dataset.xml.FlatXmlDataSetBuilder.build(FlatXmlDataSetBuilder.java:147)
at com.company.ppp.UserTest.getDataSet(UserTest.java:48)
at com.company.ppp.UserTest.setUp(UserTest.java:39)
Update: user.xml
<DATASET>
<USER USER_ID="87" LOGIN="login" PASSWORD="password" F_NAME="fname" L_NAME="lname" ACTIVE="1" ROLEID="2"/>
<USER USER_ID="88" LOGIN="login" PASSWORD="password" F_NAME="fname" L_NAME="lname" ACTIVE="1" ROLEID="2"/>
<USER USER_ID="89" LOGIN="login" PASSWORD="password" F_NAME="fname" L_NAME="lname" ACTIVE="1" ROLEID="2"/>
</DATASET>
Виртуальный выделенный сервер (VDS) становится отличным выбором
Почему выдает ошибку и не признает Graphics g? Из библиотеки привязалВсе прописал вроде
Хочу чтобы через каждые n-сек форма отображалась на 5 секунд, и обратно чтобы стала невидимойДанный код почему то не работает
Почему я получаю такую ошибкуНасколько я знаю здесь дело с gradle