Package org.rioproject.impl.costmodel

Examples of org.rioproject.impl.costmodel.GenericCostModel


    long twoDays = 1000 * 60 * 60 * 24 * 2;
    long tenDays = 1000 * 60 * 60 * 24 * 10;

    @Test
    public void testGenericCostModel() {
        GenericCostModel gcm = new GenericCostModel(0.01);
        gcm.addTimeBoundary(new ResourceCostModel.TimeBoundary(5, 10, ResourceCostModel.TimeBoundary.SECONDS));
        gcm.addTimeBoundary(new ResourceCostModel.TimeBoundary(5, 100, ResourceCostModel.TimeBoundary.MINUTES));
        System.out.println("Testing " + gcm.getClass().getName() + "\n");
        System.out.println(gcm.getDescription());
        Assert.assertTrue("Cost per unit for 2 seconds should be 0.01", gcm.getCostPerUnit(twoSeconds)==0.01);
        Assert.assertTrue("Cost per unit for 6 minutes should be 1.0", gcm.getCostPerUnit(sixMinutes) == 1.0);
        Assert.assertTrue("Cost per unit for 2 hours should be 1.0", gcm.getCostPerUnit(twoHours) == 1.0);
    }
View Full Code Here


    @Test
    public void testGenericCostModel2() {
        ResourceCostModel.TimeBoundary[] timeBoundaries =
            new ResourceCostModel.TimeBoundary[]{new ResourceCostModel.TimeBoundary(5, 1000, ResourceCostModel.TimeBoundary.HOURS),
                                                 new ResourceCostModel.TimeBoundary(5, 10000, ResourceCostModel.TimeBoundary.DAYS)};
        GenericCostModel gcm = new GenericCostModel(0.01, timeBoundaries);
        System.out.println("Testing " + gcm.getClass().getName() + "\n");
        System.out.println(gcm.getDescription());
        Assert.assertTrue("Cost per unit for 2 seconds should be 0.01", gcm.getCostPerUnit(twoSeconds)==0.01);
        Assert.assertTrue("Cost per unit for 6 minutes should be 1.0", gcm.getCostPerUnit(sixMinutes)==0.01);
        Assert.assertTrue("Cost per unit for 2 hours should be 1.0", gcm.getCostPerUnit(twoHours)==0.01);
        Assert.assertTrue("Cost per unit for 6 hours should be 10", gcm.getCostPerUnit(sixHours)==10);
        Assert.assertTrue("Cost per unit for 2 days should be 10", gcm.getCostPerUnit(twoDays)==10);
        Assert.assertTrue("Cost per unit for 10 days should be 100", gcm.getCostPerUnit(tenDays)==100);
    }
View Full Code Here

TOP

Related Classes of org.rioproject.impl.costmodel.GenericCostModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.