lunes, mayo 19, 2014
Java Cookbook Review
Testing Polyglot Persistence Done Right [slides]
And here you can see the slides (http://www.slideshare.net/asotobu/testing-polyglot-persistence-done-right). If you have any question don't hesitate to approach us.
Alex.
En los mapas me pierdo. Por sus hojas navego. Ahora sopla el viento, cuando el mar quedó lejos hace tiempo. (Pájaros de Barro - Manolo García)
Music: https://www.youtube.com/watch?v=9zdEXRKJSNY
Etiquetas: arquillian, arquillian persistence extension, geecon, nosql, nosqlunit, persistence layer tests, sql, test
lunes, abril 21, 2014
JPA Tip: Inject EntityManager instead of using PersistenceContext
Almost all projects you develop with Java EE will contain a persistence layer and probably you will use JPA for dealing with SQL systems. One way to get an EntityManager is using @PersistenceContext. In this post we are going to explore the advantages of injecting EntityManager instead of using PersistenceContext annotation.
We keep reading,
Alex
Pistol shots ring out in the bar-room night, Enter Patty Valentine from the upper hall, She sees a bartender in a pool of blood, Cries out, "My God, they killed them all" (Hurricane - Bob Dylan)
Music: https://www.youtube.com/watch?v=hr8Wn1Mwwwk
Etiquetas: Apache TomEE, arquillian, CDI, java persistence, jpa
lunes, abril 14, 2014
Docstract-0.2.0 Released.
- if include contains a java file, like first example, the whole class is read and inserted within AsciiDoc source code blocks.
- if include contains a java file but with # symbol, like second one, the right part of # will be used as method name of given class. So for example Project#setId(String, String) will include a method of Project's class called setId and receiving two string parameters.
- if include contains an xml file, the file is inserted "as is" within AsciiDoc source code block.
- if include contains an xml file and between brackets there is an xpath expression, the result of that expression will be inserted.
- any other include is left "as is", so it will be processed by AsciiDoc(tor) processor.
Also note that the include files will be resolved relative from place where the CLI is being run, typically from the root of the project.
You can use callouts inside java and xml code and the processor will render it in the proper way.
In java you can write a callout as a single line comment with callout number between <, > at start.
To render previous class we can call as:
java -jar docstract-<version>.jar --input=src/test/java/com/lordofthejars/asciidoctorfy/MM.java --output=README.adoc
Alex.
Weiß mit dem Locken umzugehn, Und mich auf's Pfeifen zu verstehn. Drum kann ich froh und lustig sein, Denn alle Vögel sind ja mein. (Die Zauberflöte - Wolfgang Amadeus Mozart)Music: https://www.youtube.com/watch?v=PRtvVQ1fq8s
Etiquetas: Apache TomEE, asciidoc, asciidoctor, documentation, tomitribe
miércoles, marzo 26, 2014
Apache TomEE + NoSQL (writing your own resources)
We keep learning,
Alex.
Et j’ai sa main!, Jour prospère!, Me voici, Militaire et mari! (Ah mes amis - Gaetano Donizetti)
Music: https://www.youtube.com/watch?v=3aS6M8j3pvQ
Etiquetas: Apache TomEE, nosql, patterns, resources
martes, febrero 18, 2014
Learn CDI with Apache TomEE [Video tutorials]
Servlets
CDI (Inject)
CDI (Scopes)
CDI (Name Qualifiers)
CDI (Qualifiers)
CDI (Alternatives)
CDI (Postconstruct)
CDI (Producer)
CDI (Events)
CDI (Interceptors)
CDI (Decorators)
We Keep Learning,
Que vas a hacer sin mí, Cuando tú te enteres que you estoy pegao, Con el que sabe no se juega, Y si se juega con cuidado (El Cuchi Cuchi - Mayimbe)
Etiquetas: Apache TomEE, CDI, Context Dependency Injection, java ee, Java EE 6, JavaEE
lunes, febrero 17, 2014
Aliens have invaded Undertow
What is Undertow?
Writing tests for Undertow
- Embedded Servlet Deployment
- Non-blocking handler
Maven Artifacts
Embedded Servlet Deployment
Non-blocking handler
Configuration
So now you can write tests for Undertow container within the context of Arquillian.
We keep learning,
Alex.
Oh django! After the showers is the sun. Will be shining... (Django - Luis Bacalov & Rocky Roberts)
Music: https://www.youtube.com/watch?v=UX3h22aABIc
Etiquetas: arquillian, integration tests, undertow, unit testing
lunes, enero 27, 2014
DRY with examples on documentation. Include Java Extension for Asciidoctor.
Using tags:
The attributes you can set in include are:
- imports: adds the imports.
- fields: adds the fields of the main class.
- class: adds all the content of the main class.
- enum=<classname>: adds the enum with the given name. The enum should be defined inside the class we are adding.
- annotation=<classname>: same as enum but for annotations.
- class=<classname>: same as enum but for inner classes.
- contructor=<constructorName>(<parameterType1>,<parameterType2>, ....): adds the defined constructor. In this case we must set the constructor name and the type of each parameter. For example: MyClass(String).
- method=<returnType> <methodName>(<parameterType1>, <parameterType2>, ...): same as constructor but for methods, which implies adding the return type. Note that it is not required to add any modifier nor throws classes.
Now we can use our classes within our documentation and by adding the required block.
This version of plugin works with Java 1.7 and before, not with Java 1.8 but it could work in some cases.
The extension is published on bintray, so to install you simply have to add bintray repository and the required dependency:
The project is hosted at: https://github.com/lordofthejars/asciidoctorj-extensions
We keep learning,
Alex.
I feel shouting ya-hoo, And me still feeling hungry, Cowabunga!!, Cookie monster went and ate the new red two. Monster Went and Ate My Red 2 - Elvis Costello & ElmoMusic: https://www.youtube.com/watch?v=KxardpBReQc
Etiquetas: asciidoc, asciidoctor, documentation, java 1.7
viernes, enero 24, 2014
Reporting JBehave results in AsciiDoc format.
Reporter is released on bintray, so the first thing is to add as repository maven bintray.
Then we can add the dependency on our project:
And now we can configure StoryReporterBuilder with adoc format.
And that's all, now when you run JBehave your reports will appear on output directory as HTML or TXT but also as AsciiDoc.
We keep learning,
Alex.
He's the guy who's the talk of the town, with the restless gun, don't shoot broad out to fool him around (Lo chiamavano Trinità - Annibale E I Cantori Moderni)Music: https://www.youtube.com/watch?v=w5HkxTLp5jA
Etiquetas: asciidoc, asciidoctor, bdd, continuous delivery, documentation, JBehave, user story
jueves, diciembre 19, 2013
Documentation is a Living System with Asciidoctor
Note that we are adding a suffix to the output file by using id tag, so the final name will be foobank-doc.war. And finally we setup that all files inside target/generated-docs will be packaged.
And now you can deploy this WAR file in your documentation server, so every team on your project will be able to read the latest content generated at the same time of compiling, packaging or deploying your application. Your documentation is treated as code.
You can see a full example in https://github.com/lordofthejars/foobank.
We keep learning,
Alex.
Desolation comes upon the sky, Now I see fire, Inside the mountain, I see fire (I See Fire - Ed Sheeran)Music: http://www.youtube.com/watch?v=DzD12qo1knM
Etiquetas: asciidoc, asciidoctor, asciidoctor-maven-plugin, assembly plugin, documentation
sábado, diciembre 14, 2013
Asciidoctor Meets JBehave.
So let's see an screenshot of previous document rendered:
Maman dit Annotate"travailler c'est bien", Bien mieux qu'être mal accompagné, Pas vrai ? (Papaoutai - Stromae)
Etiquetas: acceptance test, asciidoctor, documentation, JBehave, user story
martes, diciembre 03, 2013
Are Configuration Files Documentation? ... Yes!!! TomEE + Asciidoctor Example
Normally in our projects we generate a considerable amount of documentation. Some documentation is directly a document written as is, for example Software Requirements Specifications (SRS) or Software Design Specifications (SDS), but there are other pieces of our projects that although they are not a document directly, they are consulted by developers/testers/managers, customers ... and treat it as is, for example user stories written by developers and/or QA in Cucumber or JBehave format or javadoc. And now I ask to myself, are configuration files documentation too? Are people interested in having them in a document and treat them as documentation? And the answer is YES!!!. In this post we are going to see how to transform TomEE's configuration file into a document using an Asciidoctor extension I have developed specially for this occasion.
- In developer environment the DataSource could point to an embedded database.
- In QA environment the DataSource could point to a database installed on localhost.
- In Stage environment the same DataSource points to an external IP1.
- In Production environment the same DataSource points to an external IP2.
Probably your projects will have a document called for example infrastructure (or something similar) where all information related with the software that is being used in the project and environments used will be described.
A simple example of these kind of documents can be:
Note that besides describing the software that is going to be used for solving our problem, in this case an Apache TomEE, we are using the tomee-asciidoctor-extension to add the Apache TomEE's container and resources configuration file, so when someone wants to inspect the documentation will also see exactly the configuration values that had Apache TomEE at time of generating the document. If you look carefully you only need to add next line to transform a Apache TomEE configuration file into documentation:
include::tomee:/home/alex/git/asciidoctorj-extensions/tomee-asciidoctorj-extensions/src/test/resources/resources.xml[initialLevel=2]
In this case we are including a file called resources.xml. Note that in order to extension detects an Apache TomEE configuration file, we need to use the special keyword tomee: followed by the location of the file. Also note that we are using an attribute called initialLevel. Because we are embedding one document into another one, we need a way to set at which level the document will be rendered, and this is what this attribute is designed for.
Previous document rendered with default style sheet looks like:
See that thanks of Asciidoctor and its extension system, we are able to convert configuration files to documentation.
You can see the code of this extension at: https://github.com/lordofthejars/asciidoctorj-extensions/tree/master/tomee-asciidoctorj-extensions
We keep learning,
Alex.
Siente y baila y goza, Que la vida es una sola, Voy a reír, voy a bailar, Vive, sigue, Siempre pa'lante (Vivir Mi Mida - Marc Anthony)
Music: http://www.youtube.com/watch?v=YXnjy5YlDwk
Etiquetas: Apache TomEE, asciidoc, asciidoctor, configuration files, documentation
sábado, noviembre 16, 2013
Is there an Asciidoctor on board ?
Etiquetas: asciidoc, asciidoctor, JBoss Asylum, podcast
Tomcat y Java EE con TomEE {y mucho más}
Etiquetas: Apache Tomcat, Apache TomEE, GuateJUG, JavaEE
lunes, octubre 21, 2013
Resistance is futile mocks will be assimilated
My slides of my recently talk about testing at Codemotion Madrid. The summary of the talk was:
I would like to say thank you very much to Laura and all the team to arrange such a great conferences. Hope to see you in next Codemotion.
Etiquetas: arquillian, arquillian graphene, byteman, email testing, junit, Selenium 2
miércoles, septiembre 04, 2013
NoSQLUnit 0.7.7 Released
- Allow for array types in GraphML (https://github.com/lordofthejars/nosql-unit/issues/82)
- Enhancing manual index support in GraphML (https://github.com/lordofthejars/nosql-unit/pull/81)
- Bug Issue #79 (https://github.com/lordofthejars/nosql-unit/issues/79)
- Updated Cassandra-Unit to 1.1.2.1 and Cassandra to 1.2.0 (https://github.com/lordofthejars/nosql-unit/pull/76)
Alex.
I belong with you, You belong with me, You're my sweetheart (Ho Hey - The Lumineers)
Music: http://www.youtube.com/watch?v=zvCBSSwgtg4
Etiquetas: integration tests, nosqlunit, tests, unit testing
lunes, julio 22, 2013
AsciiDoc Editor with MarkItUp
We keep learning,
Alex.
Your love is blind, blind as a bat, The way that you're leading me home like that, Your love is blind, blind as bat (Blind as a Bat - Meatloaf)
Code: https://github.com/lordofthejars/asciidoctor-markitup
Music: http://www.youtube.com/watch?v=EpzeSSeOvw0
Etiquetas: asciidoc, asciidoctor, javascript, jquery, markitup
lunes, junio 10, 2013
Searchable documents? Yes You Can. Another reason to choose AsciiDoc
Let's add required dependencies:
An example of json document stored in Elasticsearch can be:
If you want you can take a look to both documents used in this example in https://github.com/asciidoctor/asciidoctor.github.com/blob/develop/news/asciidoctor-java-integration-0-1-3-released.adoc and https://github.com/asciidoctor/asciidoctor.github.com/blob/develop/news/asciidoctor-maven-plugin-0-1-2-released.adoc.
Next part is inserting documents inside one index. This is done by using prepareIndex method, which requires an index name (docs), an index type (asciidoctor), and the id of the document being inserted. Then we call setSource method which transforms the XContentBuilder object to json, and finally by calling execute().actionGet(), data is sent to database.
The final step is only required because we are using an embedded instance of Elasticsearch (in production this part should not be required), which refresh the indexes by calling refresh method.
After that point we can start querying Elasticsearch for retrieving information from our AsciiDoc documents.
Let's start with very simple example, which returns all documents inserted:
More queries, how about finding documents written by someone who is called Alex, but not Soto.
Also you can find all documents which contains the word released on title.
And finally let's find all documents that talks about 0.1.2 release, in this case only one document talks about it, the other one talks about 0.1.3.
Note that in this case we are printing the AsciiDoc content through console, but you could use asciidoctor.render(String content, Options options) method to render the content into required format.
So in this post we have seen how to index documents using Elasticsearch, how to get some important information from AsciiDoc files using Asciidoctor-java-integration project, and finally how to execute some queries to inserted documents. Of course there are more kind of queries in Elasticsearch, but the intend of this post wasn't to explore all possibilities of Elasticsearch.
I work hard (he works hard) every day of my life, I work till I ache in my bones, At the end (at the end of the day), I take home my hard earned pay all on my own (Somebody To Love - Queen)
Etiquetas: asciidoc, asciidoctor, elasticsearch, nosql, searchable
Implementing Timeouts with FutureTask
When the garden flowers baby are dead yes, And your mind [, your mind] is [so] full of RED, Don't you want somebody to love, Don't you need somebody to love (Somebody to love - Jefferson Airplane)
Etiquetas: FutureTask, java, timeout
domingo, abril 28, 2013
Git Bisect in Action
You can watch it in HD to see clearly each command.
We keep learning,
Alex.
Siempre quise ir a L.A. Dejar un día esta ciudad. Cruzar el mar en tu compañía. (Cadillac Solitario - Loquillo)Music: http://www.youtube.com/watch?v=kg0Jlpgzel4
Etiquetas: bugs, git, git bisect