Missing ActionValidatorManagerFactory In Struts 2.2.3? - struts2

Has ActionValidatorManagerFactory been replaced in Struts 2.2.3? I'm trying to write a unit test to test my validation logic, and can't find the class.

Yes, it was removed some time ago in favor of a dependency injection approach.
This may help you out:
http://www.mail-archive.com/dev#struts.apache.org/msg31637.html

Related

Warning : "org.apache.struts.util.PropertyMessageResources Resource org/apache/struts/taglib/LocalStrings_en.properties Not Found." in Struts 2.3.32 [duplicate]

I am planning to migrate to the Struts 2 with the Struts 1 code base. I am not getting any good source to proceed on this migration. Could you please help on this approach?
S1 with S2 it will overkill. Both frameworks are complicated, so the maintenance costs increase twice or more time. So, the strategy is to migrate completely to S2.
Both frameworks are implemented MVC pattern. Divide the application on three parts that should migrate separately: Model, Controller, and View. The order is not important, but logically is implied to follow the MCV order. The Model you'd probably not change, the Controller part requires to rewrite the configuration, the View is most difficult part, you have to rewrite S1 tags to S2 tags.
Migrating Struts 1.x to Struts 2.x:
You can use Struts1 actions under the struts1 plugin. Also consider to read the existing migration guide, solutions, and strategy that might help you in the migration process. Mapping actions could be easily done via convention plugin. You can't use Struts1 JSP tags with Struts2, but you can use it in Struts1 if you are running both frameworks with the same application.
Integrate Struts with Spring:
The right and up-to-date approach is to migrate to Struts2. If you
concern the things why Struts is deprecated, you might read this
article: Is Struts Dead? Part III: I can't kill Struts (Struts is
Deprecated) David Geary.
InfoQ Migration Guide:
Migrating Struts Apps to Struts 2 - Part I
Migrating to Struts 2 - Part II
Migrating to Struts 2 - Part III

Symfony2 functional test case not covering custom dependency injection config parameters

I have created a custom bundle with yml structure, and for the sake of the bundle usuage, I created a new array-set of config parameters and hence I wrote DependencyInjection/Configuration.php and DependencyInjection/MyConfigParamExtension.php.
I am crawling the site with WebTestCase extended cases, using a crawler to go to routes.
Now in my bundle code I have used the config parameters like:
$this->container->getParameter('my_search_params');
I expected the DependencyInjection classes will get covered by the test cases, but it is not the case.
Please advise me with you suggestions to improve the same.
The SymfonyDependencyInjectionTest by Matthias Noback works for me
Though its is recommended to avoid dependency injection and move all bundle specific configurations to parameters tag in config.yml

Integration tests vs Unit tests

I know this has been asked a lot of times, but this example one test confuses me. The test example here:
Testing Routes In ASP.NET MVC
Is this a unit or integration test? On the page it specifies it is a unit test but as I understand it, an integration test are tests that uses real dependencies. So is using the GlobalApplication.RegisterRoutes considered a dependency? So is this an integration test? I'm a bit confused to the extent of what a dependency is.
This is a unit test of a particular functionality of your application: the routes that you have defined.
So is using the GlobalApplication.RegisterRoutes considered a
dependency?
No, that's the subject under test - it's what you are testing. A dependency would be something that this subject depends on in order to work. It is this dependency that can be either mocked (in a unit test) or just using the actual object (in an integration test). For example if your routes were dependent on some database lookup operation then, if you don't mock this db call, you would be writing an integration test.

controllers integration test grails3: services are not getting injected

I am upgrading a grails app from 2.4.3 to 3.0.8.
There are a lot of integration tests which are using grails.util.GrailsWebUtil.bindMockWebRequest(grailsApplication.mainContext) following by controller.method call. But I discovered that grails.util.GrailsWebUtil doesn't contain bindMockWebRequest method anymore, seems like it has been replaced with grails.util.GrailsWebMockUtil, alright, but all services declared in controller are not getting injected into the class. I could use grails.test.spock.IntegrationSpec but this class has also been removed from grails3. There is a suggestion to use functional tests for integration test of controllers, but this solution doesn't work for me, I'm not itching to implement all these tests as functional, or inject dependencies manually into controller instances, how can I fix it?
Use grails.test.mixin.integration.Integration annotation instead of grails.test.spock.IntegrationSpec class extension.
And move the integration tests to src/integration-test/groovy.
I'm upgrading from Grails 2.5.1 to 3.2.4. One of my integration tests could not find the service I injected with def xxxService. I included the service in the #Mock list. XxxServiceIntegrationSpec extends Specification.
I know this does not quite relate to testing controllers, but maybe it helps?
We had dozones of controller integration in our old grails 2.x app. When we migrated to grails 3, we wanted to keep it, can not throw them and write functional tests from scratch.
Here I have blogged about it Integration testing controllers with Grails 3
The basic steps are
- setup mock request and response
- set current controller name
- rest mock request and response at the end of the test
See the above blog post for a complete example.
Hope it helps.
For anyone still looking for a solution to this (I had the same problem), I found this example really useful:
https://github.com/albertodeavila/testingGrails3

errors when database-migration plugin is defined in BuildConfig

My attempt to follow suggested good practice and put plugins in BuildConfig.groovy instead of application.properties, won't work for database-migration. I have tried defining it with scopes of compile, build and runtime. When I run grails refresh-dependencies, I get this error message:
Error WARNING: Specified dependency definition runtime(database-migration:1.3.2) is invalid! Skipping..
(of course, the scope in the message varies with that specified). Is there another scope that I should use, or is this plugin special in some way? It's a shame that the message doesn't say what scopes are valid - that way I wouldn't have to ask this question :-)
I only want to use the plugin in the IDE to generate the xml files, and so I want to exclude it from the war file. Is that what 'export=false' indicates, if the required scope would include it by default?
I have to admit that I can't find a clear definition of the various scopes, and what scope includes what. Can anyone point me at something?
I should add that this is Grails 2.1.1, and GGTS 3.1.
I have just spotted my error. I hadn't noticed that there is a colon before the name of the plugin. I had:
runtime("database-migration:1.3.2")
what I should have written is:
runtime(":database-migration:1.3.2")
A combination of 'Duh!' and what a strange syntax that requires a colon before each term. Oh well, that's how it goes. Reminds me of a time in a customer back in dark ages, when a group of people were poring over a Cobol program that was misbehaving, and no could figure out why. I had a peep, even though I hardly knew Cobol. In a trice, I pointed out that a full-stop was missing after a 'if' statement and before the 'else'. At least a colon has two full-stops, so I may have to acknowledge that my eyesight ain't what it was...

Resources