Importer should log file name
MODIFY
manager/api/export-import/src/main/java/io/apiman/manager/api/exportimport/manager/ExportImportManager.java
manager/api/export-import/src/main/java/io/apiman/manager/api/exportimport/manager/ExportImportManager.java
@@ -72,7 +72,7 @@ public class ExportImportManager {
private void doImport() {
IImportReader reader = eiFactories.get(config.getProvider()).createReader(config, importLogger);
- importDispatcher.start();
+ importDispatcher.start(config.getJsonFile());
reader.setDispatcher(importDispatcher);
try {
reader.read();

MODIFY
manager/api/export-import/src/main/java/io/apiman/manager/api/exportimport/manager/StorageImportDispatcher.java
manager/api/export-import/src/main/java/io/apiman/manager/api/exportimport/manager/StorageImportDispatcher.java
@@ -109,9 +109,9 @@ public class StorageImportDispatcher implements IImportReaderDispatcher {
/**
* Starts the import.
*/
- public void start() {
+ public void start(String fileName) {
logger.info("----------------------------"); //$NON-NLS-1$
- logger.info(Messages.i18n.format("StorageImportDispatcher.StartingImport")); //$NON-NLS-1$
+ logger.info(Messages.i18n.format("StorageImportDispatcher.StartingImport") + fileName); //$NON-NLS-1$
currentMetadata.setImportedOn(new Date());
currentMetadata.setApimanVersionAtImport(version.getVersionString());

MODIFY
manager/api/export-import/src/main/resources/io/apiman/manager/api/exportimport/i18n/messages.properties
manager/api/export-import/src/main/resources/io/apiman/manager/api/exportimport/i18n/messages.properties
-StorageImportDispatcher.StartingImport=Starting apiman data import.
+StorageImportDispatcher.StartingImport=Starting apiman data import:
StorageImportDispatcher.ImportingClient=\ \ Importing a client:
StorageImportDispatcher.ImportingClientContract=Importing a client contract.
StorageImportDispatcher.ImportingClientPolicy=\ \ \ \ \ \ Importing a client policy:

MODIFY
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/SystemResourceImpl.java
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/SystemResourceImpl.java
@@ -268,7 +268,7 @@ public class SystemResourceImpl implements ISystemResource {
try {
importer.setLogger(logger);
- importer.start();
+ importer.start(migratedImportFile.getAbsolutePath());
reader.setDispatcher(importer);
reader.read();
} catch (Exception e) {

MODIFY
manager/api/war/src/main/java/io/apiman/manager/api/war/WarApiManagerBootstrapperServlet.java
manager/api/war/src/main/java/io/apiman/manager/api/war/WarApiManagerBootstrapperServlet.java
@@ -102,7 +102,7 @@ public class WarApiManagerBootstrapperServlet extends HttpServlet {
try {
importer.setLogger(logger);
- importer.start();
+ importer.start(file.getAbsolutePath());
reader.setDispatcher(importer);
reader.read();
} catch (Exception e) {

MODIFY
manager/test/api/src/test/resources/test-plan-data/import/001_import.resttest
manager/test/api/src/test/resources/test-plan-data/import/001_import.resttest
@@ -370,7 +370,7 @@ Content-Type: application/json
Content-Type: text/plain;charset=utf-8
INFO: ----------------------------
-INFO: Starting apiman data import.
+INFO: Starting apiman data import: .*apiman_import_migrated.*.json
INFO: Importing a user: importeduser
INFO: Importing a gateway: The Gateway
INFO: Importing an organization: Organization 1

MODIFY
manager/test/api/src/test/resources/test-plan-data/import/002_import-again.resttest
manager/test/api/src/test/resources/test-plan-data/import/002_import-again.resttest
@@ -370,5 +370,5 @@ Content-Type: application/json
Content-Type: text/plain;charset=utf-8
INFO: ----------------------------
-INFO: Starting apiman data import.
+INFO: Starting apiman data import: .*apiman_import_migrated.*.json
INFO: Import not needed.

MODIFY
manager/test/api/src/test/resources/test-plan-data/import/003_import-with-developer.resttest
manager/test/api/src/test/resources/test-plan-data/import/003_import-with-developer.resttest
@@ -31,7 +31,7 @@ Content-Type: application/json
Content-Type: text/plain;charset=utf-8
INFO: ----------------------------
-INFO: Starting apiman data import.
+INFO: Starting apiman data import: .*apiman_import_migrated.*.json
INFO: Importing a developer: Developer1
INFO: Importing a developer: Developer2
INFO: Publishing APIs to the gateway.

MODIFY
manager/test/api/src/test/resources/test-plan-data/migrate/001_import-1.2.2.Final.resttest
manager/test/api/src/test/resources/test-plan-data/migrate/001_import-1.2.2.Final.resttest
@@ -1600,7 +1600,7 @@ INFO: Migrating Policy Def: "JSONP Policy"
INFO: Migrating Organization: "Test"
INFO: Migrating Organization: "Foo"
INFO: ----------------------------
-INFO: Starting apiman data import.
+INFO: Starting apiman data import: .*apiman_import_migrated.*.json
INFO: Importing a user: admin
INFO: Importing a gateway: The Gateway
INFO: Importing a plugin: io.apiman.plugins/apiman-plugins-log-policy/1.2.2.Final
@@ -1623,7 +1623,7 @@ INFO: Importing a policy definition: Time Restricted Access Policy
INFO: Importing a policy definition: Log Headers Policy
INFO: Importing a policy definition: JSONP Policy
INFO: Importing an organization: Test
-INFO: Importing a role membership: admin+OrganizationOwner=>Test
+INFO: Importing a role membership: admin\+OrganizationOwner=>Test
INFO: Importing a plan: Gold
INFO: Importing a plan version: 1.0
INFO: Importing a plan policy: Rate Limiting Policy
@@ -1674,7 +1674,7 @@ INFO: Importing an audit entry: 98
INFO: Importing an audit entry: 99
INFO: Importing an audit entry: 101
INFO: Importing an organization: Foo
-INFO: Importing a role membership: admin+OrganizationOwner=>Foo
+INFO: Importing a role membership: admin\+OrganizationOwner=>Foo
INFO: Importing a plan: Good
INFO: Importing a plan version: 1.0
INFO: Importing a plan policy: Caching Policy

MODIFY
pom.xml
pom.xml
<version.javax.enterprise>1.2</version.javax.enterprise>
<version.joda-time>2.7</version.joda-time>
<version.junit>4.13.2</version.junit>
+ <version.org.assertj>3.19.0</version.org.assertj>
<version.org.junit.jupiter>5.4.2</version.org.junit.jupiter>
<version.org.apache.commons.commons-lang3>3.3.2</version.org.apache.commons.commons-lang3>
<version.org.apache.directory.server>2.0.0.AM25</version.org.apache.directory.server>
<artifactId>hamcrest-all</artifactId>
<version>${version.org.hamcrest}</version>
</dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <version>${version.org.assertj}</version>
+ </dependency>
<dependency>
<groupId>org.skyscreamer</groupId>
<artifactId>jsonassert</artifactId>

MODIFY
test/common/pom.xml
test/common/pom.xml
<groupId>io.apiman</groupId>
<artifactId>apiman-gateway-engine-core</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ </dependency>
<!-- Required Third Party Libs -->
<dependency>
<groupId>xmlunit</groupId>

MODIFY
test/common/src/main/java/io/apiman/test/common/util/TestPlanRunner.java
test/common/src/main/java/io/apiman/test/common/util/TestPlanRunner.java
@@ -61,6 +61,8 @@ import com.jcabi.http.Request;
import com.jcabi.http.Response;
import com.jcabi.http.request.ApacheRequest;
+import static org.assertj.core.api.Assertions.*;
+
/**
* Runs a test plan.
*
@@ -456,13 +458,18 @@ public class TestPlanRunner {
List<String> lines = IOUtils.readLines(inputStream);
StringBuilder builder = new StringBuilder();
for (String line : lines) {
- builder.append(line).append("\n");
+ // Replace single backslashes with double backslashes to escape them for the regex compiler.
+ // These occur for example in Windows paths
+ builder.append(line.replace("\\","\\\\")).append("\n");
}
String actual = builder.toString();
String expected = restTest.getExpectedResponsePayload();
+
if (expected != null) {
- Assert.assertEquals("Response payload (text/plain) mismatch.", expected, actual);
+ assertThat(actual)
+ .withFailMessage("Response payload (text/plain) mismatch. Expected %s != %s\n", expected, actual)
+ .matches(expected);
}
} catch (Exception e) {
throw new Error(e);

Importer should log file name (#968)

Co-authored-by: BaGe <a9311c106335b4184e37fdbfcd5c512d>
Co-authored-by: Marc Savy <marc@rhymewithgravy.com>