OpenDDR-org/OpenDDR-Java — Issue #1: java.lang.ClassCastException
Author: ballesterosdm
Created: 2012-01-30 09:23:46+00:00
State: open

Hi.

First of all, I would like to thank you for this great job.

I have created a very simple JUnit test to test OpenDDR because I want to integrate it in an application where I was using WURFL. Test code is very simple:

------------------------------
initializationProperties.load(this.getClass().getResourceAsStream("/oddr/oddr.properties"));
ServiceFactory.newService("org.openddr.simpleapi.oddr.ODDRService",initializationProperties.getProperty(ODDRService.ODDR_VOCABULARY_IRI), initializationProperties);
------------------------------

I have initialized the /oddr/oddr.properties file properly.

When I run the test, a java.lang.ClassCastException is raised in the method: org.openddr.simpleapi.oddr.builder.device.TwoStepDeviceBuilder.sortElement

If I comment the line where this method is called (line 178 class TwoStepDeviceBuilder.sortElement) the test is passed. Any idea about how can I prevent this behaviour?

The exception trace is shown in the following lines:
--------------------------------
java.lang.ClassCastException: java.lang.String cannot be cast to org.openddr.simpleapi.oddr.model.device.Device
at org.openddr.simpleapi.oddr.builder.device.TwoStepDeviceBuilder.sortElement(TwoStepDeviceBuilder.java:205)
at org.openddr.simpleapi.oddr.builder.device.TwoStepDeviceBuilder.afterOderingCompleteInit(TwoStepDeviceBuilder.java:178)
at org.openddr.simpleapi.oddr.builder.device.OrderedTokenDeviceBuilder.completeInit(OrderedTokenDeviceBuilder.java:93)
at org.openddr.simpleapi.oddr.identificator.DeviceIdentificator.completeInit(DeviceIdentificator.java:105)
at org.openddr.simpleapi.oddr.ODDRService.initialize(ODDRService.java:530)
at org.w3c.ddr.simple.ServiceFactory.newService(ServiceFactory.java:80)
---------------------------------

Thanks in advance.