本文整理匯總了Java中org.restlet.data.Protocol.HTTP屬性的典型用法代碼示例。如果您正苦於以下問題:Java Protocol.HTTP屬性的具體用法?Java Protocol.HTTP怎麽用?Java Protocol.HTTP使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.restlet.data.Protocol
的用法示例。
在下文中一共展示了Protocol.HTTP屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testListPaging
@Test
public void testListPaging() throws Exception {
Component component = new Component();
component.getServers().add(Protocol.HTTP, port);
component.getDefaultHost().attach(setupAppPaging());
component.start();
try {
Client client = new Client(Protocol.HTTP);
long count = getCount(client, "READY");
assertEquals(pagingTotal, count);
Collection<FileTrackingStatus> statusObjColl = getStatusObject(
client, "READY", 0, 30);
assertEquals(30, statusObjColl.size());
} finally {
component.stop();
}
}
示例2: testGetsStatus
@Test
public void testGetsStatus() throws Exception {
Component component = new Component();
component.getServers().add(Protocol.HTTP, port);
component.getDefaultHost().attach(setupApp());
component.start();
try {
Client client = new Client(Protocol.HTTP);
for(File file: Arrays.asList(new File("test1.txt"), new File("test2.txt"), new File("test3.txt"))){
FileTrackingStatus status = getStatusObject(client, file.getAbsolutePath());
assertNotNull(status);
assertEquals(file.getAbsolutePath(), status.getPath());
}
} finally {
component.stop();
}
}
示例3: main
public static void main( String[] args )
throws Exception
{
Energy4Java polygene = new Energy4Java( );
Server server = new Server( Protocol.HTTP, 8888 );
Application app = polygene.newApplication( new ForumAssembler(), new MetadataService() );
app.activate();
ContextRestlet restlet = app.findModule( "REST", "Restlet" ).newObject( ContextRestlet.class, new org.restlet.Context() );
ChallengeAuthenticator guard = new ChallengeAuthenticator(null, ChallengeScheme.HTTP_BASIC, "testRealm");
MapVerifier mapVerifier = new MapVerifier();
mapVerifier.getLocalSecrets().put("rickard", "secret".toCharArray());
guard.setVerifier(mapVerifier);
guard.setNext(restlet);
server.setNext( restlet );
server.start();
}
示例4: pullData
/**
* Pulls data from CloudStack API
*
* @return JSON string
* @throws IOException
*/
private String pullData() throws IOException {
logger.trace("Starting to pull data from provided URL");
// create connection
Client client = new Client(Protocol.HTTP);
ClientResource cr = new ClientResource(url);
Request req = cr.getRequest();
// now header
Series<Header> headerValue = new Series<Header>(Header.class);
req.getAttributes().put(HeaderConstants.ATTRIBUTE_HEADERS, headerValue);
headerValue.add("Accept", "application/json");
headerValue.add("Content-Type", "application/json");
// fire it up
cr.get(MediaType.APPLICATION_JSON);
Representation output = cr.getResponseEntity();
logger.trace("Successfully pulled data from provided URL");
// and return response data
return output.getText();
}
示例5: setUp
@Before
public void setUp() {
ServerManager.getInstance().setServer(new StubMCServer());
component = new Component();
client = new Client(Protocol.HTTP);
// Add a new HTTP server listening on port 8182.
component.getServers().add(Protocol.HTTP, port);
// Attach the sample application.
component.getDefaultHost().attach("/mcrest", new RestApplication());
try {
component.start();
} catch (Exception e) {
e.printStackTrace();
}
serverUrl = "http://127.0.0.1:"+port+"/mcrest";
}
示例6: pullData
/**
* Pull data from provided URL
* @param url
* @return output string or empty string
*/
private String pullData(String url) throws IOException {
Client client = new Client(Protocol.HTTP);
ClientResource cr = new ClientResource(url);
Request req = cr.getRequest();
// now header
Series<Header> headerValue = new Series<Header>(Header.class);
req.getAttributes().put(HeaderConstants.ATTRIBUTE_HEADERS, headerValue);
headerValue.add("Accept", "application/json");
headerValue.add("Content-Type", "application/json");
// fire it up
cr.get(MediaType.APPLICATION_JSON);
Representation output = cr.getResponseEntity();
// return null or received text
return (output == null) ? "" : output.getText();
}
示例7: pullData
/**
* Pull data from provided URL
*
* @param url
* @return output string
*/
private String pullData(String url) throws IOException {
Client client = new Client(Protocol.HTTP);
ClientResource cr = new ClientResource(url);
Request req = cr.getRequest();
// now header
Series<Header> headerValue = new Series<Header>(Header.class);
req.getAttributes().put(HeaderConstants.ATTRIBUTE_HEADERS, headerValue);
headerValue.add("Accept", "application/json");
headerValue.add("Content-Type", "application/json");
// fire it up
cr.get(MediaType.APPLICATION_JSON);
Representation output = cr.getResponseEntity();
// and return response data
return output.getText();
}
示例8: LRSystemComponent
/**
* Constructor.
*
* @throws Exception
*/
public LRSystemComponent() throws Exception {
// Set basic properties
setName("License Recognition Server");
setDescription("License Recognition");
setOwner("Software college");
setAuthor("Justin Yang");
// Add connectors
getClients().add(new Client(Protocol.CLAP));
getClients().add(new Client(Protocol.FILE));
Server server = new Server(new Context(), Protocol.HTTP, 8183);
// Tracing
getServers().add(server);
LRSystemApplication app = new LRSystemApplication();
// Configure the default virtual host
VirtualHost host = getDefaultHost();
// Attach the application to the default virtual host
host.attachDefault(app);
}
示例9: beforeSuite
@BeforeSuite
public void beforeSuite() throws Exception {
// TODO: use logging.properties file to config java.util.logging.Logger levels
java.util.logging.Logger topJavaLogger = java.util.logging.Logger.getLogger("");
topJavaLogger.setLevel(Level.WARNING);
// start zk
_zkServer = TestHelper.startZkServer(ZK_ADDR);
AssertJUnit.assertTrue(_zkServer != null);
ZKClientPool.reset();
_gZkClient =
new ZkClient(ZK_ADDR, ZkClient.DEFAULT_CONNECTION_TIMEOUT,
ZkClient.DEFAULT_SESSION_TIMEOUT, new ZNRecordSerializer());
_gSetupTool = new ClusterSetup(_gZkClient);
// start admin
_adminThread = new AdminThread(ZK_ADDR, ADMIN_PORT);
_adminThread.start();
// create a client
_gClient = new Client(Protocol.HTTP);
// wait for the web service to start
Thread.sleep(100);
}
示例10: main
public static void main(String[] args) {
Server server = new Server(Protocol.HTTP, port, new RestletApplication());
System.out.println("Start catalog search REST Server...");
try {
server.start();
} catch (Exception e) {
e.printStackTrace();
}
}
示例11: main
public static void main(String[] args) throws Exception {
Component component = new Component();
component.getClients().add(Protocol.FILE);
//TODO: To test with the restlet 2.1 Maybe the maxTotalConnections could be avoided
// see: http://restlet-discuss.1400322.n2.nabble.com/rejectedExecution-td4513620.html
//component.getServers().add(Protocol.HTTP, SERVER_PORT);
Server server = new Server(Protocol.HTTP, 8111);
component.getServers().add(server);
server.getContext().getParameters().add("maxTotalConnections", "50");
//end TODO
Engine.getInstance().getRegisteredServers().clear();
Engine.getInstance().getRegisteredServers().add(new HttpServerHelper(server));
component.getClients().add(Protocol.FILE);
component.getDefaultHost().attach(new FreedomRestServer());
component.start();
}
示例12: testListReady
/**
* Test that we can find all of the ready objects
* @throws Exception
*/
@Test
public void testListReady() throws Exception {
Component component = new Component();
component.getServers().add(Protocol.HTTP, port);
component.getDefaultHost().attach(setupApp());
component.start();
try {
Client client = new Client(Protocol.HTTP);
ObjectMapper om = new ObjectMapper();
Collection<FileTrackingStatus> statusObjColl = getStatusObject( client, "READY", -1, -1);
assertNotNull(statusObjColl);
assertEquals(totalReady, statusObjColl.size());
Iterator<FileTrackingStatus> it = statusObjColl.iterator();
while(it.hasNext()){
FileTrackingStatus statusObj = om.convertValue(it.next(), FileTrackingStatus.class);
assertEquals("READY", statusObj.getStatus().toString()
.toUpperCase());
}
} finally {
component.stop();
}
}
示例13: testConsumer
@Test
public void testConsumer() throws IOException {
Client client = new Client(Protocol.HTTP);
Response response = client.handle(new Request(Method.GET,
"http://localhost:" + portNum + "/orders/99991/6"));
assertEquals("received GET request with id=99991 and x=6",
response.getEntity().getText());
}
示例14: testConsumerWithSpaces
@Test
public void testConsumerWithSpaces() throws IOException {
Client client = new Client(Protocol.HTTP);
Response response = client.handle(new Request(Method.GET,
"http://localhost:" + portNum + "/orders with spaces in path/99991/6"));
assertEquals("received GET request with id=99991 and x=6",
response.getEntity().getText());
}
示例15: testUnhandledConsumer
@Test
public void testUnhandledConsumer() throws IOException {
Client client = new Client(Protocol.HTTP);
Response response = client.handle(new Request(Method.POST,
"http://localhost:" + portNum + "/orders/99991/6"));
// expect error status as no Restlet consumer to handle POST method
assertEquals(Status.CLIENT_ERROR_METHOD_NOT_ALLOWED, response.getStatus());
assertNotNull(response.getEntity().getText());
}