Skip to content

Commit

Permalink
fix(ZettelkastenViewUpdateDisplayTest): ensure that the test does not…
Browse files Browse the repository at this point in the history
… run in a headless environment
  • Loading branch information
RalfBarkow committed Sep 5, 2024
1 parent 3711cd5 commit 07facbd
Showing 1 changed file with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

import org.jdesktop.application.SingleFrameApplication;

import java.awt.GraphicsEnvironment;
import org.testng.SkipException;

public class ZettelkastenViewUpdateDisplayTest {

private ZettelkastenView zettelkastenView;
Expand All @@ -20,6 +23,11 @@ public class ZettelkastenViewUpdateDisplayTest {

@BeforeMethod
public void setUp() throws Exception {
// Check if the environment is headless, and skip the test if so
if (GraphicsEnvironment.isHeadless()) {
throw new SkipException("Test skipped: Headless environment detected.");
}

settings = new Settings();
tasksData = new TasksData();
data = new Daten(zettelkastenView, settings, null, null);
Expand All @@ -31,17 +39,22 @@ protected void startup() {
zettelkastenView = new ZettelkastenView(app, settings, tasksData);
zettelkastenView.setData(data);
}

@Test
public void testUpdateEntryPaneAndKeywordsPaneInvalidEntry() {
// Check if the environment is headless and skip the test if so
if (GraphicsEnvironment.isHeadless()) {
throw new SkipException("Test skipped: Headless environment detected.");
}

int invalidEntryNumber = 0;

zettelkastenView.updateEntryPaneAndKeywordsPane(invalidEntryNumber);

assertTrue(zettelkastenView.jEditorPaneEntry.getText().contains("<body>"));
assertTrue(zettelkastenView.keywordListModel.isEmpty());
assertEquals(zettelkastenView.jTextFieldEntryNumber.getText(), "");
assertEquals(zettelkastenView.statusOfEntryLabel.getText(),
zettelkastenView.getResourceMap().getString("entryOfText"));
assertEquals(zettelkastenView.statusOfEntryLabel.getText(),
zettelkastenView.getResourceMap().getString("entryOfText"));
}
}
}

0 comments on commit 07facbd

Please sign in to comment.