use of org.jmock.Mockery in project teamcity-powershell by JetBrains.
the class PowerShellInfoTest method testSaveLoad.
@Test(dataProvider = "editionProvider")
public void testSaveLoad(@NotNull final PowerShellEdition edition) throws IOException {
PowerShellInfo info = new PowerShellInfo(PowerShellBitness.x64, createTempDir(), "1.0", edition, "powershell.exe");
final Mockery m = new Mockery();
final BuildAgentConfiguration conf = m.mock(BuildAgentConfiguration.class);
final Map<String, String> confParams = new HashMap<String, String>();
m.checking(new Expectations() {
{
allowing(conf).getConfigurationParameters();
will(returnValue(Collections.unmodifiableMap(confParams)));
allowing(conf).addConfigurationParameter(with(any(String.class)), with(any(String.class)));
will(new Action() {
public Object invoke(final Invocation invocation) {
final String key = (String) invocation.getParameter(0);
final String value = (String) invocation.getParameter(1);
Assert.assertNotNull(key);
Assert.assertNotNull(value);
confParams.put(key, value);
return null;
}
public void describeTo(final Description description) {
description.appendText("add Parameters");
}
});
}
});
final String propertyName = "powershell_" + info.getEdition().getValue() + "_" + info.getVersion() + "_" + info.getBitness().getValue();
assertNull(conf.getConfigurationParameters().get(propertyName));
assertNull(conf.getConfigurationParameters().get(propertyName + "_Path"));
info.saveInfo(conf);
assertEquals(info.getVersion(), conf.getConfigurationParameters().get(propertyName));
assertEquals(info.getHome().getAbsolutePath(), conf.getConfigurationParameters().get(propertyName + "_Path"));
}
use of org.jmock.Mockery in project activemq-artemis by apache.
the class ConfigTest method testJdbcLockConfigDefault.
public void testJdbcLockConfigDefault() throws Exception {
JDBCPersistenceAdapter adapter = new JDBCPersistenceAdapter();
Mockery context = new Mockery();
final DataSource dataSource = context.mock(DataSource.class);
final Connection connection = context.mock(Connection.class);
final DatabaseMetaData metadata = context.mock(DatabaseMetaData.class);
final ResultSet result = context.mock(ResultSet.class);
adapter.setDataSource(dataSource);
adapter.setCreateTablesOnStartup(false);
context.checking(new Expectations() {
{
allowing(dataSource).getConnection();
will(returnValue(connection));
allowing(connection).getMetaData();
will(returnValue(metadata));
allowing(connection);
allowing(metadata).getDriverName();
will(returnValue("Some_Unknown_driver"));
allowing(result).next();
will(returnValue(true));
}
});
adapter.start();
assertEquals("has the default locker", adapter.getLocker().getClass(), DefaultDatabaseLocker.class);
adapter.stop();
}
use of org.jmock.Mockery in project i2p.i2p-bote by i2p.
the class TestUtil method createConfiguration.
/**
* Creates a mock {@link Configuration} whose getKeyDerivationParametersFile() and
* getPasswordFile() methods must be called at least once each.<br/>
* Creates a file named derivparams in <code>testDir</code>.<br/>
* The <code>getPasswordCacheDuration</code> method returns 1 (one minute).
* @param testDir
*/
public static Configuration createConfiguration(File testDir) {
final Synchroniser synchroniser = new Synchroniser();
Mockery mockery = new Mockery() {
{
setImposteriser(ClassImposteriser.INSTANCE);
// otherwise we get errors on threads
setThreadingPolicy(synchroniser);
}
};
final Configuration configuration = mockery.mock(Configuration.class);
final File derivParametersFile = new File(testDir, "derivparams");
mockery.checking(new Expectations() {
{
atLeast(1).of(configuration).getKeyDerivationParametersFile();
will(returnValue(derivParametersFile));
}
});
final File passwordFile = new File(testDir, "password");
mockery.checking(new Expectations() {
{
atLeast(1).of(configuration).getPasswordFile();
will(returnValue(passwordFile));
}
});
mockery.checking(new Expectations() {
{
allowing(configuration).getPasswordCacheDuration();
will(returnValue(1));
}
});
return configuration;
}
use of org.jmock.Mockery in project pentaho-platform by pentaho.
the class BlockingQuartzJobTest method setUp.
@Before
public void setUp() throws Exception {
mockery = new Mockery() {
{
setImposteriser(ClassImposteriser.INSTANCE);
}
};
underlyingJob = mockery.mock(Job.class);
context = mockery.mock(JobExecutionContext.class);
blockoutManager = mockery.mock(IBlockoutManager.class);
logger = mockery.mock(Log.class);
}
use of org.jmock.Mockery in project gocd by gocd.
the class JobInstanceLogTest method setUp.
@Before
public void setUp() {
context = new Mockery();
context.setImposteriser(ClassImposteriser.INSTANCE);
jobInstanceLog = new JobInstanceLog(null, new HashMap());
defaultLogFile = new LogFile(new File("log20051209122103.xml"));
rootFolder = new File("root");
rootFolder.mkdirs();
env = new SystemEnvironment();
}
Aggregations