我正在运行JUnit测试,并且以下代码卡在行中" server.post(" /..."并且不返回控件(Eclipse中的红色方块按钮)。这是代码和日志。初学者,请帮助。
import org.junit.Test;
/**
* @author jooby generator
*/
public class createTemplateNodeTest extends BaseTest {
@Test
public void testCreateTemplateNode()
throws UnsupportedOperationException, Exception {
System.out.println("started ");
String json = "{\"prefLabel\":\"New Template 1\",\"altLabel\":\"NT\",\"cpus\":\"2\",\"memory\":\"1024\",\"requires\":[\"http://z2c.dts-inc.com/id/7a7dbfb4-e6be-42ed-b78e-8cc6c9853e1b/6.8\",\"http://z2c.dts-inc.com/id/12114f34-1bce-4417-9aea-d94da009efe4/5.5\"]}";
server.post("/api/createTemplateNode").body(json, "application/json").expect(200)
.header("Content-Type", "application/json;charset=UTF-8");
System.out.println("ended");
}
}
BaseTest类是:
import org.jooby.test.AppRule;
import org.jooby.test.Client;
import org.junit.ClassRule;
import org.junit.Rule;
import com.dts_inc.z2c.z2c_ws.App;
/**
* @author jooby generator
*/
public class BaseTest {
/**
* One app/server for all the test of this class. If you want to start/stop a new server per test,
* remove the static modifier and replace the {@link ClassRule} annotation with {@link Rule}.
*/
// @ClassRule
@Rule
// public static AppRule app = new AppRule(new App());
public AppRule app = new AppRule(new App());
/**
* One client per test. It creates a new HTTP client per each of the test method you have.
*/
@Rule
public Client server = new Client("http://localhost:9090");
}
生成的日志(在Eclipse中)是:
started
[2016-08-24 14:20:18,832]-[netty task-3-1] DEBUG com.dts_inc.z2c.z2c_ws.App - Incoming request:
[2016-08-24 14:20:18,832]-[netty task-3-1] DEBUG com.dts_inc.z2c.z2c_ws.App - temp2...<http://z2c.dts-inc.com/id/f12847dd-db2a-4539-8ce1-19b9e8bd9df1> sys:requires <http://z2c.dts-inc.com/id/7a7dbfb4-e6be-42ed-b78e-8cc6c9853e1b/6.8>.
[2016-08-24 14:20:18,832]-[netty task-3-1] DEBUG com.dts_inc.z2c.z2c_ws.App - temp2...<http://z2c.dts-inc.com/id/f12847dd-db2a-4539-8ce1-19b9e8bd9df1> sys:requires <http://z2c.dts-inc.com/id/12114f34-1bce-4417-9aea-d94da009efe4/5.5>.
[2016-08-24 14:20:18,832]-[netty task-3-1] DEBUG com.dts_inc.z2c.z2c_ws.App - # Template Node Configuration
@prefix : <http://z2c.dts-inc.com/id/>.
@prefix cpe: <http://cpe.mitre.org/dictionary/2.0/>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix owl: <http://www.w3.org/2002/07/owl#>.
@prefix sys: <http://www.dts-inc.com/systemspec#>.
@prefix ver: <http://www.dts-inc.com/versioned#>.
@prefix tag: <http://www.dts-inc.com/asset#>.
@prefix org: <http://www.w3.org/ns/org#>.
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
@prefix skos: <http://www.w3.org/2004/02/skos/core#>.
@prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>.
:f12847dd-db2a-4539-8ce1-19b9e8bd9df1 a sys:TemplateNode;
ver:hasHead <http://z2c.dts-inc.com/id/f12847dd-db2a-4539-8ce1-19b9e8bd9df1/2016-08-24T18:20Z>.
<http://z2c.dts-inc.com/id/f12847dd-db2a-4539-8ce1-19b9e8bd9df1/2016-08-24T18:20Z>
a sys:TemplateNode;
skos:prefLabel "New Template 1";
skos:altLabel "NT";
ver:firtVersion "true"^^xsd:boolean;
ver:timeStampVersion "2016-08-24T18:20Z"^^xsd:dateTime;
ver:isVersionOf :f12847dd-db2a-4539-8ce1-19b9e8bd9df1;
tag:cpus "2";
tag:memory "1024".
<http://z2c.dts-inc.com/id/f12847dd-db2a-4539-8ce1-19b9e8bd9df1> sys:requires <http://z2c.dts-inc.com/id/7a7dbfb4-e6be-42ed-b78e-8cc6c9853e1b/6.8>.
<http://z2c.dts-inc.com/id/f12847dd-db2a-4539-8ce1-19b9e8bd9df1> sys:requires <http://z2c.dts-inc.com/id/12114f34-1bce-4417-9aea-d94da009efe4/5.5>.
[2016-08-24 14:20:18,864]-[RxComputationScheduler-1] DEBUG com.dts_inc.z2c.module.sparql.SparqlClient - executeQuery++
[2016-08-24 14:20:18,864]-[RxComputationScheduler-1] DEBUG com.dts_inc.z2c.module.sparql.SparqlClientHandler - SparqlClientHandler Ctor
[2016-08-24 14:20:18,864]-[RxComputationScheduler-1] DEBUG com.dts_inc.z2c.module.sparql.SparqlClientInitializer - Intializer Ctor
[2016-08-24 14:20:18,864]-[RxComputationScheduler-1] DEBUG com.dts_inc.z2c.module.sparql.SparqlClientInitializer - Instance: com.dts_inc.z2c.module.sparql.SparqlClientInitializer@18f177a
[2016-08-24 14:20:18,864]-[RxComputationScheduler-1] DEBUG com.dts_inc.z2c.module.sparql.SparqlClientInitializer - Handler: com.dts_inc.z2c.module.sparql.SparqlClientHandler@4c53aa
[2016-08-24 14:20:18,864]-[RxComputationScheduler-1] DEBUG com.dts_inc.z2c.module.sparql.SparqlClient - Uri: http://cmoe3lblazegraph01.cmoa3s.com:8080/blazegraph/namespace/nairv/sparql
[2016-08-24 14:20:18,864]-[RxComputationScheduler-1] DEBUG com.dts_inc.z2c.module.sparql.SparqlClient - Connecting.
[2016-08-24 14:20:18,879]-[nioEventLoopGroup-5-1] DEBUG com.dts_inc.z2c.module.sparql.SparqlClientInitializer - Pipeline Handler: com.dts_inc.z2c.module.sparql.SparqlClientHandler@4c53aa
[2016-08-24 14:20:19,035]-[nioEventLoopGroup-5-1] DEBUG com.dts_inc.z2c.module.sparql.SparqlClientHandler - STATUS: 200 OK
[2016-08-24 14:20:19,035]-[nioEventLoopGroup-5-1] DEBUG com.dts_inc.z2c.module.sparql.SparqlClientHandler - VERSION: HTTP/1.1
[2016-08-24 14:20:19,035]-[nioEventLoopGroup-5-1] DEBUG com.dts_inc.z2c.module.sparql.SparqlClientHandler - HEADER: Server = Apache-Coyote/1.1
[2016-08-24 14:20:19,035]-[nioEventLoopGroup-5-1] DEBUG com.dts_inc.z2c.module.sparql.SparqlClientHandler - HEADER: Content-Type = application/xml;charset=ISO-8859-1
[2016-08-24 14:20:19,035]-[nioEventLoopGroup-5-1] DEBUG com.dts_inc.z2c.module.sparql.SparqlClientHandler - HEADER: Content-Length = 61
[2016-08-24 14:20:19,035]-[nioEventLoopGroup-5-1] DEBUG com.dts_inc.z2c.module.sparql.SparqlClientHandler - HEADER: Date = Wed, 24 Aug 2016 18:20:12 GMT
[2016-08-24 14:20:19,035]-[nioEventLoopGroup-5-1] DEBUG com.dts_inc.z2c.module.sparql.SparqlClientHandler - HEADER: Connection = close
[2016-08-24 14:20:19,035]-[nioEventLoopGroup-5-1] DEBUG com.dts_inc.z2c.module.sparql.SparqlClientHandler - CONTENT {
[2016-08-24 14:20:19,035]-[nioEventLoopGroup-5-1] DEBUG com.dts_inc.z2c.module.sparql.SparqlClientHandler - Chunks initialized.
[2016-08-24 14:20:19,035]-[nioEventLoopGroup-5-1] DEBUG com.dts_inc.z2c.module.sparql.SparqlClientHandler - <?xml version="1.0"?><data modified="12" milliseconds="120"/>
[2016-08-24 14:20:19,035]-[nioEventLoopGroup-5-1] DEBUG com.dts_inc.z2c.module.sparql.SparqlClientHandler - } END OF CONTENT
[2016-08-24 14:20:19,035]-[nioEventLoopGroup-5-1] DEBUG com.dts_inc.z2c.module.sparql.SparqlClientHandler - Subscriber in handler: rx.internal.operators.OperatorMap$MapSubscriber@1e8e0ae
[2016-08-24 14:20:19,035]-[nioEventLoopGroup-5-1] DEBUG com.dts_inc.z2c.module.sparql.SparqlClientHandler - Chunks: UnpooledUnsafeHeapByteBuf(ridx: 0, widx: 61, cap: 61)