You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ri...@apache.org on 2006/10/04 20:57:35 UTC
svn commit: r452976 [2/2] - in /geronimo/specs/trunk: ./
geronimo-activation_1.0.2_spec/ geronimo-activation_1.1_spec/
geronimo-activation_1.1_spec/src/ geronimo-activation_1.1_spec/src/main/
geronimo-activation_1.1_spec/src/main/java/ geronimo-activat...
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/MimeType.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/MimeType.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/MimeType.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/MimeTypeParameterList.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/MimeTypeParameterList.java?view=auto&rev=452976
==============================================================================
--- geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/MimeTypeParameterList.java (added)
+++ geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/MimeTypeParameterList.java Wed Oct 4 11:57:33 2006
@@ -0,0 +1,211 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ * 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.
+ */
+
+package javax.activation;
+
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MimeTypeParameterList {
+
+ private final Map params = new HashMap();
+
+ public MimeTypeParameterList() {
+ }
+
+ public MimeTypeParameterList(String parameterList) throws MimeTypeParseException {
+ parse(parameterList);
+ }
+
+ protected void parse(String parameterList) throws MimeTypeParseException {
+ if (parameterList == null) {
+ throw new MimeTypeParseException("parameterList is null");
+ }
+
+ RFC2045Parser parser = new RFC2045Parser(parameterList);
+ while (parser.hasMoreParams()) {
+ String attribute = parser.expectAttribute();
+ parser.expectEquals();
+ String value = parser.expectValue();
+ params.put(attribute.toLowerCase(), value);
+ }
+ }
+
+ public int size() {
+ return params.size();
+ }
+
+ public boolean isEmpty() {
+ return params.isEmpty();
+ }
+
+ public String get(String name) {
+ return (String) params.get(name.toLowerCase());
+ }
+
+ public void set(String name, String value) {
+ params.put(name.toLowerCase(), value);
+ }
+
+ public void remove(String name) {
+ params.remove(name.toLowerCase());
+ }
+
+ public Enumeration getNames() {
+ return Collections.enumeration(params.keySet());
+ }
+
+ /**
+ * String representation of this parameter list.
+ *
+ * @return
+ */
+ public String toString() {
+ StringBuffer buf = new StringBuffer(params.size() << 4);
+ for (Iterator i = params.entrySet().iterator(); i.hasNext();) {
+ Map.Entry entry = (Map.Entry) i.next();
+ buf.append("; ").append(entry.getKey()).append('=');
+ quote(buf, (String) entry.getValue());
+ }
+ return buf.toString();
+ }
+
+ private void quote(StringBuffer buf, String value) {
+ int length = value.length();
+ boolean quote = false;
+ for (int i = 0; i < length; i++) {
+ if (MimeType.isSpecial(value.charAt(i))) {
+ quote = true;
+ break;
+ }
+ }
+ if (quote) {
+ buf.append('"');
+ for (int i = 0; i < length; i++) {
+ char c = value.charAt(i);
+ if (c == '\\' || c == '"') {
+ buf.append('\\');
+ }
+ buf.append(c);
+ }
+ buf.append('"');
+ } else {
+ buf.append(value);
+ }
+ }
+
+ private static class RFC2045Parser {
+ private final String text;
+ private int index = 0;
+
+ private RFC2045Parser(String text) {
+ this.text = text;
+ }
+
+ /**
+ * Look the next ";" to start a parameter (skipping whitespace)
+ *
+ * @return
+ */
+ private boolean hasMoreParams() throws MimeTypeParseException {
+ char c;
+ do {
+ if (index == text.length()) {
+ return false;
+ }
+ c = text.charAt(index++);
+ } while (Character.isWhitespace(c));
+ if (c != ';') {
+ throw new MimeTypeParseException("Expected \";\" at " + (index - 1) + " in " + text);
+ }
+ return true;
+ }
+
+ private String expectAttribute() throws MimeTypeParseException {
+ char c;
+ do {
+ if (index == text.length()) {
+ throw new MimeTypeParseException("Expected attribute at " + (index - 1) + " in " + text);
+ }
+ c = text.charAt(index++);
+ } while (Character.isWhitespace(c));
+ int start = index - 1;
+ while (index != text.length() && !MimeType.isSpecial(text.charAt(index))) {
+ index += 1;
+ }
+ return text.substring(start, index);
+ }
+
+ private void expectEquals() throws MimeTypeParseException {
+ char c;
+ do {
+ if (index == text.length()) {
+ throw new MimeTypeParseException("Expected \"=\" at " + (index - 1) + " in " + text);
+ }
+ c = text.charAt(index++);
+ } while (Character.isWhitespace(c));
+ if (c != '=') {
+ throw new MimeTypeParseException("Expected \"=\" at " + (index - 1) + " in " + text);
+ }
+ }
+
+ private String expectValue() throws MimeTypeParseException {
+ char c;
+ do {
+ if (index == text.length()) {
+ throw new MimeTypeParseException("Expected value at " + (index - 1) + " in " + text);
+ }
+ c = text.charAt(index++);
+ } while (Character.isWhitespace(c));
+ if (c == '"') {
+ // quoted-string
+ StringBuffer buf = new StringBuffer();
+ while (true) {
+ if (index == text.length()) {
+ throw new MimeTypeParseException("Expected closing quote at " + (index - 1) + " in " + text);
+ }
+ c = text.charAt(index++);
+ if (c == '"') {
+ break;
+ }
+ if (c == '\\') {
+ if (index == text.length()) {
+ throw new MimeTypeParseException("Expected escaped char at " + (index - 1) + " in " + text);
+ }
+ c = text.charAt(index++);
+ }
+ buf.append(c);
+ }
+ return buf.toString();
+ } else {
+ // token
+ int start = index - 1;
+ while (index != text.length() && !MimeType.isSpecial(text.charAt(index))) {
+ index += 1;
+ }
+ return text.substring(start, index);
+ }
+ }
+ }
+}
\ No newline at end of file
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/MimeTypeParameterList.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/MimeTypeParameterList.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/MimeTypeParameterList.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/MimeTypeParseException.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/MimeTypeParseException.java?view=auto&rev=452976
==============================================================================
--- geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/MimeTypeParseException.java (added)
+++ geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/MimeTypeParseException.java Wed Oct 4 11:57:33 2006
@@ -0,0 +1,31 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ * 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.
+ */
+
+package javax.activation;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MimeTypeParseException extends Exception {
+ public MimeTypeParseException() {
+ super();
+ }
+
+ public MimeTypeParseException(String s) {
+ super(s);
+ }
+}
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/MimeTypeParseException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/MimeTypeParseException.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/MimeTypeParseException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/MimetypesFileTypeMap.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/MimetypesFileTypeMap.java?view=auto&rev=452976
==============================================================================
--- geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/MimetypesFileTypeMap.java (added)
+++ geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/MimetypesFileTypeMap.java Wed Oct 4 11:57:33 2006
@@ -0,0 +1,180 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ * 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.
+ */
+
+package javax.activation;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.FileReader;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.StringTokenizer;
+import java.util.Enumeration;
+import java.net.URL;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MimetypesFileTypeMap extends FileTypeMap {
+ private static final String DEFAULT_TYPE = "application/octet-stream";
+
+ private final Map types = new HashMap();
+
+ public MimetypesFileTypeMap() {
+ // defaults from /META-INF/mimetypes.default
+ try {
+ InputStream is = MimetypesFileTypeMap.class.getResourceAsStream("/META-INF/mimetypes.default");
+ if (is != null) {
+ try {
+ loadStream(is);
+ } finally {
+ is.close();
+ }
+ }
+ } catch (IOException e) {
+ // ignore
+ }
+
+ // defaults from resources called /META-INF/mime.types
+ try {
+ ClassLoader cl = MimetypesFileTypeMap.class.getClassLoader();
+ Enumeration e = cl.getResources("/META-INF/mime.types");
+ while (e.hasMoreElements()) {
+ URL url = (URL) e.nextElement();
+ try {
+ InputStream is = url.openStream();
+ try {
+ loadStream(is);
+ } finally {
+ is.close();
+ }
+ } catch (IOException e1) {
+ continue;
+ }
+ }
+ } catch (SecurityException e) {
+ // ignore
+ } catch (IOException e) {
+ // ignore
+ }
+
+ // defaults from ${java.home}/lib/mime.types
+ try {
+ File file = new File(System.getProperty("java.home"), "lib/mime.types");
+ InputStream is = new FileInputStream(file);
+ try {
+ loadStream(is);
+ } finally {
+ is.close();
+ }
+ } catch (SecurityException e) {
+ // ignore
+ } catch (FileNotFoundException e) {
+ // ignore
+ } catch (IOException e) {
+ // ignore
+ }
+
+ // defaults from ${user.home}/.mime.types
+ try {
+ File file = new File(System.getProperty("user.home"), ".mime.types");
+ InputStream is = new FileInputStream(file);
+ try {
+ loadStream(is);
+ } finally {
+ is.close();
+ }
+ } catch (SecurityException e) {
+ // ignore
+ } catch (FileNotFoundException e) {
+ // ignore
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+
+ public MimetypesFileTypeMap(String mimeTypeFileName) throws IOException {
+ this();
+ BufferedReader reader = new BufferedReader(new FileReader(mimeTypeFileName));
+ try {
+ String line;
+ while ((line = reader.readLine()) != null) {
+ addMimeTypes(line);
+ }
+ reader.close();
+ } catch (IOException e) {
+ try {
+ reader.close();
+ } catch (IOException e1) {
+ // ignore to allow original cause through
+ }
+ throw e;
+ }
+ }
+
+ public MimetypesFileTypeMap(InputStream is) {
+ this();
+ try {
+ loadStream(is);
+ } catch (IOException e) {
+ // ignore as the spec's signature says we can't throw IOException - doh!
+ }
+ }
+
+ private void loadStream(InputStream is) throws IOException {
+ BufferedReader reader = new BufferedReader(new InputStreamReader(is));
+ String line;
+ while ((line = reader.readLine()) != null) {
+ addMimeTypes(line);
+ }
+ }
+
+ public synchronized void addMimeTypes(String mime_types) {
+ int hashPos = mime_types.indexOf('#');
+ if (hashPos != -1) {
+ mime_types = mime_types.substring(0, hashPos);
+ }
+ StringTokenizer tok = new StringTokenizer(mime_types);
+ if (!tok.hasMoreTokens()) {
+ return;
+ }
+ String contentType = tok.nextToken();
+ while (tok.hasMoreTokens()) {
+ String fileType = tok.nextToken();
+ types.put(fileType, contentType);
+ }
+ }
+
+ public String getContentType(File f) {
+ return getContentType(f.getName());
+ }
+
+ public synchronized String getContentType(String filename) {
+ int index = filename.lastIndexOf('.');
+ if (index == -1 || index == filename.length()-1) {
+ return DEFAULT_TYPE;
+ }
+ String fileType = filename.substring(index + 1);
+ String contentType = (String) types.get(fileType);
+ return contentType == null ? DEFAULT_TYPE : contentType;
+ }
+}
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/MimetypesFileTypeMap.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/MimetypesFileTypeMap.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/MimetypesFileTypeMap.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/URLDataSource.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/URLDataSource.java?view=auto&rev=452976
==============================================================================
--- geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/URLDataSource.java (added)
+++ geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/URLDataSource.java Wed Oct 4 11:57:33 2006
@@ -0,0 +1,89 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ * 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.
+ */
+
+package javax.activation;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URL;
+import java.net.URLConnection;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class URLDataSource implements DataSource {
+ private final static String DEFAULT_CONTENT_TYPE = "application/octet-stream";
+
+ private final URL url;
+
+ /**
+ * Creates a URLDataSource from a URL object.
+ */
+ public URLDataSource(URL url) {
+ this.url = url;
+ }
+
+ /**
+ * Returns the value of the URL content-type header field.
+ * This method calls URL.openConnection() to obtain a connection
+ * from which to obtain the content type. If this fails or
+ * a getContentType() returns null then "application/octet-stream"
+ * is returned.
+ */
+ public String getContentType() {
+ try {
+ URLConnection connection = url.openConnection();
+ String type = connection.getContentType();
+ return type == null ? DEFAULT_CONTENT_TYPE : type;
+ } catch (IOException e) {
+ return DEFAULT_CONTENT_TYPE;
+ }
+ }
+
+ /**
+ * Returns the file name of the URL object.
+ * @return the name as returned by URL.getFile()
+ */
+ public String getName() {
+ return url.getFile();
+ }
+
+ /**
+ * Returns an InputStream obtained from the URL.
+ * @return the InputStream from URL.openStream()
+ */
+ public InputStream getInputStream() throws IOException {
+ return url.openStream();
+ }
+
+ /**
+ * Returns an OutputStream obtained from the URL.
+ */
+ public OutputStream getOutputStream() throws IOException {
+ URLConnection connection = url.openConnection();
+ connection.setDoOutput(true);
+ return connection.getOutputStream();
+ }
+
+ /**
+ * Returns the URL of the data source.
+ */
+ public URL getURL() {
+ return url;
+ }
+}
\ No newline at end of file
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/URLDataSource.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/URLDataSource.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/URLDataSource.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/UnsupportedDataTypeException.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/UnsupportedDataTypeException.java?view=auto&rev=452976
==============================================================================
--- geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/UnsupportedDataTypeException.java (added)
+++ geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/UnsupportedDataTypeException.java Wed Oct 4 11:57:33 2006
@@ -0,0 +1,33 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ * 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.
+ */
+
+package javax.activation;
+
+import java.io.IOException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class UnsupportedDataTypeException extends IOException {
+ public UnsupportedDataTypeException() {
+ super();
+ }
+
+ public UnsupportedDataTypeException(String s) {
+ super(s);
+ }
+}
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/UnsupportedDataTypeException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/UnsupportedDataTypeException.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/java/javax/activation/UnsupportedDataTypeException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/resources/META-INF/mimetypes.default
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/resources/META-INF/mimetypes.default?view=auto&rev=452976
==============================================================================
--- geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/resources/META-INF/mimetypes.default (added)
+++ geronimo/specs/trunk/geronimo-activation_1.1_spec/src/main/resources/META-INF/mimetypes.default Wed Oct 4 11:57:33 2006
@@ -0,0 +1,20 @@
+text/html html htm HTML HTM
+text/plain txt text TXT TEXT
+image/gif gif GIF
+image/ief ief
+image/jpeg jpeg jpg jpe JPG
+image/tiff tiff tif
+image/x-xwindowdump xwd
+application/postscript ai eps ps
+application/rtf rtf
+application/x-tex tex
+application/x-texinfo texinfo texi
+application/x-troff t tr roff
+audio/basic au
+audio/midi midi mid
+audio/x-aifc aifc
+audio/x-aiff aif aiff
+audio/x-wav wav
+video/mpeg mpeg mpg mpe
+video/quicktime qt mov
+video/x-msvideo avi
Added: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/site/site.xml
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-activation_1.1_spec/src/site/site.xml?view=auto&rev=452976
==============================================================================
--- geronimo/specs/trunk/geronimo-activation_1.1_spec/src/site/site.xml (added)
+++ geronimo/specs/trunk/geronimo-activation_1.1_spec/src/site/site.xml Wed Oct 4 11:57:33 2006
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2006 The Apache Software Foundation
+
+ 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.
+-->
+
+<!-- $Id: site.xml 437244 2006-08-26 23:00:23Z jdillon $ -->
+
+<project name="${project.name}">
+
+ <body>
+
+ ${parentProject}
+
+ ${modules}
+
+ ${reports}
+
+ </body>
+
+</project>
+
+
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/site/site.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/site/site.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/site/site.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/ActivationDataFlavorTest.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/ActivationDataFlavorTest.java?view=auto&rev=452976
==============================================================================
--- geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/ActivationDataFlavorTest.java (added)
+++ geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/ActivationDataFlavorTest.java Wed Oct 4 11:57:33 2006
@@ -0,0 +1,60 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ * 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.
+ */
+
+//
+// This source code implements specifications defined by the Java
+// Community Process. In order to remain compliant with the specification
+// DO NOT add / change / or delete method signatures!
+//
+package javax.activation;
+
+import java.io.InputStream;
+import java.awt.datatransfer.DataFlavor;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ActivationDataFlavorTest extends TestCase {
+ public void testMimeTypeConstructorWithoutClass() {
+ ActivationDataFlavor adf = new ActivationDataFlavor("application/*", null);
+ assertEquals("application/*", adf.getMimeType());
+ assertEquals(InputStream.class, adf.getRepresentationClass());
+ }
+
+ public void testMimeTypeConstructorWithClass() {
+ ActivationDataFlavor adf = new ActivationDataFlavor("application/x-java-serialized-object; class=java.lang.Object", null);
+ assertEquals("application/x-java-serialized-object; class=java.lang.Object", adf.getMimeType());
+ assertEquals(InputStream.class, adf.getRepresentationClass());
+ }
+
+ public void testHumanName() {
+ ActivationDataFlavor adf = new ActivationDataFlavor("text/html", "Human Name");
+ assertEquals("Human Name", adf.getHumanPresentableName());
+ adf.setHumanPresentableName("Name 2");
+ assertEquals("Name 2", adf.getHumanPresentableName());
+ adf = new ActivationDataFlavor("text/html", null);
+ assertNull(adf.getHumanPresentableName());
+ }
+
+ public void testEquals() {
+ ActivationDataFlavor adf1 = new ActivationDataFlavor("text/plain", "text/plain");
+ DataFlavor adf2 = new DataFlavor("text/plain", "text/plain");
+ assertTrue(adf1.equals(adf2));
+ }
+}
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/ActivationDataFlavorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/ActivationDataFlavorTest.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/ActivationDataFlavorTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/CommandInfoTest.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/CommandInfoTest.java?view=auto&rev=452976
==============================================================================
--- geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/CommandInfoTest.java (added)
+++ geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/CommandInfoTest.java Wed Oct 4 11:57:33 2006
@@ -0,0 +1,68 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ * 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.
+ */
+
+//
+// This source code implements specifications defined by the Java
+// Community Process. In order to remain compliant with the specification
+// DO NOT add / change / or delete method signatures!
+//
+package javax.activation;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CommandInfoTest extends TestCase {
+ public void testAttributes() {
+ CommandInfo info = new CommandInfo("test", "test.class");
+ assertEquals("test", info.getCommandName());
+ assertEquals("test.class", info.getCommandClass());
+ }
+
+ public void testInvalidClassName() throws IOException {
+ CommandInfo info = new CommandInfo("test", "test.class");
+ try {
+ info.getCommandObject(null, null);
+ fail("Expected ClassNotFoundException");
+ } catch (ClassNotFoundException e) {
+ // ok
+ }
+ }
+
+ public void testCommandObject() throws IOException, ClassNotFoundException {
+ CommandInfo info = new CommandInfo("test", MockCommandObject.class.getName());
+ DataHandler dh = new DataHandler("Hello", "text/plain");
+ Object o = info.getCommandObject(dh, MockCommandObject.class.getClassLoader());
+ assertTrue(o instanceof MockCommandObject);
+ MockCommandObject bean = (MockCommandObject) o;
+ assertEquals("test", bean.verb);
+ assertSame(dh, bean.dh);
+ }
+
+ public static class MockCommandObject implements CommandObject {
+ private String verb;
+ private DataHandler dh;
+
+ public void setCommandContext(String verb, DataHandler dh) {
+ this.verb = verb;
+ this.dh = dh;
+ }
+ }
+}
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/CommandInfoTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/CommandInfoTest.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/CommandInfoTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/DataHandlerTest.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/DataHandlerTest.java?view=auto&rev=452976
==============================================================================
--- geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/DataHandlerTest.java (added)
+++ geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/DataHandlerTest.java Wed Oct 4 11:57:33 2006
@@ -0,0 +1,75 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * 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.
+ */
+
+//
+// This source code implements specifications defined by the Java
+// Community Process. In order to remain compliant with the specification
+// DO NOT add / change / or delete method signatures!
+//
+package javax.activation;
+
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.UnsupportedFlavorException;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class DataHandlerTest extends TestCase {
+ private CommandMap defaultMap;
+
+ public void testObjectInputStream() throws IOException {
+ DataHandler handler = new DataHandler("Hello World", "text/plain");
+ InputStream is = handler.getInputStream();
+ byte[] bytes = new byte[128];
+ assertEquals(11, is.read(bytes));
+ assertEquals("Hello World", new String(bytes, 0, 11));
+ }
+
+ protected void setUp() throws Exception {
+ defaultMap = CommandMap.getDefaultCommandMap();
+ MailcapCommandMap myMap = new MailcapCommandMap();
+ myMap.addMailcap("text/plain;; x-java-content-handler=" + DummyTextHandler.class.getName());
+ CommandMap.setDefaultCommandMap(myMap);
+ }
+
+ protected void tearDown() throws Exception {
+ CommandMap.setDefaultCommandMap(defaultMap);
+ }
+
+ public static class DummyTextHandler implements DataContentHandler {
+ public DataFlavor[] getTransferDataFlavors() {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object getTransferData(DataFlavor df, DataSource ds) throws UnsupportedFlavorException, IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object getContent(DataSource ds) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void writeTo(Object obj, String mimeType, OutputStream os) throws IOException {
+ os.write(((String)obj).getBytes());
+ }
+ }
+}
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/DataHandlerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/DataHandlerTest.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/DataHandlerTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/MailcapCommandMapTest.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/MailcapCommandMapTest.java?view=auto&rev=452976
==============================================================================
--- geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/MailcapCommandMapTest.java (added)
+++ geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/MailcapCommandMapTest.java Wed Oct 4 11:57:33 2006
@@ -0,0 +1,119 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ * 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.
+ */
+
+//
+// This source code implements specifications defined by the Java
+// Community Process. In order to remain compliant with the specification
+// DO NOT add / change / or delete method signatures!
+//
+package javax.activation;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MailcapCommandMapTest extends TestCase {
+ private MailcapCommandMap map;
+
+ public void testAdd() {
+ map.addMailcap("foo/bar ;; x-java-view=Foo; x-java-edit=Bar");
+ CommandInfo info = map.getCommand("foo/bar", "view");
+ assertEquals("view", info.getCommandName());
+ assertEquals("Foo", info.getCommandClass());
+ info = map.getCommand("foo/bar", "edit");
+ assertEquals("edit", info.getCommandName());
+ assertEquals("Bar", info.getCommandClass());
+ }
+
+ public void testExplicitWildcard() {
+ map.addMailcap("foo/bar ;; x-java-view=Bar");
+ map.addMailcap("foo/* ;; x-java-view=Star");
+ CommandInfo info = map.getCommand("foo/bar", "view");
+ assertEquals("view", info.getCommandName());
+ assertEquals("Bar", info.getCommandClass());
+ info = map.getCommand("foo/foo", "view");
+ assertEquals("view", info.getCommandName());
+ assertEquals("Star", info.getCommandClass());
+ info = map.getCommand("foo/*", "view");
+ assertEquals("view", info.getCommandName());
+ assertEquals("Star", info.getCommandClass());
+ info = map.getCommand("foo", "view");
+ assertEquals("view", info.getCommandName());
+ assertEquals("Star", info.getCommandClass());
+ }
+
+ public void testImplicitWildcard() {
+ map.addMailcap("foo/bar ;; x-java-view=Bar");
+ map.addMailcap("foo ;; x-java-view=Star");
+ CommandInfo info = map.getCommand("foo/bar", "view");
+ assertEquals("view", info.getCommandName());
+ assertEquals("Bar", info.getCommandClass());
+ info = map.getCommand("foo/foo", "view");
+ assertEquals("view", info.getCommandName());
+ assertEquals("Star", info.getCommandClass());
+ info = map.getCommand("foo", "view");
+ assertEquals("view", info.getCommandName());
+ assertEquals("Star", info.getCommandClass());
+ }
+
+ public void testParameterizedMimeType() {
+ map.addMailcap("foo/bar ;; x-java-view=Bar");
+ CommandInfo info = map.getCommand("foo/bar ; type=\"text/plain\"", "view");
+ assertEquals("view", info.getCommandName());
+ assertEquals("Bar", info.getCommandClass());
+ }
+
+ public void testGetNativeCommands() {
+ MailcapCommandMap tmap = new MailcapCommandMap();
+ // a few filler entries just to increase the noise level.
+ tmap.addMailcap("image/gif;;x-java-view=com.sun.activation.viewers.ImageViewer");
+ tmap.addMailcap("image/jpeg;;x-java-view=com.sun.activation.viewers.ImageViewer");
+ tmap.addMailcap("text/*;yada yada;x-java-view=com.sun.activation.viewers.TextViewer");
+ // neither of these is a match
+ tmap.addMailcap("text/*;;x-java-edit=com.sun.activation.viewers.TextEditor");
+ tmap.addMailcap("text/*; ;x-java-edit=com.sun.activation.viewers.TextEditor");
+
+ // need one with multiple entries
+ tmap.addMailcap("text/plain;yada yada;x-java-view=com.sun.activation.viewers.TextViewer");
+ tmap.addMailcap("text/plain;bad a bing;x-java-view=com.sun.activation.viewers.TextViewer");
+
+ String[] commands = tmap.getNativeCommands("text/*");
+
+ assertEquals(1, commands.length);
+ System.out.println(">>>>>> returned native command = " + commands[0]);
+ assertEquals("text/*;yada yada;x-java-view=com.sun.activation.viewers.TextViewer", commands[0]);
+
+ commands = tmap.getNativeCommands("text/plain");
+ assertEquals(2, commands.length);
+ assertTrue("text/plain;yada yada;x-java-view=com.sun.activation.viewers.TextViewer".equals(commands[0]) ||
+ "text/plain;bad a bing;x-java-view=com.sun.activation.viewers.TextViewer".equals(commands[0]));
+ assertTrue("text/plain;yada yada;x-java-view=com.sun.activation.viewers.TextViewer".equals(commands[1]) ||
+ "text/plain;bad a bing;x-java-view=com.sun.activation.viewers.TextViewer".equals(commands[1]));
+
+ commands = tmap.getNativeCommands("image/gif");
+ assertEquals(0, commands.length);
+
+ commands = tmap.getNativeCommands("text/html");
+ assertEquals(0, commands.length);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ map = new MailcapCommandMap();
+ }
+}
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/MailcapCommandMapTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/MailcapCommandMapTest.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/MailcapCommandMapTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/MimeTypeParameterListTest.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/MimeTypeParameterListTest.java?view=auto&rev=452976
==============================================================================
--- geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/MimeTypeParameterListTest.java (added)
+++ geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/MimeTypeParameterListTest.java Wed Oct 4 11:57:33 2006
@@ -0,0 +1,137 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ * 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.
+ */
+
+package javax.activation;
+
+import java.util.Enumeration;
+
+import junit.framework.TestCase;
+
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class MimeTypeParameterListTest extends TestCase {
+ private MimeTypeParameterList parameterList;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ parameterList = new MimeTypeParameterList();
+ }
+
+ public void testEmptyParameterList() {
+ assertEquals(0, parameterList.size());
+ assertTrue(parameterList.isEmpty());
+ }
+
+ public void testSimpleParameterList() throws MimeTypeParseException {
+ parameterList.parse(";name=value");
+ assertEquals(1, parameterList.size());
+ assertFalse(parameterList.isEmpty());
+ Enumeration e = parameterList.getNames();
+ assertTrue(e.hasMoreElements());
+ assertEquals("name", e.nextElement());
+ assertFalse(e.hasMoreElements());
+ assertEquals("value", parameterList.get("name"));
+ }
+
+ public void testQuotedValue() throws MimeTypeParseException {
+ parameterList.parse(";name=\"val()ue\"");
+ assertEquals(1, parameterList.size());
+ assertEquals("val()ue", parameterList.get("name"));
+ }
+
+ public void testWhiteSpacesParameterList() throws MimeTypeParseException {
+ parameterList.parse("; name= value");
+ assertEquals(1, parameterList.size());
+ assertEquals("name", parameterList.getNames().nextElement());
+ assertEquals("value", parameterList.get("name"));
+ }
+
+ public void testLongParameterList() throws MimeTypeParseException {
+ parameterList.parse(";name1=value1; name2 = value2; name3=value3;name4 = value4");
+ assertEquals(4, parameterList.size());
+ assertEquals("value1", parameterList.get("name1"));
+ assertEquals("value2", parameterList.get("name2"));
+ assertEquals("value3", parameterList.get("name3"));
+ assertEquals("value4", parameterList.get("name4"));
+ }
+
+ public void testCaseInsensitivity() throws MimeTypeParseException {
+ parameterList.parse(";name1=value; NAME2=VALUE; NaMe3=VaLuE");
+ assertEquals(3, parameterList.size());
+ assertEquals("value", parameterList.get("name1"));
+ assertEquals("VALUE", parameterList.get("name2"));
+ assertEquals("VaLuE", parameterList.get("name3"));
+ assertEquals("value", parameterList.get("NAME1"));
+ assertEquals("value", parameterList.get("NaMe1"));
+ parameterList.remove("NAME1");
+ assertNull(parameterList.get("name1"));
+ parameterList.remove("name3");
+ assertEquals("; name2=VALUE", parameterList.toString());
+ }
+
+ public void testNoValueParameterList() {
+ try {
+ parameterList.parse("; name=");
+ fail("Expected MimeTypeParseException");
+ } catch (MimeTypeParseException e) {
+ // ok
+ }
+ }
+
+ public void testMissingValueParameterList() {
+ try {
+ parameterList.parse("; name=;name2=value");
+ fail("Expected MimeTypeParseException");
+ } catch (MimeTypeParseException e) {
+ // ok
+ }
+ }
+
+ public void testNoNameParameterList() {
+ try {
+ parameterList.parse("; = value");
+ fail("Expected MimeTypeParseException");
+ } catch (MimeTypeParseException e) {
+ // ok
+ }
+ }
+
+ public void testUnterminatedQuotedString() {
+ try {
+ parameterList.parse("; = \"value");
+ fail("Expected MimeTypeParseException");
+ } catch (MimeTypeParseException e) {
+ // ok
+ }
+ }
+
+ public void testSpecialInAttribute() {
+ String specials = "()<>@,;:\\\"/[]?= \t";
+ for (int i=0; i < specials.length(); i++) {
+ try {
+ parameterList.parse(";na"+specials.charAt(i)+"me=value");
+ fail("Expected MimeTypeParseException for special: " + specials.charAt(i));
+ } catch (MimeTypeParseException e) {
+ // ok
+ }
+ }
+ }
+}
+
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/MimeTypeParameterListTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/MimeTypeParameterListTest.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/MimeTypeParameterListTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/MimeTypeTest.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/MimeTypeTest.java?view=auto&rev=452976
==============================================================================
--- geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/MimeTypeTest.java (added)
+++ geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/MimeTypeTest.java Wed Oct 4 11:57:33 2006
@@ -0,0 +1,284 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ * 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.
+ */
+
+package javax.activation;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+import junit.framework.TestCase;
+
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class MimeTypeTest extends TestCase {
+ private MimeType mimeType;
+
+ public MimeTypeTest(String name) {
+ super(name);
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+ mimeType = new MimeType();
+ }
+
+ public void testDefaultConstructor() throws MimeTypeParseException {
+ assertEquals("application/*", mimeType.getBaseType());
+ assertEquals("application", mimeType.getPrimaryType());
+ // not sure as RFC2045 does not allow "*" but this is what the RI does
+ assertEquals("*", mimeType.getSubType());
+
+ assertTrue(mimeType.match(new MimeType()));
+ assertTrue(mimeType.match(new MimeType("application/*")));
+
+ assertNull(mimeType.getParameter("foo"));
+ assertEquals(0, mimeType.getParameters().size());
+ assertTrue(mimeType.getParameters().isEmpty());
+ }
+
+ public void testMimeTypeConstructor() throws MimeTypeParseException {
+ mimeType = new MimeType("text/plain");
+ assertEquals("text/plain", mimeType.getBaseType());
+ assertEquals("text", mimeType.getPrimaryType());
+ assertEquals("plain", mimeType.getSubType());
+ assertEquals("text/plain", mimeType.toString());
+ }
+
+ public void testTypeConstructor() throws MimeTypeParseException {
+ mimeType = new MimeType("text", "plain");
+ assertEquals("text/plain", mimeType.getBaseType());
+ assertEquals("text", mimeType.getPrimaryType());
+ assertEquals("plain", mimeType.getSubType());
+ assertEquals("text/plain", mimeType.toString());
+ }
+
+ public void testConstructorWithParams() throws MimeTypeParseException {
+ mimeType = new MimeType("text/plain; charset=\"iso-8859-1\"");
+ assertEquals("text/plain", mimeType.getBaseType());
+ assertEquals("text", mimeType.getPrimaryType());
+ assertEquals("plain", mimeType.getSubType());
+ MimeTypeParameterList params = mimeType.getParameters();
+ assertEquals(1, params.size());
+ assertEquals("iso-8859-1", params.get("charset"));
+ assertEquals("text/plain; charset=iso-8859-1", mimeType.toString());
+ }
+
+ public void testConstructorWithQuotableParams() throws MimeTypeParseException {
+ mimeType = new MimeType("text/plain; charset=\"iso(8859)\"");
+ assertEquals("text/plain", mimeType.getBaseType());
+ assertEquals("text", mimeType.getPrimaryType());
+ assertEquals("plain", mimeType.getSubType());
+ MimeTypeParameterList params = mimeType.getParameters();
+ assertEquals(1, params.size());
+ assertEquals("iso(8859)", params.get("charset"));
+ assertEquals("text/plain; charset=\"iso(8859)\"", mimeType.toString());
+ }
+
+ public void testWriteExternal() throws MimeTypeParseException, IOException {
+ mimeType = new MimeType("text/plain; charset=iso8859-1");
+ mimeType.writeExternal(new ObjectOutput() {
+ public void writeUTF(String str) {
+ assertEquals("text/plain; charset=iso8859-1", str);
+ }
+
+ public void close() {
+ fail();
+ }
+
+ public void flush() {
+ }
+
+ public void write(int b) {
+ fail();
+ }
+
+ public void write(byte b[]) {
+ fail();
+ }
+
+ public void write(byte b[], int off, int len) {
+ fail();
+ }
+
+ public void writeObject(Object obj) {
+ fail();
+ }
+
+ public void writeDouble(double v) {
+ fail();
+ }
+
+ public void writeFloat(float v) {
+ fail();
+ }
+
+ public void writeByte(int v) {
+ fail();
+ }
+
+ public void writeChar(int v) {
+ fail();
+ }
+
+ public void writeInt(int v) {
+ fail();
+ }
+
+ public void writeShort(int v) {
+ fail();
+ }
+
+ public void writeLong(long v) {
+ fail();
+ }
+
+ public void writeBoolean(boolean v) {
+ fail();
+ }
+
+ public void writeBytes(String s) {
+ fail();
+ }
+
+ public void writeChars(String s){
+ fail();
+ }
+ });
+ }
+
+ public void testReadExternal() throws IOException, ClassNotFoundException {
+ mimeType.readExternal(new ObjectInput() {
+ public String readUTF() {
+ return "text/plain; charset=iso-8859-1";
+ }
+
+ public int available() {
+ fail();
+ throw new AssertionError();
+ }
+
+ public int read() {
+ fail();
+ throw new AssertionError();
+ }
+
+ public void close() {
+ fail();
+ throw new AssertionError();
+ }
+
+ public long skip(long n) {
+ fail();
+ throw new AssertionError();
+ }
+
+ public int read(byte b[]) {
+ fail();
+ throw new AssertionError();
+ }
+
+ public int read(byte b[], int off, int len) {
+ fail();
+ throw new AssertionError();
+ }
+
+ public Object readObject() {
+ fail();
+ throw new AssertionError();
+ }
+
+ public byte readByte() {
+ fail();
+ throw new AssertionError();
+ }
+
+ public char readChar() {
+ fail();
+ throw new AssertionError();
+ }
+
+ public double readDouble() {
+ fail();
+ throw new AssertionError();
+ }
+
+ public float readFloat() {
+ fail();
+ throw new AssertionError();
+ }
+
+ public int readInt() {
+ fail();
+ throw new AssertionError();
+ }
+
+ public int readUnsignedByte() {
+ fail();
+ throw new AssertionError();
+ }
+
+ public int readUnsignedShort() {
+ fail();
+ throw new AssertionError();
+ }
+
+ public long readLong() {
+ fail();
+ throw new AssertionError();
+ }
+
+ public short readShort() {
+ fail();
+ throw new AssertionError();
+ }
+
+ public boolean readBoolean() {
+ fail();
+ throw new AssertionError();
+ }
+
+ public int skipBytes(int n) {
+ fail();
+ throw new AssertionError();
+ }
+
+ public void readFully(byte b[]) {
+ fail();
+ }
+
+ public void readFully(byte b[], int off, int len) {
+ fail();
+ }
+
+ public String readLine() {
+ fail();
+ throw new AssertionError();
+ }
+ });
+ assertEquals("text/plain", mimeType.getBaseType());
+ assertEquals("text", mimeType.getPrimaryType());
+ assertEquals("plain", mimeType.getSubType());
+ MimeTypeParameterList params = mimeType.getParameters();
+ assertEquals(1, params.size());
+ assertEquals("iso-8859-1", params.get("charset"));
+ assertEquals("text/plain; charset=iso-8859-1", mimeType.toString());
+ }
+}
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/MimeTypeTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/MimeTypeTest.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/MimeTypeTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/MimetypesFileTypeMapTest.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/MimetypesFileTypeMapTest.java?view=auto&rev=452976
==============================================================================
--- geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/MimetypesFileTypeMapTest.java (added)
+++ geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/MimetypesFileTypeMapTest.java Wed Oct 4 11:57:33 2006
@@ -0,0 +1,55 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ * 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.
+ */
+
+//
+// This source code implements specifications defined by the Java
+// Community Process. In order to remain compliant with the specification
+// DO NOT add / change / or delete method signatures!
+//
+package javax.activation;
+
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MimetypesFileTypeMapTest extends TestCase {
+ private MimetypesFileTypeMap typeMap;
+
+ public void testDefault() {
+ // unmapped
+ assertEquals("application/octet-stream", typeMap.getContentType("x.foo"));
+ // from META-INF/mimetypes.default
+ assertEquals("text/html", typeMap.getContentType("x.html"));
+ }
+
+ public void testCommentRemoval() {
+ typeMap.addMimeTypes(" text/foo foo #txt");
+ assertEquals("text/foo", typeMap.getContentType("x.foo"));
+ typeMap.addMimeTypes("#text/foo bar");
+ assertEquals("text/foo", typeMap.getContentType("x.foo"));
+ typeMap.addMimeTypes("text/foo #bar");
+ assertEquals("text/foo", typeMap.getContentType("x.foo"));
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ typeMap = new MimetypesFileTypeMap();
+ }
+}
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/MimetypesFileTypeMapTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/MimetypesFileTypeMapTest.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-activation_1.1_spec/src/test/java/javax/activation/MimetypesFileTypeMapTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/specs/trunk/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/pom.xml?view=diff&rev=452976&r1=452975&r2=452976
==============================================================================
--- geronimo/specs/trunk/pom.xml (original)
+++ geronimo/specs/trunk/pom.xml Wed Oct 4 11:57:33 2006
@@ -31,26 +31,27 @@
<artifactId>specs</artifactId>
<name>Geronimo Specifications</name>
<packaging>pom</packaging>
-
+
<version>1.2-SNAPSHOT</version>
-
+
<description>
Provides open-source implementations of Sun specifications.
</description>
-
+
<scm>
<connection>scm:svn:http://svn.apache.org/repos/asf/geronimo/specs/trunk/</connection>
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/geronimo/specs/trunk/</developerConnection>
<url>http://svn.apache.org/viewvc/geronimo/specs/trunk/</url>
</scm>
-
+
<properties>
<!--
TODO: Remove these properties
-->
-
+
<geronimoSpecsAnnotationVersion>1.0-SNAPSHOT</geronimoSpecsAnnotationVersion>
- <geronimoSpecsActivationVersion>1.1</geronimoSpecsActivationVersion>
+ <geronimoSpecsActivation102Version>1.1</geronimoSpecsActivation102Version>
+ <geronimoSpecsActivation11Version>1.0-SNAPSHOT</geronimoSpecsActivation11Version>
<geronimoSpecsCommonjVersion>1.0.1-SNAPSHOT</geronimoSpecsCommonjVersion>
<geronimoSpecsCorbaVersion>1.0</geronimoSpecsCorbaVersion>
<geronimoSpecsCorba30Version>1.1</geronimoSpecsCorba30Version>
@@ -76,50 +77,56 @@
<geronimoSpecsSaajVersion>1.0.1</geronimoSpecsSaajVersion>
<geronimoSpecsServletVersion>1.0.1</geronimoSpecsServletVersion>
</properties>
-
+
<dependencyManagement>
<dependencies>
-
+
<!--
TODO: Remove these...
-->
-
+
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-annotation_1.0_spec</artifactId>
<version>${geronimoSpecsAnnotationVersion}</version>
</dependency>
-
+
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-activation_1.0.2_spec</artifactId>
- <version>${geronimoSpecsActivationVersion}</version>
+ <version>${geronimoSpecsActivation102Version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-activation_1.1_spec</artifactId>
+ <version>${geronimoSpecsActivation11Version}</version>
</dependency>
-
+
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-commonj_1.1_spec</artifactId>
<version>${geronimoSpecsCommonjVersion}</version>
</dependency>
-
+
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-corba_3.0_spec</artifactId>
<version>${geronimoSpecsCorba30Version}</version>
</dependency>
-
+
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-corba_2.3_spec</artifactId>
<version>${geronimoSpecsCorba23Version}</version>
</dependency>
-
+
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-ejb_2.1_spec</artifactId>
<version>${geronimoSpecsEjb21Version}</version>
</dependency>
-
+
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-ejb_3.0_spec</artifactId>
@@ -137,49 +144,49 @@
<artifactId>geronimo-j2ee-connector_1.5_spec</artifactId>
<version>${geronimoSpecsJ2eeConnectorVersion}</version>
</dependency>
-
+
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-j2ee-deployment_1.1_spec</artifactId>
<version>${geronimoSpecsJ2eeDeploymentVersion}</version>
</dependency>
-
+
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-j2ee-jacc_1.0_spec</artifactId>
<version>${geronimoSpecsJ2eeJaccVersion}</version>
</dependency>
-
+
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-j2ee-management_1.0_spec</artifactId>
<version>${geronimoSpecsJ2eeManagementVersion}</version>
</dependency>
-
+
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-javamail_1.3.1_spec</artifactId>
<version>${geronimoSpecsJavamail13Version}</version>
</dependency>
-
+
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-javamail_1.4_spec</artifactId>
<version>${geronimoSpecsJavamail14Version}</version>
</dependency>
-
+
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jaxr_1.0_spec</artifactId>
<version>${geronimoSpecsJaxrVersion}</version>
</dependency>
-
+
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jaxrpc_1.1_spec</artifactId>
<version>${geronimoSpecsJaxrpcVersion}</version>
</dependency>
-
+
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jpa_3.0_spec</artifactId>
@@ -191,25 +198,25 @@
<artifactId>geronimo-jsp_2.0_spec</artifactId>
<version>${geronimoSpecsJspVersion}</version>
</dependency>
-
+
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jms_1.1_spec</artifactId>
<version>${geronimoSpecsJmsVersion}</version>
</dependency>
-
+
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jsr181_2.0_spec</artifactId>
<version>${geronimoSpecsJsr181Version}</version>
</dependency>
-
+
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jta_1.0.1B_spec</artifactId>
<version>${geronimoSpecsJta101bVersion}</version>
</dependency>
-
+
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jta_1.1_spec</artifactId>
@@ -221,19 +228,19 @@
<artifactId>geronimo-qname_1.1_spec</artifactId>
<version>${geronimoSpecsQnameVersion}</version>
</dependency>
-
+
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-saaj_1.1_spec</artifactId>
<version>${geronimoSpecsSaajVersion}</version>
</dependency>
-
+
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-servlet_2.4_spec</artifactId>
<version>${geronimoSpecsServletVersion}</version>
</dependency>
-
+
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-servlet_2.5_spec</artifactId>
@@ -245,39 +252,39 @@
<artifactId>mx4j</artifactId>
<version>3.0.1</version>
</dependency>
-
+
<dependency>
<groupId>mockobjects</groupId>
<artifactId>mockobjects-jdk1.4-j2ee1.3</artifactId>
<version>0.09</version>
</dependency>
-
+
<dependency>
<groupId>mockobjects</groupId>
<artifactId>mockobjects-core</artifactId>
<version>0.09</version>
</dependency>
-
+
<dependency>
<groupId>scout</groupId>
<artifactId>scout</artifactId>
<version>0.5</version>
</dependency>
-
+
</dependencies>
</dependencyManagement>
<dependencies>
-
+
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
-
+
</dependencies>
-
+
<build>
<plugins>
<plugin>
@@ -293,7 +300,7 @@
</execution>
</executions>
</plugin>
-
+
<!--
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -312,7 +319,7 @@
</executions>
</plugin>
-->
-
+
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
@@ -321,7 +328,7 @@
<target>1.4</target>
</configuration>
</plugin>
-
+
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-idea-plugin</artifactId>
@@ -340,9 +347,10 @@
</plugin>
</plugins>
</build>
-
+
<modules>
<module>geronimo-activation_1.0.2_spec</module>
+ <module>geronimo-activation_1.1_spec</module>
<module>geronimo-commonj_1.1_spec</module>
<module>geronimo-corba_3.0_spec</module>
<module>geronimo-corba_2.3_spec</module>
@@ -363,19 +371,19 @@
<module>geronimo-saaj_1.1_spec</module>
<module>geronimo-servlet_2.4_spec</module>
<module>geronimo-servlet_2.5_spec</module>
-
+
<!--
NOTE: This is needed for the moment for Geronimo to pass the TCK
-->
<module>geronimo-spec-corba</module>
-
+
<!--
NOTE: This is going to be phased out.
-
+
<module>geronimo-j2ee_1.4_spec</module>
-->
</modules>
-
+
<profiles>
<!--
NOTE: Some modules require JDK 1.5 to build, only enable them if our
@@ -383,11 +391,11 @@
-->
<profile>
<id>jdk1.5</id>
-
+
<activation>
<jdk>1.5</jdk>
</activation>
-
+
<modules>
<module>geronimo-annotation_1.0_spec</module>
<module>geronimo-ejb_3.0_spec</module>
@@ -397,7 +405,7 @@
</modules>
</profile>
</profiles>
-
+
<repositories>
<!--
NOTE: The default repositories are picked up by Genesis, but need to