Java Code Examples for org.junit.runner.Description#getClassName()

The following examples show how to use org.junit.runner.Description#getClassName() . 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: AsyncFSStorageAgentTest.java    From attic-apex-core with Apache License 2.0 6 votes vote down vote up
@Override
protected void starting(Description description)
{
  super.starting(description);
  basePath = "target/" + description.getClassName() + "/" + description.getMethodName();
  applicationPath = basePath + "/app";
  try {
    FileUtils.forceMkdir(new File(basePath));
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
  storageAgent = new AsyncFSStorageAgent(applicationPath, null);

  Attribute.AttributeMap.DefaultAttributeMap attributes = new Attribute.AttributeMap.DefaultAttributeMap();
  attributes.put(DAG.APPLICATION_PATH, applicationPath);
}
 
Example 2
Source File: ActivitiRule.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
protected void finished(Description description) {

		// Remove the test deployment
		try {
			TestHelper.annotationDeploymentTearDown(processEngine, deploymentId,
			    Class.forName(description.getClassName()), description.getMethodName());
		} catch (ClassNotFoundException e) {
			throw new ActivitiException("Programmatic error: could not instantiate "
			    + description.getClassName(), e);
		}

		// Reset internal clock
		processEngineConfiguration.getClock().reset();

		// Rest mocks
		if (mockSupport != null) {
			TestHelper.annotationMockSupportTeardown(mockSupport);
		}
	}
 
Example 3
Source File: AbstractUnitTest.java    From elasticsearch-shield-kerberos-realm with Apache License 2.0 5 votes vote down vote up
@Override
protected void failed(final Throwable e, final Description description) {
    final String methodName = description.getMethodName();
    String className = description.getClassName();
    className = className.substring(className.lastIndexOf('.') + 1);
    System.out.println(">>>> " + className + " " + methodName + " FAILED due to " + e);
}
 
Example 4
Source File: StateTrackerTest.java    From attic-apex-malhar with Apache License 2.0 5 votes vote down vote up
@Override
protected void starting(Description description)
{
  TestUtils.deleteTargetTestClassFolder(description);
  managedState = new MockManagedStateImpl();
  applicationPath = "target/" + description.getClassName() + "/" + description.getMethodName();
  ((FileAccessFSImpl)managedState.getFileAccess()).setBasePath(applicationPath + "/" + "bucket_data");

  managedState.setNumBuckets(2);
  managedState.setMaxMemorySize(100);

  operatorContext = ManagedStateTestUtils.getOperatorContext(1, applicationPath);
}
 
Example 5
Source File: LoggerContextRule.java    From logging-log4j2 with Apache License 2.0 5 votes vote down vote up
@Override
public Statement apply(final Statement base, final Description description) {
    // Hack: Using -DEBUG as a JVM param sets a property called "EBUG"...
    if (System.getProperties().containsKey("EBUG")) {
        StatusLogger.getLogger().setLevel(Level.DEBUG);
    }
    testClassName = description.getClassName();
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            if (contextSelectorClass != null) {
                System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, contextSelectorClass.getName());
            }
            // TODO Consider instead of the above:
            // LogManager.setFactory(new Log4jContextFactory(LoaderUtil.newInstanceOf(contextSelectorClass)));
            System.setProperty(SYS_PROP_KEY_CLASS_NAME, description.getClassName());
            System.setProperty(SYS_PROP_KEY_DISPLAY_NAME, description.getDisplayName());
            loggerContext = Configurator.initialize(description.getDisplayName(),
                    description.getTestClass().getClassLoader(), configurationLocation);
            try {
                base.evaluate();
            } finally {
                if (!Configurator.shutdown(loggerContext, shutdownTimeout, shutdownTimeUnit)) {
                    StatusLogger.getLogger().error("Logger context {} did not shutdown completely after {} {}.",
                            loggerContext.getName(), shutdownTimeout, shutdownTimeUnit);
                }
                loggerContext = null;
                contextSelectorClass = null;
                StatusLogger.getLogger().reset();
                System.clearProperty(Constants.LOG4J_CONTEXT_SELECTOR);
                System.clearProperty(SYS_PROP_KEY_CLASS_NAME);
                System.clearProperty(SYS_PROP_KEY_DISPLAY_NAME);
            }
        }
    };

}
 
Example 6
Source File: AllureJunit4.java    From allure-java with Apache License 2.0 5 votes vote down vote up
private TestResult createTestResult(final String uuid, final Description description) {
    final String className = description.getClassName();
    final String methodName = description.getMethodName();
    final String name = Objects.nonNull(methodName) ? methodName : className;
    final String fullName = Objects.nonNull(methodName) ? String.format("%s.%s", className, methodName) : className;
    final String suite = Optional.ofNullable(description.getTestClass())
            .map(it -> it.getAnnotation(DisplayName.class))
            .map(DisplayName::value).orElse(className);

    final TestResult testResult = new TestResult()
            .setUuid(uuid)
            .setHistoryId(getHistoryId(description))
            .setFullName(fullName)
            .setName(name);

    testResult.getLabels().addAll(getProvidedLabels());
    testResult.getLabels().addAll(Arrays.asList(
            createPackageLabel(getPackage(description.getTestClass())),
            createTestClassLabel(className),
            createTestMethodLabel(name),
            createSuiteLabel(suite),
            createHostLabel(),
            createThreadLabel(),
            createFrameworkLabel("junit4"),
            createLanguageLabel("java")
    ));
    testResult.getLabels().addAll(extractLabels(description));
    testResult.getLinks().addAll(extractLinks(description));

    getDisplayName(description).ifPresent(testResult::setName);
    getDescription(description).ifPresent(testResult::setDescription);
    return testResult;
}
 
Example 7
Source File: GenericContainer.java    From testcontainers-java with MIT License 5 votes vote down vote up
private TestDescription toDescription(Description description) {
    return new TestDescription() {
        @Override
        public String getTestId() {
            return description.getDisplayName();
        }

        @Override
        public String getFilesystemFriendlyName() {
            return description.getClassName() + "-" + description.getMethodName();
        }
    };
}
 
Example 8
Source File: GetBpmnModelElementTypeRule.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
protected void starting(Description description) {
  String className = description.getClassName();
  className =  className.replaceAll("Test", "");
  Class<? extends ModelElementInstance> instanceClass = null;
  try {
    instanceClass = (Class<? extends ModelElementInstance>) Class.forName(className);
  } catch (ClassNotFoundException e) {
    throw new RuntimeException(e);
  }
  modelInstance = Bpmn.createEmptyModel();
  model = modelInstance.getModel();
  modelElementType = model.getType(instanceClass);
}
 
Example 9
Source File: FlowableFormRule.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected void finished(Description description) {

        // Remove the test deployment
        try {
            FormTestHelper.annotationDeploymentTearDown(formEngine, deploymentId, Class.forName(description.getClassName()), description.getMethodName());
        } catch (ClassNotFoundException e) {
            throw new FlowableException("Programmatic error: could not instantiate " + description.getClassName(), e);
        }
    }
 
Example 10
Source File: AllureRunListener.java    From allure-cucumberjvm with Apache License 2.0 5 votes vote down vote up
public void startFakeTestCase(Description description) throws IllegalAccessException {
    String uid = getSuiteUid(description);

    String name = description.isTest() ? description.getMethodName() : description.getClassName();
    TestCaseStartedEvent event = new TestCaseStartedEvent(uid, name);
    event.setTitle(name);
    AnnotationManager am = new AnnotationManager(description.getAnnotations());
    am.update(event);

    getLifecycle().fire(event);
}
 
Example 11
Source File: FlowableDmnRule.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected void finished(Description description) {

        // Remove the test deployment
        try {
            DmnTestHelper.annotationDeploymentTearDown(dmnEngine, deploymentId, Class.forName(description.getClassName()), description.getMethodName());
        } catch (ClassNotFoundException e) {
            throw new FlowableException("Programmatic error: could not instantiate " + description.getClassName(), e);
        }
    }
 
Example 12
Source File: GetBpmnModelElementTypeRule.java    From camunda-bpmn-model with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
protected void starting(Description description) {
  String className = description.getClassName();
  className =  className.replaceAll("Test", "");
  Class<? extends ModelElementInstance> instanceClass = null;
  try {
    instanceClass = (Class<? extends ModelElementInstance>) Class.forName(className);
  } catch (ClassNotFoundException e) {
    throw new RuntimeException(e);
  }
  modelInstance = Bpmn.createEmptyModel();
  model = modelInstance.getModel();
  modelElementType = model.getType(instanceClass);
}
 
Example 13
Source File: HttpClientTracingHandlerIntegrationTest.java    From xio with Apache License 2.0 5 votes vote down vote up
@Override
protected void starting(final Description description) {
  String methodName = description.getMethodName();
  String className = description.getClassName();
  className = className.substring(className.lastIndexOf('.') + 1);
  // System.out.println("Starting JUnit-test: " + className + " " + methodName);
}
 
Example 14
Source File: TestRequestBuilder.java    From android-test with Apache License 2.0 5 votes vote down vote up
@Override
public boolean evaluateTest(Description description) {
  if (methodFilters.isEmpty()) {
    return true;
  }
  String className = description.getClassName();
  MethodFilter methodFilter = methodFilters.get(className);
  if (methodFilter != null) {
    return methodFilter.shouldRun(description);
  }
  // This test class was not explicitly excluded and none of it's test methods were
  // explicitly included or excluded. Should be run, return true:
  return true;
}
 
Example 15
Source File: RtgTestEntry.java    From rtg-tools with BSD 2-Clause "Simplified" License 4 votes vote down vote up
static String testName(Description description) {
  return description.getClassName() + "." + description.getMethodName();
}
 
Example 16
Source File: SQSStringInputOperatorTest.java    From attic-apex-malhar with Apache License 2.0 4 votes vote down vote up
@Override
protected void starting(Description description)
{
  final String methodName = description.getMethodName();
  final String className = description.getClassName();

  testBase = new SQSTestBase();
  if (testBase.validateTestCreds() == false) {
    return;
  }
  testBase.generateCurrentQueueName(methodName);
  try {
    testBase.beforTest();
  } catch (AssumptionViolatedException ave) {
    throw ave;
  } catch (Exception e) {
    throw new RuntimeException(e);
  }

  baseDir = "target/" + className + "/" + methodName;

  Attribute.AttributeMap attributeMap = new Attribute.AttributeMap.DefaultAttributeMap();
  attributeMap.put(Context.OperatorContext.SPIN_MILLIS, 500);
  attributeMap.put(Context.DAGContext.APPLICATION_PATH, baseDir);

  context = mockOperatorContext(1, attributeMap);
  operator = new JMSStringInputOperator();
  operator.setConnectionFactoryBuilder(new JMSBase.ConnectionFactoryBuilder()
  {

    @Override
    public ConnectionFactory buildConnectionFactory()
    {
      // Create the connection factory using the environment variable credential provider.
      // Connections this factory creates can talk to the queues in us-east-1 region.
      SQSConnectionFactory connectionFactory =
          SQSConnectionFactory.builder()
          .withRegion(Region.getRegion(Regions.US_EAST_1))
          .withAWSCredentialsProvider(new PropertiesFileCredentialsProvider(testBase.getDevCredsFilePath()))
          .build();
      return connectionFactory;
    }

    @Override
    public String toString()
    {
      return className + "/" + methodName + "/ConnectionFactoryBuilder";
    }

  });
  operator.setSubject(testBase.getCurrentQueueName());
  // for SQS ack mode should be "AUTO_ACKNOWLEDGE" and transacted = false
  operator.setAckMode("AUTO_ACKNOWLEDGE");
  operator.setTransacted(false);

  sink = new CollectorTestSink<>();
  operator.output.setSink(sink);
  operator.setup(context);
  operator.activate(context);
}
 
Example 17
Source File: BaseTestServer.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
private String desc(Description description) {
  return description.getClassName() + "." +  description.getMethodName();
}
 
Example 18
Source File: TemporaryJobJsonReports.java    From helios with Apache License 2.0 4 votes vote down vote up
public ReportWriter getWriterForTest(final Description testDescription) {
  return new JsonReportWriter(
      outputDir, testDescription.getClassName(), testDescription.getMethodName());
}
 
Example 19
Source File: DremioTest.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
@Override
protected void starting(Description description) {
  super.starting(description);
  className = description.getClassName();
  memWatcher = new MemWatcher();
}
 
Example 20
Source File: ResultHolder.java    From JPPF with Apache License 2.0 2 votes vote down vote up
/**
 * Determine whether this result holder already has the specified test.
 * @param desc the description of th etest to look for.
 * @return <code>true</code> if the test already exists, <code>false</code> otherwise.
 */
public boolean hasTest(final Description desc) {
  final String name = desc.getClassName() + "." + desc.getMethodName();
  return tests.contains(name);
}