/*
 * Copyright (c) 2017 Public Library of Science
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 */

package org.ambraproject.wombat.controller;

import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view;
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppContextSetup;

import java.io.IOException;

import com.google.common.base.Joiner;

import org.ambraproject.wombat.config.SpringMvcConfiguration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.web.context.WebApplicationContext;
import org.testng.annotations.BeforeMethod;

@WebAppConfiguration
@ContextConfiguration(classes={ControllerTestConfiguration.class, SpringMvcConfiguration.class})
public class ControllerTest extends AbstractTestNGSpringContextTests {
  protected static final Joiner NOSPACE_JOINER = Joiner.on("").skipNulls();
  protected static final String DESKTOP_PLOS_ONE = "DesktopPlosOne";

  @Autowired
  protected WebApplicationContext wac;

  protected MockMvc mockMvc;

  @BeforeMethod(alwaysRun = true)
  public void setUp() throws IOException {
    mockMvc = webAppContextSetup(wac).alwaysDo(print()).build();
  }

  public void verifyUriRender(String uri, String expectedViewName) throws Exception {
    mockMvc.perform(get(uri)).andExpect(status().isOk()).andExpect(view().name(expectedViewName));
  }
}

@@ -2645,10 +2645,17 @@
  set
-Up
+upMockMvc
 () t

Make test setup super method name more unique to avoid collision