-
Notifications
You must be signed in to change notification settings - Fork 229
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
Adding demo showing how to use CDI + JPA + JTA (@Transactional, trans… #39
Conversation
@manovotn, @mkouba, I'm using Weld JUnit in this example; could you take a look and let me know whether I'm doing something stupid? Also is there no simpler way than this (specifically, hooking up Narayana and a JNDI server) for using I'd like to blog about this, hoping it's useful to others, too. But at the same time I'm wondering whether these bits should be added to Weld JUnit eventually, making the experience much simpler out of the box. WDYT? |
9b4da6e
to
c222229
Compare
Also filed weld/weld-testing#65 to see whether this all could be baked right into Weld JUnit, giving a smoother experience out-of-the-box. |
Scanned the code, weld-junit bits are looking good!
Sounds like a good idea to me, let's discuss that in the weld-junit issue you created. |
private static NamingBeanImpl NAMING_BEAN; | ||
|
||
@Rule | ||
public WeldInitiator weld = WeldInitiator.from(((Weld) SeContainerInitializer.newInstance())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to avoid type cast here, you can simply use Weld API instead of CDI itself.
Just doing WeldInitiator.from(new Weld())...
should do the trick.
Also note that by doing this (e.g. by using pure new Weld()
), you are running with enabled discovery (your CP wll be scanned for beans) whereas commonly a synthetic archive is used to reduce bootstrap time. Not sure you intended that, so just pointing it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ha, didn't know it'd be as simple as calling new Weld()
:-)
you are running with enabled discovery...
Yes, I did this intentionally. Having to specify all the classes explicitly is one of the things I find a bit cumbersome when using Arquillian. Bootstrap time was perfectly fine when I ran the test. But it's definitely good to keep this in mind. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like an interesting addition to me.
Cool, thanks for reviewing. I'll merge it then and write something for in.relation.to within the next few days. |
…actional observer methods) in unit tests
c222229
to
a97abd9
Compare
Merged. Thanks, everone. |
…actional observer methods) in unittests
Hey @gsmet, could you take a look at this one? The other day I wanted to run CDI and Hibernate ORM in unit tests and it was quite some effort. So I thought I'd share my findings in a blog post, for which this will be the accompanying code.