Search in sources :

Example 81 with CreationalContext

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;
}
Also used : CreationalContext(javax.enterprise.context.spi.CreationalContext) Bean(javax.enterprise.inject.spi.Bean) Test(org.junit.Test)

Example 82 with CreationalContext

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);
}
Also used : Weld(org.jboss.weld.environment.se.Weld) Bean(javax.enterprise.inject.spi.Bean) SimpleFileSystemProvider(org.uberfire.java.nio.fs.file.SimpleFileSystemProvider) CreationalContext(javax.enterprise.context.spi.CreationalContext) Paths(org.uberfire.backend.server.util.Paths) BeanManager(javax.enterprise.inject.spi.BeanManager) File(java.io.File) TempFiles(org.guvnor.test.TempFiles) Before(org.junit.Before)

Example 83 with CreationalContext

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);
}
Also used : Path(org.uberfire.backend.vfs.Path) IncrementalBuildResults(org.guvnor.common.services.project.builder.model.IncrementalBuildResults) BuildResults(org.guvnor.common.services.project.builder.model.BuildResults) IncrementalBuildResults(org.guvnor.common.services.project.builder.model.IncrementalBuildResults) URL(java.net.URL) Bean(javax.enterprise.inject.spi.Bean) CreationalContext(javax.enterprise.context.spi.CreationalContext) Test(org.junit.Test)

Example 84 with CreationalContext

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);
}
Also used : Path(org.uberfire.backend.vfs.Path) IncrementalBuildResults(org.guvnor.common.services.project.builder.model.IncrementalBuildResults) BuildResults(org.guvnor.common.services.project.builder.model.BuildResults) IncrementalBuildResults(org.guvnor.common.services.project.builder.model.IncrementalBuildResults) URL(java.net.URL) Bean(javax.enterprise.inject.spi.Bean) CreationalContext(javax.enterprise.context.spi.CreationalContext) Test(org.junit.Test)

Example 85 with CreationalContext

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);
}
Also used : Path(org.uberfire.backend.vfs.Path) IncrementalBuildResults(org.guvnor.common.services.project.builder.model.IncrementalBuildResults) BuildResults(org.guvnor.common.services.project.builder.model.BuildResults) IncrementalBuildResults(org.guvnor.common.services.project.builder.model.IncrementalBuildResults) URL(java.net.URL) Bean(javax.enterprise.inject.spi.Bean) CreationalContext(javax.enterprise.context.spi.CreationalContext) Test(org.junit.Test)

Aggregations

CreationalContext (javax.enterprise.context.spi.CreationalContext)129 Bean (javax.enterprise.inject.spi.Bean)110 Test (org.junit.Test)83 URL (java.net.URL)67 Path (org.uberfire.backend.vfs.Path)67 KieModuleService (org.kie.workbench.common.services.shared.project.KieModuleService)66 Package (org.guvnor.common.services.project.model.Package)43 Module (org.guvnor.common.services.project.model.Module)13 BeanManager (javax.enterprise.inject.spi.BeanManager)10 BuildResults (org.guvnor.common.services.project.builder.model.BuildResults)6 IncrementalBuildResults (org.guvnor.common.services.project.builder.model.IncrementalBuildResults)6 Before (org.junit.Before)6 ArrayList (java.util.ArrayList)4 Context (javax.enterprise.context.spi.Context)4 InjectionTarget (javax.enterprise.inject.spi.InjectionTarget)4 WebBeansContext (org.apache.webbeans.config.WebBeansContext)4 Annotation (java.lang.annotation.Annotation)3 Method (java.lang.reflect.Method)3 Type (java.lang.reflect.Type)3 HashMap (java.util.HashMap)3