Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8611457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:22:53+00:00 2026-06-12T04:22:53+00:00

I have Java servlets that rely on the Channel API, from Google App Engine.

  • 0

I have Java servlets that rely on the Channel API, from Google App Engine. I am trying to write unit tests for that code, but I am quite stumped with how to write a stub client to receive a response message from the servlet, instead of me always having to rely on using an actual web page as my test client. My servlet is quite simple:

ChannelService channelService = ChannelServiceFactory.getChannelService();
channelService.sendMessage(new ChannelMessage(someKey, "ECHO: " + someMsg));

Usually, I read this in my test client, which is a web page. But, I want to write unit tests that I can test using a framework like jUnit or TestNG. After reading Google’s page about unit testing their Java services, I tried stuff such as using a LocalServiceTestHelper object in my test class and configure it with a LocalChannelServiceTestConfig object. The result of this is that my test class can create an instance of LocalChannelService, a class which seems to implement the same methods as ChannelService.

However:

  • Neither classes have any robust relationship to each other (don’t implement a similar interface, are not in the same class hierarchy…). Makes it impossible for me to inject a LocalChannelService object into my servlet as a mock object.
  • No documentation whatsoever on LocalChannelService API (Thanks a lot, Google).
  • Also no documentation on their Local Unit Testing page for how to test the Channel API (again, thanks a lot Google)

So then I came across this post about how to test ChannelService in Java code. Unfortunately, the only relevant answer given was for Python. Well, lo and behold, Google indeed does provide Python GAE server developers with tools for writing stub clients for Google services, as outline in their Python Local Unit Testing guide. Unbelievable how they neglected to do the same for Java!


Now that I’ve gotten all that off my chest (apologies if I sounded a bit too flustered), I would really like to know, what is the best way for testing Java code relying on Google App Engine’s Channel API? I really wish to rely on testing tools instead of web pages. do I have to somehow call Google’s Javascript Client for Channel API from Java? There must be a better way in which I can use a mock object or stub.


Update 1

Used a better name, “Google App Engine” instead of just “App Engine”

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T04:22:54+00:00Added an answer on June 12, 2026 at 4:22 am

    These are just my thoughts on unit testing the Channel API:

    1. You don’t need a mock.
      Just use the actual API. Just pretend that it works. It doesn’t return any failure even if your message fails to send, so you can’t test for that anyways.

    2. Have a backup.
      I don’t think you can rely on the Channel API. Messages fail to appear. I personally believe you need a backup, like a polling API that isn’t as responsive as the Channel API, but at least works.

    3. Unit test your backup API.

    4. Use Selenium to test the Channel API in a browser.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm learning how to write java servlets and jsp pages on google app engine.
I have a Java servlet that receives data from an upstream system via a
I have this java servlet that grabs information from a form, I need to
I have an application using Java servlets/JSP's. There are multiple clients using my app,
I have a Java web-app using standard web.xml and servlets. At the moment, I'm
I have inherited a Java application (servlets) that runs under Tomcat. For historical reasons,
I am new to Java Servlets, but would like to write files that are
Suppose I have a Java Servlet that takes a while to finish computing it's
I have a legacy Java servlet that is currently running in a Tomcat container.
Our application is a Java-GWT application that uses Guice-Persist and Guice-Servlet extensively. We have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.