Merge branch 'master' of https://github.com/atusa17/ptp
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
## PTP Persistence API
|
||||
|
||||
The PTP Persistence API is the web API for accessing the theorems database.
|
||||
|
||||
<http://localhost:8080/>
|
||||
|
||||
## Running from IntelliJ
|
||||
|
||||
* Create a new run configuration in IntelliJ.
|
||||
|
||||
```
|
||||
Name: "Pandamonium Theorem Prover Tomcat"
|
||||
Application Server: Tomcat (8.5.12)
|
||||
HTTP Port: 8080
|
||||
JMX Port: 1080
|
||||
Deployment tabe: Deploy pandamonium-theorem-prover.war (exploded)
|
||||
```
|
||||
## Running the Tests
|
||||
|
||||
This project is unit tested with JUnit and Mockito. You can run the unit tests with IntelliJ or Gradle. To run them with IntelliJ, browse to any `*Test.java` file and use IntelliJ's built-in test runner to run or debug the test. To run all the unit tests with Gradle:
|
||||
|
||||
* On a Linux or Macintosh machine:
|
||||
|
||||
```$ ./gradlew test```
|
||||
|
||||
* On a Windows machine:
|
||||
|
||||
```$ gradlew.bat test```
|
||||
|
||||
You can also test modules individually:
|
||||
|
||||
* On a Linux or Macintosh machine:
|
||||
|
||||
```$ ./gradlew persistence:test```
|
||||
|
||||
* On a Windows machine:
|
||||
|
||||
```$ gradlew.bat persistence:test```
|
||||
|
||||
## Integration Tests
|
||||
|
||||
To run the integration tests with IntelliJ, browse to any `*Test.java` file residing in any module name `integrationTest` and use IntelliJ's built-in test runner to run or debug the test. To run all the integration tests with Gradle:
|
||||
|
||||
* On a Linux or Macintosh machine:
|
||||
|
||||
```$ ./gradlew integrationTest```
|
||||
|
||||
* On a Windows machine
|
||||
|
||||
```$ gradlew.bat integrationTest```
|
||||
|
||||
## Built with
|
||||
|
||||
* [Spring Boot](https://projects.spring.io/spring-boot/) - Web framework
|
||||
* [Gradle](https://gradle.org/) - Dependency management
|
||||
* [JUnit](http://junit.org/junit4/) - Unit tests
|
||||
* [Mockito](http://site.mockito.org/) - Mock objects library
|
||||
* [Lombok](https://projectlombok.org/) - Boilerplate Code Generator
|
||||
@@ -1,33 +1,12 @@
|
||||
package edu.msudenver.tsp.website;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@Slf4j
|
||||
@SpringBootApplication
|
||||
public class Application {
|
||||
|
||||
public static void main(final String[] args) {
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CommandLineRunner commandLineRunner(final ApplicationContext ctx) {
|
||||
return args -> {
|
||||
|
||||
LOG.info("Beans provided by Spring Boot:");
|
||||
|
||||
final String[] beanNames = ctx.getBeanDefinitionNames();
|
||||
Arrays.sort(beanNames);
|
||||
for (final String beanName : beanNames) {
|
||||
LOG.info(beanName);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
package edu.msudenver.tsp.website;
|
||||
|
||||
public class ProofsDriver {
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package edu.msudenver.tsp.website.controller;
|
||||
|
||||
import edu.msudenver.tsp.website.forms.TheoremForm;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
@Slf4j
|
||||
@Controller
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/theorem")
|
||||
public class TheoremEntryController {
|
||||
@GetMapping({"/",""})
|
||||
public ModelAndView enterTheoremPage() {
|
||||
LOG.info("Received request to display the theorem entry page: returning model with name 'Theorem'");
|
||||
return new ModelAndView("Theorem");
|
||||
}
|
||||
|
||||
@PostMapping({"/",""})
|
||||
public String saveTheorem(@Validated final TheoremForm theoremForm, final Model model) {
|
||||
model.addAttribute("theoremName", theoremForm.getTheoremName());
|
||||
model.addAttribute("theorem", theoremForm.getTheorem());
|
||||
LOG.info("Saving theorem {}...", theoremForm);
|
||||
|
||||
return "success";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package edu.msudenver.tsp.website.forms;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class TheoremForm {
|
||||
private String theoremName;
|
||||
private String theorem;
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
spring.mvc.view.prefix:/WEB-INF/jsp/
|
||||
spring.mvc.view.suffix:.jsp
|
||||
@@ -0,0 +1,20 @@
|
||||
<%@ page contentType="text/html; charset=UTF-8"
|
||||
pageEncoding="UTF-8"%>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Theorem Entry</title>
|
||||
</head>
|
||||
<body>
|
||||
<form method="post" action="">
|
||||
<label>Theorem Name:
|
||||
<input type="text" name="theoremName"/>
|
||||
</label>
|
||||
<br><label>Theorem:
|
||||
<input type="text" name="theorem"/>
|
||||
</label><br>
|
||||
<input type="submit" value="Save">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,7 @@
|
||||
<html>
|
||||
<body>
|
||||
<br><b>Name: </b><%= request.getParameter("theoremName")%>
|
||||
<br><b>Theorem: </b><%= request.getParameter("theorem")%>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,5 +0,0 @@
|
||||
package edu.msudenver.tsp.website;
|
||||
|
||||
public class ProofsDriverTest {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package edu.msudenver.tsp.website.controller;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class TheoremEntryControllerTest {
|
||||
|
||||
private final TheoremEntryController theoremEntryController = new TheoremEntryController();
|
||||
|
||||
@Test
|
||||
public void testEnterTheoremPage() {
|
||||
final ModelAndView modelAndView = theoremEntryController.enterTheoremPage();
|
||||
|
||||
assertNotNull(modelAndView);
|
||||
assertEquals("Theorem", modelAndView.getViewName());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user