Skip to content

Instantly share code, notes, and snippets.

View VineetReynolds's full-sized avatar
🚀

Vineet Reynolds VineetReynolds

🚀
View GitHub Profile
@VineetReynolds
VineetReynolds / JavaOne2012.md
Created March 13, 2012 19:26
Java One 2012 India

Session Title

A fresh look at Java Enterprise Application testing with Arquillian

Abstract

This presentation unveils the missing link in enterprise Java development: simple, portable integration tests. It introduces a solution in the first part of the session and demonstrates it in the second.

Unit tests and mocks get you only so far. Eventually you need to verify that your components operate and interact correctly in their intended environment—you need integration tests. Yet writing integration tests has meant taking on the barrier of bootstrapping the necessary infrastructure.

Arquillian, an integration testing framework built on TestNG and JUnit, tears down this barrier. It enables you to write tests that invoke real components using real enterprise services in a real runtime. In other words, you can write real tests.



Some of the highlights in this release

  • Support for a managed GlassFish container.
    With this release, you can have Arquillian manage the lifecycle of the GlassFish container.
  • Support for GlassFish 3.1.2.
    The release enables you to use Arquillian against a remote or a managed GlassFish 3.1.2 container.
@VineetReynolds
VineetReynolds / DbUnit Notes.md
Created October 13, 2012 18:44
DbUnit Notes

Notes on DbUnit behavior and internals (v2.4.8)

Empty Strings and NULLs

  • Empty tables with no rows are expected to be present in the flat XML dataset as empty elements. For example, a table ADDRESS having no rows in the dataset should be listed as in the XML file. This should be done irrespective of whether the XML would be invalid when validated against the DTD generated for the dataset (ugh! beware of red squiggly lines in Eclipse).
  • Empty strings and NULL values in flat XML datasets:
  • DbUnit distinguishes between empty strings and NULLs.
  • For flat XML datasets, a null value is represented by omitting the column in the flat XML file. For example, if streetAddress and country are columns in the ADDRESS table, then a null streetAddress would be represented as ``. One could also use a replacement dataset that will convert placeholder values to Java null references.
@VineetReynolds
VineetReynolds / Github_API_403.md
Created November 6, 2012 10:31
Awestruct Setup

Failure

Fetching https://api.github.com/users/magnussmith
403 Forbidden
/var/lib/gems/1.8/gems/rest-client-1.6.7/lib/restclient/abstract_response.rb:48:in `return!'
/var/lib/gems/1.8/gems/rest-client-1.6.7/lib/restclient/request.rb:230:in `process_result'
/var/lib/gems/1.8/gems/rest-client-1.6.7/lib/restclient/request.rb:178:in `transmit'
/usr/lib/ruby/1.8/net/http.rb:543:in `start'
/var/lib/gems/1.8/gems/rest-client-1.6.7/lib/restclient/request.rb:172:in `transmit'
/var/lib/gems/1.8/gems/rest-client-1.6.7/lib/restclient/request.rb:64:in `_execute'
@VineetReynolds
VineetReynolds / MavenConverter.java
Created November 26, 2012 15:03
ShrinkWrap MavenConverter snippet
public static String resolveArtifactVersion(Map<ArtifactAsKey, MavenDependency> dependencyManagement, String coordinates)
{
Matcher m = DEPENDENCY_PATTERN.matcher(coordinates);
if (!m.matches())
{
throw new ResolutionException("Bad artifact coordinates"
+ ", expected format is <groupId>:<artifactId>[:<extension>[:<classifier>]][:<version>]");
}
ArtifactAsKey key = new ArtifactAsKey(m.group(DEPENDENCY_GROUP_ID), m.group(DEPENDENCY_ARTIFACT_ID),
@VineetReynolds
VineetReynolds / JAXRSResourceStories.md
Last active December 10, 2015 20:58
Stories to be implemented by the HTML5 Scaffolding generator

Story: Generate JAX-RS REST Resources

As a Forge user
I want to generate JAX-RS REST resources
So that I can use them in a HTML5 app

Scenario:Support entity creation

Given a JPA entity with an auto-generated Id
When the REST resource is generated

@VineetReynolds
VineetReynolds / create-scaffold-test-1-m-bidi-project.fsh
Last active December 11, 2015 20:28
Forge scripts for producing HTML5 scaffolds. Avoid using the bidi scripts for now, since the generated projects cannot be fixed even by hand.
echo "WARNING: This script is mostly useless. The generated scaffold has issues with semantics.";
echo "Script to generate an AngularJS scaffold with uni-directional 1:M and 1:1 relationships";
new-project --named scaffoldtester;
project add-dependency org.codehaus.jackson:jackson-core-asl:1.9.2;
persistence setup --provider HIBERNATE --container JBOSS_AS7;
validation setup --provider JAVA_EE;
entity --named Customer;
field string --named firstName;
constraint NotNull --onProperty firstName;
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running org.jboss.forge.addon.manager.AddonManagerTest
Executing test case with addon dir [/tmp/forge-test-addon-dir7520866617802589423]
Feb 13, 2013 7:41:21 PM org.jboss.forge.container.impl.AddonRegistryImpl start
INFO: Starting addon (_DEFAULT_,13ba9b11-fb68-44f3-8f03-013cd52542b6)
Feb 13, 2013 7:41:21 PM org.jboss.forge.container.AddonRunnable run
INFO: > Starting container [_DEFAULT_,13ba9b11-fb68-44f3-8f03-013cd52542b6]
Feb 13, 2013 7:41:21 PM org.jboss.forge.container.modules.ModularFileSystemURLHandler handle
[INFO] ------------------------------------------------------------------------
[INFO] Building Forge - Addon Manager Addon 2.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ addon-manager ---
[INFO] Deleting /home/vineet/git-repos/forge-core/addon-manager/addon/target
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-java-version) @ addon-manager ---
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven-version) @ addon-manager ---
-------------------------------------------------------------------------------
Test set: org.jboss.forge.addon.manager.AddonManagerTest
-------------------------------------------------------------------------------
Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 5.618 sec <<< FAILURE!
testInstallingAddonWithTwoRequiredAddonDependency(org.jboss.forge.addon.manager.AddonManagerTest) Time elapsed: 0.439 sec <<< ERROR!
org.jboss.forge.container.exception.ContainerException: Error invoking Task within ClassLoader [ModuleClassLoader for Module "_DEFAULT_:be0a28bf-8df5-40ac-886b-77bd5c5060ca_a24d5fe6-6e01-4f37-bee8-f3cdc40bceaa" from AddonModuleLoader]
at org.jboss.forge.container.util.ClassLoaders.executeIn(ClassLoaders.java:38)
at org.jboss.forge.proxy.ClassLoaderInterceptor.invoke(ClassLoaderInterceptor.java:56)
at org.jboss.forge.addon.manager.AddonManagerTest_$$_javassist_0.testInstallingAddonWithTwoRequiredAddonDependency(AddonManagerTest_$$_javassist_0.java)
at sun.reflect.NativeMethod