Skip to content

Commit

Permalink
Removed easymock usage
Browse files Browse the repository at this point in the history
  • Loading branch information
nvoxland committed Jan 21, 2016
1 parent 2889d5e commit bf9faf4
Show file tree
Hide file tree
Showing 14 changed files with 473 additions and 531 deletions.
2 changes: 0 additions & 2 deletions findbugs.core.fbp
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<Project filename="&lt;&lt;unnamed project&gt;&gt;" projectName="liquibase.core">
<Jar>C:\othersvn\liquibase\core\build</Jar>
<AuxClasspathEntry>C:\othersvn\liquibase\core\lib\cglib-nodep-2.1_3.jar</AuxClasspathEntry>
<AuxClasspathEntry>C:\othersvn\liquibase\core\lib\easymock-2.2.jar</AuxClasspathEntry>
<AuxClasspathEntry>C:\othersvn\liquibase\core\lib\easymockclassextension-2.2.jar</AuxClasspathEntry>
<AuxClasspathEntry>C:\othersvn\liquibase\core\lib\junit-4.1.jar</AuxClasspathEntry>
<AuxClasspathEntry>C:\othersvn\liquibase\core\lib\opencsv-1.8.jar</AuxClasspathEntry>
<AuxClasspathEntry>C:\othersvn\liquibase\core\lib-compile\ant-1.6.5.jar</AuxClasspathEntry>
Expand Down
6 changes: 0 additions & 6 deletions liquibase-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymockclassextension</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ protected void configureClassLoader() throws CommandLineParsingException {
File jar = extract(earZip, entry);
URL newUrl = new URL("jar:" + jar.toURI().toURL() + "!/");
urls.add(newUrl);
logger.debug("Adding '"+newUrl+"' to classpath");
logger.debug("Adding '" + newUrl + "' to classpath");
jar.deleteOnExit();
} else if (entry.getName().toLowerCase().endsWith("war")) {
File warFile = extract(earZip, entry);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,13 @@ import liquibase.resource.ClassLoaderResourceAccessor
import liquibase.resource.CompositeResourceAccessor
import liquibase.resource.FileSystemResourceAccessor
import liquibase.resource.ResourceAccessor
import org.easymock.Capture
import org.easymock.IAnswer
import org.junit.Assert
import spock.lang.Ignore
import spock.lang.Specification

import java.sql.PreparedStatement
import java.sql.SQLException

import static org.easymock.EasyMock.*
import static org.easymock.classextension.EasyMock.createMock
import static org.easymock.classextension.EasyMock.replay

public class ExecutablePreparedStatementTest extends Specification {

@Ignore
Expand Down Expand Up @@ -66,38 +60,38 @@ public class ExecutablePreparedStatementTest extends Specification {
assertSetBinaryStream(columns, changeSet);
}

protected void assertSetBinaryStream(List<ColumnConfig> columns, ChangeSet changeSet)
throws SQLException, DatabaseException {
InsertExecutablePreparedStatement statement =
new InsertExecutablePreparedStatement(
new MockDatabase(), "catalog", "schema", "table", columns, changeSet, createResourceAccessor());
PreparedStatement stmt = createMock(PreparedStatement.class);

final Capture<Integer> index = new Capture<Integer>();
final Capture<InputStream> inStream = new Capture<InputStream>();
final Capture<Integer> length = new Capture<Integer>();
stmt.setBinaryStream(capture(index), capture(inStream), capture(length));
expectLastCall().andAnswer(new IAnswer<Object>() {
@Override
public Object answer() throws Throwable {
Assert.assertEquals(new Integer(1), index.getValue());
Assert.assertNotNull(inStream.getValue());
Assert.assertTrue(inStreamgetValue() instanceof BufferedInputStream);
Assert.assertEquals(new Integer(50), length.getValue());
return null;
}
});
expect(stmt.execute()).andReturn(true);
replay(stmt);
JdbcConnection connection = createMock(JdbcConnection.class);
expect(connection.prepareStatement("INSERT INTO schema.table(null) VALUES(?)")).andReturn(stmt);
replay(connection);
statement.execute(new PreparedStatementFactory(connection));
}
// protected void assertSetBinaryStream(List<ColumnConfig> columns, ChangeSet changeSet)
// throws SQLException, DatabaseException {
//
// InsertExecutablePreparedStatement statement =
// new InsertExecutablePreparedStatement(
// new MockDatabase(), "catalog", "schema", "table", columns, changeSet, createResourceAccessor());
//
// PreparedStatement stmt = createMock(PreparedStatement.class);
//
// final Capture<Integer> index = new Capture<Integer>();
// final Capture<InputStream> inStream = new Capture<InputStream>();
// final Capture<Integer> length = new Capture<Integer>();
// stmt.setBinaryStream(capture(index), capture(inStream), capture(length));
// expectLastCall().andAnswer(new IAnswer<Object>() {
// @Override
// public Object answer() throws Throwable {
// Assert.assertEquals(new Integer(1), index.getValue());
// Assert.assertNotNull(inStream.getValue());
// Assert.assertTrue(inStreamgetValue() instanceof BufferedInputStream);
// Assert.assertEquals(new Integer(50), length.getValue());
// return null;
// }
// });
// expect(stmt.execute()).andReturn(true);
// replay(stmt);
//
// JdbcConnection connection = createMock(JdbcConnection.class);
// expect(connection.prepareStatement("INSERT INTO schema.table(null) VALUES(?)")).andReturn(stmt);
// replay(connection);
//
// statement.execute(new PreparedStatementFactory(connection));
// }

@Ignore
def testValueClobFileFromClassLoader() throws DatabaseException, SQLException {
Expand Down Expand Up @@ -141,39 +135,39 @@ public class ExecutablePreparedStatementTest extends Specification {
assertSetCharacterStream(columns, changeSet);
}

protected void assertSetCharacterStream(List<ColumnConfig> columns, ChangeSet changeSet)
throws SQLException, DatabaseException {
InsertExecutablePreparedStatement statement =
new InsertExecutablePreparedStatement(
new MockDatabase(),
"catalog", "schema", "table", columns, changeSet, createResourceAccessor());
PreparedStatement stmt = createMock(PreparedStatement.class);

final Capture<Integer> index = new Capture<Integer>();
final Capture<Reader> reader = new Capture<Reader>();
final Capture<Integer> length = new Capture<Integer>();
stmt.setCharacterStream(capture(index), capture(reader), capture(length));
expectLastCall().andAnswer(new IAnswer<Object>() {
@Override
public Object answer() throws Throwable {
Assert.assertEquals(new Integer(1), index.getValue());
Assert.assertNotNull(reader.getValue());
Assert.assertTrue(reader.getValue() instanceof BufferedReader);
Assert.assertEquals(new Integer(39), length.getValue());
return null;
}
});
expect(stmt.execute()).andReturn(true);
replay(stmt);
JdbcConnection connection = createMock(JdbcConnection.class);
expect(connection.prepareStatement("INSERT INTO schema.table(null) VALUES(?)")).andReturn(stmt);
replay(connection);
statement.execute(new PreparedStatementFactory(connection));
}
// protected void assertSetCharacterStream(List<ColumnConfig> columns, ChangeSet changeSet)
// throws SQLException, DatabaseException {
//
// InsertExecutablePreparedStatement statement =
// new InsertExecutablePreparedStatement(
// new MockDatabase(),
// "catalog", "schema", "table", columns, changeSet, createResourceAccessor());
//
// PreparedStatement stmt = createMock(PreparedStatement.class);
//
// final Capture<Integer> index = new Capture<Integer>();
// final Capture<Reader> reader = new Capture<Reader>();
// final Capture<Integer> length = new Capture<Integer>();
// stmt.setCharacterStream(capture(index), capture(reader), capture(length));
// expectLastCall().andAnswer(new IAnswer<Object>() {
// @Override
// public Object answer() throws Throwable {
// Assert.assertEquals(new Integer(1), index.getValue());
// Assert.assertNotNull(reader.getValue());
// Assert.assertTrue(reader.getValue() instanceof BufferedReader);
// Assert.assertEquals(new Integer(39), length.getValue());
// return null;
// }
// });
// expect(stmt.execute()).andReturn(true);
// replay(stmt);
//
// JdbcConnection connection = createMock(JdbcConnection.class);
// expect(connection.prepareStatement("INSERT INTO schema.table(null) VALUES(?)")).andReturn(stmt);
// replay(connection);
//
// statement.execute(new PreparedStatementFactory(connection));
// }

/**
* Create a test context resource accessor.
Expand Down
Loading

0 comments on commit bf9faf4

Please sign in to comment.