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


Java HttpTester.parse方法代码示例

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


在下文中一共展示了HttpTester.parse方法的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: 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

示例4: 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

示例5: 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

示例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("/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

示例7: 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

示例8: 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

示例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("/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

示例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("/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

示例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("/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

示例12: testStartTransServlet

import org.eclipse.jetty.testing.HttpTester; //导入方法依赖的package包/类
@Test
public void testStartTransServlet() {

  // add our test transformation
  testAddTransServlet();

  HttpTester request = new HttpTester();
  HttpTester response = new HttpTester();
  request.setMethod( "GET" );
  request.setHeader( "Host", "tester" );
  request.setURI( StartTransServlet.CONTEXT_PATH + "?xml=Y&name=CarteUnitTest" );
  request.setVersion( "HTTP/1.0" );
  try {
    response.parse( tester.getResponses( request.generate() ) );

    Document document = XMLHandler.loadXMLString( response.getContent() );
    NodeList nodes = document.getElementsByTagName( "result" );
    Assert.assertEquals( 1, nodes.getLength() );
    Assert.assertEquals( WebResult.STRING_OK, nodes.item( 0 ).getTextContent() );

    SlaveServerStatus status = getStatus();
    SlaveServerTransStatus transStatus = status.findTransStatus( "CarteUnitTest", null );
    Assert.assertNotNull( transStatus );
    Assert.assertFalse( transStatus.isPaused() );
    Assert.assertTrue( transStatus.isRunning() );

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

示例13: 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

示例14: 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

示例15: 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("/user/json");
    resp.parse(tester.getResponses(req.generate()));
    
    System.out.println(resp.getContent());
    
    Gson gson = new Gson();
    StubUser su = gson.fromJson(resp.getContent(), StubUser.class);
    
    assertEquals(200, resp.getStatus());
    assertEquals(su.getId(), 1);
    assertEquals(su.getEmail(), "[email protected]");
    assertEquals(su.getLanguage(), "fi");
    assertEquals(su.getNetid(), "1");
    assertEquals(su.getFullname(), "testi testaaja");
    assertEquals(su.getFirstname(), "testi");
    assertEquals(su.getLastname(), "testaaja");
    assertEquals(su.isCan_login(), true);
    assertEquals(su.isRequire_certificate(), false);
    assertEquals(su.isSelf_registered(), true);
}
 
开发者ID:anis-moubarik,项目名称:SimpleREST,代码行数:28,代码来源:UserResourceTest.java


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