Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
896fc24
adjusted build and properties to get Chromedriver working.
mmuir-accenture Apr 24, 2019
876b9d9
Added username field
mmuir-accenture Apr 29, 2019
8c6675e
Removed redundant service
mmuir-accenture May 1, 2019
82994dd
Updated HTML view test to expect (currently unwired) delete button
mmuir-accenture May 2, 2019
e7f0949
Modified travis yml
mmuir-accenture May 2, 2019
c64a851
Modified travis.yml to remove bootRun
mmuir-accenture May 2, 2019
d84f6e6
Attempting to add testing to the travis integration
mmuir-accenture May 2, 2019
94b7127
Adding scan -s flag to travis.yml
mmuir-accenture May 2, 2019
cc38591
Pew pew pew
mmuir-accenture May 2, 2019
85ae341
OK, the pew pew pew didn't work. Trying again with gradle specific st…
mmuir-accenture May 2, 2019
e5dbf8f
what are those three dots?
mmuir-accenture May 2, 2019
7dc361e
bootruntest playing with stuff
mmuir-accenture May 2, 2019
336ec2d
Removing bootRun
mmuir-accenture May 2, 2019
d5d1587
Why don't you stop using the wrapper?
mmuir-accenture May 2, 2019
e8553b5
More changes
mmuir-accenture May 2, 2019
0dab729
Why did it say test and not gradle test?
mmuir-accenture May 2, 2019
81c1f26
Oh, hey, the end to end test has a .groovy extension
mmuir-accenture May 3, 2019
619739c
Changes to remove obsolete imports and commented out statements
mmuir-accenture May 7, 2019
f7cb6ba
No more groovy. Ash will be sad.
mmuir-accenture May 14, 2019
9db7e39
Travis testing
mmuir-accenture May 14, 2019
a514b59
Modifications to remove unused code
mmuir-accenture May 14, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
language: java

jdk:
- oraclejdk8
cache:
directories:
- $HOME/.gradle

addons:
chrome: stable

dist: trusty
services:
- xvfb

before_install:
- # start your web application and listen on `localhost`
- "/Applications/Google\\ Chrome.app/Contents/MacOS/Google\\ Chrome --headless --disable-gpu --remote-debugging-port=8080 http://localhost &"


script:
- ./gradlew build
- gradle bootRun &
- gradle test
- gradle --stop
75 changes: 32 additions & 43 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,61 +1,50 @@

buildscript {
ext {
springBootVersion = '2.0.0.RELEASE'
seleniumVersion = '3.0.1'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
ext {
springBootVersion = '2.0.0.RELEASE'
seleniumVersion = '3.141.59'
}
repositories {
mavenCentral()
maven { url 'http://dl.bintray.com/vermeulen-mp/gradle-plugins' }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath 'com.wiredforcode:gradle-spawn-plugin:0.8.0'
}

}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'com.wiredforcode.spawn'

group = 'com.pillar'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8

repositories {
mavenCentral()
mavenCentral()
}

dependencies {
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-web')
compile(group: 'com.h2database', name: 'h2', version: '1.4.194')

compile(group: 'org.springframework.boot', name: 'spring-boot-starter-thymeleaf')

runtime('mysql:mysql-connector-java')
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('org.thymeleaf:thymeleaf-testing:3.0.3.RELEASE')
testCompile('org.gebish:geb-junit4:2.1')
testCompile("org.seleniumhq.selenium:selenium-chrome-driver:${seleniumVersion}")

testCompile("io.github.bonigarcia:webdrivermanager:1.5.0") {
exclude group: 'org.seleniumhq.selenium'
}
}

task bootRunTest(type: org.springframework.boot.gradle.tasks.run.BootRun, dependsOn: build) {
group= 'Application'
doFirst() {
main = bootJar.mainClassName
classpath = sourceSets.main.runtimeClasspath
systemProperty 'spring.profiles.active', 'test'
}
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-web')
compile(group: 'com.h2database', name: 'h2', version: '1.4.194')
compile(group: 'org.springframework.boot', name: 'spring-boot-starter-thymeleaf')
compile('org.apache.ivy:ivy:2.4.0')

runtime('mysql:mysql-connector-java')
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('org.thymeleaf:thymeleaf-testing:3.0.3.RELEASE')
testCompile('org.gebish:geb-junit4:2.3')
testCompile("org.seleniumhq.selenium:selenium-java:${seleniumVersion}")
testCompile("org.seleniumhq.selenium:selenium-chrome-driver:${seleniumVersion}")

testCompile("io.github.bonigarcia:webdrivermanager:3.4.0") {
exclude group: 'org.seleniumhq.selenium'
}
}

task bootRunProd(type: org.springframework.boot.gradle.tasks.run.BootRun, dependsOn: build) {
group= 'Application'
doFirst() {
main = bootJar.mainClassName
classpath = sourceSets.main.runtimeClasspath
systemProperty 'spring.profiles.active', 'prod'
}
}
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Mar 09 11:01:42 CST 2018
#Tue Apr 23 14:06:00 EDT 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.pillar.pillarLearningCenter.controller;

import com.pillar.pillarLearningCenter.model.Post;
import com.pillar.pillarLearningCenter.service.PostService;
//import com.pillar.pillarLearningCenter.service.PostService;
import com.pillar.pillarLearningCenter.repository.PostRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
Expand All @@ -13,11 +14,11 @@
public class PostController {

@Autowired
private PostService postService;
private PostRepository postService;

@GetMapping("/posts")
public String posts(Model model) {
List<Post> allPosts = postService.getAllPosts();
List<Post> allPosts = postService.findAll();
model.addAttribute("postList", allPosts);
return "posts";
}
Expand All @@ -30,7 +31,7 @@ public String postsNew(Model model) {

@PostMapping("/posts/new")
public String submitPost(@ModelAttribute Post post) {
postService.createPost(post);
postService.save(post);
return "redirect:/posts";
}

Expand Down
29 changes: 19 additions & 10 deletions src/main/java/com/pillar/pillarLearningCenter/model/Post.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.pillar.pillarLearningCenter.model;

import javax.persistence.*;
import java.util.Objects;

@Entity
@Table(name = "posts")
Expand All @@ -14,6 +15,9 @@ public class Post {
@Column(name = "title")
public String title;

@Column(name = "username")
public String username;

@Column(name = "content")
public String content;

Expand All @@ -25,6 +29,12 @@ public String getTitle() {
return title;
}

public void setUsername(String username) {
this.username = username;
}

public String getUsername() {return username;}

public Long getId() {
return id;
}
Expand All @@ -41,17 +51,16 @@ public void setContent(String content) {
this.content = content;
}


@Override
public boolean equals(Object o) {
if(o == this) {
return true;
}

if (!(o instanceof Post)) {
return false;
}

Post post2 = (Post) o;
return post2.getId() == this.getId() && post2.getTitle().equals(this.getTitle()) && post2.getContent().equals(this.getContent());
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Post post = (Post) o;
return Objects.equals(id, post.id) &&
Objects.equals(title, post.title) &&
Objects.equals(username, post.username) &&
Objects.equals(content, post.content);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@

@Repository
public interface PostRepository extends JpaRepository<Post, Long>{
//public Post getOne(Long id);
public Post save(Post post);

}

This file was deleted.

This file was deleted.

1 change: 1 addition & 0 deletions src/main/resources/templates/new.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<h1>Create a New Post!</h1>
<form action="#" th:action="@{/posts/new}" th:object="${post}" method="post">
<label>Title: <input name="title" /></label>
<label>Username: <input name="username"/></label>
<label>Content: <input name="content" /></label>
<input name="submit" type="submit" value="Submit" />
</form>
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/templates/posts.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<h1>Posts</h1>
<div th:each="post : ${postList}">
<h1 th:text="${post.title}"></h1>
<h3 th:text="${post.username}"></h3>
<p th:text="${post.content}"></p>
<input name = "delete" type="submit" value="Delete"/>
</div>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.pillar.pillarLearningCenter.endToEndTests;

import io.github.bonigarcia.wdm.WebDriverManager;
import static org.junit.Assert.assertEquals;

import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;



import java.util.List;

public class CreatePostTest {
private WebDriver driver;
private ChromeOptions options = new ChromeOptions().addArguments("--headless");

@BeforeClass
public static void setupClass() {
WebDriverManager.chromedriver().setup();
}

@Before
public void setupTest() {
driver = new ChromeDriver(options);
}

@After
public void teardown() {
if (driver != null) {
driver.quit();
}
}

@Test
public void ThisThingCreatesAPost() {
driver.navigate().to("http://localhost:8080/posts/new");
driver.findElement(By.name("title")).sendKeys("New Title - in memory");
driver.findElement(By.name("content")).sendKeys("Content here");
driver.findElement(By.name("username")).sendKeys("Max");
driver.findElement(By.name("submit")).click();

List<WebElement> results = driver.findElements(By.xpath("//h1"));
String result = results.get(1).getText();

assertEquals("New Title - in memory", result);
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package com.pillar.pillarLearningCenter.endToEndTests


import geb.junit4.GebTest
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4

@RunWith(JUnit4)
class CreatePostTest extends GebTest {
class CreatePostTestDEAD extends GebTest {
//teardown method here
/* @Autowired
private TestEntityManager entityManager;
Expand All @@ -22,11 +23,13 @@ class CreatePostTest extends GebTest {

$("form").title = "New Title - in memory"
$("form").content = "Content here"
$("form").username = "Max"
$("input", value: "Submit").click()

assert $("h1")[0].text() == "Posts"
assert $("div h1")[-1].text() == "New Title - in memory"
assert $("div p")[-1].text() == "Content here"
assert $("div h3")[-1].text() == "Max"
//teardown()
}
}
Loading