How to use CosmosDBEmulatorContainer method of org.testcontainers.containers.CosmosDBEmulatorContainer class

Best Testcontainers-java code snippet using org.testcontainers.containers.CosmosDBEmulatorContainer.CosmosDBEmulatorContainer

copy

Full Screen

...10import org.springframework.context.ConfigurableApplicationContext;11import org.springframework.context.annotation.Bean;12import org.springframework.test.context.ActiveProfiles;13import org.springframework.test.context.ContextConfiguration;14import org.testcontainers.containers.CosmosDBEmulatorContainer;15import org.testcontainers.junit.jupiter.Container;16import org.testcontainers.junit.jupiter.Testcontainers;17import org.testcontainers.utility.DockerImageName;18import java.io.FileOutputStream;19import java.nio.file.Path;20import java.security.KeyStore;21@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)22@ContextConfiguration(initializers = AbstractIntegrationTest.Initializer.class)23@Testcontainers24@ActiveProfiles({"integration-test"})25class AbstractIntegrationTest {26 protected static final int ServerPort = 8090;27 @Container28 private static final CosmosDBEmulatorContainer emulator = new CosmosDBEmulatorContainer(29 DockerImageName.parse("mcr.microsoft.com/​cosmosdb/​linux/​azure-cosmos-emulator:latest")30 );31 @TempDir32 private static Path tempFolder;33 static class Initializer34 implements ApplicationContextInitializer<ConfigurableApplicationContext> {35 @SneakyThrows36 @Override37 public void initialize(ConfigurableApplicationContext context) {38 Path keyStoreFile = tempFolder.resolve("azure-cosmos-emulator.keystore");39 KeyStore keyStore = emulator.buildNewKeyStore();40 keyStore.store(new FileOutputStream(keyStoreFile.toFile()), emulator.getEmulatorKey().toCharArray());41 System.setProperty("javax.net.ssl.trustStore", keyStoreFile.toString());42 System.setProperty("javax.net.ssl.trustStorePassword", emulator.getEmulatorKey());...

Full Screen

Full Screen
copy

Full Screen

1package com.example.cosmos.config;2import org.springframework.stereotype.Component;3import org.testcontainers.containers.CosmosDBEmulatorContainer;4import org.testcontainers.utility.DockerImageName;5import java.io.FileOutputStream;6import java.io.IOException;7import java.nio.file.Files;8import java.nio.file.Path;9import java.security.KeyStore;10import java.security.KeyStoreException;11import java.security.NoSuchAlgorithmException;12import java.security.cert.CertificateException;13import java.util.List;14import java.util.concurrent.atomic.AtomicBoolean;15@Component16public class CosmosDatabaseContainer implements AutoCloseable {17 public static final String IMAGE_NAME = "mcr.microsoft.com/​cosmosdb/​linux/​azure-cosmos-emulator";18 private CosmosDBEmulatorContainer cosmosDBEmulatorContainer;19 private static AtomicBoolean initialized = new AtomicBoolean();20 private static CosmosDatabaseContainer thisContainer;21 private CosmosDatabaseContainer() {22 if (initialized.compareAndSet(false, true)) {23 this.cosmosDBEmulatorContainer =24 new CosmosDBEmulatorContainer(DockerImageName.parse(IMAGE_NAME));25 cosmosDBEmulatorContainer.setEnv(List.of("AZURE_COSMOS_EMULATOR_PARTITION_COUNT=5"));26 cosmosDBEmulatorContainer.start();27 configureKeyStore();28 }29 }30 public static CosmosDatabaseContainer getInstance() {31 if (thisContainer == null) {32 thisContainer = new CosmosDatabaseContainer();33 }34 return thisContainer;35 }36 @Override37 public void close() throws Exception {38 cosmosDBEmulatorContainer.stop();...

Full Screen

Full Screen
copy

Full Screen

...4import java.security.KeyStore;5/​**6 * An Azure CosmosDB container7 */​8public class CosmosDBEmulatorContainer extends GenericContainer<CosmosDBEmulatorContainer> {9 private static final DockerImageName DEFAULT_IMAGE_NAME =10 DockerImageName.parse("mcr.microsoft.com/​cosmosdb/​linux/​azure-cosmos-emulator");11 private static final int PORT = 8081;12 /​**13 * @param dockerImageName specified docker image name to run14 */​15 public CosmosDBEmulatorContainer(final DockerImageName dockerImageName) {16 super(dockerImageName);17 dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME);18 withExposedPorts(PORT);19 waitingFor(Wait.forLogMessage("(?s).*Started\\r\\n$", 1));20 }21 /​**22 * @return new KeyStore built with PKCS1223 */​24 public KeyStore buildNewKeyStore() {25 return KeyStoreBuilder.buildByDownloadingCertificate(getEmulatorEndpoint(), getEmulatorKey());26 }27 /​**28 * Emulator key is a known constant and specified in Azure Cosmos DB Documents.29 * This key is also used as password for emulator certificate file....

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

An Interactive Guide To CSS Hover Effects

Building a website is all about keeping the user experience in mind. Ultimately, it’s about providing visitors with a mind-blowing experience so they’ll keep coming back. One way to ensure visitors have a great time on your site is to add some eye-catching text or image animations.

Do you possess the necessary characteristics to adopt an Agile testing mindset?

To understand the agile testing mindset, we first need to determine what makes a team “agile.” To me, an agile team continually focuses on becoming self-organized and cross-functional to be able to complete any challenge they may face during a project.

Project Goal Prioritization in Context of Your Organization&#8217;s Strategic Objectives

One of the most important skills for leaders to have is the ability to prioritize. To understand how we can organize all of the tasks that must be completed in order to complete a project, we must first understand the business we are in, particularly the project goals. There might be several project drivers that stimulate project execution and motivate a company to allocate the appropriate funding.

Test strategy and how to communicate it

I routinely come across test strategy documents when working with customers. They are lengthy—100 pages or more—and packed with monotonous text that is routinely reused from one project to another. Yawn once more— the test halt and resume circumstances, the defect management procedure, entrance and exit criteria, unnecessary generic risks, and in fact, one often-used model replicates the requirements of textbook testing, from stress to systems integration.

How To Automate Mouse Clicks With Selenium Python

Sometimes, in our test code, we need to handle actions that apparently could not be done automatically. For example, some mouse actions such as context click, double click, drag and drop, mouse movements, and some special key down and key up actions. These specific actions could be crucial depending on the project context.

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Testcontainers-java automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful