6

I have gone through https://github.com/spring-projects/spring-boot/issues/424 but my project structure contains .html files at the /templates diretory as shown below

.

|-- java
| `-- com
|       `-- projectx
|           |-- config
|           |   |-- Application.java
|           |   `-- WebXmlInitialiser.java
|           |-- controller
|           |   `-- CustomerQuickRegisterController.java
|           |-- domain
|           |   `-- Email.java
|           `-- services
|               |-- CustomerQuickRegisterDataFixtures.java
|               |-- CustomerQuickRegisterHandler.java
|               `-- CustomerQuickRegisterService.java
`-- resources
    |-- application.properties
    `-- templates
        |-- emailForm.html
        `-- result.html

But still while testing with following test

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = Application.class)
@WebAppConfiguration
@IntegrationTest

@ActiveProfiles("Test")
public class CustomerQuickRegisterControllerIntergrationTest {


    @Autowired
    private WebApplicationContext  wac;

    MockMvc mockMvc;

    @Before
    public void setUp()
    {
        this.mockMvc=MockMvcBuilders.webAppContextSetup(wac).build();
    }

    @Test
    public void thatEmailAddedSucessfully() throws Exception {

        this.mockMvc.perform(
                post("/email/addemail")

It is giving error as

java.lang.IllegalStateException: Cannot find template location: class path resource [templates/] (please add some templates or check your Thymeleaf configuration) 

But when I am running this project as gradle build:bootRun it works fine.Also .war file created from this project works well. I am not sure what's problem when i am testing it.

MasterCode
  • 975
  • 5
  • 21
  • 44
  • 1
    The classpath in your IDE? Check your settings and make sure those templates really are in the classpath. – Dave Syer Sep 06 '14 at 06:56
  • BTW an `@IntegrationTest` with `MockMvc` is a contradiction. You didn't mean to use both did you? – Dave Syer Sep 06 '14 at 06:57
  • @DaveSyer I checked and there was problem in IDE. And now It is working fine. Initially i was confused because the gradle:bootRun was working fine and i was able to access those view HTML files. Anyways.. Thanks for your response – MasterCode Sep 06 '14 at 10:47

1 Answers1

0

I checked and there was problem in IDE. And now It is working fine. Initially i was confused because the gradle:bootRun was working fine and i was able to access those view HTML files.

MasterCode
  • 975
  • 5
  • 21
  • 44