Search in sources :

Example 21 with MockitoException

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);
}
Also used : GeogigCLI(org.locationtech.geogig.cli.GeogigCLI) ConsoleReader(jline.console.ConsoleReader) UnsupportedTerminal(jline.UnsupportedTerminal) MockitoException(org.mockito.exceptions.base.MockitoException) Test(org.junit.Test)

Example 22 with MockitoException

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);
}
Also used : GeogigCLI(org.locationtech.geogig.cli.GeogigCLI) ConsoleReader(jline.console.ConsoleReader) UnsupportedTerminal(jline.UnsupportedTerminal) MockitoException(org.mockito.exceptions.base.MockitoException) Test(org.junit.Test)

Example 23 with MockitoException

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);
}
Also used : GeogigCLI(org.locationtech.geogig.cli.GeogigCLI) ConsoleReader(jline.console.ConsoleReader) UnsupportedTerminal(jline.UnsupportedTerminal) MockitoException(org.mockito.exceptions.base.MockitoException) Test(org.junit.Test)

Example 24 with MockitoException

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);
}
Also used : GeogigCLI(org.locationtech.geogig.cli.GeogigCLI) ConsoleReader(jline.console.ConsoleReader) UnsupportedTerminal(jline.UnsupportedTerminal) MockitoException(org.mockito.exceptions.base.MockitoException) Test(org.junit.Test)

Example 25 with MockitoException

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;
}
Also used : ArrayList(java.util.ArrayList) URL(java.net.URL) MockitoException(org.mockito.exceptions.base.MockitoException) MockitoConfigurationException(org.mockito.exceptions.misusing.MockitoConfigurationException) MockitoException(org.mockito.exceptions.base.MockitoException) MockitoConfigurationException(org.mockito.exceptions.misusing.MockitoConfigurationException)

Aggregations

MockitoException (org.mockito.exceptions.base.MockitoException)51 Test (org.junit.Test)29 UnsupportedTerminal (jline.UnsupportedTerminal)12 ConsoleReader (jline.console.ConsoleReader)12 GeogigCLI (org.locationtech.geogig.cli.GeogigCLI)12 Field (java.lang.reflect.Field)4 InvocationBuilder (org.mockito.internal.invocation.InvocationBuilder)3 ThrowsException (org.mockito.internal.stubbing.answers.ThrowsException)3 ParameterizedConstructorInstantiator (org.mockito.internal.util.reflection.FieldInitializer.ParameterizedConstructorInstantiator)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 URL (java.net.URL)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 ArgumentCaptor (org.mockito.ArgumentCaptor)2 InOrder (org.mockito.InOrder)2 Spy (org.mockito.Spy)2 Instantiator (org.mockito.internal.creation.instance.Instantiator)2 MockHandlerImpl (org.mockito.internal.handler.MockHandlerImpl)2 InvocationMatcher (org.mockito.internal.invocation.InvocationMatcher)2 FieldInitializationReport (org.mockito.internal.util.reflection.FieldInitializationReport)2