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

  • SEARCH
  • Home
  • 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 8362251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:53:56+00:00 2026-06-09T11:53:56+00:00

I am newbie in Java & play framework. Currently I’m using Play framework 2.0

  • 0

I am newbie in Java & play framework. Currently I’m using Play framework 2.0 and there are no class play.test.FunctionalTest. How to write functiona test ?

  • 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-09T11:53:58+00:00Added an answer on June 9, 2026 at 11:53 am

    See the examples in your sample applications.

    One of the ready-provided examples is at ${PLAY_FRAMEWORK}/samples/java/computer-database/test/FunctionalTest.java, quoting below:

    import org.junit.*;
    
    import java.util.*;
    
    import play.mvc.*;
    import play.test.*;
    import play.libs.F.*;
    
    import static play.test.Helpers.*;
    import static org.fest.assertions.Assertions.*;
    
    public class FunctionalTest {
    
        @Test
        public void redirectHomePage() {
            running(fakeApplication(), new Runnable() {
               public void run() {
                   Result result = callAction(controllers.routes.ref.Application.index());
    
                   assertThat(status(result)).isEqualTo(SEE_OTHER);
                   assertThat(redirectLocation(result)).isEqualTo("/computers");
               }
            });
        }
    
        @Test
        public void listComputersOnTheFirstPage() {
            running(fakeApplication(), new Runnable() {
               public void run() {
                   Result result = callAction(controllers.routes.ref.Application.list(0, "name", "asc", ""));
    
                   assertThat(status(result)).isEqualTo(OK);
                   assertThat(contentAsString(result)).contains("574 computers found");
               }
            });
        }
    
        @Test
        public void filterComputerByName() {
            running(fakeApplication(), new Runnable() {
               public void run() {
                   Result result = callAction(controllers.routes.ref.Application.list(0, "name", "asc", "Apple"));
    
                   assertThat(status(result)).isEqualTo(OK);
                   assertThat(contentAsString(result)).contains("13 computers found");
               }
            });
        }
    
        @Test
        public void createANewComputer() {
            running(fakeApplication(), new Runnable() {
                public void run() {
                    Result result = callAction(controllers.routes.ref.Application.save());
    
                    assertThat(status(result)).isEqualTo(BAD_REQUEST);
    
                    Map<String,String> data = new HashMap<String,String>();
                    data.put("name", "FooBar");
                    data.put("introduced", "badbadbad");
                    data.put("company.id", "1");
    
                    result = callAction(
                        controllers.routes.ref.Application.save(), 
                        fakeRequest().withFormUrlEncodedBody(data)
                    );
    
                    assertThat(status(result)).isEqualTo(BAD_REQUEST);
                    assertThat(contentAsString(result)).contains("<option value=\"1\" selected>Apple Inc.</option>");
                    assertThat(contentAsString(result)).contains("<input type=\"text\" id=\"introduced\" name=\"introduced\" value=\"badbadbad\" >");
                    assertThat(contentAsString(result)).contains("<input type=\"text\" id=\"name\" name=\"name\" value=\"FooBar\" >");
    
                    data.put("introduced", "2011-12-24");
    
                    result = callAction(
                        controllers.routes.ref.Application.save(), 
                        fakeRequest().withFormUrlEncodedBody(data)
                    );
    
                    assertThat(status(result)).isEqualTo(SEE_OTHER);
                    assertThat(redirectLocation(result)).isEqualTo("/computers");
                    assertThat(flash(result).get("success")).isEqualTo("Computer FooBar has been created");
    
                    result = callAction(controllers.routes.ref.Application.list(0, "name", "asc", "FooBar"));
                    assertThat(status(result)).isEqualTo(OK);
                    assertThat(contentAsString(result)).contains("One computer found");
    
                }
            });
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a java newbie. I have been using Eclipse to test a simple
I am a newbie java dev using netbeans IDE 7.1.1 and im watching this
I am a newbie to java script and currently reading John Resig's Pro javascript
I am a newbie in java. Say, I have a class Individual . I
newbie doing Java homework here. I have one class named Album which contains the
Java newbie. I am trying to run a java main class from cmd line
I am newbie to java. One doubt. I read that, internally, Thread class's run()
I am a complete newbie with Java. I use notepad++ to write Java code,
Im replicating a C# class in Java. (Im a Java newbie.) My class needs
I am a Java newbie, hence the simple question: I have a class whose

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.