@ Override public Object [ ] [ ] getDataByKeys ( String [ ] keys ) { logger . entering ( Arrays . toString ( keys ) ) ; if ( null == resource . getCls ( ) ) { resource . setCls ( KeyValueMap . class ) ; } Object [ ] [ ] objectArray ; try { JAXBContext context = JAXBContext . newInstance ( resource . getCls ( ) ) ; Unmarshaller unmarshaller = context . createUnmarshaller ( ) ; StreamSource xmlStreamSource = new StreamSource ( resource . getInputStream ( ) ) ; Map < String , KeyValuePair > keyValueItems = unmarshaller . unmarshal ( xmlStreamSource , KeyValueMap . class ) . getValue ( ) . getMap ( ) ; objectArray = DataProviderHelper . getDataByKeys ( keyValueItems , keys ) ; } catch ( JAXBException excp ) { logger . exiting ( excp . getMessage ( ) ) ; throw new DataProviderException ( "Error unmarshalling XML file." , excp ) ; } // Passing no arguments to exiting() because implementation to print 2D array could be highly recursive. logger . exiting ( ) ; return objectArray ; }
Generates a two dimensional array for TestNG DataProvider from the XML data representing a map of name value collection filtered by keys .