GAE+JUnit: Add a blob to the blobstore
Asked Answered
B

1

6

I'm using Google App Engine for Java, and I'm trying to write JUnit tests for my code that deals with the blobstore. How can I put a blob in the blobstore to use during testing (after it has been configured to keep everything in-memory with the LocalBlobstoreServiceTestConfig)? It seems like the solution should be very simple and basic, but somehow I cannot find it.

I imagine it was possible using the Files API, but I have steered clear of it because it is being discontinued (next week).

The only way I know of to get blobs into the blobstore outside of tests is via a multi-part form upload. However, I don't know how I would do that in the context of a JUnit test.

One can also interact with Google Cloud Storage objects via the blobstore API, but I have chosen to use the vanilla blobstore so that I don't need to loop yet another service (and its client libraries) into my app.

So again I ask, how do I get a blob in there so I can test the code that uses it?

Bland answered 24/7, 2015 at 1:59 Comment(4)
What do you mean by "in memory" blobstore service?Incest
@Incest Sorry that was a misleading description. I meant the blobstore after it has been configured with the default LocalBlobstoreServiceTestConfig. I updated the question to clarify.Bland
Have you tried this? [Using Blobstore from JUnit][1] [1]: https://mcmap.net/q/1916705/-using-blobstore-from-junitSpecialty
@Specialty Thank you for looking into it. However, that answer uses the deprecated Files API.Bland
H
2

It seems as though you're correct that this feature does not exist. You should open a Feature Request issue in the public issue tracker and any other users interested in this can star the issue. Once that's done, it will be triaged and logged Google-side for implementation over time.

Hydrosome answered 6/8, 2015 at 22:20 Comment(1)
I created this feature request. If anyone else cares to star it, it is at: code.google.com/p/googleappengine/issues/detail?id=12232Bland

© 2022 - 2024 — McMap. All rights reserved.