Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Integrated Spring MVC service. Created a test GET request.

  • Loading branch information...
commit d05c8521e27fdba9acb0c4a112bb31f5c6212cfa 1 parent fd1078c
Christopher Thielen cthielen authored
BIN  .DS_Store
View
Binary file not shown
3  .gitignore
View
@@ -1,3 +1,4 @@
config.properties
.classpath
-.project
+.project
+target/
43 pom.xml
View
@@ -12,7 +12,27 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <start-class>edu.ucdavis.dss.BannerTest.Application</start-class>
</properties>
+
+ <parent>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-parent</artifactId>
+ <version>1.0.0.RC3</version>
+ </parent>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.3.2</version>
+ </plugin>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
<dependencies>
<dependency>
@@ -31,5 +51,28 @@
<artifactId>mockrunner-core</artifactId>
<version>1.0.0</version>
</dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ </dependency>
</dependencies>
+
+ <repositories>
+ <repository>
+ <id>spring-snapshots</id>
+ <url>http://repo.spring.io/libs-snapshot</url>
+ <snapshots><enabled>true</enabled></snapshots>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>spring-snapshots</id>
+ <url>http://repo.spring.io/libs-snapshot</url>
+ <snapshots><enabled>true</enabled></snapshots>
+ </pluginRepository>
+ </pluginRepositories>
</project>
14 src/main/java/edu/ucdavis/dss/BannerTest/Application.java
View
@@ -0,0 +1,14 @@
+package edu.ucdavis.dss.BannerTest;
+
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.SpringApplication;
+import org.springframework.context.annotation.ComponentScan;
+
+@ComponentScan
+@EnableAutoConfiguration
+public class Application {
+
+ public static void main(String[] args) {
+ SpringApplication.run(Application.class, args);
+ }
+}
6 src/main/java/edu/ucdavis/dss/BannerTest/BannerConnector.java
View
@@ -20,7 +20,7 @@ public BannerConnector() {
}
- public boolean connect() {
+ public boolean connect(String dbConnStr, String dbUser, String dbPassword) {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch (ClassNotFoundException e) {
@@ -32,8 +32,8 @@ public boolean connect() {
try {
connection = DriverManager.getConnection(
- PropertiesFile.dbString, PropertiesFile.dbUser,
- PropertiesFile.dbPassword);
+ dbConnStr, dbUser, dbPassword
+ );
} catch (SQLException e) {
// e.printStackTrace();
return false;
39 src/main/java/edu/ucdavis/dss/BannerTest/BannerTest.java
View
@@ -5,26 +5,27 @@
public class BannerTest {
public static void main(String[] argv) {
-
-// System.out.println("-------- Oracle JDBC Connection Testing ------");
- if (PropertiesFile.read()) {
+
+ if (PropertiesFile.read() == false) {
+ System.out.println("Could not connect.");
+ return;
+ }
- BannerConnector bannerConnector = new BannerConnector();
-
- if(bannerConnector.connect() == false) {
- System.out.println("Could not connect.");
- }
-
- int course_count = bannerConnector.countCoursesForTerm("201301");
-
- System.out.println("Course count is " + course_count);
-
- try {
- bannerConnector.close();
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ BannerConnector bannerConnector = new BannerConnector();
+
+ if(bannerConnector.connect(PropertiesFile.dbString, PropertiesFile.dbUser, PropertiesFile.dbPassword) == false) {
+ System.out.println("Could not connect.");
+ }
+
+ int course_count = bannerConnector.countCoursesForTerm("201301");
+
+ System.out.println("Course count is " + course_count);
+
+ try {
+ bannerConnector.close();
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
}
}
38 src/main/java/edu/ucdavis/dss/BannerTest/BannerTestController.java
View
@@ -0,0 +1,38 @@
+package edu.ucdavis.dss.BannerTest;
+
+import java.util.concurrent.atomic.AtomicLong;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import java.sql.SQLException;
+
+@Controller
+public class BannerTestController {
+
+ @RequestMapping("/test")
+ public @ResponseBody String CourseCount() {
+ if (PropertiesFile.read() == false) {
+ return "Could not connect due to properties file error.";
+ }
+
+ BannerConnector bannerConnector = new BannerConnector();
+
+ if(bannerConnector.connect(PropertiesFile.dbString, PropertiesFile.dbUser, PropertiesFile.dbPassword) == false) {
+ return "Could not connect due to DB connection error.";
+ }
+
+ int course_count = bannerConnector.countCoursesForTerm("201301");
+
+ try {
+ bannerConnector.close();
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return "Course count is " + course_count;
+
+ }
+}
+
4 src/main/java/edu/ucdavis/dss/BannerTest/PropertiesFile.java
View
@@ -21,10 +21,8 @@ public static boolean read () {
dbString = (String) properties.getProperty("dbString");
dbUser = (String) properties.getProperty("dbUser");
dbPassword = (String) properties.getProperty("dbPassword");
-
} catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ System.out.println("Please ensure config.properties exists and is set up correctly.");
return false;
}
BIN  target/BannerTest-0.0.1-SNAPSHOT.jar
View
Binary file not shown
5 target/classes/META-INF/MANIFEST.MF
View
@@ -1,5 +0,0 @@
-Manifest-Version: 1.0
-Built-By: okadri
-Build-Jdk: 1.6.0_65
-Created-By: Maven Integration for Eclipse
-
7 target/classes/META-INF/maven/edu.ucdavis.dss/BannerTest/pom.properties
View
@@ -1,7 +0,0 @@
-#Generated by Maven Integration for Eclipse
-#Tue Feb 25 17:52:32 PST 2014
-version=0.0.1-SNAPSHOT
-groupId=edu.ucdavis.dss
-m2e.projectName=BannerTest
-m2e.projectLocation=/Users/okadri/workspace/BannerTest
-artifactId=BannerTest
35 target/classes/META-INF/maven/edu.ucdavis.dss/BannerTest/pom.xml
View
@@ -1,35 +0,0 @@
-<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>edu.ucdavis.dss</groupId>
- <artifactId>BannerTest</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- <packaging>jar</packaging>
-
- <name>BannerTest</name>
- <url>http://maven.apache.org</url>
-
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.oracle</groupId>
- <artifactId>ojdbc6</artifactId>
- <version>11.2.0.3.0</version>
- </dependency>
- <dependency>
- <groupId>com.mockrunner</groupId>
- <artifactId>mockrunner-core</artifactId>
- <version>1.0.0</version>
- </dependency>
- </dependencies>
-</project>
BIN  target/classes/edu/ucdavis/dss/BannerTest/BannerConnector.class
View
Binary file not shown
BIN  target/classes/edu/ucdavis/dss/BannerTest/BannerTest.class
View
Binary file not shown
BIN  target/classes/edu/ucdavis/dss/BannerTest/PropertiesFile.class
View
Binary file not shown
5 target/maven-archiver/pom.properties
View
@@ -1,5 +0,0 @@
-#Generated by Maven
-#Tue Feb 25 13:21:30 PST 2014
-version=0.0.1-SNAPSHOT
-groupId=edu.ucdavis.dss
-artifactId=BannerTest
69 target/surefire-reports/TEST-edu.ucdavis.dss.BannerTest.AppTest.xml
View
@@ -1,69 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<testsuite failures="0" time="0.014" errors="0" skipped="0" tests="1" name="edu.ucdavis.dss.BannerTest.AppTest">
- <properties>
- <property name="java.runtime.name" value="Java(TM) SE Runtime Environment"/>
- <property name="sun.boot.library.path" value="/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Libraries"/>
- <property name="java.vm.version" value="20.65-b04-462"/>
- <property name="awt.nativeDoubleBuffering" value="true"/>
- <property name="gopherProxySet" value="false"/>
- <property name="mrj.build" value="11M4609"/>
- <property name="java.vm.vendor" value="Apple Inc."/>
- <property name="java.vendor.url" value="http://www.apple.com/"/>
- <property name="path.separator" value=":"/>
- <property name="java.vm.name" value="Java HotSpot(TM) 64-Bit Server VM"/>
- <property name="file.encoding.pkg" value="sun.io"/>
- <property name="user.country" value="US"/>
- <property name="sun.java.launcher" value="SUN_STANDARD"/>
- <property name="sun.os.patch.level" value="unknown"/>
- <property name="java.vm.specification.name" value="Java Virtual Machine Specification"/>
- <property name="user.dir" value="/Users/cthielen/Documents/workspace/BannerTest"/>
- <property name="java.runtime.version" value="1.6.0_65-b14-462-11M4609"/>
- <property name="java.awt.graphicsenv" value="apple.awt.CGraphicsEnvironment"/>
- <property name="basedir" value="/Users/cthielen/Documents/workspace/BannerTest"/>
- <property name="java.endorsed.dirs" value="/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/endorsed"/>
- <property name="os.arch" value="x86_64"/>
- <property name="surefire.real.class.path" value="/Users/cthielen/Documents/workspace/BannerTest/target/surefire/surefirebooter2340541256937747200.jar"/>
- <property name="java.io.tmpdir" value="/var/folders/tn/pycfl_yj0l3f9ny488gjhvp40000gn/T/"/>
- <property name="line.separator" value="
-"/>
- <property name="java.vm.specification.vendor" value="Sun Microsystems Inc."/>
- <property name="os.name" value="Mac OS X"/>
- <property name="sun.jnu.encoding" value="MacRoman"/>
- <property name="java.library.path" value=".:/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java"/>
- <property name="surefire.test.class.path" value="/Users/cthielen/Documents/workspace/BannerTest/target/test-classes:/Users/cthielen/Documents/workspace/BannerTest/target/classes:/Users/cthielen/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar:/opt/oracle/instantclient_11_2/ojdbc6.jar:"/>
- <property name="java.specification.name" value="Java Platform API Specification"/>
- <property name="java.class.version" value="50.0"/>
- <property name="sun.management.compiler" value="HotSpot 64-Bit Tiered Compilers"/>
- <property name="os.version" value="10.9.2"/>
- <property name="http.nonProxyHosts" value="local|*.local|169.254/16|*.169.254/16"/>
- <property name="user.home" value="/Users/cthielen"/>
- <property name="user.timezone" value=""/>
- <property name="java.awt.printerjob" value="apple.awt.CPrinterJob"/>
- <property name="java.specification.version" value="1.6"/>
- <property name="file.encoding" value="MacRoman"/>
- <property name="user.name" value="cthielen"/>
- <property name="java.class.path" value="/Users/cthielen/Documents/workspace/BannerTest/target/test-classes:/Users/cthielen/Documents/workspace/BannerTest/target/classes:/Users/cthielen/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar:/opt/oracle/instantclient_11_2/ojdbc6.jar:"/>
- <property name="java.vm.specification.version" value="1.0"/>
- <property name="sun.arch.data.model" value="64"/>
- <property name="java.home" value="/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home"/>
- <property name="sun.java.command" value="/Users/cthielen/Documents/workspace/BannerTest/target/surefire/surefirebooter2340541256937747200.jar /Users/cthielen/Documents/workspace/BannerTest/target/surefire/surefire3284832312427088441tmp /Users/cthielen/Documents/workspace/BannerTest/target/surefire/surefire3111197951329953476tmp"/>
- <property name="java.specification.vendor" value="Sun Microsystems Inc."/>
- <property name="user.language" value="en"/>
- <property name="awt.toolkit" value="apple.awt.CToolkit"/>
- <property name="java.vm.info" value="mixed mode"/>
- <property name="java.version" value="1.6.0_65"/>
- <property name="java.ext.dirs" value="/Library/Java/Extensions:/System/Library/Java/Extensions:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext"/>
- <property name="sun.boot.class.path" value="/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/jsfd.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar:/System/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport.framework/Resources/Java/JavaRuntimeSupport.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/ui.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/laf.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/sunrsasign.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/jsse.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/jce.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/charsets.jar"/>
- <property name="java.vendor" value="Apple Inc."/>
- <property name="localRepository" value="/Users/cthielen/.m2/repository"/>
- <property name="file.separator" value="/"/>
- <property name="java.vendor.url.bug" value="http://bugreport.apple.com/"/>
- <property name="sun.cpu.endian" value="little"/>
- <property name="sun.io.unicode.encoding" value="UnicodeLittle"/>
- <property name="mrj.version" value="1070.1.6.0_65-462"/>
- <property name="socksNonProxyHosts" value="local|*.local|169.254/16|*.169.254/16"/>
- <property name="ftp.nonProxyHosts" value="local|*.local|169.254/16|*.169.254/16"/>
- <property name="sun.cpu.isalist" value=""/>
- </properties>
- <testcase time="0.001" classname="edu.ucdavis.dss.BannerTest.AppTest" name="testApp"/>
-</testsuite>
4 target/surefire-reports/edu.ucdavis.dss.BannerTest.AppTest.txt
View
@@ -1,4 +0,0 @@
--------------------------------------------------------------------------------
-Test set: edu.ucdavis.dss.BannerTest.AppTest
--------------------------------------------------------------------------------
-Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.014 sec
BIN  target/test-classes/edu/ucdavis/dss/BannerTest/BannerTestTest.class
View
Binary file not shown
Please sign in to comment.
Something went wrong with that request. Please try again.