@@ -134,48 +134,41 @@ protected final void runTest() throws Exception {
134134
135135 logger .debug ("running {}" , getName ());
136136
137- RepositoryConnection con = dataRep .getConnection ();
138- RepositoryConnection erCon = expectedResultRepo .getConnection ();
139- try {
140- String updateString = readUpdateString ();
137+ try (RepositoryConnection con = dataRep .getConnection ()) {
138+ try (RepositoryConnection erCon = expectedResultRepo .getConnection ()) {
139+ String updateString = readUpdateString ();
141140
142- con .begin ();
141+ con .begin ();
143142
144- Update update = con .prepareUpdate (QueryLanguage .SPARQL , updateString , requestFile );
143+ Update update = con .prepareUpdate (QueryLanguage .SPARQL , updateString , requestFile );
145144
146- assertThatNoException ().isThrownBy (() -> {
147- int hashCode = update .hashCode ();
148- if (hashCode == System .identityHashCode (update )) {
149- throw new UnsupportedOperationException (
150- "hashCode() result is the same as the identityHashCode in "
151- + update .getClass ().getName ());
152- }
153- });
145+ assertThatNoException ().isThrownBy (() -> {
146+ int hashCode = update .hashCode ();
147+ if (hashCode == System .identityHashCode (update )) {
148+ throw new UnsupportedOperationException (
149+ "hashCode() result is the same as the identityHashCode in "
150+ + update .getClass ().getName ());
151+ }
152+ });
154153
155- update .setDataset (dataset );
156- update .execute ();
154+ update .setDataset (dataset );
155+ update .execute ();
157156
158- con .commit ();
157+ con .commit ();
159158
160- // check default graph
161- logger .info ("checking default graph" );
162- compareGraphs (Iterations .asList (con .getStatements (null , null , null , true , (Resource ) null )),
163- Iterations .asList (erCon .getStatements (null , null , null , true , (Resource ) null )));
159+ // check default graph
160+ logger .info ("checking default graph" );
161+ compareGraphs (Iterations .asList (con .getStatements (null , null , null , true , (Resource ) null )),
162+ Iterations .asList (erCon .getStatements (null , null , null , true , (Resource ) null )));
163+
164+ for (String namedGraph : inputNamedGraphs .keySet ()) {
165+ logger .info ("checking named graph {}" , namedGraph );
166+ IRI contextURI = con .getValueFactory ().createIRI (namedGraph .replaceAll ("\" " , "" ));
167+ compareGraphs (Iterations .asList (con .getStatements (null , null , null , true , contextURI )),
168+ Iterations .asList (erCon .getStatements (null , null , null , true , contextURI )));
169+ }
164170
165- for (String namedGraph : inputNamedGraphs .keySet ()) {
166- logger .info ("checking named graph {}" , namedGraph );
167- IRI contextURI = con .getValueFactory ().createIRI (namedGraph .replaceAll ("\" " , "" ));
168- compareGraphs (Iterations .asList (con .getStatements (null , null , null , true , contextURI )),
169- Iterations .asList (erCon .getStatements (null , null , null , true , contextURI )));
170- }
171- } catch (Exception e ) {
172- if (con .isActive ()) {
173- con .rollback ();
174171 }
175- throw e ;
176- } finally {
177- con .close ();
178- erCon .close ();
179172 }
180173 }
181174
@@ -229,7 +222,7 @@ public void setUp() throws Exception {
229222 }
230223
231224 @ Override
232- public void tearDown () throws Exception {
225+ public void tearDown () {
233226 if (dataRep != null ) {
234227 clear (dataRep );
235228 dataRep .shutDown ();
0 commit comments