INTEXT-23 - Incorrect enum comparison

This commit is contained in:
Jarred Li
2012-10-02 22:17:17 +08:00
committed by Gunnar Hillert
parent 3f167bb28e
commit 1adcce712e
16 changed files with 32 additions and 42 deletions

View File

@@ -19,7 +19,7 @@ Spring Integration's channel. There are 5 ways to get data out of Splunk:
<int-splunk:inbound-channel-adapter id="splunkInboundChannelAdapter"
auto-startup="true" search="search spring:example"
splunk-server-ref="splunkServer"
channel="inputFromSplunk" mode="blocking" earliestTime="-1d" latestTime="now" initEarliestTime="-1d">
channel="inputFromSplunk" mode="BLOCKING" earliestTime="-1d" latestTime="now" initEarliestTime="-1d">
<int:poller fixed-rate="5" time-unit="SECONDS"/>
</int-splunk:inbound-channel-adapter>
~~~~~
@@ -29,7 +29,7 @@ Spring Integration's channel. There are 5 ways to get data out of Splunk:
<int-splunk:inbound-channel-adapter id="splunkInboundChannelAdapter"
auto-startup="true" search="search spring:example"
splunk-server-ref="splunkServer"
channel="inputFromSplunk" mode="normal" earliestTime="-1d" latestTime="now" initEarliestTime="-1d">
channel="inputFromSplunk" mode="NORMAL" earliestTime="-1d" latestTime="now" initEarliestTime="-1d">
<int:poller fixed-rate="5" time-unit="SECONDS"/>
</int-splunk:inbound-channel-adapter>
~~~~~
@@ -38,7 +38,7 @@ Spring Integration's channel. There are 5 ways to get data out of Splunk:
~~~~~xml
<int-splunk:inbound-channel-adapter id="splunkInboundChannelAdapter"
auto-startup="true" savedSearch="test" splunk-server-ref="splunkServer"
channel="inputFromSplunk" mode="saved" earliestTime="-1d" latestTime="now" initEarliestTime="-1d">
channel="inputFromSplunk" mode="SAVEDSEARCH" earliestTime="-1d" latestTime="now" initEarliestTime="-1d">
<int:poller fixed-rate="5" time-unit="SECONDS"/>
</int-splunk:inbound-channel-adapter>
~~~~~
@@ -47,7 +47,7 @@ Spring Integration's channel. There are 5 ways to get data out of Splunk:
~~~~~xml
<int-splunk:inbound-channel-adapter id="splunkInboundChannelAdapter"
auto-startup="true" search="search spring:example" splunk-server-ref="splunkServer" channel="inputFromSplunk"
mode="realtime" earliestTime="-5s" latestTime="rt" initEarliestTime="-1d">
mode="REALTIME" earliestTime="-5s" latestTime="rt" initEarliestTime="-1d">
<int:poller fixed-rate="5" time-unit="SECONDS"/>
</int-splunk:inbound-channel-adapter>
~~~~~
@@ -56,7 +56,7 @@ Spring Integration's channel. There are 5 ways to get data out of Splunk:
~~~~~xml
<int-splunk:inbound-channel-adapter id="splunkInboundChannelAdapter"
auto-startup="true" search="search spring:example" splunk-server-ref="splunkServer" channel="inputFromSplunk"
mode="export" earliestTime="-5d" latestTime="now" initEarliestTime="-1d">
mode="EXPORT" earliestTime="-5d" latestTime="now" initEarliestTime="-1d">
<int:poller fixed-rate="5" time-unit="SECONDS"/>
</int-splunk:inbound-channel-adapter>
~~~~~
@@ -75,7 +75,7 @@ channels in Spring Integration. There are 3 kinds of method to put data
id="splunkOutboundChannelAdapter" auto-startup="true" order="1"
channel="outputToSplunk"
splunk-server-ref="splunkServer" pool-server-connection="true"
sourceType="spring-integration" source="example2" ingest="submit">
sourceType="spring-integration" source="example2" ingest="SUBMIT">
</int-splunk:outbound-channel-adapter>
~~~~~
@@ -85,7 +85,7 @@ channels in Spring Integration. There are 3 kinds of method to put data
<int-splunk:outbound-channel-adapter
id="splunkOutboundChannelAdapter" auto-startup="true" order="1"
channel="outputToSplunk" splunk-server-ref="splunkServer"
ingest="stream">
ingest="STREAM">
</int-splunk:outbound-channel-adapter>
~~~~~
@@ -95,7 +95,7 @@ channels in Spring Integration. There are 3 kinds of method to put data
<int-splunk:outbound-channel-adapter
id="splunkOutboundChannelAdapter" auto-startup="true" order="1"
channel="outputToSplunk" splunk-server-ref="splunkServer"
ingest="tcp" tcpPort="9999">
ingest="TCP" tcpPort="9999">
</int-splunk:outbound-channel-adapter>
~~~~~

View File

@@ -27,15 +27,5 @@ package org.springframework.integration.splunk.support;
*
*/
public enum IngestType {
stream("stream"), tcp("tcp"), submit("submit");
private String type;
IngestType(String ingestType) {
this.type = ingestType;
}
public String getIngestType() {
return type;
}
STREAM, TCP, SUBMIT;
}

View File

@@ -29,5 +29,5 @@ package org.springframework.integration.splunk.support;
*
*/
public enum SearchMode {
blocking, normal, realtime, export, saved;
BLOCKING, NORMAL, REALTIME, EXPORT, SAVEDSEARCH;
}

View File

@@ -179,19 +179,19 @@ public class SplunkDataReader implements DataReader, InitializingBean {
public List<SplunkData> search() throws Exception {
logger.debug("mode:" + mode);
switch (mode) {
case saved: {
case SAVEDSEARCH: {
return savedSearch();
}
case blocking: {
case BLOCKING: {
return blockingSearch();
}
case normal: {
case NORMAL: {
return nonBlockingSearch();
}
case export: {
case EXPORT: {
return exportSearch();
}
case realtime: {
case REALTIME: {
return realtimeSearch();
}
}

View File

@@ -54,7 +54,7 @@ public class SplunkDataWriter implements DataWriter, InitializingBean {
private String index;
private IngestType ingest = IngestType.stream; //tcp, stream, submit
private IngestType ingest = IngestType.STREAM; //tcp, stream, submit
private int tcpPort;
@@ -101,8 +101,8 @@ public class SplunkDataWriter implements DataWriter, InitializingBean {
receiver = service.getReceiver();
}
if ((ingest.equals(IngestType.stream) || ingest.equals(IngestType.tcp))) {
if (ingest.equals("stream")) {
if ((ingest.equals(IngestType.STREAM) || ingest.equals(IngestType.TCP))) {
if (ingest.equals(IngestType.STREAM)) {
if (indexObject != null)
socket = indexObject.attach(args);
else
@@ -115,7 +115,7 @@ public class SplunkDataWriter implements DataWriter, InitializingBean {
writer = new OutputStreamWriter(ostream, "UTF8");
}
if ((ingest.equals(IngestType.stream) || ingest.equals(IngestType.tcp))) {
if ((ingest.equals(IngestType.STREAM) || ingest.equals(IngestType.TCP))) {
writer.write(data.toString());
writer.flush();
writer.close();

View File

@@ -53,7 +53,7 @@ public class SplunkInboundChannelAdapterParserSavedSearchTests {
SplunkDataReader.class);
Assert.assertNotNull(reader);
SearchMode mode = SearchMode.saved;
SearchMode mode = SearchMode.SAVEDSEARCH;
Assert.assertEquals(mode, reader.getMode());
String savedSearch = "savedSearch";

View File

@@ -58,7 +58,7 @@ public class SplunkInboundChannelAdapterParserTests {
String searchString = "search spring:example";
Assert.assertEquals(searchString, reader.getSearch());
SearchMode mode = SearchMode.blocking;
SearchMode mode = SearchMode.BLOCKING;
Assert.assertEquals(mode, reader.getMode());
String earliestTime = "-1d";

View File

@@ -50,7 +50,7 @@ public class SplunkOutboundChannelAdapterParserStreamTests {
SplunkDataWriter.class);
Assert.assertNotNull(writer);
IngestType ingest = IngestType.stream;
IngestType ingest = IngestType.STREAM;
Assert.assertEquals(ingest, writer.getIngest());
String host = "test.host";

View File

@@ -56,7 +56,7 @@ public class SplunkOutboundChannelAdapterParserTests {
String source = "example5";
Assert.assertEquals(source, writer.getSource());
IngestType ingest = IngestType.submit;
IngestType ingest = IngestType.SUBMIT;
Assert.assertEquals(ingest, writer.getIngest());

View File

@@ -58,7 +58,7 @@ public class SplunkDataReaderTests {
*/
@Test
public void testBlockingSearch() throws Exception {
reader.setMode(SearchMode.blocking);
reader.setMode(SearchMode.BLOCKING);
reader.setSearch("search spring:example");
List<SplunkData> data = reader.search();
Assert.assertNotNull(data);
@@ -67,7 +67,7 @@ public class SplunkDataReaderTests {
@Test
public void testNonBlockingSearch() throws Exception {
reader.setMode(SearchMode.normal);
reader.setMode(SearchMode.NORMAL);
reader.setSearch("search spring:example");
List<SplunkData> data = reader.search();
Assert.assertNotNull(data);
@@ -77,7 +77,7 @@ public class SplunkDataReaderTests {
@Test
public void testRealtimeSearch() throws Exception {
reader.setMode(SearchMode.realtime);
reader.setMode(SearchMode.REALTIME);
reader.setSearch("search spring:example");
List<SplunkData> data = reader.search();
Assert.assertNotNull(data);

View File

@@ -50,7 +50,7 @@ public class SplunkDataWriterTests {
*/
@Test
public void testWrite() throws Exception {
writer.setIngest(IngestType.submit);
writer.setIngest(IngestType.SUBMIT);
SplunkData sd = new SplunkData("spring", "spring:example");
sd.setCommonDesc("description");

View File

@@ -11,7 +11,7 @@
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package="org.springframework.integration"></context:component-scan>
<context:component-scan base-package="org.springframework.integration.splunk.support"></context:component-scan>
<bean id="conversionService" class="org.springframework.context.support.ConversionServiceFactoryBean"/>
<int-splunk:server id="splunkServer" host="10.112.127.51" port="8089" userName="admin" password="password" owner="admin"/>

View File

@@ -16,7 +16,7 @@
<int-splunk:inbound-channel-adapter id="splunkInboundChannelAdapter"
auto-startup="false"
splunk-server-ref="splunkServer"
channel="inputFromSplunk" mode="saved" earliestTime="-1d" latestTime="now"
channel="inputFromSplunk" mode="SAVEDSEARCH" earliestTime="-1d" latestTime="now"
initEarliestTime="-1d" count="1000"
savedSearch="savedSearch" owner="admin" app="search">
<int:poller fixed-rate="5000"/>

View File

@@ -16,7 +16,7 @@
<int-splunk:inbound-channel-adapter id="splunkInboundChannelAdapter"
auto-startup="false" search="search spring:example"
splunk-server-ref="splunkServer"
channel="inputFromSplunk" mode="blocking" earliestTime="-1d" latestTime="now"
channel="inputFromSplunk" mode="BLOCKING" earliestTime="-1d" latestTime="now"
initEarliestTime="-1d" fieldList="field1, field2">
<int:poller fixed-rate="5000"/>
</int-splunk:inbound-channel-adapter>

View File

@@ -18,7 +18,7 @@
id="splunkOutboundChannelAdapter" auto-startup="true" order="1"
channel="outputToSplunk" splunk-server-ref="splunkServer"
pool-server-connection="true" sourceType="spring-integration" source="example5"
ingest="stream" host="test.host" hostRegex="test.host.*">
ingest="STREAM" host="test.host" hostRegex="test.host.*">
</int-splunk:outbound-channel-adapter>
</beans>

View File

@@ -18,7 +18,7 @@
id="splunkOutboundChannelAdapter" auto-startup="true" order="1"
channel="outputToSplunk" splunk-server-ref="splunkServer"
pool-server-connection="true" sourceType="spring-integration" source="example5"
ingest="submit">
ingest="SUBMIT">
</int-splunk:outbound-channel-adapter>
</beans>