Skip to content
This repository has been archived by the owner on Sep 12, 2021. It is now read-only.

Allow access to component factory for sub-classes. #69

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import org.junit.Before;
import org.junit.Test;

import com.codeaffine.console.core.ConsoleComponentFactory;
import com.codeaffine.console.core.pdetest.console.TestConsoleComponentFactory;
import com.codeaffine.console.core.pdetest.console.TestConsoleConfigurer;

public class GenericConsolePDETest {
Expand All @@ -26,6 +28,20 @@ public void testInitialize() {
verify( consoleConfigurer ).configure( console );
}

@Test
public void testGetConsoleComponentFactory() {
// should return null without initialization
assertThat( console.getConsoleComponentFactory() ).isNull();

// set a console
console.setConsoleComponentFactory( new TestConsoleComponentFactory() );

// note, the implementation wraps it into a GenericConsoleComponentFactory
ConsoleComponentFactory componentFactory = console.getConsoleComponentFactory();
assertThat( componentFactory ).isNotNull();
assertThat( componentFactory.getClass() ).isSameAs( GenericConsoleComponentFactory.class );
}

@Test
public void testGetEncoding() {
String encoding = console.getEncoding();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ public ColorScheme getColorScheme() {
return colorScheme;
}

public ConsoleComponentFactory getConsoleComponentFactory() {
return this.consoleComponentFactory;
}

@Override
public void setConsoleComponentFactory( ConsoleComponentFactory consoleComponentFactory ) {
this.consoleComponentFactory = new GenericConsoleComponentFactory( consoleComponentFactory );
Expand Down