Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR para viabilizar uso de frameworks de Mock #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,12 @@
package br.gov.frameworkdemoiselle.junit;

import org.jboss.weld.environment.se.Weld;
import org.jboss.weld.environment.se.WeldContainer;
import org.junit.runner.notification.RunNotifier;
import org.junit.runners.BlockJUnit4ClassRunner;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.InitializationError;

import br.gov.frameworkdemoiselle.lifecycle.AfterShutdownProccess;
import br.gov.frameworkdemoiselle.lifecycle.AfterStartupProccess;
import br.gov.frameworkdemoiselle.util.Beans;

public class DemoiselleRunner extends BlockJUnit4ClassRunner {
Expand All @@ -67,9 +66,9 @@ protected void runChild(FrameworkMethod method, RunNotifier notifier) {
@Override
public void run(RunNotifier notifier) {
Weld weld = new Weld();
weld.initialize();
WeldContainer container = weld.initialize();

this.startup();
this.startup(container);
super.run(notifier);

weld.shutdown();
Expand All @@ -79,13 +78,14 @@ protected Object createTest() throws Exception {
return Beans.getReference(getTestClass().getJavaClass());
}

private void startup() {
Beans.getBeanManager().fireEvent(new AfterStartupProccess() {
private void startup(WeldContainer container) {
Beans.setBeanManager(container.getBeanManager());
Beans.getBeanManager().fireEvent(new Object() {
});
}

private void shutdown() {
Beans.getBeanManager().fireEvent(new AfterShutdownProccess() {
Beans.getBeanManager().fireEvent(new Object() {
});
}
}