You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2021/02/22 21:54:08 UTC

[GitHub] [nifi] mattyb149 commented on a change in pull request #4577: NIFI-6752 Create ASN.1 RecordReader

mattyb149 commented on a change in pull request #4577:
URL: https://github.com/apache/nifi/pull/4577#discussion_r580617836



##########
File path: nifi-assembly/pom.xml
##########
@@ -1347,6 +1347,20 @@ language governing permissions and limitations under the License. -->
                 </dependency>
             </dependencies>
         </profile>
+        <profile>
+            <id>include-asn1</id>
+            <activation>
+                <activeByDefault>false</activeByDefault>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>org.apache.nifi</groupId>
+                    <artifactId>nifi-asn1-nar</artifactId>
+                    <version>1.13.0-SNAPSHOT</version>

Review comment:
       This should be `1.14.0-SNAPSHOT`

##########
File path: nifi-nar-bundles/nifi-asn1-bundle/nifi-asn1-services/src/test/java/org/apache/nifi/jasn1/ExampleDataGenerator.java
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.nifi.jasn1;
+
+import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
+import com.beanit.asn1bean.ber.types.BerBoolean;
+import com.beanit.asn1bean.ber.types.BerInteger;
+import com.beanit.asn1bean.ber.types.BerOctetString;
+import com.beanit.asn1bean.ber.types.string.BerUTF8String;
+import org.apache.nifi.jasn1.example.BasicTypeSet;
+import org.apache.nifi.jasn1.example.BasicTypes;
+import org.apache.nifi.jasn1.example.Composite;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+
+/**
+ * Depends on generated test classes
+ */
+public class ExampleDataGenerator {
+
+    private static final Logger LOG = LoggerFactory.getLogger(ExampleDataGenerator.class);
+
+    public static void main(String[] args) throws Exception {
+
+        final File asnFile = new File(ExampleDataGenerator.class.getResource("/example.asn").getFile());
+        final File dir = new File(asnFile.getParentFile().getParentFile().getParentFile(), "src/test/resources/examples");
+
+        generateBasicTypes(dir);
+
+        generateComposite(dir);
+    }
+
+    private static void generateBasicTypes(File dir) throws IOException {
+        final File file = new File(dir, "basic-types.dat");
+        try (final ReverseByteArrayOutputStream rev = new ReverseByteArrayOutputStream(1024);
+             final OutputStream out = new FileOutputStream(file)) {
+            final BasicTypes basicTypes = new BasicTypes();
+            basicTypes.setB(new BerBoolean(true));
+            basicTypes.setI(new BerInteger(789));
+            basicTypes.setOctStr(new BerOctetString(new byte[]{1, 2, 3, 4, 5}));
+            basicTypes.setUtf8Str(new BerUTF8String("Some UTF-8 String. こんにちは世界。"));
+            final int encoded = basicTypes.encode(rev);
+            out.write(rev.getArray(), 0, encoded);
+            LOG.info("Generated {} bytes to {}", encoded, file);
+        }
+    }
+
+    private static void generateComposite(File dir) throws IOException {
+        final File file = new File(dir, "composite.dat");

Review comment:
       When I run the new template, I get `null` for all values in the record(s), is something mis-configured? The checksum of the file in `examples` is the same as those generated by this test, and the unit tests run fine.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org