Skip to content

Commit

Permalink
web application in less than 140 characters
Browse files Browse the repository at this point in the history
  • Loading branch information
bhavesh.shah committed Feb 4, 2016
1 parent b9be544 commit c456f18
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/spring-boot-workshop.iml
/target
/.idea
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
# spring-boot-workshop
Spring Boot Workshop - Java Meetup - Ahmedabad
# Spring Boot Workshop - Java Meetup - Ahmedabad

# Getting Started - Prerequisites

1. JDK 8 latest stable version installed
2. Latest maven plugin installed

Generate spring project through spring hosted web based quick starter service: [Spring Initializr] (http://start.spring.io/)
49 changes: 49 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.meetup</groupId>
<artifactId>spring-boot-workshop</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>spring-boot-workshop</name>
<description>Spring Boot Workshop</description>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>


</project>
14 changes: 14 additions & 0 deletions src/main/java/com/meetup/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.meetup;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
* The Application
*/
@SpringBootApplication
public class App {
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
}
12 changes: 12 additions & 0 deletions src/main/java/com/meetup/web/RootController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.meetup.web;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class RootController {
@RequestMapping("/")
public String home(){
return "Hello, World";
}
}
4 changes: 4 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
server:
address: localhost
port: 8585
context-path:
8 changes: 8 additions & 0 deletions src/main/resources/banner.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
___ ___ ___ _ _____ _ ______ _
|_ | | \/ | | | / ___| (_) | ___ \ | |
| | __ ___ ____ _ | . . | ___ ___| |_ _ _ _ __ ______ \ `--. _ __ _ __ _ _ __ __ _ ______ | |_/ / ___ ___ | |_
| |/ _` \ \ / / _` | | |\/| |/ _ \/ _ \ __| | | | '_ \ |______| `--. \ '_ \| '__| | '_ \ / _` | |______| | ___ \/ _ \ / _ \| __|
/\__/ / (_| |\ V / (_| | | | | | __/ __/ |_| |_| | |_) | /\__/ / |_) | | | | | | | (_| | | |_/ / (_) | (_) | |_
\____/ \__,_| \_/ \__,_| \_| |_/\___|\___|\__|\__,_| .__/ \____/| .__/|_| |_|_| |_|\__, | \____/ \___/ \___/ \__|
| | | | __/ |
|_| |_| |___/
37 changes: 37 additions & 0 deletions src/test/java/com/meetup/ApplicationTests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.meetup;

import com.meetup.web.RootController;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.http.MediaType;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;

import static org.hamcrest.Matchers.equalTo;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = App.class)
@WebAppConfiguration
public class ApplicationTests {

private MockMvc mockRootController;

@Before
public void setUp(){
mockRootController = MockMvcBuilders.standaloneSetup(new RootController()).build();
}

@Test
public void testHome() throws Exception{
mockRootController.perform(MockMvcRequestBuilders.get("/").
accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk()).andExpect(content().string(equalTo("Hello, World")));
}

}

0 comments on commit c456f18

Please sign in to comment.