Package javaguide.tests

Source Code of javaguide.tests.FakeApplicationTest$Computer

package javaguide.tests;

import static play.test.Helpers.*;
import static org.junit.Assert.*;

import org.junit.Test;

import play.Application;
import play.GlobalSettings;
import play.test.FakeApplication;
import play.test.Helpers;

public class FakeApplicationTest {
 
    static class Computer {
        String name = "Macintosh";
        String introduced = "1984-01-24";

        static Computer findById(long id) {
            return new Computer();
        }
    }

    String formatted(String s) {
        return s;
    }
   
    //#test-running-fakeapp
    @Test
    public void findById() {
        running(fakeApplication(inMemoryDatabase("test")), new Runnable() {
            public void run() {
                Computer macintosh = Computer.findById(21l);
                assertEquals("Macintosh", macintosh.name);
                assertEquals("1984-01-24", formatted(macintosh.introduced));
            }
        });
    }
    //#test-running-fakeapp
   
    private void fakeApps() {
     
      //#test-fakeapp
      FakeApplication fakeApp = Helpers.fakeApplication();
     
      FakeApplication fakeAppWithGlobal = fakeApplication(new GlobalSettings() {
        @Override
        public void onStart(Application app) {
          System.out.println("Starting FakeApplication");
        }
      });
     
      FakeApplication fakeAppWithMemoryDb = fakeApplication(inMemoryDatabase("test"));
      //#test-fakeapp
    }

}
TOP

Related Classes of javaguide.tests.FakeApplicationTest$Computer

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.