metron-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject [01/25] metron git commit: METRON-877 Extract core implementation and UDF support, create metron-stellar module (mattf-horton) closes apache/metron#616
Date Sun, 02 Jul 2017 22:43:27 GMT
Repository: metron
Updated Branches:
  refs/heads/master df94ed405 -> a5b13777a


http://git-wip-us.apache.org/repos/asf/metron/blob/a5b13777/metron-stellar/stellar-common/src/test/java/org/apache/metron/stellar/dsl/functions/resolver/SimpleFunctionResolverTest.java
----------------------------------------------------------------------
diff --git a/metron-stellar/stellar-common/src/test/java/org/apache/metron/stellar/dsl/functions/resolver/SimpleFunctionResolverTest.java
b/metron-stellar/stellar-common/src/test/java/org/apache/metron/stellar/dsl/functions/resolver/SimpleFunctionResolverTest.java
new file mode 100644
index 0000000..a4c3b2d
--- /dev/null
+++ b/metron-stellar/stellar-common/src/test/java/org/apache/metron/stellar/dsl/functions/resolver/SimpleFunctionResolverTest.java
@@ -0,0 +1,122 @@
+/**
+ * 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.stellar.dsl.functions.resolver;
+
+import com.google.common.collect.Lists;
+import org.apache.metron.stellar.dsl.BaseStellarFunction;
+import org.apache.metron.stellar.dsl.Context;
+import org.apache.metron.stellar.dsl.ParseException;
+import org.apache.metron.stellar.dsl.Stellar;
+import org.apache.metron.stellar.dsl.StellarFunction;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.List;
+
+/**
+ * Tests the SimpleFunctionResolver class.
+ */
+public class SimpleFunctionResolverTest {
+
+  private SimpleFunctionResolver resolver;
+
+  @Before
+  public void setup() {
+    resolver = new SimpleFunctionResolver();
+  }
+
+  @Test
+  public void testFunctionResolution() {
+    resolver.withClass(IAmAFunction.class);
+    List<String> functions = Lists.newArrayList(resolver.getFunctions());
+    Assert.assertEquals(1, functions.size());
+    Assert.assertTrue(functions.contains("namespace_function"));
+  }
+
+  /**
+   * The function resolver should be able to instantiate an instance of the function's implementation.
+   */
+  @Test
+  public void testApply() {
+    resolver.withClass(IAmAFunction.class);
+    final String functionName = "namespace_function";
+    StellarFunction fn = resolver.apply(functionName);
+    Assert.assertTrue(fn instanceof IAmAFunction);
+  }
+
+  /**
+   * All Stellar functions must be annotated.
+   */
+  @Test
+  public void testFunctionResolutionWithMissingAnnotation() {
+    resolver.withClass(MissingAnnotation.class);
+    List<String> functions = Lists.newArrayList(resolver.getFunctions());
+    Assert.assertEquals(0, functions.size());
+  }
+
+  /**
+   * If the resolver comes across the same function definition twice, nothing bad should
happen.
+   */
+  @Test
+  public void testIgnoreDuplicates() {
+    resolver.withClass(IAmAFunction.class);
+    resolver.withClass(IAmAFunction.class);
+    List<String> functions = Lists.newArrayList(resolver.getFunctions());
+    Assert.assertEquals(1, functions.size());
+  }
+
+  /**
+   * I am the real deal.  I am a Stellar function.
+   */
+  @Stellar(namespace="namespace", name="function", description="description", returns="returns",
params={"param1"})
+  private static class IAmAFunction extends BaseStellarFunction {
+
+    public IAmAFunction() {
+    }
+
+    @Override
+    public Object apply(List<Object> args) {
+      return null;
+    }
+  }
+
+  /**
+   * This is not a Stellar function.  It implements StellarFunction, but is not annotated.
+   */
+  private static class MissingAnnotation implements StellarFunction {
+
+    public MissingAnnotation() {
+    }
+
+    @Override
+    public Object apply(List<Object> args, Context context) throws ParseException {
+      return null;
+    }
+
+    @Override
+    public void initialize(Context context) {
+    }
+
+    @Override
+    public boolean isInitialized() {
+      return false;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/metron/blob/a5b13777/metron-stellar/stellar-common/src/test/resources/config/global.json
----------------------------------------------------------------------
diff --git a/metron-stellar/stellar-common/src/test/resources/config/global.json b/metron-stellar/stellar-common/src/test/resources/config/global.json
new file mode 100644
index 0000000..44ce6b1
--- /dev/null
+++ b/metron-stellar/stellar-common/src/test/resources/config/global.json
@@ -0,0 +1,3 @@
+{
+  "configuration.class.test.property": "Configuration"
+}

http://git-wip-us.apache.org/repos/asf/metron/blob/a5b13777/metron-stellar/stellar-common/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/metron-stellar/stellar-common/src/test/resources/log4j.properties b/metron-stellar/stellar-common/src/test/resources/log4j.properties
new file mode 100644
index 0000000..0d50388
--- /dev/null
+++ b/metron-stellar/stellar-common/src/test/resources/log4j.properties
@@ -0,0 +1,24 @@
+#  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.
+
+# Root logger option
+log4j.rootLogger=ERROR, stdout
+
+# Direct log messages to stdout
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n

http://git-wip-us.apache.org/repos/asf/metron/blob/a5b13777/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index af97e83..1b5f89f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,12 +29,13 @@
         <url>https://www.apache.org</url>
     </organization>
     <modules>
-            <module>metron-analytics</module>
-            <module>metron-platform</module>
-            <module>metron-deployment</module>
-            <module>metron-docker</module>
-            <module>metron-interface</module>
-            <module>site-book</module>
+        <module>metron-analytics</module>
+        <module>metron-platform</module>
+        <module>metron-deployment</module>
+        <module>metron-docker</module>
+        <module>metron-interface</module>
+        <module>site-book</module>
+        <module>metron-stellar</module>
     </modules>
 
     <repositories>
@@ -108,6 +109,8 @@
         <global_jar_version>3.0.2</global_jar_version>
         <global_surefire_version>2.18</global_surefire_version>
         <global_maven_version>[3.3.1,)</global_maven_version>
+        <global_kryo_version>3.0.3</global_kryo_version>
+        <global_kryo_serializers_version>0.38</global_kryo_serializers_version>
         <argLine></argLine>
     </properties>
 

http://git-wip-us.apache.org/repos/asf/metron/blob/a5b13777/site-book/pom.xml
----------------------------------------------------------------------
diff --git a/site-book/pom.xml b/site-book/pom.xml
index a6e4873..37a8672 100644
--- a/site-book/pom.xml
+++ b/site-book/pom.xml
@@ -52,8 +52,9 @@
 	<build>
 	  <plugins>
           <plugin>
-              <artifactId>exec-maven-plugin</artifactId>
               <groupId>org.codehaus.mojo</groupId>
+              <artifactId>exec-maven-plugin</artifactId>
+              <version>1.5.0</version>
               <executions>
                   <execution>
                       <id>Generate MD</id>


Mime
View raw message