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


Java RuntimeType类代码示例

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


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

示例1: configure

import javax.ws.rs.RuntimeType; //导入依赖的package包/类
@Override
public boolean configure(FeatureContext context) {
	// limit to SERVER runtime
	if (RuntimeType.SERVER == context.getConfiguration().getRuntimeType()) {

		// check disabled
		if (context.getConfiguration().getProperties().containsKey(DISABLE_AUTHENTICATION)) {
			LOGGER.debug(() -> "Skip AuthenticationFeature registration, [" + DISABLE_AUTHENTICATION
					+ "] property detected");
			return false;
		}

		if (!context.getConfiguration().isRegistered(AuthenticationDynamicFeature.class)) {
			context.register(AuthenticationDynamicFeature.class);
		}
		return true;
	}
	return false;
}
 
开发者ID:holon-platform,项目名称:holon-jaxrs,代码行数:20,代码来源:AuthenticationFeature.java

示例2: SpringContextJerseyTest

import javax.ws.rs.RuntimeType; //导入依赖的package包/类
/**
 * An extending class must implement the {@link #configure()} method to
 * provide an application descriptor.
 *
 * @throws TestContainerException if the default test container factory
 *                                cannot be obtained, or the application descriptor is not
 *                                supported by the test container factory.
 */
public SpringContextJerseyTest() throws TestContainerException {
    ResourceConfig config = getResourceConfig(configure());
    config.register(new ServiceFinderBinder<TestContainerFactory>(TestContainerFactory.class, null, RuntimeType.SERVER));

    if (isLogRecordingEnabled()) {
        registerLogHandler();
    }
    this.application = new ApplicationHandler(config);
    this.tc = getContainer(application, getTestContainerFactory());
    if (isLogRecordingEnabled()) {
        loggedStartupRecords.addAll(loggedRuntimeRecords);
        loggedRuntimeRecords.clear();
        unregisterLogHandler();
    }
}
 
开发者ID:Ellychou,项目名称:Todo-Jersey-Spring-MyBatis,代码行数:24,代码来源:SpringContextJerseyTest.java

示例3: testJerseyFilterClientNoParams

import javax.ws.rs.RuntimeType; //导入依赖的package包/类
@Test
public void testJerseyFilterClientNoParams() throws Exception{
    //environment
    ArgumentCaptor<Response> argument = ArgumentCaptor.forClass(Response.class);
    when(context.getConfiguration()).thenReturn(config);
    when(config.getRuntimeType()).thenReturn(RuntimeType.CLIENT);
    when(context.getProperty(JWSJerseyFilter.JWS_FILTER_KEY)).thenReturn(null);
    when(context.getUri()).thenReturn(new URI("http://localhost:8080"));
    //test
    jwsJerseyFilter.filter(context);
    //validation
    verify(context,atLeastOnce()).abortWith(argument.capture());
    Assert.assertEquals("Response should be bad request",Response.Status.BAD_REQUEST.getStatusCode(),argument.getValue().getStatus());
    validateMockitoUsage();

}
 
开发者ID:Appverse,项目名称:appverse-server,代码行数:17,代码来源:JWSJerseyTest.java

示例4: getPropertyNameForRuntime

import javax.ws.rs.RuntimeType; //导入依赖的package包/类
static String getPropertyNameForRuntime(String key, RuntimeType runtimeType) {
    if (runtimeType != null && key.startsWith("jersey.config")) {
        RuntimeType[] types = RuntimeType.values();
        for (int i = 0; i < types.length; ++i) {
            RuntimeType type = types[i];
            if (key.startsWith("jersey.config." + type.name().toLowerCase())) {
                return key;
            }
        }
        return key.replace("jersey.config", "jersey.config." + runtimeType.name().toLowerCase());
    } else {
        return key;
    }
}
 
开发者ID:igorzg,项目名称:payara-micro-docker-starter-kit,代码行数:15,代码来源:JacksonFeature.java

示例5: PropertiesValueFactoryProvider

import javax.ws.rs.RuntimeType; //导入依赖的package包/类
@Inject
public PropertiesValueFactoryProvider(MultivaluedParameterExtractorProvider mpep,
        ServiceLocator locator,
        Configuration configuration) {
    super(mpep, locator, Parameter.Source.UNKNOWN);
    this.serviceLocator = locator;
    this.i18nEnabled = PropertiesHelper.getValue(configuration.getProperties(),
            RuntimeType.SERVER, JerseyPropertiesFeature.ENABLE_I18N, false, null);
}
 
开发者ID:psamsotha,项目名称:jersey-properties,代码行数:10,代码来源:PropertiesValueFactoryProvider.java

示例6: configure

import javax.ws.rs.RuntimeType; //导入依赖的package包/类
@Override
public boolean configure(final FeatureContext context) {
    final Configuration config = context.getConfiguration();
    //client side only configuration
    if (RuntimeType.CLIENT == config.getRuntimeType()) {
        if (!config.isRegistered(JWSJerseyFilter.class)){
            context.property(JWSJerseyFilter.JWS_FILTER_KEY, key);
            context.register(JWSJerseyFilter.class);
            return true;
        }
    }
    return false;
}
 
开发者ID:Appverse,项目名称:appverse-server,代码行数:14,代码来源:JWSJerseyFeature.java

示例7: testJerseyFilterServer

import javax.ws.rs.RuntimeType; //导入依赖的package包/类
@Test
public void testJerseyFilterServer() throws IOException{
    //environment
    when(context.getConfiguration()).thenReturn(config);
    when(config.getRuntimeType()).thenReturn(RuntimeType.SERVER);
    //test
    jwsJerseyFilter.filter(context);
    //validation
    verify(config,times(1)).getRuntimeType();
    validateMockitoUsage();
}
 
开发者ID:Appverse,项目名称:appverse-server,代码行数:12,代码来源:JWSJerseyTest.java

示例8: testJerseyFilterClientWithParams

import javax.ws.rs.RuntimeType; //导入依赖的package包/类
@Test
public void testJerseyFilterClientWithParams() throws Exception{
    //load certificate
    KeyStore keyStore = getKeyStoreClient();
    Key key = keyStore.getKey(clientCertAlias, clientCertPassword.toCharArray());
    //environment
    ArgumentCaptor<String> argumentHeader = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> argumentHeaderValue = ArgumentCaptor.forClass(String.class);
    when(context.getConfiguration()).thenReturn(config);
    when(config.getRuntimeType()).thenReturn(RuntimeType.CLIENT);
    when(context.getProperty(JWSJerseyFilter.JWS_FILTER_KEY)).thenReturn(key);
    when(context.getUri()).thenReturn(new URI("http://localhost:8080"));
    when(context.getHeaders()).thenReturn(headers);
    //test
    jwsJerseyFilter.filter(context);
    //validation
    verify(headers,times(1)).add(argumentHeader.capture(), argumentHeaderValue.capture());
    Assert.assertEquals("Response should contain header",JWSJerseyFilter.JWS_AUTHORIZATION_HEADER,argumentHeader.getValue());
    String headerValue = argumentHeaderValue.getValue();
    Assert.assertTrue("Response should contain token",headerValue.contains(JWSJerseyFilter.JWS_AUTHORIZATION_START_TOKEN));
    //validate split by space
    String[] token = headerValue.split(" ");
    Assert.assertEquals("Header should contain signed hash", 2,token.length);
    Assert.assertFalse("Header should contain signed hash", token[1].isEmpty());
    validateMockitoUsage();

}
 
开发者ID:Appverse,项目名称:appverse-server,代码行数:28,代码来源:JWSJerseyTest.java

示例9: testJerseyFeatureClientWithParamsConstructor1

import javax.ws.rs.RuntimeType; //导入依赖的package包/类
@Test
public void testJerseyFeatureClientWithParamsConstructor1() throws Exception{
    //load certificate
    KeyStore keyStore = getKeyStoreClient();
    Key key = keyStore.getKey(clientCertAlias, clientCertPassword.toCharArray());

    //test constructor1
    JWSJerseyFeature jwsJerseyFeature = new JWSJerseyFeature(keyStore,clientCertAlias,clientCertPassword);

    //environment
    ArgumentCaptor<String> argumentName = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<Object> argumentKey = ArgumentCaptor.forClass(Object.class);
    ArgumentCaptor<Class> argumentClazz = ArgumentCaptor.forClass(Class.class);
    when(featureContext.getConfiguration()).thenReturn(config);
    when(config.getRuntimeType()).thenReturn(RuntimeType.CLIENT);
    when(config.isRegistered(JWSJerseyFilter.class)).thenReturn(false);

    //test
    boolean response = jwsJerseyFeature.configure(featureContext);
    //validation
    Assert.assertTrue("response should be true", response);
    verify(featureContext,times(1)).property(argumentName.capture(),argumentKey.capture());
    Assert.assertEquals("Response should have the same name as param", JWSJerseyFilter.JWS_FILTER_KEY, argumentName.getValue());
    Assert.assertEquals("Response should have the same key as param", key, argumentKey.getValue());
    verify(featureContext,times(1)).register(argumentClazz.capture());
    Assert.assertEquals("Response should have the same key as param",JWSJerseyFilter.class,argumentClazz.getValue());
    validateMockitoUsage();

}
 
开发者ID:Appverse,项目名称:appverse-server,代码行数:30,代码来源:JWSJerseyTest.java

示例10: testJerseyFeatureClientWithParamsConstructor2

import javax.ws.rs.RuntimeType; //导入依赖的package包/类
@Test
public void testJerseyFeatureClientWithParamsConstructor2() throws Exception{
    //load certificate
    KeyStore keyStore = getKeyStoreClient();
    Key key = keyStore.getKey(clientCertAlias, clientCertPassword.toCharArray());
    //test constructor1
    JWSJerseyFeature jwsJerseyFeature = new JWSJerseyFeature(key);

    //environment
    ArgumentCaptor<String> argumentName = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<Object> argumentKey = ArgumentCaptor.forClass(Object.class);
    ArgumentCaptor<Class> argumentClazz = ArgumentCaptor.forClass(Class.class);
    when(featureContext.getConfiguration()).thenReturn(config);
    when(config.getRuntimeType()).thenReturn(RuntimeType.CLIENT);
    when(config.isRegistered(JWSJerseyFilter.class)).thenReturn(false);

    //test
    boolean response = jwsJerseyFeature.configure(featureContext);
    //validation
    Assert.assertTrue("response should be true", response);
    verify(featureContext,times(1)).property(argumentName.capture(),argumentKey.capture());
    Assert.assertEquals("Response should have the same name as param", JWSJerseyFilter.JWS_FILTER_KEY, argumentName.getValue());
    Assert.assertEquals("Response should have the same key as param", key, argumentKey.getValue());
    verify(featureContext,times(1)).register(argumentClazz.capture());
    Assert.assertEquals("Response should have the same key as param",JWSJerseyFilter.class,argumentClazz.getValue());
    validateMockitoUsage();

}
 
开发者ID:Appverse,项目名称:appverse-server,代码行数:29,代码来源:JWSJerseyTest.java

示例11: isNotServerProvider

import javax.ws.rs.RuntimeType; //导入依赖的package包/类
private boolean isNotServerProvider(Class<?> clazz) {
    final ConstrainedTo ct = clazz.getAnnotation(ConstrainedTo.class);
    if (ct != null && ct.value() != RuntimeType.SERVER) {
        if (!FAIL_ON_CONSTRAINED_TO) {
            LOGGER.warning(clazz + " is not a SERVER provider, ignoring");
            return true;
        }
        throw new IllegalArgumentException(clazz + " is not a SERVER provider");
    }
    return false;
}
 
开发者ID:apache,项目名称:tomee,代码行数:12,代码来源:CxfRsHttpListener.java

示例12: getRuntimeType

import javax.ws.rs.RuntimeType; //导入依赖的package包/类
@Override
public RuntimeType getRuntimeType() {
    return RuntimeType.SERVER;
}
 
开发者ID:minijax,项目名称:minijax,代码行数:5,代码来源:MinijaxApplication.java

示例13: testJWSAuthenticationFilterHeaderWithNoContent

import javax.ws.rs.RuntimeType; //导入依赖的package包/类
@Test
public void testJWSAuthenticationFilterHeaderWithNoContent() throws Exception{
    //empty content and specific url
    String content = "";
    String requestURL="http://localhost:8080";
    ServletInputStream emptyContent = new DelegatingServletInputStream(new ByteArrayInputStream( content.getBytes()));

    //prepare client
    KeyStore keyStore = getKeyStoreClient();
    Key key = keyStore.getKey(clientCertAlias, clientCertPassword.toCharArray());
    JWSJerseyFilter jwsJerseyFilter = new JWSJerseyFilter();

    //environment
    ArgumentCaptor<String> argumentHeader = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> argumentHeaderValue = ArgumentCaptor.forClass(String.class);
    when(context.getConfiguration()).thenReturn(config);
    when(config.getRuntimeType()).thenReturn(RuntimeType.CLIENT);
    when(context.getProperty(JWSJerseyFilter.JWS_FILTER_KEY)).thenReturn(key);
    when(context.getUri()).thenReturn(new URI(requestURL));
    when(context.getHeaders()).thenReturn(headers);
    when(context.getEntity()).thenReturn(null);


    //test client
    jwsJerseyFilter.filter(context);
    //validation client
    verify(headers,times(1)).add(argumentHeader.capture(), argumentHeaderValue.capture());
    String headerKey = argumentHeader.getValue();
    String headerValue = argumentHeaderValue.getValue();
    Assert.assertTrue("Response from client should contain token", headerValue.contains(JWSJerseyFilter.JWS_AUTHORIZATION_START_TOKEN));
    logger.info("Client Header Content: {}={}", headerKey,headerValue);

    //prepare server
    when(request.getHeader(headerKey)).thenReturn(headerValue);
    when(request.getInputStream()).thenReturn(emptyContent);
    when(request.getRequestURL()).thenReturn(new StringBuffer(requestURL));
    //test server
    myJWSFilter.doFilter(request, response, chain);

    //validation
    verify(chain,times(1)).doFilter(any(ServletRequest.class), any(ServletResponse.class));
    verify(response, times(0)).sendError(anyInt());//check sendError is not set


}
 
开发者ID:Appverse,项目名称:appverse-server,代码行数:46,代码来源:JWSAuthenticationProcessFilterTest.java

示例14: testJWSAuthenticationFilterHeaderWithContent

import javax.ws.rs.RuntimeType; //导入依赖的package包/类
@Test
public void testJWSAuthenticationFilterHeaderWithContent() throws Exception{
    //some content and specific url
    final String content = "{\n" +
            "\t\"id\": \"0001\",\n" +
            "\t\"type\": \"donut\",\n" +
            "\t\"name\": \"Cake\",\n" +
            "\t\"image\":\n" +
            "\t\t{\n" +
            "\t\t\t\"url\": \"images/0001.jpg\",\n" +
            "\t\t\t\"width\": 200,\n" +
            "\t\t\t\"height\": 200\n" +
            "\t\t},\n" +
            "\t\"thumbnail\":\n" +
            "\t\t{\n" +
            "\t\t\t\"url\": \"images/thumbnails/0001.jpg\",\n" +
            "\t\t\t\"width\": 32,\n" +
            "\t\t\t\"height\": 32\n" +
            "\t\t}\n" +
            "}";
    String requestURL="http://localhost:8080";

    //prepare client
    ServletInputStream someContent = new DelegatingServletInputStream(new ByteArrayInputStream( content.getBytes()));
    KeyStore keyStore = getKeyStoreClient();
    Key key = keyStore.getKey(clientCertAlias, clientCertPassword.toCharArray());
    JWSJerseyFilter jwsJerseyFilter = new JWSJerseyFilter();

    //environment
    ArgumentCaptor<String> argumentHeader = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> argumentHeaderValue = ArgumentCaptor.forClass(String.class);
    when(context.getConfiguration()).thenReturn(config);
    when(config.getRuntimeType()).thenReturn(RuntimeType.CLIENT);
    when(context.getProperty(JWSJerseyFilter.JWS_FILTER_KEY)).thenReturn(key);
    when(context.getUri()).thenReturn(new URI(requestURL));
    when(context.getHeaders()).thenReturn(headers);
    when(context.getEntity()).thenReturn(content);
    doAnswer(new Answer<Void>(){
        @Override
        public Void answer(InvocationOnMock invocation) throws Throwable{
            Object[] arguments = invocation.getArguments();

            ((OutputStream)arguments[6]).write(content.getBytes());
            ((OutputStream)arguments[6]).flush();
            return null;
        }
    }).when(messageBodyWriter).writeTo(any(Object.class), any(Class.class), any(Type.class), any(Annotation[].class), any(MediaType.class), any(MultivaluedMap.class), any(OutputStream.class));
   
    /* TODO: Next sentence is not working because of jax.ws.rs version change, it needs to be reviewed 
    when(messageBodyWorkers.getMessageBodyWriter(any(Class.class), any(Type.class), any(Annotation[].class), any(MediaType.class))).thenReturn(messageBodyWriter);
    */
    jwsJerseyFilter.setWorkers(messageBodyWorkers);

    Type entity = content.getClass();
    when(context.getEntityClass()).thenReturn((Class)entity);


    //test client
    jwsJerseyFilter.filter(context);
    //validation client
    verify(headers,times(1)).add(argumentHeader.capture(), argumentHeaderValue.capture());
    String headerKey = argumentHeader.getValue();
    String headerValue = argumentHeaderValue.getValue();
    Assert.assertTrue("Response from client should contain token", headerValue.contains(JWSJerseyFilter.JWS_AUTHORIZATION_START_TOKEN));
    logger.info("Client Header Content: {}={}", headerKey,headerValue);

    //prepare server
    when(request.getHeader(headerKey)).thenReturn(headerValue);
    when(request.getInputStream()).thenReturn(someContent);
    when(request.getRequestURL()).thenReturn(new StringBuffer(requestURL));
    //test server
    myJWSFilter.doFilter(request, response, chain);

    //validation
    verify(chain,times(1)).doFilter(any(ServletRequest.class), any(ServletResponse.class));
    verify(response, times(0)).sendError(anyInt());//check sendError is not set


}
 
开发者ID:Appverse,项目名称:appverse-server,代码行数:80,代码来源:JWSAuthenticationProcessFilterTest.java

示例15: getRuntimeType

import javax.ws.rs.RuntimeType; //导入依赖的package包/类
@Override
public RuntimeType getRuntimeType() {
    return get().getRuntimeType();
}
 
开发者ID:apache,项目名称:tomee,代码行数:5,代码来源:ThreadLocalConfiguration.java


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