47
47
public class ITSystemTest {
48
48
49
49
private static LanguageServiceClient client ;
50
+ private static final String GCS_BUCKET ;
51
+ private static final String GCS_BUCKET_ENV_VAR = "GOOGLE_CLOUD_TESTS_LANGUAGE_BUCKET" ;
52
+
53
+ static {
54
+ if (System .getenv (GCS_BUCKET_ENV_VAR ) != null ) {
55
+ GCS_BUCKET = System .getenv (GCS_BUCKET_ENV_VAR );
56
+ } else {
57
+ GCS_BUCKET = "cloud-samples-data" ;
58
+ }
59
+ }
60
+
50
61
private static final String ANALYZE_TEXT =
51
62
"Android is a mobile operating system developed by Google, based on the Linux kernel and designed primarily for touchscreen mobile devices such as smartphones and tablets." ;
52
63
@@ -64,7 +75,7 @@ public void tearDown() {
64
75
public void analyzeEntitiesFileTest () {
65
76
Document doc =
66
77
Document .newBuilder ()
67
- .setGcsContentUri ("gs://cloud-samples-data /language/android.txt" )
78
+ .setGcsContentUri (String . format ( "gs://%s /language/android.txt" , GCS_BUCKET ) )
68
79
.setType (Type .PLAIN_TEXT )
69
80
.build ();
70
81
AnalyzeEntitiesRequest request = AnalyzeEntitiesRequest .newBuilder ().setDocument (doc ).build ();
@@ -104,7 +115,7 @@ public void analyzeEntitiesTextTest() {
104
115
public void analyzeEntitySentimentFileTest () {
105
116
Document doc =
106
117
Document .newBuilder ()
107
- .setGcsContentUri ("gs://cloud-samples-data /language/president.txt" )
118
+ .setGcsContentUri (String . format ( "gs://%s /language/president.txt" , GCS_BUCKET ) )
108
119
.setType (Type .PLAIN_TEXT )
109
120
.build ();
110
121
AnalyzeEntitySentimentRequest request =
@@ -163,7 +174,7 @@ public void analyzeEntitySentimentTextWithEncodedExpectedResultTest() {
163
174
public void analyzeSentimentFileWithReturnPositiveTest () {
164
175
Document doc =
165
176
Document .newBuilder ()
166
- .setGcsContentUri ("gs://cloud-samples-data /language/sentiment-positive.txt" )
177
+ .setGcsContentUri (String . format ( "gs://%s /language/sentiment-positive.txt" , GCS_BUCKET ) )
167
178
.setType (Type .PLAIN_TEXT )
168
179
.build ();
169
180
AnalyzeSentimentResponse response = client .analyzeSentiment (doc );
@@ -188,7 +199,7 @@ public void analyzeSentimentTextWithReturnPositiveTest() {
188
199
public void analyzeSentimentFileWithReturnNegativeTest () {
189
200
Document doc =
190
201
Document .newBuilder ()
191
- .setGcsContentUri ("gs://cloud-samples-data /language/sentiment-negative.txt" )
202
+ .setGcsContentUri (String . format ( "gs://%s /language/sentiment-negative.txt" , GCS_BUCKET ) )
192
203
.setType (Type .PLAIN_TEXT )
193
204
.build ();
194
205
Sentiment sentiment = client .analyzeSentiment (doc ).getDocumentSentiment ();
@@ -212,7 +223,7 @@ public void analyzeSentimentTextWithReturnNegativeTest() {
212
223
public void analyzeSyntaxFileTest () {
213
224
Document doc =
214
225
Document .newBuilder ()
215
- .setGcsContentUri ("gs://cloud-samples-data /language/syntax-sentence.txt" )
226
+ .setGcsContentUri (String . format ( "gs://%s /language/syntax-sentence.txt" , GCS_BUCKET ) )
216
227
.setType (Type .PLAIN_TEXT )
217
228
.build ();
218
229
AnalyzeSyntaxRequest request =
@@ -255,7 +266,7 @@ public void analyzeSyntaxTextTest() {
255
266
public void classifyFileTest () {
256
267
Document doc =
257
268
Document .newBuilder ()
258
- .setGcsContentUri ("gs://cloud-samples-data /language/android.txt" )
269
+ .setGcsContentUri (String . format ( "gs://%s /language/android.txt" , GCS_BUCKET ) )
259
270
.setType (Type .PLAIN_TEXT )
260
271
.build ();
261
272
ClassifyTextRequest request = ClassifyTextRequest .newBuilder ().setDocument (doc ).build ();
0 commit comments