-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
web application in less than 140 characters
- Loading branch information
bhavesh.shah
committed
Feb 4, 2016
1 parent
b9be544
commit c456f18
Showing
8 changed files
with
135 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/spring-boot-workshop.iml | ||
/target | ||
/.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
server: | ||
address: localhost | ||
port: 8585 | ||
context-path: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
___ ___ ___ _ _____ _ ______ _ | ||
|_ | | \/ | | | / ___| (_) | ___ \ | | | ||
| | __ ___ ____ _ | . . | ___ ___| |_ _ _ _ __ ______ \ `--. _ __ _ __ _ _ __ __ _ ______ | |_/ / ___ ___ | |_ | ||
| |/ _` \ \ / / _` | | |\/| |/ _ \/ _ \ __| | | | '_ \ |______| `--. \ '_ \| '__| | '_ \ / _` | |______| | ___ \/ _ \ / _ \| __| | ||
/\__/ / (_| |\ V / (_| | | | | | __/ __/ |_| |_| | |_) | /\__/ / |_) | | | | | | | (_| | | |_/ / (_) | (_) | |_ | ||
\____/ \__,_| \_/ \__,_| \_| |_/\___|\___|\__|\__,_| .__/ \____/| .__/|_| |_|_| |_|\__, | \____/ \___/ \___/ \__| | ||
| | | | __/ | | ||
|_| |_| |___/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"))); | ||
} | ||
|
||
} |