From 665fcc5b7f69c79b32f3f02f9d7c89bce5443367 Mon Sep 17 00:00:00 2001 From: dimaz1232 Date: Wed, 28 Jan 2015 16:51:41 +0200 Subject: [PATCH] Commit#3 - final task --- .../.gitignore | 1 + .../spring-boot-sample-web-jsp - Copy/pom.xml | 104 ++++++++++++++++++ .../src/main/java/sample/jsp/Post.java | 38 +++++++ .../src/main/java/sample/jsp/PostService.java | 11 ++ .../main/java/sample/jsp/PostServiceImpl.java | 27 +++++ .../sample/jsp/SampleWebJspApplication.java | 36 ++++++ .../java/sample/jsp/WelcomeController.java | 73 ++++++++++++ .../src/main/java/sample/jsp/addNewPost.java | 13 +++ .../src/main/java/sample/jsp/driver.java | 22 ++++ .../src/main/java/sample/jsp/loginPage.java | 55 +++++++++ .../main/java/sample/jsp/mainForumPage.java | 29 +++++ .../java/sample/jsp/registrationPage.java | 16 +++ .../src/main/resources/application.properties | 3 + .../src/main/resources/testng.xml | 79 +++++++++++++ .../src/main/webapp/WEB-INF/jsp/about.jsp | 11 ++ .../src/main/webapp/WEB-INF/jsp/contact.jsp | 11 ++ .../src/main/webapp/WEB-INF/jsp/login.jsp | 59 ++++++++++ .../src/main/webapp/WEB-INF/jsp/newPost.jsp | 43 ++++++++ .../main/webapp/WEB-INF/jsp/postViewAll.jsp | 94 ++++++++++++++++ .../main/webapp/WEB-INF/jsp/registration.jsp | 60 ++++++++++ .../src/main/webapp/WEB-INF/jsp/topic.jsp | 28 +++++ .../jsp/SampleWebJspApplicationTests.java | 79 +++++++++++++ .../src/test/resources/testng.xml | 62 +++++++++++ 23 files changed, 954 insertions(+) create mode 100644 Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/.gitignore create mode 100644 Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/pom.xml create mode 100644 Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/java/sample/jsp/Post.java create mode 100644 Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/java/sample/jsp/PostService.java create mode 100644 Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/java/sample/jsp/PostServiceImpl.java create mode 100644 Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/java/sample/jsp/SampleWebJspApplication.java create mode 100644 Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/java/sample/jsp/WelcomeController.java create mode 100644 Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/java/sample/jsp/addNewPost.java create mode 100644 Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/java/sample/jsp/driver.java create mode 100644 Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/java/sample/jsp/loginPage.java create mode 100644 Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/java/sample/jsp/mainForumPage.java create mode 100644 Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/java/sample/jsp/registrationPage.java create mode 100644 Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/resources/application.properties create mode 100644 Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/resources/testng.xml create mode 100644 Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/webapp/WEB-INF/jsp/about.jsp create mode 100644 Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/webapp/WEB-INF/jsp/contact.jsp create mode 100644 Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/webapp/WEB-INF/jsp/login.jsp create mode 100644 Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/webapp/WEB-INF/jsp/newPost.jsp create mode 100644 Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/webapp/WEB-INF/jsp/postViewAll.jsp create mode 100644 Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/webapp/WEB-INF/jsp/registration.jsp create mode 100644 Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/webapp/WEB-INF/jsp/topic.jsp create mode 100644 Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/test/java/sample/jsp/SampleWebJspApplicationTests.java create mode 100644 Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/test/resources/testng.xml diff --git a/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/.gitignore b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/.gitignore new file mode 100644 index 0000000..b83d222 --- /dev/null +++ b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/pom.xml b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/pom.xml new file mode 100644 index 0000000..8266e61 --- /dev/null +++ b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/pom.xml @@ -0,0 +1,104 @@ + + + 4.0.0 + + + org.springframework.boot + spring-boot-samples + 1.2.0.BUILD-SNAPSHOT + + spring-boot-sample-web-jsp + war + Spring Boot Web JSP Sample + Spring Boot Web JSP Sample + http://projects.spring.io/spring-boot/ + + Pivotal Software, Inc. + http://www.spring.io + + + ${basedir}/../.. + 1.7 + / + + + + org.testng + testng + 6.8.17 + + + org.hamcrest + hamcrest-all + 1.3 + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.data + spring-data-jpa + 1.7.1.RELEASE + + + org.springframework.boot + spring-boot-starter-tomcat + provided + + + org.apache.tomcat.embed + tomcat-embed-jasper + provided + + + org.springframework.boot + spring-boot-starter-test + test + + + org.seleniumhq.selenium + selenium-api + 2.44.0 + + + org.seleniumhq.selenium + selenium-firefox-driver + 2.44.0 + + + org.seleniumhq.selenium + selenium-support + 2.44.0 + + + dom4j + dom4j + 1.1 + + + junit + junit + 4.12 + + + javax.servlet + jstl + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + org.apache.maven.plugins + maven-surefire-plugin + + false + + + + + diff --git a/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/java/sample/jsp/Post.java b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/java/sample/jsp/Post.java new file mode 100644 index 0000000..a1a0619 --- /dev/null +++ b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/java/sample/jsp/Post.java @@ -0,0 +1,38 @@ +package sample.jsp; + +public class Post { + String title; + String message; + String url; + String img; + + + public String getTitle(){ + return title; + } + public String getMessage(){ + return message; + } + public String getUrl(){ + return url; + } + public String getImg(){ + return img; + } + + + public void setTitle(String title){ + this.title = title; + } + public void setMessage(String message){ + this.message = message; + } + public void setUrl(String url){ + this.url = url; + } + public void setImg(String img){ + this.img = img; + } + + +} diff --git a/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/java/sample/jsp/PostService.java b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/java/sample/jsp/PostService.java new file mode 100644 index 0000000..b25023a --- /dev/null +++ b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/java/sample/jsp/PostService.java @@ -0,0 +1,11 @@ +package sample.jsp; + + +import java.util.List; + +public interface PostService { + + List getAllPosts(); + void addPost(Post post); + +} diff --git a/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/java/sample/jsp/PostServiceImpl.java b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/java/sample/jsp/PostServiceImpl.java new file mode 100644 index 0000000..6e4cc0b --- /dev/null +++ b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/java/sample/jsp/PostServiceImpl.java @@ -0,0 +1,27 @@ +package sample.jsp; + + +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +@Service +public class PostServiceImpl implements PostService { + + List posts = new ArrayList(); + + public List getAllPosts() { + return posts; + } + + public void addPost(Post post) { + posts.add(post); + } + + public String getByTitle(String title) { + return title; + } + + +} diff --git a/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/java/sample/jsp/SampleWebJspApplication.java b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/java/sample/jsp/SampleWebJspApplication.java new file mode 100644 index 0000000..6fe4742 --- /dev/null +++ b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/java/sample/jsp/SampleWebJspApplication.java @@ -0,0 +1,36 @@ +/* + * Copyright 2012-2013 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package sample.jsp; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.context.web.SpringBootServletInitializer; + +@SpringBootApplication +public class SampleWebJspApplication extends SpringBootServletInitializer { + + @Override + protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { + return application.sources(SampleWebJspApplication.class); + } + + public static void main(String[] args) throws Exception { + SpringApplication.run(SampleWebJspApplication.class, args); + } + +} diff --git a/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/java/sample/jsp/WelcomeController.java b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/java/sample/jsp/WelcomeController.java new file mode 100644 index 0000000..25c2d90 --- /dev/null +++ b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/java/sample/jsp/WelcomeController.java @@ -0,0 +1,73 @@ +package sample.jsp; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.servlet.ModelAndView; + +import javax.servlet.http.HttpServletRequest; + +@Controller +@RequestMapping(value = "post") +public class WelcomeController { + + @Autowired + private PostServiceImpl postService; + + @RequestMapping(value = "login", method = RequestMethod.GET) + public ModelAndView getLogin(){ + ModelAndView model = new ModelAndView("login"); + return model; + } + + @RequestMapping("registration") + public String registration(Map model) { + return "registration"; + } + + @RequestMapping("about") + public String about(Map model) { + return "about"; + } + + @RequestMapping("contact") + public String contact(Map model) { + return "contact"; + } + + + @RequestMapping(value = "viewAllPost", method = RequestMethod.GET) + public ModelAndView viewAllPost(){ + ModelAndView rtv = new ModelAndView(); + rtv.setViewName("postViewAll"); + rtv.addObject("posts", postService.getAllPosts()); + return rtv; + } + + @RequestMapping(value = "fillPost", method = RequestMethod.GET) + public ModelAndView newPost(){ + ModelAndView rtv = new ModelAndView(); + rtv.setViewName("newPost"); + rtv.addObject("post", new Post()); + return rtv; + } + + @RequestMapping(value = "addPost", method = RequestMethod.POST) + public String add(@ModelAttribute(value = "post") Post post){ + postService.addPost(post); + return "redirect:viewAllPost"; + } + + @RequestMapping(value = "/topic/{title}", method = RequestMethod.GET) + public String getTopicById(HttpServletRequest request, @PathVariable("title") String title){ + request.setAttribute("topic", postService.getByTitle(title)); + return "topic"; + } + +} + diff --git a/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/java/sample/jsp/addNewPost.java b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/java/sample/jsp/addNewPost.java new file mode 100644 index 0000000..f09eeee --- /dev/null +++ b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/java/sample/jsp/addNewPost.java @@ -0,0 +1,13 @@ +package sample.jsp; + + +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +public class addNewPost { + + public static WebElement findWebElementInAddNewPostPage(By by) { + return driver.getInstance().findElement(by); + } + +} diff --git a/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/java/sample/jsp/driver.java b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/java/sample/jsp/driver.java new file mode 100644 index 0000000..b81e7fa --- /dev/null +++ b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/java/sample/jsp/driver.java @@ -0,0 +1,22 @@ +package sample.jsp; + +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.firefox.FirefoxDriver; + +public class driver { + + private static WebDriver driver; + + public static WebDriver getInstance() { + if (driver == null) + driver = new FirefoxDriver(); + return driver; + } + + public static void closeBrowser() { + driver.quit(); + } + + +} + diff --git a/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/java/sample/jsp/loginPage.java b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/java/sample/jsp/loginPage.java new file mode 100644 index 0000000..265bb85 --- /dev/null +++ b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/java/sample/jsp/loginPage.java @@ -0,0 +1,55 @@ +package sample.jsp; + +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +public class loginPage { + + + + public static void goTo() { + driver.getInstance().navigate().to("http://localhost:8080/post/login"); + } + + public static WebElement email() { + return driver.getInstance().findElement(By.id("inputEmail")); + } + public static WebElement password() { + return driver.getInstance().findElement(By.id("inputPassword")); + } + public static WebElement submit() { + return driver.getInstance().findElement(By.xpath("html/body/div[1]/form/button")); + } + + public static WebElement findWebElementInLoginPage(By by) { + return driver.getInstance().findElement(by); + } + + public static EnterCredentials login(String username) { + return new EnterCredentials(username); + } + + static class EnterCredentials { + private String username; + + public EnterCredentials(String username) { + this.username = username; + } + + public void withPassword(String password) { + email().sendKeys(username); + password().sendKeys(password); + submit().click(); + } + } + + public static void enterMainPage() { + goTo(); + login("any@any.any") + .withPassword("any"); + mainForumPage.waitForWebElementToBeClickable(By.linkText("Spring forum")); + } + + + +} diff --git a/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/java/sample/jsp/mainForumPage.java b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/java/sample/jsp/mainForumPage.java new file mode 100644 index 0000000..dffad6e --- /dev/null +++ b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/java/sample/jsp/mainForumPage.java @@ -0,0 +1,29 @@ +package sample.jsp; + +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.openqa.selenium.support.ui.WebDriverWait; + +public class mainForumPage { + + private static final int DEFAULT_ACTION_TIMEOUT = 10; + + + public static WebElement addNewPost() { + return driver.getInstance().findElement(By.xpath(".//*[@id='navbar']/ul/a")); + } + + + public static WebElement waitForWebElementToBeClickable(By by) { + WebDriverWait wait = new WebDriverWait(driver.getInstance(), DEFAULT_ACTION_TIMEOUT); + WebElement webElement; + return webElement = wait.until(ExpectedConditions.refreshed(ExpectedConditions.elementToBeClickable(by))); + } + + public static WebElement findWebElementInMainPage(By by) { + return driver.getInstance().findElement(by); + } + + +} diff --git a/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/java/sample/jsp/registrationPage.java b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/java/sample/jsp/registrationPage.java new file mode 100644 index 0000000..b7ada78 --- /dev/null +++ b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/java/sample/jsp/registrationPage.java @@ -0,0 +1,16 @@ +package sample.jsp; + +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +public class registrationPage { + + public static void goTo() { + driver.getInstance().navigate().to("http://localhost:8080/post/registration"); + } + + public static WebElement findWebElementInRegistrationPage(By by) { + return driver.getInstance().findElement(by); + } + +} diff --git a/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/resources/application.properties b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/resources/application.properties new file mode 100644 index 0000000..f95f1d3 --- /dev/null +++ b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/resources/application.properties @@ -0,0 +1,3 @@ +spring.view.prefix: /WEB-INF/jsp/ +spring.view.suffix: .jsp +application.message: Hello Phil \ No newline at end of file diff --git a/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/resources/testng.xml b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/resources/testng.xml new file mode 100644 index 0000000..6d66bb0 --- /dev/null +++ b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/resources/testng.xml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/webapp/WEB-INF/jsp/about.jsp b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/webapp/WEB-INF/jsp/about.jsp new file mode 100644 index 0000000..cc6b10b --- /dev/null +++ b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/webapp/WEB-INF/jsp/about.jsp @@ -0,0 +1,11 @@ + + +<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> + + + + This is info page +

Just info about this site

+Back + \ No newline at end of file diff --git a/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/webapp/WEB-INF/jsp/contact.jsp b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/webapp/WEB-INF/jsp/contact.jsp new file mode 100644 index 0000000..89b2d27 --- /dev/null +++ b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/webapp/WEB-INF/jsp/contact.jsp @@ -0,0 +1,11 @@ + + + <%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%> + <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> + + + + Contacts +

dzholudev@gmail.com

+ Back + \ No newline at end of file diff --git a/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/webapp/WEB-INF/jsp/login.jsp b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/webapp/WEB-INF/jsp/login.jsp new file mode 100644 index 0000000..54804de --- /dev/null +++ b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/webapp/WEB-INF/jsp/login.jsp @@ -0,0 +1,59 @@ + + + + + + + + + + + Signin Template for Bootstrap + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/webapp/WEB-INF/jsp/newPost.jsp b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/webapp/WEB-INF/jsp/newPost.jsp new file mode 100644 index 0000000..11f7fd4 --- /dev/null +++ b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/webapp/WEB-INF/jsp/newPost.jsp @@ -0,0 +1,43 @@ +<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + + New Post + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Title
Message
Url
Img
+ +
+ +
+ + + diff --git a/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/webapp/WEB-INF/jsp/postViewAll.jsp b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/webapp/WEB-INF/jsp/postViewAll.jsp new file mode 100644 index 0000000..3c12469 --- /dev/null +++ b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/webapp/WEB-INF/jsp/postViewAll.jsp @@ -0,0 +1,94 @@ + + +<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> + + + + View All Posts + + + + + + + + + + + + + + + + + Sticky Footer Navbar Template for Bootstrap + + + + + + + + + + + + + + + + + + + +
+
+
+
+ + + + +

${post.title}

+
+ Message - ${post.message} +
+ Url - ${post.url} +
+ Img - ${post.img} +
+ To view this topic go to -
+ + +
----------------------------------------------------------- + +
+ +
+ + + diff --git a/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/webapp/WEB-INF/jsp/registration.jsp b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/webapp/WEB-INF/jsp/registration.jsp new file mode 100644 index 0000000..cdf0609 --- /dev/null +++ b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/webapp/WEB-INF/jsp/registration.jsp @@ -0,0 +1,60 @@ + + + + + + + + + + + Register a new user + + + + + + + + + + + + + + + + + + + + + + + +
+${loginError} +

Please enter following information

+
+
+
+ + +
+
+ + +
+
+ + +
+
+
+ +
+
+
+ + + diff --git a/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/webapp/WEB-INF/jsp/topic.jsp b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/webapp/WEB-INF/jsp/topic.jsp new file mode 100644 index 0000000..947ff6a --- /dev/null +++ b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/main/webapp/WEB-INF/jsp/topic.jsp @@ -0,0 +1,28 @@ + + +<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> + + + + ${post.title} + + + + + +

${post.title}

+ ${post.message} + ${post.url} + ${post.img} +
+ + +
----------------------------------------------------------- + +
+ +
+ +Back + \ No newline at end of file diff --git a/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/test/java/sample/jsp/SampleWebJspApplicationTests.java b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/test/java/sample/jsp/SampleWebJspApplicationTests.java new file mode 100644 index 0000000..b0fe240 --- /dev/null +++ b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/test/java/sample/jsp/SampleWebJspApplicationTests.java @@ -0,0 +1,79 @@ +package sample.jsp; + +import org.junit.Assert; +import org.openqa.selenium.By; +import org.testng.annotations.AfterTest; +import org.testng.annotations.Test; + +public class SampleWebJspApplicationTests { + + @AfterTest(alwaysRun = true) + public void tearDown() throws Exception { + driver.closeBrowser(); + } + + @Test(groups = {"1", "pageLoad"}) + public void startLogin() throws Exception { + loginPage.goTo(); + Assert.assertEquals(driver.getInstance().getTitle(), "Signin Template for Bootstrap"); + Assert.assertTrue(loginPage.findWebElementInLoginPage(By.id("inputEmail")).isDisplayed()); + Assert.assertTrue(loginPage.findWebElementInLoginPage(By.id("inputPassword")).isDisplayed()); + Assert.assertTrue(loginPage.findWebElementInLoginPage(By.xpath("html/body/div[1]/form/div/label")).isDisplayed()); + Assert.assertTrue(loginPage.findWebElementInLoginPage(By.xpath("html/body/div[1]/form/button")).isDisplayed()); + Assert.assertTrue(loginPage.findWebElementInLoginPage(By.xpath("html/body/center/a/button")).isDisplayed()); + } + + @Test(groups = {"1", "registrationLoad"}, dependsOnMethods = "startLogin") + public void startRegistration() throws Exception { + registrationPage.goTo(); + Assert.assertTrue(registrationPage.findWebElementInRegistrationPage(By.id("userName")).isDisplayed()); + Assert.assertTrue(registrationPage.findWebElementInRegistrationPage(By.id("userEmail")).isDisplayed()); + Assert.assertTrue(registrationPage.findWebElementInRegistrationPage(By.id("password")).isDisplayed()); + } + + @Test(groups = {"3", "enterMainPage"}, dependsOnGroups = "1") + public void enterLogin() throws Exception { + loginPage.enterMainPage(); + Assert.assertEquals(driver.getInstance().getTitle(), "View All Posts"); + Assert.assertTrue(mainForumPage.findWebElementInMainPage(By.id("new_post")).isDisplayed()); + Assert.assertTrue(mainForumPage.findWebElementInMainPage(By.id("info_id")).isDisplayed()); + Assert.assertTrue(mainForumPage.findWebElementInMainPage(By.id("contact_id")).isDisplayed()); + Assert.assertTrue(mainForumPage.findWebElementInMainPage(By.xpath(".//*[@id='navbar']/ul/a")).isDisplayed()); + + } + + @Test(groups = {"3", "checkNewPost"}, dependsOnMethods = "enterLogin") + public void addNewPostCheck() throws Exception { + mainForumPage.addNewPost().click(); + Assert.assertTrue(addNewPost.findWebElementInAddNewPostPage(By.id("title")).isDisplayed()); + Assert.assertTrue(addNewPost.findWebElementInAddNewPostPage(By.id("message")).isDisplayed()); + Assert.assertTrue(addNewPost.findWebElementInAddNewPostPage(By.id("url")).isDisplayed()); + Assert.assertTrue(addNewPost.findWebElementInAddNewPostPage(By.id("img")).isDisplayed()); + Assert.assertTrue(addNewPost.findWebElementInAddNewPostPage(By.id("add_post")).isDisplayed()); + } + + @Test(groups = {"5", "addNewPost"}, dependsOnGroups = "3") + public void addNewPostAdd() throws Exception { + addNewPost.findWebElementInAddNewPostPage(By.id("title")).sendKeys("New title"); + addNewPost.findWebElementInAddNewPostPage(By.id("message")).sendKeys("This is new message for auto test"); + addNewPost.findWebElementInAddNewPostPage(By.id("url")).sendKeys("http://google.com"); + addNewPost.findWebElementInAddNewPostPage(By.id("img")).sendKeys("http://somesite/imgs/123.jpeg"); + addNewPost.findWebElementInAddNewPostPage(By.id("add_post")).click(); + Assert.assertTrue(mainForumPage.findWebElementInMainPage(By.xpath("html/body/input[1]")).isDisplayed()); + } + + @Test(groups = {"6", "checkInfo"}, dependsOnMethods = "addNewPostAdd") + public void goToAbout() throws Exception { + mainForumPage.findWebElementInMainPage(By.xpath(".//*[@id='info_id']/a")).click(); + Assert.assertEquals(driver.getInstance().getTitle(), "This is info page"); + mainForumPage.findWebElementInMainPage(By.xpath("html/body/a")).click(); + } + + @Test(groups = {"6", "checkContacts"}, dependsOnMethods = "goToAbout") + public void goToContacts() throws Exception { + mainForumPage.findWebElementInMainPage(By.xpath(".//*[@id='contact_id']/a")).click(); + Assert.assertEquals(driver.getInstance().getTitle(), "Contacts"); + mainForumPage.findWebElementInMainPage(By.xpath("html/body/a")).click(); + } + +} diff --git a/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/test/resources/testng.xml b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/test/resources/testng.xml new file mode 100644 index 0000000..c94e331 --- /dev/null +++ b/Zholudev/final task/spring-boot-sample-web-jsp - Copy/spring-boot-sample-web-jsp - Copy/src/test/resources/testng.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file