forked from woshizhangbin/12306ngpm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
签入一个完整的可以从客户端使用ajax访问后台restful service的原型实现,可以根据车次号查询和简单的购票.
- Loading branch information
Showing
24 changed files
with
389 additions
and
69 deletions.
There are no files selected for viewing
Empty file.
This file was deleted.
Oops, something went wrong.
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
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,24 @@ | ||
package org.ng12306.tpms; | ||
|
||
import javax.xml.bind.annotation.XmlRootElement; | ||
|
||
@XmlRootElement | ||
public class Order { | ||
// 车次号 | ||
public String train; | ||
|
||
// 上车站点 | ||
public String departure; | ||
|
||
// 下车站点 | ||
public String termination; | ||
|
||
// 座位号 | ||
public String seat; | ||
|
||
// 身份证号 | ||
public String id; | ||
|
||
// 上车时间 | ||
public String date; | ||
} |
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
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
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
43 changes: 43 additions & 0 deletions
43
trunk/tpms/src/test/java/org/ng12306/tpms/TicketResourceTest.java
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,43 @@ | ||
package org.ng12306.tpms; | ||
|
||
import junit.framework.TestCase; | ||
|
||
import com.sun.grizzly.http.SelectorThread; | ||
import com.sun.jersey.api.client.Client; | ||
import com.sun.jersey.api.client.WebResource; | ||
import com.sun.jersey.api.client.ClientResponse; | ||
|
||
public class TicketResourceTest extends TestCase { | ||
private SelectorThread threadSelector; | ||
|
||
private Client c; | ||
|
||
public TicketResourceTest(String testName) { | ||
super(testName); | ||
} | ||
|
||
@Override | ||
protected void setUp() throws Exception { | ||
super.setUp(); | ||
|
||
threadSelector = Main.startServer(); | ||
c = Client.create(); | ||
} | ||
|
||
@Override | ||
protected void tearDown() throws Exception { | ||
super.tearDown(); | ||
|
||
threadSelector.stopEndpoint(); | ||
} | ||
|
||
// 测试根据车次号查询车次 | ||
public void testQueryTrainByTrainNo() { | ||
WebResource r = c.resource(Main.BASE_URI.toString() + "ticket/id/1"); | ||
ClientResponse response = r.get(ClientResponse.class); | ||
assertEquals(200, response.getStatus()); | ||
assertNotNull(response.getEntity(String.class)); | ||
} | ||
|
||
// TODO: 添加更多的测试用例! | ||
} |
62 changes: 62 additions & 0 deletions
62
trunk/tpms/target/surefire-reports/TEST-org.ng12306.tpms.MainTest.xml
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,62 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<testsuite failures="0" time="4.895" errors="0" skipped="0" tests="1" name="org.ng12306.tpms.MainTest"> | ||
<properties> | ||
<property name="java.runtime.name" value="Java(TM) SE Runtime Environment"/> | ||
<property name="sun.boot.library.path" value="/usr/lib/jvm/jdk1.7.0_05/jre/lib/i386"/> | ||
<property name="java.vm.version" value="23.1-b03"/> | ||
<property name="java.vm.vendor" value="Oracle Corporation"/> | ||
<property name="java.vendor.url" value="http://java.oracle.com/"/> | ||
<property name="path.separator" value=":"/> | ||
<property name="guice.disable.misplaced.annotation.check" value="true"/> | ||
<property name="java.vm.name" value="Java HotSpot(TM) Client 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="/vagrant/trunk/tpms"/> | ||
<property name="java.runtime.version" value="1.7.0_05-b06"/> | ||
<property name="java.awt.graphicsenv" value="sun.awt.X11GraphicsEnvironment"/> | ||
<property name="java.endorsed.dirs" value="/usr/lib/jvm/jdk1.7.0_05/jre/lib/endorsed"/> | ||
<property name="os.arch" value="i386"/> | ||
<property name="java.io.tmpdir" value="/tmp"/> | ||
<property name="line.separator" value=" | ||
"/> | ||
<property name="java.vm.specification.vendor" value="Oracle Corporation"/> | ||
<property name="os.name" value="Linux"/> | ||
<property name="classworlds.conf" value="/usr/local/maven/bin/m2.conf"/> | ||
<property name="sun.jnu.encoding" value="ISO-8859-1"/> | ||
<property name="java.library.path" value="/usr/java/packages/lib/i386:/lib:/usr/lib"/> | ||
<property name="java.specification.name" value="Java Platform API Specification"/> | ||
<property name="java.class.version" value="51.0"/> | ||
<property name="sun.management.compiler" value="HotSpot Client Compiler"/> | ||
<property name="os.version" value="2.6.32-38-generic"/> | ||
<property name="user.home" value="/home/vagrant"/> | ||
<property name="user.timezone" value="Europe/Brussels"/> | ||
<property name="java.awt.printerjob" value="sun.print.PSPrinterJob"/> | ||
<property name="file.encoding" value="ISO-8859-1"/> | ||
<property name="java.specification.version" value="1.7"/> | ||
<property name="user.name" value="vagrant"/> | ||
<property name="java.class.path" value="/usr/local/maven/boot/plexus-classworlds-2.4.jar"/> | ||
<property name="java.vm.specification.version" value="1.7"/> | ||
<property name="sun.arch.data.model" value="32"/> | ||
<property name="java.home" value="/usr/lib/jvm/jdk1.7.0_05/jre"/> | ||
<property name="sun.java.command" value="org.codehaus.plexus.classworlds.launcher.Launcher test"/> | ||
<property name="java.specification.vendor" value="Oracle Corporation"/> | ||
<property name="user.language" value="en"/> | ||
<property name="awt.toolkit" value="sun.awt.X11.XToolkit"/> | ||
<property name="java.vm.info" value="mixed mode"/> | ||
<property name="java.version" value="1.7.0_05"/> | ||
<property name="java.ext.dirs" value="/usr/lib/jvm/jdk1.7.0_05/jre/lib/ext:/usr/java/packages/lib/ext"/> | ||
<property name="securerandom.source" value="file:/dev/./urandom"/> | ||
<property name="sun.boot.class.path" value="/usr/lib/jvm/jdk1.7.0_05/jre/lib/resources.jar:/usr/lib/jvm/jdk1.7.0_05/jre/lib/rt.jar:/usr/lib/jvm/jdk1.7.0_05/jre/lib/sunrsasign.jar:/usr/lib/jvm/jdk1.7.0_05/jre/lib/jsse.jar:/usr/lib/jvm/jdk1.7.0_05/jre/lib/jce.jar:/usr/lib/jvm/jdk1.7.0_05/jre/lib/charsets.jar:/usr/lib/jvm/jdk1.7.0_05/jre/lib/jfr.jar:/usr/lib/jvm/jdk1.7.0_05/jre/classes"/> | ||
<property name="java.vendor" value="Oracle Corporation"/> | ||
<property name="maven.home" value="/usr/local/maven"/> | ||
<property name="file.separator" value="/"/> | ||
<property name="java.vendor.url.bug" value="http://bugreport.sun.com/bugreport/"/> | ||
<property name="sun.cpu.endian" value="little"/> | ||
<property name="sun.io.unicode.encoding" value="UnicodeLittle"/> | ||
<property name="sun.cpu.isalist" value=""/> | ||
</properties> | ||
<testcase time="4.781" classname="org.ng12306.tpms.MainTest" name="testApplicationWadl"/> | ||
</testsuite> |
Oops, something went wrong.