Closed pykereaper closed 9 months ago
when I run GpsPrune, I can get a weather forecast for a point just fine so I don't think there's a problem with the API key.
when I run the unit tests, it doesn't use the openweathermap server or the API key, so that can't be the problem.
when I call the service by entering a suitable URL in the browser (including the valid API key), then I get valid XML back, with no errors.
I'm not sure what you're trying to do.
I didn't deeply evaluate what the problem is, so maybe my suspicion of an invalid OpenWeatherMap API key was a bit hasty. Sorry if I cause confusion.
Nevertheless, Unit tests definitely fail. I'm using Gradle and if I run gradle test
, those two tests fail:
/dev/GpsPrune$ gradle test
> Task :test
ParsingTest > testCurrentWeather() FAILED
java.lang.IllegalArgumentException at ParsingTest.java:39
ParsingTest > testForecast() FAILED
java.lang.IllegalArgumentException at ParsingTest.java:57
177 tests completed, 2 failed
> Task :test FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':test'.
I already pasted the stack trace of one of the failed tests.
I will take some time to investigate and hopefully find the cause.
Can you assure, that tim.prune.function.weather.ParsingTest.testCurrentWeather()
and tim.prune.function.weather.ParsingTest.testForecast()
are succeeding with you?
Alright. Found the reason for the InputStream cannot be null
exception.
Let's just use the failed testForecast()
as an example.
You set a new FileStreamStreamProvider
as StreamProvider
: https://github.com/activityworkshop/GpsPrune/blob/06d9ff3e10971bd586137862d93103adb1a2a0f7/test/tim/prune/function/weather/ParsingTest.java#L38
And FileStreamProvider
couldn't be more simple: https://github.com/activityworkshop/GpsPrune/blob/06d9ff3e10971bd586137862d93103adb1a2a0f7/test/tim/prune/function/weather/FileStreamProvider.java#L19
It just opens the file xml/examplecurrentweather.xml
, provided from the Java resources. This file resides in test/tim/prune/function/weather/xml/examplecurrentweather.xml
: https://github.com/activityworkshop/GpsPrune/blob/06d9ff3e10971bd586137862d93103adb1a2a0f7/test/tim/prune/function/weather/xml/examplecurrentweather.xml#L1
But that location has to be declared as a resource directory in the Gradle build script. (And also in the Maven one). I'll provide a merge request, that fixes that.
... that location has to be declared as a resource directory in the Gradle build script. (And also in the Maven one).
This sounds like yet another example of where everything runs fine without Gradle or Maven, but with Gradle or Maven then it doesn't work. If you don't use Gradle or Maven then the unit tests run just fine because they can find these xml files without any problems.
Thanks for the patch, I assume that means that there isn't a large number of Gradle/Maven users who have run any unit tests in the last years!
Maven & Gradle projects usually have a different folder structure. e.g.:
.
└── src
├── main
│ ├── java
│ │ └── tim
│ │ └── prune
│ └── resources
│ └── tim
│ └── prune
└── test
├── java
│ └── tim
│ └── prune
└── resources
└── tim
└── prune
The resources
and java
folder are declared by default. But for uncommon folder structures, one can change the setup, like we had to do here.
The fact that folders have to be declared probably can have some advantages regarding build optimization.
Anyway, what I want to say is: Lets not start a war which build system is superior. I'd just say there's a reason, Ant got superseded by Maven and Maven basically got replaced by Gradle. But that doesn't mean the "old" systems are bad. In the end, all comes down to the use case. I imagine, you are perfectly happy with Ant or the Eclipse build system. Because it's just this isolated project. But let's just imagine this project becoming part of a larger build. Maybe one across several Git repositories. A more flexible build system like Gradle, with its support for multi-project-builds, can definitely simplify things.
Thanks for merging! :)
When I run the unit tests I got two errors with
testCurrentWeather()
andtestForecast()
. Both having the same cause.Could it have something to do with the API key of OpenWeatherMap being invalid?
Stacktrace of the test: