Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVioleta Georgieva2015-02-18 03:04:18 -0500
committerVioleta Georgieva2015-02-18 03:10:24 -0500
commit9a016eebbcb69d4296dd06e401b418dc75db9d67 (patch)
treeda030cbe81a0463d95ee3bcf6629c80e6d1d966d
parente389a75303a63fb760dfc70d17896467f108d411 (diff)
downloadorg.eclipse.gemini.naming-9a016eebbcb69d4296dd06e401b418dc75db9d67.tar.gz
org.eclipse.gemini.naming-9a016eebbcb69d4296dd06e401b418dc75db9d67.tar.xz
org.eclipse.gemini.naming-9a016eebbcb69d4296dd06e401b418dc75db9d67.zip
Tests: Fix potential NPE.
-rw-r--r--integration-testing/src/test/java/org/eclipse/gemini/naming/test/ContextManagerTestCase.java6
-rw-r--r--integration-testing/src/test/java/org/eclipse/gemini/naming/test/FactoryResolutionTestCase.java10
2 files changed, 11 insertions, 5 deletions
diff --git a/integration-testing/src/test/java/org/eclipse/gemini/naming/test/ContextManagerTestCase.java b/integration-testing/src/test/java/org/eclipse/gemini/naming/test/ContextManagerTestCase.java
index 11d5e20..a8b708c 100644
--- a/integration-testing/src/test/java/org/eclipse/gemini/naming/test/ContextManagerTestCase.java
+++ b/integration-testing/src/test/java/org/eclipse/gemini/naming/test/ContextManagerTestCase.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Oracle.
+ * Copyright (c) 2010, 2015 Oracle.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
@@ -93,7 +93,9 @@ public class ContextManagerTestCase extends NamingTestCase {
assertEquals("Factory Manager did not return the expected factory",
expectedBindingValue, initialContext.lookup(expectedBindingName));
} finally {
- initialContext.close();
+ if (initialContext != null) {
+ initialContext.close();
+ }
}
// attempt the same test from the context manager service
diff --git a/integration-testing/src/test/java/org/eclipse/gemini/naming/test/FactoryResolutionTestCase.java b/integration-testing/src/test/java/org/eclipse/gemini/naming/test/FactoryResolutionTestCase.java
index bea202d..9ae8f71 100644
--- a/integration-testing/src/test/java/org/eclipse/gemini/naming/test/FactoryResolutionTestCase.java
+++ b/integration-testing/src/test/java/org/eclipse/gemini/naming/test/FactoryResolutionTestCase.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2013 Oracle.
+ * Copyright (c) 2012, 2015 Oracle.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
@@ -108,7 +108,9 @@ public class FactoryResolutionTestCase extends NamingTestCase {
try {
context = new InitialContext(environment);
} finally {
- context.close();
+ if (context != null) {
+ context.close();
+ }
}
}
@@ -366,7 +368,9 @@ public class FactoryResolutionTestCase extends NamingTestCase {
assertEquals("Incorrect value returned by context factory",
expectedLookupValue, context.lookup(expectedLookupName));
} finally {
- context.close();
+ if (context != null) {
+ context.close();
+ }
serviceRegistration.unregister();
}

Back to the top