edgent-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rui Shen (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (EDGENT-306) With edgent Tester, failed to read file content from the newly appeared files from a directory
Date Fri, 04 Nov 2016 07:48:58 GMT

    [ https://issues.apache.org/jira/browse/EDGENT-306?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15635575#comment-15635575

Rui Shen commented on EDGENT-306:

Hi Dale,

Thanks for your response during your vacation. 

Here is my method to generate the file content, which is just the usual way. 

  private void writeFileContent(File file, String[] lines) throws Exception {
    try (BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(
        new FileOutputStream(file), StandardCharsets.UTF_8))) {
      for (int j = 0; j < lines.length; j++) {
    } catch (Exception e) {
      throw e;

I replace my above code with your code of writing files in FileStreamsTextFileWriterTest.testWriterWatcherReader(),
and my test case can pass now, :).  And an interesting thing is that if I remove the policy
setting from the code, it does not work any more. So looks like that I must use FileStreams.textFileWriter()
to generate file contents and must uses policy as you defined. 

> With edgent Tester, failed to read file content from the newly appeared files from a
> -----------------------------------------------------------------------------------------------
>                 Key: EDGENT-306
>                 URL: https://issues.apache.org/jira/browse/EDGENT-306
>             Project: Edgent
>          Issue Type: Bug
>          Components: Test
>    Affects Versions: 0.4.0
>            Reporter: Rui Shen
>         Attachments: CopyOfFileStreamsTest.java, FileReaderApp.java, M2.png
> I got a trouble when using edgent Tester. The scenario that I am trying to test is:
> 1) There is a empty directory (e.g "testdata")
> 2) Use FileStreams.directoryWatcher to watch the directory "testdata" and use FileStreams.textFileReader
to read content of newly appeared files in the directory.
> I am trying to use edgent Tester to write a unit test of this scenario (I checked org.apache.edgent.test.connectors.file.FileStreamsTest
and didn't find such scenario). But I found my unit test always failed at reading the content
of newly appeared files. But if the files are pre-existing, it works. 
> I attached two files. To reproduce this issue, you can run testDirectoryWatcherOrder
in CopyOfFileStreamsTest.java. And you will see the following error. FileReaderApp.java is
a standard alone version of the above test scenario - it works well (once you start it, generate
some files with content in the directory, you can see the file content are printed in console).

> So could you please let me know if this is a defect of edgent Tester or my usage mistake?

This message was sent by Atlassian JIRA

View raw message