Skip to content

Commit

Permalink
Added a new IntegrationTest type for JWT tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dmaynard authored and Greg Curtis committed Feb 13, 2017
1 parent 0a43984 commit cfbb4ed
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 17 deletions.
12 changes: 12 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,17 @@ task integrationTest(type: Test) {
}
}

task integrationTestJWT(type: Test) {
description 'Runs the JWT based integration tests.'
group 'Verification'
testLogging.showStandardStreams = true
useJUnit {
includeCategories 'com.box.sdk.IntegrationTestJWT'

}
}


jacocoTestReport.dependsOn(integrationTest);

tasks.withType(JavaCompile) {
Expand Down Expand Up @@ -125,6 +136,7 @@ artifacts {
test {
useJUnit {
excludeCategories 'com.box.sdk.IntegrationTest'
excludeCategories 'com.box.sdk.IntegrationTestJWT'
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/box/sdk/BoxFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -515,9 +515,9 @@ public void uploadVersion(InputStream fileContent, String fileContentSHA1, Date

BoxJSONResponse response;
if (listener == null) {
response = (BoxJSONResponse)request.send();
response = (BoxJSONResponse) request.send();
} else {
response = (BoxJSONResponse)request.send(listener);
response = (BoxJSONResponse) request.send(listener);
}
response.getJSON();
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/box/sdk/BoxAPIConnectionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public void successfullySavesAndRestoresConnection() {
}

@Test
@Category(IntegrationTest.class)
@Category(IntegrationTestJWT.class)
public void developerEditionAppAuthWorks() {
final String enterpriseId = TestConfig.getEnterpriseID();
final String clientId = TestConfig.getClientID();
Expand Down Expand Up @@ -253,7 +253,7 @@ public void developerEditionAppAuthWorks() {
}

@Test
@Category(IntegrationTest.class)
@Category(IntegrationTestJWT.class)
public void developerEditionAppUserWorks() {
final String enterpriseId = TestConfig.getEnterpriseID();
final String clientId = TestConfig.getClientID();
Expand Down
3 changes: 1 addition & 2 deletions src/test/java/com/box/sdk/BoxFileTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
import java.util.logging.Logger;

import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasItem;
Expand Down Expand Up @@ -847,7 +846,7 @@ public void addTaskSucceeds() {
byte[] fileBytes = "Non-empty string".getBytes(StandardCharsets.UTF_8);
String taskMessage = "Non-empty message";
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
Date dueAt = new Date(new Date().getTime()+1000*24*60*60);
Date dueAt = new Date(new Date().getTime() + (1000 * 24 * 60 * 60));

InputStream uploadStream = new ByteArrayInputStream(fileBytes);
BoxFile uploadedFile = rootFolder.uploadFile(uploadStream, fileName).getResource();
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/box/sdk/BoxTaskTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ public void updateInfoSucceeds() {
Calendar calendar = new GregorianCalendar();
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
calendar.add(Calendar.DATE,1);
calendar.add(Calendar.DATE, 1);
Date dueAt = calendar.getTime();

BoxTask.Info taskInfo = uploadedFile.addTask(BoxTask.Action.REVIEW, originalMessage, dueAt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

public class BoxTransactionalAPIConnectionTest {
@Test
@Category(IntegrationTest.class)
@Category(IntegrationTestJWT.class)
public void successfullyCreatesTransactionalConnection() {
final String transactionalAccessToken = TestConfig.getTransactionalAccessToken();

Expand All @@ -22,7 +22,7 @@ public void successfullyCreatesTransactionalConnection() {
}

@Test
@Category(IntegrationTest.class)
@Category(IntegrationTestJWT.class)
public void successfullyCreatesEmbedLinkWithTransactionalConnection() {
final String transactionalAccessToken = TestConfig.getTransactionalAccessToken();

Expand Down Expand Up @@ -55,7 +55,7 @@ public void successfullyCreatesEmbedLinkWithTransactionalConnection() {
}

@Test
@Category(IntegrationTest.class)
@Category(IntegrationTestJWT.class)
public void successfullyCreatesEmbedLinkWithResourceScopedTransactionalConnection() {
final String transactionalAccessToken = TestConfig.getTransactionalAccessToken();

Expand Down Expand Up @@ -83,7 +83,7 @@ public void successfullyCreatesEmbedLinkWithResourceScopedTransactionalConnectio
}

@Test(expected = BoxAPIException.class)
@Category(IntegrationTest.class)
@Category(IntegrationTestJWT.class)
public void throwsWhenAttemptingToCreatesEmbedLinkWithAnotherFilesResourceScopedTransactionalConnection() {
final String transactionalAccessToken = TestConfig.getTransactionalAccessToken();

Expand Down
5 changes: 2 additions & 3 deletions src/test/java/com/box/sdk/BoxUserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Logger;

import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
Expand Down Expand Up @@ -966,7 +965,7 @@ public void createAndDeleteEnterpriseUserSucceeds() {
// Since deleting users happens in a separate process in the backend
// it is really an asynchronous call. So we have to use a new user in
// this test in case the previous user's deletion hasn't completed.
final String login = "login2@box.com";
final String login = "login2@boz.com";
final String name = "non-empty name";

BoxUser.Info createdUserInfo = BoxUser.createEnterpriseUser(api, login, name);
Expand Down Expand Up @@ -1002,7 +1001,7 @@ public void getMembershipsHasCorrectMemberships() {
@Category(IntegrationTest.class)
public void updateInfoSucceeds() {
BoxAPIConnection api = new BoxAPIConnection(TestConfig.getAccessToken());
final String login = "login3@box.com";
final String login = "login3@boz.com";
final String originalName = "original name";
final String updatedName = "updated name";

Expand Down
1 change: 0 additions & 1 deletion src/test/java/com/box/sdk/BoxWebHookTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.logging.Logger;
import java.util.Set;

import static org.hamcrest.Matchers.equalTo;
Expand Down
2 changes: 0 additions & 2 deletions src/test/java/com/box/sdk/EventStreamTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;

import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
Expand All @@ -29,7 +28,6 @@ public class EventStreamTest {
@Test
@Category(IntegrationTest.class)
public void receiveEventsForFolderCreateAndFolderDelete() throws InterruptedException {
// Logger logger = TestConfig.setLogLevel("FINE");
final LinkedBlockingQueue<BoxEvent> observedEvents = new LinkedBlockingQueue<BoxEvent>();
BoxAPIConnection api = new BoxAPIConnection(TestConfig.getAccessToken());
EventStream stream = new EventStream(api);
Expand Down
7 changes: 7 additions & 0 deletions src/test/java/com/box/sdk/IntegrationTestJWT.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.box.sdk;

/**
* Created by dmaynard on 2/9/17.
*/
public interface IntegrationTestJWT {
}

0 comments on commit cfbb4ed

Please sign in to comment.