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


Java Form类代码示例

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


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

示例1: empty

import com.sun.jersey.api.representation.Form; //导入依赖的package包/类
@Test
public void empty() {
	ClientResponse res;
	res = request("rdf/update")
		.get(ClientResponse.class);
	assertEquals("Should return 405 response code", 405, res.getStatus());
	Form f = new Form();
	f.add("update", "");
	res = request("rdf/update")
		.type(MediaType.APPLICATION_FORM_URLENCODED)
		.entity(f)
		.post(ClientResponse.class);
	assertEquals("Should return 400 response code", 400, res.getStatus());
	res = request("rdf/update")
		.type(RDFMediaType.SPARQL_UPDATE)
		.post(ClientResponse.class);
	assertEquals("Should return 200 response code", 400, res.getStatus());
}
 
开发者ID:lszeremeta,项目名称:neo4j-sparql-extension-yars,代码行数:19,代码来源:SPARQLUpdateTest.java

示例2: Create

import com.sun.jersey.api.representation.Form; //导入依赖的package包/类
@Override
public Form Create() {

	if (activated == true)
		throw new RuntimeException("Only one active session at a time is allowed");
	participants.clear();
	transactionIDcalledContextCoupon = null;
	owner = null;
	activated = false;
	state = Maps.newHashMap();
	cxContainer = null;
	sessionName = UUID.randomUUID().toString();
	final Form f = new Form();
	f.addFirst("sessionName", sessionName);
	f.addFirst("newContextManager", "someUrl");
	return f;
}
 
开发者ID:jkiddo,项目名称:ccow,代码行数:18,代码来源:ContextState.java

示例3: toForm

import com.sun.jersey.api.representation.Form; //导入依赖的package包/类
public static Form toForm(final InputStream inputStream) throws Exception {

		final String encoded = ReaderWriter.readFromAsString(new InputStreamReader(inputStream));
		// com.sun.jersey.core.impl.provider.entity.BaseFormProvider
		final Form map = new Form();
		final String charsetName = "UTF-8";
		final StringTokenizer tokenizer = new StringTokenizer(encoded, "&");
		String token;
		try {
			while (tokenizer.hasMoreTokens()) {
				token = tokenizer.nextToken();
				final int idx = token.indexOf('=');
				if (idx < 0) {
					map.add(URLDecoder.decode(token, charsetName), null);
				} else if (idx > 0) {
					map.add(URLDecoder.decode(token.substring(0, idx), charsetName),
							URLDecoder.decode(token.substring(idx + 1), charsetName));
				}
			}
			return map;
		} catch (final IllegalArgumentException ex) {
			throw new WebApplicationException(ex, Status.BAD_REQUEST);
		}
	}
 
开发者ID:jkiddo,项目名称:ccow,代码行数:25,代码来源:GenericHttpConnection.java

示例4: ContextChangesPending

import com.sun.jersey.api.representation.Form; //导入依赖的package包/类
@Override
public Form ContextChangesPending(final long contextCoupon) throws Exception {

	final JSONRPC2Request request = new JSONRPC2Request("ContextParticipant.ContextChangesPending", UUID.randomUUID().toString());
	final SettableFuture<JSONRPC2Response> future = SettableFuture.create();
	cache.put(request.getID().toString(), future);
	session.getBasicRemote().sendObject(request);

	final JSONRPC2Response response = future.get(3000, TimeUnit.MILLISECONDS);
	if(!response.indicatesSuccess())
		throw new RuntimeException("Error processing request: " + response.toJSONString());
	final Form form = new Form();
	final JSONObject r = (JSONObject) response.getResult();
	r.forEach((k,v)->form.add(k, v));
	return form;
}
 
开发者ID:jkiddo,项目名称:ccow,代码行数:17,代码来源:WSContextParticipantProxy.java

示例5: responseToEntity

import com.sun.jersey.api.representation.Form; //导入依赖的package包/类
public static BasicHttpEntity responseToEntity(final Response jerseyResponse) throws UnsupportedEncodingException {
	final BasicHttpEntity entity = new BasicHttpEntity();
	if (jerseyResponse.getEntity() != null) {

		// com.sun.jersey.core.impl.provider.entity.BaseFormProvider
		final String charsetName = "UTF-8";
		final Form t = (Form) jerseyResponse.getEntity();
		final StringBuilder sb = new StringBuilder();
		for (final Map.Entry<String, List<String>> e : t.entrySet()) {
			for (final String value : e.getValue()) {
				if (sb.length() > 0)
					sb.append('&');
				sb.append(URLEncoder.encode(e.getKey(), charsetName));
				if (value != null) {
					sb.append('=');
					sb.append(URLEncoder.encode(value, charsetName));
				}
			}
		}
		entity.setContent(new ByteArrayInputStream(sb.toString().getBytes()));
		entity.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
	}
	return entity;
}
 
开发者ID:jkiddo,项目名称:ccow,代码行数:25,代码来源:RequestHandlerUtil.java

示例6: toResponse

import com.sun.jersey.api.representation.Form; //导入依赖的package包/类
private Form toResponse(final URI uri, final MultivaluedMap<String, String> queryParameters) {

		final String method = queryParameters.getFirst("method");
		String _interface = queryParameters.getFirst("interface");
		if (_interface == null)
			_interface = "";

		final Method methodToInvoke = getMethod(_interface, method);

		final List<Object> args = prepareParameters(uri, queryParameters, methodToInvoke);

		try {
			final Object[] argsAsArray = args.toArray();
			final Object object = methodToInvoke.invoke(servletsToObjects.get(methodToInvoke.getDeclaringClass()),
					argsAsArray);
			return (Form) object;
		} catch (final Exception e) {
			throw new RuntimeException("Bad stuff happened", e);
		}
	}
 
开发者ID:jkiddo,项目名称:ccow,代码行数:21,代码来源:CCOWHandler.java

示例7: participantSetsContextValuesAndEndsContext

import com.sun.jersey.api.representation.Form; //导入依赖的package包/类
@Test
public void participantSetsContextValuesAndEndsContext() throws Exception {

	system2.startContextChanges();
	system2.setItemValues(itemNames, itemValues);
	final Form form = system2.endContextChanges();
	final boolean _continue = !Boolean.getBoolean(form.getFirst("noContinue"));
	final String stringResponses = form.getFirst("responses");
	final List<String> reasons;
	if (Strings.isNullOrEmpty(stringResponses))
		reasons = Lists.newArrayList();
	else
		reasons = Lists.newArrayList(Splitter.on("|").split(stringResponses));
	assertEquals(true, _continue);
	assertEquals(true, reasons.isEmpty());
}
 
开发者ID:jkiddo,项目名称:ccow,代码行数:17,代码来源:IntegrationTests.java

示例8: goThroughContextChangeAndVerifyWithWSClient

import com.sun.jersey.api.representation.Form; //导入依赖的package包/类
@Test
public void goThroughContextChangeAndVerifyWithWSClient() throws Exception {
	
	final WSContextParticipantImpl wsClient = new WSContextParticipantImpl(host, serverPort);
	wsClient.joinCommonContext();
	system1.startContextChanges();
	system1.setItemValues(itemNames, itemValues);
	final Form form = system1.endContextChanges();
	final boolean _continue = !Boolean.getBoolean(form.getFirst("noContinue"));
	final String stringResponses = form.getFirst("responses");
	final List<String> reasons;
	if (Strings.isNullOrEmpty(stringResponses))
		reasons = Lists.newArrayList();
	else
		reasons = Lists.newArrayList(Splitter.on("|").split(stringResponses));
	assertEquals(true, _continue);
	assertEquals(true, reasons.isEmpty());
	assertEquals(true, wsClient.getConnection().getLatestMessage() != null);
	wsClient.close();
}
 
开发者ID:jkiddo,项目名称:ccow,代码行数:21,代码来源:WebSocketsTestSuite.java

示例9: check_token

import com.sun.jersey.api.representation.Form; //导入依赖的package包/类
public boolean check_token(String token) throws Exception {
	String authorization_endpoint = this.getUAAendpoint();
	logger.info(">>>" + authorization_endpoint);
	WebResource webResource = restClient.resource(authorization_endpoint + "/check_token");
    String authString = cfClientId + ":" + cfSecretKey;
    byte[] authEncBytes = Base64.encodeBase64(authString.getBytes());
    Form form = new Form();
    form.add("token", token);
    String authStringEnc = new String(authEncBytes);
    ClientResponse cr = webResource
            .accept(MediaType.APPLICATION_JSON)
            .type(MediaType.APPLICATION_FORM_URLENCODED)
            .header("charset", "utf-8")
            .header("authorization", "Basic " + authStringEnc)
            .post(ClientResponse.class, form);
    
    String response = cr.getEntity(String.class);
    logger.info(">>>" + response);
    int status_code = cr.getStatus();
    return (status_code == 200);
	
}
 
开发者ID:cfibmers,项目名称:open-Autoscaler,代码行数:23,代码来源:CloudFoundryManager.java

示例10: test_filter_noActionOnPostFormPut

import com.sun.jersey.api.representation.Form; //导入依赖的package包/类
public void test_filter_noActionOnPostFormPut() {
  ContainerRequest mock = Mockito.mock(ContainerRequest.class);
  when(mock.getMethod()).thenReturn("POST");
  Form form = new Form();
  form.put("method", Arrays.asList("PUT"));
  when(mock.getFormParameters()).thenReturn(form);
  
  HttpMethodFilter test = new HttpMethodFilter();
  ContainerRequest result = test.filter(mock);
  
  assertSame(mock, result);
  verify(mock).getMethod();
  verify(mock).getFormParameters();
  verify(mock).setMethod("PUT");
  verifyNoMoreInteractions(mock);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:17,代码来源:HttpMethodFilterTest.java

示例11: test_filter_noActionOnPostFormDelete

import com.sun.jersey.api.representation.Form; //导入依赖的package包/类
public void test_filter_noActionOnPostFormDelete() {
  ContainerRequest mock = Mockito.mock(ContainerRequest.class);
  when(mock.getMethod()).thenReturn("POST");
  Form form = new Form();
  form.put("method", Arrays.asList("DELETE"));
  when(mock.getFormParameters()).thenReturn(form);
  
  HttpMethodFilter test = new HttpMethodFilter();
  ContainerRequest result = test.filter(mock);
  
  assertSame(mock, result);
  verify(mock).getMethod();
  verify(mock).getFormParameters();
  verify(mock).setMethod("DELETE");
  verifyNoMoreInteractions(mock);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:17,代码来源:HttpMethodFilterTest.java

示例12: test_filter_noActionOnPostFormOptions

import com.sun.jersey.api.representation.Form; //导入依赖的package包/类
public void test_filter_noActionOnPostFormOptions() {
  ContainerRequest mock = Mockito.mock(ContainerRequest.class);
  when(mock.getMethod()).thenReturn("POST");
  Form form = new Form();
  form.put("method", Arrays.asList("OPTIONS"));
  when(mock.getFormParameters()).thenReturn(form);
  
  HttpMethodFilter test = new HttpMethodFilter();
  ContainerRequest result = test.filter(mock);
  
  assertSame(mock, result);
  verify(mock).getMethod();
  verify(mock).getFormParameters();
  verify(mock).setMethod("OPTIONS");
  verifyNoMoreInteractions(mock);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:17,代码来源:HttpMethodFilterTest.java

示例13: test_filter_noActionOnPostFormHead

import com.sun.jersey.api.representation.Form; //导入依赖的package包/类
public void test_filter_noActionOnPostFormHead() {
  ContainerRequest mock = Mockito.mock(ContainerRequest.class);
  when(mock.getMethod()).thenReturn("POST");
  Form form = new Form();
  form.put("method", Arrays.asList("HEAD"));
  when(mock.getFormParameters()).thenReturn(form);
  
  HttpMethodFilter test = new HttpMethodFilter();
  ContainerRequest result = test.filter(mock);
  
  assertSame(mock, result);
  verify(mock).getMethod();
  verify(mock).getFormParameters();
  verify(mock).setMethod("HEAD");
  verifyNoMoreInteractions(mock);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:17,代码来源:HttpMethodFilterTest.java

示例14: test_filter_noActionOnPostFormPost

import com.sun.jersey.api.representation.Form; //导入依赖的package包/类
public void test_filter_noActionOnPostFormPost() {
  ContainerRequest mock = Mockito.mock(ContainerRequest.class);
  when(mock.getMethod()).thenReturn("POST");
  Form form = new Form();
  form.put("method", Arrays.asList("POST"));
  when(mock.getFormParameters()).thenReturn(form);
  
  HttpMethodFilter test = new HttpMethodFilter();
  ContainerRequest result = test.filter(mock);
  
  assertSame(mock, result);
  verify(mock).getMethod();
  verify(mock).getFormParameters();
  verify(mock).setMethod("POST");
  verifyNoMoreInteractions(mock);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:17,代码来源:HttpMethodFilterTest.java

示例15: test_filter_noActionOnPostFormGet

import com.sun.jersey.api.representation.Form; //导入依赖的package包/类
public void test_filter_noActionOnPostFormGet() {
  ContainerRequest mock = Mockito.mock(ContainerRequest.class);
  when(mock.getMethod()).thenReturn("POST");
  Form form = new Form();
  form.put("method", Arrays.asList("GET"));
  when(mock.getFormParameters()).thenReturn(form);
  
  HttpMethodFilter test = new HttpMethodFilter();
  ContainerRequest result = test.filter(mock);
  
  assertSame(mock, result);
  verify(mock).getMethod();
  verify(mock).getFormParameters();
  verify(mock).setMethod("GET");
  verifyNoMoreInteractions(mock);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:17,代码来源:HttpMethodFilterTest.java


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