Skip to Content.
Sympa Menu

grouper-dev - RE: [grouper-dev] help with writing changeLog tests ?

Subject: Grouper Developers Forum

List archive

RE: [grouper-dev] help with writing changeLog tests ?


Chronological Thread 
  • From: Chris Hyzer <>
  • To: Tom Zeller <>, Grouper Dev <>
  • Subject: RE: [grouper-dev] help with writing changeLog tests ?
  • Date: Fri, 30 Sep 2011 16:06:05 +0000
  • Accept-language: en-US

I think you can make it think it is actually running to be a more realistic
test... i.e. configure it for tests in the grouper-loader testConfig in a
startUp() [and remove in tearDown()]:

GrouperLoaderConfig.testConfig.put("changeLog.consumer.ldappcng.class",
LdappcngConsumer.class.getName());

GrouperLoaderConfig.testConfig.put("changeLog.consumer.ldappcng.quartzCron",
"0 0 8 * * ?");

Then run it to register the consumer and clear out the change log:

GrouperLoader.runOnceByJobName(grouperSession,
GrouperLoaderType.GROUPER_CHANGE_LOG_TEMP_TO_CHANGE_LOG);
GrouperLoader.runOnceByJobName(grouperSession,
GrouperLoaderType.GROUPER_CHANGE_LOG_CONSUMER_PREFIX + "ldappcng");

Do stuff:

Call those again and it will process whatever you did

GrouperLoader.runOnceByJobName(grouperSession,
GrouperLoaderType.GROUPER_CHANGE_LOG_TEMP_TO_CHANGE_LOG);
GrouperLoader.runOnceByJobName(grouperSession,
GrouperLoaderType.GROUPER_CHANGE_LOG_CONSUMER_PREFIX + "ldappcng");

Ok?

Thanks,
Chris

-----Original Message-----
From:


[mailto:]
On Behalf Of Tom Zeller
Sent: Friday, September 30, 2011 10:31 AM
To: Grouper Dev
Subject: [grouper-dev] help with writing changeLog tests ?

I am starting to write tests for the ldappcng changelog consumer. Is
this the correct way to write changelog tests ?

public void testSomething() {

ldappcngConsumer.runChangeLog();

ChangeLogTempToEntity.convertRecords();

// clear changelog
HibernateSession.byHqlStatic().createQuery("delete from
ChangeLogEntryTemp").executeUpdate();
HibernateSession.byHqlStatic().createQuery("delete from
ChangeLogEntryEntity").executeUpdate();

// do something e.g. group.addMember();

ChangeLogTempToEntity.convertRecords();

ldappcngConsumer.runChangeLog();

// verify test
}

And here is the runChangeLog() method :

public void runChangeLog() {
LOG.info("runChangeLog");
Hib3GrouperLoaderLog hib3GrouploaderLog = new Hib3GrouperLoaderLog();
hib3GrouploaderLog.setHost(GrouperUtil.hostname());
hib3GrouploaderLog.setJobName(CHANGELOG_JOB_NAME);
hib3GrouploaderLog.setStatus(GrouperLoaderStatus.RUNNING.name());
hib3GrouploaderLog.store();

try {
ChangeLogHelper.processRecords(CHANGELOG_JOB_NAME,
hib3GrouploaderLog, this);
hib3GrouploaderLog.setStatus(GrouperLoaderStatus.SUCCESS.name());
} catch (Exception e) {
LOG.error("Error processing records", e);
hib3GrouploaderLog.setStatus(GrouperLoaderStatus.ERROR.name());
}
hib3GrouploaderLog.store();
}



Archive powered by MHonArc 2.6.16.

Top of Page