org.alfresco.util
Class BaseSpringTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.springframework.test.ConditionalTestCase
              extended by org.springframework.test.AbstractSpringContextTests
                  extended by org.springframework.test.AbstractSingleSpringContextTests
                      extended by org.springframework.test.AbstractDependencyInjectionSpringContextTests
                          extended by org.springframework.test.AbstractTransactionalSpringContextTests
                              extended by org.springframework.test.AbstractTransactionalDataSourceSpringContextTests
                                  extended by org.alfresco.util.BaseSpringTest
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
AbstractMultitenantWorkflowTest, AbstractPublishingIntegrationTest, AbstractWorkflowServiceIntegrationTest, ActionParameterConstraintTest, ActivityServiceImplTest, AddFeaturesActionExecuterTest, AVMRemoteSnapshotTrackerTest, BaseAlfrescoSpringTest, BaseNodeServiceTest, BaseRuleTest, BaseVersionStoreTest, CheckOutCheckInServiceImplTest, CompareMimeTypeEvaluatorTest, ComparePropertyValueEvaluatorTest, ConfigurableServiceImplTest, ContentMetadataExtracterTest, DescriptorServiceTest, ExecuteAllRulesActionExecuterTest, ExporterComponentTest, FlickrTest, HasAspectEvaluatorTest, HasChildEvaluatorTest, HasTagEvaluatorTest, ImporterComponentTest, IsSubTypeEvaluatorTest, JBPMJunit4LoadTests, JBPMSpringTest, LockBehaviourImplTest, LockServiceImplTest, NodeEligibleForRethumbnailingEvaluatorTest, NodeRefPropertyMethodInterceptorTest, OutputSpacesStoreSystemTest, PublishingIntegratedTest, PublishWebContentProcessTest, RemoveFeaturesActionExecuterTest, RepositoryExporterComponentTest, ReviewAndApproveTest, RuleLinkTest, RuleTriggerTest, RuleTypeImplTest, ScriptBehaviourTest, SetPropertyValueActionExecuterTest, SlideShareTest, StartWorkflowActionExecuterTest, SubsystemsTest, YouTubeTest

public abstract class BaseSpringTest
extends org.springframework.test.AbstractTransactionalDataSourceSpringContextTests

Base test class providing Hibernate sessions.

By default this is auto-wired by type. If a this is going to result in a conlict the use auto-wire by name. This can be done by setting populateProtectedVariables to true in the constructor and then adding protected members with the same name as the bean you require.


Field Summary
protected  org.hibernate.SessionFactory sessionFactory
          protected so that it gets populated if autowiring is done by variable name
 
Fields inherited from class org.springframework.test.AbstractTransactionalDataSourceSpringContextTests
jdbcTemplate
 
Fields inherited from class org.springframework.test.AbstractTransactionalSpringContextTests
transactionDefinition, transactionManager, transactionStatus
 
Fields inherited from class org.springframework.test.AbstractDependencyInjectionSpringContextTests
AUTOWIRE_BY_NAME, AUTOWIRE_BY_TYPE, AUTOWIRE_NO
 
Fields inherited from class org.springframework.test.AbstractSingleSpringContextTests
applicationContext
 
Fields inherited from class org.springframework.test.ConditionalTestCase
logger
 
Constructor Summary
BaseSpringTest()
          Constructor
 
Method Summary
protected  void flushAndClear()
          Forces the session to flush to the database (without commiting) and clear the cache.
protected  java.lang.String[] getConfigLocations()
          Get the config locations
protected  org.hibernate.Session getSession()
           
protected  org.springframework.context.ConfigurableApplicationContext loadContext(java.lang.Object key)
          Ignores the key and loads the application context.
 void setSessionFactory(org.hibernate.SessionFactory sessionFactory)
          Setter present for in case autowiring is done by type
 
Methods inherited from class org.springframework.test.AbstractTransactionalDataSourceSpringContextTests
countRowsInTable, deleteFromTables, executeSqlScript, getJdbcTemplate, setComplete, setDataSource, setSqlScriptEncoding
 
Methods inherited from class org.springframework.test.AbstractTransactionalSpringContextTests
endTransaction, isDefaultRollback, isRollback, onSetUp, onSetUpBeforeTransaction, onSetUpInTransaction, onTearDown, onTearDownAfterTransaction, onTearDownInTransaction, preventTransaction, setDefaultRollback, setTransactionDefinition, setTransactionManager, startNewTransaction
 
Methods inherited from class org.springframework.test.AbstractDependencyInjectionSpringContextTests
getAutowireMode, injectDependencies, isDependencyCheck, isPopulateProtectedVariables, prepareTestInstance, setAutowireMode, setDependencyCheck, setPopulateProtectedVariables
 
Methods inherited from class org.springframework.test.AbstractSingleSpringContextTests
contextKey, createApplicationContext, createBeanDefinitionReader, customizeBeanFactory, getApplicationContext, getConfigPath, getConfigPaths, getLoadCount, loadContextLocations, prepareApplicationContext, setDirty, setUp, tearDown
 
Methods inherited from class org.springframework.test.AbstractSpringContextTests
addContext, contextKeyString, getContext, hasCachedContext, isContextKeyEmpty, setDirty
 
Methods inherited from class org.springframework.test.ConditionalTestCase
getDisabledTestCount, isDisabledInThisEnvironment, recordDisabled, runBare
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runTest, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sessionFactory

protected org.hibernate.SessionFactory sessionFactory
protected so that it gets populated if autowiring is done by variable name

Constructor Detail

BaseSpringTest

public BaseSpringTest()
Constructor

Method Detail

setSessionFactory

public void setSessionFactory(org.hibernate.SessionFactory sessionFactory)
Setter present for in case autowiring is done by type

Parameters:
sessionFactory -

getSession

protected org.hibernate.Session getSession()
Returns:
Returns the existing session attached to the thread. A new session will not be created.

flushAndClear

protected void flushAndClear()
Forces the session to flush to the database (without commiting) and clear the cache. This ensures that all reads against the session are fresh instances, which gives the assurance that the DB read/write operations occur correctly.


getConfigLocations

protected java.lang.String[] getConfigLocations()
Get the config locations

Overrides:
getConfigLocations in class org.springframework.test.AbstractSingleSpringContextTests
Returns:
an array containing the config locations

loadContext

protected org.springframework.context.ConfigurableApplicationContext loadContext(java.lang.Object key)
                                                                          throws java.lang.Exception
Ignores the key and loads the application context.

Overrides:
loadContext in class org.springframework.test.AbstractSingleSpringContextTests
Throws:
java.lang.Exception


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.