本文整理汇总了Java中org.jboss.resteasy.test.TestPortProvider.generateURL方法的典型用法代码示例。如果您正苦于以下问题:Java TestPortProvider.generateURL方法的具体用法?Java TestPortProvider.generateURL怎么用?Java TestPortProvider.generateURL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jboss.resteasy.test.TestPortProvider
的用法示例。
在下文中一共展示了TestPortProvider.generateURL方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testMetadataVisibility
import org.jboss.resteasy.test.TestPortProvider; //导入方法依赖的package包/类
@Test
public void testMetadataVisibility() throws Exception {
Client client = mockClient2();
MockProvider.CLIENT = client;
StringWriter sw = new StringWriter();
EdmxFormatWriter.write(client.getMetadata(), sw);
ClientRequest request = new ClientRequest(TestPortProvider.generateURL("/odata/northwind/$metadata"));
ClientResponse<String> response = request.get(String.class);
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals(sw.toString(), response.getEntity());
String edm = "<?xml version=\"1.0\" encoding=\"utf-8\"?><edmx:Edmx Version=\"1.0\" xmlns:edmx=\"http://schemas.microsoft.com/ado/2007/06/edmx\"><edmx:DataServices m:DataServiceVersion=\"2.0\" xmlns:m=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\"></edmx:DataServices></edmx:Edmx>";
Assert.assertEquals(edm, response.getEntity());
}
示例2: testProjectedColumns
import org.jboss.resteasy.test.TestPortProvider; //导入方法依赖的package包/类
@Test
public void testProjectedColumns() throws Exception {
Client client = mockClient();
MockProvider.CLIENT = client;
ArgumentCaptor<Query> sql = ArgumentCaptor.forClass(Query.class);
ArgumentCaptor<EdmEntitySet> entitySet = ArgumentCaptor.forClass(EdmEntitySet.class);
OEntity entity = createCustomersEntity(client.getMetadata());
ArrayList<OEntity> list = new ArrayList<OEntity>();
list.add(entity);
EntityList result = Mockito.mock(EntityList.class);
when(result.get(0)).thenReturn(entity);
when(result.size()).thenReturn(1);
when(result.iterator()).thenReturn(list.iterator());
when(client.executeSQL(any(Query.class), anyListOf(SQLParam.class), any(EdmEntitySet.class), (LinkedHashMap<String, Boolean>) any(), any(QueryInfo.class))).thenReturn(result);
ClientRequest request = new ClientRequest(TestPortProvider.generateURL("/odata/northwind/Customers?$select=CustomerID,CompanyName,Address"));
ClientResponse<String> response = request.get(String.class);
verify(client).executeSQL(sql.capture(), anyListOf(SQLParam.class), entitySet.capture(), (LinkedHashMap<String, Boolean>) any(), any(QueryInfo.class));
Assert.assertEquals("SELECT g0.CustomerID, g0.CompanyName, g0.Address FROM nw.Customers AS g0 ORDER BY g0.CustomerID", sql.getValue().toString());
Assert.assertEquals(200, response.getStatus());
//Assert.assertEquals("", response.getEntity());
}
示例3: testProcedure
import org.jboss.resteasy.test.TestPortProvider; //导入方法依赖的package包/类
@Test
public void testProcedure() throws Exception {
Client client = mockClient();
MockProvider.CLIENT = client;
ArgumentCaptor<String> sql = ArgumentCaptor.forClass(String.class);
ArgumentCaptor<List> params = ArgumentCaptor.forClass(List.class);
when(client.executeCall(any(String.class), anyListOf(SQLParam.class), any(EdmType.class))).thenReturn(Responses.simple(EdmSimpleType.INT32, "return", null));
ClientRequest request = new ClientRequest(TestPortProvider.generateURL("/odata/northwind/getCustomers?p2=datetime'2011-09-11T00:00:00'&p3=2.0M"));
ClientResponse<String> response = request.get(String.class);
verify(client).executeCall(sql.capture(), params.capture(), any(EdmType.class));
Assert.assertEquals("{? = call nw.getCustomers(p2=>?,p3=>?)}", sql.getValue().toString());
Assert.assertEquals(TimestampUtil.createTimestamp(111, 8, 11, 0, 0, 0, 0), ((SQLParam)params.getValue().get(0)).value);
Assert.assertEquals(BigDecimal.valueOf(2.0), ((SQLParam)params.getValue().get(1)).value);
Assert.assertEquals(200, response.getStatus());
}
示例4: testSelect
import org.jboss.resteasy.test.TestPortProvider; //导入方法依赖的package包/类
@Test
public void testSelect() throws Exception {
Client client = mockClient();
MockProvider.CLIENT = client;
ArgumentCaptor<Query> sql = ArgumentCaptor.forClass(Query.class);
ArgumentCaptor<EdmEntitySet> entitySet = ArgumentCaptor.forClass(EdmEntitySet.class);
OEntity entity = createCustomersEntity(client.getMetadata());
ArrayList<OEntity> list = new ArrayList<OEntity>();
list.add(entity);
EntityList result = Mockito.mock(EntityList.class);
when(result.get(0)).thenReturn(entity);
when(result.size()).thenReturn(1);
when(result.iterator()).thenReturn(list.iterator());
when(client.executeSQL(any(Query.class), anyListOf(SQLParam.class), any(EdmEntitySet.class), (LinkedHashMap<String, Boolean>) any(), any(QueryInfo.class))).thenReturn(result);
ClientRequest request = new ClientRequest(TestPortProvider.generateURL("/odata/northwind/Customers?$select=CustomerID,CompanyName,Address"));
ClientResponse<String> response = request.get(String.class);
verify(client).executeSQL(sql.capture(), anyListOf(SQLParam.class), entitySet.capture(), (LinkedHashMap<String, Boolean>) any(), any(QueryInfo.class));
Assert.assertEquals("SELECT g0.CustomerID, g0.CompanyName, g0.Address FROM nw.Customers AS g0 ORDER BY g0.CustomerID", sql.getValue().toString());
Assert.assertEquals(200, response.getStatus());
}
示例5: test001
import org.jboss.resteasy.test.TestPortProvider; //导入方法依赖的package包/类
@Test
void test001() {
final String generateBasicReqURL = TestPortProvider.generateURL("/rest" + "/api");
System.out.println("generateBasicReqURL = " + generateBasicReqURL);
Client client = ClientBuilder.newClient();
final Invocation.Builder request = client
.target(generateBasicReqURL)
.path("add")
.queryParam("inputA", "1")
.queryParam("inputB", "1")
.request();
final Response response = request.get();
Assert.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
Assert.assertEquals("2", response.readEntity(String.class));
}
示例6: test001
import org.jboss.resteasy.test.TestPortProvider; //导入方法依赖的package包/类
@Test
void test001() {
final String generateBasicReqURL = TestPortProvider.generateURL("/rest" + "/security");
System.out.println("generateBasicReqURL = " + generateBasicReqURL);
Client client = ClientBuilder.newClient();
final Invocation.Builder request = client
.target(generateBasicReqURL)
.path("check")
.queryParam("username", "admin")
.queryParam("password", "admin")
.request();
final Response response = request.get();
Assert.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
Assert.assertEquals("true", response.readEntity(String.class));
}
示例7: testMetadata
import org.jboss.resteasy.test.TestPortProvider; //导入方法依赖的package包/类
@Test
public void testMetadata() throws Exception {
Client client = mockClient();
MockProvider.CLIENT = client;
StringWriter sw = new StringWriter();
EdmxFormatWriter.write(client.getMetadata(), sw);
ClientRequest request = new ClientRequest(TestPortProvider.generateURL("/odata/northwind/$metadata"));
ClientResponse<String> response = request.get(String.class);
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals(sw.toString(), response.getEntity());
}
示例8: testError
import org.jboss.resteasy.test.TestPortProvider; //导入方法依赖的package包/类
@Test
public void testError() throws Exception {
Client client = mockClient();
MockProvider.CLIENT = client;
when(client.executeSQL(any(Query.class), anyListOf(SQLParam.class), any(EdmEntitySet.class), (LinkedHashMap<String, Boolean>) any(), any(QueryInfo.class))).thenThrow(new NullPointerException());
ClientRequest request = new ClientRequest(TestPortProvider.generateURL("/odata/northwind/Customers?$select=CustomerID,CompanyName,Address"));
ClientResponse<String> response = request.get(String.class);
Assert.assertEquals(500, response.getStatus());
Assert.assertTrue(response.getEntity().endsWith("<error xmlns=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\"><code>ServerErrorException</code><message lang=\"en-US\">Internal Server Error</message></error>"));
}
示例9: testNoSkipToken
import org.jboss.resteasy.test.TestPortProvider; //导入方法依赖的package包/类
@Test public void testNoSkipToken() throws Exception {
EmbeddedServer es = new EmbeddedServer();
es.start(new EmbeddedConfiguration());
try {
ModelMetaData mmd = new ModelMetaData();
mmd.setName("vw");
mmd.setSchemaSourceType("ddl");
mmd.setModelType(Type.VIRTUAL);
mmd.setSchemaText("create view x (a string primary key, b integer) as select 'xyz', 123 union all select 'abc', 456;");
es.deployVDB("northwind", mmd);
TeiidDriver td = es.getDriver();
Properties props = new Properties();
props.setProperty("batch-size", "0");
LocalClient lc = new LocalClient("northwind", 1, props);
lc.setDriver(td);
MockProvider.CLIENT = lc;
ClientRequest request = new ClientRequest(TestPortProvider.generateURL("/odata/northwind/x?$format=json"));
ClientResponse<String> response = request.get(String.class);
assertEquals(200, response.getStatus());
JSONParser parser = new JSONParser();
JSONValueExtractor contentHandler = new JSONValueExtractor("__next");
parser.parse(response.getEntity(), contentHandler);
assertNotNull(contentHandler.next);
assertTrue(response.getEntity().contains("abc"));
assertTrue(response.getEntity().contains("xyz"));
assertNull(contentHandler.value);
} finally {
es.stop();
}
}
示例10: testBatch
import org.jboss.resteasy.test.TestPortProvider; //导入方法依赖的package包/类
@Test public void testBatch() throws Exception {
EmbeddedServer es = new EmbeddedServer();
HardCodedExecutionFactory hc = new HardCodedExecutionFactory() {
@Override
public boolean supportsCompareCriteriaEquals() {
return true;
}
};
hc.addUpdate("DELETE FROM x WHERE x.a = 'a' AND x.b = 'b'", new int[] {1});
es.addTranslator("x", hc);
es.start(new EmbeddedConfiguration());
try {
ModelMetaData mmd = new ModelMetaData();
mmd.setName("m");
mmd.setSchemaSourceType("ddl");
mmd.setSchemaText("create foreign table x (a string, b string, c integer, primary key (a, b)) options (updatable true);");
mmd.addSourceMapping("x", "x", null);
es.deployVDB("northwind", mmd);
TeiidDriver td = es.getDriver();
Properties props = new Properties();
LocalClient lc = new LocalClient("northwind", 1, props);
lc.setDriver(td);
MockProvider.CLIENT = lc;
String post = "Content-Type: application/http\n"
+ "Content-Transfer-Encoding:binary\n"
+ "\nDELETE /odata/northwind/x(a='a',b='b') HTTP/1.1\n"
//+ "Host: host\n"
+ "--batch_36522ad7-fc75-4b56-8c71-56071383e77b\n";
ClientRequest request = new ClientRequest(TestPortProvider.generateURL("/odata/northwind/Customers/$batch"));
request.body(ODataBatchProvider.MULTIPART_MIXED, post);
ClientResponse<String> response = request.post(String.class);
assertEquals(202, response.getStatus());
} finally {
es.stop();
}
}
示例11: testCreateQueueWithBadContentType
import org.jboss.resteasy.test.TestPortProvider; //导入方法依赖的package包/类
@Test
public void testCreateQueueWithBadContentType() throws Exception {
String queueConfig = "<queue name=\"testQueue\"><durable>true</durable></queue>";
ClientRequest create = new ClientRequest(TestPortProvider.generateURL("/queues"));
ClientResponse cRes = create.body("application/x-www-form-urlencoded", queueConfig).post();
cRes.releaseConnection();
Assert.assertEquals(415, cRes.getStatus());
}
示例12: testFindQueue
import org.jboss.resteasy.test.TestPortProvider; //导入方法依赖的package包/类
@Test
public void testFindQueue() throws Exception {
String testName = "testFindQueue";
server.getActiveMQServer().addAddressInfo(new AddressInfo(SimpleString.toSimpleString(testName), RoutingType.MULTICAST));
server.getActiveMQServer().createQueue(new SimpleString(testName), RoutingType.MULTICAST, new SimpleString(testName), null, false, false);
ClientRequest request = new ClientRequest(TestPortProvider.generateURL("/queues/" + testName));
ClientResponse<?> response = request.head();
response.releaseConnection();
Assert.assertEquals(200, response.getStatus());
Link sender = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), response, "create");
System.out.println("create: " + sender);
Link consumers = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-consumers");
System.out.println("pull: " + consumers);
response = Util.setAutoAck(consumers, true);
Link consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next");
System.out.println("poller: " + consumeNext);
ClientResponse<?> res = sender.request().body("text/plain", Integer.toString(1)).post();
res.releaseConnection();
Assert.assertEquals(201, res.getStatus());
res = consumeNext.request().post(String.class);
Assert.assertEquals(200, res.getStatus());
Assert.assertEquals("1", res.getEntity(String.class));
res.releaseConnection();
Link session = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), res, "consumer");
System.out.println("session: " + session);
Assert.assertEquals(204, session.request().delete().getStatus());
}
示例13: testCheckGeneratedColumns
import org.jboss.resteasy.test.TestPortProvider; //导入方法依赖的package包/类
@Test
public void testCheckGeneratedColumns() throws Exception {
Client client = mockClient();
MockProvider.CLIENT = client;
ArgumentCaptor<Command> insertCmd = ArgumentCaptor.forClass(Command.class);
ArgumentCaptor<Query> sql = ArgumentCaptor.forClass(Query.class);
ArgumentCaptor<EdmEntitySet> entitySet = ArgumentCaptor.forClass(EdmEntitySet.class);
OEntity entity = createCustomersEntity(client.getMetadata());
ArrayList<OEntity> list = new ArrayList<OEntity>();
list.add(entity);
EntityList result = Mockito.mock(EntityList.class);
when(result.get(0)).thenReturn(entity);
when(result.size()).thenReturn(1);
when(result.iterator()).thenReturn(list.iterator());
when(client.executeSQL(any(Query.class), anyListOf(SQLParam.class), any(EdmEntitySet.class), (LinkedHashMap<String, Boolean>) any(), any(QueryInfo.class))).thenReturn(result);
UpdateResponse respose = new UpdateResponse() {
@Override
public int getUpdateCount() {
return 1;
}
@Override
public Map<String, Object> getGeneratedKeys() {
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("id", 1234);
return map;
}
};
String post = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
"<entry xml:base=\"http://host/service.svc/\"\n" +
"xmlns:d=\"http://schemas.microsoft.com/ado/2007/08/dataservices\"\n" +
"xmlns:m=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\"\n" +
"xmlns=\"http://www.w3.org/2005/Atom\">\n" +
" <content type=\"application/xml\">\n" +
" <m:properties>\n" +
" <d:CompanyName>JBoss</d:CompanyName>\n" +
" <d:ContactName>Joe</d:ContactName>\n" +
" <d:ContactTitle>1970</d:ContactTitle>\n" +
" <d:Address>123 Main Street</d:Address>\n" +
" <d:City>STL</d:City>\n" +
" <d:Region>MidWest</d:Region>\n" +
" <d:PostalCode>12345</d:PostalCode>\n" +
" <d:Country>USA</d:Country>\n" +
" <d:Phone>123234</d:Phone>\n" +
" </m:properties>\n" +
" </content>\n" +
"</entry>";
when(client.executeUpdate(any(Command.class), anyListOf(SQLParam.class))).thenReturn(respose);
ClientRequest request = new ClientRequest(TestPortProvider.generateURL("/odata/northwind/Customers"));
request.body(MediaType.APPLICATION_ATOM_XML, post);
ClientResponse<String> response = request.post();
verify(client).executeUpdate(insertCmd.capture(), anyListOf(SQLParam.class));
// post after insert pulls the entity inserted. In above XML there is customer id, but
// below selection is based on primary key 1234
verify(client).executeSQL(sql.capture(), anyListOf(SQLParam.class), entitySet.capture(), (LinkedHashMap<String, Boolean>) any(), any(QueryInfo.class));
Assert.assertEquals("INSERT INTO Customers (CompanyName, ContactName, ContactTitle, Address, City, Region, PostalCode, Country, Phone) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", insertCmd.getValue().toString());
Assert.assertEquals("SELECT g0.CustomerID, g0.CompanyName, g0.ContactName, g0.ContactTitle, g0.Address, g0.City, g0.Region, g0.PostalCode, g0.Country, g0.Phone, g0.Fax FROM nw.Customers AS g0 WHERE g0.CustomerID = 1234 ORDER BY g0.CustomerID", sql.getValue().toString());
Assert.assertEquals(201, response.getStatus());
}
示例14: testSkipNoPKTable
import org.jboss.resteasy.test.TestPortProvider; //导入方法依赖的package包/类
@Test
public void testSkipNoPKTable() throws Exception {
Client client = mockClient();
MockProvider.CLIENT = client;
ClientRequest request = new ClientRequest(TestPortProvider.generateURL("/odata/northwind/NoPKTable"));
ClientResponse<String> response = request.get(String.class);
Assert.assertEquals(404, response.getStatus());
Assert.assertTrue(response.getEntity().endsWith("<error xmlns=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\"><code>NotFoundException</code><message lang=\"en-US\">TEIID16011 EntitySet \"NoPKTable\" is not found; Check the spelling, use modelName.tableName; The table that representing the Entity type must either have a PRIMARY KEY or UNIQUE key(s)</message></error>"));
}
示例15: testCreateTopic
import org.jboss.resteasy.test.TestPortProvider; //导入方法依赖的package包/类
@Test
public void testCreateTopic() throws Exception {
String queueConfig = "<topic name=\"testTopic\"></topic>";
ClientRequest create = new ClientRequest(TestPortProvider.generateURL("/topics"));
ClientResponse cRes = create.body("application/activemq.jms.topic+xml", queueConfig).post();
cRes.releaseConnection();
Assert.assertEquals(201, cRes.getStatus());
ClientRequest request = cRes.getLocationLink().request();
ClientResponse<?> response = request.head();
response.releaseConnection();
Assert.assertEquals(200, response.getStatus());
Link sender = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), response, "create");
Link subscriptions = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), response, "pull-subscriptions");
ClientResponse<?> res = subscriptions.request().post();
res.releaseConnection();
Assert.assertEquals(201, res.getStatus());
Link sub1 = res.getLocationLink();
Assert.assertNotNull(sub1);
Link consumeNext1 = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), res, "consume-next");
Assert.assertNotNull(consumeNext1);
System.out.println("consumeNext1: " + consumeNext1);
res = subscriptions.request().post();
res.releaseConnection();
Assert.assertEquals(201, res.getStatus());
Link sub2 = res.getLocationLink();
Assert.assertNotNull(sub2);
Link consumeNext2 = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), res, "consume-next");
Assert.assertNotNull(consumeNext1);
res = sender.request().body("text/plain", Integer.toString(1)).post();
res.releaseConnection();
Assert.assertEquals(201, res.getStatus());
res = sender.request().body("text/plain", Integer.toString(2)).post();
res.releaseConnection();
Assert.assertEquals(201, res.getStatus());
res = consumeNext1.request().post(String.class);
Assert.assertEquals(200, res.getStatus());
Assert.assertEquals("1", res.getEntity(String.class));
res.releaseConnection();
consumeNext1 = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), res, "consume-next");
res = consumeNext1.request().post(String.class);
Assert.assertEquals(200, res.getStatus());
Assert.assertEquals("2", res.getEntity(String.class));
res.releaseConnection();
consumeNext1 = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), res, "consume-next");
res = consumeNext2.request().post(String.class);
Assert.assertEquals(200, res.getStatus());
Assert.assertEquals("1", res.getEntity(String.class));
res.releaseConnection();
consumeNext2 = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), res, "consume-next");
res = consumeNext2.request().post(String.class);
Assert.assertEquals(200, res.getStatus());
Assert.assertEquals("2", res.getEntity(String.class));
res.releaseConnection();
consumeNext2 = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), res, "consume-next");
res = sub1.request().delete();
res.releaseConnection();
Assert.assertEquals(204, res.getStatus());
res = sub2.request().delete();
res.releaseConnection();
Assert.assertEquals(204, res.getStatus());
}