use of jakarta.ws.rs.container.DynamicFeature in project resteasy by resteasy.
the class ClientDynamicFeaturesTest method testDynamicFeatures.
/**
* @tpTestDetails Check dynamic feature counts.
* @tpSince RESTEasy 3.0.16
*/
@Test
public void testDynamicFeatures() throws Exception {
ResteasyProviderFactory factory = ResteasyProviderFactory.newInstance();
RegisterBuiltin.register(factory);
factory.registerProvider(ClientDynamicFeaturesClientFeature1.class, 0, false, null);
factory.registerProvider(ClientDynamicFeaturesServerFeature1.class, 0, false, null);
factory.registerProvider(ClientDynamicFeaturesDualFeature1.class, 0, false, null);
ClientDynamicFeaturesClientFeature2 clientFeature = new ClientDynamicFeaturesClientFeature2();
ClientDynamicFeaturesServerFeature2 serverFeature = new ClientDynamicFeaturesServerFeature2();
ClientDynamicFeaturesDualFeature2 feature = new ClientDynamicFeaturesDualFeature2();
factory.registerProviderInstance(clientFeature, null, 0, false);
factory.registerProviderInstance(serverFeature, null, 0, false);
factory.registerProviderInstance(feature, null, 0, false);
Set<DynamicFeature> clientFeatureSet = factory.getClientDynamicFeatures();
Set<DynamicFeature> serverFeatureSet = factory.getServerDynamicFeatures();
Assert.assertEquals(CLIENT_FEATURE_ERROR_MSG, 1, countFeatures(clientFeatureSet, "ClientDynamicFeaturesClientFeature1"));
Assert.assertEquals(CLIENT_FEATURE_ERROR_MSG, 1, countFeatures(clientFeatureSet, "ClientDynamicFeaturesClientFeature2"));
Assert.assertEquals(CLIENT_FEATURE_ERROR_MSG, 1, countFeatures(clientFeatureSet, "ClientDynamicFeaturesDualFeature1"));
Assert.assertEquals(CLIENT_FEATURE_ERROR_MSG, 1, countFeatures(clientFeatureSet, "ClientDynamicFeaturesDualFeature2"));
Assert.assertEquals(SERVER_FEATURE_ERROR_MSG, 1, countFeatures(serverFeatureSet, "ClientDynamicFeaturesServerFeature1"));
Assert.assertEquals(SERVER_FEATURE_ERROR_MSG, 1, countFeatures(serverFeatureSet, "ClientDynamicFeaturesServerFeature2"));
Assert.assertEquals(SERVER_FEATURE_ERROR_MSG, 1, countFeatures(serverFeatureSet, "ClientDynamicFeaturesDualFeature1"));
Assert.assertEquals(SERVER_FEATURE_ERROR_MSG, 1, countFeatures(serverFeatureSet, "ClientDynamicFeaturesDualFeature2"));
}
use of jakarta.ws.rs.container.DynamicFeature in project minijax by minijax.
the class MinijaxApplication method addResourceMethod.
public void addResourceMethod(final MinijaxResourceMethod rm) {
for (final DynamicFeature dynamicFeature : dynamicFeatures) {
dynamicFeature.configure(rm, this);
}
resourceMethods.add(rm);
MinijaxResourceMethod.sortByLiteralLength(resourceMethods);
}
use of jakarta.ws.rs.container.DynamicFeature in project resteasy by resteasy.
the class ProviderFactoryTest method testDeploymentStart.
@Test
public void testDeploymentStart() {
ResteasyProviderFactory orig = ResteasyProviderFactory.peekInstance();
try {
ResteasyProviderFactory.setInstance(null);
ResteasyProviderFactory rpf1 = ResteasyProviderFactory.newInstance();
RegisterBuiltin.register(rpf1);
rpf1.registerProvider(MyInterceptor.class);
ResteasyDeployment dep1 = new ResteasyDeploymentImpl();
dep1.setProviderFactory(rpf1);
dep1.setDeploymentSensitiveFactoryEnabled(true);
dep1.start();
ResteasyProviderFactory rpf2 = ResteasyProviderFactory.newInstance();
RegisterBuiltin.register(rpf2);
rpf2.register(new DynamicFeature() {
@Override
public void configure(ResourceInfo resourceInfo, FeatureContext context) {
if (ResteasyProviderFactory.getInstance().isRegistered(MyInterceptor.class)) {
Assert.fail("Second deployment consuming provider factory from first deployment");
}
}
});
ResteasyDeployment dep2 = new ResteasyDeploymentImpl();
dep2.setProviderFactory(rpf2);
dep2.setDeploymentSensitiveFactoryEnabled(true);
dep2.start();
dep1.stop();
dep2.stop();
} finally {
ResteasyProviderFactory.setInstance(orig);
}
}
Aggregations