1 /** 2 * Copyright 2005-2011 The Kuali Foundation 3 * 4 * Licensed under the Educational Community License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.opensource.org/licenses/ecl2.php 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package org.kuali.rice.kew.xml.export; 17 18 import org.kuali.rice.core.api.CoreApiServiceLocator; 19 import org.kuali.rice.kew.export.KewExportDataSet; 20 import org.kuali.rice.kim.api.group.Group; 21 import org.kuali.rice.kim.api.group.GroupService; 22 import org.kuali.rice.kim.api.identity.IdentityService; 23 import org.kuali.rice.kim.api.services.KimApiServiceLocator; 24 import org.kuali.rice.test.BaselineTestCase; 25 26 import java.util.List; 27 28 import static org.junit.Assert.assertTrue; 29 30 /** 31 * This is a description of what this class does - jjhanso don't forget to fill this in. 32 * 33 * @author Kuali Rice Team (rice.collab@kuali.org) 34 * 35 */ 36 @BaselineTestCase.BaselineMode(BaselineTestCase.Mode.NONE) 37 public class GroupXmlExporterTest extends XmlExporterTestCase { 38 39 /** 40 * This overridden method ... 41 * 42 * @see org.kuali.rice.kew.xml.export.XmlExporterTestCase#assertExport() 43 */ 44 @Override 45 protected void assertExport() throws Exception { 46 IdentityService identityService = KimApiServiceLocator.getIdentityService(); 47 GroupService groupService = KimApiServiceLocator.getGroupService(); 48 List<? extends Group> oldGroups = groupService.getGroupsByPrincipalId( 49 identityService.getPrincipalByPrincipalName("ewestfal").getPrincipalId()); 50 51 KewExportDataSet dataSet = new KewExportDataSet(); 52 dataSet.getGroups().addAll(oldGroups); 53 byte[] xmlBytes = CoreApiServiceLocator.getXmlExporterService().export(dataSet.createExportDataSet()); 54 assertTrue("XML should be non empty.", xmlBytes != null && xmlBytes.length > 0); 55 56 StringBuffer output = new StringBuffer(); 57 for (int i=0; i < xmlBytes.length; i++){ 58 output.append((char)xmlBytes[i]); 59 } 60 System.out.print(output.toString()); 61 // now clear the tables 62 //ClearDatabaseLifecycle clearLifeCycle = new ClearDatabaseLifecycle(); 63 //clearLifeCycle.getTablesToClear().add("EN_RULE_BASE_VAL_T"); 64 //clearLifeCycle.getTablesToClear().add("EN_RULE_ATTRIB_T"); 65 //clearLifeCycle.getTablesToClear().add("EN_RULE_TMPL_T"); 66 //clearLifeCycle.getTablesToClear().add("EN_DOC_TYP_T"); 67 //clearLifeCycle.start(); 68 //new ClearCacheLifecycle().stop(); 69 //KimImplServiceLocator.getGroupService(). 70 71 // import the exported xml 72 //loadXmlStream(new BufferedInputStream(new ByteArrayInputStream(xmlBytes))); 73 /* 74 List newRules = KEWServiceLocator.getRuleService().fetchAllRules(true); 75 assertEquals("Should have same number of old and new Rules.", oldRules.size(), newRules.size()); 76 for (Iterator iterator = oldRules.iterator(); iterator.hasNext();) { 77 RuleBaseValues oldRule = (RuleBaseValues) iterator.next(); 78 boolean foundRule = false; 79 for (Iterator iterator2 = newRules.iterator(); iterator2.hasNext();) { 80 RuleBaseValues newRule = (RuleBaseValues) iterator2.next(); 81 if (oldRule.getDescription().equals(newRule.getDescription())) { 82 assertRuleExport(oldRule, newRule); 83 foundRule = true; 84 } 85 } 86 assertTrue("Could not locate the new rule for description " + oldRule.getDescription(), foundRule); 87 } 88 */ 89 } 90 91 }