HHH-12246 - Fix failing test
This commit is contained in:
parent
9d335961b8
commit
9704b564f3
|
@ -30,12 +30,9 @@ import org.hibernate.testing.TestForIssue;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.mockito.Mockito;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
import static org.mockito.Mockito.doThrow;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Vlad Mihalcea
|
* @author Vlad Mihalcea
|
||||||
|
@ -44,10 +41,10 @@ public class SchemaScriptFileGenerationFailureTest {
|
||||||
private Writer writer;
|
private Writer writer;
|
||||||
private EntityManagerFactoryBuilder entityManagerFactoryBuilder;
|
private EntityManagerFactoryBuilder entityManagerFactoryBuilder;
|
||||||
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws IOException {
|
public void setUp() {
|
||||||
writer = Mockito.mock( Writer.class );
|
writer = new FailingWriter();
|
||||||
doThrow( new IOException( "Expected" ) ).when( writer ).flush();
|
|
||||||
|
|
||||||
entityManagerFactoryBuilder = Bootstrap.getEntityManagerFactoryBuilder(
|
entityManagerFactoryBuilder = Bootstrap.getEntityManagerFactoryBuilder(
|
||||||
buildPersistenceUnitDescriptor(),
|
buildPersistenceUnitDescriptor(),
|
||||||
|
@ -57,7 +54,7 @@ public class SchemaScriptFileGenerationFailureTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestForIssue(jiraKey = "HHH-12192")
|
@TestForIssue(jiraKey = "HHH-12192")
|
||||||
public void testErrorMessageContainsTheFailingDDLCommand() throws Exception {
|
public void testErrorMessageContainsTheFailingDDLCommand() {
|
||||||
try {
|
try {
|
||||||
entityManagerFactoryBuilder.generateSchema();
|
entityManagerFactoryBuilder.generateSchema();
|
||||||
fail( "Should haave thrown IOException" );
|
fail( "Should haave thrown IOException" );
|
||||||
|
@ -79,7 +76,6 @@ public class SchemaScriptFileGenerationFailureTest {
|
||||||
|
|
||||||
IOException root = (IOException) e.getCause().getCause().getCause();
|
IOException root = (IOException) e.getCause().getCause().getCause();
|
||||||
assertEquals( "Expected", root.getMessage() );
|
assertEquals( "Expected", root.getMessage() );
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,4 +112,21 @@ public class SchemaScriptFileGenerationFailureTest {
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class FailingWriter extends Writer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(char[] cbuf, int off, int len) throws IOException {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void flush() throws IOException {
|
||||||
|
throw new IOException( "Expected" );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() throws IOException {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue