6 Replies Latest reply on Jan 13, 2014 7:57 AM by protoss78

    Errai Bus 2.4.3 and JUnit discoveries

    protoss78 Newbie

      Hi Errai Professionals,

       

      I've a question related to errai bus. I recently added it to one of my existing projects and I started to recognize the following things:

      1. When I start my web application now, I always get the following message in the console during startup:
        [WARN] Module declares a servlet class 'com.google.gwt.junit.server.JUnitHostImpl', but the web.xml has no corresponding declaration; please add the following lines to your web.xml:
      2. The size of my web project increased dramatically. Even my development setup WAR file increased its size by 40MB (compiled only for webkit browsers). When I compile my project for multiple platforms (eg regular desktop, smartphones and tablets using MGWT), I got WAR files that were suddenly a few hundred MB bigger than before using Errai
      3. When I tried to implement a proper GWT logging mechanism that also included remote logging and stacktrace deobfuscation for my production version, I couldn't get the GWT compiler to produce the required symbol maps.

       

      A little digging in the Internet quickly showed me that the reason for all above described problems seems to be that JUnit is inherited in my GWT module. Here are a few forum entries that I discovered:

       

      Since I never inherited JUnit on my own, I started to check all other GWT modules that I'm using in my GWT project. Finally I found out that ErraiBus.gwt.xml is inheriting JUnit, because of its AbstractErraiTest class.

      I can quite easily workaround issue 1 and 2, especially since issue 2 can be resolved by simply removing the .junit_symbolMaps folder. I still haven't found a fix to my symbol map generation problem. So any help on that will be much appreciated.

      But my main question would be if it is really necessary to include the AbstractErraiTest class and its JUnit inheritence in the official ErraiBus module? Wouldn't it be better to have a separate module for that?

       

      Thanks,

      8-) Roman

        • 1. Re: Errai Bus 2.4.3 and JUnit discoveries
          Jonathan Fuerth Master

          Hi Roman,

           

          The AbstractErraiTest was moved into src/main/java of the errai-bus Maven module because it's used from other modules as well. Based on your findings (thanks for digging into this issue!) it sounds like this might have unintended side effects on finished applications.

           

          After we moved AbstractErraiTest out of the test sources into the main sources, we discovered a somewhat successful mechanism for reusing classes from src/test/java across Maven modules. You can see this technique in errai-codegen and errai-codegen-gwt: the errai-codegen-gwt tests depend on types defined in src/test/java of errai-codegen. The dependency is expressed here: https://github.com/errai/errai/blob/master/errai-codegen-gwt/pom.xml#L21-L27 and the test-scoped classes and sources are exported here: https://github.com/errai/errai/blob/master/errai-codegen/pom.xml#L77-L87

           

          I say "somewhat successful" because there are still a few wrinkles with this approach: first, the dependency breaks when you run maven in offline or -DskipTests mode because the test-jar execution never happens; second, there is sometimes a dependency error during the first full-project (reactor) build after the project version number has changed.

           

          If you have ideas about how to factor out AbstractErraiTest in a better way (or any other ideas for removing the JUnit GWT module from ErraiBus), please do send a pull request with the fixes and we'll take a look!

           

          Cheers,

          Jonathan

          • 2. Re: Errai Bus 2.4.3 and JUnit discoveries
            protoss78 Newbie

            Thanks for your in-depth answer Joanathan.

            I'll try to look at everything and let you know if I can come up with another solution, but I've a feeling that you won't receive a pull request this year anymore.

             

            Cheers,

            8-) Roman

            • 3. Re: Errai Bus 2.4.3 and JUnit discoveries
              Christian Sadilek Master

              Hi,

               

              One thing we could do is create a separate errai-testing project / GWT module that we only inherit/use in our test modules. I believe that's what Roman meant? We can then move all our test base classes to this new module. The only downside is that we'll need a module for Errai Bus, IOC, CDI and JAX-RS as they all have their own individual base classes for testing. Maybe we can get away with just one module though. That's definitely worth trying.

               

              Cheers,

              Christian

              • 4. Re: Errai Bus 2.4.3 and JUnit discoveries
                protoss78 Newbie

                Hi Christian,

                 

                You are right - this was my initial thought to solve this problem. Maybe I've an even simpler solution at hand. Would it be possible to create an additional ErraiBus.gwt.xml file - maybe called ErraiBusNoTests.gwt.xml - which does not inherit JUnit but everything else that is needed. Afterward the existing ErraiBus.gwt.xml could inherit this new ErraiBusNoTests.gwt.xml right at the beginning and also inherit JUnit. This way the developers could choose which GWT module fits their needs and the default behavior would stay the same. Also the whole project structure would stay as it is.

                The MGWT project did something similar to reduce compile permutations (MGWTMin.gwt.xml and MGWT.gwt.xml):

                https://code.google.com/p/mgwt/source/browse/src/main/java/com/googlecode/mgwt/?r=a1e9368e0de5f89c973b5b684262b573eb8fd077

                 

                Maybe I'll find time on the weekend to try this, but if you guys see a reason why this approach would not work at all please let me know.

                 

                Thanks,

                8-) Roman

                • 5. Re: Errai Bus 2.4.3 and JUnit discoveries
                  Christian Sadilek Master

                  Hi Roman,

                   

                  Yes, that sounds like a really good idea (and a potential pull request ). Let us know if that worked for you!

                   

                  Cheers,

                  Christian

                  • 6. Re: Errai Bus 2.4.3 and JUnit discoveries
                    protoss78 Newbie

                    Small update from my side. I tried the ErraiBusNoTests.gwt.xml approach this weekend, but still was not able to get rid of the JUnit stuff in the compiled version. I have to recheck all of my dependencies and find out where this is now coming from. I'll keep you posted if I have any new findings.

                     

                    Thanks,

                    8-) Roman