You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by gn...@apache.org on 2020/02/13 12:56:13 UTC

[camel] 03/05: Fix unit test which always fail the second time

This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 6974495a07cc233bcf9287265a0901a76e8d07e9
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Thu Feb 13 12:49:43 2020 +0100

    Fix unit test which always fail the second time
---
 .../dsl/component/ComponentsDslMetadataRegistryTest.java      | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/tooling/maven/camel-package-maven-plugin/src/test/java/org/apache/camel/maven/packaging/dsl/component/ComponentsDslMetadataRegistryTest.java b/tooling/maven/camel-package-maven-plugin/src/test/java/org/apache/camel/maven/packaging/dsl/component/ComponentsDslMetadataRegistryTest.java
index 2f346e8..08f023b 100644
--- a/tooling/maven/camel-package-maven-plugin/src/test/java/org/apache/camel/maven/packaging/dsl/component/ComponentsDslMetadataRegistryTest.java
+++ b/tooling/maven/camel-package-maven-plugin/src/test/java/org/apache/camel/maven/packaging/dsl/component/ComponentsDslMetadataRegistryTest.java
@@ -19,6 +19,8 @@ package org.apache.camel.maven.packaging.dsl.component;
 import java.io.File;
 import java.io.IOException;
 import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.StandardCopyOption;
 import java.util.Objects;
 
 import org.apache.camel.tooling.model.ComponentModel;
@@ -36,13 +38,16 @@ class ComponentsDslMetadataRegistryTest {
     public void testIfSyncCorrectly() throws IOException {
         final String json = PackageHelper.loadText(new File(Objects.requireNonNull(getClass().getClassLoader().getResource("json/test_component2.json")).getFile()));
         final File metadata = new File(Objects.requireNonNull(getClass().getClassLoader().getResource("json/component_metadata.json")).getFile());
+        final File metadataWork = metadata.toPath().resolveSibling("component_metadata_work.json").toFile();
 
-        final String metadataJson = PackageHelper.loadText(metadata);
+        Files.copy(metadata.toPath(), metadataWork.toPath(), StandardCopyOption.REPLACE_EXISTING);
+
+        final String metadataJson = PackageHelper.loadText(metadataWork);
 
         final File classesDir = FileSystems.getDefault().getPath(".").resolve("src/test/java/org/apache/camel/maven/packaging/dsl/component").toFile();
 
         final ComponentModel componentModel = JsonMapper.generateComponentModel(json);
-        final ComponentsDslMetadataRegistry componentsDslMetadataRegistry = new ComponentsDslMetadataRegistry(classesDir, metadata);
+        final ComponentsDslMetadataRegistry componentsDslMetadataRegistry = new ComponentsDslMetadataRegistry(classesDir, metadataWork);
 
         // check for size
         assertEquals(2, componentsDslMetadataRegistry.getComponentCacheFromMemory().size());
@@ -57,7 +62,7 @@ class ComponentsDslMetadataRegistryTest {
         // first it adds to he memory cache and then it sync the metadata file by checking existing classes and delete whatever not presented there
         componentsDslMetadataRegistry.addComponentToMetadataAndSyncMetadataFile(componentModel, "ComponentsDslMetadataRegistryTest");
 
-        final String updatedMetadataJson = PackageHelper.loadText(metadata);
+        final String updatedMetadataJson = PackageHelper.loadText(metadataWork);
 
         // check for the size
         assertEquals(1, componentsDslMetadataRegistry.getComponentCacheFromMemory().size());