Skip to content

Commit

Permalink
Merge pull request #10 from Runer112/dev/issue-2
Browse files Browse the repository at this point in the history
Issue #2: Fixed to use new String(license.getText()).
  • Loading branch information
romeara committed Jan 11, 2016
2 parents 4817f59 + a65dd69 commit 30cd30a
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

/**
* This sample gathers the data to generate the report section "License Texts"
*
*
* It demonstrates:
* - How to get the license info for a Bill of Material (BOM)
* - How to retrieve a license by ID (including the license text)
Expand Down Expand Up @@ -100,7 +100,7 @@ public static void main(String[] args) throws Exception {

if (license != null) {
System.out.println("*** " + license.getName() + "*** ");
System.out.println(license.getText());
System.out.println(new String(license.getText()));
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package com.blackducksoftware.sdk.protex.client.examples.test;

import java.io.File;

import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import com.blackducksoftware.sdk.protex.client.examples.report.SampleReportDataLicenseText;
import com.blackducksoftware.sdk.protex.client.examples.test.type.AbstractSdkSampleTest;
import com.blackducksoftware.sdk.protex.client.examples.test.type.TestSources;
import com.blackducksoftware.sdk.protex.client.examples.test.type.Tests;
import com.blackducksoftware.sdk.protex.license.LicenseCategory;
import com.blackducksoftware.sdk.protex.project.AnalysisSourceLocation;
import com.blackducksoftware.sdk.protex.project.ProjectRequest;

public class SampleReportDataLicenseTextTest extends AbstractSdkSampleTest {

private String projectId;

@BeforeClass
protected void createProject() throws Exception {
ProjectRequest projectRequest = new ProjectRequest();
projectRequest.setName("SampleReportDataLicenseTextTest Project");

AnalysisSourceLocation sourceLocation = TestSources.getAnalysisSourceLocation(getProxy());

projectRequest.setAnalysisSourceLocation(sourceLocation);
projectRequest.setLicenseId("gpl20");

projectId = getProxy().getProjectApi().createProject(projectRequest, LicenseCategory.OPEN_SOURCE);

TestSources.synchronousSourceScan(getProxy(), projectId, 1000);
}

@Test(groups = { Tests.SOURCE_DEPENDENT_TEST })
public void runSample() throws Exception {
File tempFile = File.createTempFile("thing", ".html");

String[] args = new String[4];
args[0] = Tests.getServerUrl();
args[1] = Tests.getServerUsername();
args[2] = Tests.getServerPassword();
args[3] = projectId;

SampleReportDataLicenseText.main(args);

tempFile.deleteOnExit();
}

@AfterClass(alwaysRun = true)
protected void deleteProject() throws Exception {
if (projectId != null) {
getProxy().getProjectApi().deleteProject(projectId);
}
}

}

0 comments on commit 30cd30a

Please sign in to comment.