Search in sources :

Example 1 with BeforeMethod

use of org.testng.annotations.BeforeMethod in project che by eclipse.

the class SnapshotDaoTest method createSnapshots.

@BeforeMethod
private void createSnapshots() throws TckRepositoryException {
    // one account for all the workspaces
    final AccountImpl account = new AccountImpl("account1", "name", "type");
    // workspaces
    workspaces = new TestWorkspace[SNAPSHOTS_SIZE / 3];
    for (int i = 0; i < workspaces.length; i++) {
        workspaces[i] = new TestWorkspace("workspace-" + i, account.getId());
    }
    // snapshots
    snapshots = new SnapshotImpl[SNAPSHOTS_SIZE];
    for (int i = 0; i < SNAPSHOTS_SIZE; i++) {
        snapshots[i] = createSnapshot("snapshot-" + i, // 3 snapshot share the same workspace id
        workspaces[i / 3].getId(), // 2 snapshots share the same env name
        "environment-" + i / 2, "machine-" + i);
    }
    accountRepo.createAll(singletonList(account));
    workspaceRepo.createAll(asList(workspaces));
    snaphotRepo.createAll(asList(snapshots));
}
Also used : AccountImpl(org.eclipse.che.account.spi.AccountImpl) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with BeforeMethod

use of org.testng.annotations.BeforeMethod in project che by eclipse.

the class RecipeServiceTest method setUpUriInfo.

@BeforeMethod
public void setUpUriInfo() throws NoSuchFieldException, IllegalAccessException {
    when(uriInfo.getBaseUriBuilder()).thenReturn(new UriBuilderImpl());
    final Field uriField = service.getClass().getSuperclass().getDeclaredField("uriInfo");
    uriField.setAccessible(true);
    uriField.set(service, uriInfo);
}
Also used : Field(java.lang.reflect.Field) UriBuilderImpl(org.everrest.core.impl.uri.UriBuilderImpl) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 3 with BeforeMethod

use of org.testng.annotations.BeforeMethod in project che by eclipse.

the class CheEnvironmentEngineTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    engine = spy(new CheEnvironmentEngine(snapshotDao, machineInstanceProviders, System.getProperty("java.io.tmpdir"), DEFAULT_MACHINE_MEM_LIMIT_MB, eventService, environmentParser, new DefaultServicesStartStrategy(), machineProvider, infrastructureProvisioner, API_ENDPOINT, recipeDownloader, containerNameGenerator, agentRegistry, sharedPool));
    when(machineInstanceProviders.getProvider("docker")).thenReturn(instanceProvider);
    when(instanceProvider.getRecipeTypes()).thenReturn(Collections.singleton("dockerfile"));
    when(agentRegistry.getAgent(any(AgentKey.class))).thenReturn(agent);
    EnvironmentContext.getCurrent().setSubject(new SubjectImpl("name", "id", "token", false));
}
Also used : AgentKey(org.eclipse.che.api.agent.shared.model.AgentKey) SubjectImpl(org.eclipse.che.commons.subject.SubjectImpl) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 4 with BeforeMethod

use of org.testng.annotations.BeforeMethod in project che by eclipse.

the class SshDaoTest method setUp.

@BeforeMethod
public void setUp() throws TckRepositoryException {
    UserImpl[] users = new UserImpl[COUNT_OF_USERS];
    for (int i = 0; i < COUNT_OF_USERS; i++) {
        users[i] = new UserImpl("owner" + i, "owner" + i + "@eclipse.org", "owner" + i, "password", emptyList());
    }
    pairs = new SshPairImpl[COUNT_OF_PAIRS];
    for (int i = 0; i < COUNT_OF_PAIRS; i++) {
        pairs[i] = new // 3 each pairs share the same owner
        SshPairImpl(// 3 each pairs share the same owner
        "owner" + i / 3, // each 2 pairs share the same service
        "service" + i / 2, "name" + i, NameGenerator.generate("publicKey-", 20), NameGenerator.generate("privateKey-", 20));
    }
    userRepository.createAll(Arrays.asList(users));
    sshRepository.createAll(Arrays.asList(pairs));
}
Also used : UserImpl(org.eclipse.che.api.user.server.model.impl.UserImpl) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 5 with BeforeMethod

use of org.testng.annotations.BeforeMethod in project che by eclipse.

the class DownloadFileResponseFilterTest method before.

/**
     * Setup env for launching requests
     * @throws Exception
     */
@BeforeMethod
public void before() throws Exception {
    //set up launcher
    final ResourceBinderImpl resources = new ResourceBinderImpl();
    resources.addResource(MyJaxRSService.class, null);
    final DependencySupplierImpl dependencies = new DependencySupplierImpl();
    final ApplicationProviderBinder providers = new ApplicationProviderBinder();
    providers.addExceptionMapper(ApiExceptionMapper.class);
    providers.addResponseFilter(EverrestDownloadFileResponseFilter.class);
    final URI uri = new URI(BASE_URI);
    final ContainerRequest req = new ContainerRequest(null, uri, uri, null, null, null);
    final ApplicationContext context = anApplicationContext().withRequest(req).withProviders(providers).withDependencySupplier(dependencies).build();
    ApplicationContext.setCurrent(context);
    final EverrestProcessor processor = new EverrestProcessor(new EverrestConfiguration(), dependencies, new RequestHandlerImpl(new RequestDispatcher(resources), providers), null);
    resourceLauncher = new ResourceLauncher(processor);
}
Also used : DependencySupplierImpl(org.everrest.core.tools.DependencySupplierImpl) ApplicationProviderBinder(org.everrest.core.impl.ApplicationProviderBinder) ApplicationContext.anApplicationContext(org.everrest.core.ApplicationContext.anApplicationContext) ApplicationContext(org.everrest.core.ApplicationContext) EverrestConfiguration(org.everrest.core.impl.EverrestConfiguration) RequestHandlerImpl(org.everrest.core.impl.RequestHandlerImpl) ResourceBinderImpl(org.everrest.core.impl.ResourceBinderImpl) ContainerRequest(org.everrest.core.impl.ContainerRequest) URI(java.net.URI) EverrestProcessor(org.everrest.core.impl.EverrestProcessor) ResourceLauncher(org.everrest.core.tools.ResourceLauncher) RequestDispatcher(org.everrest.core.impl.RequestDispatcher) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

BeforeMethod (org.testng.annotations.BeforeMethod)1078 File (java.io.File)60 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)52 IOException (java.io.IOException)49 DateTime (org.joda.time.DateTime)46 NavigationHelper (org.mifos.test.acceptance.framework.testhelpers.NavigationHelper)42 DateTimeUpdaterRemoteTestingService (org.mifos.test.acceptance.remote.DateTimeUpdaterRemoteTestingService)41 LoanTestHelper (org.mifos.test.acceptance.framework.testhelpers.LoanTestHelper)38 Enumeration (java.util.Enumeration)37 Project (com.google.refine.model.Project)33 StringWriter (java.io.StringWriter)26 Properties (java.util.Properties)26 EntityType (org.molgenis.data.meta.model.EntityType)25 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)23 ServletConfig (jakarta.servlet.ServletConfig)22 ServletContext (jakarta.servlet.ServletContext)22 HttpServletRequest (javax.servlet.http.HttpServletRequest)22 AppLauncher (org.mifos.test.acceptance.framework.AppLauncher)22 Subject (javax.security.auth.Subject)21 Attribute (org.molgenis.data.meta.model.Attribute)21