Published Solution:
Source code:
Screenshot
Hey @rabestro, I think the [Invalid Unicode]
is not the actual error you need to fix. It certainly is showing that on the web page, but when you check the test failure (click where it says Failed
), it says this:
Message: Can't find bundle for base name messages, locale en_US
Exception: java.util.MissingResourceException: Can't find bundle for base name messages, locale en_US
at java.base/java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:2059)
at java.base/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1697)
at java.base/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1600)
at java.base/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1555)
at java.base/java.util.ResourceBundle.getBundle(ResourceBundle.java:935)
at LedgerFormatter.<init>(LedgerFormatter.java:15)
at Ledger.format(Ledger.java:14)
at LedgerTest.emptyLedgerUS(LedgerTest.java:29)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
In regards to the [Invalid Unicode]
, I’m guessing your properties files are not UTF-8 encoded (when I clone your repo, file
tells me its ISO-8859):
efreet exercism-solutions-java/ledger ‹main› » file src/main/resources/messages.properties
src/main/resources/messages.properties: ISO-8859 text
@ErikSchierboom, would this be why it shows [Invalid Unicode]
on the web?
Thanks for pointing that out.
As a work around I moved resources inside src/main/java and convert .properties files to Java objects that extends ListResourceBundle
. This is an alternative way to deal with resources.
For Ledger exercise we deal with localisation, and I believe that for this exercise using resources is an idiomatic approach.
So, I discover the issue with standard java properties.
The second issue - for correctly submitting files I should use command like:
exercism submit src/main/java/*.java src/main/java/resources/*
I will be nice to have a simpler command.
I honestly don’t know, sorry