001 /** 002 * Copyright 2005-2011 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.rice.kew.xml.export; 017 018 import org.kuali.rice.core.api.CoreApiServiceLocator; 019 import org.kuali.rice.kew.export.KewExportDataSet; 020 import org.kuali.rice.kim.api.group.Group; 021 import org.kuali.rice.kim.api.group.GroupService; 022 import org.kuali.rice.kim.api.identity.IdentityService; 023 import org.kuali.rice.kim.api.services.KimApiServiceLocator; 024 import org.kuali.rice.test.BaselineTestCase; 025 026 import java.util.List; 027 028 import static org.junit.Assert.assertTrue; 029 030 /** 031 * This is a description of what this class does - jjhanso don't forget to fill this in. 032 * 033 * @author Kuali Rice Team (rice.collab@kuali.org) 034 * 035 */ 036 @BaselineTestCase.BaselineMode(BaselineTestCase.Mode.NONE) 037 public class GroupXmlExporterTest extends XmlExporterTestCase { 038 039 /** 040 * This overridden method ... 041 * 042 * @see org.kuali.rice.kew.xml.export.XmlExporterTestCase#assertExport() 043 */ 044 @Override 045 protected void assertExport() throws Exception { 046 IdentityService identityService = KimApiServiceLocator.getIdentityService(); 047 GroupService groupService = KimApiServiceLocator.getGroupService(); 048 List<? extends Group> oldGroups = groupService.getGroupsByPrincipalId( 049 identityService.getPrincipalByPrincipalName("ewestfal").getPrincipalId()); 050 051 KewExportDataSet dataSet = new KewExportDataSet(); 052 dataSet.getGroups().addAll(oldGroups); 053 byte[] xmlBytes = CoreApiServiceLocator.getXmlExporterService().export(dataSet.createExportDataSet()); 054 assertTrue("XML should be non empty.", xmlBytes != null && xmlBytes.length > 0); 055 056 StringBuffer output = new StringBuffer(); 057 for (int i=0; i < xmlBytes.length; i++){ 058 output.append((char)xmlBytes[i]); 059 } 060 System.out.print(output.toString()); 061 // now clear the tables 062 //ClearDatabaseLifecycle clearLifeCycle = new ClearDatabaseLifecycle(); 063 //clearLifeCycle.getTablesToClear().add("EN_RULE_BASE_VAL_T"); 064 //clearLifeCycle.getTablesToClear().add("EN_RULE_ATTRIB_T"); 065 //clearLifeCycle.getTablesToClear().add("EN_RULE_TMPL_T"); 066 //clearLifeCycle.getTablesToClear().add("EN_DOC_TYP_T"); 067 //clearLifeCycle.start(); 068 //new ClearCacheLifecycle().stop(); 069 //KimImplServiceLocator.getGroupService(). 070 071 // import the exported xml 072 //loadXmlStream(new BufferedInputStream(new ByteArrayInputStream(xmlBytes))); 073 /* 074 List newRules = KEWServiceLocator.getRuleService().fetchAllRules(true); 075 assertEquals("Should have same number of old and new Rules.", oldRules.size(), newRules.size()); 076 for (Iterator iterator = oldRules.iterator(); iterator.hasNext();) { 077 RuleBaseValues oldRule = (RuleBaseValues) iterator.next(); 078 boolean foundRule = false; 079 for (Iterator iterator2 = newRules.iterator(); iterator2.hasNext();) { 080 RuleBaseValues newRule = (RuleBaseValues) iterator2.next(); 081 if (oldRule.getDescription().equals(newRule.getDescription())) { 082 assertRuleExport(oldRule, newRule); 083 foundRule = true; 084 } 085 } 086 assertTrue("Could not locate the new rule for description " + oldRule.getDescription(), foundRule); 087 } 088 */ 089 } 090 091 }