Skip to content

Commit 5cc3d26

Browse files
committed
better pre-test cleanup
1 parent 89564a8 commit 5cc3d26

3 files changed

Lines changed: 16 additions & 11 deletions

File tree

src/test/java/org/cip4/lib/jdf/jsonutil/JSONTestCaseBase.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,10 @@ public abstract class JSONTestCaseBase
9393
@BeforeAll
9494
static void setTmpSchema()
9595
{
96+
getNewSchema(true);
9697
for (int i = 2; i < 3; i++)
9798
{
98-
final File f = getNewSchema();
99+
final File f = getNewSchema(false);
99100
assertTrue(f.canRead());
100101
final File f1 = new File(sm_dirTestDataTemp + "schema/Version_2_" + i + "/xjdf.json");
101102
final File f2 = new File(sm_dirTestDataTemp + "schemakeep/Version_2_" + i + "/xjdf.json");
@@ -110,12 +111,16 @@ static void setTmpSchema()
110111
}
111112
}
112113

113-
protected static File getNewSchema()
114+
protected static File getNewSchema(boolean force)
114115
{
115116
synchronized (JSONTestCaseBase.class)
116117
{
117118
final File file = new File(sm_dirTestDataTemp + "schema/Version_2_3/xjdf.json");
118-
if (!file.exists())
119+
if (force)
120+
{
121+
FileUtil.forceDelete(file);
122+
}
123+
if (force || !file.exists())
119124
{
120125
final File f = new File(sm_dirTestData + "schema/Version_2_3/xjdf.json");
121126
assertTrue(f.canRead());
@@ -306,7 +311,7 @@ public JSONObjHelper writeBothJson(final KElement e, final JSONWriter jsonWriter
306311
FileUtil.writeFile(jsonWriter, new File(sm_dirTestDataTemp + "xjdf/json", output));
307312
FileUtil.writeFile(new JSONRtfWalker(jsonWriter), new File(sm_dirTestDataTemp + "xjdf/rtf", output + ".rtf"));
308313

309-
final JSONSchemaReader srf = new JSONSchemaReader(getNewSchema());
314+
final JSONSchemaReader srf = new JSONSchemaReader(getNewSchema(false));
310315
final Collection<Error> schemabugs = srf.checkJSON(jo.toJSONString());
311316
if (checkJSONSchema)
312317
{

src/test/java/org/cip4/lib/jdf/jsonutil/schema/JSONSchemaMergerTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class JSONSchemaMergerTest extends JSONTestCaseBase
6767
@Test
6868
void testJSONSchemaUpdateBad() throws URISyntaxException
6969
{
70-
final File f = getNewSchema();
70+
final File f = getNewSchema(false);
7171
assertTrue(f.canRead());
7272
final KElement e = KElement.createRoot("foo");
7373
final JSONWriter jsonWriter = XJDFJSONWriterTest.getXJDFWriter(false);
@@ -80,16 +80,16 @@ void testJSONSchemaUpdateBad() throws URISyntaxException
8080
@Test
8181
void testJSONSchemaMerge() throws URISyntaxException
8282
{
83-
File f0 = getNewSchema();
83+
File f0 = getNewSchema(false);
8484
FileUtil.deleteAll(f0);
85-
f0 = getNewSchema();
85+
f0 = getNewSchema(false);
8686
assertTrue(f0.canRead());
8787
}
8888

8989
@Test
9090
void testJSONSchemaReaderDigiPrint() throws URISyntaxException
9191
{
92-
final JSONSchemaReader sr = new JSONSchemaReader(UrlUtil.fileToUrl(getNewSchema(), true));
92+
final JSONSchemaReader sr = new JSONSchemaReader(UrlUtil.fileToUrl(getNewSchema(false), true));
9393
assertNotNull(sr.getTheSchema());
9494
final String jos = FileUtil.fileToString(new File(sm_dirTestData + "json/Duplex-1Up.XJDF.json"), null);
9595
assertNotNull(new JSONObjHelper(jos).getRoot());
@@ -100,7 +100,7 @@ void testJSONSchemaReaderDigiPrint() throws URISyntaxException
100100
@Test
101101
void testJSONSchemaReaderIntent() throws URISyntaxException
102102
{
103-
final File fs = getNewSchema();
103+
final File fs = getNewSchema(false);
104104
final JSONWriter w = new JSONWriter();
105105
w.setXJDF();
106106
for (final File f : FileUtil.listFilesWithExtension(new File(sm_dirTestData + "xjdf"), "xjdf"))
@@ -117,7 +117,7 @@ void testJSONSchemaReaderIntent() throws URISyntaxException
117117
@Test
118118
void testToString() throws URISyntaxException
119119
{
120-
final File f = getNewSchema();
120+
final File f = getNewSchema(false);
121121
assertTrue(f.canRead());
122122
final JSONSchemaUpdate up = new JSONSchemaUpdate(f);
123123
assertNotNull(up.toString());

src/test/java/org/cip4/lib/jdf/jsonutil/schema/JSONSchemaReaderTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void testJSONSchemaReaderBad() throws URISyntaxException
8686
@Test
8787
void testCheckJSON() throws Exception
8888
{
89-
final JSONSchemaReader srf = new JSONSchemaReader(getNewSchema());
89+
final JSONSchemaReader srf = new JSONSchemaReader(getNewSchema(false));
9090
final XJMFHelper h = new XJMFHelper();
9191
final JDFNotification n = (JDFNotification) h.appendMessage(EnumFamily.Signal, EnumType.Notification).appendElement(ElementName.NOTIFICATION);
9292
n.setClass(EClass.Information);

0 commit comments

Comments
 (0)