use of org.glassfish.jersey.internal.inject.InjectionManager in project jersey by jersey.
the class WadlGeneratorConfigTest method testBuildWadlGeneratorFromDescriptions.
@Test
public void testBuildWadlGeneratorFromDescriptions() {
final InjectionManager locator = InjectionManagerFactory.createInjectionManager();
final String propValue = "bar";
WadlGeneratorConfig config = WadlGeneratorConfig.generator(MyWadlGenerator.class).prop("foo", propValue).build();
WadlGenerator wadlGenerator = config.createWadlGenerator(locator);
Assert.assertEquals(MyWadlGenerator.class, wadlGenerator.getClass());
Assert.assertEquals(((MyWadlGenerator) wadlGenerator).getFoo(), propValue);
final String propValue2 = "baz";
config = WadlGeneratorConfig.generator(MyWadlGenerator.class).prop("foo", propValue).generator(MyWadlGenerator2.class).prop("bar", propValue2).build();
wadlGenerator = config.createWadlGenerator(locator);
Assert.assertEquals(MyWadlGenerator2.class, wadlGenerator.getClass());
final MyWadlGenerator2 wadlGenerator2 = (MyWadlGenerator2) wadlGenerator;
Assert.assertEquals(wadlGenerator2.getBar(), propValue2);
Assert.assertEquals(MyWadlGenerator.class, wadlGenerator2.getDelegate().getClass());
Assert.assertEquals(((MyWadlGenerator) wadlGenerator2.getDelegate()).getFoo(), propValue);
}
use of org.glassfish.jersey.internal.inject.InjectionManager in project jersey by jersey.
the class WadlGeneratorConfigurationLoaderTest method testLoadConfigClass.
@Test
public void testLoadConfigClass() throws URISyntaxException {
final ResourceConfig resourceConfig = new ResourceConfig();
resourceConfig.property(ServerProperties.WADL_GENERATOR_CONFIG, MyWadlGeneratorConfig.class.getName());
final InjectionManager locator = InjectionManagerFactory.createInjectionManager(resourceConfig.getProperties());
final WadlGenerator wadlGenerator = WadlGeneratorConfigLoader.loadWadlGeneratorsFromConfig(resourceConfig.getProperties()).createWadlGenerator(locator);
Assert.assertEquals(MyWadlGenerator.class, wadlGenerator.getClass());
}
use of org.glassfish.jersey.internal.inject.InjectionManager in project jersey by jersey.
the class WadlGeneratorLoaderTest method testLoadFileFromClasspathRelative.
@Test
public void testLoadFileFromClasspathRelative() throws Exception {
final InjectionManager injectionManager = InjectionManagerFactory.createInjectionManager();
final Properties props = new Properties();
props.put("testFile", "classpath:testfile.xml");
final WadlGeneratorDescription description = new WadlGeneratorDescription(MyWadlGenerator2.class, props);
final WadlGenerator wadlGenerator = WadlGeneratorLoader.loadWadlGeneratorDescriptions(injectionManager, description);
Assert.assertEquals(MyWadlGenerator2.class, wadlGenerator.getClass());
final URL resource = getClass().getResource("testfile.xml");
Assert.assertEquals(new File(resource.toURI()).getAbsolutePath(), ((MyWadlGenerator2) wadlGenerator).getTestFile().getAbsolutePath());
}
use of org.glassfish.jersey.internal.inject.InjectionManager in project jersey by jersey.
the class WadlGeneratorLoaderTest method testLoadFileFromClasspathAbsolute.
@Test
public void testLoadFileFromClasspathAbsolute() throws Exception {
final InjectionManager injectionManager = InjectionManagerFactory.createInjectionManager();
final Properties props = new Properties();
final String path = "classpath:/" + getClass().getPackage().getName().replaceAll("\\.", "/") + "/testfile.xml";
props.put("testFile", path);
final WadlGeneratorDescription description = new WadlGeneratorDescription(MyWadlGenerator2.class, props);
final WadlGenerator wadlGenerator = WadlGeneratorLoader.loadWadlGeneratorDescriptions(injectionManager, description);
Assert.assertEquals(MyWadlGenerator2.class, wadlGenerator.getClass());
final URL resource = getClass().getResource("testfile.xml");
Assert.assertEquals(new File(resource.toURI()).getAbsolutePath(), ((MyWadlGenerator2) wadlGenerator).getTestFile().getAbsolutePath());
}
use of org.glassfish.jersey.internal.inject.InjectionManager in project jersey by jersey.
the class WadlGeneratorLoaderTest method testLoadFileFromAbsolutePath.
@Test
public void testLoadFileFromAbsolutePath() throws Exception {
final InjectionManager injectionManager = InjectionManagerFactory.createInjectionManager();
final URL resource = getClass().getResource("testfile.xml");
final Properties props = new Properties();
final String path = new File(resource.toURI()).getAbsolutePath();
props.put("testFile", path);
final WadlGeneratorDescription description = new WadlGeneratorDescription(MyWadlGenerator2.class, props);
final WadlGenerator wadlGenerator = WadlGeneratorLoader.loadWadlGeneratorDescriptions(injectionManager, description);
Assert.assertEquals(MyWadlGenerator2.class, wadlGenerator.getClass());
Assert.assertEquals(new File(resource.toURI()).getAbsolutePath(), ((MyWadlGenerator2) wadlGenerator).getTestFile().getAbsolutePath());
}
Aggregations