File tree Expand file tree Collapse file tree 2 files changed +12
-11
lines changed
src/test/java/org/codehaus/plexus/components/secdispatcher/internal Expand file tree Collapse file tree 2 files changed +12
-11
lines changed Original file line number Diff line number Diff line change 1313
1414package org .codehaus .plexus .components .secdispatcher .internal ;
1515
16- import java .io .FileWriter ;
16+ import java .io .OutputStream ;
1717import java .nio .charset .StandardCharsets ;
18+ import java .nio .file .Files ;
19+ import java .nio .file .Paths ;
1820import java .util .Base64 ;
1921import java .util .Map ;
2022import java .util .Set ;
@@ -49,9 +51,8 @@ private void saveSec(String masterSource) throws Exception {
4951 sec .setMasterSource (masterSource );
5052 sec .setMasterCipher (AESGCMNoPadding .CIPHER_ALG );
5153
52- try (FileWriter fw = new FileWriter ("./target/sec.xml" )) {
53- new SecurityConfigurationStaxWriter ().write (fw , sec );
54- fw .flush ();
54+ try (OutputStream fos = Files .newOutputStream (Paths .get ("./target/sec.xml" ))) {
55+ new SecurityConfigurationStaxWriter ().write (fos , sec );
5556 }
5657 System .setProperty (DefaultSecDispatcher .SYSTEM_PROPERTY_CONFIGURATION_LOCATION , "./target/sec.xml" );
5758 }
Original file line number Diff line number Diff line change 1313
1414package org .codehaus .plexus .components .secdispatcher .internal ;
1515
16- import java .io .FileWriter ;
16+ import java .io .OutputStream ;
17+ import java .nio .file .Files ;
18+ import java .nio .file .Paths ;
1719import java .util .Map ;
1820
1921import org .codehaus .plexus .components .secdispatcher .model .Config ;
@@ -54,9 +56,8 @@ private void saveSec(String masterSource) throws Exception {
5456
5557 sec .addConfiguration (conf );
5658
57- try (FileWriter fw = new FileWriter ("./target/sec1.xml" )) {
58- new SecurityConfigurationStaxWriter ().write (fw , sec );
59- fw .flush ();
59+ try (OutputStream fos = Files .newOutputStream (Paths .get ("./target/sec1.xml" ))) {
60+ new SecurityConfigurationStaxWriter ().write (fos , sec );
6061 }
6162 }
6263
@@ -65,9 +66,8 @@ public void prepare() throws Exception {
6566 System .setProperty (DefaultSecDispatcher .SYSTEM_PROPERTY_CONFIGURATION_LOCATION , "./target/sec.xml" );
6667 SettingsSecurity sec = new SettingsSecurity ();
6768 sec .setRelocation ("./target/sec1.xml" );
68- try (FileWriter fw = new FileWriter ("./target/sec.xml" )) {
69- new SecurityConfigurationStaxWriter ().write (fw , sec );
70- fw .flush ();
69+ try (OutputStream fos = Files .newOutputStream (Paths .get ("./target/sec.xml" ))) {
70+ new SecurityConfigurationStaxWriter ().write (fos , sec );
7171 }
7272 saveSec ("magic:mighty" );
7373 }
You can’t perform that action at this time.
0 commit comments