Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
public class CLIApplicationBase extends BaseApplicationImpl {
private static final Log log = Log.getLog(CLIApplicationBase.class);
protected Path workspaceDirCurrent;
private boolean started = false;
private volatile boolean started = false;

private DBPPreferenceStore preferenceStore;
private boolean stateless = false;
Expand Down
1 change: 1 addition & 0 deletions product/community-unittest/dbvr-unittest.product
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@

<features>
<feature id="org.dbvr.app.ce.test.feature"/>
<feature id="org.jkiss.dbeaver.test.base.feature"/>
</features>

<configurations>
Expand Down
32 changes: 16 additions & 16 deletions test/org.dbvr.test.platform/src/org/dbvr/test/AuthModelsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration;
import org.jkiss.dbeaver.model.connection.DBPDriver;
import org.jkiss.dbeaver.runtime.DBWorkbench;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.util.UUID;

Expand All @@ -41,8 +41,8 @@ public void testListAllAuthModels() throws Exception {
var cmd = DBVRTestSuite.getApplication().createCommandLine();
CLIProcessResult result = cmd.executeCommandLineCommands(null, false, false, args);

Assert.assertNotNull(result.getOutput());
Assert.assertFalse(result.getOutput().isEmpty());
Assertions.assertNotNull(result.getOutput());
Assertions.assertFalse(result.getOutput().isEmpty());
}

@Test
Expand All @@ -56,12 +56,12 @@ public void testFilterByDriver() throws Exception {
var cmd = DBVRTestSuite.getApplication().createCommandLine();
CLIProcessResult result = cmd.executeCommandLineCommands(null, false, false, args);

Assert.assertNotNull(result.getOutput());
Assert.assertFalse(result.getOutput().isEmpty());
Assertions.assertNotNull(result.getOutput());
Assertions.assertFalse(result.getOutput().isEmpty());

String output = result.getOutput().getFirst();
Assert.assertTrue(output.contains("Applicable Drivers: H2 Embedded"));
Assert.assertTrue(output.contains("Auth Model ID: native"));
Assertions.assertTrue(output.contains("Applicable Drivers: H2 Embedded"));
Assertions.assertTrue(output.contains("Auth Model ID: native"));
}

@Test
Expand All @@ -75,12 +75,12 @@ public void testFilterByProvider() throws Exception {
var cmd = DBVRTestSuite.getApplication().createCommandLine();
CLIProcessResult result = cmd.executeCommandLineCommands(null, false, false, args);

Assert.assertNotNull(result.getOutput());
Assert.assertFalse(result.getOutput().isEmpty());
Assertions.assertNotNull(result.getOutput());
Assertions.assertFalse(result.getOutput().isEmpty());

String output = result.getOutput().getFirst();
Assert.assertTrue(output.contains("Auth Model ID:"));
Assert.assertTrue(output.contains("Applicable Drivers:"));
Assertions.assertTrue(output.contains("Auth Model ID:"));
Assertions.assertTrue(output.contains("Applicable Drivers:"));
}

@Test
Expand All @@ -96,12 +96,12 @@ public void testFilterByConnection() throws Exception {
var cmd = DBVRTestSuite.getApplication().createCommandLine();
CLIProcessResult result = cmd.executeCommandLineCommands(null, false, false, args);

Assert.assertNotNull(result.getOutput());
Assert.assertFalse(result.getOutput().isEmpty());
Assertions.assertNotNull(result.getOutput());
Assertions.assertFalse(result.getOutput().isEmpty());

String output = result.getOutput().getFirst();
Assert.assertTrue(output.contains("Applicable Drivers: H2 Embedded"));
Assert.assertTrue(output.contains("Auth Model ID: native"));
Assertions.assertTrue(output.contains("Applicable Drivers: H2 Embedded"));
Assertions.assertTrue(output.contains("Auth Model ID: native"));
} finally {
ds.getRegistry().removeDataSource(ds);
}
Expand Down
27 changes: 20 additions & 7 deletions test/org.dbvr.test.platform/src/org/dbvr/test/DBVRTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,36 @@
*/
package org.dbvr.test;

import org.jkiss.junit.osgi.OSGITestRunner;
import org.jkiss.junit.osgi.annotation.RunWithApplication;
import org.jkiss.junit.osgi.annotation.RunWithProduct;
import org.jkiss.junit.osgi.annotation.RunnerProxy;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.jkiss.junit.osgi.behaviors.IAsyncApplication;
import org.jkiss.junit.osgi.extension.OSGITestExtension;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.extension.ExtendWith;

@RunWithProduct("dbvr-unittest.product")
@RunnerProxy(MockitoJUnitRunner.class)
@RunWith(OSGITestRunner.class)
@ExtendWith(OSGITestExtension.class)
@RunWithApplication(
bundleName = "org.dbvr.app.ce",
registryName = "org.dbvr.app.ce.application",
waitForWorkbench = false,
properties = {
@RunWithApplication.Property(name = "osgi.instance.area", value = "./target/workpsace")
}
)
public abstract class DBVRTest {
public abstract class DBVRTest implements IAsyncApplication {

Check warning on line 36 in test/org.dbvr.test.platform/src/org/dbvr/test/DBVRTest.java

View workflow job for this annotation

GitHub Actions / Check style / Lint

[checkstyle] reported by reviewdog 🐶 Abbreviation in name 'DBVRTest' must contain no more than '4' consecutive capital letters. Raw Output: /github/workspace/./test/org.dbvr.test.platform/src/org/dbvr/test/DBVRTest.java:36:23: warning: Abbreviation in name 'DBVRTest' must contain no more than '4' consecutive capital letters. (com.puppycrawl.tools.checkstyle.checks.naming.AbbreviationAsWordInNameCheck)

@BeforeAll
public static void setUpApplication() throws Exception {
DBVRTestSuite.initApplication();
}

@Override
public boolean verifyLaunched() {
try {
return DBVRTestSuite.getApplication().isStarted();
} catch (Exception e) {
return false;
}
}
}
22 changes: 12 additions & 10 deletions test/org.dbvr.test.platform/src/org/dbvr/test/DBVRTestSuite.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,22 @@
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.runtime.DBWorkbench;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.platform.suite.api.SelectClasses;
import org.junit.platform.suite.api.Suite;


@RunWith(Suite.class)
@Suite.SuiteClasses({
@Suite
@SelectClasses({
HelpArgTest.class,
DataSourceManagementTest.class,
ProjectManagementTest.class,
AuthModelsTest.class,
InjectTest.class,
MetaLocalCommandTest.class
})
public class DBVRTestSuite {
public class DBVRTestSuite extends DBVRTest {

Check warning on line 36 in test/org.dbvr.test.platform/src/org/dbvr/test/DBVRTestSuite.java

View workflow job for this annotation

GitHub Actions / Check style / Lint

[checkstyle] reported by reviewdog 🐶 Abbreviation in name 'DBVRTestSuite' must contain no more than '4' consecutive capital letters. Raw Output: /github/workspace/./test/org.dbvr.test.platform/src/org/dbvr/test/DBVRTestSuite.java:36:14: warning: Abbreviation in name 'DBVRTestSuite' must contain no more than '4' consecutive capital letters. (com.puppycrawl.tools.checkstyle.checks.naming.AbbreviationAsWordInNameCheck)
private static CLIApplicationCE applicationCE;

@BeforeClass
public static void initApplication() throws Exception {
System.out.println("Start CLI Application");
if (DBWorkbench.isPlatformStarted()) {
Expand Down Expand Up @@ -72,10 +70,14 @@
@NotNull
public static CLIApplicationCE getApplication() throws DBException {
if (applicationCE == null) {
if (DBWorkbench.isPlatformStarted()) {
return (CLIApplicationCE) DBWorkbench.getPlatform().getApplication();
// running inside OSGi: the runner already started the app, read it from the platform
if (DBWorkbench.isPlatformStarted()
&& DBWorkbench.getPlatform().getApplication() instanceof CLIApplicationCE ce) {
applicationCE = ce;
}
if (applicationCE == null) {
throw new DBException("Application is not running");
}
throw new DBException("Application is not running");
}

return applicationCE;
Expand Down
Loading
Loading