Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Java] Feedback: The Testutil Modules are valuable and should not be removed #818

Closed
Johannes-Schneider opened this issue May 18, 2022 · 7 comments
Labels
feedback Java Related to documentation on the SAP Cloud SDK for Java

Comments

@Johannes-Schneider
Copy link
Member

Ask for feedback

This issue is meant to collect user feedback regarding the upcoming removal of the testutil-* modules from the public deliveries of the SAP Cloud SDK for Java.

Following modules wont't be available after the release of version 4:

If you are relying on (one of) these modules, please react with a 👍 to let us know

@Johannes-Schneider Johannes-Schneider added Java Related to documentation on the SAP Cloud SDK for Java feedback labels May 18, 2022
@Johannes-Schneider
Copy link
Member Author

Removing these modules will impact the Cloud SDK tutorials.
For example: https://developers.sap.com/tutorials/s4sdk-odata-service-cloud-foundry.html#30540988-5d47-4e9a-a6d3-9ea8dcd23cfc

@newtork
Copy link
Contributor

newtork commented Jul 13, 2022

Hi @zerbarus and @theits,
Can you please explain the usage of testutil-* in your project?
Maybe we can propose a different API call that matches your use-case.

@theits
Copy link

theits commented Jul 13, 2022

Hi @zerbarus and @theits, Can you please explain the usage of testutil-* in your project? Maybe we can propose a different API call that matches your use-case.

Hi @newtork ,

I am using com.sap.cloud.sdk.testutil.MockUtil in order to mock the destination-service from the cloud foundry environment for integration testing.

@newtork
Copy link
Contributor

newtork commented Jul 15, 2022

Hi @theits
Can you consider the following usage instead...?

@Before
public void setLoader() {
  final DefaultHttpDestination dest = DefaultHttpDestination.builder("http://destination/").name("MyDest").build();
  final DefaultDestinationLoader loader = new DefaultDestinationLoader().registerDestination(dest);
  DestinationAccessor.setLoader(loader);
}

@After
public void resetLoader() {
  DestinationAccessor.setLoader(null);
}

Benefits:

  • No mocking necessary.
  • No additional testutil dependency.
  • API is "more stable" than testutil code.

Of course there are semantic differences. Please let me know, if it's missing something.

@theits
Copy link

theits commented Jul 19, 2022

Hi @newtork ,
Thanks for your response, your solution works great for my usecase. The only drawback is, that DefaultDestinationLoader is annotated with @Beta. I hope it stays stable.

@MatKuhr
Copy link
Member

MatKuhr commented Feb 19, 2024

Closing this as MockUtil has been removed

@MatKuhr MatKuhr closed this as completed Feb 19, 2024
@sap-manaschuri
Copy link

sap-manaschuri commented Feb 24, 2024

We are migrating the com.sap.cloud.sdk:sdk-modules-bom from 4.27.0 to 5.2.0 and trying to remove the dependency of com.sap.cloud.sdk.cloudplatform:scp-cf and com.sap.cloud.sdk.testutil:testutil-core as it is depricated.
When we used following code instead of MockDestination and MockUtil

@before
public void setLoader() {
final DefaultHttpDestination dest = DefaultHttpDestination.builder("http://destination/").name("MyDest").build();
final DefaultDestinationLoader loader = new DefaultDestinationLoader().registerDestination(dest);
DestinationAccessor.setLoader(loader);
}

We are getting following error :

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 10.72 sec <<< FAILURE!
testPostKeyPairToKeyStore(com.sap.ich.certificationAutomationService.Service.DocStoreRestServiceTest) Time elapsed: 0.755 sec <<< ERROR!
com.sap.cloud.sdk.cloudplatform.connectivity.exception.DestinationNotFoundException: Destination '?????' not found.
at com.sap.cloud.sdk.cloudplatform.connectivity.DefaultDestinationLoader.lambda$tryGetDestination$0(DefaultDestinationLoader.java:69)
at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708)
at com.sap.cloud.sdk.cloudplatform.connectivity.DefaultDestinationLoader.tryGetDestination(DefaultDestinationLoader.java:69)
at com.sap.cloud.sdk.cloudplatform.connectivity.DestinationLoader.tryGetDestination(DestinationLoader.java:37)

Can you please suggest the solution?
Thanks,
Manas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feedback Java Related to documentation on the SAP Cloud SDK for Java
Projects
None yet
Development

No branches or pull requests

5 participants