当前位置: 首页>>代码示例>>Java>>正文


Java HttpTester类代码示例

本文整理汇总了Java中org.eclipse.jetty.testing.HttpTester的典型用法代码示例。如果您正苦于以下问题:Java HttpTester类的具体用法?Java HttpTester怎么用?Java HttpTester使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


HttpTester类属于org.eclipse.jetty.testing包,在下文中一共展示了HttpTester类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: servletOutput

import org.eclipse.jetty.testing.HttpTester; //导入依赖的package包/类
@Test
public void servletOutput() throws Exception {
  ServletTester container = new ServletTester();
  container.setContextPath("/context");
  container.addServlet(HelloServlet.class, "/*");
  container.start();

  HttpTester request = new HttpTester();
  request.setMethod("GET");
  request.setURI("/context/foo/bar");
  request.setVersion("HTTP/1.0");

  HttpTester response = new HttpTester();
  response.parse(container.getResponses(request.generate()));

  assertEquals(200, response.getStatus());
  assertEquals("Servlet says Hello!\npathinfo = /foo/bar\n", response.getContent());
  assertEquals("text/plain;charset=UTF-8", response.getHeader("Content-Type"));

  container.stop();
}
 
开发者ID:bitmelt,项目名称:maven-servlet-template,代码行数:22,代码来源:HelloServletTest.java

示例2: testGetXml

import org.eclipse.jetty.testing.HttpTester; //导入依赖的package包/类
@Test
public void testGetXml() throws IOException, Exception{
    HttpTester req = new HttpTester();
    HttpTester resp = new HttpTester();
    
    req.setMethod("GET");
    req.setHeader("HOST", "tester");
    req.setURI("/rootcommunities/xml");
    resp.parse(tester.getResponses(req.generate()));
    
    System.out.println(resp.getContent());
    
    assertEquals(200, resp.getStatus());
    assertEquals(resp.getContent().contains("test"), true);
    assertEquals(resp.getContent().contains("Root"), true);
    assertEquals(resp.getContent().contains("community/1"), true);
}
 
开发者ID:anis-moubarik,项目名称:SimpleREST,代码行数:18,代码来源:RootCommunitiesResourceTest.java

示例3: testGetJson

import org.eclipse.jetty.testing.HttpTester; //导入依赖的package包/类
@Test
public void testGetJson() throws IOException, Exception{
    HttpTester req = new HttpTester();
    HttpTester resp = new HttpTester();
    
    req.setMethod("GET");
    req.setHeader("HOST", "tester");
    req.setURI("/rootcommunities/json");
    resp.parse(tester.getResponses(req.generate()));
    
    System.out.println(resp.getContent());
    
    assertEquals(200, resp.getStatus());
    Gson gson = new Gson();
    
    StubCommunity[] communities = gson.fromJson(resp.getContent(), StubCommunity[].class);
    
    assertEquals(communities.length, 2);
    assertEquals(communities[0].getId(), 1);
}
 
开发者ID:anis-moubarik,项目名称:SimpleREST,代码行数:21,代码来源:RootCommunitiesResourceTest.java

示例4: testGetXml

import org.eclipse.jetty.testing.HttpTester; //导入依赖的package包/类
@Test
public void testGetXml() throws IOException, Exception{
    HttpTester req = new HttpTester();
    HttpTester resp = new HttpTester();
    
    req.setMethod("GET");
    req.setHeader("HOST", "tester");
    req.setURI("/user/xml");
    resp.parse(tester.getResponses(req.generate()));
    System.out.println(resp.getContent());
    
    assertEquals(200, resp.getStatus());
    String[] attributes = {"email", "id", "language", "netid", "fullname", "firstname",
    "lastname", "can login", "require certificate", "self registered"};
    for(String attribute : attributes){
        assertEquals(resp.getContent().contains(attribute), true);
    }
    
    String[] values = {"test(a)test.com", "fi", "1", "testi testaaja", "testi", "testaaja", "false", "true"};
    
    for(String value : values){
        assertEquals(resp.getContent().contains(value), true);
    }
}
 
开发者ID:anis-moubarik,项目名称:SimpleREST,代码行数:25,代码来源:UserResourceTest.java

示例5: testGetXml

import org.eclipse.jetty.testing.HttpTester; //导入依赖的package包/类
@Test
public void testGetXml() throws Exception {
    HttpTester req = new HttpTester();
    HttpTester res = new HttpTester();
    
    req.setMethod("GET");
    req.setHeader("HOST", "tester"); 
    req.setURI("/groups/xml");
    res.parse(tester.getResponses(req.generate()));
    System.out.println(res.getContent());
    assertEquals(200, res.getStatus());
    
    String[] attributes = {"id","href"};
    for(String attribute : attributes){
        assertEquals(res.getContent().contains(attribute), true);
    }
    
    String[] values = {"testGroup", "/group/1"};
    for(String value : values){
        assertEquals(res.getContent().contains(value), true);
    }
}
 
开发者ID:anis-moubarik,项目名称:SimpleREST,代码行数:23,代码来源:GroupsResourceTest.java

示例6: testGetXml

import org.eclipse.jetty.testing.HttpTester; //导入依赖的package包/类
@Test
public void testGetXml() throws IOException, Exception{
    HttpTester req = new HttpTester();
    HttpTester resp = new HttpTester();
    
    req.setMethod("GET");
    req.setHeader("HOST", "tester");
    req.setURI("/community/xml");
    resp.parse(tester.getResponses(req.generate()));
    
    System.out.println(resp.getContent());
    assertEquals(200, resp.getStatus());
    String[] attributes = { "short_description", "introductory_text",
                            "copyright_text", "side_bar_text" };        
    for(String attribute : attributes){
        assertEquals(resp.getContent().contains(attribute), true);
    }
}
 
开发者ID:anis-moubarik,项目名称:SimpleREST,代码行数:19,代码来源:CommunityResourceTest.java

示例7: testGetJson

import org.eclipse.jetty.testing.HttpTester; //导入依赖的package包/类
@Test
public void testGetJson() throws IOException, Exception{
    HttpTester req = new HttpTester();
    HttpTester resp = new HttpTester();
    
    req.setMethod("GET");
    req.setHeader("HOST", "tester");
    req.setURI("/community/json");
    resp.parse(tester.getResponses(req.generate()));
    Gson gson = new Gson();
    System.out.println(resp.getContent());
    StubCommunity sc = gson.fromJson(resp.getContent(), StubCommunity.class);
    assertEquals(200, resp.getStatus());
    assertEquals(sc.getId(), 1);
    assertEquals(sc.getName(), "test");
    assertEquals(sc.getCopyright_text(), "testi copyright");
    assertEquals(sc.getIntroductory_text(), "testi intro");
    assertEquals(sc.getShort_description(), "testi kuvaus");
    assertEquals(sc.getSide_bar_text(), "testi sidebar");
}
 
开发者ID:anis-moubarik,项目名称:SimpleREST,代码行数:21,代码来源:CommunityResourceTest.java

示例8: testEdit

import org.eclipse.jetty.testing.HttpTester; //导入依赖的package包/类
/**
 * Test of edit method, of class CommunityResource.
 */
@Test
public void testEdit() throws IOException, Exception {
    HttpTester req = new HttpTester();
    HttpTester resp = new HttpTester();
    
    req.setMethod("PUT");
    req.setHeader("HOST", "tester");
    req.setURI("/community/edit");
    resp.parse(tester.getResponses(req.generate()));
    System.out.println(resp.getContent());
    assertEquals(200, resp.getStatus());
    String[] attributes = { "short_description", "introductory_text",
                            "copyright_text", "side_bar_text" };        
    for(String attribute : attributes){
        assertEquals(resp.getContent().contains(attribute), true);
    }
}
 
开发者ID:anis-moubarik,项目名称:SimpleREST,代码行数:21,代码来源:CommunityResourceTest.java

示例9: testGetXml

import org.eclipse.jetty.testing.HttpTester; //导入依赖的package包/类
@Test
public void testGetXml() throws IOException, Exception{
    HttpTester req = new HttpTester();
    HttpTester resp = new HttpTester();
    
    req.setMethod("GET");
    req.setHeader("HOST", "tester");
    req.setURI("/metadatafield/xml");
    resp.parse(tester.getResponses(req.generate()));
    
    String content = resp.getContent();
    
    assertEquals(200, resp.getStatus());
    String[] attributes = {"schema", "element", "qualifier", "scopenote"};
    for(String attribute : attributes){
        assertEquals(content.contains(attribute), true);
    }
    
    String[] values = {"dckk", "testElement", "testQualifier", "Description"};
    for(String value : values){
        assertEquals(content.contains(value), true);
    }
}
 
开发者ID:anis-moubarik,项目名称:SimpleREST,代码行数:24,代码来源:MetadataFieldResourceTest.java

示例10: testJson

import org.eclipse.jetty.testing.HttpTester; //导入依赖的package包/类
@Test
public void testJson() throws IOException, Exception{
    HttpTester req = new HttpTester();
    HttpTester resp = new HttpTester();
    
    req.setMethod("GET");
    req.setHeader("HOST", "tester");
    req.setURI("/metadatafield/json");
    resp.parse(tester.getResponses(req.generate()));
    System.out.println(resp.getContent());
    Gson gson = new Gson();
    
    StubMetadata sm = gson.fromJson(resp.getContent(), StubMetadata.class);
    
    assertEquals(200, resp.getStatus());
    assertEquals(sm.getElement(), "testElement");
    assertEquals(sm.getId(), 1);
    assertEquals(sm.getSchema(), "dckk");
    assertEquals(sm.getQualifier(), "testQualifier");
    assertEquals(sm.getScopeNote(), "Description");
}
 
开发者ID:anis-moubarik,项目名称:SimpleREST,代码行数:22,代码来源:MetadataFieldResourceTest.java

示例11: testGetXml

import org.eclipse.jetty.testing.HttpTester; //导入依赖的package包/类
@Test
public void testGetXml() throws IOException, Exception{    
    
    HttpTester req = new HttpTester();
    HttpTester resp = new HttpTester();
    
    req.setMethod("GET");
    req.setHeader("HOST", "tester");
    req.setURI("/group/xml");
    resp.parse(tester.getResponses(req.generate()));
    System.out.println("");
    System.out.println(resp.getContent());
    System.out.println("");
    assertEquals(200, resp.getStatus());
    /*String[] attributes = { "name"};        
    for(String attribute : attributes){
        assertEquals(resp.getContent().contains(attribute), true);
    }*/
    //assertEquals(true, true);
}
 
开发者ID:anis-moubarik,项目名称:SimpleREST,代码行数:21,代码来源:GroupResourceTest.java

示例12: testGetXml

import org.eclipse.jetty.testing.HttpTester; //导入依赖的package包/类
@Test
public void testGetXml() throws IOException, Exception{
    HttpTester req = new HttpTester();
    HttpTester resp = new HttpTester();
    
    req.setMethod("GET");
    req.setHeader("HOST", "tester");
    req.setURI("/metadataschema/xml");
    resp.parse(tester.getResponses(req.generate()));
    
    String content = resp.getContent();
    
    assertEquals(200, resp.getStatus());
    String[] attributes = {"name", "namespace"};
    for(String attribute : attributes){
        assertEquals(content.contains(attribute), true);
    }
    
    String[] values = {"dckk", "http://kk.fi/dckk/"};
    for(String value : values){
        assertEquals(content.contains(value), true);
    }
}
 
开发者ID:anis-moubarik,项目名称:SimpleREST,代码行数:24,代码来源:MetadataSchemaResourceTest.java

示例13: testJson

import org.eclipse.jetty.testing.HttpTester; //导入依赖的package包/类
@Test
public void testJson() throws IOException, Exception{
    HttpTester req = new HttpTester();
    HttpTester resp = new HttpTester();
    
    req.setMethod("GET");
    req.setHeader("HOST", "tester");
    req.setURI("/metadataschema/json");
    resp.parse(tester.getResponses(req.generate()));
    Gson gson = new Gson();
    
    StubSchema ss = gson.fromJson(resp.getContent(), StubSchema.class);
    
    assertEquals(200, resp.getStatus());
    assertEquals(ss.getId(), 1);
    assertEquals(ss.getName(), "dckk");
    assertEquals(ss.getNamespace(), "http://kk.fi/dckk/");
}
 
开发者ID:anis-moubarik,项目名称:SimpleREST,代码行数:19,代码来源:MetadataSchemaResourceTest.java

示例14: testGetXml

import org.eclipse.jetty.testing.HttpTester; //导入依赖的package包/类
@Test
public void testGetXml() throws Exception {
    HttpTester req = new HttpTester();
    HttpTester res = new HttpTester();

    req.setMethod("GET");
    req.setHeader("HOST", "tester");
    req.setURI("/users/xml");
    res.parse(tester.getResponses(req.generate()));
    System.out.println(res.getContent());
    assertEquals(200, res.getStatus());

    String[] attributes = {"/user/12341", "/user/12342"};
    for (String attribute : attributes) {
        assertEquals(res.getContent().contains(attribute), true);
    }

    String[] values = {"testi testaaja1", "testi testaaja2"};

    for (String value : values) {
        assertEquals(res.getContent().contains(value), true);
    }
}
 
开发者ID:anis-moubarik,项目名称:SimpleREST,代码行数:24,代码来源:UsersResourceTest.java

示例15: testGetXml

import org.eclipse.jetty.testing.HttpTester; //导入依赖的package包/类
@Test
public void testGetXml() throws IOException, Exception{
    HttpTester req = new HttpTester();
    HttpTester resp = new HttpTester();
    
    req.setMethod("GET");
    req.setHeader("HOST", "tester");
    req.setURI("/bitstream/xml");
    resp.parse(tester.getResponses(req.generate()));
    System.out.println(resp.getContent());
    
    String response = resp.getContent();
    
    assertEquals(200, resp.getStatus());
    String[] attributes = {"name", "mimetype", "description", "userformatdescription", "source", "sequenceid", "sizebytes"};
    for(String attribute : attributes){
        assertEquals(response.contains(attribute), true);
    }
    
    String[] values = {"testi.pdf", "application/pdfs", "1337"};
    for(String value : values){
        assertEquals(response.contains(value), true);
    }
}
 
开发者ID:anis-moubarik,项目名称:SimpleREST,代码行数:25,代码来源:BitstreamResourceTest.java


注:本文中的org.eclipse.jetty.testing.HttpTester类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。