use of javax.enterprise.context.spi.CreationalContext in project core by weld.
the class SimpleInterceptorTest method testSimpleInterceptorWithStereotype.
@Test
public void testSimpleInterceptorWithStereotype() {
Bean bean = beanManager.getBeans(SimpleBeanWithStereotype.class).iterator().next();
CreationalContext creationalContext = beanManager.createCreationalContext(bean);
SimpleBeanWithStereotype simpleBean = (SimpleBeanWithStereotype) bean.create(creationalContext);
String result = simpleBean.doSomething();
assert "Hello!".equals(result);
bean.destroy(simpleBean, creationalContext);
assert SimpleInterceptor.aroundInvokeCalled;
assert SimpleInterceptor.postConstructCalled;
assert SimpleInterceptor.preDestroyCalled;
assert TwoBindingsInterceptor.aroundInvokeCalled;
assert SimpleBeanWithStereotype.postConstructCalled;
}
use of javax.enterprise.context.spi.CreationalContext in project kie-wb-common by kiegroup.
the class PackageNameAllowListLoaderTest method setUp.
@Before
public void setUp() throws Exception {
final SimpleFileSystemProvider fs = new SimpleFileSystemProvider();
// Bootstrap WELD container
weld = new Weld();
final BeanManager beanManager = weld.initialize().getBeanManager();
// Instantiate Paths used in tests for Path conversion
final Bean pathsBean = (Bean) beanManager.getBeans(Paths.class).iterator().next();
final CreationalContext cc = beanManager.createCreationalContext(pathsBean);
Paths paths = (Paths) beanManager.getReference(pathsBean, Paths.class, cc);
tempFiles = new TempFiles();
final File tempFile = tempFiles.createTempFile("allow-list");
final org.uberfire.java.nio.file.Path nioPackagePath = fs.getPath(tempFile.toURI());
pathToAllowList = paths.convert(nioPackagePath);
loader = new PackageNameAllowListLoader(packageNameSearchProvider, ioService);
}
use of javax.enterprise.context.spi.CreationalContext in project kie-wb-common by kiegroup.
the class ResourceChangeIncrementalBuilderWithoutFullBuildTest method testResourceUpdated.
@Test
public void testResourceUpdated() throws Exception {
final Bean buildChangeListenerBean = (Bean) beanManager.getBeans(org.guvnor.common.services.builder.ResourceChangeIncrementalBuilder.class).iterator().next();
final CreationalContext cc = beanManager.createCreationalContext(buildChangeListenerBean);
final org.guvnor.common.services.builder.ResourceChangeIncrementalBuilder buildChangeListener = (org.guvnor.common.services.builder.ResourceChangeIncrementalBuilder) beanManager.getReference(buildChangeListenerBean, org.guvnor.common.services.builder.ResourceChangeIncrementalBuilder.class, cc);
final URL resourceUrl = this.getClass().getResource("/BuildChangeListenerRepo/src/main/resources/update.drl");
final org.uberfire.java.nio.file.Path nioResourcePath = fs.getPath(resourceUrl.toURI());
final Path resourcePath = paths.convert(nioResourcePath);
// Perform incremental build (Without a full Build first)
buildChangeListener.updateResource(resourcePath);
waitForBuildResults(buildResultsObserver);
final BuildResults buildResults = buildResultsObserver.getBuildResults();
assertNotNull(buildResults);
assertEquals(0, buildResults.getErrorMessages().size());
assertEquals(1, buildResults.getInformationMessages().size());
final IncrementalBuildResults incrementalBuildResults = buildResultsObserver.getIncrementalBuildResults();
assertNull(incrementalBuildResults);
}
use of javax.enterprise.context.spi.CreationalContext in project kie-wb-common by kiegroup.
the class ResourceChangeIncrementalBuilderWithoutFullBuildTest method testNonPackageResourceUpdated.
@Test
public void testNonPackageResourceUpdated() throws Exception {
// This tests changes to a resource that is neither pom.xml nor kmodule.xml nor within a Package
final Bean buildChangeListenerBean = (Bean) beanManager.getBeans(org.guvnor.common.services.builder.ResourceChangeIncrementalBuilder.class).iterator().next();
final CreationalContext cc = beanManager.createCreationalContext(buildChangeListenerBean);
final org.guvnor.common.services.builder.ResourceChangeIncrementalBuilder buildChangeListener = (org.guvnor.common.services.builder.ResourceChangeIncrementalBuilder) beanManager.getReference(buildChangeListenerBean, org.guvnor.common.services.builder.ResourceChangeIncrementalBuilder.class, cc);
final URL resourceUrl = this.getClass().getResource("/BuildChangeListenerRepo/project.imports");
final org.uberfire.java.nio.file.Path nioResourcePath = fs.getPath(resourceUrl.toURI());
final Path resourcePath = paths.convert(nioResourcePath);
// Perform incremental build (Without a full Build first)
buildChangeListener.updateResource(resourcePath);
final BuildResults buildResults = buildResultsObserver.getBuildResults();
assertNull(buildResults);
final IncrementalBuildResults incrementalBuildResults = buildResultsObserver.getIncrementalBuildResults();
assertNull(incrementalBuildResults);
}
use of javax.enterprise.context.spi.CreationalContext in project kie-wb-common by kiegroup.
the class ResourceChangeIncrementalBuilderWithoutFullBuildTest method testPomResourceUpdated.
@Test
public void testPomResourceUpdated() throws Exception {
// This tests changes pom.xml
final Bean buildChangeListenerBean = (Bean) beanManager.getBeans(org.guvnor.common.services.builder.ResourceChangeIncrementalBuilder.class).iterator().next();
final CreationalContext cc = beanManager.createCreationalContext(buildChangeListenerBean);
final org.guvnor.common.services.builder.ResourceChangeIncrementalBuilder buildChangeListener = (org.guvnor.common.services.builder.ResourceChangeIncrementalBuilder) beanManager.getReference(buildChangeListenerBean, org.guvnor.common.services.builder.ResourceChangeIncrementalBuilder.class, cc);
final URL resourceUrl = this.getClass().getResource("/BuildChangeListenerRepo/pom.xml");
final org.uberfire.java.nio.file.Path nioResourcePath = fs.getPath(resourceUrl.toURI());
final Path resourcePath = paths.convert(nioResourcePath);
// Perform incremental build (Without a full Build first)
buildChangeListener.updateResource(resourcePath);
waitForBuildResults(buildResultsObserver);
final BuildResults buildResults = buildResultsObserver.getBuildResults();
assertNotNull(buildResults);
assertEquals(0, buildResults.getErrorMessages().size());
assertEquals(1, buildResults.getInformationMessages().size());
final IncrementalBuildResults incrementalBuildResults = buildResultsObserver.getIncrementalBuildResults();
assertNull(incrementalBuildResults);
}
Aggregations