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


Java TestPortProvider类代码示例

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


TestPortProvider类属于org.jboss.resteasy.test包,在下文中一共展示了TestPortProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testGsonConfig

import org.jboss.resteasy.test.TestPortProvider; //导入依赖的package包/类
@SuppressWarnings("static-access")
@Test
public void testGsonConfig() {

	Client client = ResteasyClientBuilder.newClient(); // Avoid conflict with Jersey in classpath
	// ClientBuilder.newClient()

	String pong = client.target(TestPortProvider.generateURL("/test/ping")).request().get(String.class);
	assertEquals("pong", pong);

	PropertyBox box = SET.execute(() -> client.target(TestPortProvider.generateURL("/test/data/{num}"))
			.resolveTemplate("num", 1).request().get(PropertyBox.class));
	assertNotNull(box);
	assertEquals(Integer.valueOf(1), box.getValue(NUM));
	assertEquals("Str_1", box.getValue(STR));

	box = SET.execute(
			() -> client.target(TestPortProvider.generateURL("/test/data/2")).request().get(PropertyBox.class));
	assertNotNull(box);
	assertEquals(Integer.valueOf(2), box.getValue(NUM));
	assertEquals("Str_2", box.getValue(STR));

}
 
开发者ID:holon-platform,项目名称:holon-json,代码行数:24,代码来源:TestResteasyServicesIntegration.java

示例2: 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());
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:17,代码来源:TestODataIntegration.java

示例3: 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());		
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:27,代码来源:TestODataIntegration.java

示例4: 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());
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:19,代码来源:TestODataIntegration.java

示例5: 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());
       
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:27,代码来源:TestODataIntegration.java

示例6: testGsonConfig

import org.jboss.resteasy.test.TestPortProvider; //导入依赖的package包/类
@SuppressWarnings("static-access")
@Test
public void testGsonConfig() {

	Client client = ResteasyClientBuilder.newClient() // Avoid conflict with Jersey in classpath
			// ClientBuilder.newClient()
			.register(JacksonFeature.class);

	String pong = client.target(TestPortProvider.generateURL("/test/ping")).request().get(String.class);
	assertEquals("pong", pong);

	PropertyBox box = SET.execute(() -> client.target(TestPortProvider.generateURL("/test/data/{num}"))
			.resolveTemplate("num", 1).request().get(PropertyBox.class));
	assertNotNull(box);
	assertEquals(Integer.valueOf(1), box.getValue(NUM));
	assertEquals("Str_1", box.getValue(STR));

	box = SET.execute(
			() -> client.target(TestPortProvider.generateURL("/test/data/2")).request().get(PropertyBox.class));
	assertNotNull(box);
	assertEquals(Integer.valueOf(2), box.getValue(NUM));
	assertEquals("Str_2", box.getValue(STR));
	
	
	PropertyBox boxToSrlz = PropertyBox.builder(SET).set(NUM, 100).build();
	
	Response response = client.target(TestPortProvider.generateURL("/test/srlz")).request()
			.put(Entity.entity(boxToSrlz, MediaType.APPLICATION_JSON));
	assertNotNull(response);
	assertEquals(Status.ACCEPTED.getStatusCode(), response.getStatus());

}
 
开发者ID:holon-platform,项目名称:holon-json,代码行数:33,代码来源:TestResteasyIntegration.java

示例7: testGsonConfig

import org.jboss.resteasy.test.TestPortProvider; //导入依赖的package包/类
@SuppressWarnings("static-access")
@Test
public void testGsonConfig() {

	Client client = ResteasyClientBuilder.newClient(); // Avoid conflict with Jersey in classpath
	// ClientBuilder.newClient();

	String pong = client.target(TestPortProvider.generateURL("/test/ping")).request().get(String.class);
	assertEquals("pong", pong);

	PropertyBox box = SET.execute(() -> client.target(TestPortProvider.generateURL("/test/data/{num}"))
			.resolveTemplate("num", 1).request().get(PropertyBox.class));
	assertNotNull(box);
	assertEquals(Integer.valueOf(1), box.getValue(NUM));
	assertEquals("Str_1", box.getValue(STR));

	box = SET.execute(
			() -> client.target(TestPortProvider.generateURL("/test/data/2")).request().get(PropertyBox.class));
	assertNotNull(box);
	assertEquals(Integer.valueOf(2), box.getValue(NUM));
	assertEquals("Str_2", box.getValue(STR));

	PropertyBox boxToSrlz = PropertyBox.builder(SET).set(NUM, 100).set(DBL, 77.7).build();

	Response response = client.target(TestPortProvider.generateURL("/test/srlz")).request()
			.put(Entity.entity(boxToSrlz, MediaType.APPLICATION_JSON));
	assertNotNull(response);
	assertEquals(Status.ACCEPTED.getStatusCode(), response.getStatus());

}
 
开发者ID:holon-platform,项目名称:holon-json,代码行数:31,代码来源:TestResteasyServicesIntegration.java

示例8: testGsonConfig

import org.jboss.resteasy.test.TestPortProvider; //导入依赖的package包/类
@SuppressWarnings("static-access")
@Test
public void testGsonConfig() {

	Client client = ResteasyClientBuilder.newClient() // Avoid conflict with Jersey in classpath
			// ClientBuilder.newClient()
			.register(GsonFeature.class);

	String pong = client.target(TestPortProvider.generateURL("/test/ping")).request().get(String.class);
	assertEquals("pong", pong);

	PropertyBox box = SET.execute(() -> client.target(TestPortProvider.generateURL("/test/data/{num}"))
			.resolveTemplate("num", 1).request().get(PropertyBox.class));
	assertNotNull(box);
	assertEquals(Integer.valueOf(1), box.getValue(NUM));
	assertEquals("Str_1", box.getValue(STR));

	box = SET.execute(
			() -> client.target(TestPortProvider.generateURL("/test/data/2")).request().get(PropertyBox.class));
	assertNotNull(box);
	assertEquals(Integer.valueOf(2), box.getValue(NUM));
	assertEquals("Str_2", box.getValue(STR));

	PropertyBox boxToSrlz = PropertyBox.builder(SET).set(NUM, 100).set(DBL, 77.7).build();

	Response response = client.target(TestPortProvider.generateURL("/test/srlz")).request()
			.put(Entity.entity(boxToSrlz, MediaType.APPLICATION_JSON));
	assertNotNull(response);
	assertEquals(Status.ACCEPTED.getStatusCode(), response.getStatus());

}
 
开发者ID:holon-platform,项目名称:holon-json,代码行数:32,代码来源:TestResteasyIntegrationContext.java

示例9: testGsonConfig

import org.jboss.resteasy.test.TestPortProvider; //导入依赖的package包/类
@SuppressWarnings("static-access")
@Test
public void testGsonConfig() {

	Client client = ResteasyClientBuilder.newClient() // Avoid conflict with Jersey in classpath
			// ClientBuilder.newClient()
			.register(GsonFeature.class);

	String pong = client.target(TestPortProvider.generateURL("/test/ping")).request().get(String.class);
	assertEquals("pong", pong);

	PropertyBox box = SET.execute(() -> client.target(TestPortProvider.generateURL("/test/data/{num}"))
			.resolveTemplate("num", 1).request().get(PropertyBox.class));
	assertNotNull(box);
	assertEquals(Integer.valueOf(1), box.getValue(NUM));
	assertEquals("Str_1", box.getValue(STR));

	box = SET.execute(
			() -> client.target(TestPortProvider.generateURL("/test/data/2")).request().get(PropertyBox.class));
	assertNotNull(box);
	assertEquals(Integer.valueOf(2), box.getValue(NUM));
	assertEquals("Str_2", box.getValue(STR));

	PropertyBox boxToSrlz = PropertyBox.builder(SET).set(NUM, 100).set(DBL, 77.7).build();

	Response response = client.target(TestPortProvider.generateURL("/test/srlz")).request()
			.put(Entity.entity(boxToSrlz, MediaType.APPLICATION_JSON));
	assertNotNull(response);
	assertEquals(Status.ACCEPTED.getStatusCode(), response.getStatus());
	
	// check cache
	response = client.target(TestPortProvider.generateURL("/test/srlz")).request()
			.put(Entity.entity(boxToSrlz, MediaType.APPLICATION_JSON));
	assertNotNull(response);
	assertEquals(Status.ACCEPTED.getStatusCode(), response.getStatus());

}
 
开发者ID:holon-platform,项目名称:holon-json,代码行数:38,代码来源:TestResteasyIntegration.java

示例10: 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));
}
 
开发者ID:Java-Publications,项目名称:javamagazin-009-microkernel,代码行数:16,代码来源:ServiceRESTTest.java

示例11: 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));
}
 
开发者ID:Java-Publications,项目名称:javamagazin-009-microkernel,代码行数:16,代码来源:LoginRestTest.java

示例12: 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());
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:15,代码来源:TestODataIntegration.java

示例13: 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>"));
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:14,代码来源:TestODataIntegration.java

示例14: testInvalidCharacterReplacement

import org.jboss.resteasy.test.TestPortProvider; //导入依赖的package包/类
@Test public void testInvalidCharacterReplacement() 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 char, c string[], d integer) as select 'ab\u0000cd\u0001', char(22), ('a\u00021','b1'), 1;");
		es.deployVDB("northwind", mmd);
		
		TeiidDriver td = es.getDriver();
		Properties props = new Properties();
		props.setProperty(LocalClient.INVALID_CHARACTER_REPLACEMENT, " ");
		LocalClient lc = new LocalClient("northwind", 1, props);
		lc.setDriver(td);
		MockProvider.CLIENT = lc;
		
        ClientRequest request = new ClientRequest(TestPortProvider.generateURL("/odata/northwind/x"));
        ClientResponse<String> response = request.get(String.class);
        Assert.assertEquals(200, response.getStatus());
        assertTrue(response.getEntity().contains("ab cd "));
        assertTrue(response.getEntity().contains("a 1"));
	} finally {
		es.stop();
	}
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:28,代码来源:TestODataIntegration.java

示例15: 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();
    }
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:34,代码来源:TestODataIntegration.java


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