You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@metron.apache.org by ce...@apache.org on 2016/02/10 15:28:03 UTC
incubator-metron git commit: METRON-28 Metron should compile with
JUnit 4 (dossett via cestella) closes apache/incubator-metron#18
Repository: incubator-metron
Updated Branches:
refs/heads/master 4536eb5fd -> 973b1bbc4
METRON-28 Metron should compile with JUnit 4 (dossett via cestella) closes apache/incubator-metron#18
Project: http://git-wip-us.apache.org/repos/asf/incubator-metron/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-metron/commit/973b1bbc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-metron/tree/973b1bbc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-metron/diff/973b1bbc
Branch: refs/heads/master
Commit: 973b1bbc45f9b3687458b9f6ff4d8740eb7506f7
Parents: 4536eb5
Author: dossett <do...@gmail.com>
Authored: Wed Feb 10 09:27:41 2016 -0500
Committer: cstella <ce...@gmail.com>
Committed: Wed Feb 10 09:27:41 2016 -0500
----------------------------------------------------------------------
.../alerts/adapters/AllAlertAdapterTest.java | 7 +-
metron-streaming/Metron-Common/pom.xml | 3 +-
.../apache/metron/test/AbstractConfigTest.java | 8 +-
.../apache/metron/test/AbstractSchemaTest.java | 2 +
.../apache/metron/test/AbstractTestContext.java | 13 +-
.../test/BasicTldExtractorTest.java | 125 --------
.../org/apache/metron/AbstractConfigTest.java | 300 +++++++++++++++++++
.../org/apache/metron/AbstractSchemaTest.java | 198 ++++++++++++
.../org/apache/metron/AbstractTestContext.java | 191 ++++++++++++
.../tldextractor/BasicTldExtractorTest.java | 72 +++++
.../adapters/cif/CIFHbaseAdapterTest.java | 21 +-
.../adapters/geo/GeoMysqlAdapterTest.java | 18 +-
.../adapters/whois/WhoisHBaseAdapterTest.java | 11 +-
.../parsing/test/BasicFireEyeParserTest.java | 9 +-
.../metron/parsing/test/BasicIseParserTest.java | 3 +-
.../parsing/test/BasicLancopeParserTest.java | 5 +-
.../test/BasicPaloAltoFirewallParserTest.java | 5 +-
.../parsing/test/BasicSourcefireParserTest.java | 5 +-
.../metron/parsing/test/BroParserTest.java | 5 +-
.../metron/parsing/test/GrokAsaParserTest.java | 13 +-
metron-streaming/pom.xml | 6 +-
21 files changed, 832 insertions(+), 188 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/973b1bbc/metron-streaming/Metron-Alerts/src/test/java/org/apache/metron/alerts/adapters/AllAlertAdapterTest.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-Alerts/src/test/java/org/apache/metron/alerts/adapters/AllAlertAdapterTest.java b/metron-streaming/Metron-Alerts/src/test/java/org/apache/metron/alerts/adapters/AllAlertAdapterTest.java
index 6731536..86d4481 100644
--- a/metron-streaming/Metron-Alerts/src/test/java/org/apache/metron/alerts/adapters/AllAlertAdapterTest.java
+++ b/metron-streaming/Metron-Alerts/src/test/java/org/apache/metron/alerts/adapters/AllAlertAdapterTest.java
@@ -22,6 +22,7 @@ import java.util.Properties;
import org.apache.metron.test.AbstractConfigTest;
import org.apache.metron.alerts.adapters.AllAlertAdapter;
+import org.junit.Assert;
/**
* <ul>
@@ -72,7 +73,7 @@ public class AllAlertAdapterTest extends AbstractConfigTest {
protected void setUp() throws Exception {
super.setUp("org.apache.metron.alerts.adapters.AllAlertAdapter");
Properties prop = super.getTestProperties();
- assertNotNull(prop);
+ Assert.assertNotNull(prop);
// this.setMode("global");
if(skipTests(this.getMode())){
System.out.println(getClass().getName()+" Skipping Tests !!Local Mode");
@@ -108,7 +109,7 @@ public class AllAlertAdapterTest extends AbstractConfigTest {
}else{
boolean initialized =AllAlertAdapterTest.getAllAlertAdapter().initialize();
- assertTrue(initialized);
+ Assert.assertTrue(initialized);
}
}
@@ -120,7 +121,7 @@ public class AllAlertAdapterTest extends AbstractConfigTest {
return;//skip tests
}else{
boolean containsAlert =AllAlertAdapterTest.getAllAlertAdapter().containsAlertId("test");
- assertFalse(containsAlert);
+ Assert.assertFalse(containsAlert);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/973b1bbc/metron-streaming/Metron-Common/pom.xml
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-Common/pom.xml b/metron-streaming/Metron-Common/pom.xml
index 214e060..75ee9d9 100644
--- a/metron-streaming/Metron-Common/pom.xml
+++ b/metron-streaming/Metron-Common/pom.xml
@@ -97,7 +97,8 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>3.8.2</version>
+ <version>${global_junit_version}</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/973b1bbc/metron-streaming/Metron-Common/src/main/java/org/apache/metron/test/AbstractConfigTest.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-Common/src/main/java/org/apache/metron/test/AbstractConfigTest.java b/metron-streaming/Metron-Common/src/main/java/org/apache/metron/test/AbstractConfigTest.java
index 9dadc33..74989d2 100644
--- a/metron-streaming/Metron-Common/src/main/java/org/apache/metron/test/AbstractConfigTest.java
+++ b/metron-streaming/Metron-Common/src/main/java/org/apache/metron/test/AbstractConfigTest.java
@@ -1,6 +1,4 @@
-
-
- /*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
@@ -110,9 +108,9 @@ public class AbstractConfigTest extends AbstractTestContext{
this.setSettings(SettingsLoader.getConfigOptions((PropertiesConfiguration)this.config, configName + "."));
this.getSettings().put(configName, (String) configOptions.get(configName));
} catch (ConfigurationException e) {
- fail("Config not found !!"+e);
e.printStackTrace();
- }
+ throw new Exception("Config not found !!"+e);
+ }
}
/*
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/973b1bbc/metron-streaming/Metron-Common/src/main/java/org/apache/metron/test/AbstractSchemaTest.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-Common/src/main/java/org/apache/metron/test/AbstractSchemaTest.java b/metron-streaming/Metron-Common/src/main/java/org/apache/metron/test/AbstractSchemaTest.java
index d568b56..3b6c098 100644
--- a/metron-streaming/Metron-Common/src/main/java/org/apache/metron/test/AbstractSchemaTest.java
+++ b/metron-streaming/Metron-Common/src/main/java/org/apache/metron/test/AbstractSchemaTest.java
@@ -192,6 +192,8 @@ public class AbstractSchemaTest extends AbstractConfigTest{
public String getSchemaJsonString() {
return this.schemaJsonString;
}
+
+ protected void assertNotNull(Object o) throws Exception {}
}
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/973b1bbc/metron-streaming/Metron-Common/src/main/java/org/apache/metron/test/AbstractTestContext.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-Common/src/main/java/org/apache/metron/test/AbstractTestContext.java b/metron-streaming/Metron-Common/src/main/java/org/apache/metron/test/AbstractTestContext.java
index bd7267d..c81caff 100644
--- a/metron-streaming/Metron-Common/src/main/java/org/apache/metron/test/AbstractTestContext.java
+++ b/metron-streaming/Metron-Common/src/main/java/org/apache/metron/test/AbstractTestContext.java
@@ -1,6 +1,4 @@
-
-
- /*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
@@ -23,8 +21,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
-import junit.framework.TestCase;
-
/**
* <ul>
* <li>Title: </li>
@@ -37,7 +33,7 @@ import junit.framework.TestCase;
* </ul>
* @version $Revision: 1.1 $
*/
-public class AbstractTestContext extends TestCase{
+public class AbstractTestContext {
/**
* The testProps.
*/
@@ -68,7 +64,6 @@ public class AbstractTestContext extends TestCase{
* @param name the name of the test case.
*/
public AbstractTestContext(String name) {
- super(name);
try{
if(System.getProperty("mode")!=null){
setMode(System.getProperty("mode") );
@@ -85,7 +80,6 @@ public class AbstractTestContext extends TestCase{
* (non-Javadoc)
* @see junit.framework.TestCase#setUp()
*/
- @Override
protected void setUp() throws Exception {
InputStream input=null;
File directory = new File("src/test/resources");
@@ -102,7 +96,7 @@ public class AbstractTestContext extends TestCase{
testProperties.load(input);
}catch(IOException ex){
ex.printStackTrace();
- fail("failed to load properties");
+ throw new Exception("failed to load properties");
}
@@ -112,7 +106,6 @@ public class AbstractTestContext extends TestCase{
* (non-Javadoc)
* @see junit.framework.TestCase#tearDown()
*/
- @Override
protected void tearDown() throws Exception {
}
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/973b1bbc/metron-streaming/Metron-Common/src/main/java/org/apache/metron/tldextractor/test/BasicTldExtractorTest.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-Common/src/main/java/org/apache/metron/tldextractor/test/BasicTldExtractorTest.java b/metron-streaming/Metron-Common/src/main/java/org/apache/metron/tldextractor/test/BasicTldExtractorTest.java
deleted file mode 100644
index 73175f0..0000000
--- a/metron-streaming/Metron-Common/src/main/java/org/apache/metron/tldextractor/test/BasicTldExtractorTest.java
+++ /dev/null
@@ -1,125 +0,0 @@
-
-
- /*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.metron.tldextractor.test;
-
-import org.apache.metron.test.AbstractConfigTest;
-import org.apache.metron.tldextractor.BasicTldExtractor;
-
-
- /**
- * <ul>
- * <li>Title: Basic TLD Extractor Test</li>
- * <li>Description: Basic TLD Extractor class test</li>
- * <li>Created: Feb 26, 2015</li>
- * </ul>
- * @author $Author: $
- * @version $Revision: 1.1 $
- */
-public class BasicTldExtractorTest extends AbstractConfigTest {
- /**
- * The tldExtractor.
- */
-
- private BasicTldExtractor tldExtractor=null;
-
- /**
- * Constructs a new <code>BasicTldExtractorTest</code> instance.
- * @param name
- */
-
- public BasicTldExtractorTest(String name) {
- super(name);
- }
-
- /**
-
- * @throws java.lang.Exception
- */
- protected static void setUpBeforeClass() throws Exception {
- }
-
- /**
-
- * @throws java.lang.Exception
- */
- protected static void tearDownAfterClass() throws Exception {
- }
-
- /*
- * (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
-
- protected void setUp() throws Exception {
- super.setUp("org.apache.metron.tldextractor.test.BasicTldExtractorTest");
- this.tldExtractor=new BasicTldExtractor(this.getConfig().getString("logFile"));
- }
-
- /*
- * (non-Javadoc)
- * @see junit.framework.TestCase#tearDown()
- */
-
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- /**
- * Test method for {@link org.apache.metron.tldextractor.BasicTldExtractor#BasicTldExtractor()}.
- */
- public void testBasicTldExtractor() {
- assertNotNull(this.tldExtractor);
- }
-
- /**
- * Test method for {@link org.apache.metron.tldextractor.BasicTldExtractor#extract2LD(java.lang.String)}.
- */
- public void testExtract2LD() {
- //fail("Not yet implemented");
- }
-
- /**
- * Test method for {@link org.apache.metron.tldextractor.BasicTldExtractor#extractTLD(java.lang.String)}.
- */
- public void testExtractTLD()
- {
- String result = this.tldExtractor.extractTLD("cisco.com");
- System.out.println("result ="+result);
- }
- /**
- * Returns the tldExtractor.
- * @return the tldExtractor.
- */
-
- public BasicTldExtractor getTldExtractor() {
- return tldExtractor;
- }
-
- /**
- * Sets the tldExtractor.
- * @param tldExtractor the tldExtractor.
- */
-
- public void setTldExtractor(BasicTldExtractor tldExtractor) {
-
- this.tldExtractor = tldExtractor;
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/973b1bbc/metron-streaming/Metron-Common/src/test/java/org/apache/metron/AbstractConfigTest.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-Common/src/test/java/org/apache/metron/AbstractConfigTest.java b/metron-streaming/Metron-Common/src/test/java/org/apache/metron/AbstractConfigTest.java
new file mode 100644
index 0000000..4976eba
--- /dev/null
+++ b/metron-streaming/Metron-Common/src/test/java/org/apache/metron/AbstractConfigTest.java
@@ -0,0 +1,300 @@
+
+
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.metron;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Map;
+
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.PropertiesConfiguration;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.github.fge.jackson.JsonLoader;
+import com.github.fge.jsonschema.core.report.ProcessingReport;
+import com.github.fge.jsonschema.main.JsonSchemaFactory;
+import com.github.fge.jsonschema.main.JsonValidator;
+import org.apache.metron.AbstractTestContext;
+import org.apache.metron.helpers.topology.SettingsLoader;
+
+ /**
+ * <ul>
+ * <li>Title: </li>
+ * <li>Description: The class <code>AbstractConfigTest</code> is
+ * an abstract base class for implementing JUnit tests that need to use
+ * config to connect to ZooKeeper and HBase. The <code>setup</code> method will attempt to
+ * load a properties from a file, located in src/test/resources,
+ * with the same name as the class.</li>
+ * <li>Created: Oct 10, 2014</li>
+ * </ul>
+ * @version $Revision: 1.1 $
+ */
+public class AbstractConfigTest extends AbstractTestContext {
+ /**
+ * The configPath.
+ */
+ protected String configPath=null;
+
+ /**
+ * The configName.
+ */
+ protected String configName=null;
+
+ /**
+ * The config.
+ */
+ private Configuration config=null;
+
+ /**
+ * The settings.
+ */
+ Map<String, String> settings=null;
+
+ /**
+ * The schemaJsonString.
+ */
+ private String schemaJsonString = null;
+ /**
+ * Any Object for mavenMode
+ * @parameter
+ * expression="${mode}"
+ * default-value="local"
+ */
+ private Object mode="local";
+
+ /**
+ * Constructs a new <code>AbstractConfigTest</code> instance.
+ * @throws Exception
+ */
+ public AbstractConfigTest() throws Exception {
+ super.setUp();
+ }
+
+ /**
+ * Constructs a new <code>AbstractTestContext</code> instance.
+ * @param name the name of the test case.
+ */
+ public AbstractConfigTest(String name) {
+ super(name);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp(String configName) throws Exception {
+ super.setUp();
+ this.setConfigPath("src/test/resources/config/"+getClass().getSimpleName()+".config");
+ try {
+ this.setConfig(new PropertiesConfiguration(this.getConfigPath()));
+
+ Map configOptions= SettingsLoader.getConfigOptions((PropertiesConfiguration)this.config, configName+"=");
+ this.setSettings(SettingsLoader.getConfigOptions((PropertiesConfiguration)this.config, configName + "."));
+ this.getSettings().put(configName, (String) configOptions.get(configName));
+ } catch (ConfigurationException e) {
+ e.printStackTrace();
+ throw new Exception("Config not found !!"+e);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ @Override
+ protected void tearDown() throws Exception {
+
+ }
+
+
+ /**
+ * validateJsonData
+ * @param jsonSchema
+ * @param jsonData
+ * @return
+ * @throws Exception
+ */
+
+ protected boolean validateJsonData(final String jsonSchema, final String jsonData)
+ throws Exception {
+
+ final JsonNode d = JsonLoader.fromString(jsonData);
+ final JsonNode s = JsonLoader.fromString(jsonSchema);
+
+ final JsonSchemaFactory factory = JsonSchemaFactory.byDefault();
+ JsonValidator v = factory.getValidator();
+
+ ProcessingReport report = v.validate(s, d);
+ System.out.println(report);
+
+ return report.toString().contains("success");
+ }
+
+ protected String readSchemaFromFile(URL schema_url) throws Exception {
+ BufferedReader br = new BufferedReader(new FileReader(
+ schema_url.getFile()));
+ String line;
+ StringBuilder sb = new StringBuilder();
+ while ((line = br.readLine()) != null) {
+ System.out.println(line);
+ sb.append(line);
+ }
+ br.close();
+
+ String schema_string = sb.toString().replaceAll("\n", "");
+ schema_string = schema_string.replaceAll(" ", "");
+
+ System.out.println("Read in schema: " + schema_string);
+
+ return schema_string;
+ }
+
+ protected String[] readTestDataFromFile(String test_data_url) throws Exception {
+ BufferedReader br = new BufferedReader(new FileReader(
+ new File(test_data_url)));
+ ArrayList<String> inputDataLines = new ArrayList<String>();
+
+ String line;
+ while ((line = br.readLine()) != null) {
+ System.out.println(line);
+ inputDataLines.add(line.toString().replaceAll("\n", ""));
+ }
+ br.close();
+ String[] inputData = new String[inputDataLines.size()];
+ inputData = inputDataLines.toArray(inputData);
+
+ return inputData;
+ }
+ /**
+ * Skip Tests
+ */
+ public boolean skipTests(Object mode){
+ if(mode.toString().equals("local")){
+ return true;
+ }else {
+ return false;
+ }
+ }
+
+ /**
+ * Returns the mode.
+ * @return the mode.
+ */
+
+ public Object getMode() {
+ return mode;
+ }
+
+ /**
+ * Sets the mode.
+ * @param mode the mode.
+ */
+
+ public void setMode(Object mode) {
+
+ this.mode = mode;
+ }
+
+
+ /**
+ * @param readSchemaFromFile
+ */
+ public void setSchemaJsonString(String schemaJsonString) {
+ this.schemaJsonString=schemaJsonString;
+ }
+
+
+ /**
+ * @return
+ */
+ public String getSchemaJsonString() {
+ return this.schemaJsonString;
+ }
+
+ /**
+ * Returns the configPath.
+ * @return the configPath.
+ */
+ public String getConfigPath() {
+ return configPath;
+ }
+
+ /**
+ * Sets the configPath.
+ * @param configPath the configPath.
+ */
+ public void setConfigPath(String configPath) {
+ this.configPath = configPath;
+ }
+ /**
+ * Returns the config.
+ * @return the config.
+ */
+
+ public Configuration getConfig() {
+ return config;
+ }
+
+ /**
+ * Sets the config.
+ * @param config the config.
+ */
+
+ public void setConfig(Configuration config) {
+
+ this.config = config;
+ }
+ /**
+ * Returns the settings.
+ * @return the settings.
+ */
+
+ public Map<String, String> getSettings() {
+ return settings;
+ }
+
+ /**
+ * Sets the settings.
+ * @param settings the settings.
+ */
+
+ public void setSettings(Map<String, String> settings) {
+ this.settings = settings;
+ }
+ /**
+ * Returns the configName.
+ * @return the configName.
+ */
+ public String getConfigName() {
+ return configName;
+ }
+
+ /**
+ * Sets the configName.
+ * @param configName the configName.
+ */
+ public void setConfigName(String configName) {
+ this.configName = configName;
+ }
+}
+
+
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/973b1bbc/metron-streaming/Metron-Common/src/test/java/org/apache/metron/AbstractSchemaTest.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-Common/src/test/java/org/apache/metron/AbstractSchemaTest.java b/metron-streaming/Metron-Common/src/test/java/org/apache/metron/AbstractSchemaTest.java
new file mode 100644
index 0000000..6352198
--- /dev/null
+++ b/metron-streaming/Metron-Common/src/test/java/org/apache/metron/AbstractSchemaTest.java
@@ -0,0 +1,198 @@
+
+
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.metron;
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.net.URL;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.github.fge.jackson.JsonLoader;
+import com.github.fge.jsonschema.core.report.ProcessingReport;
+import com.github.fge.jsonschema.main.JsonSchemaFactory;
+import com.github.fge.jsonschema.main.JsonValidator;
+
+ /**
+ * <ul>
+ * <li>Title: </li>
+ * <li>Description: The class <code>AbstractSchemaTest</code> is
+ * an abstract base class for implementing JUnit tests that need to load a
+ * Json Schema. The <code>setup</code> method will attempt to
+ * load a properties from a file, located in src/test/resources,
+ * with the same name as the class.</li>
+ * <li>Created: Aug 7, 2014</li>
+ * </ul>
+ * @version $Revision: 1.1 $
+ */
+public class AbstractSchemaTest extends AbstractConfigTest{
+
+
+ /**
+ * The schemaJsonString.
+ */
+ private String schemaJsonString = null;
+ /**
+ * Any Object for mavenMode
+ * @parameter
+ * expression="${mode}"
+ * default-value="local"
+ */
+ private Object mode="local";
+
+ /**
+ * Constructs a new <code>AbstractTestContext</code> instance.
+ * @throws Exception
+ */
+ public AbstractSchemaTest() throws Exception {
+ super.setUp();
+ }
+
+ /**
+ * Constructs a new <code>AbstractTestContext</code> instance.
+ * @param name the name of the test case.
+ */
+ public AbstractSchemaTest(String name) {
+ super(name);
+ try{
+ if(System.getProperty("mode")!=null){
+ setMode(System.getProperty("mode") );
+ }else
+ {
+ setMode("local");
+ }
+ }catch(Exception ex){
+ setMode("local");
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ @Override
+ protected void tearDown() throws Exception {
+
+ }
+
+
+ /**
+ * validateJsonData
+ * @param jsonSchema
+ * @param jsonData
+ * @return
+ * @throws Exception
+ */
+
+ protected boolean validateJsonData(final String jsonSchema, final String jsonData)
+ throws Exception {
+
+ final JsonNode d = JsonLoader.fromString(jsonData);
+ final JsonNode s = JsonLoader.fromString(jsonSchema);
+
+ final JsonSchemaFactory factory = JsonSchemaFactory.byDefault();
+ JsonValidator v = factory.getValidator();
+
+ ProcessingReport report = v.validate(s, d);
+ System.out.println(report);
+
+ return report.toString().contains("success");
+ }
+
+ protected String readSchemaFromFile(URL schema_url) throws Exception {
+ BufferedReader br = new BufferedReader(new FileReader(
+ schema_url.getFile()));
+ String line;
+ StringBuilder sb = new StringBuilder();
+ while ((line = br.readLine()) != null) {
+ System.out.println(line);
+ sb.append(line);
+ }
+ br.close();
+
+ String schema_string = sb.toString().replaceAll("\n", "");
+ schema_string = schema_string.replaceAll(" ", "");
+
+ System.out.println("Read in schema: " + schema_string);
+
+ return schema_string;
+
+ }
+
+ /**
+ * Skip Tests
+ */
+ public boolean skipTests(Object mode){
+ if(mode.toString().equals("local")){
+ return true;
+ }else {
+ return false;
+ }
+ }
+
+ /**
+ * Returns the mode.
+ * @return the mode.
+ */
+
+ public Object getMode() {
+ return mode;
+ }
+
+ /**
+ * Sets the mode.
+ * @param mode the mode.
+ */
+
+ public void setMode(Object mode) {
+
+ this.mode = mode;
+ }
+
+
+ /**
+
+ * @param readSchemaFromFile
+ */
+
+ public void setSchemaJsonString(String schemaJsonString) {
+ this.schemaJsonString=schemaJsonString;
+ }
+
+
+ /**
+
+ * @return
+ */
+
+ public String getSchemaJsonString() {
+ return this.schemaJsonString;
+ }
+
+}
+
+
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/973b1bbc/metron-streaming/Metron-Common/src/test/java/org/apache/metron/AbstractTestContext.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-Common/src/test/java/org/apache/metron/AbstractTestContext.java b/metron-streaming/Metron-Common/src/test/java/org/apache/metron/AbstractTestContext.java
new file mode 100644
index 0000000..a057562
--- /dev/null
+++ b/metron-streaming/Metron-Common/src/test/java/org/apache/metron/AbstractTestContext.java
@@ -0,0 +1,191 @@
+
+
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.metron;
+import org.junit.After;
+import org.junit.Test;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+ /**
+ * <ul>
+ * <li>Title: </li>
+ * <li>Description: The class <code>AbstractTestContext</code> is
+ * an abstract base class for implementing JUnit tests that need to load a
+ * test properties. The <code>setup</code> method will attempt to
+ * load a properties from a file, located in src/test/resources,
+ * with the same name as the class.</li>
+ * <li>Created: Aug 7, 2014</li>
+ * </ul>
+ * @version $Revision: 1.1 $
+ */
+public class AbstractTestContext {
+ /**
+ * The testProps.
+ */
+ protected File testPropFile=null;
+
+ /**
+ * The properties loaded for test.
+ */
+ protected Properties testProperties=new Properties();
+
+ /**
+ * Any Object for mavenMode
+ * @parameter
+ * expression="${mode}"
+ * default-value="global"
+ */
+ private Object mode="local";
+
+ /**
+ * Constructs a new <code>AbstractTestContext</code> instance.
+ */
+ public AbstractTestContext() {
+ super();
+ }
+
+ /**
+ * Constructs a new <code>AbstractTestContext</code> instance.
+ * @param name the name of the test case.
+ */
+ public AbstractTestContext(String name) {
+ try{
+ if(System.getProperty("mode")!=null){
+ setMode(System.getProperty("mode") );
+ }else
+ {
+ setMode("local");
+ }
+ }catch(Exception ex){
+ setMode("local");
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ InputStream input=null;
+ File directory = new File("src/test/resources");
+ if (!directory.isDirectory()) {
+ return;
+ }
+ File file = new File(directory, getClass().getSimpleName() + ".properties");
+ if (!file.canRead()) {
+ return;
+ }
+ setTestPropFile(file);
+ try{
+ input=new FileInputStream(file);
+ testProperties.load(input);
+ }catch(IOException ex){
+ ex.printStackTrace();
+ throw new Exception("failed to load properties");
+ }
+
+
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ @After
+ protected void tearDown() throws Exception {
+
+ }
+
+ /**
+ * Returns the testProperties.
+ * @return the testProperties.
+ */
+
+ public Properties getTestProperties() {
+ return testProperties;
+ }
+
+ /**
+ * Sets the testProperties.
+ * @param testProperties the testProperties.
+ */
+
+ public void setTestProperties(Properties testProperties) {
+
+ this.testProperties = testProperties;
+ }
+ /**
+ * Returns the testPropFile.
+ * @return the testPropFile.
+ */
+
+ public File getTestPropFile() {
+ return testPropFile;
+ }
+
+ /**
+ * Sets the testPropFile.
+ * @param testPropFile the testPropFile.
+ */
+
+ public void setTestPropFile(File testPropFile) {
+
+ this.testPropFile = testPropFile;
+ }
+
+ /**
+ * Skip Tests
+ */
+ public boolean skipTests(Object mode){
+ if(mode.toString().equals("local")){
+ return true;
+ }else {
+ return false;
+ }
+ }
+
+ /**
+ * Returns the mode.
+ * @return the mode.
+ */
+
+ public Object getMode() {
+ return mode;
+ }
+
+ /**
+ * Sets the mode.
+ * @param mode the mode.
+ */
+
+ public void setMode(Object mode) {
+
+ this.mode = mode;
+ }
+
+ protected void assertNotNull() {}
+ protected void assertNotNull(Object o) {}
+
+ }
+
+
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/973b1bbc/metron-streaming/Metron-Common/src/test/java/org/apache/metron/tldextractor/BasicTldExtractorTest.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-Common/src/test/java/org/apache/metron/tldextractor/BasicTldExtractorTest.java b/metron-streaming/Metron-Common/src/test/java/org/apache/metron/tldextractor/BasicTldExtractorTest.java
new file mode 100644
index 0000000..7ce1719
--- /dev/null
+++ b/metron-streaming/Metron-Common/src/test/java/org/apache/metron/tldextractor/BasicTldExtractorTest.java
@@ -0,0 +1,72 @@
+
+
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.metron.tldextractor;
+
+import org.apache.metron.AbstractConfigTest;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+
+ /**
+ * <ul>
+ * <li>Title: Basic TLD Extractor Test</li>
+ * <li>Description: Basic TLD Extractor class test</li>
+ * <li>Created: Feb 26, 2015</li>
+ * </ul>
+ * @author $Author: $
+ * @version $Revision: 1.1 $
+ */
+public class BasicTldExtractorTest {
+
+ private BasicTldExtractor tldExtractor=null;
+
+ @Before
+ public void setUp() throws Exception {
+ //super.setUp("org.apache.metron.tldextractor.BasicTldExtractorTest");
+ this.tldExtractor=new BasicTldExtractor();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ //super.tearDown();
+ }
+
+ /**
+ * Test method for {@link org.apache.metron.tldextractor.BasicTldExtractor#extract2LD(java.lang.String)}.
+ */
+ @Test
+ public void testExtract2LD() {
+ String result = this.tldExtractor.extract2LD("cisco.com");
+ Assert.assertEquals(result, "cisco.com");
+ }
+
+ /**
+ * Test method for {@link org.apache.metron.tldextractor.BasicTldExtractor#extractTLD(java.lang.String)}.
+ */
+ @Test
+ public void testExtractTLD()
+ {
+ String result = this.tldExtractor.extractTLD("cisco.com");
+ Assert.assertEquals(result, ".com");
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/973b1bbc/metron-streaming/Metron-EnrichmentAdapters/src/test/java/org/apache/metron/enrichment/adapters/cif/CIFHbaseAdapterTest.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-EnrichmentAdapters/src/test/java/org/apache/metron/enrichment/adapters/cif/CIFHbaseAdapterTest.java b/metron-streaming/Metron-EnrichmentAdapters/src/test/java/org/apache/metron/enrichment/adapters/cif/CIFHbaseAdapterTest.java
index 82b4529..4a39edb 100644
--- a/metron-streaming/Metron-EnrichmentAdapters/src/test/java/org/apache/metron/enrichment/adapters/cif/CIFHbaseAdapterTest.java
+++ b/metron-streaming/Metron-EnrichmentAdapters/src/test/java/org/apache/metron/enrichment/adapters/cif/CIFHbaseAdapterTest.java
@@ -23,6 +23,7 @@ import java.util.Properties;
import org.apache.metron.test.AbstractTestContext;
import org.apache.metron.enrichment.adapters.cif.CIFHbaseAdapter;
+import org.junit.Assert;
/**
@@ -74,7 +75,7 @@ public class CIFHbaseAdapterTest extends AbstractTestContext {
super.setUp();
Properties prop = super.getTestProperties();
- assertNotNull(prop);
+ Assert.assertNotNull(prop);
if(skipTests(this.getMode())){
return;//skip tests
@@ -126,7 +127,7 @@ public class CIFHbaseAdapterTest extends AbstractTestContext {
if(skipTests(this.getMode())){
return;//skip tests
}else{
- assertTrue(cifHbaseAdapter.initializeAdapter());
+ Assert.assertTrue(cifHbaseAdapter.initializeAdapter());
}
}
@@ -137,7 +138,7 @@ public class CIFHbaseAdapterTest extends AbstractTestContext {
if(skipTests(this.getMode())){
return;//skip tests
}else{
- assertNull(cifHbaseAdapter.enrichByIP("11.1.1"));
+ Assert.assertNull(cifHbaseAdapter.enrichByIP("11.1.1"));
}
}
@@ -148,7 +149,7 @@ public class CIFHbaseAdapterTest extends AbstractTestContext {
if(skipTests(this.getMode())){
return;//skip tests
}else{
- assertNull(cifHbaseAdapter.enrichByIP("invaliddomain"));
+ Assert.assertNull(cifHbaseAdapter.enrichByIP("invaliddomain"));
}
}
@@ -159,7 +160,7 @@ public class CIFHbaseAdapterTest extends AbstractTestContext {
if(skipTests(this.getMode())){
return;//skip tests
}else{
- assertNull(cifHbaseAdapter.enrichByIP("sample@invalid.com"));
+ Assert.assertNull(cifHbaseAdapter.enrichByIP("sample@invalid.com"));
}
}
@@ -170,7 +171,7 @@ public class CIFHbaseAdapterTest extends AbstractTestContext {
if(skipTests(this.getMode())){
return;//skip tests
}else{
- assertNotNull(cifHbaseAdapter);
+ Assert.assertNotNull(cifHbaseAdapter);
}
}
@@ -182,10 +183,10 @@ public class CIFHbaseAdapterTest extends AbstractTestContext {
return;//skip tests
}else{
cifHbaseAdapter.initializeAdapter();
- assertNotNull(cifHbaseAdapter.enrich("testinvalid.metadata"));
+ Assert.assertNotNull(cifHbaseAdapter.enrich("testinvalid.metadata"));
- assertNotNull(cifHbaseAdapter.enrich("ivalid.ip"));
- assertNotNull(cifHbaseAdapter.enrich("1.1.1.10"));
+ Assert.assertNotNull(cifHbaseAdapter.enrich("ivalid.ip"));
+ Assert.assertNotNull(cifHbaseAdapter.enrich("1.1.1.10"));
}
}
@@ -198,7 +199,7 @@ public class CIFHbaseAdapterTest extends AbstractTestContext {
return;//skip tests
}else{
cifHbaseAdapter.initializeAdapter();
- assertNotNull(cifHbaseAdapter.getCIFObject("testkey"));
+ Assert.assertNotNull(cifHbaseAdapter.getCIFObject("testkey"));
}
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/973b1bbc/metron-streaming/Metron-EnrichmentAdapters/src/test/java/org/apache/metron/enrichment/adapters/geo/GeoMysqlAdapterTest.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-EnrichmentAdapters/src/test/java/org/apache/metron/enrichment/adapters/geo/GeoMysqlAdapterTest.java b/metron-streaming/Metron-EnrichmentAdapters/src/test/java/org/apache/metron/enrichment/adapters/geo/GeoMysqlAdapterTest.java
index cf5c184..a54dc6e 100644
--- a/metron-streaming/Metron-EnrichmentAdapters/src/test/java/org/apache/metron/enrichment/adapters/geo/GeoMysqlAdapterTest.java
+++ b/metron-streaming/Metron-EnrichmentAdapters/src/test/java/org/apache/metron/enrichment/adapters/geo/GeoMysqlAdapterTest.java
@@ -1,4 +1,4 @@
- /*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
@@ -22,8 +22,10 @@ import java.util.Properties;
import org.json.simple.JSONObject;
import org.apache.metron.test.AbstractSchemaTest;
+import org.junit.Assert;
- /**
+
+/**
* <ul>
* <li>Title: GeoMySqlAdapterTest</li>
* <li>Description: Tests for GeoMySqlAdapter</li>
@@ -75,7 +77,7 @@ public class GeoMysqlAdapterTest extends AbstractSchemaTest {
}else{
GeoMysqlAdapterTest.setGeoMySqlAdapter(new GeoMysqlAdapter((String)prop.get("mysql.ip"), (new Integer((String)prop.get("mysql.port"))).intValue(),(String)prop.get("mysql.username"),(String)prop.get("mysql.password"), (String)prop.get("bolt.enrichment.geo.adapter.table")));
connected =geoMySqlAdapter.initializeAdapter();
- assertTrue(connected);
+ Assert.assertTrue(connected);
URL schema_url = getClass().getClassLoader().getResource(
"TestSchemas/GeoMySqlSchema.json");
super.setSchemaJsonString(super.readSchemaFromFile(schema_url));
@@ -107,15 +109,15 @@ public class GeoMysqlAdapterTest extends AbstractSchemaTest {
System.out.println("json ="+json);
assertNotNull(json);
- assertEquals(true, super.validateJsonData(super.getSchemaJsonString(), json.toString()));
+ Assert.assertEquals(true, super.validateJsonData(super.getSchemaJsonString(), json.toString()));
//assert LocId is not null
assertNotNull(json.get("locID"));
//assert right LocId is being returned
- assertEquals("4522",json.get("locID"));
+ Assert.assertEquals("4522",json.get("locID"));
} catch (Exception e) {
e.printStackTrace();
- fail("Json validation Failed");
+ Assert.assertTrue(false);
}
}
}
@@ -128,7 +130,7 @@ public class GeoMysqlAdapterTest extends AbstractSchemaTest {
return;//skip tests
}else{
boolean connected =geoMySqlAdapter.initializeAdapter();
- assertTrue(connected);
+ Assert.assertTrue(connected);
}
}
@@ -139,7 +141,7 @@ public class GeoMysqlAdapterTest extends AbstractSchemaTest {
if(skipTests(this.getMode())){
return;//skip tests
}else{
- assertTrue(connected);
+ Assert.assertTrue(connected);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/973b1bbc/metron-streaming/Metron-EnrichmentAdapters/src/test/java/org/apache/metron/enrichment/adapters/whois/WhoisHBaseAdapterTest.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-EnrichmentAdapters/src/test/java/org/apache/metron/enrichment/adapters/whois/WhoisHBaseAdapterTest.java b/metron-streaming/Metron-EnrichmentAdapters/src/test/java/org/apache/metron/enrichment/adapters/whois/WhoisHBaseAdapterTest.java
index 4518151..1c687e2 100644
--- a/metron-streaming/Metron-EnrichmentAdapters/src/test/java/org/apache/metron/enrichment/adapters/whois/WhoisHBaseAdapterTest.java
+++ b/metron-streaming/Metron-EnrichmentAdapters/src/test/java/org/apache/metron/enrichment/adapters/whois/WhoisHBaseAdapterTest.java
@@ -24,6 +24,7 @@ import java.util.Properties;
import org.json.simple.JSONObject;
import org.apache.metron.test.AbstractTestContext;
+import org.junit.Assert;
/**
* <ul>
@@ -68,7 +69,7 @@ public class WhoisHBaseAdapterTest extends AbstractTestContext {
protected void setUp() throws Exception {
super.setUp();
Properties prop = super.getTestProperties();
- assertNotNull(prop);
+ Assert.assertNotNull(prop);
if(skipTests(this.getMode())){
return;//skip tests
@@ -99,7 +100,7 @@ public class WhoisHBaseAdapterTest extends AbstractTestContext {
}else{
whoisHbaseAdapter=new WhoisHBaseAdapter((String)prop.get("bolt.enrichment.whois.hbase.table.name"),(String)prop.get("kafka.zk.list"),(String)prop.get("kafka.zk.port"));
connected =whoisHbaseAdapter.initializeAdapter();
- assertTrue(connected);
+ Assert.assertTrue(connected);
}
}
@@ -120,7 +121,7 @@ public class WhoisHBaseAdapterTest extends AbstractTestContext {
if(skipTests(this.getMode())){
return;//skip tests
}else{
- assertTrue(connected);
+ Assert.assertTrue(connected);
}
}
@@ -134,10 +135,10 @@ public class WhoisHBaseAdapterTest extends AbstractTestContext {
JSONObject json = whoisHbaseAdapter.enrich("72.163.4.161");
//assert Geo Response is not null
- assertNotNull(json);
+ Assert.assertNotNull(json);
//assert LocId is not null
- assertNotNull(json.get("cisco.com"));
+ Assert.assertNotNull(json.get("cisco.com"));
}
}
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/973b1bbc/metron-streaming/Metron-MessageParsers/src/test/java/org/apache/metron/parsing/test/BasicFireEyeParserTest.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-MessageParsers/src/test/java/org/apache/metron/parsing/test/BasicFireEyeParserTest.java b/metron-streaming/Metron-MessageParsers/src/test/java/org/apache/metron/parsing/test/BasicFireEyeParserTest.java
index 535093b..9adf446 100644
--- a/metron-streaming/Metron-MessageParsers/src/test/java/org/apache/metron/parsing/test/BasicFireEyeParserTest.java
+++ b/metron-streaming/Metron-MessageParsers/src/test/java/org/apache/metron/parsing/test/BasicFireEyeParserTest.java
@@ -14,6 +14,7 @@ import org.json.simple.parser.ParseException;
import org.apache.metron.parsing.parsers.BasicFireEyeParser;
import org.apache.metron.test.AbstractConfigTest;
+import org.junit.Assert;
/**
* <ul>
@@ -83,7 +84,7 @@ public class BasicFireEyeParserTest extends AbstractConfigTest
public void testParse() {
for (String inputString : getInputStrings()) {
JSONObject parsed = parser.parse(inputString.getBytes());
- assertNotNull(parsed);
+ Assert.assertNotNull(parsed);
JSONParser parser = new JSONParser();
@@ -95,15 +96,15 @@ public class BasicFireEyeParserTest extends AbstractConfigTest
}
Iterator iter = json.entrySet().iterator();
- assertNotNull(json);
- assertFalse(json.isEmpty());
+ Assert.assertNotNull(json);
+ Assert.assertFalse(json.isEmpty());
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
String key = (String) entry.getKey();
String value = (String) json.get(key).toString();
- assertNotNull(value);
+ Assert.assertNotNull(value);
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/973b1bbc/metron-streaming/Metron-MessageParsers/src/test/java/org/apache/metron/parsing/test/BasicIseParserTest.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-MessageParsers/src/test/java/org/apache/metron/parsing/test/BasicIseParserTest.java b/metron-streaming/Metron-MessageParsers/src/test/java/org/apache/metron/parsing/test/BasicIseParserTest.java
index 1f34875..e8842b9 100644
--- a/metron-streaming/Metron-MessageParsers/src/test/java/org/apache/metron/parsing/test/BasicIseParserTest.java
+++ b/metron-streaming/Metron-MessageParsers/src/test/java/org/apache/metron/parsing/test/BasicIseParserTest.java
@@ -26,6 +26,7 @@ import org.json.simple.parser.ParseException;
import org.apache.metron.parsing.parsers.BasicIseParser;
import org.apache.metron.test.AbstractSchemaTest;
+import org.junit.Assert;
/**
@@ -118,7 +119,7 @@ public class BasicIseParserTest extends AbstractSchemaTest {
Map<?, ?> json=null;
try {
json = (Map<?, ?>) parser.parse(parsed.toJSONString());
- assertEquals(true, validateJsonData(super.getSchemaJsonString(), json.toString()));
+ Assert.assertEquals(true, validateJsonData(super.getSchemaJsonString(), json.toString()));
} catch (ParseException e) {
e.printStackTrace();
}
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/973b1bbc/metron-streaming/Metron-MessageParsers/src/test/java/org/apache/metron/parsing/test/BasicLancopeParserTest.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-MessageParsers/src/test/java/org/apache/metron/parsing/test/BasicLancopeParserTest.java b/metron-streaming/Metron-MessageParsers/src/test/java/org/apache/metron/parsing/test/BasicLancopeParserTest.java
index dcab342..9667699 100644
--- a/metron-streaming/Metron-MessageParsers/src/test/java/org/apache/metron/parsing/test/BasicLancopeParserTest.java
+++ b/metron-streaming/Metron-MessageParsers/src/test/java/org/apache/metron/parsing/test/BasicLancopeParserTest.java
@@ -26,8 +26,9 @@ import org.json.simple.parser.ParseException;
import org.apache.metron.parsing.parsers.BasicLancopeParser;
import org.apache.metron.test.AbstractSchemaTest;
+import org.junit.Assert;
- /**
+ /**
* <ul>
* <li>Title: Junit for LancopeParserTest</li>
* <li>Description: </li>
@@ -112,7 +113,7 @@ public class BasicLancopeParserTest extends AbstractSchemaTest {
Map<?, ?> json=null;
try {
json = (Map<?, ?>) parser.parse(parsed.toJSONString());
- assertEquals(true, validateJsonData(super.getSchemaJsonString(), json.toString()));
+ Assert.assertEquals(true, validateJsonData(super.getSchemaJsonString(), json.toString()));
} catch (ParseException e) {
e.printStackTrace();
}
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/973b1bbc/metron-streaming/Metron-MessageParsers/src/test/java/org/apache/metron/parsing/test/BasicPaloAltoFirewallParserTest.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-MessageParsers/src/test/java/org/apache/metron/parsing/test/BasicPaloAltoFirewallParserTest.java b/metron-streaming/Metron-MessageParsers/src/test/java/org/apache/metron/parsing/test/BasicPaloAltoFirewallParserTest.java
index e04e2a6..7a0b9d4 100644
--- a/metron-streaming/Metron-MessageParsers/src/test/java/org/apache/metron/parsing/test/BasicPaloAltoFirewallParserTest.java
+++ b/metron-streaming/Metron-MessageParsers/src/test/java/org/apache/metron/parsing/test/BasicPaloAltoFirewallParserTest.java
@@ -9,6 +9,7 @@ import org.json.simple.parser.ParseException;
import org.apache.metron.parsing.parsers.BasicPaloAltoFirewallParser;
import org.apache.metron.test.AbstractConfigTest;
+import org.junit.Assert;
public class BasicPaloAltoFirewallParserTest extends AbstractConfigTest {
/**
@@ -77,7 +78,7 @@ public class BasicPaloAltoFirewallParserTest extends AbstractConfigTest {
public void testParse() {
for (String inputString : getInputStrings()) {
JSONObject parsed = paParser.parse(inputString.getBytes());
- assertNotNull(parsed);
+ Assert.assertNotNull(parsed);
System.out.println(parsed);
JSONParser parser = new JSONParser();
@@ -95,7 +96,7 @@ public class BasicPaloAltoFirewallParserTest extends AbstractConfigTest {
Map.Entry entry = (Map.Entry) iter.next();
String key = (String) entry.getKey();
String value = (String) json.get(key).toString();
- assertNotNull(value);
+ Assert.assertNotNull(value);
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/973b1bbc/metron-streaming/Metron-MessageParsers/src/test/java/org/apache/metron/parsing/test/BasicSourcefireParserTest.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-MessageParsers/src/test/java/org/apache/metron/parsing/test/BasicSourcefireParserTest.java b/metron-streaming/Metron-MessageParsers/src/test/java/org/apache/metron/parsing/test/BasicSourcefireParserTest.java
index c9d1614..dd56eeb 100644
--- a/metron-streaming/Metron-MessageParsers/src/test/java/org/apache/metron/parsing/test/BasicSourcefireParserTest.java
+++ b/metron-streaming/Metron-MessageParsers/src/test/java/org/apache/metron/parsing/test/BasicSourcefireParserTest.java
@@ -14,6 +14,7 @@ import org.json.simple.parser.ParseException;
import org.apache.metron.parsing.parsers.BasicSourcefireParser;
import org.apache.metron.test.AbstractConfigTest;
+import org.junit.Assert;
/**
* <ul>
@@ -84,7 +85,7 @@ public class BasicSourcefireParserTest extends AbstractConfigTest
for (String sourceFireString : getSourceFireStrings()) {
byte[] srcBytes = sourceFireString.getBytes();
JSONObject parsed = sourceFireParser.parse(sourceFireString.getBytes());
- assertNotNull(parsed);
+ Assert.assertNotNull(parsed);
System.out.println(parsed);
JSONParser parser = new JSONParser();
@@ -102,7 +103,7 @@ public class BasicSourcefireParserTest extends AbstractConfigTest
Map.Entry entry = (Map.Entry) iter.next();
String key = (String) entry.getKey();
String value = (String) json.get("original_string").toString();
- assertNotNull(value);
+ Assert.assertNotNull(value);
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/973b1bbc/metron-streaming/Metron-MessageParsers/src/test/java/org/apache/metron/parsing/test/BroParserTest.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-MessageParsers/src/test/java/org/apache/metron/parsing/test/BroParserTest.java b/metron-streaming/Metron-MessageParsers/src/test/java/org/apache/metron/parsing/test/BroParserTest.java
index a99f705..01a1210 100644
--- a/metron-streaming/Metron-MessageParsers/src/test/java/org/apache/metron/parsing/test/BroParserTest.java
+++ b/metron-streaming/Metron-MessageParsers/src/test/java/org/apache/metron/parsing/test/BroParserTest.java
@@ -13,6 +13,7 @@ import org.json.simple.parser.ParseException;
import org.apache.metron.parsing.parsers.BasicBroParser;
import org.apache.metron.test.AbstractConfigTest;
+import org.junit.Assert;
/**
* <ul>
@@ -85,7 +86,7 @@ public class BroParserTest extends AbstractConfigTest {
for (String inputString : getInputStrings()) {
JSONObject cleanJson = parser.parse(inputString.getBytes());
- assertNotNull(cleanJson);
+ Assert.assertNotNull(cleanJson);
System.out.println(cleanJson);
Pattern p = Pattern.compile("[^\\._a-z0-9 ]",
@@ -104,7 +105,7 @@ public class BroParserTest extends AbstractConfigTest {
Matcher m = p.matcher(key);
boolean b = m.find();
// Test False
- assertFalse(b);
+ Assert.assertFalse(b);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/973b1bbc/metron-streaming/Metron-MessageParsers/src/test/java/org/apache/metron/parsing/test/GrokAsaParserTest.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-MessageParsers/src/test/java/org/apache/metron/parsing/test/GrokAsaParserTest.java b/metron-streaming/Metron-MessageParsers/src/test/java/org/apache/metron/parsing/test/GrokAsaParserTest.java
index 72bb819..86f23bd 100644
--- a/metron-streaming/Metron-MessageParsers/src/test/java/org/apache/metron/parsing/test/GrokAsaParserTest.java
+++ b/metron-streaming/Metron-MessageParsers/src/test/java/org/apache/metron/parsing/test/GrokAsaParserTest.java
@@ -9,9 +9,10 @@ import org.json.simple.parser.ParseException;
import org.apache.metron.parsing.parsers.GrokAsaParser;
import org.apache.metron.test.AbstractConfigTest;
+import org.junit.Assert;
- /**
+/**
* <ul>
* <li>Title: </li>
* <li>Description: </li>
@@ -81,7 +82,7 @@ public class GrokAsaParserTest extends AbstractConfigTest{
for (String grokAsaString : getGrokAsaStrings()) {
JSONObject parsed = grokAsaParser.parse(grokAsaString.getBytes());
- assertNotNull(parsed);
+ Assert.assertNotNull(parsed);
System.out.println(parsed);
JSONParser parser = new JSONParser();
@@ -93,20 +94,20 @@ public class GrokAsaParserTest extends AbstractConfigTest{
e.printStackTrace();
}
//Ensure JSON returned is not null/empty
- assertNotNull(json);
+ Assert.assertNotNull(json);
Iterator iter = json.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
- assertNotNull(entry);
+ Assert.assertNotNull(entry);
String key = (String) entry.getKey();
- assertNotNull(key);
+ Assert.assertNotNull(key);
String value = (String) json.get("CISCO_TAGGED_SYSLOG").toString();
- assertNotNull(value);
+ Assert.assertNotNull(value);
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/973b1bbc/metron-streaming/pom.xml
----------------------------------------------------------------------
diff --git a/metron-streaming/pom.xml b/metron-streaming/pom.xml
index d04862d..84b29f3 100644
--- a/metron-streaming/pom.xml
+++ b/metron-streaming/pom.xml
@@ -10,7 +10,7 @@
the specific language governing permissions and limitations under the License. -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.metron</groupId>
<artifactId>Metron-Streaming</artifactId>
@@ -71,11 +71,13 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
+ <scope>test</scope>
</dependency>
</dependencies>
- <build>
+ <build>
</build>
+
<reporting>
<plugins>
<plugin>