>
>
> How can I fix opening file in
>
> https://github.com/apache/netbeans/blob/0636a9ece532761c582ff2062c7baebef72debf6/php/php.latte/test/unit/src/org/netbeans/modules/php/latte/indent/LatteIndenterTestBase.java#L61
> ?
>
> File is opened by calling "DataObject dobj = DataObject.find(fo);" where
> fo is instance of FileObject. I don't know how to read input as UTF-8.
>
> Opened file has wrong encoding, result of test is compared to (now
> correct) expected file content and test fails.
>

I'd try setting file.encoding in the setup() method.  Or if you want to get
fancy, put an instance of FileEncodingQueryImplementation that always
returns UTF-8 in MockServices in setup.  Or ensure an implementation of
FileEncodingQueryImplementation is in the DataObject's lookup if you're
supplying the DataLoader for it and can instantiate the DataObject subclass
you want for it.

The behavior in general is correct - if nothing exists to specify an
alternate encoding for a file (such as a project), assume the default
system encoding.  Something just needs to handle the special case of
running tests on a machine whose default encoding is *not* UTF-8 - to the
test, it's just a file with no encoding information associated with, so it
defaults to the best available option, which is the system encoding.
Trying to do something special globally for the case of tests would likely
just break tests that test encoding handling.

-Tim



>
> > I assume that in the past the unittests were developed on linux
> > machines and were run on the linux based CI infrastructure.
> Yes, I fixed different errors in tests on Windows caused by different
> directory separator.
> > You can try to pass the file encoding to the ant call. If you run the
> > unittest from the IDE, you can "rerun" (second green double arrow in
> > the output tab) and specifiy properties there.
> >
> > HTH
> >
> > Matthias
> >
> Thanks.
>
> Tom
>
>

-- 
http://timboudreau.com

Reply via email to