13
13
*******************************************************************************/
14
14
package org .eclipse .core .tests .internal .watson ;
15
15
16
- import java .io .*;
17
- import org .eclipse .core .internal .watson .*;
18
- import org .eclipse .core .runtime .IPath ;
19
- import org .junit .Before ;
20
- import org .junit .Test ;
21
-
22
- public class DeltaFlatteningTest extends ElementTreeSerializationTest {
23
- protected ElementTree fNewTree ;
24
- protected IPath project3 , folder5 , file4 , file5 ;
25
-
26
- /**
27
- * Performs the serialization activity for this test
28
- */
29
- @ Override
30
- public Object doRead (ElementTreeReader reader , DataInputStream input ) throws IOException {
31
- return reader .readDelta (fNewTree , input );
32
- }
33
-
34
- /**
35
- * Runs a test for this class at a certain depth and path
36
- */
37
- @ Override
38
- public void doTest (IPath path , int depth ) {
16
+ import static org .eclipse .core .tests .internal .watson .ElementTreeSerializationTestHelper .doPipeTest ;
39
17
40
- /* Get an element tree from somewhere. */
41
- fTree = TestUtil .createTestElementTree ();
42
- fSubtreePath = path ;
43
- fDepth = depth ;
44
- ElementTree newTree = (ElementTree ) doPipeTest ();
45
- TestUtil .assertEqualTrees (this .getClass () + "test0" , fTree , newTree , fSubtreePath , fDepth );
46
- }
18
+ import java .io .IOException ;
19
+ import org .eclipse .core .internal .watson .DefaultElementComparator ;
20
+ import org .eclipse .core .internal .watson .ElementTree ;
21
+ import org .eclipse .core .internal .watson .ElementTreeWriter ;
22
+ import org .eclipse .core .runtime .IPath ;
23
+ import org .eclipse .core .tests .internal .watson .ElementTreeSerializationTestHelper .StreamReader ;
24
+ import org .eclipse .core .tests .internal .watson .ElementTreeSerializationTestHelper .StreamWriter ;
25
+ import org .junit .jupiter .params .ParameterizedTest ;
26
+ import org .junit .jupiter .params .provider .ArgumentsSource ;
47
27
48
- /**
49
- * Performs the serialization activity for this test
50
- */
51
- @ Override
52
- public void doWrite (ElementTreeWriter writer , DataOutputStream output ) throws IOException {
53
- writer .writeDelta (fTree , fNewTree , fSubtreePath , fDepth , output , DefaultElementComparator .getComparator ());
54
- }
28
+ public class DeltaFlatteningTest implements IPathConstants {
55
29
56
- @ Override
57
- @ Before
58
- public void setUp () throws Exception {
59
- super .setUp ();
60
- fTree = TestUtil .createTestElementTree ();
30
+ private ElementTree prepareTreeForChange () {
31
+ ElementTree tree = TestUtil .createTestElementTree ();
61
32
/**
62
33
* The following changes will be made to the base tree:
63
34
* - add project3
@@ -69,32 +40,45 @@ public void setUp() throws Exception {
69
40
* - delete folder3
70
41
*/
71
42
72
- fNewTree = fTree .newEmptyDelta ();
43
+ ElementTree newTree = tree .newEmptyDelta ();
73
44
74
- project3 = solution .append ("project3" );
75
- folder5 = project3 .append ("folder5" );
76
- file4 = project2 .append ("file4" );
77
- file5 = folder1 .append ("file5" );
45
+ IPath project3 = solution .append ("project3" );
46
+ IPath folder5 = project3 .append ("folder5" );
47
+ IPath file4 = project2 .append ("file4" );
48
+ IPath file5 = folder1 .append ("file5" );
78
49
79
- fNewTree .createElement (project3 , "project3" );
80
- fNewTree .createElement (folder5 , "folder5" );
81
- fNewTree .deleteElement (file1 );
82
- fNewTree .createElement (folder2 , "ChangedData" );
83
- fNewTree .createElement (file4 , "file4" );
84
- fNewTree .createElement (file5 , "file5" );
85
- fNewTree .deleteElement (folder3 );
86
- fNewTree .immutable ();
50
+ newTree .createElement (project3 , "project3" );
51
+ newTree .createElement (folder5 , "folder5" );
52
+ newTree .deleteElement (file1 );
53
+ newTree .createElement (folder2 , "ChangedData" );
54
+ newTree .createElement (file4 , "file4" );
55
+ newTree .createElement (file5 , "file5" );
56
+ newTree .deleteElement (folder3 );
57
+ newTree .immutable ();
87
58
88
59
/* assert the new structure */
89
- TestUtil .assertHasPaths (fNewTree , new IPath [] {solution , project1 , project2 , project3 , file2 , file4 , file5 , folder1 , folder2 , folder4 , folder5 });
90
- TestUtil .assertNoPaths (fNewTree , new IPath [] {file1 , file3 , folder3 });
60
+ TestUtil .assertHasPaths (newTree , new IPath [] { solution , project1 , project2 , project3 , file2 , file4 , file5 ,
61
+ folder1 , folder2 , folder4 , folder5 });
62
+ TestUtil .assertNoPaths (newTree , new IPath [] { file1 , file3 , folder3 });
63
+
64
+ return newTree ;
91
65
}
92
66
93
67
/**
94
68
* Tests the reading and writing of element deltas
95
69
*/
96
- @ Test
97
- public void test0 () {
98
- doExhaustiveTests ();
70
+ @ ParameterizedTest
71
+ @ ArgumentsSource (ElementTreeSerializationTestHelper .class )
72
+ public void test0 (IPath path , int depth ) throws IOException {
73
+ ElementTree tree = TestUtil .createTestElementTree ();
74
+ IPath testTreeRootPath = solution ;
75
+ ElementTree treeForChange = prepareTreeForChange ();
76
+
77
+ StreamReader streamReader = (reader , input ) -> reader .readDelta (treeForChange , input );
78
+ StreamWriter streamWriter = (writer , output ) -> writer .writeDelta (tree , treeForChange , testTreeRootPath ,
79
+ ElementTreeWriter .D_INFINITE , output , DefaultElementComparator .getComparator ());
80
+ ElementTree newTree = (ElementTree ) doPipeTest (streamWriter , streamReader );
81
+
82
+ TestUtil .assertEqualTrees (this .getClass () + "test0" , tree , newTree , path , depth );
99
83
}
100
84
}
0 commit comments