Skip to content

Commit

Permalink
remove deprecated simpleparser (#571)
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-mlb authored Dec 14, 2023
1 parent 0316a3a commit 01f44d9
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 313 deletions.
8 changes: 4 additions & 4 deletions src/main/java/emissary/parser/ParserFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

/**
* Provide a factory for getting the proper type of input parser Provide the implementing classes for that match the
* configured Data Identifier Engine in both PARSER_IMPL_[type] and PARSER_NIO_IMPL_[type] variants if available. All
* configured parsers must implement emissary.parser.SessionParser.
* configured Data Identifier Engine in PARSER_NIO_IMPL_[type] variants if available. All configured parsers must
* implement emissary.parser.SessionParser.
*
* When no proper mappings are found or the specified parser cannot be instantiated, the SimpleParser and
* SimpleNioParser are used instead. If these cannot be instantiated, then something is likely seriously wrong.
* When no proper mappings are found or the specified parser cannot be instantiated, the SimpleNioParser is used
* instead. If these cannot be instantiated, then something is likely seriously wrong.
*
* If an NIO parser is requested, see makeSessionParser(FileChannel), but cannot be found for the data type, the Channel
* is evaluated and if under MAX_NIO_FALLBACK_SIZE, then the bytes are consumed and a standard parser is produced if one
Expand Down
155 changes: 0 additions & 155 deletions src/main/java/emissary/parser/SimpleParser.java

This file was deleted.

2 changes: 0 additions & 2 deletions src/main/resources/emissary/parser/ParserFactory.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#
# Set up some defaults
#
DEFAULT_PARSER = "emissary.parser.SimpleParser"
DEFAULT_NIO_PARSER = "emissary.parser.SimpleNioParser"

#
Expand All @@ -14,7 +13,6 @@ MAX_NIO_FALLBACK_SIZE = "100M"
# Any classes specified here must implement
# the interfact emissary.parser.SessionParser
#
PARSER_IMPL_simple = "emissary.parser.SimpleParser"
PARSER_NIO_IMPL_simple = "emissary.parser.SimpleNioParser"

#
Expand Down
12 changes: 7 additions & 5 deletions src/test/java/emissary/parser/SessionProducerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,27 @@
import emissary.test.core.junit5.UnitTest;

import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;

@SuppressWarnings("deprecation")
// TODO: either remove these tests or test the new Parser
class SessionProducerTest extends UnitTest {
@Test
void testBasicSetup() throws Exception {
SimpleParser parser = new SimpleParser("This is a test".getBytes());
SessionParser parser = Mockito.mock(SessionParser.class);
DecomposedSession d = new DecomposedSession();
d.setData("This is a test".getBytes());
Mockito.when(parser.getNextSession()).thenReturn(d);
SessionProducer sp = new SessionProducer(parser, "UNKNOWN");
IBaseDataObject payload = sp.getNextSession("name");
assertEquals("This is a test", new String(payload.data()), "Parser/Producer should create payload object with correct data");
}

@Test
void testZoneAssignments() {
SimpleParser parser = new SimpleParser("This is a test".getBytes());
SessionParser parser = Mockito.mock(SessionParser.class);
SessionProducer sp = new SessionProducer(parser, "UNKNOWN");
DecomposedSession d = new DecomposedSession();
d.setHeader("The Header".getBytes());
Expand All @@ -41,7 +43,7 @@ void testZoneAssignments() {

@Test
void testAlternateViewAssignment() {
SimpleParser parser = new SimpleParser("This is a test".getBytes());
SessionParser parser = Mockito.mock(SessionParser.class);
SessionProducer sp = new SessionProducer(parser, "UNKNOWN");
DecomposedSession d = new DecomposedSession();
d.addMetaData("FOO", "BAR");
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/emissary/parser/SimpleNioParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void testInterface() {
// They will have to look here :-)
try {
SimpleNioParser sp = new SimpleNioParser(channel);
assertTrue(sp instanceof SessionParser, "SimpleParser interface definition");
assertTrue(sp instanceof SessionParser, "SessionParser interface definition");
} catch (ParserException ex) {
fail("SimpleNioParser is not a SessionParser", ex);
}
Expand Down
146 changes: 0 additions & 146 deletions src/test/java/emissary/parser/SimpleParserTest.java

This file was deleted.

0 comments on commit 01f44d9

Please sign in to comment.