File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111
1212import org .junit .jupiter .api .*;
1313
14+ import com .google .gson .JsonObject ;
15+ import com .google .gson .JsonParser ;
16+ import com .google .gson .stream .JsonWriter ;
17+
1418import ghidra .test .AbstractGhidraHeadlessIntegrationTest ;
1519import ghidra .test .TestEnv ;
1620
@@ -107,15 +111,40 @@ public void setUp() throws Exception {
107111 assertFalse (fns .isEmpty ());
108112 }
109113
110- @ BeforeEach
111- public void startTest () throws Exception {
114+ @ AfterAll
115+ public void cleanUp () throws Exception {
116+ if (program != null ) {
117+ program .release (this );
118+ }
119+ if (env != null ) {
120+ env .dispose ();
121+ }
122+
123+ if (!stringWriter .getBuffer ().isEmpty ()) {
124+ writer .close ();
125+ stringWriter .close ();
126+ }
127+ }
128+
129+ @ Test
130+ public void testSerialize () throws Exception {
112131 stringWriter = new StringWriter ();
113132 assertNotNull (stringWriter );
133+
114134 writer = new BufferedWriter (stringWriter );
115135 assertNotNull (writer );
116136
117137 functionSerializer = new FunctionSerializer (writer , program );
118138 assertNotNull (functionSerializer .currentProgram );
119139 assertFalse (functionSerializer .currentProgram .isClosed ());
140+
141+ JsonWriter jsonWriter = functionSerializer .serialize (fns );
142+ assertNotNull (jsonWriter );
143+
144+ assertDoesNotThrow (() -> { stringWriter .toString (); });
145+
146+ JsonObject jsonOutput = JsonParser
147+ .parseString (stringWriter .toString ())
148+ .getAsJsonObject ();
120149 }
121150}
You can’t perform that action at this time.
0 commit comments