2

我在集成测试中使用了 S4SDK VDM 来测试我的 ODATA 服务。在实施过程中出现了一些问题,Alexander 让我让它发挥作用。(用于集成测试的 VDM

当我在 Eclipse 中执行 JUnit 时,它运行良好。但是,当 JUnit 在管道中的 Maven Build/ 期间运行时,它会失败并出现以下错误

[INFO] 
[INFO] Results:
[INFO] 
[ERROR] Errors: 
[ERROR]   BusinessServiceIT.createBusinessService:132->createLandscapeObject:214 » ErpOData
[INFO] 
[ERROR] Tests run: 21, Failures: 0, Errors: 1, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 09:34 min
[INFO] Finished at: 2019-06-13T16:00:26+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M3:test (default-test) on project x-srv-landscapeManagement-integration-tests: There are test failures.
[ERROR] 
[ERROR] Please refer to C:\Users\xxxxx\git\x-service-landscapeManagement\srv\integration-tests\target\surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :x-srv-landscapeManagement-integration-tests
    public static void beforeClass() {
        mockUtil.mockDefaults();
        mockUtil.mockAuditLog();

        lsoCreateHelper.withCustomHttpHeader("Authorization", jwToken).onRequestAndImplicitRequests();
        connectionHelper.withCustomHttpHeader("Authorization", jwToken).onRequestAndImplicitRequests();

    }```

``` @Before
    public void beforeEach() throws URISyntaxException, IOException, ODataException {
        mockUtil.mockDestination("localhorst", new URI("http://localhost:" + randomServerPort));
        erpConfCtx = new ErpConfigContext("localhorst");
        final String publicKey = FileUtils.readFile("publicKey.txt");
        final Map<String, String> verificationkey = ImmutableMap.of("verificationkey", publicKey);
        final JsonObject xsuaaServiceCredentials = new Gson().toJsonTree(verificationkey).getAsJsonObject();
        when(((ScpCfCloudPlatform) CloudPlatformAccessor.getCloudPlatform())
                .getXsuaaServiceCredentials(org.mockito.ArgumentMatchers.any(DecodedJWT.class)))
                        .thenReturn(xsuaaServiceCredentials);
    }```

private UUID createLandscapeObject(String lsoType, String name, String customerNumber, String source,
        String usecase, String tenantId, String tenantType) throws ODataException {
    Properties properties = new Properties();
    List<Properties> propertySet = new ArrayList<>();

    if (usecase != null) {
        properties.setName("useCase");
        properties.setValue(usecase);
        properties.setSource(source);
        propertySet.add(properties);
    }

    if (tenantId != null) {
        propertySet = new ArrayList<>();
        properties.setName("TenantId");
        properties.setValue(tenantId);
        properties.setSource(source);
        propertySet.add(properties);
    }

    if (tenantType != null) {
        propertySet = new ArrayList<>();
        properties.setName("TenantType");
        properties.setValue(tenantType);
        properties.setSource(source);
        propertySet.add(properties);
    }

    LandscapeObjects landscapeObjects = new LandscapeObjects(null, null, null, null, null, name, "benufromit_test",
            lsoType, customerNumber, source, null, null, propertySet);
    LOG.info("benu-business1");

    final LandscapeObjectsCreateFluentHelper lsoCreateHelper = lmsService.createLandscapeObjects(landscapeObjects)
            .withCustomHttpHeader("Authorization", jwToken).onRequestAndImplicitRequests();

    landscapeObjects = lsoCreateHelper.execute(erpConfCtx);
    return landscapeObjects.getId();

}```

[错误] 错误:[错误] BusinessServiceIT.createBusinessService:132->createLandscapeObject:214 » ErpOData

目标\肯定报告

-------------------------------------------------------------------------------
Test set: com.sap.crun.landscape.BusinessServiceIT
-------------------------------------------------------------------------------
Tests run: 3, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 66.107 s <<< FAILURE! - in com.sap.crun.landscape.BusinessServiceIT
createBusinessService(com.sap.crun.landscape.BusinessServiceIT)  Time elapsed: 2.463 s  <<< ERROR!
com.sap.cloud.sdk.s4hana.datamodel.odata.helper.ODataVdmErrorResultHandler$ErpODataException: 
The endpoint responded with HTTP error code 500.
. . 
Full error message: 
<?xml version='1.0' encoding='UTF-8'?><error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><code/><message xml:lang="en">Service not available: LandscapeService.</message></error>
    at com.sap.crun.landscape.BusinessServiceIT.createLandscapeObject(BusinessServiceIT.java:214)
    at com.sap.crun.landscape.BusinessServiceIT.createBusinessService(BusinessServiceIT.java:132)```


**TestApplication**

package com.sap.crun.landscape;

    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.boot.web.servlet.ServletComponentScan;
    import org.springframework.context.annotation.ComponentScan;

    @SpringBootApplication
    @ComponentScan(basePackages = {"com.sap.cloud.servicesdk.spring", "com.sap.crun.landscape"})
    @ServletComponentScan( "com.sap.cloud.sdk" )
    public class TestApplication {
        public static void main(String[] args) {
            SpringApplication.run(TestApplication.class, args);
        }
    }



4

0 回答 0