Running SQL server for java

I have a Java application that uses an MSSQL server through the JDBC driver. Is there some kind of stub that I can use for testing? For example, I want to check how my application handles cases of connection errors, an off-disk SQL server, and other exceptions. It is quite complicated and difficult to simulate it using a real SQL server.

thank

+5
source share
6 answers

You can write unit tests using DAOor repositories that return mock objects Connectionusing a mock library such as https://mocquer.dev.java.net/ .

, .

+1

( , , ) ( , / ), , , .

- .

+1

, - . /LAN.

, , , :

MySQL, MS-SQL. , . , , MS-SQL db.

+1

, , . HyperSQLDB - , Java. HSQLDB , . , , ..

, ? ?

0

, MS-SQL, - (, ), . - .

, .

, , , , Mockito (docs) PowerMock. , , . - ( ) ? . /mock JDBC ResultSet Java 5 6?

0

sp_who2 db, spid, db. : kill <<spid>> , . spid 50, , . . ALTER DATABASE dbname SET SINGLE_USER WITH ROLLBACK_IMMEDIATE, db.

Select @@MAX_Connections as Max_Connections , ( , ).

. - .

to create an error on disk just redraw the db file size and don't let it grow ... then paste the data into the database (you will get an exception).

altert database xxx (file= maxsize= filegrowth=)

0
source

All Articles