Skip to content

Commit 3be6d5f

Browse files
authored
Merge pull request #385 from box/enableTestLogging
Some changes to enable getting log output from Integration Tests
2 parents 3d11d83 + cfbb4ed commit 3be6d5f

14 files changed

+55
-23
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
gradle/
2+
gradlew
3+
gradlew.bat
14
.gradle/
25
gradle.properties
36
build/

build.gradle

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,24 @@ task sourcesJar(type: Jar) {
8888
task integrationTest(type: Test) {
8989
description 'Runs the integration tests.'
9090
group 'Verification'
91-
91+
testLogging.showStandardStreams = true
9292
useJUnit {
9393
includeCategories 'com.box.sdk.IntegrationTest'
94+
9495
}
9596
}
9697

98+
task integrationTestJWT(type: Test) {
99+
description 'Runs the JWT based integration tests.'
100+
group 'Verification'
101+
testLogging.showStandardStreams = true
102+
useJUnit {
103+
includeCategories 'com.box.sdk.IntegrationTestJWT'
104+
105+
}
106+
}
107+
108+
97109
jacocoTestReport.dependsOn(integrationTest);
98110

99111
tasks.withType(JavaCompile) {
@@ -124,6 +136,7 @@ artifacts {
124136
test {
125137
useJUnit {
126138
excludeCategories 'com.box.sdk.IntegrationTest'
139+
excludeCategories 'com.box.sdk.IntegrationTestJWT'
127140
}
128141
}
129142

src/main/java/com/box/sdk/BoxFile.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -513,13 +513,13 @@ public void uploadVersion(InputStream fileContent, String fileContentSHA1, Date
513513
request.putField("content_modified_at", modified);
514514
}
515515

516-
BoxAPIResponse response;
516+
BoxJSONResponse response;
517517
if (listener == null) {
518-
response = request.send();
518+
response = (BoxJSONResponse) request.send();
519519
} else {
520-
response = request.send(listener);
520+
response = (BoxJSONResponse) request.send(listener);
521521
}
522-
response.disconnect();
522+
response.getJSON();
523523
}
524524

525525
/**

src/main/java/com/box/sdk/BoxFileVersion.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ public void promote() {
224224
BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), url, "POST");
225225
request.setBody(jsonObject.toString());
226226
BoxJSONResponse response = (BoxJSONResponse) request.send();
227-
response.disconnect();
228227
this.parseJSON(JsonObject.readFrom(response.getJSON()));
229228
}
230229
}

src/test/java/com/box/sdk/BoxAPIConnectionTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ public void successfullySavesAndRestoresConnection() {
210210
}
211211

212212
@Test
213-
@Category(IntegrationTest.class)
213+
@Category(IntegrationTestJWT.class)
214214
public void developerEditionAppAuthWorks() {
215215
final String enterpriseId = TestConfig.getEnterpriseID();
216216
final String clientId = TestConfig.getClientID();
@@ -253,7 +253,7 @@ public void developerEditionAppAuthWorks() {
253253
}
254254

255255
@Test
256-
@Category(IntegrationTest.class)
256+
@Category(IntegrationTestJWT.class)
257257
public void developerEditionAppUserWorks() {
258258
final String enterpriseId = TestConfig.getEnterpriseID();
259259
final String clientId = TestConfig.getClientID();

src/test/java/com/box/sdk/BoxCollectionTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,5 +192,6 @@ public void getCollectionItemsSucceeds() {
192192

193193
uploadedFile.setCollections(favorites);
194194
assertThat(favorites, hasItem(Matchers.<BoxItem.Info>hasProperty("ID", equalTo(uploadedFile.getID()))));
195+
uploadedFile.delete();
195196
}
196197
}

src/test/java/com/box/sdk/BoxFileTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ public void addTaskSucceeds() {
846846
byte[] fileBytes = "Non-empty string".getBytes(StandardCharsets.UTF_8);
847847
String taskMessage = "Non-empty message";
848848
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
849-
Date dueAt = new Date();
849+
Date dueAt = new Date(new Date().getTime() + (1000 * 24 * 60 * 60));
850850

851851
InputStream uploadStream = new ByteArrayInputStream(fileBytes);
852852
BoxFile uploadedFile = rootFolder.uploadFile(uploadStream, fileName).getResource();

src/test/java/com/box/sdk/BoxTaskTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,7 @@ public void updateInfoSucceeds() {
559559
Calendar calendar = new GregorianCalendar();
560560
calendar.set(Calendar.SECOND, 0);
561561
calendar.set(Calendar.MILLISECOND, 0);
562+
calendar.add(Calendar.DATE, 1);
562563
Date dueAt = calendar.getTime();
563564

564565
BoxTask.Info taskInfo = uploadedFile.addTask(BoxTask.Action.REVIEW, originalMessage, dueAt);

src/test/java/com/box/sdk/BoxTransactionalAPIConnectionTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
public class BoxTransactionalAPIConnectionTest {
1414
@Test
15-
@Category(IntegrationTest.class)
15+
@Category(IntegrationTestJWT.class)
1616
public void successfullyCreatesTransactionalConnection() {
1717
final String transactionalAccessToken = TestConfig.getTransactionalAccessToken();
1818

@@ -22,7 +22,7 @@ public void successfullyCreatesTransactionalConnection() {
2222
}
2323

2424
@Test
25-
@Category(IntegrationTest.class)
25+
@Category(IntegrationTestJWT.class)
2626
public void successfullyCreatesEmbedLinkWithTransactionalConnection() {
2727
final String transactionalAccessToken = TestConfig.getTransactionalAccessToken();
2828

@@ -55,7 +55,7 @@ public void successfullyCreatesEmbedLinkWithTransactionalConnection() {
5555
}
5656

5757
@Test
58-
@Category(IntegrationTest.class)
58+
@Category(IntegrationTestJWT.class)
5959
public void successfullyCreatesEmbedLinkWithResourceScopedTransactionalConnection() {
6060
final String transactionalAccessToken = TestConfig.getTransactionalAccessToken();
6161

@@ -83,7 +83,7 @@ public void successfullyCreatesEmbedLinkWithResourceScopedTransactionalConnectio
8383
}
8484

8585
@Test(expected = BoxAPIException.class)
86-
@Category(IntegrationTest.class)
86+
@Category(IntegrationTestJWT.class)
8787
public void throwsWhenAttemptingToCreatesEmbedLinkWithAnotherFilesResourceScopedTransactionalConnection() {
8888
final String transactionalAccessToken = TestConfig.getTransactionalAccessToken();
8989

src/test/java/com/box/sdk/BoxUserTest.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,10 @@ public void getCurrentUserInfoIsCorrect() throws InterruptedException {
962962
@Category(IntegrationTest.class)
963963
public void createAndDeleteEnterpriseUserSucceeds() {
964964
BoxAPIConnection api = new BoxAPIConnection(TestConfig.getAccessToken());
965-
final String login = "[email protected]";
965+
// Since deleting users happens in a separate process in the backend
966+
// it is really an asynchronous call. So we have to use a new user in
967+
// this test in case the previous user's deletion hasn't completed.
968+
final String login = "[email protected]";
966969
final String name = "non-empty name";
967970

968971
BoxUser.Info createdUserInfo = BoxUser.createEnterpriseUser(api, login, name);
@@ -998,7 +1001,7 @@ public void getMembershipsHasCorrectMemberships() {
9981001
@Category(IntegrationTest.class)
9991002
public void updateInfoSucceeds() {
10001003
BoxAPIConnection api = new BoxAPIConnection(TestConfig.getAccessToken());
1001-
final String login = "login@box.com";
1004+
final String login = "login3@boz.com";
10021005
final String originalName = "original name";
10031006
final String updatedName = "updated name";
10041007

0 commit comments

Comments
 (0)