本文整理汇总了Java中org.easymock.MockControl.createControl方法的典型用法代码示例。如果您正苦于以下问题:Java MockControl.createControl方法的具体用法?Java MockControl.createControl怎么用?Java MockControl.createControl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.easymock.MockControl
的用法示例。
在下文中一共展示了MockControl.createControl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import org.easymock.MockControl; //导入方法依赖的package包/类
protected void setUp() throws Exception {
strategy = new MissingPatchMigrationRunnerStrategy();
patchInfoStoreControl = MockControl.createControl(PatchInfoStore.class);
patchInfoStore = (PatchInfoStore) patchInfoStoreControl.getMock();
allMigrationTasks = new ArrayList<MigrationTask>();
rollbackableTask2 = new TestRollbackableTask2();
rollbackableTask4 = new TestRollbackableTask4();
mockControl = createControl();
currentPatchInfoStore = mockControl.createMock(PatchInfoStore.class);
allMigrationTasks.add(new TestRollbackableTask1());
allMigrationTasks.add(rollbackableTask2);
allMigrationTasks.add(new TestRollbackableTask3());
allMigrationTasks.add(rollbackableTask4);
allMigrationTasks.add(new TestRollbackableTask5());
}
示例2: setUp
import org.easymock.MockControl; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
protected void setUp() throws Exception
{
super.setUp();
conn = getJDBCMockObjectFactory().getMockConnection();
context = new DataSourceMigrationContext();
context.setDataSource(new ConnectionWrapperDataSource(conn));
context.setSystemName("milestone");
context.setDatabaseType(new DatabaseType("hsqldb"));
table = new PatchTable(context);
contextControl = MockControl.createControl(JdbcMigrationContext.class);
mockContext = (JdbcMigrationContext) contextControl.getMock();
}
示例3: setReportedPatchLevel
import org.easymock.MockControl; //导入方法依赖的package包/类
/**
* For the given launchers, set all it's context's patch info stores as mocks
* that report the given patch level. This method is a helper to get this
* test to pass the DisitributedMigrationProcess::validateControlledSystems() test.
* @param launchers Collection of JDBCMigrationLaunchers
* @param levelToReport the patch level the mock should report
* @throws MigrationException
*/
protected void setReportedPatchLevel(Collection launchers, int levelToReport) throws MigrationException
{
for(Iterator launchersIterator = launchers.iterator(); launchersIterator.hasNext(); )
{
JdbcMigrationLauncher launcher = (JdbcMigrationLauncher) launchersIterator.next();
for(Iterator it = launcher.getContexts().keySet().iterator(); it.hasNext(); )
{
MigrationContext ctx = (MigrationContext) it.next();
MockControl patchInfoStoreControl = MockControl.createControl(PatchInfoStore.class);
PatchInfoStore patchInfoStore = (PatchInfoStore) patchInfoStoreControl.getMock();
patchInfoStore.getPatchLevel();
patchInfoStoreControl.setReturnValue(levelToReport);
patchInfoStoreControl.replay();
launcher.getContexts().put(ctx, patchInfoStore);
}
}
}
示例4: testGetResourceFromBundleClasspath
import org.easymock.MockControl; //导入方法依赖的package包/类
/**
* Test method for
* {@link org.springframework.osgi.io.OsgiBundleResource#getResourceFromBundleClasspath(java.lang.String)}.
*/
public void testGetResourceFromBundleClasspath() throws Exception {
MockControl control = MockControl.createControl(Bundle.class);
Bundle mock = (Bundle) control.getMock();
String location = "file://foo";
URL result = new URL(location);
control.expectAndReturn(mock.getResource(location), result);
control.replay();
resource = new OsgiBundleResource(mock, location);
assertSame(result, resource.getResourceFromBundleClasspath(location));
control.verify();
}
示例5: testGetRemoteJar
import org.easymock.MockControl; //导入方法依赖的package包/类
public void testGetRemoteJar()
throws TransferFailedException, ResourceDoesNotExistException, UnsupportedProtocolException, IOException,
AuthorizationException
{
Artifact artifact = createTestArtifact( "target/test-data/get-remote-jar", "jar" );
ArtifactRepository repo = createStringRepo();
StringWagon wagon = (StringWagon) wagonManager.getWagon( "string" );
wagon.addExpectedContent( repo.getLayout().pathOf( artifact ), "expected" );
MockControl control = MockControl.createControl( UpdateCheckManager.class );
control.replay();
wagonManager.getArtifact( artifact, repo, null, false );
assertTrue( artifact.getFile().exists() );
assertEquals( "expected", FileUtils.fileRead( artifact.getFile(), "UTF-8" ) );
control.verify();
}
示例6: testValidateControlledSystemsWhenNodePatchLevelsAreInSync
import org.easymock.MockControl; //导入方法依赖的package包/类
public void testValidateControlledSystemsWhenNodePatchLevelsAreInSync() throws Exception
{
// system has one node
String systemName = "system1";
JdbcMigrationLauncher launcher = new JdbcMigrationLauncher();
MockControl contextControl = MockControl.createControl(JdbcMigrationContext.class);
JdbcMigrationContext context = (JdbcMigrationContext) contextControl.getMock();
MockControl patchInfoStoreControl = MockControl.createControl(PatchInfoStore.class);
PatchInfoStore patchInfoStore = (PatchInfoStore) patchInfoStoreControl.getMock();
expect(migrationRunnerStrategy.isSynchronized(currentPatchInfoStore, patchInfoStore)).andReturn(true);
migrationRunnerStrategyControl.replay();
migrationProcess.setMigrationRunnerStrategy(migrationRunnerStrategy);
// create the launcher's contexts collection
LinkedHashMap contexts = new LinkedHashMap();
contexts.put(context, patchInfoStore);
launcher.setContexts(contexts);
HashMap controlledSystems = new HashMap();
controlledSystems.put(systemName, launcher);
migrationProcess.setControlledSystems(controlledSystems);
try
{
migrationProcess.validateControlledSystems(currentPatchInfoStore);
}
catch(Exception e)
{
fail("Unexpected exception when validating controlled systems.");
}
}
示例7: testSybasePatchesCommitsOnEveryStatement
import org.easymock.MockControl; //导入方法依赖的package包/类
/**
* Test that sybase database patches are committed when illegal multi
* statement transaction commands are used.
*
* @throws IOException
* if an unexpected error occurs
* @throws MigrationException
* if an unexpected error occurs
* @throws SQLException
* if an unexpected error occurs
*/
public void testSybasePatchesCommitsOnEveryStatement() throws IOException,
MigrationException, SQLException
{
InputStream is = getClass().getResourceAsStream("test/sybase_tsql.sql");
assertNotNull(is);
task = new SqlScriptMigrationTask("sybase_tsql.sql", 1, is);
MockDatabaseType dbType = new MockDatabaseType("sybase");
dbType.setMultipleStatementsSupported(false);
context.setDatabaseType(dbType);
int numStatements = task.getSqlStatements(context).size();
// setup mocks to verify commits are called
MockControl dataSourceControl = MockControl
.createControl(DataSource.class);
DataSource dataSource = (DataSource) dataSourceControl.getMock();
context.setDataSource(dataSource);
MockControl connectionControl = MockControl
.createControl(Connection.class);
Connection connection = (Connection) connectionControl.getMock();
dataSourceControl.expectAndReturn(dataSource.getConnection(),
connection);
MockControl statementControl = MockControl
.createControl(Statement.class);
Statement statement = (Statement) statementControl.getMock();
statement.execute("");
statementControl.setMatcher(MockControl.ALWAYS_MATCHER);
statementControl.setReturnValue(true, MockControl.ONE_OR_MORE);
statementControl.expectAndReturn(statement.isClosed(), false, MockControl.ONE_OR_MORE);
statement.close();
statementControl.setVoidCallable(MockControl.ONE_OR_MORE);
connectionControl.expectAndReturn(connection.isClosed(), false,
MockControl.ONE_OR_MORE);
connectionControl.expectAndReturn(connection.createStatement(),
statement, numStatements);
connectionControl.expectAndReturn(connection.getAutoCommit(), false,
MockControl.ONE_OR_MORE);
connection.commit();
/*
* Magic Number 4 derived from the assumption that the fixture sql
* contains only one statement that is not allowed in a multi statement
* transaction: commit at beginning of migrate method commit prior to
* running the command not allowed in multi statement transaction to
* clear the transaction state. commit after running the multi statement
* transaction to clear transaction state for upcoming statements.
* commit at end of migrate method once all statements executed.
*
* Therefore, if you add more illegal statements to the fixture, add 2
* more commit call's for each illegal statement.
*/
connectionControl.setVoidCallable(4);
dataSourceControl.replay();
connectionControl.replay();
statementControl.replay();
// run tests
task.migrate(context);
dataSourceControl.verify();
connectionControl.verify();
}
示例8: testUnregisterService
import org.easymock.MockControl; //导入方法依赖的package包/类
public void testUnregisterService() throws Exception {
MockControl ctrl = MockControl.createControl(ServiceRegistration.class);
ServiceRegistration reg = (ServiceRegistration) ctrl.getMock();
reg.unregister();
ctrl.replay();
exporter.unregisterService(reg);
ctrl.verify();
}
示例9: setUp
import org.easymock.MockControl; //导入方法依赖的package包/类
protected void setUp() throws Exception {
super.setUp();
processor = new ServiceReferenceInjectionBeanPostProcessor();
context = new MockBundleContext();
processor.setBundleContext(context);
processor.setBeanClassLoader(getClass().getClassLoader());
MockControl factoryControl = MockControl.createControl(BeanFactory.class);
BeanFactory factory = (BeanFactory) factoryControl.getMock();
processor.setBeanFactory(factory);
}
示例10: setUp
import org.easymock.MockControl; //导入方法依赖的package包/类
protected void setUp() throws Exception {
exporter = new OsgiServiceFactoryBean();
beanFactoryControl = MockControl.createControl(ConfigurableBeanFactory.class);
beanFactory = (ConfigurableBeanFactory) this.beanFactoryControl.getMock();
bundleContext = new MockBundleContext();
ctxCtrl = MockControl.createControl(BundleContext.class);
ctx = (BundleContext) ctxCtrl.getMock();
exporter.setBeanFactory(beanFactory);
exporter.setBundleContext(bundleContext);
}
示例11: setUp
import org.easymock.MockControl; //导入方法依赖的package包/类
protected void setUp() throws Exception {
adminControl = MockControl.createControl(ConfigurationAdmin.class);
admin = (ConfigurationAdmin) adminControl.getMock();
MockControl configMock = MockControl.createControl(Configuration.class);
cfg = (Configuration) configMock.getMock();
config = new Hashtable();
adminControl.expectAndReturn(admin.getConfiguration(persistentId), cfg, MockControl.ONE_OR_MORE);
configMock.expectAndReturn(cfg.getProperties(), config, MockControl.ONE_OR_MORE);
adminControl.replay();
configMock.replay();
bundleContext = new MockBundleContext() {
// add Configuration admin support
public Object getService(ServiceReference reference) {
return admin;
}
};
appContext = new GenericApplicationContext();
appContext.getBeanFactory().addBeanPostProcessor(new BundleContextAwareProcessor(bundleContext));
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(appContext);
// reader.setEventListener(this.listener);
reader.loadBeanDefinitions(new ClassPathResource("configProperties.xml", getClass()));
appContext.refresh();
}
示例12: testValidateControlledSystemsWhenNodePatchLevelsAreOutOfSync
import org.easymock.MockControl; //导入方法依赖的package包/类
public void testValidateControlledSystemsWhenNodePatchLevelsAreOutOfSync() throws Exception
{
// system has one node
String systemName = "system1";
JdbcMigrationLauncher launcher = new JdbcMigrationLauncher();
// first node is at the 'current' patch level
MockControl node1ContextControl = MockControl.createControl(JdbcMigrationContext.class);
JdbcMigrationContext node1Context = (JdbcMigrationContext) node1ContextControl.getMock();
MockControl node1PatchInfoStoreControl = MockControl.createControl(PatchInfoStore.class);
PatchInfoStore node1PatchInfoStore = (PatchInfoStore) node1PatchInfoStoreControl.getMock();
// setup mock patch info store to return the patch level we want
node1Context.getDatabaseName();
node1ContextControl.setReturnValue("node1", MockControl.ONE_OR_MORE);
node1ContextControl.replay();
// second node simulates a newly added database instance, it has not been patched
MockControl node2ContextControl = MockControl.createControl(JdbcMigrationContext.class);
JdbcMigrationContext node2Context = (JdbcMigrationContext) node2ContextControl.getMock();
MockControl node2PatchInfoStoreControl = MockControl.createControl(PatchInfoStore.class);
PatchInfoStore node2PatchInfoStore = (PatchInfoStore) node2PatchInfoStoreControl.getMock();
// setup mock patch info store to return the patch level we want
node2Context.getDatabaseName();
node2ContextControl.setReturnValue("node2", MockControl.ONE_OR_MORE);
node2ContextControl.replay();
// create the launcher's contexts collection
LinkedHashMap contexts = new LinkedHashMap();
contexts.put(node1Context, node1PatchInfoStore);
contexts.put(node2Context, node2PatchInfoStore);
launcher.setContexts(contexts);
HashMap controlledSystems = new HashMap();
controlledSystems.put(systemName, launcher);
migrationProcess.setControlledSystems(controlledSystems);
expect(migrationRunnerStrategy.isSynchronized(currentPatchInfoStore, node1PatchInfoStore)).andReturn(true);
expect(migrationRunnerStrategy.isSynchronized(currentPatchInfoStore, node2PatchInfoStore)).andReturn(false);
migrationRunnerStrategyControl.replay();
migrationProcess.setMigrationRunnerStrategy(migrationRunnerStrategy);
try
{
migrationProcess.validateControlledSystems(currentPatchInfoStore);
fail("Unexpected exception when validating controlled systems.");
}
catch(MigrationException me)
{
}
catch(Exception e)
{
fail("Unexpected exception when validating controlled systems.");
}
}
示例13: setUp
import org.easymock.MockControl; //导入方法依赖的package包/类
protected void setUp()
{
mocklv = MockControl.createControl(Leave.class);
lv = (Leave) mocklv.getMock();
}
示例14: setUp
import org.easymock.MockControl; //导入方法依赖的package包/类
protected void setUp(){
mockCore_control = MockControl.createControl(Core.class);
mockCore = (Core) mockCore_control.getMock();
}
示例15: setUp
import org.easymock.MockControl; //导入方法依赖的package包/类
protected void setUp()
{
mockst = MockControl.createControl(Student.class);
st = (Student) mockst.getMock();
}