Skip to content

Commit 63ef6c3

Browse files
authored
Merge branch 'devel' into 7128-remove-deprecated-api
2 parents d5cde48 + f728590 commit 63ef6c3

20 files changed

Lines changed: 282 additions & 248 deletions

server/test/io.cloudbeaver.test.platform/META-INF/MANIFEST.MF

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ Bundle-Release-Date: 20220606
77
Bundle-Vendor: DBeaver Corp
88
Bundle-RequiredExecutionEnvironment: JavaSE-21
99
Bundle-ActivationPolicy: lazy
10-
Require-Bundle: org.junit,
11-
org.mockito.mockito-core,
10+
Require-Bundle: org.eclipse.core.runtime,
1211
org.apache.felix.scr,
1312
org.jkiss.dbeaver.osgi.test.runner;visibility:=reexport,
1413
org.jkiss.dbeaver.model.sql,

server/test/io.cloudbeaver.test.platform/src/io/cloudbeaver/CloudbeaverMockTest.java

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,53 @@
1+
/*
2+
* DBeaver - Universal Database Manager
3+
* Copyright (C) 2010-2026 DBeaver Corp and others
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
117
package io.cloudbeaver;
218

19+
import io.cloudbeaver.app.CEAppStarter;
320
import io.cloudbeaver.utils.WebTestUtils;
4-
import org.jkiss.junit.osgi.OSGITestRunner;
521
import org.jkiss.junit.osgi.annotation.RunWithApplication;
622
import org.jkiss.junit.osgi.annotation.RunWithProduct;
7-
import org.jkiss.junit.osgi.annotation.RunnerProxy;
823
import org.jkiss.junit.osgi.behaviors.IAsyncApplication;
9-
import org.junit.runner.RunWith;
10-
import org.mockito.junit.MockitoJUnitRunner;
24+
import org.jkiss.junit.osgi.extension.OSGITestExtension;
25+
import org.junit.jupiter.api.BeforeAll;
26+
import org.junit.jupiter.api.BeforeEach;
27+
import org.junit.jupiter.api.extension.ExtendWith;
28+
import org.mockito.MockitoAnnotations;
1129

1230
import java.net.CookieManager;
1331
import java.net.http.HttpClient;
1432

1533
@RunWithProduct("CloudbeaverServerUnitTest.product")
16-
@RunnerProxy(MockitoJUnitRunner.class)
17-
@RunWith(OSGITestRunner.class)
34+
@ExtendWith(OSGITestExtension.class)
1835
@RunWithApplication(
1936
bundleName = "io.cloudbeaver.server.ce",
2037
registryName = "io.cloudbeaver.product.ce.application",
2138
args = {"-web-config", "workspace/conf/cloudbeaver.conf"},
2239
vmArgs = {"logback.configurationFile", "workspace/conf/logback.xml"}
2340
)
2441
public abstract class CloudbeaverMockTest implements IAsyncApplication {
42+
@BeforeAll
43+
public static void startServer() throws Exception {
44+
CEAppStarter.startServerIfNotStarted();
45+
}
46+
47+
@BeforeEach
48+
public void setupMocks() {
49+
MockitoAnnotations.openMocks(this);
50+
}
2551
private static final String GQL_API_URL = "http://localhost:18978/api/gql";
2652
private static final String SERVER_STATUS_URL = "http://localhost:18978/status";
2753
private final HttpClient httpClient = HttpClient.newBuilder()

server/test/io.cloudbeaver.test.platform/src/io/cloudbeaver/app/CEAppStarter.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import org.jkiss.code.NotNull;
2525
import org.jkiss.dbeaver.runtime.DBWorkbench;
2626
import org.jkiss.utils.SecurityUtils;
27-
import org.junit.AfterClass;
27+
import org.junit.jupiter.api.AfterAll;
2828

2929
import java.net.CookieManager;
3030
import java.net.http.HttpClient;
@@ -43,6 +43,9 @@ public class CEAppStarter {
4343

4444
public static void startServerIfNotStarted() throws Exception {
4545
System.out.println("Start CBApplication");
46+
if (testApp != null) {
47+
return;
48+
}
4649
if (DBWorkbench.isPlatformStarted() && DBWorkbench.getPlatform().getApplication() instanceof CBApplication<?>) {
4750
testApp = (CBApplication<?>) DBWorkbench.getPlatform().getApplication();
4851
return;
@@ -66,7 +69,7 @@ public static void startServerIfNotStarted() throws Exception {
6669
}
6770
}
6871

69-
@AfterClass
72+
@AfterAll
7073
public static void shutdownServer() {
7174
testApp.stop();
7275
}

server/test/io.cloudbeaver.test.platform/src/io/cloudbeaver/model/lsp/DBLTextDocumentServiceContextTest.java

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
import org.eclipse.lsp4j.*;
2020
import org.jkiss.dbeaver.ext.h2.model.H2SQLDialect;
2121
import org.jkiss.dbeaver.model.lsp.context.ContextAwareDocument;
22-
import org.junit.Assert;
23-
import org.junit.Test;
22+
import org.junit.jupiter.api.Assertions;
23+
import org.junit.jupiter.api.Test;
2424

2525
import java.util.List;
2626
import java.util.concurrent.CompletableFuture;
@@ -35,12 +35,12 @@ public void shouldInitH2Context() {
3535
);
3636

3737
ContextAwareDocument contextedDocument = DocumentServiceTestUtils.getDocument(service, document.getUri());
38-
Assert.assertNotNull(contextedDocument);
39-
Assert.assertEquals(dataSourceDescriptor.getDataSource(), contextedDocument.getDataSource());
40-
Assert.assertNotNull(contextedDocument.getExecutionContext());
41-
Assert.assertEquals(dataSourceDescriptor.getDataSource(), contextedDocument.getExecutionContext().getDataSource());
42-
Assert.assertTrue(contextedDocument.getSyntaxManager().getDialect() instanceof H2SQLDialect);
43-
Assert.assertNotNull(contextedDocument.getRuleManager());
38+
Assertions.assertNotNull(contextedDocument);
39+
Assertions.assertEquals(dataSourceDescriptor.getDataSource(), contextedDocument.getDataSource());
40+
Assertions.assertNotNull(contextedDocument.getExecutionContext());
41+
Assertions.assertEquals(dataSourceDescriptor.getDataSource(), contextedDocument.getExecutionContext().getDataSource());
42+
Assertions.assertTrue(contextedDocument.getSyntaxManager().getDialect() instanceof H2SQLDialect);
43+
Assertions.assertNotNull(contextedDocument.getRuleManager());
4444
}
4545

4646
@Test
@@ -69,14 +69,14 @@ INSERT INTO users (id, profile) VALUES (1,'{"name": "JohnDoe"}'::jsonb) ON CONFL
6969
profile->>'name' AS name;
7070
""".trim();
7171

72-
Assert.assertEquals(expectedQuery.trim(), edit.getNewText());
72+
Assertions.assertEquals(expectedQuery.trim(), edit.getNewText());
7373
Position start = edit.getRange().getStart();
74-
Assert.assertEquals(0, start.getLine());
75-
Assert.assertEquals(0, start.getCharacter());
74+
Assertions.assertEquals(0, start.getLine());
75+
Assertions.assertEquals(0, start.getCharacter());
7676

7777
Position end = edit.getRange().getEnd();
78-
Assert.assertEquals(1, end.getLine());
79-
Assert.assertEquals(97, end.getCharacter());
78+
Assertions.assertEquals(1, end.getLine());
79+
Assertions.assertEquals(97, end.getCharacter());
8080
}
8181

8282
@Test
@@ -90,8 +90,8 @@ public void shouldReturnEmptyCompletionsForInvalidPosition() throws ExecutionExc
9090

9191
CompletionList completions = service.completion(completionParams).get().getRight();
9292

93-
Assert.assertNotNull(completions);
94-
Assert.assertTrue(completions.getItems().isEmpty());
93+
Assertions.assertNotNull(completions);
94+
Assertions.assertTrue(completions.getItems().isEmpty());
9595
}
9696

9797
@Test
@@ -105,9 +105,9 @@ public void shouldSuggestKeywordCompletion() throws ExecutionException, Interrup
105105

106106
CompletionList completions = service.completion(completionParams).get().getRight();
107107

108-
Assert.assertNotNull(completions);
109-
Assert.assertFalse(completions.getItems().isEmpty());
110-
Assert.assertEquals("SELECT", completions.getItems().getFirst().getLabel());
108+
Assertions.assertNotNull(completions);
109+
Assertions.assertFalse(completions.getItems().isEmpty());
110+
Assertions.assertEquals("SELECT", completions.getItems().getFirst().getLabel());
111111
}
112112

113113
@Test
@@ -124,8 +124,8 @@ public void shouldSuggestMultilineKeywordCompletion() throws ExecutionException,
124124

125125
CompletionList completions = service.completion(completionParams).get().getRight();
126126

127-
Assert.assertNotNull(completions);
128-
Assert.assertEquals(1, completions.getItems().size());
129-
Assert.assertEquals("FROM", completions.getItems().getFirst().getLabel());
127+
Assertions.assertNotNull(completions);
128+
Assertions.assertEquals(1, completions.getItems().size());
129+
Assertions.assertEquals("FROM", completions.getItems().getFirst().getLabel());
130130
}
131131
}

server/test/io.cloudbeaver.test.platform/src/io/cloudbeaver/model/lsp/DBLTextDocumentServiceTest.java

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* DBeaver - Universal Database Manager
3-
* Copyright (C) 2010-2025 DBeaver Corp and others
3+
* Copyright (C) 2010-2026 DBeaver Corp and others
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -23,9 +23,9 @@
2323
import org.jkiss.dbeaver.model.lsp.context.ContextAwareDocument;
2424
import org.jkiss.dbeaver.model.sql.SQLSyntaxManager;
2525
import org.jkiss.dbeaver.model.sql.parser.SQLRuleManager;
26-
import org.junit.Assert;
27-
import org.junit.Before;
28-
import org.junit.Test;
26+
import org.junit.jupiter.api.Assertions;
27+
import org.junit.jupiter.api.BeforeEach;
28+
import org.junit.jupiter.api.Test;
2929

3030
import java.util.List;
3131
import java.util.Objects;
@@ -38,7 +38,7 @@
3838
public class DBLTextDocumentServiceTest extends CloudbeaverMockTest {
3939
private DBLTextDocumentService service;
4040

41-
@Before
41+
@BeforeEach
4242
public void setUp() {
4343
service = new DBLTextDocumentService();
4444
}
@@ -55,9 +55,9 @@ public void shouldOpenDocumentWithArbitraryURI() {
5555
service.didOpen(params);
5656

5757
ContextAwareDocument document = DocumentServiceTestUtils.getDocument(service, uri);
58-
Assert.assertNotNull(document);
59-
Assert.assertEquals(document.getSyntaxManager().getDialect(), BasicSQLDialect.INSTANCE);
60-
Assert.assertNull(document.getExecutionContext());
58+
Assertions.assertNotNull(document);
59+
Assertions.assertEquals(document.getSyntaxManager().getDialect(), BasicSQLDialect.INSTANCE);
60+
Assertions.assertNull(document.getExecutionContext());
6161
}
6262

6363
@Test
@@ -67,14 +67,14 @@ public void shouldOpenDocument() {
6767
service.didOpen(new DidOpenTextDocumentParams(textDocument));
6868

6969
ContextAwareDocument savedDocument = DocumentServiceTestUtils.getDocument(service, textDocument.getUri());
70-
Assert.assertNotNull(savedDocument);
71-
Assert.assertEquals(query, savedDocument.getText());
70+
Assertions.assertNotNull(savedDocument);
71+
Assertions.assertEquals(query, savedDocument.getText());
7272

7373
SQLSyntaxManager syntaxManager = savedDocument.getSyntaxManager();
74-
Assert.assertNotNull(syntaxManager);
75-
Assert.assertEquals(BasicSQLDialect.INSTANCE, syntaxManager.getDialect());
74+
Assertions.assertNotNull(syntaxManager);
75+
Assertions.assertEquals(BasicSQLDialect.INSTANCE, syntaxManager.getDialect());
7676
SQLRuleManager ruleManager = savedDocument.getRuleManager();
77-
Assert.assertNotNull(ruleManager);
77+
Assertions.assertNotNull(ruleManager);
7878
}
7979

8080
@Test
@@ -84,10 +84,10 @@ public void shouldInitDefaultSyntax() {
8484

8585
ContextAwareDocument savedDocument = Objects.requireNonNull(DocumentServiceTestUtils.getDocument(service, textDocument.getUri()));
8686
SQLSyntaxManager syntaxManager = savedDocument.getSyntaxManager();
87-
Assert.assertNotNull(syntaxManager);
88-
Assert.assertEquals(BasicSQLDialect.INSTANCE, syntaxManager.getDialect());
87+
Assertions.assertNotNull(syntaxManager);
88+
Assertions.assertEquals(BasicSQLDialect.INSTANCE, syntaxManager.getDialect());
8989
SQLRuleManager ruleManager = savedDocument.getRuleManager();
90-
Assert.assertNotNull(ruleManager);
90+
Assertions.assertNotNull(ruleManager);
9191
}
9292

9393
@Test
@@ -103,8 +103,8 @@ public void shouldOpenAndChangeDocument() {
103103
service.didChange(new DidChangeTextDocumentParams(textDocumentChange, contentChanges));
104104

105105
ContextAwareDocument updatedDocument = DocumentServiceTestUtils.getDocument(service, textDocument.getUri());
106-
Assert.assertNotNull(updatedDocument);
107-
Assert.assertEquals(updatedSql, updatedDocument.getText());
106+
Assertions.assertNotNull(updatedDocument);
107+
Assertions.assertEquals(updatedSql, updatedDocument.getText());
108108
}
109109

110110
@Test
@@ -120,10 +120,10 @@ public void shouldFailSubmittingMultipleChangesToDocument() {
120120
TextDocumentContentChangeEvent event2 = new TextDocumentContentChangeEvent(updatedSql2);
121121
List<TextDocumentContentChangeEvent> contentChanges = List.of(event1, event2);
122122

123-
Assert.assertThrows(
124-
"Unexpected number of document changes: 2",
123+
Assertions.assertThrows(
125124
IllegalArgumentException.class,
126-
() -> service.didChange(new DidChangeTextDocumentParams(textDocumentChange, contentChanges))
125+
() -> service.didChange(new DidChangeTextDocumentParams(textDocumentChange, contentChanges)),
126+
"Unexpected number of document changes: 2"
127127
);
128128
}
129129

@@ -138,7 +138,7 @@ public void shouldOpenAndCloseDocument() {
138138
service.didClose(closeParams);
139139

140140
ContextAwareDocument updatedDocument = DocumentServiceTestUtils.getDocument(service, textDocument.getUri());
141-
Assert.assertNull(updatedDocument);
141+
Assertions.assertNull(updatedDocument);
142142
}
143143

144144
@Test
@@ -155,15 +155,15 @@ public void shouldFormatSingleLineQuery() throws ExecutionException, Interrupted
155155
FROM
156156
tablename AS alias;
157157
""";
158-
Assert.assertEquals(expectedQuery.trim(), textEdit.getNewText());
158+
Assertions.assertEquals(expectedQuery.trim(), textEdit.getNewText());
159159

160160
Position start = textEdit.getRange().getStart();
161-
Assert.assertEquals(0, start.getCharacter());
162-
Assert.assertEquals(0, start.getLine());
161+
Assertions.assertEquals(0, start.getCharacter());
162+
Assertions.assertEquals(0, start.getLine());
163163

164164
Position end = textEdit.getRange().getEnd();
165-
Assert.assertEquals(0, end.getLine());
166-
Assert.assertEquals(42, end.getCharacter());
165+
Assertions.assertEquals(0, end.getLine());
166+
Assertions.assertEquals(42, end.getCharacter());
167167
}
168168

169169
@Test
@@ -190,15 +190,15 @@ public void shouldFormatMultilineQuery() throws ExecutionException, InterruptedE
190190
schemaname3.tablename3
191191
;
192192
""".trim();
193-
Assert.assertEquals(expectedQuery.trim(), textEdit.getNewText());
193+
Assertions.assertEquals(expectedQuery.trim(), textEdit.getNewText());
194194

195195
Position start = textEdit.getRange().getStart();
196-
Assert.assertEquals(0, start.getCharacter());
197-
Assert.assertEquals(0, start.getLine());
196+
Assertions.assertEquals(0, start.getCharacter());
197+
Assertions.assertEquals(0, start.getLine());
198198

199199
Position end = textEdit.getRange().getEnd();
200-
Assert.assertEquals(3, end.getLine());
201-
Assert.assertEquals(1, end.getCharacter());
200+
Assertions.assertEquals(3, end.getLine());
201+
Assertions.assertEquals(1, end.getCharacter());
202202
}
203203

204204
@Test
@@ -223,10 +223,10 @@ CREATE TABLE logs (id serial PRIMARY KEY,
223223
END $$;
224224
""".trim();
225225

226-
Assert.assertEquals(expectedQuery.trim(), textEdit.getNewText());
226+
Assertions.assertEquals(expectedQuery.trim(), textEdit.getNewText());
227227
Position end = textEdit.getRange().getEnd();
228-
Assert.assertEquals(1, end.getLine());
229-
Assert.assertEquals(63, end.getCharacter());
228+
Assertions.assertEquals(1, end.getLine());
229+
Assertions.assertEquals(63, end.getCharacter());
230230
}
231231

232232
@Test
@@ -238,7 +238,7 @@ public void shouldReturnKeywordTokenData() throws ExecutionException, Interrupte
238238
SemanticTokensParams params = new SemanticTokensParams(new TextDocumentIdentifier(document.getUri()));
239239
Integer[] tokensData = service.semanticTokensFull(params).get().getData().toArray(new Integer[0]);
240240

241-
Assert.assertArrayEquals(
241+
Assertions.assertArrayEquals(
242242
new Integer[] {0, 0, 6, 0, 0},
243243
tokensData
244244
);
@@ -259,7 +259,7 @@ public void shouldReturnMultipleTokensData() throws ExecutionException, Interrup
259259
0, 23, 5, 0, 0, // WHERE
260260
0, 39, 5, 1, 0 // 'Doe'
261261
};
262-
Assert.assertArrayEquals(
262+
Assertions.assertArrayEquals(
263263
expectedData,
264264
tokensData
265265
);
@@ -286,7 +286,7 @@ public void shouldReturnMultilineTokensData() throws ExecutionException, Interru
286286
3, 0, 5, 0, 0, // WHERE
287287
4, 14, 5, 1, 0 // 'Doe'
288288
};
289-
Assert.assertArrayEquals(
289+
Assertions.assertArrayEquals(
290290
expectedData,
291291
tokensData
292292
);

0 commit comments

Comments
 (0)