@Test @DataSet("AbstractDbTestAnnotationTest_testingEntity.xml") @DataSetExport(tablesDataSet="AbstractDbTestAnnotationTest_testingEntity.xml") public void dataSet_isExported() { this.em.find(TestingEntity.class, -1L).setName("dataSet_isExported"); } }
/** * Gets the target file name for the specified DataSetExport. * <p> * This will either take the value of exportName specified in the annotation or compute a generic value based on the class and method * name. * * @param dataSetExport * @return Export file name of the DataSetExport file */ String getExportFileName(DataSetExport dataSetExport) { String targetFileName = dataSetExport.exportName(); if (StringUtils.isEmpty(targetFileName)) { // Construct name using class and method name targetFileName = String.format("%s_%s.xml" , this.getTestClass().getSimpleName() , JuStringUtils.removeNonAlphabeticalLeadingCharacters(this.testMethodReadableName)); } return targetFileName; }
DataSetExport dataSetExport = this.annoInfo.dataSetExportAnnos.get(0).getAnnotation(); if (dataSetExport.exportType() != ExportType.NONE) { URL tablesDataSestUrl = JuUrl.resource().relativeTo(this.getTestClass()).get(dataSetExport.tablesDataSet()); if (tablesDataSestUrl == null) tablesDataSestUrl = JuUrl.resource(dataSetExport.tablesDataSet()); if (dataSetExport.exportType() == ExportType.PHYSICAL) { if (JuUtils.getJuPropertyChain().get("ju-testing.export.compareToResource", Boolean.class, true)) { xmlOutput.writeToXmlFile(targetFilePath); } else if (dataSetExport.exportType() == ExportType.MEMORY) { throw new IllegalArgumentException("Unsupported export type: " + dataSetExport.exportType());
@Test @DataSetExport(tablesDataSet = "ds", exportName = "exportForTest1") public void test1() { runIndex = DataSetExport_ExportsSuite_Nested.runCount++; } }
@Test @DataSet("AbstractDbTestTransactionTest_testingEntity.xml") @DataVerify @DataSetExport(tablesDataSet="AbstractDbTestTransactionTest_testingEntity.xml", doPhysicalExport=false) public void transaction_isRolledBack() { this.em.find(TestingEntity.class, -1L).setName("DoCommit"); this.em.flush(); this.setRollbackOnly(); } public static class Transaction_isRolledBack extends DataVerifier {
@Test @DataSetExport(tablesDataSet = "ds", exportName = "exportForTest1") public void test2() { runIndex2 = MyTestExportsSuite.runCount++; } }
@Test @DataSet("AbstractDbTestTransactionTest_testingEntity.xml") @DataVerify @DataSetExport(tablesDataSet="AbstractDbTestTransactionTest_testingEntity.xml", doPhysicalExport=false) public void transaction_isCommitted() { this.em.find(TestingEntity.class, -1L).setName("DoCommit"); } public static class Transaction_isCommitted extends DataVerifier {
@Test @DataSet("dataSetExport/exportForTest2") @DataSetExport(tablesDataSet = "ds", exportName = "exportForTest3") public void test2() { }
@Test @DataSet("dataSetExport/exportForTest1") @DataSetExport(tablesDataSet = "ds", exportName = "exportForTest2") public void test1() { }
@Test @DataSet("someUnrelatedDataSet") @DataSetExport(tablesDataSet = "ds") public void test() { runIndex = MyTestExportsSuite.runCount++; }
@Test @DataSet("dataSetExport/exportForTest2") @DataSetExport(tablesDataSet = "ds", exportName = "exportForTest1") public void test2() { } }
@Test @DataSet("dataSetExport/exportForTest1") @DataSetExport(tablesDataSet = "ds", exportName = "exportForTest2") public void test1() { }
@Test @DataSet("dataSetExport/exportForTest2") @DataSetExport(tablesDataSet = "ds", exportName = "exportForTest1") public void test2() { } }
@Test @DataSet("dataSetExport/exportForTest1") @DataSetExport(tablesDataSet = "ds", exportName = "exportForTest2") public void test1() { } }
@Test @DataSet("dataSetExport/exportForTest3") @DataSetExport(tablesDataSet = "ds", exportName = "exportForTest1") public void test3() { } }
@Test @DataSet("AbstractDbTestTransactionTest_testingEntity.xml") @DataVerify @DataSetExport(tablesDataSet="AbstractDbTestTransactionTest_testingEntity.xml", doPhysicalExport=false) public void multipleTransactions_areSupported() { // H2 has a locking strategy that will cause a timeout in this scenario JuAssumeUtils.dbIsNot(this.emUtil, DbType.H2); TestingEntity te1 = new TestingEntity("TE1"); this.em.persist(te1); try (EmfWork ew2 = this.startNewWork()) { TestingEntity te2 = new TestingEntity("TE2"); ew2.getEm().persist(te2); try (EmfWork ew3 = this.startNewWork()) { TestingEntity te3 = new TestingEntity("TE3"); ew3.getEm().persist(te3); } ew2.setRollbackOnly(); } } public static class MultipleTransactions_areSupported extends DataVerifier {