Initial use of mockdriver (still failing).
parent
eae6c0686d
commit
cb45b4e71a
|
|
@ -24,7 +24,7 @@ public class MockDriver implements Driver {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Connection connect(String url, Properties info) throws SQLException {
|
public Connection connect(String url, Properties info) throws SQLException {
|
||||||
if (!url.startsWith("jdbc:jaydebeapi://")) {
|
if (!acceptsURL(url)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return Mockito.mock(Connection.class);
|
return Mockito.mock(Connection.class);
|
||||||
|
|
@ -32,7 +32,7 @@ public class MockDriver implements Driver {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean acceptsURL(String url) throws SQLException {
|
public boolean acceptsURL(String url) throws SQLException {
|
||||||
return true;
|
return url.startsWith("jdbc:jaydebeapi://");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
#-*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright 2015 Bastian Bowe
|
||||||
|
#
|
||||||
|
# This file is part of JayDeBeApi.
|
||||||
|
# JayDeBeApi is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Lesser General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# JayDeBeApi is distributed in the hope that it will be useful, but
|
||||||
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# Lesser General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Lesser General Public
|
||||||
|
# License along with JayDeBeApi. If not, see
|
||||||
|
# <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import jaydebeapi
|
||||||
|
|
||||||
|
import unittest2 as unittest
|
||||||
|
|
||||||
|
class MockTest(unittest.TestCase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
self.conn = jaydebeapi.connect('org.jaydebeapi.mockdriver.MockDriver', 'jdbc:jaydebeapi://dummyurl')
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
self.conn.close()
|
||||||
|
|
||||||
|
def test_execute(self):
|
||||||
|
cursor = self.conn.cursor()
|
||||||
|
cursor.execute("dummy stmt")
|
||||||
Loading…
Reference in New Issue