Java Code Examples for javax.ws.rs.RuntimeType#CLIENT
The following examples show how to use
javax.ws.rs.RuntimeType#CLIENT .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConfigurationImplTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testInvalidConstraintOnProvider() { TestHandler handler = new TestHandler(); LogUtils.getL7dLogger(ConfigurableImpl.class).addHandler(handler); try (ConfigurableImpl<Client> configurable = new ConfigurableImpl<>(createClientProxy(), RuntimeType.CLIENT)) { Configuration config = configurable.getConfiguration(); configurable.register(ClientFilterConstrainedToServer.class); assertEquals(0, config.getInstances().size()); for (String message : handler.messages) { if (message.startsWith("WARN") && message.contains("cannot be registered in ")) { return; // success } } } fail("did not log expected message"); }
Example 2
Source File: ConfigurationImplTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testChecksConstrainedToAnnotationDuringRegistration() { TestHandler handler = new TestHandler(); LogUtils.getL7dLogger(ConfigurableImpl.class).addHandler(handler); try (ConfigurableImpl<Client> configurable = new ConfigurableImpl<>(createClientProxy(), RuntimeType.CLIENT)) { Configuration config = configurable.getConfiguration(); configurable.register(ContainerResponseFilterImpl.class); assertEquals(0, config.getInstances().size()); for (String message : handler.messages) { if (message.startsWith("WARN") && message.contains("Null, empty or invalid contracts specified")) { return; // success } } } fail("did not log expected message"); }
Example 3
Source File: RestClientRecorder.java From quarkus with Apache License 2.0 | 5 votes |
public void initializeResteasyProviderFactory(RuntimeValue<InjectorFactory> ifc, boolean useBuiltIn, Set<String> providersToRegister, Set<String> contributedProviders) { ResteasyProviderFactory clientProviderFactory = new ResteasyProviderFactoryImpl(RuntimeType.CLIENT, new ResteasyProviderFactoryImpl()) { @Override public RuntimeType getRuntimeType() { return RuntimeType.CLIENT; } @Override public InjectorFactory getInjectorFactory() { return ifc.getValue(); } }; if (useBuiltIn) { RegisterBuiltin.register(clientProviderFactory); registerProviders(clientProviderFactory, contributedProviders, false); } else { providersToRegister.removeAll(contributedProviders); registerProviders(clientProviderFactory, providersToRegister, true); registerProviders(clientProviderFactory, contributedProviders, false); } RestClientBuilderImpl.setProviderFactory(clientProviderFactory); providerFactory = clientProviderFactory; }
Example 4
Source File: ConfigurableImpl.java From cxf with Apache License 2.0 | 5 votes |
private boolean checkConstraints(Object provider) { Class<?> providerClass = provider.getClass(); ConstrainedTo providerConstraint = providerClass.getAnnotation(ConstrainedTo.class); if (providerConstraint != null) { RuntimeType currentRuntime = config.getRuntimeType(); RuntimeType providerRuntime = providerConstraint.value(); // need to check (1) whether the registration is occurring in the specified runtime type // and (2) does the provider implement an invalid interface based on the constrained runtime type if (!providerRuntime.equals(currentRuntime)) { LOG.warning("Provider " + provider + " cannot be registered in this " + currentRuntime + " runtime because it is constrained to " + providerRuntime + " runtimes."); return false; } Class<?>[] restrictedInterfaces = RuntimeType.CLIENT.equals(providerRuntime) ? RESTRICTED_CLASSES_IN_CLIENT : RESTRICTED_CLASSES_IN_SERVER; for (Class<?> restrictedContract : restrictedInterfaces) { if (restrictedContract.isAssignableFrom(providerClass)) { RuntimeType opposite = RuntimeType.CLIENT.equals(providerRuntime) ? RuntimeType.SERVER : RuntimeType.CLIENT; LOG.warning("Provider " + providerClass.getName() + " is invalid - it is constrained to " + providerRuntime + " runtimes but implements a " + opposite + " interface "); return false; } } } return true; }
Example 5
Source File: ConfigurationImplTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testServerFilterContractsOnClientIsRejected() { try (ConfigurableImpl<Client> configurable = new ConfigurableImpl<>(createClientProxy(), RuntimeType.CLIENT)) { Configuration config = configurable.getConfiguration(); configurable.register(TestFilter.class); Map<Class<?>, Integer> contracts = config.getContracts(TestFilter.class); assertTrue(contracts.containsKey(ClientRequestFilter.class)); assertTrue(contracts.containsKey(ClientResponseFilter.class)); assertFalse(contracts.containsKey(ContainerRequestFilter.class)); assertFalse(contracts.containsKey(ContainerResponseFilter.class)); } }
Example 6
Source File: ConfigurationImplTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testClientFilterWithNestedInterfacesIsAccepted() { try (ConfigurableImpl<Client> configurable = new ConfigurableImpl<>(createClientProxy(), RuntimeType.CLIENT)) { Configuration config = configurable.getConfiguration(); configurable.register(NestedInterfaceTestFilter.class); Map<Class<?>, Integer> contracts = config.getContracts(NestedInterfaceTestFilter.class); assertTrue(contracts.containsKey(ClientRequestFilter.class)); assertTrue(contracts.containsKey(ClientResponseFilter.class)); } }
Example 7
Source File: ClientBuilderImpl.java From cxf with Apache License 2.0 | 5 votes |
@Override public ClientBuilder withConfig(Configuration cfg) { if (cfg.getRuntimeType() != RuntimeType.CLIENT) { throw new IllegalArgumentException(); } configImpl = new ClientConfigurableImpl<>(this, cfg); return this; }
Example 8
Source File: MicroProfileClientConfigurableImpl.java From cxf with Apache License 2.0 | 4 votes |
public MicroProfileClientConfigurableImpl(C configurable, Configuration config) { super(configurable, config == null ? new ConfigurationImpl(RuntimeType.CLIENT) : new ConfigurationImpl(config)); }
Example 9
Source File: ClientConfigurableImpl.java From cxf with Apache License 2.0 | 4 votes |
public ClientConfigurableImpl(C configurable, Configuration config) { super(configurable, config == null ? new ConfigurationImpl(RuntimeType.CLIENT) : new ConfigurationImpl(config)); }