use of org.mockito.exceptions.base.MockitoException in project GeoGig by boundlessgeo.
the class PGDescribeTest method testDescribeException.
@Test
public void testDescribeException() throws Exception {
ConsoleReader consoleReader = new ConsoleReader(System.in, System.out, new UnsupportedTerminal());
GeogigCLI mockCli = spy(new GeogigCLI(consoleReader));
setUpGeogig(mockCli);
when(mockCli.getConsole()).thenThrow(new MockitoException("Exception"));
PGDescribe describeCommand = new PGDescribe();
describeCommand.table = "table1";
describeCommand.dataStoreFactory = TestHelper.createTestFactory();
exception.expect(MockitoException.class);
describeCommand.run(mockCli);
}
use of org.mockito.exceptions.base.MockitoException in project GeoGig by boundlessgeo.
the class SLImportTest method testImportException.
@Test
public void testImportException() throws Exception {
ConsoleReader consoleReader = new ConsoleReader(System.in, System.out, new UnsupportedTerminal());
GeogigCLI mockCli = spy(new GeogigCLI(consoleReader));
setUpGeogig(mockCli);
when(mockCli.getConsole()).thenThrow(new MockitoException("Exception"));
SLImport importCommand = new SLImport();
importCommand.all = true;
importCommand.dataStoreFactory = TestHelper.createTestFactory();
exception.expect(MockitoException.class);
importCommand.run(mockCli);
}
use of org.mockito.exceptions.base.MockitoException in project GeoGig by boundlessgeo.
the class OracleListTest method testListException.
@Test
public void testListException() throws Exception {
ConsoleReader consoleReader = new ConsoleReader(System.in, System.out, new UnsupportedTerminal());
GeogigCLI mockCli = spy(new GeogigCLI(consoleReader));
setUpGeogig(mockCli);
when(mockCli.getConsole()).thenThrow(new MockitoException("Exception"));
OracleList listCommand = new OracleList();
listCommand.dataStoreFactory = TestHelper.createTestFactory();
exception.expect(MockitoException.class);
listCommand.run(mockCli);
}
use of org.mockito.exceptions.base.MockitoException in project GeoGig by boundlessgeo.
the class OracleDescribeTest method testDescribeException.
@Test
public void testDescribeException() throws Exception {
ConsoleReader consoleReader = new ConsoleReader(System.in, System.out, new UnsupportedTerminal());
GeogigCLI mockCli = spy(new GeogigCLI(consoleReader));
setUpGeogig(mockCli);
when(mockCli.getConsole()).thenThrow(new MockitoException("Exception"));
OracleDescribe describeCommand = new OracleDescribe();
describeCommand.table = "table1";
describeCommand.dataStoreFactory = TestHelper.createTestFactory();
exception.expect(MockitoException.class);
describeCommand.run(mockCli);
}
use of org.mockito.exceptions.base.MockitoException in project j2objc by google.
the class ClassPathLoader method loadImplementations.
/**
* Equivalent to {@link java.util.ServiceLoader#load} but without requiring
* Java 6 / Android 2.3 (Gingerbread).
*/
static <T> List<T> loadImplementations(Class<T> service) {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
if (loader == null) {
loader = ClassLoader.getSystemClassLoader();
}
Enumeration<URL> resources;
try {
resources = loader.getResources("mockito-extensions/" + service.getName());
} catch (IOException e) {
throw new MockitoException("Failed to load " + service, e);
}
List<T> result = new ArrayList<T>();
for (URL resource : Collections.list(resources)) {
InputStream in = null;
try {
in = resource.openStream();
for (String line : readerToLines(new InputStreamReader(in, "UTF-8"))) {
String name = stripCommentAndWhitespace(line);
if (name.length() != 0) {
result.add(service.cast(loader.loadClass(name).newInstance()));
}
}
} catch (Exception e) {
throw new MockitoConfigurationException("Failed to load " + service + " using " + resource, e);
} finally {
closeQuietly(in);
}
}
return result;
}
Aggregations