• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java HttpTester类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: 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("/bitstream/json");
    resp.parse(tester.getResponses(req.generate()));
    
    Gson gson = new Gson();
    
    System.out.println(resp.getContent());
    StubBitstream sb = gson.fromJson(resp.getContent(), StubBitstream.class);
    
    assertEquals(200, resp.getStatus());
    assertEquals(sb.getId(), 1);
    assertEquals(sb.getDescription(), "");
    assertEquals(sb.getName(), "testi.pdf");
    assertEquals(sb.getSizebytes().compareTo(1337L), 0);
    assertEquals(sb.getUserformatdescription(), "");
    assertEquals(sb.getMimetype(), "application/pdfs");
}
 
开发者ID:anis-moubarik,项目名称:SimpleREST,代码行数:24,代码来源:BitstreamResourceTest.java


示例17: testGetRootServlet

import org.eclipse.jetty.testing.HttpTester; //导入依赖的package包/类
@Test
public void testGetRootServlet() {
  HttpTester request = new HttpTester();
  HttpTester response = new HttpTester();
  request.setMethod( "GET" );
  request.setHeader( "Host", "tester" );
  request.setURI( GetRootServlet.CONTEXT_PATH );
  request.setVersion( "HTTP/1.0" );
  try {
    response.parse( tester.getResponses( request.generate() ) );

    Node document = parse( response.getContent() );
    String title = BaseMessages.getString( GetRootServlet.class, "GetRootServlet.KettleSlaveServer.Title" );
    Assert.assertEquals( title, findTextNode( document, "TITLE" ).getTextContent() );
    String menu = BaseMessages.getString( GetRootServlet.class, "GetRootServlet.SlaveServerMenu" );
    Assert.assertEquals( menu, findTextNode( document, "H2" ).getTextContent() );
    String status = BaseMessages.getString( GetRootServlet.class, "GetRootServlet.ShowStatus" );
    Assert.assertEquals( status, findTextNode( document, "A" ).getTextContent() );

  } catch ( Exception ex ) {
    ex.printStackTrace();
    Assert.fail( ex.getMessage() );
  }
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:25,代码来源:CarteIT.java


示例18: testGetStatusServlet

import org.eclipse.jetty.testing.HttpTester; //导入依赖的package包/类
@Test
public void testGetStatusServlet() {
  HttpTester request = new HttpTester();
  HttpTester response = new HttpTester();
  request.setMethod( "GET" );
  request.setHeader( "Host", "tester" );
  request.setURI( GetStatusServlet.CONTEXT_PATH + "?xml=Y" );
  request.setVersion( "HTTP/1.0" );
  try {
    response.parse( tester.getResponses( request.generate() ) );
    // just test if we actually can create a SlaveServerStatus from the webservice
    // and that it is the same going in as out
    String xml =
      XMLHandler.getXMLHeader( Const.XML_ENCODING )
        + SlaveServerStatus.fromXML( response.getContent() ).getXML();
    Assert.assertEquals( response.getContent().trim(), xml.trim() );
  } catch ( Exception ex ) {
    ex.printStackTrace();
    Assert.fail( ex.getMessage() );
  }
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:22,代码来源:CarteIT.java


示例19: 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("/item/xml");
    resp.parse(tester.getResponses(req.generate()));
    System.out.println(resp.getContent());
    
    assertEquals(200, resp.getStatus());
    assertEquals(resp.getContent().contains("dc.contributor.author"), true);
    assertEquals(resp.getContent().contains("dc.date.issued"), true);
}
 
开发者ID:anis-moubarik,项目名称:SimpleREST,代码行数:16,代码来源:ItemResourceTest.java


示例20: 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("/item/json");
    resp.parse(tester.getResponses(req.generate()));
    System.out.println(resp.getContent());
    System.out.println("RESPONSE!!!!"+resp.getStatus());
    if(resp.getStatus() == 304){
        return;
    }
    Gson gson = new Gson();
    StubItem si = gson.fromJson(resp.getContent(), StubItem.class);

    
    assertEquals(200, resp.getStatus());
    assertEquals(si.in_archive(), true);
    assertEquals(si.getOwningCollectionID(), 0);
    assertEquals(si.withdrawn(), false);
    assertEquals(si.getId(), 1);
    
    DCValue[] metadata = si.getMetadata();
    assertEquals(metadata[0].schema, "dc");
    assertEquals(metadata[0].element, "contributor");
    assertEquals(metadata[0].qualifier, "author");
    assertEquals(metadata[0].value, "Testi Testaaja");
    
    assertEquals(metadata[1].schema, "dc");
    assertEquals(metadata[1].element, "date");
    assertEquals(metadata[1].qualifier, "issued");
    assertEquals(metadata[1].value, "2013");
}
 
开发者ID:anis-moubarik,项目名称:SimpleREST,代码行数:36,代码来源:ItemResourceTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SimpleTextExtractionStrategy类代码示例发布时间:2022-05-22
下一篇:
Java NameProvider类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap