本文整理汇总了Java中org.eclipse.jetty.testing.HttpTester.setVersion方法的典型用法代码示例。如果您正苦于以下问题:Java HttpTester.setVersion方法的具体用法?Java HttpTester.setVersion怎么用?Java HttpTester.setVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jetty.testing.HttpTester
的用法示例。
在下文中一共展示了HttpTester.setVersion方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例2: 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() );
}
}
示例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() );
}
}
示例4: getStatus
import org.eclipse.jetty.testing.HttpTester; //导入方法依赖的package包/类
public SlaveServerStatus getStatus() {
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() ) );
return SlaveServerStatus.fromXML( response.getContent() );
} catch ( Exception ex ) {
ex.printStackTrace();
}
return null;
}
示例5: testAddTransServlet
import org.eclipse.jetty.testing.HttpTester; //导入方法依赖的package包/类
@Test
public void testAddTransServlet() {
HttpTester request = new HttpTester();
HttpTester response = new HttpTester();
request.setMethod( "GET" );
request.setHeader( "Host", "tester" );
request.setURI( RegisterTransServlet.CONTEXT_PATH + "?xml=Y" );
request.setVersion( "HTTP/1.0" );
try {
TransExecutionConfiguration transExecConfig = new TransExecutionConfiguration();
Trans trans = CarteIT.generateTestTransformation();
TransConfiguration transConfig = new TransConfiguration( trans.getTransMeta(), transExecConfig );
request.setContent( transConfig.getXML() );
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( trans.getName(), null ); // find the first one
Assert.assertNotNull( transStatus );
Assert.assertFalse( transStatus.isPaused() );
Assert.assertFalse( transStatus.isRunning() );
} catch ( Exception ex ) {
ex.printStackTrace();
Assert.fail( ex.getMessage() );
}
}
示例6: 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() );
}
}
示例7: testPauseTransServlet
import org.eclipse.jetty.testing.HttpTester; //导入方法依赖的package包/类
@Test
public void testPauseTransServlet() {
// add our test transformation
testAddTransServlet();
// start our test transformation
testStartTransServlet();
HttpTester request = new HttpTester();
HttpTester response = new HttpTester();
request.setMethod( "GET" );
request.setHeader( "Host", "tester" );
request.setURI( PauseTransServlet.CONTEXT_PATH + "?xml=Y&name=CarteUnitTest" );
request.setVersion( "HTTP/1.0" );
try {
SlaveServerStatus status = getStatus();
SlaveServerTransStatus transStatus = status.findTransStatus( "CarteUnitTest", null );
Assert.assertNotNull( transStatus );
// let's make sure that it is not paused
Assert.assertFalse( transStatus.isPaused() );
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() );
status = getStatus();
transStatus = status.findTransStatus( "CarteUnitTest", null );
Assert.assertNotNull( transStatus );
// now check to be sure it is paused
Assert.assertTrue( transStatus.isPaused() );
} catch ( Exception ex ) {
ex.printStackTrace();
Assert.fail( ex.getMessage() );
}
}