package com.vci.test.bof.event; import junit.framework.Assert; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import com.vci.corba.common.VCIError; import com.vci.corba.omd.data.AttributeValue; import com.vci.corba.omd.data.BusinessObject; import com.vci.server.bof.BOFactoryServiceImpl; public class BOFactoryTest { public static BOFactoryServiceImpl impl = null; @BeforeClass public static void setUpBeforeClass() throws Exception { } @AfterClass public static void tearDownAfterClass() throws Exception { } @Before public void setUp() throws Exception { impl = new BOFactoryServiceImpl(); } @After public void tearDown() throws Exception { } @Test public void testCreatObject() { BusinessObject bo = new BusinessObject(); bo.oid = "100003"; bo.revisionid = "200001"; bo.nameoid = "300001"; bo.btName = "fileobject"; bo.isLastR = true; bo.isFirstR = true; bo.isLastV = true; bo.isFirstV = true; bo.creator = "creator"; bo.createTime = System.currentTimeMillis(); bo.modifier = "modifier"; bo.modifyTime = System.currentTimeMillis(); bo.revisionRule = "revisionRule001"; bo.versionRule = "versionrule001"; bo.revisionSeq = 1; bo.revisionValue = "reval"; bo.versionSeq = 2; bo.versionValue = "verVal"; bo.lctId = "lctId001"; bo.lcStatus = "create"; bo.id = "ABC-001"; bo.name = "六角头螺栓"; bo.description = "test"; bo.owner = "xx"; // bo.checkinBy = "liucq"; // bo.checkoutBy = "liucq2"; bo.fromVersion = "ssssss"; AttributeValue[] attrValArray = new AttributeValue[3]; AttributeValue name = new AttributeValue(); name.attrName = "RevisionLimit"; name.attrVal = "3"; attrValArray[0] = name; AttributeValue filePath = new AttributeValue(); filePath.attrName = "FilePath"; filePath.attrVal = "E:\\DevelopWorkspace\\AXISWebService\\test.txt"; attrValArray[1] = filePath; AttributeValue FileType = new AttributeValue(); FileType.attrName = "FileType"; FileType.attrVal = "txt"; attrValArray[2] = FileType; bo.newAttrValList = attrValArray; // try { // //impl.createBusinessObject(bo, false, false); // } catch (VCIError e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } Assert.assertNotNull(bo.oid); } @Test public void testUpdateBO() { BusinessObject bo = new BusinessObject(); bo.oid = "100003"; AttributeValue[] attrValArray = new AttributeValue[2]; AttributeValue name = new AttributeValue(); name.attrName = "filename"; name.attrVal = "测试文件更改"; attrValArray[0] = name; AttributeValue filePath = new AttributeValue(); filePath.attrName = "FilePath"; filePath.attrVal = "E:\\DevelopWorkspace\\AXISWebService\\test1.txt"; attrValArray[1] = filePath; bo.newAttrValList = attrValArray; bo.btName = "plm_cus_FOM2"; boolean rs = false; // try { // //BusinessObjectHolder boHolder = new BusinessObjectHolder(); // //boHolder.value = bo; // //rs = impl.updateBusinessObject(bo); // } catch (VCIError e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } Assert.assertTrue(rs); } @Test public void testDeleteBO() { BusinessObject bo = new BusinessObject(); bo.oid = "100003"; bo.btName = "FileType"; boolean rs = false; // try { // rs = impl.deleteBusinessObject(bo, 1); // } catch (VCIError e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } Assert.assertTrue(rs); } @Test public void testSelectBO() { String[] queryColumns = {"FILEPATH","FILETYPE"}; // try { // // BusinessObject bo = impl.readBusinessObject("100003", "fileobject"); // System.out.println(bo.newAttrValList[0].attrVal); // } catch (VCIError e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } } @Test public void testCheckinBO() throws VCIError { BusinessObject bo = new BusinessObject(); bo.oid = "100003"; bo.btName = "fileobject"; bo.modifier = "lzm"; // boolean rs = impl.checkInBusinessObject(bo); // Assert.assertTrue(true); } @Test public void testCheckoutBO() throws VCIError { BusinessObject bo = new BusinessObject(); bo.oid = "100003"; bo.btName = "fileobject"; bo.modifier = "lzm"; // boolean rs = impl.checkoutBusinessObject(bo); // Assert.assertTrue(true); } @Test public void testTransitionBO() throws VCIError { BusinessObject bo = new BusinessObject(); bo.oid = "100003"; bo.btName = "fileobject"; bo.lcStatus = "lzm-state"; // BusinessObjectHolder boHolder = new BusinessObjectHolder(); // boHolder.value = bo; // boolean rs = impl.transferBusinessObject(boHolder, null); // Assert.assertTrue(true); } @Test public void testUnchecnoutBO() throws VCIError { BusinessObject bo = new BusinessObject(); bo.oid = "100003"; bo.btName = "fileobject"; // boolean rs = impl.unCheckOutBusinessObject(bo); // Assert.assertTrue(true); } @Test public void testChangeBOOwner() throws VCIError { BusinessObject bo = new BusinessObject(); bo.oid = "100003"; bo.btName = "fileobject"; bo.owner = "lzm"; // boolean rs = impl.changeBusinessObjectOwner(bo, null); // Assert.assertTrue(true); } public static void main(String args[]){ boolean rs = false; // try { // impl = new BOFactoryServiceImpl(); // BusinessObject bo = impl.readBusinessObject("42B69FE2-1606-31E6-8CD4-01AED0B5EBA8", "Part"); // BusinessObjectHolder holder = new BusinessObjectHolder(); // holder.value=bo; // rs = impl.updateBusinessObjectOut(holder); // System.out.println(); // } catch (VCIError e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } Assert.assertTrue(rs); } }