chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fguilla...@apache.org
Subject svn commit: r782039 - in /incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src: main/java/org/apache/chemistry/atompub/client/app/ main/java/org/apache/chemistry/atompub/client/common/ main/java/org/apache/chemistry/atompub/client/common/xm...
Date Fri, 05 Jun 2009 15:13:12 GMT
Author: fguillaume
Date: Fri Jun  5 15:13:06 2009
New Revision: 782039

URL: http://svn.apache.org/viewvc?rev=782039&view=rev
Log:
remove unused classes, move tests to actual unit tests

Added:
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/common/
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/common/atom/
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/common/atom/TestPropertyIterator.java
  (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/common/xml/
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/common/xml/TestXMLWriter.java
  (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/feedentry.xml
  (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/xmlwriter-output.xml
  (with props)
Removed:
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/AdapterManager.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/ClassLookup.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/ClassNameRegistry.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/ClassRegistry.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/Path.java
Modified:
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/APPContentManager.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/xml/XMLWriter.java

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/APPContentManager.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/APPContentManager.java?rev=782039&r1=782038&r2=782039&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/APPContentManager.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/APPContentManager.java
Fri Jun  5 15:13:06 2009
@@ -28,7 +28,6 @@
 import org.apache.chemistry.atompub.client.CredentialsProvider;
 import org.apache.chemistry.atompub.client.NoSuchRepositoryException;
 import org.apache.chemistry.atompub.client.app.httpclient.HttpClientConnector;
-import org.apache.chemistry.atompub.client.common.AdapterManager;
 import org.apache.chemistry.atompub.client.common.atom.ReadContext;
 
 /**
@@ -66,10 +65,6 @@
         }
     }
 
-    protected AdapterManager createAdapterManager() {
-        return new AdapterManager();
-    }
-
     protected Connector createConnector() {
         return new HttpClientConnector(this);
     }

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/xml/XMLWriter.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/xml/XMLWriter.java?rev=782039&r1=782038&r2=782039&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/xml/XMLWriter.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/xml/XMLWriter.java
Fri Jun  5 15:13:06 2009
@@ -18,7 +18,6 @@
 package org.apache.chemistry.atompub.client.common.xml;
 
 import java.io.IOException;
-import java.io.StringWriter;
 import java.io.Writer;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -28,7 +27,6 @@
 
 import javax.xml.namespace.QName;
 
-import org.apache.chemistry.atompub.CMIS;
 import org.apache.chemistry.atompub.client.common.DateParser;
 
 // This file contains code from org.apache.commons.betwixt.XMLUtils
@@ -162,7 +160,7 @@
 
     public XMLWriter element(String name) throws IOException {
         if (element != null && !element.isContainer) { // a non closed sibling -
-                                                       // close it
+            // close it
             pop();
             writer.write("/>");
         }
@@ -198,7 +196,6 @@
                 } else {
                     writer.write("<?xml version=\"1.0\"?>");
                 }
-                writer.write(crlf);
             }
         } else {
             element.isContainer = true;
@@ -388,7 +385,7 @@
     }
 
     public static String format(Date date) {
-        StringBuilder sb = new StringBuilder();
+        StringBuilder sb = new StringBuilder(24);
         Calendar c = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
         c.setTime(date);
         sb.append(c.get(Calendar.YEAR));
@@ -448,7 +445,7 @@
      * @return text with escaped delimiters
      */
     public static final String escapeBodyValue(Object value) {
-        StringBuffer buffer = new StringBuffer(value.toString());
+        StringBuilder buffer = new StringBuilder(value.toString());
         for (int i = 0, size = buffer.length(); i < size; i++) {
             switch (buffer.charAt(i)) {
             case '<':
@@ -481,7 +478,7 @@
      * @return text with characters restricted (for use in attributes) escaped
      */
     public static final String escapeAttributeValue(Object value) {
-        StringBuffer buffer = new StringBuffer(value.toString());
+        StringBuilder buffer = new StringBuilder(value.toString());
         for (int i = 0, size = buffer.length(); i < size; i++) {
             switch (buffer.charAt(i)) {
             case '<':
@@ -564,18 +561,4 @@
         }
     }
 
-    public static void main(String[] args) throws Exception {
-
-        StringWriter w = new StringWriter();
-        XMLWriter x = new XMLWriter(w, 4);
-
-        x.start().element("service").xmlns("cmis", CMIS.CMIS_NS).attr(
-                "version", "1.0").start().element("ws1").attr("k", "v").content(
-                "test").element("ws2").attr("key", "val").start().element(
-                CMIS.OBJECT).end().element("ws3").attr("key", "val").end().end();
-
-        System.out.println(w.toString());
-
-    }
-
 }

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/common/atom/TestPropertyIterator.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/common/atom/TestPropertyIterator.java?rev=782039&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/common/atom/TestPropertyIterator.java
(added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/common/atom/TestPropertyIterator.java
Fri Jun  5 15:13:06 2009
@@ -0,0 +1,51 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Authors:
+ *     Bogdan Stefanescu, Nuxeo
+ *     Florent Guillaume, Nuxeo
+ */
+package org.apache.chemistry.atompub.client.common.atom;
+
+import java.io.Serializable;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.chemistry.atompub.CMIS;
+import org.apache.chemistry.atompub.client.common.xml.StaxReader;
+
+/**
+ *
+ */
+public class TestPropertyIterator extends TestCase {
+
+    public void testPropertyIterator() throws Exception {
+        URL url = this.getClass().getClassLoader().getResource("feedentry.xml");
+        StaxReader sr = StaxReader.newReader(url.openStream());
+        sr.getFirstTag(CMIS.PROPERTIES);
+        PropertyIterator pi = new PropertyIterator(sr);
+        List<String> names = new LinkedList<String>();
+        while (pi.hasNext()) {
+            XmlProperty p = pi.next();
+            Serializable value = p.value;
+            names.add(value.toString());
+        }
+        assertEquals(Arrays.asList("string_null", "string", "date",
+                "string_array", "date_array"), names);
+    }
+
+}

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/common/atom/TestPropertyIterator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/common/atom/TestPropertyIterator.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/common/atom/TestPropertyIterator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/common/xml/TestXMLWriter.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/common/xml/TestXMLWriter.java?rev=782039&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/common/xml/TestXMLWriter.java
(added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/common/xml/TestXMLWriter.java
Fri Jun  5 15:13:06 2009
@@ -0,0 +1,64 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Authors:
+ *     Bogdan Stefanescu, Nuxeo
+ *     Florent Guillaume, Nuxeo
+ */
+package org.apache.chemistry.atompub.client.common.xml;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.apache.chemistry.atompub.CMIS;
+
+/**
+ *
+ */
+public class TestXMLWriter extends TestCase {
+
+    public static String toString(Reader r) throws IOException {
+        char[] chars = new char[1000]; // big enough for this test
+        int pos = 0;
+        int n = 0;
+        do {
+            pos += n;
+            n = r.read(chars, pos, chars.length - pos);
+        } while (n > 0);
+        return new String(chars, 0, pos);
+    }
+
+    public void testXMLWriter() throws Exception {
+        Writer w = new StringWriter();
+        XMLWriter x = new XMLWriter(w, 2);
+        x.start().element("service").xmlns("cmis", CMIS.CMIS_NS).attr(
+                "version", "1.0").start().element("ws1").attr("k", "v").content(
+                "test").element("ws2").attr("key", "val").start().element(
+                CMIS.OBJECT).end().element("ws3").attr("key", "val").end().end();
+        String actual = w.toString();
+
+        InputStream stream = this.getClass().getClassLoader().getResourceAsStream(
+                "xmlwriter-output.xml");
+        String expected = toString(new InputStreamReader(stream, "UTF-8"));
+        stream.close();
+
+        assertEquals(expected.trim(), actual.trim());
+    }
+}

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/common/xml/TestXMLWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/common/xml/TestXMLWriter.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/common/xml/TestXMLWriter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/feedentry.xml
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/feedentry.xml?rev=782039&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/feedentry.xml
(added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/feedentry.xml
Fri Jun  5 15:13:06 2009
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<entry xmlns="http://www.w3.org/2005/Atom" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200901">
+  <cmis:object>
+    <cmis:properties>
+      <cmis:propertyString cmis:name="string_null" />
+      <cmis:propertyString cmis:name="string">
+        <cmis:value>string1</cmis:value>
+      </cmis:propertyString>
+      <cmis:propertyDateTime cmis:name="date">
+        <cmis:value>2009-03-17T17:55:08+01:00
+        </cmis:value>
+      </cmis:propertyDateTime>
+      <cmis:propertyString cmis:name="string_array">
+        <cmis:value>string1</cmis:value>
+        <cmis:value>string2</cmis:value>
+      </cmis:propertyString>
+      <cmis:propertyDateTime cmis:name="date_array">
+        <cmis:value>2009-03-17T17:55:08+01:00
+        </cmis:value>
+        <cmis:value>2009-03-18T17:55:08+01:00
+        </cmis:value>
+      </cmis:propertyDateTime>
+    </cmis:properties>
+  </cmis:object>
+</entry>

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/feedentry.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/feedentry.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/feedentry.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/xmlwriter-output.xml
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/xmlwriter-output.xml?rev=782039&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/xmlwriter-output.xml
(added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/xmlwriter-output.xml
Fri Jun  5 15:13:06 2009
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<service xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200901" version="1.0">
+  <ws1 k="v">test</ws1>
+  <ws2 key="val">
+    <cmis:object/>
+  </ws2>
+  <ws3 key="val"/>
+</service>

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/xmlwriter-output.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/xmlwriter-output.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/xmlwriter-output.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message