Buggy code:
public class SimpleCostDescriptionTest extends TestCase { static final Logger log = LoggerFactory . getLogger ( SimpleCostDescriptionTest . class ) ; public void testEcosystemDescription ( ) throws IOException , JAXBException { CloudProvider provider = new CloudProvider ( "Amazon" ) ; provider . setUuid ( UUID . fromString ( "251ed7c7-aa4d-49d4-b42b-7efefd970d6b" ) ) ; String melaIP = "localhost" ; Integer melaPort = 8080 ; String melaURL = "//MELA//REST_WS" ; DefaultHttpClient httpClient = new DefaultHttpClient ( ) ; HttpHost endpoint = new HttpHost ( melaIP , melaPort ) ; CloudServicesSpecification cloudServicesSpecification = new CloudServicesSpecification ( ) ; cloudServicesSpecification . addCloudProvider ( provider ) ; { CloudOfferedService unit = new CloudOfferedService ( "IaaS" , "VM" , "m1.small" ) ; unit . withUuid ( UUID . fromString ( "38400000-8cf0-11bd-b23e-000000000000" ) ) ; { CostFunction vmCost = new CostFunction ( ( ( unit . getName ( ) ) + "_cost" ) ) ; CostElement vmCostElement = new CostElement ( "vmCost" , new at . ac . tuwien . dsg . mela . common . monitoringConcepts . Metric ( "instance" , "#//m" , MetricType . COST ) , Type . PERIODIC ) ; vmCostElement . addCostInterval ( new MetricValue ( Double . POSITIVE_INFINITY ) , 0.12 ) ; vmCost . addCostElement ( vmCostElement ) ; unit . addCostFunction ( vmCost ) ; } provider . addCloudOfferedService ( unit ) ; } { CloudOfferedService unit = new CloudOfferedService ( "IaaS" , "VM" , "m1.medium" ) ; unit . withUuid ( UUID . fromString ( "38400000-8cf0-11bd-b23e-000000000001" ) ) ; { CostFunction vmCost = new CostFunction ( ( ( unit . getName ( ) ) + "_cost" ) ) ; CostElement vmCostElement = new CostElement ( "vmCost" , new at . ac . tuwien . dsg . mela . common . monitoringConcepts . Metric ( "instance" , "#//m" , MetricType . COST ) , Type . PERIODIC ) ; vmCostElement . addCostInterval ( new MetricValue ( Double . POSITIVE_INFINITY ) , 0.24 ) ; vmCost . addCostElement ( vmCostElement ) ; unit . addCostFunction ( vmCost ) ; } provider . addCloudOfferedService ( unit ) ; } { CloudOfferedService unit = new CloudOfferedService ( "IaaS" , "VM" , "m1.large" ) ; unit . withUuid ( UUID . fromString ( "38400000-8cf0-11bd-b23e-000000000002" ) ) ; { CostFunction vmCost = new CostFunction ( ( ( unit . getName ( ) ) + "_cost" ) ) ; CostElement vmCostElement = new CostElement ( "vmCost" , new at . ac . tuwien . dsg . mela . common . monitoringConcepts . Metric ( "instance" , "#//m" , MetricType . COST ) , Type . PERIODIC ) ; vmCostElement . addCostInterval ( new MetricValue ( Double . POSITIVE_INFINITY ) , 0.48 ) ; vmCost . addCostElement ( vmCostElement ) ; unit . addCostFunction ( vmCost ) ; } provider . addCloudOfferedService ( unit ) ; } { CloudOfferedService unit = new CloudOfferedService ( "MaaS" , "Network" , "network" ) ; unit . withUuid ( UUID . fromString ( "38400000-8cf0-11bd-b23e-000000000003" ) ) ; { CostFunction cost = new CostFunction ( ( ( unit . getName ( ) ) + "_cost" ) ) ; <START_BUG> CostElement costElement = new CostElement ( "dataTransferCost" , new at . ac . tuwien . dsg . mela . common . monitoringConcepts . Metric ( "dataTransfer" , "MB//s" , MetricType . COST ) , Type . USAGE ) ; <END_BUG> costElement . addCostInterval ( new MetricValue ( 1024 ) , ( 0.03 // 1024 ) ) ; costElement . addCostInterval ( new MetricValue ( ( ( 10 * 1024 ) * 1024 ) ) , ( 0.01 // 1024 ) ) ; cost . addCostElement ( costElement ) ; unit . addCostFunction ( cost ) ; } provider . addCloudOfferedService ( unit ) ; } { try { JAXBContext jAXBContext = JAXBContext . newInstance ( CloudServicesSpecification . class ) ; Marshaller marshaller = jAXBContext . createMarshaller ( ) ; marshaller . setProperty ( Marshaller . JAXB_FORMATTED_OUTPUT , true ) ; StringWriter sw = new StringWriter ( ) ; marshaller . marshal ( cloudServicesSpecification , sw ) ; SimpleCostDescriptionTest . log . info ( sw . toString ( ) ) ; BufferedWriter writer = new BufferedWriter ( new FileWriter ( ".//cloud_pricing_scheme.xml" ) ) ; marshaller . marshal ( cloudServicesSpecification , writer ) ; writer . flush ( ) ; writer . close ( ) ; } catch ( Exception e ) { SimpleCostDescriptionTest . log . error ( e . getMessage ( ) , e ) ; fail ( e . getMessage ( ) ) ; } } } }

Fix:
CostElement costElement = new CostElement ( "dataTransferCost" , new at . ac . tuwien . dsg . mela . common . monitoringConcepts . Metric ( "dataTransfer" , "MB//s" , MetricType . RESOURCE ) , Type . USAGE ) ;