Skip to content

Commit 44a9118

Browse files
committed
add try/catch
1 parent e72e7cb commit 44a9118

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

bigtable/src/test/java/com/m/examples/bigtable/InstanceAdminExampleTest.java

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@
1212
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
15-
*/
15+
*/
1616

1717
package com.m.examples.bigtable;
1818

1919
import static org.junit.Assert.assertFalse;
2020
import static org.junit.Assert.assertNotNull;
2121
import static org.junit.Assert.assertTrue;
22+
import static org.junit.Assert.fail;
2223

2324
import com.google.api.gax.rpc.NotFoundException;
2425
import com.google.cloud.bigtable.admin.v2.BigtableInstanceAdminClient;
@@ -39,7 +40,9 @@
3940
import org.junit.BeforeClass;
4041
import org.junit.Test;
4142

42-
/** Integration tests for {@link InstanceAdminExample} */
43+
/**
44+
* Integration tests for {@link InstanceAdminExample}
45+
*/
4346
public class InstanceAdminExampleTest {
4447

4548
private static final String ID_PREFIX = "instanceadmin";
@@ -91,18 +94,22 @@ public void after() {
9194
}
9295

9396
@Test
94-
public void testCreateAndDeleteInstance() throws IOException {
97+
public void testCreateAndDeleteInstance() {
9598
// Creates an instance.
9699
String testInstance = generateId();
97100
String testCluster = generateId();
98-
InstanceAdminExample testInstanceAdmin =
99-
new InstanceAdminExample(projectId, testInstance, testCluster);
100-
testInstanceAdmin.createProdInstance();
101-
assertTrue(adminClient.exists(testInstance));
102-
103-
// Deletes an instance.
104-
testInstanceAdmin.deleteInstance();
105-
assertFalse(adminClient.exists(testInstance));
101+
try {
102+
InstanceAdminExample testInstanceAdmin =
103+
new InstanceAdminExample(projectId, testInstance, testCluster);
104+
testInstanceAdmin.createProdInstance();
105+
assertTrue(adminClient.exists(testInstance));
106+
// Deletes an instance.
107+
testInstanceAdmin.deleteInstance();
108+
assertFalse(adminClient.exists(testInstance));
109+
} catch (Exception e) {
110+
e.printStackTrace();
111+
fail();
112+
}
106113
}
107114

108115
@Test

0 commit comments

Comments
 (0)