Skip to content

Instantly share code, notes, and snippets.

View VineetReynolds's full-sized avatar
🚀

Vineet Reynolds VineetReynolds

🚀
View GitHub Profile
@aslakknutsen
aslakknutsen / start_testing_java8_today.asciidoc
Last active October 11, 2023 20:07
Example of how to use both JDK 7 and JDK 8 in one build.

JDK 8 Released

Most of us won’t be able to use/deploy JDK 8 in production for a looong time. But that shouldn’t stop us from using it, right?

It should be possible to sneak in JDK 8 in the back way, the same way we snuck in Groovy and other libraries we wanted to use.

The Test Suite to the rescue

The Maven compiler plugin run in two separate lifecycles, compile and testCompile. Those can be configured separately.

@VineetReynolds
VineetReynolds / generate.fsh
Last active December 21, 2015 17:19
Generating AngularJS Scaffold for TicketMonster
forge install-plugin angularjs;
git clone git@github.com:jboss-jdf/ticket-monster.git;
cd ticket-monster/demo/;
rest endpoint-from-entity --contentType application/json org.jboss.jdf.example.ticketmonster.model.* --strategy ROOT_AND_NESTED_DTO;
scaffold-x setup --scaffoldType angularjs --targetDir admin;
scaffold-x from src/main/java/org/jboss/jdf/example/ticketmonster/model/*;
@VineetReynolds
VineetReynolds / Generating REST resources.asciidoc
Last active December 17, 2015 00:59
A collection of notes describing generation of REST resources for JPA object graphs of various types.

General assumptions

This section outlines some general assumptions of the behavior of the generated REST resources:

Read all resources

Perform a GET to the REST resource collection URL (i.e. to /rest/customers and not /rest/customers/1). An array/list representation of the collection in the appropriate content-type is returned.

Create a new Resource

Perform a POST to the REST resource collection URL. A 201 Response is generated containing the resource identifier with the location of the newly created resource in the Location header. In some cases it might be beneficial to generate a 200 response so that the client does not have to issue a subsequent GET (discuss).

@VineetReynolds
VineetReynolds / Arquillian_Spock_Integration_Notes.md
Created February 24, 2012 11:08
Arquillian Spock Integration Notes

Design Notes

A global extension ArquillianSpockExtension (of type org.spockframework.runtime.extension.IGlobalExtension) is used to hook into the Spock/Sputnik testrunner lifecycle.

This allows an @Deployment method specified in a Specification to be found (indirectly) by the Sputnik testrunner:

  • The ArquillianSpockExtension builds a new instance of an Arquillian TestRunnerAdaptor. This adaptor is used to manage the Arquillian lifecycle.
  • An ArquillianInterceptor (that references the previously created TestRunnerAdaptor) is established as an interceptor for several Spec method kinds: SETUP_SPEC, CLEANUP_SPEC, SETUP, CLEANUP and FEATURE.
  • When the Sputnik testrunner fires a method of type SETUP_SPEC, the ArquillianInterceptor intercepts this invocation to direct the TestRunnerAdaptor of Arquillian to fires it's BeforeClass event. At this point, managed/embedded containers would be started by Arquillian. A deployment scenario is generated if a @Deployment method is d
@aslakknutsen
aslakknutsen / RemoteDomainTestCase.java
Created February 13, 2012 13:57
Arquillian Domain Server support
/*
* JBoss, Home of Professional Open Source
* Copyright 2011 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @authors tag. All rights reserved.
* See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@VineetReynolds
VineetReynolds / Readme.md
Created February 6, 2012 17:38
Proposed Features for the Arquillian-JBehave Integration

Features for the Arquillian-JBehave integration

  • Feature: Execution of stories in-container (obviously)
  • Note - This works as intended, now.
  • Feature: Execution of stories at the client (again, obviously)
  • Note - This works as intended, now.
  • Feature: Injection of dependencies into the JBehave Steps classes. It would be worth looking at reusing the TestEnrichers used by Arquillian to originally enrich the test class. Dependency injection might be possible if the integration were to provide a custom InjectableStepsFactory that injects the step instances with the required dependencies.
  • Note - This is now currently possible. All looks good, except for the manner in which it has been achieved. JBehave executes stories in a new thread. This results in the unavailability of the contexts and ThreadLocal datastores used by the TestEnrichers. The hack/workaround for this is to first obtain references to the enrichers by @Observing the Before event
@aslakknutsen
aslakknutsen / RestClientTestClass.java
Created November 15, 2011 17:58
Arquillian Extension REST - Rest Client Annotations on TestMethods
/*
* JBoss, Home of Professional Open Source
* Copyright 2011 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @authors tag. All rights reserved.
* See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@VineetReynolds
VineetReynolds / SHRINKDESC-97 Notes.md
Created November 12, 2011 04:26
SHRINKDESC-97 Notes

The importAsNode(InputStream, boolean) method of the XmlDomNodeImporterImpl class, parses the provided InputStream into a XML document, using a DocumentBuilder. Under the hood, the InputStream is wrapped as an InputSource, whose encoding is unknown - we haven't created the InputSource ourselves, and neither is an explicit encoding specified for the InputSource using the setEncoding method. When the input stream contains umlauts encoded in ISO-8859-1, the parser (in-built Xerces of the Oracle/Sun JRE) incorrectly attempts reading them as UTF-8; see the bug report for the parser behavior.

Going by the API documentation for the InputSource class, the solution is to either use an InputSource with an underlying character stream, or to specify the encoding for the byte stream.

Using a character stream

This would require introduction of anothe