2 Replies Latest reply on Feb 1, 2011 6:44 PM by gunnar.morling

    Setting ValidationServices under arquillian-weld-ee-embedded-1.1

    gunnar.morling

      Hi,

       

      I'm building a test with Weld using arquillian-weld-ee-embedded-1.1. This container provides mock implementations for some of Weld's SPI services for environment interaction, one of them being ValidationServices.

       

      In my test I have an injection point for javax.validation.ValidatoryFactory which due to the presence of the mock ValidationServices is populated with a mock implementation as well. For my test I'd need a real ValidatorFactory though, but right now I don't have any idea how to acomplish this. I'd also be fine, if the mock ValidationServices were not registered, in that case I could simply register my own ValidatorFactory bean.

       

      Thanks for any help, Gunnar

        • 1. Re: Setting ValidationServices under arquillian-weld-ee-embedded-1.1
          aslak

          This is a bootstrap registered service in the Weld EE container and can't be changed in a supported way. I would recommend you use a full container (JBoss / Glassfish) to test those scenarios.

           

          There are possible two other options you could try

           

          • The Weld SE container does not have a registered ValidationServices, so you can create a custom Producer for Validator here, but Weld SE does not have Request/Session scope active. So you would have to handle the Scopes manually via Weld specific calls. (A standarized API for scope control acorss all containers and vendors are coming, but not done yet.)

           

          • Outside any supported API/SPI and tied to Weld, it might work to inject BeanManagerImpl, use getServices and add your own v. of ValidationServices. If this works and possible sides effects are unknown.
          1 of 1 people found this helpful
          • 2. Re: Setting ValidationServices under arquillian-weld-ee-embedded-1.1
            gunnar.morling

            Thanks for your feedback. I've switched over to the Weld SE container in between and as you suggest I'm manually registering a Validator bean (I had used EE in the first place as the SE container currently doesn't support portable extensions (https://issues.jboss.org/browse/ARQ-335)).

             

            Do you plan to provide some way to set this kind of service in the Weld EE container? Otherwise I think it would be better if the mock implementations of the Weld services threw UnsupportedOperationExceptions that make clear that they can't be used.