Kategorien
Cloud Cloud Foundry Java Pivotal Cloud Foundry Programming Languages

Starting with JEE on Pivotal Cloud Foundry

The following article describes a small proof of concept on how to deploy a sample JEE application. The purpose of that application is the show a transition path from traditional JEE applications requiring a huge application server installation to a more self-contained, still JEE compliant application with a smaller footprint.

Kategorien
Dev Note Java Programming Languages

DEV-NOTES|Java: Surprising import findings

You might not know that the order of static imports and ordinary imports is crucial. I stumbled upon a code snippet using a static import from a static inner class, during some codes research for a work project. Trying out that code ends up with a compiler error, saying that a standard class from the JDK was not found.

Kategorien
Dev Note Gradle Groovy

DEV-NOTES|Gradle: Reading Eclipses codeformatter xml file

This little code snippet transforms the code formatter XML description file into a properties structure which could be applied to the JDT properties later on.

def initializeFormatter() {
  def formatterDefinitions = new XmlSlurper.parse("$rootDir/misc/codeformatter.xml")
  assert formatterDefinitions instanceof GPathResult

  def Properties props = new Properties()

  formatterDefinitions.'**'.findAll{ node ->
    node.name() == 'setting'
  }*.each { n ->
    props.put(n.@id.text(), n.@value.text()
  }

  return props
}
Kategorien
Programming Languages Rust rust-taglib

Announcement of Rust-TagLib 0.0.1

Rust-taglib provides Rust bindings to the TagLib library. TagLib is a library for reading and editing meta data information of various audio formats. Recently the Rust wrapper supports the operations exposed by the simple C binding interface only.

Kategorien
AngularJS Frameworks GotoCo HTML5 Javascript Programming Languages Projects

Lazy remote service access – REST and IndexedDB

Visiting the Goto Conference in Berlin let me code a quick hack of a personal conference planner GotoCo . GotoCo is a small mobile application based on web technologies using the Ionic framework. It features to access the conference information, store them locally for later use and build your personal conference schedule. Visit http://apps.mindcrime-ilab.de/gotoco/index.html to check out the app – but due to the conference is already over it might not that useful anymore.

Conference sessions and tracks become more or less fixed after some point and network usage is always critical on mobile devices (limited speed or transfer volume). Applying a cache mechanims seems appropriate in order to make the app more responsive and mobile friendly.

Kategorien
Allgemein Book Review Scala

Book Review|Scala for Java Developers

Thanks to Packt Publishing I have got a free ebook copy of „Scala for Java Developers„.

Preface

All Java code samples are covered by the features of the Java language specification whereas the upcoming functional extensions of Java 8 are not part of the discourse.

Review / Summary

The book “Scala for Java Developers” by Thomas Alexandre is an introduction to the Scala language from a Java Developers perspective. It does not explain basic programming paradigms like object orientation beside a very small wrap up of the functional paradigm as it might not be well known to every Java coder. The book is organized into 10 sections which should be read in order and mostly build upon each other.

Kategorien
AngularJS CoffeeScript Dev Note

DEV-NOTES|AngularJS: Global fault handler

„Dev Notes“ is a small column about practical hints on certain problems or solutions taken from real world applications.

AngularJS is a great framework simplifying the development of JavaScript applications. The following example shows how to setup a global error handler to notify the user about the applications state.

fault-handler_sampleTo benefit from angulars super powers the global fault handler part visible to the user is encapsulated into an angular directive which is an easy but powerful way to enhance the HTML tag cloud with your own components. Building the handler involves roughly the following steps:

Note: For those who are not fluent in CoffeeScript the code can be ‚compiled‘ to JavaScript on the CoffeeScript homepage using the ‚Try CoffeeScript‘ tab.

  1. Add global fault handler and clear method
    app.run ($rootScope, $log) ->
      ###
      # fault handler
      ###
      $rootScope.faultHandler = (data) ->
        $log.debug "[faultHandler] error data[#{data}]"
        # handle and process error data here
        # assign error message to global fault message
        $rootScope = "ERROR: #{data}"
    
      ###
      # clear fault
      ###
      $rootScope.clearFault = () ->
        $log.debug "[faultHandler] clearing fault[#{$rootScope.errorMessage}]"
        $rootScope.errorMessage = undefined
    
  2. Create custom tag to include the error handler
    'use strict'
    
    angular.module('myApp')
      .directive('errorMessages', () ->
        template: "<div class='alert alert-danger' data-ng-show='errorMessage'><strong>Achtung:&nbsp;</strong><span data-ng-bind='errorMessage'></span></div>"
        restrict: 'E'
      )
    
    
  3. Refer to fault handler
    'use strict'
    
    angular.module('myApp')
    .controller 'UserprofilCtrl', ($scope, $rootScope, $log, UserProfilService) ->
        $scope.profil = $rootScope.user
    
        # query userprofile by UID
        result = UserProfilService.get({id: $scope.profil.uid})
    
        result.$promise.then (profil) ->
          $scope.profil = profil
          $rootScope.clearFault()
        .catch $rootScope.faultHandler
    
  4. Use it
    <!-- include the following place holder tag into your page -->
    <x-error-messages></x-error-messages>
    
Kategorien
C++ Frameworks Programming Languages QtTestLib

Creating class level xunit report files with QtTestLib

Working on my new project SynPlayer – an controller to the Synology AudioStation based on C++ and Qt – it becomes evident to set up a testing infrastructure. Keeping dependency small and simple the decision was to facilitate QtTestLib for testing purposes.

Kategorien
Gradle Quick Tip Scala

Deliver code coverage indices for Scala using Gradle and SCCT

This post is a kind of follow up post to Gradle rocking Scala Specs2 tests. After setting up the build supporting Specs2 tests we could take it a step further to provide information about the code coverage of the tests.

SCCT is a code coverage tool for Scala. One benefit of SCCT is that the output format is compliant, to the widely known Cobertura so it could easily integrated into Jenkins for example.

Kategorien
Gradle Programming Languages Quick Tip Scala

Gradle rocking scala specs2 tests

In preparation of the upcoming Coursera course „Reactive Programming“ I just want to refresh my Scala skills by porting the Coursera Downloader from Python to Scala.

Setting up the initial build with Gradle is quite easy using the Scala Plugin. Looking around for some testing framework I have chosen Specs2 . Running Gradle after building some simple unit tests shows up that the tests are not executed at all. The build passes without running one single tests. Even declaring the tests to be processed by a JUnit4 runner did not want show up a single tests result. So I came up with the following simple solution. I add a new specs2 task to my Gradle build using the specs2 file runner:

/**
 * Run Spec2 tests
 */
task specs(type: JavaExec, dependsOn: testClasses) {
    main = 'org.specs2.files'
    args = ['console']
    classpath sourceSets.main.runtimeClasspath
    classpath sourceSets.test.runtimeClasspath
    classpath configurations.testRuntime
    classpath configurations.runtime
}

The file runner will select all files matching .*Spec in the test source directory which default (src/test/scala) nicely conforms the default project setup. If necessary it could be adjusted by setting the specs2.srcTestDir system property. For more information on the Specs2 Runners refer to the Specs2 documentation.

Now you have only to hook in the test step execution which could be easily achieved by extending the test task to depend on the specs2 tasks as well:

/*
 * and  add them to the default test set
 */
test.dependsOn specs

Running the test target of the Gradle build once again shows up the execution of the specs2 target and all tests and specifications.

Update(09/04/2014)

Marino Borra points out that he could run the specs tests successfully with the default gradle test task by simply adding the @RunWith(classOf[JUnitRunner]) annotation.