cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1500294 - in /cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne: util/UtilTest.java xml/XMLEncoderTest.java
Date Sat, 06 Jul 2013 15:12:18 GMT
Author: aadamchik
Date: Sat Jul  6 15:12:18 2013
New Revision: 1500294

URL: http://svn.apache.org/r1500294
Log:
stripping license headers when running tests and tweaking other deprecated test cases
to ensure they still pass

Modified:
    cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/util/UtilTest.java
    cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/xml/XMLEncoderTest.java

Modified: cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/util/UtilTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/util/UtilTest.java?rev=1500294&r1=1500293&r2=1500294&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/util/UtilTest.java
(original)
+++ cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/util/UtilTest.java
Sat Jul  6 15:12:18 2013
@@ -141,7 +141,8 @@ public class UtilTest extends TestCase {
     }
 
     public void testCopyJarUrl() throws Exception {
-        URL fileInJar = getClass().getClassLoader().getResource("testfile1.txt");
+        // using a completely unrelated file to test copy op
+        URL fileInJar = getClass().getClassLoader().getResource("dbcp.properties");
         assertNotNull(fileInJar);
 
         // skipping test if file not in jar

Modified: cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/xml/XMLEncoderTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/xml/XMLEncoderTest.java?rev=1500294&r1=1500293&r2=1500294&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/xml/XMLEncoderTest.java
(original)
+++ cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/xml/XMLEncoderTest.java
Sat Jul  6 15:12:18 2013
@@ -35,12 +35,11 @@ public class XMLEncoderTest extends Test
 
     static final String XML_DATA_DIR = "xmlcoding/";
     static final boolean windows;
-    
+
     static {
         if (System.getProperty("os.name").toUpperCase().contains("WINDOWS")) {
             windows = true;
-        }
-        else {
+        } else {
             windows = false;
         }
     }
@@ -70,18 +69,37 @@ public class XMLEncoderTest extends Test
     }
 
     private String loadTestFileAsString(String filename) throws IOException {
-        BufferedReader in = new BufferedReader(new InputStreamReader(ResourceUtil
-                .getResource(XML_DATA_DIR + filename).openStream()));
+        BufferedReader in = new BufferedReader(new InputStreamReader(ResourceUtil.getResource(XML_DATA_DIR
+ filename)
+                .openStream()));
         StringBuffer comp = new StringBuffer();
+        boolean inComment = false;
         while (in.ready()) {
-            comp.append(in.readLine());
+
+            String line = in.readLine();
+
+            // strip license header
+            if (!inComment) {
+                if (line.trim().startsWith("<!--")) {
+                    inComment = true;
+                    continue;
+                }
+            }
+            else {
+                if(line.contains("-->")) {
+                    inComment = false;
+                }
+                
+                continue;
+            }
+
+            comp.append(line);
             if (windows) {
                 comp.append("\r");
             }
             comp.append("\n");
         }
         in.close();
-        
+
         return comp.toString();
     }
 
@@ -100,7 +118,8 @@ public class XMLEncoderTest extends Test
         String result = encoder.encode("TestObjects", obj1);
 
         String comp = loadTestFileAsString("encoded-complex-collection.xml");
-        // there are differences in attribute order encoding, so there can be more than
+        // there are differences in attribute order encoding, so there can be
+        // more than
         // one valid output depending on the parser used...
 
         if (!comp.equals(result)) {
@@ -110,8 +129,8 @@ public class XMLEncoderTest extends Test
     }
 
     public void testSimpleMapping() throws Exception {
-        XMLEncoder encoder = new XMLEncoder(ResourceUtil.getResource(
-                XML_DATA_DIR + "simple-mapping.xml").toExternalForm());
+        XMLEncoder encoder = new XMLEncoder(ResourceUtil.getResource(XML_DATA_DIR + "simple-mapping.xml")
+                .toExternalForm());
         TestObject test = new TestObject();
         test.setAge(57);
         test.setName("George");
@@ -120,68 +139,68 @@ public class XMLEncoderTest extends Test
         String result = encoder.encode(test);
 
         String comp = loadTestFileAsString("simple-mapped.xml");
-        
+
         assertEquals(comp, result);
     }
-    
-    //  Added test for 1-to-1 relationship mappings, per CAY-597.
+
+    // Added test for 1-to-1 relationship mappings, per CAY-597.
     public void test1To1Mapping() throws Exception {
-        XMLEncoder encoder = new XMLEncoder(ResourceUtil.getResource(
-                XML_DATA_DIR + "1to1-mapping.xml").toExternalForm());
-        
+        XMLEncoder encoder = new XMLEncoder(ResourceUtil.getResource(XML_DATA_DIR + "1to1-mapping.xml")
+                .toExternalForm());
+
         TestObject grandParent = new TestObject();
         grandParent.setAge(117);
         grandParent.setName("Sue");
         grandParent.setOpen(false);
-        
+
         TestObject parent = new TestObject();
         parent.setAge(94);
         parent.setName("Bill");
         parent.setOpen(true);
         parent.setParent(grandParent);
-        
+
         TestObject child = new TestObject();
         child.setAge(57);
         child.setName("George");
         child.setOpen(false);
         child.setParent(parent);
-        
+
         String result = encoder.encode(child);
 
         String comp = loadTestFileAsString("1to1-mapped.xml");
-        
+
         assertEquals(comp, result);
     }
-    
+
     // Added test for 1-to-1 relationships, per CAY-597.
     public void testEncode1To1() throws Exception {
         TestObject grandParent = new TestObject();
         grandParent.setAge(117);
         grandParent.setName("Sue");
         grandParent.setOpen(false);
-        
+
         TestObject parent = new TestObject();
         parent.setAge(94);
         parent.setName("Bill");
         parent.setOpen(true);
         parent.setParent(grandParent);
-        
+
         TestObject child = new TestObject();
         child.setAge(57);
         child.setName("George");
         child.setOpen(false);
         child.setParent(parent);
-        
+
         String xml = new XMLEncoder().encode("Test", child);
 
         String comp = loadTestFileAsString("1to1-encoded.xml");
-        
+
         assertEquals(comp, xml);
     }
 
     public void testCollectionMapping() throws Exception {
-        XMLEncoder encoder = new XMLEncoder(ResourceUtil.getResource(
-                XML_DATA_DIR + "collection-mapping.xml").toExternalForm());
+        XMLEncoder encoder = new XMLEncoder(ResourceUtil.getResource(XML_DATA_DIR + "collection-mapping.xml")
+                .toExternalForm());
         TestObject george = new TestObject();
         george.setAge(76);
         george.setName("George");
@@ -208,7 +227,7 @@ public class XMLEncoderTest extends Test
         String xml = new XMLEncoder().encode("EncodedTestList", dataObjects);
 
         String comp = loadTestFileAsString("data-objects-encoded.xml");
-        
+
         assertEquals(comp, xml);
     }
 
@@ -219,10 +238,8 @@ public class XMLEncoderTest extends Test
         dataObjects.add(new TestObject("Mary", 28, false));
         dataObjects.add(new TestObject("Joe", 31, true));
 
-        String xml = new XMLEncoder(ResourceUtil.getResource(
-                XML_DATA_DIR + "simple-mapping.xml").toExternalForm()).encode(
-                "EncodedTestList",
-                dataObjects);
+        String xml = new XMLEncoder(ResourceUtil.getResource(XML_DATA_DIR + "simple-mapping.xml").toExternalForm())
+                .encode("EncodedTestList", dataObjects);
 
         String comp = loadTestFileAsString("data-objects-mapped.xml");
 



Mime
View raw message