Spring Context wildcard in unit tests - unit-testing

We have a project setup here which uses Maven profiles quite extensively. We're using Spring, and although we mostly have an annotation-based configuration there are a few XML configuration files needed.
These Spring XML config files are pulled in with various different profiles, and in the actual web application they're all put in WEB-INF/spring and loaded up with classpath:spring/spring-*.xml. This works fine.
The problem is unit testing: I want to test a variety of different profiles, and Spring seems to have an issue with a wildcard specification like that when the files are spread over several directories.
The easiest solution I think would just be to specify each config file in the #ContextConfiguration test annotation, but unfortunately if one is missing Spring throws an exception, and there doesn't seem to be a way of turning this off.
The other thing I thought was potentially dumping all spring config files into one folder before running the tests, but that seems a bit of a kludge.
I was just wondering if anyone else had any experience of this problem and any workarounds.

It seems that the Spring guys have thought of this already.
You can use the syntax:
classpath*:spring/spring-*.xml
Which seems to work properly.

Related

How to unit test kafka streams dsl when using schema registry

Lets say I want write a unit test for the example show here :
https://github.com/confluentinc/kafka-streams-examples/blob/5.1.2-post/src/main/java/io/confluent/examples/streams/WikipediaFeedAvroLambdaExample.java
I tried the following methods, both which did not work out for me:
1) Use TopologyTestDriver.
This class is pretty useful as long as schema registry is not involved.
I tried making use of MockSchemaRegistryClient but it didn't work out.
And even if it does work out, it requires that I create my own serializers which kind of defeats the purpose of schema registry.
2) Use EmbeddedSingleNodeKafkaCluster defined in the same project.
https://github.com/confluentinc/kafka-streams-examples/blob/5.1.2-post/src/test/java/io/confluent/examples/streams/kafka/EmbeddedSingleNodeKafkaCluster.java
Now this class is really handy and seems to have embedded kafka cluster and schema registry. But it does not seem to be available in any artifact. Consequently I tried copying the class but ran into further import issues.
Unable to download this particular artifact : io.confluent:kafka-schema-registry-client:5.0.0:tests
Has anyone able to make progress with the above mentioned options? Or even a completely different solution?
For doing this I ended up doing this small test library based on testcontainers: https://github.com/vspiliop/embedded-kafka-cluster. Starts a fully configurable docker based Kafka cluster (broker, zookeeper and Confluent Schema Registry) as part of your tests. Check out the example unit and cucumber tests.

Spring Boot 2.0.0.RELEASE on aws lambda

I'm trying to make a Spring Boot (Web Starter) work on AWS Lambda and have a class not found exception. I checked MANIFEST.MF and there's a spring classpath set but not a normal classpath. I think what's happening is that in the lambda configuration you set a Handler class, but it can't find it because that class is actually in BOOT-INF.
One thing I think might be a problem is that I have two maven plugins configured:
spring-boot-maven-plugin
maven-shade-plugin
and I'm wondering if they are conflicting with each other. My shading plugin configuration excludes tomcat and undertow, but the shaded jar is the same size as the non-shaded one which isn't right.
One stackoverflow suggested configuring org.springframework.boot to use the MODULE layout, but MODULE has been removed.
Is there a known workaround for this? I could convert this to a non "starter" spring project but that's a lot of effort and I have this sinking feeling it won't solve anything. In the absence of better ideas perhaps that's what I will have to do.

Crashing WCF WebService on Windows Phone

I am using 3 webservices in my project and it was running correctly. But in these days it is crashing when creating it's client and I haven't changed anything.
How can I solve it, could you help me, please?
It's saying your service config file is not found. Are you referencing it correctly from the app.config?
It looks like you're using WPF or Silverlight so find your app.config file.
You cannot apply configSource= to since that is a config section group - not a simple config section, and the configSource attribute is only available on simple configuration sections.
You should however absolutely be able to apply the configSource attribute to any of the nodes inside - I do this all the time, in production systems - and it just works; for behaviors, services, clients, bindings, etc; each in a separate .config file.
.ClientConfig is also a bad extension. All configuration files should have .config extension.
In the worst case scenario that you can't configure the external config source for the settings, move them back tot he app.config file of the application!

How do those who are not using a backend framework (such as Rails/Symfony/Django) go about developing and deploying an Ember application's assets?

More specifically, when using a backend application framework I generally am afforded some level of asset management which allows me to work with multiple files in development which are uncompressed and unminified and then in production mode those files become automatically minified, compressed, and concatenated into a single file.
I am looking to create an Ember application that is a single page app that interfaces with a separate RESTful services layer. I simply do not need the weight of a framework behind the Ember app and am hoping to serve it as static html+css+js, so I am looking for any guidance on how to easily manage development and deployment of a client-side only app without adding much overhead.
Right now my biggest issue is with including JS (and to a lesser extent, CSS) files. My HTML is static and I have an Ember app comprised of many files, so I have many script tags to include them all. This is clearly not appropriate for production so I imagine some kind of build tool will be needed to assemble my Javascript files and overwrite the script tags in the HTML file. Are there tools out there right now that will do this? Is there another approach that I may be overlooking?
This is my first fully client-side application so it's very possible that I just need to make a paradigm shift, having done server-side applications for so long.
Agreed this can be tricky without a backend framework. For sure script tags are not the way to go and you will need some kind of build tool for production deployment.
Ember App Kit is a solution a few of us have been working on. It's still early stages but i've used it for a couple of projects so far and it's been much better than trying to roll-my-own with grunt. I would expect it to become the default starting point for ember apps in near future, to try it now just download it as a zip then read the Getting Started Guide
There are many other solid solutions out there, consider checking out:
ember-tools
brunch-with-ember-reloaded
brunch-with-hapmsters
charcoal
I use a combination of requirejs and Grunt, using these lovely functions and this one, which can compile your ember-handlebars templates into functions. (The git-contrib includes the ability to watch for changes in your files and perform various build steps which may differ if you are in development or production. You can have separate grunt functions which run various tasks for production or development. Of course for all of this you are going to need node!

Arquillian with weblogic 10.3

Our project has started mandating us to write tests for all modules going into Prod from now on. We have cases where a Spring POJO has some injected EJBs and these EJBs are used within the POJO methods. Since we couldn't find a way to unit test injected EJBs within a POJO (tried various ways but were unsuccessful), we were suggested to use Arquillian. I configured Arquillian to run on a local JBoss 6.0.0 server - all their tests ran properly from command line as well as from Eclipse.
However, our test and prod environments use Weblogic 10.3 server. I havent found much information as to how we could configure Arquillian unit tests to run in weblogic. If anyone has tried this earlier, could you please let me know which config files and what to change ?
-Sonu
The properties to be specified in the arquillian.xml file for WLS 10.3, are listed in the Arquillian Reference Guide. Usually, one may need to specify the mandatory properties, but should the need arise, other properties can be specified as well.
Note that, the contents of this page are for the 1.0.0.Alpha1 version at the moment, and would be revised at some point in the future in subsequent releases (when they are made).