You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by jo...@apache.org on 2006/08/14 22:40:57 UTC
svn commit: r431431 - in /webservices/commons/trunk/modules/neethi:
src/main/assembly/ src/test/java/org/apache/ws/policy/
src/test/test-resources/ src/test/test2/
src/test/test2/org/apache/ws/policy/ src/test/test3/
src/test/test3/org/apache/neethi/ t...
Author: jochen
Date: Mon Aug 14 13:40:55 2006
New Revision: 431431
URL: http://svn.apache.org/viewvc?rev=431431&view=rev
Log:
Moved the test-resource, test2 and test3 directories to src/test, in order
to meet the Maven 2 standards.
Added:
webservices/commons/trunk/modules/neethi/src/test/test-resources/
- copied from r431230, webservices/commons/trunk/modules/neethi/test-resources/
webservices/commons/trunk/modules/neethi/src/test/test2/
- copied from r431230, webservices/commons/trunk/modules/neethi/test2/
webservices/commons/trunk/modules/neethi/src/test/test3/
- copied from r431230, webservices/commons/trunk/modules/neethi/test3/
Removed:
webservices/commons/trunk/modules/neethi/test/
webservices/commons/trunk/modules/neethi/test-resources/
webservices/commons/trunk/modules/neethi/test2/
webservices/commons/trunk/modules/neethi/test3/
Modified:
webservices/commons/trunk/modules/neethi/src/main/assembly/src.xml
webservices/commons/trunk/modules/neethi/src/test/java/org/apache/ws/policy/PolicyTestCase.java
webservices/commons/trunk/modules/neethi/src/test/test2/org/apache/ws/policy/Test_EffectivePolicy.java
webservices/commons/trunk/modules/neethi/src/test/test2/org/apache/ws/policy/Test_JIRA14.java
webservices/commons/trunk/modules/neethi/src/test/test2/org/apache/ws/policy/Test_Policy.java
webservices/commons/trunk/modules/neethi/src/test/test3/org/apache/neethi/MergeTest.java
webservices/commons/trunk/modules/neethi/src/test/test3/org/apache/neethi/NormalizeTest.java
webservices/commons/trunk/modules/neethi/src/test/test3/org/apache/neethi/PolicyTestCase.java
Modified: webservices/commons/trunk/modules/neethi/src/main/assembly/src.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/assembly/src.xml?rev=431431&r1=431430&r2=431431&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/assembly/src.xml (original)
+++ webservices/commons/trunk/modules/neethi/src/main/assembly/src.xml Mon Aug 14 13:40:55 2006
@@ -24,14 +24,5 @@
<fileSet>
<directory>src</directory>
</fileSet>
- <fileSet>
- <directory>test2</directory>
- </fileSet>
- <fileSet>
- <directory>test3</directory>
- </fileSet>
- <fileSet>
- <directory>test-resources</directory>
- </fileSet>
</fileSets>
</assembly>
Modified: webservices/commons/trunk/modules/neethi/src/test/java/org/apache/ws/policy/PolicyTestCase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/test/java/org/apache/ws/policy/PolicyTestCase.java?rev=431431&r1=431430&r2=431431&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/test/java/org/apache/ws/policy/PolicyTestCase.java (original)
+++ webservices/commons/trunk/modules/neethi/src/test/java/org/apache/ws/policy/PolicyTestCase.java Mon Aug 14 13:40:55 2006
@@ -24,19 +24,17 @@
public class PolicyTestCase extends TestCase {
protected String baseDir = System.getProperty("basedir");
- protected String testDir = "test" + File.separator;
- protected String testResourceDir = "test-resources";
+ protected String testResourceDir = "src" + File.separator + "test" + File.separator + "test-resources";
public PolicyTestCase(String name) {
super(name);
if (baseDir == null) {
- baseDir = (String) (new File(".")).getAbsolutePath();
+ baseDir = (String) new File(".").getAbsolutePath();
}
- testDir = (String) (new File(baseDir, testDir).getAbsolutePath());
- }
-
+ }
+
public InputStream getResource(String name) {
- String filePath = (new File(testResourceDir, name)).getAbsolutePath();
+ String filePath = new File(testResourceDir, name).getAbsolutePath();
try {
FileInputStream fis = new FileInputStream(filePath);
return fis;
@@ -46,4 +44,3 @@
}
}
}
-
Modified: webservices/commons/trunk/modules/neethi/src/test/test2/org/apache/ws/policy/Test_EffectivePolicy.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/test/test2/org/apache/ws/policy/Test_EffectivePolicy.java?rev=431431&r1=431230&r2=431431&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/test/test2/org/apache/ws/policy/Test_EffectivePolicy.java (original)
+++ webservices/commons/trunk/modules/neethi/src/test/test2/org/apache/ws/policy/Test_EffectivePolicy.java Mon Aug 14 13:40:55 2006
@@ -1,21 +1,18 @@
package org.apache.ws.policy;
-import java.io.File;
-import java.io.FileInputStream;
+import java.io.InputStream;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import javax.xml.namespace.QName;
-import junit.framework.TestCase;
-
import org.apache.ws.policy.attachment.WSDLPolicyProcessor;
import org.apache.ws.policy.util.PolicyFactory;
import org.apache.ws.policy.util.PolicyReader;
import org.apache.ws.policy.util.PolicyRegistry;
-public class Test_EffectivePolicy extends TestCase {
+public class Test_EffectivePolicy extends PolicyTestCase {
public Test_EffectivePolicy(String name) {
super(name);
@@ -24,14 +21,9 @@
public void testService() {
try {
- String wsdlFile = "EffectivePolicy_Service.wsdl";
- String sep = System.getProperty("file.separator");
- File file = new File("test-resources" + sep + "base" + sep
- + wsdlFile);
- // Read this in as an InputStream
- FileInputStream fIS = new FileInputStream(file);
+ InputStream in = getResource("base/EffectivePolicy_Service.wsdl");
// TODO: You get a NPException when you do the following ...
- WSDLPolicyProcessor wpp = new WSDLPolicyProcessor(fIS);
+ WSDLPolicyProcessor wpp = new WSDLPolicyProcessor(in);
// But the following avoid it.
// WSDLPolicyProcessor wpp = new WSDLPolicyProcessor(fIS, new
// PolicyRegistry());
@@ -84,14 +76,9 @@
public void testEndpoint() {
try {
- String wsdlFile = "EffectivePolicy_Endpoint.wsdl";
- String sep = System.getProperty("file.separator");
- File file = new File("test-resources" + sep + "base" + sep
- + wsdlFile);
- // Read this in as an InputStream
- FileInputStream fIS = new FileInputStream(file);
+ InputStream in = getResource("base/EffectivePolicy_Endpoint.wsdl");
// TODO: You get a NPException when you do the following ...
- WSDLPolicyProcessor wpp = new WSDLPolicyProcessor(fIS);
+ WSDLPolicyProcessor wpp = new WSDLPolicyProcessor(in);
// But the following avoid it.
// WSDLPolicyProcessor wpp = new WSDLPolicyProcessor(fIS, new
// PolicyRegistry());
@@ -144,14 +131,9 @@
public void testOperation() {
try {
- String wsdlFile = "EffectivePolicy_Operation.wsdl";
- String sep = System.getProperty("file.separator");
- File file = new File("test-resources" + sep + "base" + sep
- + wsdlFile);
- // Read this in as an InputStream
- FileInputStream fIS = new FileInputStream(file);
+ InputStream in = getResource("base/EffectivePolicy_Operation.wsdl");
// TODO: You get a NPException when you do the following ...
- WSDLPolicyProcessor wpp = new WSDLPolicyProcessor(fIS);
+ WSDLPolicyProcessor wpp = new WSDLPolicyProcessor(in);
// But the following avoid it.
// WSDLPolicyProcessor wpp = new WSDLPolicyProcessor(fIS, new
// PolicyRegistry());
@@ -204,13 +186,8 @@
public void testOperation_EmptyBinding() {
try {
- String wsdlFile = "EffectivePolicy_Operation_EmptyBinding.wsdl";
- String sep = System.getProperty("file.separator");
- File file = new File("test-resources" + sep + "base" + sep
- + wsdlFile);
- // Read this in as an InputStream
- FileInputStream fIS = new FileInputStream(file);
- WSDLPolicyProcessor wpp = new WSDLPolicyProcessor(fIS);
+ InputStream in = getResource("base/EffectivePolicy_Operation_EmptyBinding.wsdl");
+ WSDLPolicyProcessor wpp = new WSDLPolicyProcessor(in);
String ns = "http://policy.tests.webservices.com";
QName service = new QName(ns, "MyService");
@@ -260,13 +237,8 @@
public void testInput() {
try {
- String wsdlFile = "EffectivePolicy_Input.wsdl";
- String sep = System.getProperty("file.separator");
- File file = new File("test-resources" + sep + "base" + sep
- + wsdlFile);
- // Read this in as an InputStream
- FileInputStream fIS = new FileInputStream(file);
- WSDLPolicyProcessor wpp = new WSDLPolicyProcessor(fIS);
+ InputStream in = getResource("base/EffectivePolicy_Input.wsdl");
+ WSDLPolicyProcessor wpp = new WSDLPolicyProcessor(in);
String ns = "http://policy.tests.webservices.com";
QName service = new QName(ns, "MyService");
@@ -317,14 +289,9 @@
public void testInput_NotNamed() {
try {
- String wsdlFile = "EffectivePolicy_InputNotNamed.wsdl";
- String sep = System.getProperty("file.separator");
- File file = new File("test-resources" + sep + "base" + sep
- + wsdlFile);
- // Read this in as an InputStream
- FileInputStream fIS = new FileInputStream(file);
+ InputStream in = getResource("base/EffectivePolicy_InputNotNamed.wsdl");
// TODO: You get a NPException when you do the following ...
- WSDLPolicyProcessor wpp = new WSDLPolicyProcessor(fIS);
+ WSDLPolicyProcessor wpp = new WSDLPolicyProcessor(in);
// But the following avoid it.
// WSDLPolicyProcessor wpp = new WSDLPolicyProcessor(fIS, new
// PolicyRegistry());
@@ -377,14 +344,9 @@
public void testOutput() {
try {
- String wsdlFile = "EffectivePolicy_Output.wsdl";
- String sep = System.getProperty("file.separator");
- File file = new File("test-resources" + sep + "base" + sep
- + wsdlFile);
- // Read this in as an InputStream
- FileInputStream fIS = new FileInputStream(file);
+ InputStream in = getResource("base/EffectivePolicy_Output.wsdl");
// TODO: You get a NPException when you do the following ...
- WSDLPolicyProcessor wpp = new WSDLPolicyProcessor(fIS);
+ WSDLPolicyProcessor wpp = new WSDLPolicyProcessor(in);
// But the following avoid it.
// WSDLPolicyProcessor wpp = new WSDLPolicyProcessor(fIS, new
// PolicyRegistry());
@@ -437,14 +399,9 @@
public void testOutput_NotNamed() {
try {
- String wsdlFile = "EffectivePolicy_OutputNotNamed.wsdl";
- String sep = System.getProperty("file.separator");
- File file = new File("test-resources" + sep + "base" + sep
- + wsdlFile);
- // Read this in as an InputStream
- FileInputStream fIS = new FileInputStream(file);
+ InputStream in = getResource("base/EffectivePolicy_OutputNotNamed.wsdl");
// TODO: You get a NPException when you do the following ...
- WSDLPolicyProcessor wpp = new WSDLPolicyProcessor(fIS);
+ WSDLPolicyProcessor wpp = new WSDLPolicyProcessor(in);
// But the following avoid it.
// WSDLPolicyProcessor wpp = new WSDLPolicyProcessor(fIS, new
// PolicyRegistry());
@@ -496,15 +453,14 @@
}
/*
- * TODO Faults should be named ... public void testFault() { try { String
- * wsdlFile = "EffectivePolicy_Fault.wsdl"; String sep =
- * System.getProperty("file.separator"); File file = new
- * File("test-resources" + sep + "base" + sep + wsdlFile); // Read this in
- * as an InputStream FileInputStream fIS = new FileInputStream(file); //
- * TODO: You get a NPException when you do the following ... //
- * WSDLPolicyProcessor wpp = new WSDLPolicyProcessor(fIS);
- * WSDLPolicyProcessor wpp = new WSDLPolicyProcessor(fIS, new
- * PolicyRegistry());
+ * TODO Faults should be named ...
+ * public void testFault() {
+ * try {
+ * InputStream in = getResource("base/EffectivePolicy_Fault.wsdl");
+ * TODO: You get a NPException when you do the following ...
+ * // WSDLPolicyProcessor wpp = new WSDLPolicyProcessor(in);
+ * WSDLPolicyProcessor wpp = new WSDLPolicyProcessor(in,
+ * new PolicyRegistry());
*
* String ns = "http://policy.tests.webservices.com"; QName service = new
* QName(ns, "MyService"); Iterator it = null;
@@ -543,21 +499,15 @@
public void testNoPolicies() {
try {
- String wsdlFile = "EffectivePolicy_NoPolicies.wsdl";
- String sep = System.getProperty("file.separator");
- File file = new File("test-resources" + sep + "base" + sep
- + wsdlFile);
- // Read this in as an InputStream
- FileInputStream fIS = new FileInputStream(file);
+ InputStream in = getResource("base/EffectivePolicy_NoPolicies.wsdl");
// TODO: You get a NPException when you do the following ...
- WSDLPolicyProcessor wpp = new WSDLPolicyProcessor(fIS);
+ WSDLPolicyProcessor wpp = new WSDLPolicyProcessor(in);
// But the following avoid it.
// WSDLPolicyProcessor wpp = new WSDLPolicyProcessor(fIS, new
// PolicyRegistry());
String ns = "http://policy.tests.webservices.com";
QName service = new QName(ns, "MyService");
- Iterator it = null;
Policy normPolService = wpp.getEffectiveServicePolicy(service);
assertTrue("Service Policy should be null", normPolService == null);
@@ -616,9 +566,7 @@
assertions.add(logTimeReference);
yearDayPolicy.addTerms(assertions);
- File f = new File(
- "test-resources/base/EffectivePolicy_ImportedPolicies.xml");
- FileInputStream in = new FileInputStream(f);
+ InputStream in = getResource("base/EffectivePolicy_ImportedPolicies.xml");
PolicyReader pReader = PolicyFactory
.getPolicyReader(PolicyFactory.OM_POLICY_READER);
Policy hourAndDay = pReader.readPolicy(in);
@@ -630,15 +578,10 @@
"http://policy.tests.webservices.com/HourAndDay",
hourAndDay);
- String wsdlFile = "EffectivePolicy_ServicePartial.wsdl";
- String sep = System.getProperty("file.separator");
- File file = new File("test-resources" + sep + "base" + sep
- + wsdlFile);
- // Read this in as an InputStream
- FileInputStream fIS = new FileInputStream(file);
+ in = getResource("base/EffectivePolicy_ServicePartial.wsdl");
// TODO: You get a NPException when you do the following ...
// WSDLPolicyProcessor wpp = new WSDLPolicyProcessor(fIS);
- WSDLPolicyProcessor wpp = new WSDLPolicyProcessor(fIS, myRegistry);
+ WSDLPolicyProcessor wpp = new WSDLPolicyProcessor(in, myRegistry);
String ns = "http://policy.tests.webservices.com";
QName service = new QName(ns, "MyService");
Modified: webservices/commons/trunk/modules/neethi/src/test/test2/org/apache/ws/policy/Test_JIRA14.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/test/test2/org/apache/ws/policy/Test_JIRA14.java?rev=431431&r1=431230&r2=431431&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/test/test2/org/apache/ws/policy/Test_JIRA14.java (original)
+++ webservices/commons/trunk/modules/neethi/src/test/test2/org/apache/ws/policy/Test_JIRA14.java Mon Aug 14 13:40:55 2006
@@ -18,17 +18,16 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
+import java.io.InputStream;
import java.util.Hashtable;
import javax.xml.namespace.QName;
-import junit.framework.TestCase;
-
import org.apache.ws.policy.util.PolicyFactory;
import org.apache.ws.policy.util.PolicyReader;
import org.apache.ws.policy.util.PolicyWriter;
-public class Test_JIRA14 extends TestCase {
+public class Test_JIRA14 extends PolicyTestCase {
QName q1 = new QName("http://www.apache.org/policyTest", "q1");
QName q2 = new QName("http://www.apache.org/policyTest", "q2");
@@ -144,7 +143,6 @@
pol.addAttribute(q4, "Fourth");
Hashtable attributes = pol.getAttributes();
- String value = null;
assertTrue("Attribute number check [" + attributes.size() + "]",
attributes.size() == 5);
@@ -201,8 +199,7 @@
public void testReadAttributes() {
try {
- File f = new File("test-resources/base/Policy_Optional_MixedNested.xml");
- FileInputStream in = new FileInputStream(f);
+ InputStream in = getResource("base/Policy_Optional_MixedNested.xml");
PolicyReader pReader = PolicyFactory
.getPolicyReader(PolicyFactory.OM_POLICY_READER);
Policy pol = pReader.readPolicy(in);
@@ -216,8 +213,7 @@
assertTrue("Attribute C INCORRECT", pol.getAttribute(qNameC).equals("C"));
// Now do the same for DOM ...
- f = new File("test-resources/base/Policy_Optional_MixedNested.xml");
- in = new FileInputStream(f);
+ in = getResource("base/Policy_Optional_MixedNested.xml");
pReader = PolicyFactory.getPolicyReader(PolicyFactory.DOM_POLICY_READER);
pol = pReader.readPolicy(in);
@@ -235,7 +231,7 @@
// Read it back ... it should have the same attributes
in = new FileInputStream(tempFile);
pReader = PolicyFactory.getPolicyReader(PolicyFactory.OM_POLICY_READER);
- Policy polRead = pReader.readPolicy(in);
+ pReader.readPolicy(in);
assertTrue("Attribute B INCORRECT", pol.getAttribute(qNameB).equals("B"));
assertTrue("Attribute A INCORRECT", pol.getAttribute(qNameA).equals("A"));
Modified: webservices/commons/trunk/modules/neethi/src/test/test2/org/apache/ws/policy/Test_Policy.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/test/test2/org/apache/ws/policy/Test_Policy.java?rev=431431&r1=431230&r2=431431&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/test/test2/org/apache/ws/policy/Test_Policy.java (original)
+++ webservices/commons/trunk/modules/neethi/src/test/test2/org/apache/ws/policy/Test_Policy.java Mon Aug 14 13:40:55 2006
@@ -15,22 +15,19 @@
*/
package org.apache.ws.policy;
-import java.io.File;
-import java.io.FileInputStream;
+import java.io.InputStream;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
-import java.util.Vector;
import javax.xml.namespace.QName;
-import junit.framework.TestCase;
-
import org.apache.ws.policy.util.PolicyComparator;
import org.apache.ws.policy.util.PolicyFactory;
import org.apache.ws.policy.util.PolicyReader;
-public class Test_Policy extends TestCase {
+
+public class Test_Policy extends PolicyTestCase {
Policy pol4, pol5, pol6, pol7;
@@ -53,8 +50,7 @@
public void testAlternatives_AllEmpty() {
try {
- File f = new File("test-resources/base/Policy_Alternatives_AllEmpty.xml");
- FileInputStream in = new FileInputStream(f);
+ InputStream in = getResource("base/Policy_Alternatives_AllEmpty.xml");
PolicyReader pReader = PolicyFactory
.getPolicyReader(PolicyFactory.DOM_POLICY_READER);
Policy pol = pReader.readPolicy(in);
@@ -72,8 +68,7 @@
public void testAlternatives_EOEmpty() {
try {
- File f = new File("test-resources/base/Policy_Alternatives_EOEmpty.xml");
- FileInputStream in = new FileInputStream(f);
+ InputStream in = getResource("base/Policy_Alternatives_EOEmpty.xml");
PolicyReader pReader = PolicyFactory
.getPolicyReader(PolicyFactory.OM_POLICY_READER);
Policy pol = pReader.readPolicy(in);
@@ -90,9 +85,7 @@
public void testAlternatives_PolicyEmpty() {
try {
- File f = new File(
- "test-resources/base/Policy_Alternatives_PolicyEmpty.xml");
- FileInputStream in = new FileInputStream(f);
+ InputStream in = getResource("base/Policy_Alternatives_PolicyEmpty.xml");
PolicyReader pReader = PolicyFactory
.getPolicyReader(PolicyFactory.OM_POLICY_READER);
Policy pol = pReader.readPolicy(in);
@@ -111,9 +104,7 @@
public void testAlternatives_AllSingle() {
try {
- File f = new File(
- "test-resources/base/Policy_Alternatives_AllSingle.xml");
- FileInputStream in = new FileInputStream(f);
+ InputStream in = getResource("base/Policy_Alternatives_AllSingle.xml");
PolicyReader pReader = PolicyFactory
.getPolicyReader(PolicyFactory.DOM_POLICY_READER);
Policy pol = pReader.readPolicy(in);
@@ -148,8 +139,7 @@
public void testAlternatives_EOSingle() {
try {
- File f = new File("test-resources/base/Policy_Alternatives_EOSingle.xml");
- FileInputStream in = new FileInputStream(f);
+ InputStream in = getResource("base/Policy_Alternatives_EOSingle.xml");
PolicyReader pReader = PolicyFactory
.getPolicyReader(PolicyFactory.DOM_POLICY_READER);
Policy pol = pReader.readPolicy(in);
@@ -184,9 +174,7 @@
public void testAlternatives_PolicySingle() {
try {
- File f = new File(
- "test-resources/base/Policy_Alternatives_PolicySingle.xml");
- FileInputStream in = new FileInputStream(f);
+ InputStream in = getResource("base/Policy_Alternatives_PolicySingle.xml");
PolicyReader pReader = PolicyFactory
.getPolicyReader(PolicyFactory.OM_POLICY_READER);
Policy pol = pReader.readPolicy(in);
@@ -220,8 +208,7 @@
public void testAlternatives_AllMany() {
try {
- File f = new File("test-resources/base/Policy_Alternatives_AllMany.xml");
- FileInputStream in = new FileInputStream(f);
+ InputStream in = getResource("base/Policy_Alternatives_AllMany.xml");
PolicyReader pReader = PolicyFactory
.getPolicyReader(PolicyFactory.DOM_POLICY_READER);
Policy pol = pReader.readPolicy(in);
@@ -274,8 +261,7 @@
public void testAlternatives_EOMany() {
try {
- File f = new File("test-resources/base/Policy_Alternatives_EOMany.xml");
- FileInputStream in = new FileInputStream(f);
+ InputStream in = getResource("base/Policy_Alternatives_EOMany.xml");
PolicyReader pReader = PolicyFactory
.getPolicyReader(PolicyFactory.OM_POLICY_READER);
Policy pol = pReader.readPolicy(in);
@@ -336,9 +322,7 @@
public void testAlternatives_PolicyMany() {
try {
- File f = new File(
- "test-resources/base/Policy_Alternatives_PolicyMany.xml");
- FileInputStream in = new FileInputStream(f);
+ InputStream in = getResource("base/Policy_Alternatives_PolicyMany.xml");
PolicyReader pReader = PolicyFactory
.getPolicyReader(PolicyFactory.OM_POLICY_READER);
Policy pol = pReader.readPolicy(in);
@@ -391,9 +375,7 @@
public void testAlternatives_AllNested() {
try {
- File f = new File(
- "test-resources/base/Policy_Alternatives_AllNested.xml");
- FileInputStream in = new FileInputStream(f);
+ InputStream in = getResource("base/Policy_Alternatives_AllNested.xml");
PolicyReader pReader = PolicyFactory
.getPolicyReader(PolicyFactory.DOM_POLICY_READER);
Policy pol = pReader.readPolicy(in);
@@ -453,8 +435,7 @@
public void testAlternatives_EONested() {
try {
- File f = new File("test-resources/base/Policy_Alternatives_EONested.xml");
- FileInputStream in = new FileInputStream(f);
+ InputStream in = getResource("base/Policy_Alternatives_EONested.xml");
PolicyReader pReader = PolicyFactory
.getPolicyReader(PolicyFactory.DOM_POLICY_READER);
Policy pol = pReader.readPolicy(in);
@@ -524,9 +505,7 @@
public void testAlternatives_PolicyNested() {
try {
- File f = new File(
- "test-resources/base/Policy_Alternatives_PolicyNested.xml");
- FileInputStream in = new FileInputStream(f);
+ InputStream in = getResource("base/Policy_Alternatives_PolicyNested.xml");
PolicyReader pReader = PolicyFactory
.getPolicyReader(PolicyFactory.DOM_POLICY_READER);
Policy pol = pReader.readPolicy(in);
@@ -584,14 +563,11 @@
public void testAlternatives_MixedNested() {
try {
- File f = new File(
- "test-resources/base/Policy_Alternatives_MixedNested.xml");
- FileInputStream in = new FileInputStream(f);
+ InputStream in = getResource("base/Policy_Alternatives_MixedNested.xml");
PolicyReader pReader = PolicyFactory
.getPolicyReader(PolicyFactory.DOM_POLICY_READER);
Policy pol = pReader.readPolicy(in);
- Vector expectedVocab = new Vector();
QName qNameHour = new QName(TestConstants.NAMESPACE_CAL,
TestConstants.ASSERTION_HOUR);
QName qNameMonth = new QName(TestConstants.NAMESPACE_CAL,
@@ -649,13 +625,11 @@
public void testOptional_AllSingle() {
try {
- File f = new File("test-resources/base/Policy_Optional_AllSingle.xml");
- FileInputStream in = new FileInputStream(f);
+ InputStream in = getResource("base/Policy_Optional_AllSingle.xml");
PolicyReader pReader = PolicyFactory
.getPolicyReader(PolicyFactory.DOM_POLICY_READER);
Policy pol = pReader.readPolicy(in);
- Vector expectedVocab = new Vector();
QName qNameHour = new QName(TestConstants.NAMESPACE_CAL,
TestConstants.ASSERTION_HOUR);
@@ -689,13 +663,11 @@
public void testOptional_EOSingle() {
try {
- File f = new File("test-resources/base/Policy_Optional_EOSingle.xml");
- FileInputStream in = new FileInputStream(f);
+ InputStream in = getResource("base/Policy_Optional_EOSingle.xml");
PolicyReader pReader = PolicyFactory
.getPolicyReader(PolicyFactory.DOM_POLICY_READER);
Policy pol = pReader.readPolicy(in);
- Vector expectedVocab = new Vector();
QName qNameHour = new QName(TestConstants.NAMESPACE_CAL,
TestConstants.ASSERTION_HOUR);
@@ -729,13 +701,11 @@
public void testOptional_PolicySingle() {
try {
- File f = new File("test-resources/base/Policy_Optional_PolicySingle.xml");
- FileInputStream in = new FileInputStream(f);
+ InputStream in = getResource("base/Policy_Optional_PolicySingle.xml");
PolicyReader pReader = PolicyFactory
.getPolicyReader(PolicyFactory.DOM_POLICY_READER);
Policy pol = pReader.readPolicy(in);
- Vector expectedVocab = new Vector();
QName qNameHour = new QName(TestConstants.NAMESPACE_CAL,
TestConstants.ASSERTION_HOUR);
@@ -769,8 +739,7 @@
public void testOptional_AllMany() {
try {
- File f = new File("test-resources/base/Policy_Optional_AllMany.xml");
- FileInputStream in = new FileInputStream(f);
+ InputStream in = getResource("base/Policy_Optional_AllMany.xml");
PolicyReader pReader = PolicyFactory
.getPolicyReader(PolicyFactory.DOM_POLICY_READER);
Policy pol = pReader.readPolicy(in);
@@ -834,8 +803,7 @@
public void testOptional_EOMany() {
try {
- File f = new File("test-resources/base/Policy_Optional_EOMany.xml");
- FileInputStream in = new FileInputStream(f);
+ InputStream in = getResource("base/Policy_Optional_EOMany.xml");
PolicyReader pReader = PolicyFactory
.getPolicyReader(PolicyFactory.DOM_POLICY_READER);
Policy pol = pReader.readPolicy(in);
@@ -903,8 +871,7 @@
public void testOptional_PolicyMany() {
try {
- File f = new File("test-resources/base/Policy_Optional_PolicyMany.xml");
- FileInputStream in = new FileInputStream(f);
+ InputStream in = getResource("base/Policy_Optional_PolicyMany.xml");
PolicyReader pReader = PolicyFactory
.getPolicyReader(PolicyFactory.DOM_POLICY_READER);
Policy pol = pReader.readPolicy(in);
@@ -966,9 +933,7 @@
public void testOptional_MixedNested() {
try {
-
- File f = new File("test-resources/base/Policy_Optional_MixedNested.xml");
- FileInputStream in = new FileInputStream(f);
+ InputStream in = getResource("base/Policy_Optional_MixedNested.xml");
PolicyReader pReader = PolicyFactory
.getPolicyReader(PolicyFactory.DOM_POLICY_READER);
Policy pol = pReader.readPolicy(in);
@@ -1073,8 +1038,7 @@
public void testOptional_Explosion() {
try {
- File f = new File("test-resources/base/Policy_Optional_Explosion.xml");
- FileInputStream in = new FileInputStream(f);
+ InputStream in = getResource("base/Policy_Optional_Explosion.xml");
PolicyReader pReader = PolicyFactory
.getPolicyReader(PolicyFactory.OM_POLICY_READER);
Policy pol = pReader.readPolicy(in);
@@ -1083,7 +1047,7 @@
long alternativesCount = 0;
while (it.hasNext()) {
- List alternative = (List) it.next();
+ assertTrue(it.next() instanceof List);
alternativesCount++;
}
assertTrue("Number of Alternatives [" + alternativesCount + "] should be 65536", alternativesCount == 65536);
@@ -1096,8 +1060,7 @@
public void testAlternatives_Duplicates() {
try {
- File f = new File("test-resources/base/Policy_Alternatives_Duplicates.xml");
- FileInputStream in = new FileInputStream(f);
+ InputStream in = getResource("base/Policy_Alternatives_Duplicates.xml");
PolicyReader pReader = PolicyFactory
.getPolicyReader(PolicyFactory.OM_POLICY_READER);
Policy pol = pReader.readPolicy(in);
@@ -1239,7 +1202,6 @@
pol.addAttribute(q4, "Fourth");
Hashtable attributes = pol.getAttributes();
- String value = null;
assertTrue("Attribute number check [" + attributes.size() + "]",
attributes.size() == 5);
@@ -1260,12 +1222,10 @@
try {
PolicyReader pReader = PolicyFactory
.getPolicyReader(PolicyFactory.OM_POLICY_READER);
- File f = new File("test-resources/base/Policy_Equality1.xml");
- FileInputStream in = new FileInputStream(f);
+ InputStream in = getResource("base/Policy_Equality1.xml");
Policy pol1 = pReader.readPolicy(in);
- f = new File("test-resources/base/Policy_Equality2.xml");
- in = new FileInputStream(f);
+ in = getResource("base/Policy_Equality2.xml");
Policy pol2 = pReader.readPolicy(in);
assertTrue("Comparator: Policy1 should be EQUAL to Policy2",
Modified: webservices/commons/trunk/modules/neethi/src/test/test3/org/apache/neethi/MergeTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/test/test3/org/apache/neethi/MergeTest.java?rev=431431&r1=431230&r2=431431&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/test/test3/org/apache/neethi/MergeTest.java (original)
+++ webservices/commons/trunk/modules/neethi/src/test/test3/org/apache/neethi/MergeTest.java Mon Aug 14 13:40:55 2006
@@ -49,9 +49,9 @@
r2 = "samples2" + File.separator + "Policy" + f2 + ".xml";
r3 = "merged" + File.separator + f;
- p1 = PolicyEngine.getPolicy(getResource(r1));
- p2 = PolicyEngine.getPolicy(getResource(r2));
- p3 = PolicyEngine.getPolicy(getResource(r3));
+ p1 = PolicyEngine.getPolicy(getResourceAsElement(r1));
+ p2 = PolicyEngine.getPolicy(getResourceAsElement(r2));
+ p3 = PolicyEngine.getPolicy(getResourceAsElement(r3));
// result
p4 = (Policy) p1.merge(p2);
Modified: webservices/commons/trunk/modules/neethi/src/test/test3/org/apache/neethi/NormalizeTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/test/test3/org/apache/neethi/NormalizeTest.java?rev=431431&r1=431230&r2=431431&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/test/test3/org/apache/neethi/NormalizeTest.java (original)
+++ webservices/commons/trunk/modules/neethi/src/test/test3/org/apache/neethi/NormalizeTest.java Mon Aug 14 13:40:55 2006
@@ -39,10 +39,10 @@
r1 = "samples" + File.separator + "test" + i + ".xml";
r2 = "normalized" + File.separator + "test" + i + ".xml";
- p1 = PolicyEngine.getPolicy(getResource(r1));
+ p1 = PolicyEngine.getPolicy(getResourceAsElement(r1));
test = p1;
p1 = (Policy) p1.normalize(true);
- p2 = PolicyEngine.getPolicy(getResource(r2));
+ p2 = PolicyEngine.getPolicy(getResourceAsElement(r2));
if (!PolicyComparator.compare(p1, p2)) {
XMLStreamWriter writer;
Modified: webservices/commons/trunk/modules/neethi/src/test/test3/org/apache/neethi/PolicyTestCase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/test/test3/org/apache/neethi/PolicyTestCase.java?rev=431431&r1=431230&r2=431431&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/test/test3/org/apache/neethi/PolicyTestCase.java (original)
+++ webservices/commons/trunk/modules/neethi/src/test/test3/org/apache/neethi/PolicyTestCase.java Mon Aug 14 13:40:55 2006
@@ -15,36 +15,24 @@
*/
package org.apache.neethi;
-import java.io.File;
-import java.io.FileInputStream;
+import java.io.InputStream;
import javax.xml.stream.XMLInputFactory;
-import junit.framework.TestCase;
-
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.impl.llom.factory.OMXMLBuilderFactory;
-public class PolicyTestCase extends TestCase {
- protected String baseDir = System.getProperty("basedir");
- protected String testDir = "test" + File.separator;
- protected String testResourceDir = "test-resources";
-
+
+public class PolicyTestCase extends org.apache.ws.policy.PolicyTestCase {
public PolicyTestCase(String name) {
super(name);
- if (baseDir == null) {
- baseDir = (String) (new File(".")).getAbsolutePath();
- }
- testDir = (String) (new File(baseDir, testDir).getAbsolutePath());
}
- public OMElement getResource(String name) {
- String filePath = (new File(testResourceDir, name)).getAbsolutePath();
+ public OMElement getResourceAsElement(String name) {
try {
-
- FileInputStream fis = new FileInputStream(filePath);
- OMElement element = OMXMLBuilderFactory.createStAXOMBuilder(OMAbstractFactory.getOMFactory(), XMLInputFactory.newInstance().createXMLStreamReader(fis)).getDocumentElement();
+ InputStream in = getResource(name);
+ OMElement element = OMXMLBuilderFactory.createStAXOMBuilder(OMAbstractFactory.getOMFactory(), XMLInputFactory.newInstance().createXMLStreamReader(in)).getDocumentElement();
return element;
} catch (Exception e) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: commons-dev-help@ws.apache.org