org.junit.jupiter.api.extension.Extension Java Examples

The following examples show how to use org.junit.jupiter.api.extension.Extension. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: doma   Author: domaframework   File: EntityProcessorTest.java    License: Apache License 2.0 6 votes vote down vote up
private TestTemplateInvocationContext invocationContext(
    Class<?> compilationUnit, String... options) {
  return new TestTemplateInvocationContext() {
    @Override
    public String getDisplayName(int invocationIndex) {
      return compilationUnit.getSimpleName();
    }

    @Override
    public List<Extension> getAdditionalExtensions() {
      return Arrays.asList(
          new SimpleParameterResolver(compilationUnit),
          new ResourceParameterResolver(compilationUnit),
          new GeneratedClassNameParameterResolver(compilationUnit),
          new SimpleParameterResolver(options));
    }
  };
}
 
Example #2
Source Project: doma   Author: domaframework   File: EntityProcessorTest.java    License: Apache License 2.0 6 votes vote down vote up
private TestTemplateInvocationContext invocationContext(
    Class<?> compilationUnit, Class<?> annotatedClass, String... options) {
  return new TestTemplateInvocationContext() {
    @Override
    public String getDisplayName(int invocationIndex) {
      return compilationUnit.getSimpleName();
    }

    @Override
    public List<Extension> getAdditionalExtensions() {
      return Arrays.asList(
          new SimpleParameterResolver(compilationUnit),
          new ResourceParameterResolver(compilationUnit),
          new GeneratedClassNameParameterResolver(annotatedClass),
          new SimpleParameterResolver(options));
    }
  };
}
 
Example #3
Source Project: doma   Author: domaframework   File: EntityProcessorTest.java    License: Apache License 2.0 6 votes vote down vote up
private TestTemplateInvocationContext invocationContext(
    Class<?> clazz, Message message, String... options) {
  return new TestTemplateInvocationContext() {
    @Override
    public String getDisplayName(int invocationIndex) {
      return clazz.getSimpleName();
    }

    @Override
    public List<Extension> getAdditionalExtensions() {
      return Arrays.asList(
          new SimpleParameterResolver(clazz),
          new SimpleParameterResolver(message),
          new SimpleParameterResolver(options));
    }
  };
}
 
Example #4
Source Project: doma   Author: domaframework   File: MetamodelTest.java    License: Apache License 2.0 6 votes vote down vote up
private TestTemplateInvocationContext invocationContext(
    Class<?> compilationUnit, String... options) {
  return new TestTemplateInvocationContext() {
    @Override
    public String getDisplayName(int invocationIndex) {
      return compilationUnit.getSimpleName();
    }

    @Override
    public List<Extension> getAdditionalExtensions() {
      return Arrays.asList(
          new SimpleParameterResolver(compilationUnit),
          new ResourceParameterResolver(compilationUnit),
          new CriteriaGeneratedClassNameParameterResolver(compilationUnit),
          new SimpleParameterResolver(options));
    }
  };
}
 
Example #5
Source Project: doma   Author: domaframework   File: MetamodelTest.java    License: Apache License 2.0 6 votes vote down vote up
private TestTemplateInvocationContext invocationContext(
    Class<?> compilationUnit, String... options) {
  return new TestTemplateInvocationContext() {
    @Override
    public String getDisplayName(int invocationIndex) {
      return compilationUnit.getSimpleName();
    }

    @Override
    public List<Extension> getAdditionalExtensions() {
      return Arrays.asList(
          new SimpleParameterResolver(compilationUnit),
          new ResourceParameterResolver(compilationUnit),
          new CriteriaGeneratedClassNameParameterResolver(compilationUnit, "Q", ""),
          new SimpleParameterResolver(options));
    }
  };
}
 
Example #6
Source Project: doma   Author: domaframework   File: MetamodelTest.java    License: Apache License 2.0 6 votes vote down vote up
private TestTemplateInvocationContext invocationContext(
    Class<?> clazz, Message message, String... options) {
  return new TestTemplateInvocationContext() {
    @Override
    public String getDisplayName(int invocationIndex) {
      return clazz.getSimpleName();
    }

    @Override
    public List<Extension> getAdditionalExtensions() {
      return Arrays.asList(
          new SimpleParameterResolver(clazz),
          new SimpleParameterResolver(message),
          new SimpleParameterResolver(options));
    }
  };
}
 
Example #7
Source Project: doma   Author: domaframework   File: MetamodelOptionTest.java    License: Apache License 2.0 6 votes vote down vote up
private TestTemplateInvocationContext invocationContext(
    Class<?> compilationUnit, String... options) {
  return new TestTemplateInvocationContext() {
    @Override
    public String getDisplayName(int invocationIndex) {
      return compilationUnit.getSimpleName();
    }

    @Override
    public List<Extension> getAdditionalExtensions() {
      return Arrays.asList(
          new SimpleParameterResolver(compilationUnit),
          new ResourceParameterResolver(compilationUnit),
          new CriteriaGeneratedClassNameParameterResolver(compilationUnit, PREFIX, SUFFIX),
          new SimpleParameterResolver(options));
    }
  };
}
 
Example #8
Source Project: doma   Author: domaframework   File: EmbeddableProcessorTest.java    License: Apache License 2.0 6 votes vote down vote up
private TestTemplateInvocationContext invocationContext(
    Class<?> compilationUnit, String... options) {
  return new TestTemplateInvocationContext() {
    @Override
    public String getDisplayName(int invocationIndex) {
      return compilationUnit.getSimpleName();
    }

    @Override
    public List<Extension> getAdditionalExtensions() {
      return Arrays.asList(
          new SimpleParameterResolver(compilationUnit),
          new ResourceParameterResolver(compilationUnit),
          new GeneratedClassNameParameterResolver(compilationUnit),
          new SimpleParameterResolver(options));
    }
  };
}
 
Example #9
Source Project: doma   Author: domaframework   File: EmbeddableProcessorTest.java    License: Apache License 2.0 6 votes vote down vote up
private TestTemplateInvocationContext invocationContext(
    Class<?> compilationUnit, Class<?> annotatedClass, String... options) {
  return new TestTemplateInvocationContext() {
    @Override
    public String getDisplayName(int invocationIndex) {
      return compilationUnit.getSimpleName();
    }

    @Override
    public List<Extension> getAdditionalExtensions() {
      return Arrays.asList(
          new SimpleParameterResolver(compilationUnit),
          new ResourceParameterResolver(compilationUnit),
          new GeneratedClassNameParameterResolver(annotatedClass),
          new SimpleParameterResolver(options));
    }
  };
}
 
Example #10
Source Project: doma   Author: domaframework   File: EmbeddableProcessorTest.java    License: Apache License 2.0 6 votes vote down vote up
private TestTemplateInvocationContext invocationContext(
    Class<?> clazz, Message message, String... options) {
  return new TestTemplateInvocationContext() {
    @Override
    public String getDisplayName(int invocationIndex) {
      return clazz.getSimpleName();
    }

    @Override
    public List<Extension> getAdditionalExtensions() {
      return Arrays.asList(
          new SimpleParameterResolver(clazz),
          new SimpleParameterResolver(message),
          new SimpleParameterResolver(options));
    }
  };
}
 
Example #11
Source Project: doma   Author: domaframework   File: DaoProcessorTest.java    License: Apache License 2.0 6 votes vote down vote up
private TestTemplateInvocationContext invocationContext(Class<?> clazz, String... options) {
  return new TestTemplateInvocationContext() {
    @Override
    public String getDisplayName(int invocationIndex) {
      return clazz.getSimpleName();
    }

    @Override
    public List<Extension> getAdditionalExtensions() {
      return Arrays.asList(
          new SimpleParameterResolver(clazz),
          new ResourceParameterResolver(clazz),
          new GeneratedClassNameParameterResolver(clazz),
          new SimpleParameterResolver(options));
    }
  };
}
 
Example #12
Source Project: doma   Author: domaframework   File: SqlTest.java    License: Apache License 2.0 6 votes vote down vote up
private TestTemplateInvocationContext invocationContext(
    Class<?> clazz, Message message, String... options) {
  return new TestTemplateInvocationContext() {
    @Override
    public String getDisplayName(int invocationIndex) {
      return clazz.getSimpleName();
    }

    @Override
    public List<Extension> getAdditionalExtensions() {
      return Arrays.asList(
          new SimpleParameterResolver(clazz),
          new SimpleParameterResolver(message),
          new SimpleParameterResolver(options));
    }
  };
}
 
Example #13
Source Project: doma   Author: domaframework   File: SingletonConfigProcessorTest.java    License: Apache License 2.0 6 votes vote down vote up
private TestTemplateInvocationContext invocationContext(
    Class<?> clazz, Message message, String... options) {
  return new TestTemplateInvocationContext() {
    @Override
    public String getDisplayName(int invocationIndex) {
      return clazz.getSimpleName();
    }

    @Override
    public List<Extension> getAdditionalExtensions() {
      return Arrays.asList(
          new SimpleParameterResolver(clazz),
          new SimpleParameterResolver(message),
          new SimpleParameterResolver(options));
    }
  };
}
 
Example #14
Source Project: doma   Author: domaframework   File: DomainProcessorTest.java    License: Apache License 2.0 6 votes vote down vote up
private TestTemplateInvocationContext invocationContext(
    Class<?> compilationUnit, String... options) {
  return new TestTemplateInvocationContext() {
    @Override
    public String getDisplayName(int invocationIndex) {
      return compilationUnit.getSimpleName();
    }

    @Override
    public List<Extension> getAdditionalExtensions() {
      return Arrays.asList(
          new SimpleParameterResolver(compilationUnit),
          new ResourceParameterResolver(compilationUnit),
          new GeneratedClassNameParameterResolver(compilationUnit),
          new SimpleParameterResolver(options));
    }
  };
}
 
Example #15
Source Project: doma   Author: domaframework   File: DomainProcessorTest.java    License: Apache License 2.0 6 votes vote down vote up
private TestTemplateInvocationContext invocationContext(
    Class<?> compilationUnit, Class<?> annotatedClass, String... options) {
  return new TestTemplateInvocationContext() {
    @Override
    public String getDisplayName(int invocationIndex) {
      return compilationUnit.getSimpleName();
    }

    @Override
    public List<Extension> getAdditionalExtensions() {
      return Arrays.asList(
          new SimpleParameterResolver(compilationUnit),
          new ResourceParameterResolver(compilationUnit),
          new GeneratedClassNameParameterResolver(annotatedClass),
          new SimpleParameterResolver(options));
    }
  };
}
 
Example #16
Source Project: doma   Author: domaframework   File: DomainProcessorTest.java    License: Apache License 2.0 6 votes vote down vote up
private TestTemplateInvocationContext invocationContext(
    Class<?> clazz, Message message, String... options) {
  return new TestTemplateInvocationContext() {
    @Override
    public String getDisplayName(int invocationIndex) {
      return clazz.getSimpleName();
    }

    @Override
    public List<Extension> getAdditionalExtensions() {
      return Arrays.asList(
          new SimpleParameterResolver(clazz),
          new SimpleParameterResolver(message),
          new SimpleParameterResolver(options));
    }
  };
}
 
Example #17
Source Project: doma   Author: domaframework   File: ExternalDomainProcessorTest.java    License: Apache License 2.0 6 votes vote down vote up
private TestTemplateInvocationContext invocationContext(
    Class<?> compilationUnit, Class<?> externalDomainClass) {
  return new TestTemplateInvocationContext() {
    @Override
    public String getDisplayName(int invocationIndex) {
      return compilationUnit.getSimpleName();
    }

    @Override
    public List<Extension> getAdditionalExtensions() {
      return Arrays.asList(
          new SimpleParameterResolver(compilationUnit),
          new ResourceParameterResolver(compilationUnit),
          new GeneratedClassNameParameterResolver(externalDomainClass, true));
    }
  };
}
 
Example #18
Source Project: doma   Author: domaframework   File: ExternalDomainProcessorTest.java    License: Apache License 2.0 6 votes vote down vote up
private TestTemplateInvocationContext invocationContext(
    Class<?> clazz, Message message, String... options) {
  return new TestTemplateInvocationContext() {
    @Override
    public String getDisplayName(int invocationIndex) {
      return clazz.getSimpleName();
    }

    @Override
    public List<Extension> getAdditionalExtensions() {
      return Arrays.asList(
          new SimpleParameterResolver(clazz),
          new SimpleParameterResolver(message),
          new SimpleParameterResolver(options));
    }
  };
}
 
Example #19
Source Project: junitperf   Author: houbb   File: PerfConfigContext.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public List<Extension> getAdditionalExtensions() {
    return Collections.singletonList(
            (TestInstancePostProcessor) (testInstance, context) -> {
                final Class clazz = testInstance.getClass();
                // Group test contexts by test class
                ACTIVE_CONTEXTS.putIfAbsent(clazz, new ArrayList<>());

                EvaluationContext evaluationContext = new EvaluationContext(testInstance,
                        method,
                        DateUtil.getCurrentDateTimeStr());
                evaluationContext.loadConfig(perfConfig);
                evaluationContext.loadRequire(perfRequire);
                StatisticsCalculator statisticsCalculator = perfConfig.statistics().newInstance();
                Set<Reporter> reporterSet = getReporterSet();
                ACTIVE_CONTEXTS.get(clazz).add(evaluationContext);
                try {
                    new PerformanceEvaluationStatement(evaluationContext,
                            statisticsCalculator,
                            reporterSet,
                            ACTIVE_CONTEXTS.get(clazz),
                            clazz).evaluate();
                } catch (Throwable throwable) {
                    throw new JunitPerfRuntimeException(throwable);
                }
            }
    );
}
 
Example #20
Source Project: nomulus   Author: google   File: DualDatabaseTestInvocationContextProvider.java    License: Apache License 2.0 5 votes vote down vote up
private TestTemplateInvocationContext createInvocationContext(
    String name, Supplier<? extends TransactionManager> tmSupplier) {
  return new TestTemplateInvocationContext() {
    @Override
    public String getDisplayName(int invocationIndex) {
      return name;
    }

    @Override
    public List<Extension> getAdditionalExtensions() {
      return ImmutableList.of(new DatabaseSwitchInvocationContext(tmSupplier));
    }
  };
}
 
Example #21
Source Project: spring-cloud-dataflow   Author: spring-cloud   File: DockerComposeFactory.java    License: Apache License 2.0 5 votes vote down vote up
public static Extension startDockerCompose(Path tempFolder) {

		if (DockerComposeFactoryProperties.isDockerComposeDisabled()) {
			return (BeforeAllCallback) context -> logger.info("Docker Compose installation is disabled!");
		}

		logger.info("{} = {}", DockerComposeFactoryProperties.TEST_DOCKER_COMPOSE_DATAFLOW_VERSIONN,
				DockerComposeFactoryProperties.get(DockerComposeFactoryProperties.TEST_DOCKER_COMPOSE_DATAFLOW_VERSIONN, DEFAULT_DATAFLOW_VERSION));
		logger.info("{} = {}", DockerComposeFactoryProperties.TEST_DOCKER_COMPOSE_SKIPPER_VERSIONN,
				DockerComposeFactoryProperties.get(DockerComposeFactoryProperties.TEST_DOCKER_COMPOSE_SKIPPER_VERSIONN, DEFAULT_SKIPPER_VERSION));
		logger.info("{} = {}", DockerComposeFactoryProperties.TEST_DOCKER_COMPOSE_STREAM_APPS_URI,
				DockerComposeFactoryProperties.get(DockerComposeFactoryProperties.TEST_DOCKER_COMPOSE_STREAM_APPS_URI, DEFAULT_STREAM_APPS_URI));
		logger.info("{} = {}", DockerComposeFactoryProperties.TEST_DOCKER_COMPOSE_TASK_APPS_URI,
				DockerComposeFactoryProperties.get(DockerComposeFactoryProperties.TEST_DOCKER_COMPOSE_TASK_APPS_URI, DEFAULT_TASK_APPS_URI));
		logger.info("{} = {}", DockerComposeFactoryProperties.TEST_DOCKER_COMPOSE_PATHS,
				DockerComposeFactoryProperties.getDockerComposePaths(DEFAULT_DOCKER_COMPOSE_PATHS));

		String[] dockerComposePaths = new ResourceExtractor(tempFolder).extract(
				DockerComposeFactoryProperties.getDockerComposePaths(DEFAULT_DOCKER_COMPOSE_PATHS));
		logger.info("Extracted docker compose files = {}", Arrays.toString(dockerComposePaths));

		return DockerComposeExtension.builder()
				.files(DockerComposeFiles.from(dockerComposePaths))
				.machine(dockerMachine)
				.saveLogsTo("target/dockerLogs/DockerComposeIT")
				.waitingForService("dataflow-server", HealthChecks.toRespond2xxOverHttp(9393,
						(port) -> port.inFormat("http://$HOST:$EXTERNAL_PORT")), org.joda.time.Duration.standardMinutes(10))
				.waitingForService("skipper-server", HealthChecks.toRespond2xxOverHttp(7577,
						(port) -> port.inFormat("http://$HOST:$EXTERNAL_PORT")), org.joda.time.Duration.standardMinutes(10))
				// set to false to test with local dataflow and skipper images.
				.pullOnStartup(DockerComposeFactoryProperties.getBoolean(DockerComposeFactoryProperties.TEST_DOCKER_COMPOSE_PULLONSTARTUP, true))
				.build();
	}
 
Example #22
Source Project: doma   Author: domaframework   File: DaoProcessorTest.java    License: Apache License 2.0 5 votes vote down vote up
private TestTemplateInvocationContext invocationContext(Class<?> clazz, Message message) {
  return new TestTemplateInvocationContext() {
    @Override
    public String getDisplayName(int invocationIndex) {
      return clazz.getSimpleName();
    }

    @Override
    public List<Extension> getAdditionalExtensions() {
      return Arrays.asList(
          new SimpleParameterResolver(clazz), new SimpleParameterResolver(message));
    }
  };
}
 
Example #23
Source Project: java-cloudant   Author: cloudant   File: MultiExtension.java    License: Apache License 2.0 5 votes vote down vote up
public MultiExtension(Extension... extensions) {
    this.extensions = Arrays.asList(extensions);
    // After tests we need to call extensions in the reverse order
    this.reversedExtensions = new ArrayList<>(this.extensions.size());
    this.reversedExtensions.addAll(this.extensions);
    Collections.reverse(reversedExtensions);
}
 
Example #24
Source Project: java-cloudant   Author: cloudant   File: MultiExtension.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void afterAll(ExtensionContext extensionContext) throws Exception {
    for (Extension extension : reversedExtensions) {
        if (extension instanceof AfterAllCallback) {
            ((AfterAllCallback) extension).afterAll(extensionContext);
        }
    }
}
 
Example #25
Source Project: java-cloudant   Author: cloudant   File: MultiExtension.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void afterEach(ExtensionContext extensionContext) throws Exception {
    for (Extension extension : reversedExtensions) {
        if (extension instanceof AfterEachCallback) {
            ((AfterEachCallback) extension).afterEach(extensionContext);
        }
    }
}
 
Example #26
Source Project: java-cloudant   Author: cloudant   File: MultiExtension.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void afterTestExecution(ExtensionContext extensionContext) throws Exception {
    for (Extension extension : reversedExtensions) {
        if (extension instanceof AfterTestExecutionCallback) {
            ((AfterTestExecutionCallback) extension).afterTestExecution(extensionContext);
        }
    }
}
 
Example #27
Source Project: java-cloudant   Author: cloudant   File: MultiExtension.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void beforeAll(ExtensionContext extensionContext) throws Exception {
    for (Extension extension : extensions) {
        if (extension instanceof BeforeAllCallback) {
            ((BeforeAllCallback) extension).beforeAll(extensionContext);
        }
    }
}
 
Example #28
Source Project: java-cloudant   Author: cloudant   File: MultiExtension.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void beforeEach(ExtensionContext extensionContext) throws Exception {
    for (Extension extension : extensions) {
        if (extension instanceof BeforeEachCallback) {
            ((BeforeEachCallback) extension).beforeEach(extensionContext);
        }
    }
}
 
Example #29
Source Project: java-cloudant   Author: cloudant   File: MultiExtension.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void beforeTestExecution(ExtensionContext extensionContext) throws Exception {
    for (Extension extension : extensions) {
        if (extension instanceof BeforeTestExecutionCallback) {
            ((BeforeTestExecutionCallback) extension).beforeTestExecution(extensionContext);
        }
    }
}
 
Example #30
Source Project: fdb-record-layer   Author: FoundationDB   File: DualPlannerExtension.java    License: Apache License 2.0 4 votes vote down vote up
public DualPlannerTestInvocationContext(boolean useRewritePlanner, List<Extension> extensions) {
    this.extensions = new ArrayList<>(extensions);
    this.extensions.add((TestInstancePostProcessor) (testInstance, context) ->
            ((FDBRecordStoreQueryTestBase) testInstance).setUseRewritePlanner(useRewritePlanner));
}