public static void writePackage(KnowledgePackage pkg, File dest) {
   dest.deleteOnExit();
   OutputStream out = null;
   try {
     out = new BufferedOutputStream(new FileOutputStream(dest));
     DroolsStreamUtils.streamOut(out, pkg);
   } catch (Exception e) {
     throw new RuntimeException(e);
   } finally {
     if (out != null) {
       try {
         out.close();
       } catch (IOException e) {
       }
     }
   }
 }
Ejemplo n.º 2
0
  @Before
  public void setUp() throws Exception {
    _rgchPwTest = new char[] {'p', 'a', 's', 's', 'w', 'o', 'r', 'd'};

    _fileExisting = File.createTempFile("obzvaultexisting", ".vault");
    _strDecryptedExisting = "existing";
    OBZVaultDocument doc = new OBZVaultDocument();
    doc.setAppVersion("X.Y.DEV");
    doc.setText(_strDecryptedExisting);
    doc.saveAsVaultDoc(_fileExisting, _rgchPwTest);

    _fileText = File.createTempFile("obzvaulttext", ".txt");
    _strText = "Hello world!";
    OutputStream os = new FileOutputStream(_fileText);
    os.write(_strText.getBytes());
    os.close();
  }
  private void assertExpectedFileIO() {
    File realFile = new File(FILE_NAME);
    boolean realFileCreated = realFile.exists();

    if (realFileCreated) {
      realFile.delete();
    }

    assertFalse("Real file created", realFileCreated);
    assertTrue("File not written", testOutput.toString().startsWith("File written"));
  }