package org.zstack.test.configuration;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.zstack.core.componentloader.ComponentLoader;
import org.zstack.core.db.DatabaseFacade;
import org.zstack.header.configuration.DiskOfferingInventory;
import org.zstack.header.configuration.DiskOfferingVO;
import org.zstack.test.*;
import org.zstack.utils.Utils;
import org.zstack.utils.data.SizeUnit;
import org.zstack.utils.logging.CLogger;
public class TestAddDiskOffering {
CLogger logger = Utils.getLogger(TestAddDiskOffering.class);
Api api;
ComponentLoader loader;
DatabaseFacade dbf;
@Before
public void setUp() throws Exception {
DBUtil.reDeployDB();
BeanConstructor con = new WebBeanConstructor();
/* This loads spring application context */
loader = con
.addXml("ZoneManager.xml")
.addXml("PortalForUnitTest.xml")
.addXml("ConfigurationManager.xml")
.addXml("Simulator.xml")
.addXml("PrimaryStorageManager.xml")
.addXml("AccountManager.xml")
.build();
dbf = loader.getComponent(DatabaseFacade.class);
api = new Api();
api.startServer();
}
@After
public void tearDown() throws Exception {
api.stopServer();
}
@Test
public void test() throws InterruptedException, ApiSenderException {
DiskOfferingInventory inv = new DiskOfferingInventory();
inv.setDiskSize(SizeUnit.GIGABYTE.toByte(10));
inv.setName("Test");
inv.setDescription("Test");
inv = api.addDiskOffering(inv);
DiskOfferingVO vo = dbf.findByUuid(inv.getUuid(), DiskOfferingVO.class);
Assert.assertEquals(SizeUnit.GIGABYTE.toByte(10), vo.getDiskSize());
}
}