org.jvnet.hudson.test.Bug Java Examples

The following examples show how to use org.jvnet.hudson.test.Bug. 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: DockerTraceabilityReportListenerImplTest.java    From docker-traceability-plugin with MIT License 6 votes vote down vote up
/**
 * Checks the resolution of imageId from previously saved data.
 * @throws Exception test failure
 */
@Bug(28752)
public void submitReportWithoutImageReference() throws Exception {
    DockerTraceabilityPluginTest.configure(new DockerTraceabilityPluginConfiguration(true, true));
    final String imageId = FingerprintTestUtil.generateDockerId("1");
    final Event event1 = new DockerEvent("run", imageId, "host", 12345).toDockerEvent();
    final Event event2 = new DockerEvent("die", imageId, "host", 12346).toDockerEvent();
    final InspectContainerResponse containerInfo = JSONSamples.inspectContainerData_emptyImage.
            readObject(InspectContainerResponse.class);
    
    DockerTraceabilityReport r1 = new DockerTraceabilityReport(event1, null, containerInfo, imageId, null, null, 
            new LinkedList<String>(), null);
    DockerTraceabilityReport r2 = new DockerTraceabilityReport(event2, null, containerInfo, null, null, null, 
            new LinkedList<String>(), null);
    
    // Spawn two reports
    DockerTraceabilityReportListener.fire(r1);
    DockerTraceabilityReportListener.fire(r2);
    
    // Retrieve
    final DockerDeploymentFacet facet = 
        DockerFingerprints.getFacet(containerInfo.getId(), DockerDeploymentFacet.class);
    assertNotNull(facet);
    assertEquals(imageId, facet.getImageId());
    assertEquals("Expected both reports to be saved in the fingerprint", 2, facet.getDeploymentRecords().size());     
}
 
Example #2
Source File: FlakySuiteResultTest.java    From flaky-test-handler-plugin with Apache License 2.0 6 votes vote down vote up
@Bug(1233)
public void testIssue1233() throws Exception {
  FlakySuiteResult result = parseOne(getDataFile("junit-report-1233.xml"));

  List<FlakyCaseResult> cases = result.getCases();
  assertEquals("Class name is incorrect", "test.foo.bar.DefaultIntegrationTest",
      cases.get(0).getClassName());
  assertEquals("Class name is incorrect", "test.foo.bar.BundleResolverIntegrationTest",
      cases.get(1).getClassName());
  assertEquals("Class name is incorrect", "test.foo.bar.BundleResolverIntegrationTest",
      cases.get(2).getClassName());
  assertEquals("Class name is incorrect", "test.foo.bar.ProjectSettingsTest",
      cases.get(3).getClassName());
  assertEquals("Class name is incorrect", "test.foo.bar.ProjectSettingsTest",
      cases.get(4).getClassName());
}
 
Example #3
Source File: FlakySuiteResultTest.java    From flaky-test-handler-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * JUnit report file is generated by SoapUI Pro 1.7.6
 */
@Bug(1463)
public void testIssue1463() throws Exception {
  FlakySuiteResult result = parseOne(getDataFile("junit-report-1463.xml"));

  List<FlakyCaseResult> cases = result.getCases();
  for (FlakyCaseResult caseResult : cases) {
    assertEquals("Test class name is incorrect in " + caseResult.getName(), "WLI-FI-Tests-Fake",
        caseResult.getClassName());
  }
  assertEquals("Test name is incorrect", "IF_importTradeConfirmationToDwh",
      cases.get(0).getName());
  assertEquals("Test name is incorrect", "IF_getAmartaDisbursements", cases.get(1).getName());
  assertEquals("Test name is incorrect", "IF_importGLReconDataToDwh", cases.get(2).getName());
  assertEquals("Test name is incorrect", "IF_importTradeInstructionsToDwh",
      cases.get(3).getName());
  assertEquals("Test name is incorrect", "IF_getDeviationTradeInstructions",
      cases.get(4).getName());
  assertEquals("Test name is incorrect", "IF_getDwhGLData", cases.get(5).getName());
}
 
Example #4
Source File: DockerTraceabilityRootActionTest.java    From docker-traceability-plugin with MIT License 5 votes vote down vote up
@Test
@Bug(28656)
public void createFingerPrintsOnDemand() throws Exception {
    // Read data from resources
    String inspectData = JSONSamples.inspectContainerData.readString();
    InspectContainerResponse inspectResponse = JSONSamples.inspectContainerData.
            readObject(InspectContainerResponse[].class)[0];
    final String containerId = inspectResponse.getId();
    final String imageId = inspectResponse.getImageId();
    
    // Retrieve instances
    final DockerTraceabilityRootAction action = DockerTraceabilityRootAction.getInstance();
    assertNotNull(action);
    
    // Enable automatic fingerprints creation
    DockerTraceabilityPluginConfiguration config = new DockerTraceabilityPluginConfiguration(true, false);
    DockerTraceabilityPluginTest.configure(config);
    DockerTraceabilityPlugin plugin = DockerTraceabilityPlugin.getInstance();
    assertTrue(plugin.getConfiguration().isCreateImageFingerprints());
    
    // Submit JSON
    HttpResponse res = action.doSubmitContainerStatus(inspectData, null, null, null, 0, null, null);
    
    // Ensure that both container and images have been created with proper facets
    Fingerprint imageFP = DockerFingerprints.of(imageId);
    Fingerprint containerFP = DockerFingerprints.of(containerId);
    assertNotNull(imageFP);
    assertNotNull(DockerFingerprints.getFacet(imageFP, DockerDeploymentRefFacet.class));
    assertNotNull(containerFP);
    assertNotNull(DockerFingerprints.getFacet(containerFP, DockerDeploymentFacet.class));
    
    // TODO: JENKINS-28655 (Fingerprints cleanup)
    // Check original references - Docker Traceability Manager should create runs
    // assertNotNull(imageFP.getOriginal().getJob());
    // assertNotNull(containerFP.getOriginal().getJob());
}
 
Example #5
Source File: TestResultTest.java    From junit-plugin with MIT License 5 votes vote down vote up
@Bug(12457)
public void testTestSuiteDistributedOverMultipleFilesIsCountedAsOne() throws IOException, URISyntaxException {
    TestResult testResult = new TestResult();
    testResult.parse(getDataFile("JENKINS-12457/TestSuite_a1.xml"), null);
    testResult.parse(getDataFile("JENKINS-12457/TestSuite_a2.xml"), null);
    testResult.tally();
    
    assertEquals("Wrong number of testsuites", 1, testResult.getSuites().size());
    assertEquals("Wrong number of test cases", 2, testResult.getTotalCount());
    
    // check duration: 157.980 (TestSuite_a1.xml) and 15.000 (TestSuite_a2.xml) = 172.98 
    assertEquals("Wrong duration for test result", 172.98, testResult.getDuration(), 0.1);
}
 
Example #6
Source File: FlakyTestResultTest.java    From flaky-test-handler-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * When test methods are parametrized, they can occur multiple times in the testresults XMLs. Test
 * that these are counted correctly.
 */
@Bug(13214)
public void testDuplicateTestMethods() throws IOException, URISyntaxException {
  FlakyTestResult testResult = new FlakyTestResult();
  testResult.parse(getDataFile("JENKINS-13214/27449.xml"));
  testResult.parse(getDataFile("JENKINS-13214/27540.xml"));
  testResult.parse(getDataFile("JENKINS-13214/29734.xml"));
  testResult.tally();

  assertEquals("Wrong number of test suites", 1, testResult.getSuites().size());
  assertEquals("Wrong number of test cases", 3, testResult.getTotalCount());
}
 
Example #7
Source File: FlakyTestResultTest.java    From flaky-test-handler-plugin with Apache License 2.0 5 votes vote down vote up
@Bug(12457)
public void testTestSuiteDistributedOverMultipleFilesIsCountedAsOne()
    throws IOException, URISyntaxException {
  FlakyTestResult testResult = new FlakyTestResult();
  testResult.parse(getDataFile("JENKINS-12457/TestSuite_a1.xml"));
  testResult.parse(getDataFile("JENKINS-12457/TestSuite_a2.xml"));
  testResult.tally();

  assertEquals("Wrong number of testsuites", 1, testResult.getSuites().size());
  assertEquals("Wrong number of test cases", 2, testResult.getTotalCount());

  // check duration: 157.980 (TestSuite_a1.xml) and 15.000 (TestSuite_a2.xml) = 172.98
  assertEquals("Wrong duration for test result", 172.98, testResult.getDuration(), 0.1);
}
 
Example #8
Source File: FlakySuiteResultTest.java    From flaky-test-handler-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * JUnit report produced by TAP (Test Anything Protocol)
 */
@Bug(1472)
public void testIssue1472() throws Exception {
  List<FlakySuiteResult> results = FlakySuiteResult
      .parse(getDataFile("junit-report-1472.xml"), false);
  assertTrue(results.size() > 20); // lots of data here

  FlakySuiteResult sr0 = results.get(0);
  FlakySuiteResult sr1 = results.get(1);
  assertEquals("make_test.t_basic_lint_t", sr0.getName());
  assertEquals("make_test.t_basic_meta_t", sr1.getName());
  assertTrue(!sr0.getStdout().equals(sr1.getStdout()));
}
 
Example #9
Source File: FlakySuiteResultTest.java    From flaky-test-handler-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * When the testcase fails to initialize (exception in constructor or @Before) there is no
 * 'testcase' element at all.
 */
@Bug(6700)
public void testErrorInTestInitialization() throws Exception {
  FlakySuiteResult FlakySuiteResult = parseOne(getDataFile("junit-report-6700.xml"));

  assertEquals(1, FlakySuiteResult.getCases().size());

  FlakyCaseResult result = FlakySuiteResult.getCases().get(0);
  assertEquals(1, result.getFailCount());
  assertTrue(result.getErrorStackTrace() != null);
}
 
Example #10
Source File: FlakySuiteResultTest.java    From flaky-test-handler-plugin with Apache License 2.0 5 votes vote down vote up
@Bug(6454)
public void testParseNestedTestSuites() throws Exception {
  // A report with several nested suites
  // 3 of them have actual some tests - each exactly one
  List<FlakySuiteResult> results = parseSuites(getDataFile("junit-report-nested-testsuites.xml"));
  assertEquals(3, results.size());

  for (FlakySuiteResult result : results) {
    assertEquals(1, result.getCases().size());
  }
}
 
Example #11
Source File: FlakySuiteResultTest.java    From flaky-test-handler-plugin with Apache License 2.0 4 votes vote down vote up
@Bug(2874)
public void testIssue2874() throws Exception {
  FlakySuiteResult result = parseOne(getDataFile("junit-report-2874.xml"));

  assertEquals("test suite name", "DummyTest", result.getName());
}