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 File: EntityProcessorTest.java    From doma with 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 #2
Source File: SqlTest.java    From doma with 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 #3
Source File: DaoProcessorTest.java    From doma with 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 #4
Source File: EmbeddableProcessorTest.java    From doma with 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 #5
Source File: EmbeddableProcessorTest.java    From doma with 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 #6
Source File: EmbeddableProcessorTest.java    From doma with 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 #7
Source File: MetamodelOptionTest.java    From doma with 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 File: MetamodelTest.java    From doma with 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 #9
Source File: MetamodelTest.java    From doma with 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 #10
Source File: MetamodelTest.java    From doma with 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 #11
Source File: EntityProcessorTest.java    From doma with 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 #12
Source File: EntityProcessorTest.java    From doma with 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 #13
Source File: SingletonConfigProcessorTest.java    From doma with 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 File: DomainProcessorTest.java    From doma with 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 File: DomainProcessorTest.java    From doma with 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 File: DomainProcessorTest.java    From doma with 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 File: ExternalDomainProcessorTest.java    From doma with 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 File: ExternalDomainProcessorTest.java    From doma with 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 File: MultiExtension.java    From java-cloudant with 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 #20
Source File: MultiExtension.java    From java-cloudant with 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 #21
Source File: MultiExtension.java    From java-cloudant with 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 #22
Source File: DaoProcessorTest.java    From doma with 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 File: MultiExtension.java    From java-cloudant with 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 #24
Source File: MultiExtension.java    From java-cloudant with 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 #25
Source File: DockerComposeFactory.java    From spring-cloud-dataflow with 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 #26
Source File: DualDatabaseTestInvocationContextProvider.java    From nomulus with 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 #27
Source File: MultiExtension.java    From java-cloudant with 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 #28
Source File: MultiExtension.java    From java-cloudant with 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 #29
Source File: PerfConfigContext.java    From junitperf with 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 #30
Source File: DualPlannerExtension.java    From fdb-record-layer with 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));
}