Package

Source Code of AdminAssetGetTest

/*
     Copyright 2012-2013
     Claudio Tesoriero - c.tesoriero-at-baasbox.com

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/

// @author: Marco Tibuzzi

import static play.test.Helpers.GET;
import static play.test.Helpers.HTMLUNIT;
import static play.test.Helpers.fakeApplication;
import static play.test.Helpers.routeAndCall;
import static play.test.Helpers.running;
import static play.test.Helpers.testServer;

import javax.ws.rs.core.MediaType;

import org.apache.http.protocol.HTTP;
import org.junit.Test;

import play.libs.F.Callback;
import play.mvc.Result;
import play.mvc.Http.Status;
import play.test.FakeRequest;
import play.test.TestBrowser;

import core.AbstractAdminAssetTest;
import core.TestConfig;


public class AdminAssetGetTest extends AbstractAdminAssetTest
{
  @Override
  public String getRouteAddress()
  {
    return "/admin/asset";
  }
 
  @Override
  public String getMethod()
  {
    return GET;
  }

  @Override
  protected void assertContent(String s)
  {
  }
 
  @Test
  public void testRouteGet()
  {
    running
    (
      getFakeApplication(),
      new Runnable()
      {
        public void run()
        {
          FakeRequest request = new FakeRequest(getMethod(), getRouteAddress());
          request = request.withHeader(TestConfig.KEY_APPCODE, TestConfig.VALUE_APPCODE);
          request = request.withHeader(TestConfig.KEY_AUTH, TestConfig.AUTH_ADMIN_ENC);
          request = request.withHeader(HTTP.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED);
          Result result = routeAndCall(request);
          assertRoute(result, "testRouteGet", Status.OK, null, false);
        }
      }
    );   
  }

  @Test
  public void testServerGet()
  {
    running
    (
      getTestServer(),
      HTMLUNIT,
      new Callback<TestBrowser>()
          {
        public void invoke(TestBrowser browser)
        {
          setHeader(TestConfig.KEY_APPCODE, TestConfig.VALUE_APPCODE);
          setHeader(TestConfig.KEY_AUTH, TestConfig.AUTH_ADMIN_ENC);
          setHeader(HTTP.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED);
          httpRequest(getURLAddress(), getMethod());
          assertServer("testServerGet", Status.OK, null, false);
        }
          }
    );
  }
}
TOP

Related Classes of AdminAssetGetTest

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.