You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by kd...@apache.org on 2018/09/22 02:11:28 UTC

[29/51] [partial] nifi-registry git commit: NIFIREG-201 Refactoring project structure to better isolate extensions

http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/6f26290d/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/event/TestEventFactory.java
----------------------------------------------------------------------
diff --git a/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/event/TestEventFactory.java b/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/event/TestEventFactory.java
new file mode 100644
index 0000000..a9ad911
--- /dev/null
+++ b/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/event/TestEventFactory.java
@@ -0,0 +1,169 @@
+/*
+ * 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.registry.event;
+
+import org.apache.nifi.registry.bucket.Bucket;
+import org.apache.nifi.registry.flow.VersionedFlow;
+import org.apache.nifi.registry.flow.VersionedFlowSnapshot;
+import org.apache.nifi.registry.flow.VersionedFlowSnapshotMetadata;
+import org.apache.nifi.registry.flow.VersionedProcessGroup;
+import org.apache.nifi.registry.hook.Event;
+import org.apache.nifi.registry.hook.EventFieldName;
+import org.apache.nifi.registry.hook.EventType;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.UUID;
+
+import static org.junit.Assert.assertEquals;
+
+public class TestEventFactory {
+
+    private Bucket bucket;
+    private VersionedFlow versionedFlow;
+    private VersionedFlowSnapshot versionedFlowSnapshot;
+
+    @Before
+    public void setup() {
+        bucket = new Bucket();
+        bucket.setName("Bucket1");
+        bucket.setIdentifier(UUID.randomUUID().toString());
+        bucket.setCreatedTimestamp(System.currentTimeMillis());
+
+        versionedFlow = new VersionedFlow();
+        versionedFlow.setIdentifier(UUID.randomUUID().toString());
+        versionedFlow.setName("Flow 1");
+        versionedFlow.setBucketIdentifier(bucket.getIdentifier());
+        versionedFlow.setBucketName(bucket.getName());
+
+        VersionedFlowSnapshotMetadata metadata = new VersionedFlowSnapshotMetadata();
+        metadata.setAuthor("user1");
+        metadata.setComments("This is flow 1");
+        metadata.setVersion(1);
+        metadata.setBucketIdentifier(bucket.getIdentifier());
+        metadata.setFlowIdentifier(versionedFlow.getIdentifier());
+
+        versionedFlowSnapshot = new VersionedFlowSnapshot();
+        versionedFlowSnapshot.setSnapshotMetadata(metadata);
+        versionedFlowSnapshot.setFlowContents(new VersionedProcessGroup());
+    }
+
+    @Test
+    public void testBucketCreatedEvent() {
+        final Event event = EventFactory.bucketCreated(bucket);
+        event.validate();
+
+        assertEquals(EventType.CREATE_BUCKET, event.getEventType());
+        assertEquals(2, event.getFields().size());
+
+        assertEquals(bucket.getIdentifier(), event.getField(EventFieldName.BUCKET_ID).getValue());
+        assertEquals("unknown", event.getField(EventFieldName.USER).getValue());
+    }
+
+    @Test
+    public void testBucketUpdatedEvent() {
+        final Event event = EventFactory.bucketUpdated(bucket);
+        event.validate();
+
+        assertEquals(EventType.UPDATE_BUCKET, event.getEventType());
+        assertEquals(2, event.getFields().size());
+
+        assertEquals(bucket.getIdentifier(), event.getField(EventFieldName.BUCKET_ID).getValue());
+        assertEquals("unknown", event.getField(EventFieldName.USER).getValue());
+    }
+
+    @Test
+    public void testBucketDeletedEvent() {
+        final Event event = EventFactory.bucketDeleted(bucket);
+        event.validate();
+
+        assertEquals(EventType.DELETE_BUCKET, event.getEventType());
+        assertEquals(2, event.getFields().size());
+
+        assertEquals(bucket.getIdentifier(), event.getField(EventFieldName.BUCKET_ID).getValue());
+        assertEquals("unknown", event.getField(EventFieldName.USER).getValue());
+    }
+
+    @Test
+    public void testFlowCreated() {
+        final Event event = EventFactory.flowCreated(versionedFlow);
+        event.validate();
+
+        assertEquals(EventType.CREATE_FLOW, event.getEventType());
+        assertEquals(3, event.getFields().size());
+
+        assertEquals(bucket.getIdentifier(), event.getField(EventFieldName.BUCKET_ID).getValue());
+        assertEquals(versionedFlow.getIdentifier(), event.getField(EventFieldName.FLOW_ID).getValue());
+        assertEquals("unknown", event.getField(EventFieldName.USER).getValue());
+    }
+
+    @Test
+    public void testFlowUpdated() {
+        final Event event = EventFactory.flowUpdated(versionedFlow);
+        event.validate();
+
+        assertEquals(EventType.UPDATE_FLOW, event.getEventType());
+        assertEquals(3, event.getFields().size());
+
+        assertEquals(bucket.getIdentifier(), event.getField(EventFieldName.BUCKET_ID).getValue());
+        assertEquals(versionedFlow.getIdentifier(), event.getField(EventFieldName.FLOW_ID).getValue());
+        assertEquals("unknown", event.getField(EventFieldName.USER).getValue());
+    }
+
+    @Test
+    public void testFlowDeleted() {
+        final Event event = EventFactory.flowDeleted(versionedFlow);
+        event.validate();
+
+        assertEquals(EventType.DELETE_FLOW, event.getEventType());
+        assertEquals(3, event.getFields().size());
+
+        assertEquals(bucket.getIdentifier(), event.getField(EventFieldName.BUCKET_ID).getValue());
+        assertEquals(versionedFlow.getIdentifier(), event.getField(EventFieldName.FLOW_ID).getValue());
+        assertEquals("unknown", event.getField(EventFieldName.USER).getValue());
+    }
+
+    @Test
+    public void testFlowVersionedCreated() {
+        final Event event = EventFactory.flowVersionCreated(versionedFlowSnapshot);
+        event.validate();
+
+        assertEquals(EventType.CREATE_FLOW_VERSION, event.getEventType());
+        assertEquals(5, event.getFields().size());
+
+        assertEquals(bucket.getIdentifier(), event.getField(EventFieldName.BUCKET_ID).getValue());
+        assertEquals(versionedFlow.getIdentifier(), event.getField(EventFieldName.FLOW_ID).getValue());
+
+        assertEquals(String.valueOf(versionedFlowSnapshot.getSnapshotMetadata().getVersion()),
+                event.getField(EventFieldName.VERSION).getValue());
+
+        assertEquals(versionedFlowSnapshot.getSnapshotMetadata().getAuthor(),
+                event.getField(EventFieldName.USER).getValue());
+
+        assertEquals(versionedFlowSnapshot.getSnapshotMetadata().getComments(),
+                event.getField(EventFieldName.COMMENT).getValue());
+    }
+
+    @Test
+    public void testFlowVersionedCreatedWhenCommentsMissing() {
+        versionedFlowSnapshot.getSnapshotMetadata().setComments(null);
+        final Event event = EventFactory.flowVersionCreated(versionedFlowSnapshot);
+        event.validate();
+        assertEquals("", event.getField(EventFieldName.COMMENT).getValue());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/6f26290d/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/event/TestEventService.java
----------------------------------------------------------------------
diff --git a/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/event/TestEventService.java b/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/event/TestEventService.java
new file mode 100644
index 0000000..0270dd8
--- /dev/null
+++ b/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/event/TestEventService.java
@@ -0,0 +1,97 @@
+/*
+ * 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.registry.event;
+
+import org.apache.nifi.registry.bucket.Bucket;
+import org.apache.nifi.registry.hook.Event;
+import org.apache.nifi.registry.hook.EventHookException;
+import org.apache.nifi.registry.hook.EventHookProvider;
+import org.apache.nifi.registry.provider.ProviderConfigurationContext;
+import org.apache.nifi.registry.provider.ProviderCreationException;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.UUID;
+
+public class TestEventService {
+
+    private CapturingEventHook eventHook;
+    private EventService eventService;
+
+    @Before
+    public void setup() {
+        eventHook = new CapturingEventHook();
+        eventService = new EventService(Collections.singletonList(eventHook));
+        eventService.postConstruct();
+    }
+
+    @After
+    public void teardown() throws Exception {
+        eventService.destroy();
+    }
+
+    @Test
+    public void testPublishConsume() throws InterruptedException {
+        final Bucket bucket = new Bucket();
+        bucket.setIdentifier(UUID.randomUUID().toString());
+
+        final Event bucketCreatedEvent = EventFactory.bucketCreated(bucket);
+        eventService.publish(bucketCreatedEvent);
+
+        final Event bucketDeletedEvent = EventFactory.bucketDeleted(bucket);
+        eventService.publish(bucketDeletedEvent);
+
+        Thread.sleep(1000);
+
+        final List<Event> events = eventHook.getEvents();
+        Assert.assertEquals(2, events.size());
+
+        final Event firstEvent = events.get(0);
+        Assert.assertEquals(bucketCreatedEvent.getEventType(), firstEvent.getEventType());
+
+        final Event secondEvent = events.get(1);
+        Assert.assertEquals(bucketDeletedEvent.getEventType(), secondEvent.getEventType());
+    }
+
+    /**
+     * Simple implementation of EventHookProvider that captures event for later verification.
+     */
+    private class CapturingEventHook implements EventHookProvider {
+
+        private List<Event> events = new ArrayList<>();
+
+        @Override
+        public void onConfigured(ProviderConfigurationContext configurationContext) throws ProviderCreationException {
+
+        }
+
+        @Override
+        public void handle(Event event) throws EventHookException {
+            events.add(event);
+        }
+
+        public List<Event> getEvents() {
+            return events;
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/6f26290d/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/event/TestStandardEvent.java
----------------------------------------------------------------------
diff --git a/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/event/TestStandardEvent.java b/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/event/TestStandardEvent.java
new file mode 100644
index 0000000..8e9f73f
--- /dev/null
+++ b/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/event/TestStandardEvent.java
@@ -0,0 +1,47 @@
+/*
+ * 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.registry.event;
+
+import org.apache.nifi.registry.hook.Event;
+import org.apache.nifi.registry.hook.EventField;
+import org.apache.nifi.registry.hook.EventFieldName;
+import org.apache.nifi.registry.hook.EventType;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestStandardEvent {
+
+    @Test(expected = IllegalStateException.class)
+    public void testInvalidEvent() {
+        final Event event = new StandardEvent.Builder()
+                .eventType(EventType.CREATE_BUCKET)
+                .build();
+
+        event.validate();
+    }
+
+    @Test
+    public void testGetFieldWhenDoesNotExist() {
+        final Event event = new StandardEvent.Builder()
+                .eventType(EventType.CREATE_BUCKET)
+                .build();
+
+        final EventField field = event.getField(EventFieldName.BUCKET_ID);
+        Assert.assertNull(field);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/6f26290d/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/MockFlowPersistenceProvider.java
----------------------------------------------------------------------
diff --git a/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/MockFlowPersistenceProvider.java b/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/MockFlowPersistenceProvider.java
new file mode 100644
index 0000000..430f3a3
--- /dev/null
+++ b/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/MockFlowPersistenceProvider.java
@@ -0,0 +1,57 @@
+/*
+ * 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.registry.provider;
+
+import org.apache.nifi.registry.flow.FlowPersistenceProvider;
+import org.apache.nifi.registry.flow.FlowSnapshotContext;
+import org.apache.nifi.registry.flow.FlowPersistenceException;
+
+import java.util.Map;
+
+public class MockFlowPersistenceProvider implements FlowPersistenceProvider {
+
+    private Map<String,String> properties;
+
+    @Override
+    public void onConfigured(ProviderConfigurationContext configurationContext) throws ProviderCreationException {
+        properties = configurationContext.getProperties();
+    }
+
+    @Override
+    public void saveFlowContent(FlowSnapshotContext context, byte[] content) throws FlowPersistenceException {
+
+    }
+
+    @Override
+    public byte[] getFlowContent(String bucketId, String flowId, int version) throws FlowPersistenceException {
+        return new byte[0];
+    }
+
+    @Override
+    public void deleteAllFlowContent(String bucketId, String flowId) throws FlowPersistenceException {
+
+    }
+
+    @Override
+    public void deleteFlowContent(String bucketId, String flowId, int version) throws FlowPersistenceException {
+
+    }
+
+    public Map<String,String> getProperties() {
+        return properties;
+    }
+}

http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/6f26290d/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/TestStandardProviderFactory.java
----------------------------------------------------------------------
diff --git a/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/TestStandardProviderFactory.java b/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/TestStandardProviderFactory.java
new file mode 100644
index 0000000..30f66ef
--- /dev/null
+++ b/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/TestStandardProviderFactory.java
@@ -0,0 +1,90 @@
+/*
+ * 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.registry.provider;
+
+import org.apache.nifi.registry.extension.ExtensionManager;
+import org.apache.nifi.registry.flow.FlowPersistenceProvider;
+import org.apache.nifi.registry.properties.NiFiRegistryProperties;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.when;
+
+public class TestStandardProviderFactory {
+
+    @Test
+    public void testGetProvidersSuccess() {
+        final NiFiRegistryProperties props = new NiFiRegistryProperties();
+        props.setProperty(NiFiRegistryProperties.PROVIDERS_CONFIGURATION_FILE, "src/test/resources/provider/providers-good.xml");
+
+        final ExtensionManager extensionManager = Mockito.mock(ExtensionManager.class);
+        when(extensionManager.getExtensionClassLoader(any(String.class))).thenReturn(this.getClass().getClassLoader());
+
+        final ProviderFactory providerFactory = new StandardProviderFactory(props, extensionManager);
+        providerFactory.initialize();
+
+        final FlowPersistenceProvider flowPersistenceProvider = providerFactory.getFlowPersistenceProvider();
+        assertNotNull(flowPersistenceProvider);
+
+        final MockFlowPersistenceProvider mockFlowProvider = (MockFlowPersistenceProvider) flowPersistenceProvider;
+        assertNotNull(mockFlowProvider.getProperties());
+        assertEquals("flow foo", mockFlowProvider.getProperties().get("Flow Property 1"));
+        assertEquals("flow bar", mockFlowProvider.getProperties().get("Flow Property 2"));
+    }
+
+    @Test(expected = ProviderFactoryException.class)
+    public void testGetFlowProviderBeforeInitializingShouldThrowException() {
+        final NiFiRegistryProperties props = new NiFiRegistryProperties();
+        props.setProperty(NiFiRegistryProperties.PROVIDERS_CONFIGURATION_FILE, "src/test/resources/provider/providers-good.xml");
+
+        final ExtensionManager extensionManager = Mockito.mock(ExtensionManager.class);
+        when(extensionManager.getExtensionClassLoader(any(String.class))).thenReturn(this.getClass().getClassLoader());
+
+        final ProviderFactory providerFactory = new StandardProviderFactory(props, extensionManager);
+        providerFactory.getFlowPersistenceProvider();
+    }
+
+    @Test(expected = ProviderFactoryException.class)
+    public void testProvidersConfigDoesNotExist() {
+        final NiFiRegistryProperties props = new NiFiRegistryProperties();
+        props.setProperty(NiFiRegistryProperties.PROVIDERS_CONFIGURATION_FILE, "src/test/resources/provider/providers-does-not-exist.xml");
+
+        final ExtensionManager extensionManager = Mockito.mock(ExtensionManager.class);
+        when(extensionManager.getExtensionClassLoader(any(String.class))).thenReturn(this.getClass().getClassLoader());
+
+        final ProviderFactory providerFactory = new StandardProviderFactory(props, extensionManager);
+        providerFactory.initialize();
+    }
+
+    @Test(expected = ProviderFactoryException.class)
+    public void testFlowProviderClassNotFound() {
+        final NiFiRegistryProperties props = new NiFiRegistryProperties();
+        props.setProperty(NiFiRegistryProperties.PROVIDERS_CONFIGURATION_FILE, "src/test/resources/provider/providers-class-not-found.xml");
+
+        final ExtensionManager extensionManager = Mockito.mock(ExtensionManager.class);
+        when(extensionManager.getExtensionClassLoader(any(String.class))).thenReturn(this.getClass().getClassLoader());
+
+        final ProviderFactory providerFactory = new StandardProviderFactory(props, extensionManager);
+        providerFactory.initialize();
+
+        providerFactory.getFlowPersistenceProvider();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/6f26290d/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/flow/TestFileSystemFlowPersistenceProvider.java
----------------------------------------------------------------------
diff --git a/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/flow/TestFileSystemFlowPersistenceProvider.java b/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/flow/TestFileSystemFlowPersistenceProvider.java
new file mode 100644
index 0000000..14a4861
--- /dev/null
+++ b/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/flow/TestFileSystemFlowPersistenceProvider.java
@@ -0,0 +1,204 @@
+/*
+ * 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.registry.provider.flow;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.nifi.registry.flow.FlowPersistenceProvider;
+import org.apache.nifi.registry.flow.FlowSnapshotContext;
+import org.apache.nifi.registry.provider.ProviderConfigurationContext;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.mockito.Mockito.when;
+
+public class TestFileSystemFlowPersistenceProvider {
+
+    static final String FLOW_STORAGE_DIR = "target/flow_storage";
+
+    static final ProviderConfigurationContext CONFIGURATION_CONTEXT = new ProviderConfigurationContext() {
+        @Override
+        public Map<String, String> getProperties() {
+            final Map<String,String> props = new HashMap<>();
+            props.put(FileSystemFlowPersistenceProvider.FLOW_STORAGE_DIR_PROP, FLOW_STORAGE_DIR);
+            return props;
+        }
+    };
+
+    private File flowStorageDir;
+    private FileSystemFlowPersistenceProvider fileSystemFlowProvider;
+
+    @Before
+    public void setup() throws IOException {
+        flowStorageDir = new File(FLOW_STORAGE_DIR);
+        if (flowStorageDir.exists()) {
+            org.apache.commons.io.FileUtils.cleanDirectory(flowStorageDir);
+            flowStorageDir.delete();
+        }
+
+        Assert.assertFalse(flowStorageDir.exists());
+
+        fileSystemFlowProvider = new FileSystemFlowPersistenceProvider();
+        fileSystemFlowProvider.onConfigured(CONFIGURATION_CONTEXT);
+        Assert.assertTrue(flowStorageDir.exists());
+    }
+
+    @Test
+    public void testSaveSuccessfully() throws IOException {
+        createAndSaveSnapshot(fileSystemFlowProvider,"bucket1", "flow1", 1, "flow1v1");
+        verifySnapshot(flowStorageDir, "bucket1", "flow1", 1, "flow1v1");
+
+        createAndSaveSnapshot(fileSystemFlowProvider,"bucket1", "flow1", 2, "flow1v2");
+        verifySnapshot(flowStorageDir, "bucket1", "flow1", 2, "flow1v2");
+
+        createAndSaveSnapshot(fileSystemFlowProvider,"bucket1", "flow2", 1, "flow2v1");
+        verifySnapshot(flowStorageDir, "bucket1", "flow2", 1, "flow2v1");
+
+        createAndSaveSnapshot(fileSystemFlowProvider,"bucket2", "flow3", 1, "flow3v1");
+        verifySnapshot(flowStorageDir, "bucket2", "flow3", 1, "flow3v1");
+    }
+
+    @Test
+    public void testSaveWithExistingVersion() throws IOException {
+        final FlowSnapshotContext context = Mockito.mock(FlowSnapshotContext.class);
+        when(context.getBucketId()).thenReturn("bucket1");
+        when(context.getFlowId()).thenReturn("flow1");
+        when(context.getVersion()).thenReturn(1);
+
+        final byte[] content = "flow1v1".getBytes(StandardCharsets.UTF_8);
+        fileSystemFlowProvider.saveFlowContent(context, content);
+
+        // save new content for an existing version
+        final byte[] content2 = "XXX".getBytes(StandardCharsets.UTF_8);
+        try {
+            fileSystemFlowProvider.saveFlowContent(context, content2);
+            Assert.fail("Should have thrown exception");
+        } catch (Exception e) {
+
+        }
+
+        // verify the new content wasn't written
+        final File flowSnapshotFile = new File(flowStorageDir, "bucket1/flow1/1/1" + FileSystemFlowPersistenceProvider.SNAPSHOT_EXTENSION);
+        try (InputStream in = new FileInputStream(flowSnapshotFile)) {
+            Assert.assertEquals("flow1v1", IOUtils.toString(in, StandardCharsets.UTF_8));
+        }
+    }
+
+    @Test
+    public void testSaveAndGet() throws IOException {
+        createAndSaveSnapshot(fileSystemFlowProvider,"bucket1", "flow1", 1, "flow1v1");
+        createAndSaveSnapshot(fileSystemFlowProvider,"bucket1", "flow1", 2, "flow1v2");
+
+        final byte[] flow1v1 = fileSystemFlowProvider.getFlowContent("bucket1", "flow1", 1);
+        Assert.assertEquals("flow1v1", new String(flow1v1, StandardCharsets.UTF_8));
+
+        final byte[] flow1v2 = fileSystemFlowProvider.getFlowContent("bucket1", "flow1", 2);
+        Assert.assertEquals("flow1v2", new String(flow1v2, StandardCharsets.UTF_8));
+    }
+
+    @Test
+    public void testGetWhenDoesNotExist() {
+        final byte[] flow1v1 = fileSystemFlowProvider.getFlowContent("bucket1", "flow1", 1);
+        Assert.assertNull(flow1v1);
+    }
+
+    @Test
+    public void testDeleteSnapshots() throws IOException {
+        final String bucketId = "bucket1";
+        final String flowId = "flow1";
+
+        createAndSaveSnapshot(fileSystemFlowProvider, bucketId, flowId, 1, "flow1v1");
+        createAndSaveSnapshot(fileSystemFlowProvider, bucketId, flowId, 2, "flow1v2");
+
+        Assert.assertNotNull(fileSystemFlowProvider.getFlowContent(bucketId, flowId, 1));
+        Assert.assertNotNull(fileSystemFlowProvider.getFlowContent(bucketId, flowId, 2));
+
+        fileSystemFlowProvider.deleteAllFlowContent(bucketId, flowId);
+
+        Assert.assertNull(fileSystemFlowProvider.getFlowContent(bucketId, flowId, 1));
+        Assert.assertNull(fileSystemFlowProvider.getFlowContent(bucketId, flowId, 2));
+
+        // delete a flow that doesn't exist
+        fileSystemFlowProvider.deleteAllFlowContent(bucketId, "some-other-flow");
+
+        // delete a bucket that doesn't exist
+        fileSystemFlowProvider.deleteAllFlowContent("some-other-bucket", flowId);
+    }
+
+    @Test
+    public void testDeleteSnapshot() throws IOException {
+        final String bucketId = "bucket1";
+        final String flowId = "flow1";
+
+        createAndSaveSnapshot(fileSystemFlowProvider, bucketId, flowId, 1, "flow1v1");
+        createAndSaveSnapshot(fileSystemFlowProvider, bucketId, flowId, 2, "flow1v2");
+
+        Assert.assertNotNull(fileSystemFlowProvider.getFlowContent(bucketId, flowId, 1));
+        Assert.assertNotNull(fileSystemFlowProvider.getFlowContent(bucketId, flowId, 2));
+
+        fileSystemFlowProvider.deleteFlowContent(bucketId, flowId, 1);
+
+        Assert.assertNull(fileSystemFlowProvider.getFlowContent(bucketId, flowId, 1));
+        Assert.assertNotNull(fileSystemFlowProvider.getFlowContent(bucketId, flowId, 2));
+
+        fileSystemFlowProvider.deleteFlowContent(bucketId, flowId, 2);
+
+        Assert.assertNull(fileSystemFlowProvider.getFlowContent(bucketId, flowId, 1));
+        Assert.assertNull(fileSystemFlowProvider.getFlowContent(bucketId, flowId, 2));
+
+        // delete a version that doesn't exist
+        fileSystemFlowProvider.deleteFlowContent(bucketId, flowId, 3);
+
+        // delete a flow that doesn't exist
+        fileSystemFlowProvider.deleteFlowContent(bucketId, "some-other-flow", 1);
+
+        // delete a bucket that doesn't exist
+        fileSystemFlowProvider.deleteFlowContent("some-other-bucket", flowId, 1);
+    }
+
+    private void createAndSaveSnapshot(final FlowPersistenceProvider flowPersistenceProvider, final String bucketId, final String flowId, final int version,
+                                       final String contentString) throws IOException {
+        final FlowSnapshotContext context = Mockito.mock(FlowSnapshotContext.class);
+        when(context.getBucketId()).thenReturn(bucketId);
+        when(context.getFlowId()).thenReturn(flowId);
+        when(context.getVersion()).thenReturn(version);
+
+        final byte[] content = contentString.getBytes(StandardCharsets.UTF_8);
+        flowPersistenceProvider.saveFlowContent(context, content);
+    }
+
+    private void verifySnapshot(final File flowStorageDir, final String bucketId, final String flowId, final int version,
+                                final String contentString) throws IOException {
+        // verify the correct snapshot file was created
+        final File flowSnapshotFile = new File(flowStorageDir,
+                bucketId + "/" + flowId + "/" + version + "/" + version + FileSystemFlowPersistenceProvider.SNAPSHOT_EXTENSION);
+        Assert.assertTrue(flowSnapshotFile.exists());
+
+        try (InputStream in = new FileInputStream(flowSnapshotFile)) {
+            Assert.assertEquals(contentString, IOUtils.toString(in, StandardCharsets.UTF_8));
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/6f26290d/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/flow/TestStandardFlowSnapshotContext.java
----------------------------------------------------------------------
diff --git a/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/flow/TestStandardFlowSnapshotContext.java b/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/flow/TestStandardFlowSnapshotContext.java
new file mode 100644
index 0000000..bff2ef9
--- /dev/null
+++ b/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/flow/TestStandardFlowSnapshotContext.java
@@ -0,0 +1,57 @@
+/*
+ * 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.registry.provider.flow;
+
+import org.apache.nifi.registry.flow.FlowSnapshotContext;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestStandardFlowSnapshotContext {
+
+    @Test
+    public void testBuilder() {
+        final String bucketId = "1234-1234-1234-1234";
+        final String bucketName = "Some Bucket";
+        final String flowId = "2345-2345-2345-2345";
+        final String flowName = "Some Flow";
+        final int version = 2;
+        final String comments = "Some Comments";
+        final String author = "anonymous";
+        final long timestamp = System.currentTimeMillis();
+
+        final FlowSnapshotContext context = new StandardFlowSnapshotContext.Builder()
+                .bucketId(bucketId)
+                .bucketName(bucketName)
+                .flowId(flowId)
+                .flowName(flowName)
+                .version(version)
+                .comments(comments)
+                .author(author)
+                .snapshotTimestamp(timestamp)
+                .build();
+
+        Assert.assertEquals(bucketId, context.getBucketId());
+        Assert.assertEquals(bucketName, context.getBucketName());
+        Assert.assertEquals(flowId, context.getFlowId());
+        Assert.assertEquals(flowName, context.getFlowName());
+        Assert.assertEquals(version, context.getVersion());
+        Assert.assertEquals(comments, context.getComments());
+        Assert.assertEquals(author, context.getAuthor());
+        Assert.assertEquals(timestamp, context.getSnapshotTimestamp());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/6f26290d/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/flow/git/TestGitFlowPersistenceProvider.java
----------------------------------------------------------------------
diff --git a/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/flow/git/TestGitFlowPersistenceProvider.java b/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/flow/git/TestGitFlowPersistenceProvider.java
new file mode 100644
index 0000000..45351ab
--- /dev/null
+++ b/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/flow/git/TestGitFlowPersistenceProvider.java
@@ -0,0 +1,290 @@
+/*
+ * 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.registry.provider.flow.git;
+
+import org.apache.nifi.registry.flow.FlowPersistenceException;
+import org.apache.nifi.registry.provider.ProviderConfigurationContext;
+import org.apache.nifi.registry.provider.ProviderCreationException;
+import org.apache.nifi.registry.provider.StandardProviderConfigurationContext;
+import org.apache.nifi.registry.provider.flow.StandardFlowSnapshotContext;
+import org.apache.nifi.registry.util.FileUtils;
+import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.errors.GitAPIException;
+import org.eclipse.jgit.lib.StoredConfig;
+import org.eclipse.jgit.revwalk.RevCommit;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.function.Consumer;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+public class TestGitFlowPersistenceProvider {
+
+    private static final Logger logger = LoggerFactory.getLogger(TestGitFlowPersistenceProvider.class);
+
+    private void assertCreationFailure(final Map<String, String> properties, final Consumer<ProviderCreationException> assertion) {
+        final GitFlowPersistenceProvider persistenceProvider = new GitFlowPersistenceProvider();
+
+        try {
+            final ProviderConfigurationContext configurationContext = new StandardProviderConfigurationContext(properties);
+            persistenceProvider.onConfigured(configurationContext);
+            fail("Should fail");
+        } catch (ProviderCreationException e) {
+            assertion.accept(e);
+        }
+    }
+
+    @Test
+    public void testNoFlowStorageDirSpecified() {
+        final Map<String, String> properties = new HashMap<>();
+        assertCreationFailure(properties,
+                e -> assertEquals("The property Flow Storage Directory must be provided", e.getMessage()));
+    }
+
+    @Test
+    public void testLoadNonExistingDir() {
+        final Map<String, String> properties = new HashMap<>();
+        properties.put(GitFlowPersistenceProvider.FLOW_STORAGE_DIR_PROP, "target/non-existing");
+        assertCreationFailure(properties,
+                e -> assertEquals("'target/non-existing' is not a directory or does not exist.", e.getCause().getMessage()));
+    }
+
+    @Test
+    public void testLoadNonGitDir() {
+        final Map<String, String> properties = new HashMap<>();
+        properties.put(GitFlowPersistenceProvider.FLOW_STORAGE_DIR_PROP, "target");
+        assertCreationFailure(properties,
+                e -> assertEquals("Directory 'target' does not contain a .git directory." +
+                                " Please init and configure the directory with 'git init' command before using it from NiFi Registry.",
+                        e.getCause().getMessage()));
+    }
+
+    @FunctionalInterface
+    private interface GitConsumer {
+        void accept(Git git) throws GitAPIException;
+    }
+
+    private void assertProvider(final Map<String, String> properties, final GitConsumer gitConsumer, final Consumer<GitFlowPersistenceProvider> assertion, boolean deleteDir)
+            throws IOException, GitAPIException {
+
+        final File gitDir = new File(properties.get(GitFlowPersistenceProvider.FLOW_STORAGE_DIR_PROP));
+        try {
+            FileUtils.ensureDirectoryExistAndCanReadAndWrite(gitDir);
+
+            try (final Git git = Git.init().setDirectory(gitDir).call()) {
+                logger.debug("Initiated a git repository {}", git);
+                final StoredConfig config = git.getRepository().getConfig();
+                config.setString("user", null, "name", "git-user");
+                config.setString("user", null, "email", "git-user@example.com");
+                config.save();
+                gitConsumer.accept(git);
+            }
+
+            final GitFlowPersistenceProvider persistenceProvider = new GitFlowPersistenceProvider();
+
+            final ProviderConfigurationContext configurationContext = new StandardProviderConfigurationContext(properties);
+            persistenceProvider.onConfigured(configurationContext);
+            assertion.accept(persistenceProvider);
+
+        } finally {
+            if (deleteDir) {
+                FileUtils.deleteFile(gitDir, true);
+            }
+        }
+    }
+
+    @Test
+    public void testLoadEmptyGitDir() throws GitAPIException, IOException {
+        final Map<String, String> properties = new HashMap<>();
+        properties.put(GitFlowPersistenceProvider.FLOW_STORAGE_DIR_PROP, "target/empty-git");
+
+        assertProvider(properties, g -> {}, p -> {
+            try {
+                p.getFlowContent("bucket-id-A", "flow-id-1", 1);
+            } catch (FlowPersistenceException e) {
+                assertEquals("Bucket ID bucket-id-A was not found.", e.getMessage());
+            }
+        }, true);
+    }
+
+    @Test
+    public void testLoadCommitHistories() throws GitAPIException, IOException {
+        final Map<String, String> properties = new HashMap<>();
+        properties.put(GitFlowPersistenceProvider.FLOW_STORAGE_DIR_PROP, "target/repo-with-histories");
+
+        assertProvider(properties, g -> {}, p -> {
+            // Create some Flows and keep the directory.
+            final StandardFlowSnapshotContext.Builder contextBuilder = new StandardFlowSnapshotContext.Builder()
+                    .bucketId("bucket-id-A")
+                    .bucketName("C'est/Bucket A/です。")
+                    .flowId("flow-id-1")
+                    .flowName("テスト_用/フロー#1\\[contains invalid chars]")
+                    .author("unit-test-user")
+                    .comments("Initial commit.")
+                    .snapshotTimestamp(new Date().getTime())
+                    .version(1);
+
+            final byte[] flow1Ver1 = "Flow1 ver.1".getBytes(StandardCharsets.UTF_8);
+            p.saveFlowContent(contextBuilder.build(), flow1Ver1);
+
+            contextBuilder.comments("2nd commit.").version(2);
+            final byte[] flow1Ver2 = "Flow1 ver.2".getBytes(StandardCharsets.UTF_8);
+            p.saveFlowContent(contextBuilder.build(), flow1Ver2);
+
+            // Rename flow.
+            contextBuilder.flowName("FlowOne").comments("3rd commit.").version(3);
+            final byte[] flow1Ver3 = "FlowOne ver.3".getBytes(StandardCharsets.UTF_8);
+            p.saveFlowContent(contextBuilder.build(), flow1Ver3);
+
+            // Adding another flow.
+            contextBuilder.flowId("flow-id-2").flowName("FlowTwo").comments("4th commit.").version(1);
+            final byte[] flow2Ver1 = "FlowTwo ver.1".getBytes(StandardCharsets.UTF_8);
+            p.saveFlowContent(contextBuilder.build(), flow2Ver1);
+
+            // Rename bucket.
+            contextBuilder.bucketName("New name for Bucket A").comments("5th commit.").version(2);
+            final byte[] flow2Ver2 = "FlowTwo ver.2".getBytes(StandardCharsets.UTF_8);
+            p.saveFlowContent(contextBuilder.build(), flow2Ver2);
+
+
+        }, false);
+
+        assertProvider(properties, g -> {
+            // Assert commit.
+            final AtomicInteger commitCount = new AtomicInteger(0);
+            final String[] commitMessages = {
+                    "5th commit.\n\nBy NiFi Registry user: unit-test-user",
+                    "4th commit.\n\nBy NiFi Registry user: unit-test-user",
+                    "3rd commit.\n\nBy NiFi Registry user: unit-test-user",
+                    "2nd commit.\n\nBy NiFi Registry user: unit-test-user",
+                    "Initial commit.\n\nBy NiFi Registry user: unit-test-user"
+            };
+            for (RevCommit commit : g.log().call()) {
+                assertEquals("git-user", commit.getAuthorIdent().getName());
+                final int commitIndex = commitCount.getAndIncrement();
+                assertEquals(commitMessages[commitIndex], commit.getFullMessage());
+            }
+            assertEquals(commitMessages.length, commitCount.get());
+        }, p -> {
+            // Should be able to load flow from commit histories.
+            final byte[] flow1Ver1 = p.getFlowContent("bucket-id-A", "flow-id-1", 1);
+            assertEquals("Flow1 ver.1", new String(flow1Ver1, StandardCharsets.UTF_8));
+
+            final byte[] flow1Ver2 = p.getFlowContent("bucket-id-A", "flow-id-1", 2);
+            assertEquals("Flow1 ver.2", new String(flow1Ver2, StandardCharsets.UTF_8));
+
+            // Even if the name of flow has been changed, it can be retrieved by the same flow id.
+            final byte[] flow1Ver3 = p.getFlowContent("bucket-id-A", "flow-id-1", 3);
+            assertEquals("FlowOne ver.3", new String(flow1Ver3, StandardCharsets.UTF_8));
+
+            final byte[] flow2Ver1 = p.getFlowContent("bucket-id-A", "flow-id-2", 1);
+            assertEquals("FlowTwo ver.1", new String(flow2Ver1, StandardCharsets.UTF_8));
+
+            // Even if the name of bucket has been changed, it can be retrieved by the same flow id.
+            final byte[] flow2Ver2 = p.getFlowContent("bucket-id-A", "flow-id-2", 2);
+            assertEquals("FlowTwo ver.2", new String(flow2Ver2, StandardCharsets.UTF_8));
+
+            // Delete the 2nd flow.
+            p.deleteAllFlowContent("bucket-id-A", "flow-id-2");
+
+        }, false);
+
+        assertProvider(properties, g -> {
+            // Assert commit.
+            final AtomicInteger commitCount = new AtomicInteger(0);
+            final String[] commitMessages = {
+                    "Deleted flow FlowTwo.snapshot:flow-id-2 in bucket New_name_for_Bucket_A:bucket-id-A.",
+                    "5th commit.",
+                    "4th commit.",
+                    "3rd commit.",
+                    "2nd commit.",
+                    "Initial commit."
+            };
+            for (RevCommit commit : g.log().call()) {
+                assertEquals("git-user", commit.getAuthorIdent().getName());
+                final int commitIndex = commitCount.getAndIncrement();
+                assertEquals(commitMessages[commitIndex], commit.getShortMessage());
+            }
+            assertEquals(commitMessages.length, commitCount.get());
+        }, p -> {
+            // Should be able to load flow from commit histories.
+            final byte[] flow1Ver1 = p.getFlowContent("bucket-id-A", "flow-id-1", 1);
+            assertEquals("Flow1 ver.1", new String(flow1Ver1, StandardCharsets.UTF_8));
+
+            final byte[] flow1Ver2 = p.getFlowContent("bucket-id-A", "flow-id-1", 2);
+            assertEquals("Flow1 ver.2", new String(flow1Ver2, StandardCharsets.UTF_8));
+
+            // Even if the name of flow has been changed, it can be retrieved by the same flow id.
+            final byte[] flow1Ver3 = p.getFlowContent("bucket-id-A", "flow-id-1", 3);
+            assertEquals("FlowOne ver.3", new String(flow1Ver3, StandardCharsets.UTF_8));
+
+            // The 2nd flow has been deleted, and should not exist.
+            try {
+                p.getFlowContent("bucket-id-A", "flow-id-2", 1);
+            } catch (FlowPersistenceException e) {
+                assertEquals("Flow ID flow-id-2 was not found in bucket New_name_for_Bucket_A:bucket-id-A.", e.getMessage());
+            }
+
+            try {
+                p.getFlowContent("bucket-id-A", "flow-id-2", 2);
+            } catch (FlowPersistenceException e) {
+                assertEquals("Flow ID flow-id-2 was not found in bucket New_name_for_Bucket_A:bucket-id-A.", e.getMessage());
+            }
+
+            // Delete the 1st flow, too.
+            p.deleteAllFlowContent("bucket-id-A", "flow-id-1");
+
+        }, false);
+
+        assertProvider(properties, g -> {
+            // Assert commit.
+            final AtomicInteger commitCount = new AtomicInteger(0);
+            final String[] commitMessages = {
+                    "Deleted flow FlowOne.snapshot:flow-id-1 in bucket New_name_for_Bucket_A:bucket-id-A.",
+                    "Deleted flow FlowTwo.snapshot:flow-id-2 in bucket New_name_for_Bucket_A:bucket-id-A.",
+                    "5th commit.",
+                    "4th commit.",
+                    "3rd commit.",
+                    "2nd commit.",
+                    "Initial commit."
+            };
+            for (RevCommit commit : g.log().call()) {
+                assertEquals("git-user", commit.getAuthorIdent().getName());
+                final int commitIndex = commitCount.getAndIncrement();
+                assertEquals(commitMessages[commitIndex], commit.getShortMessage());
+            }
+            assertEquals(commitMessages.length, commitCount.get());
+        }, p -> {
+            // The 1st flow has been deleted, and should not exist. Moreover, the bucket A has been deleted since there's no flow.
+            try {
+                p.getFlowContent("bucket-id-A", "flow-id-1", 1);
+            } catch (FlowPersistenceException e) {
+                assertEquals("Bucket ID bucket-id-A was not found.", e.getMessage());
+            }
+        }, true);
+    }
+}

http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/6f26290d/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/hook/TestScriptEventHookProvider.java
----------------------------------------------------------------------
diff --git a/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/hook/TestScriptEventHookProvider.java b/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/hook/TestScriptEventHookProvider.java
new file mode 100644
index 0000000..ab24998
--- /dev/null
+++ b/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/hook/TestScriptEventHookProvider.java
@@ -0,0 +1,45 @@
+/*
+ * 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.registry.provider.hook;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
+import org.apache.nifi.registry.extension.ExtensionManager;
+import org.apache.nifi.registry.properties.NiFiRegistryProperties;
+import org.apache.nifi.registry.provider.ProviderCreationException;
+import org.apache.nifi.registry.provider.ProviderFactory;
+import org.apache.nifi.registry.provider.StandardProviderFactory;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+public class TestScriptEventHookProvider {
+
+    @Test(expected = ProviderCreationException.class)
+    public void testBadScriptProvider() {
+        final NiFiRegistryProperties props = new NiFiRegistryProperties();
+        props.setProperty(NiFiRegistryProperties.PROVIDERS_CONFIGURATION_FILE, "src/test/resources/provider/hook/bad-script-provider.xml");
+
+        final ExtensionManager extensionManager = Mockito.mock(ExtensionManager.class);
+        when(extensionManager.getExtensionClassLoader(any(String.class))).thenReturn(this.getClass().getClassLoader());
+
+        final ProviderFactory providerFactory = new StandardProviderFactory(props, extensionManager);
+        providerFactory.initialize();
+        providerFactory.getEventHookProviders();
+    }
+
+}