index
int64
0
0
repo_id
stringlengths
9
205
file_path
stringlengths
31
246
content
stringlengths
1
12.2M
__index_level_0__
int64
0
10k
0
Create_ds/geronimo-specs/geronimo-ejb_3.1_spec/src/main/java/javax
Create_ds/geronimo-specs/geronimo-ejb_3.1_spec/src/main/java/javax/ejb/TransactionRolledbackLocalException.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.ejb; /** * @version $Rev$ $Date$ */ public class TransactionRolledbackLocalException extends EJBException { public TransactionRolledbackLocalException() { super(); } public TransactionRolledbackLocalException(String message) { super(message); } public TransactionRolledbackLocalException(String message, Exception ex) { super(message, ex); } }
1,800
0
Create_ds/geronimo-specs/geronimo-ejb_3.1_spec/src/main/java/javax
Create_ds/geronimo-specs/geronimo-ejb_3.1_spec/src/main/java/javax/ejb/EJBException.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.ejb; import java.io.PrintStream; import java.io.PrintWriter; /** * @version $Rev$ $Date$ */ public class EJBException extends RuntimeException { private static final long serialVersionUID = 796770993296843510L; private Exception causeException; public EJBException() { super(); } public EJBException(Exception causeException) { super(causeException); } public EJBException(String message) { super(message); } public EJBException(String message, Exception causeException) { super(message, causeException); } public Exception getCausedByException() { Throwable cause = getCause(); if (cause instanceof Exception) { return (Exception) cause; } return null; } public String getMessage() { return super.getMessage(); } public void printStackTrace(PrintStream ps) { super.printStackTrace(ps); } public void printStackTrace() { super.printStackTrace(); } public void printStackTrace(PrintWriter pw) { super.printStackTrace(pw); } }
1,801
0
Create_ds/geronimo-specs/geronimo-ejb_3.1_spec/src/main/java/javax
Create_ds/geronimo-specs/geronimo-ejb_3.1_spec/src/main/java/javax/ejb/Lock.java
/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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.ejb; import static javax.ejb.LockType.WRITE; import static java.lang.annotation.RetentionPolicy.RUNTIME; import static java.lang.annotation.ElementType.TYPE; import static java.lang.annotation.ElementType.METHOD; @java.lang.annotation.Target(value = {TYPE, METHOD}) @java.lang.annotation.Retention(value = RUNTIME) public @interface Lock { javax.ejb.LockType value() default WRITE; }
1,802
0
Create_ds/geronimo-specs/geronimo-ejb_3.1_spec/src/main/java/javax
Create_ds/geronimo-specs/geronimo-ejb_3.1_spec/src/main/java/javax/ejb/SessionContext.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.ejb; import javax.xml.rpc.handler.MessageContext; import java.util.Map; /** * @version $Rev$ $Date$ */ public interface SessionContext extends EJBContext { EJBLocalObject getEJBLocalObject() throws IllegalStateException; EJBObject getEJBObject() throws IllegalStateException; MessageContext getMessageContext() throws IllegalStateException; <T> T getBusinessObject(Class<T> businessInterface); Class getInvokedBusinessInterface(); boolean wasCancelCalled(); }
1,803
0
Create_ds/geronimo-specs/geronimo-ejb_3.1_spec/src/main/java/javax
Create_ds/geronimo-specs/geronimo-ejb_3.1_spec/src/main/java/javax/ejb/AccessLocalException.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.ejb; /** * @version $Rev$ $Date$ */ public class AccessLocalException extends EJBException { public AccessLocalException() { super(); } public AccessLocalException(String message) { super(message); } public AccessLocalException(String message, Exception ex) { super(message, ex); } }
1,804
0
Create_ds/geronimo-specs/geronimo-ejb_3.1_spec/src/main/java/javax
Create_ds/geronimo-specs/geronimo-ejb_3.1_spec/src/main/java/javax/ejb/MessageDriven.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.ejb; import java.lang.annotation.Target; import java.lang.annotation.Retention; import java.lang.annotation.ElementType; import java.lang.annotation.RetentionPolicy; /** * @version $Rev$ $Date$ */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) public @interface MessageDriven { String name() default ""; Class messageListenerInterface() default Object.class; ActivationConfigProperty[] activationConfig() default {}; String mappedName() default ""; String description() default ""; }
1,805
0
Create_ds/geronimo-specs/geronimo-ejb_3.1_spec/src/main/java/javax
Create_ds/geronimo-specs/geronimo-ejb_3.1_spec/src/main/java/javax/ejb/Handle.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.ejb; import java.io.Serializable; import java.rmi.RemoteException; /** * @version $Rev$ $Date$ */ public interface Handle extends Serializable { EJBObject getEJBObject() throws RemoteException; }
1,806
0
Create_ds/geronimo-specs/geronimo-ejb_3.1_spec/src/main/java/javax
Create_ds/geronimo-specs/geronimo-ejb_3.1_spec/src/main/java/javax/ejb/RemoteHome.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.ejb; import java.lang.annotation.Target; import java.lang.annotation.Retention; import java.lang.annotation.ElementType; import java.lang.annotation.RetentionPolicy; /** * @version $Rev$ $Date$ */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) public @interface RemoteHome { Class value(); }
1,807
0
Create_ds/geronimo-specs/geronimo-ejb_3.1_spec/src/main/java/javax
Create_ds/geronimo-specs/geronimo-ejb_3.1_spec/src/main/java/javax/ejb/TransactionRequiredLocalException.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.ejb; /** * @version $Rev$ $Date$ */ public class TransactionRequiredLocalException extends EJBException { public TransactionRequiredLocalException() { super(); } public TransactionRequiredLocalException(String message) { super(message); } }
1,808
0
Create_ds/geronimo-specs/geronimo-ejb_3.1_spec/src/main/java/javax
Create_ds/geronimo-specs/geronimo-ejb_3.1_spec/src/main/java/javax/ejb/SessionSynchronization.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.ejb; import java.rmi.RemoteException; /** * @version $Rev$ $Date$ */ public interface SessionSynchronization { void afterBegin() throws EJBException, RemoteException; void afterCompletion(boolean committed) throws EJBException, RemoteException; void beforeCompletion() throws EJBException, RemoteException; }
1,809
0
Create_ds/geronimo-specs/geronimo-ejb_3.1_spec/src/main/java/javax
Create_ds/geronimo-specs/geronimo-ejb_3.1_spec/src/main/java/javax/ejb/CreateException.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.ejb; /** * @version $Rev$ $Date$ */ public class CreateException extends Exception { public CreateException() { super(); } public CreateException(String message) { super(message); } }
1,810
0
Create_ds/geronimo-specs/geronimo-ejb_3.1_spec/src/main/java/javax
Create_ds/geronimo-specs/geronimo-ejb_3.1_spec/src/main/java/javax/ejb/EntityBean.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.ejb; import java.rmi.RemoteException; /** * @version $Rev$ $Date$ */ public interface EntityBean extends EnterpriseBean { void ejbActivate() throws EJBException, RemoteException; void ejbLoad() throws EJBException, RemoteException; void ejbPassivate() throws EJBException, RemoteException; void ejbRemove() throws RemoveException, EJBException, RemoteException; void ejbStore() throws EJBException, RemoteException; void setEntityContext(EntityContext ctx) throws EJBException, RemoteException; void unsetEntityContext() throws EJBException, RemoteException; }
1,811
0
Create_ds/geronimo-specs/geronimo-ejb_3.1_spec/src/main/java/javax
Create_ds/geronimo-specs/geronimo-ejb_3.1_spec/src/main/java/javax/ejb/TransactionAttributeType.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.ejb; /** * @version $Rev$ $Date$ */ public enum TransactionAttributeType { MANDATORY, REQUIRED, REQUIRES_NEW, SUPPORTS, NOT_SUPPORTED, NEVER; }
1,812
0
Create_ds/geronimo-specs/geronimo-ejb_3.1_spec/src/main/java/javax/ejb
Create_ds/geronimo-specs/geronimo-ejb_3.1_spec/src/main/java/javax/ejb/embeddable/EJBContainer.java
/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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.ejb.embeddable; import java.util.Collections; import java.util.List; import javax.ejb.EJBException; import javax.ejb.spi.EJBContainerProvider; import org.apache.geronimo.osgi.locator.ProviderLocator; public abstract class EJBContainer { public static final String PROVIDER = "javax.ejb.embeddable.provider"; public static final String APP_NAME = "javax.ejb.embeddable.appName"; public static final String MODULES = "javax.ejb.embeddable.modules"; public EJBContainer() { } public abstract void close(); public static EJBContainer createEJBContainer() { return createEJBContainer(Collections.EMPTY_MAP); } public static EJBContainer createEJBContainer(java.util.Map<?, ?> properties) { if (properties == null) { properties = Collections.EMPTY_MAP; } try { ClassLoader loader = Thread.currentThread().getContextClassLoader(); // go check the loader files. List<Object> providers = ProviderLocator.getServices(EJBContainerProvider.class.getName(), EJBContainer.class, loader); for (Object o : providers) { EJBContainer container = ((EJBContainerProvider) o).createEJBContainer(properties); if (container != null) { return container; } } throw new EJBException("Provider error. No provider definition found"); } catch (EJBException e) { // if the container provider throws an EJBException, don't wrap another one // around the original. throw e; } catch (Exception e) { throw new EJBException("Provider error. No provider found", e); } } public abstract javax.naming.Context getContext(); }
1,813
0
Create_ds/geronimo-specs/geronimo-ejb_3.1_spec/src/main/java/javax/ejb
Create_ds/geronimo-specs/geronimo-ejb_3.1_spec/src/main/java/javax/ejb/spi/HandleDelegate.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.ejb.spi; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import javax.ejb.EJBHome; import javax.ejb.EJBObject; /** * @version $Rev$ $Date$ */ public interface HandleDelegate { EJBHome readEJBHome(ObjectInputStream istream) throws ClassNotFoundException, IOException; EJBObject readEJBObject(ObjectInputStream istream) throws ClassNotFoundException, IOException; void writeEJBHome(EJBHome ejbHome, ObjectOutputStream ostream) throws IOException; void writeEJBObject(EJBObject ejbObject, ObjectOutputStream ostream) throws IOException; }
1,814
0
Create_ds/geronimo-specs/geronimo-ejb_3.1_spec/src/main/java/javax/ejb
Create_ds/geronimo-specs/geronimo-ejb_3.1_spec/src/main/java/javax/ejb/spi/EJBContainerProvider.java
/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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.ejb.spi; import javax.ejb.embeddable.EJBContainer; public interface EJBContainerProvider { public EJBContainer createEJBContainer(java.util.Map<?,?> properties); }
1,815
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/ServiceException.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc; /** * The <code>javax.xml.rpc.ServiceException</code> is thrown from the * methods in the <code>javax.xml.rpc.Service</code> interface and * <code>ServiceFactory</code> class. * * * @version $Rev$ $Date$ */ public class ServiceException extends Exception { // fixme: could we refactor this to use the jdk1.4 exception wrapping stuff? /** The cause of this exception. */ Throwable cause; /** * Constructs a new exception with <code>null</code> as its * detail message. The cause is not initialized. */ public ServiceException() {} /** * Constructs a new exception with the specified detail * message. The cause is not initialized. * * @param message The detail message which is later * retrieved using the <code>getMessage</code> method */ public ServiceException(String message) { super(message); } /** * Constructs a new exception with the specified detail * message and cause. * * @param message the detail message which is later retrieved * using the <code>getMessage</code> method * @param cause the cause which is saved for the later * retrieval throw by the <code>getCause</code> * method */ public ServiceException(String message, Throwable cause) { super(message); this.cause = cause; } /** * Constructs a new exception with the specified cause * and a detail message of <tt>(cause==null ? null : * cause.toString())</tt> (which typically contains the * class and detail message of <tt>cause</tt>). * * @param cause the cause which is saved for the later * retrieval throw by the getCause method. * (A <tt>null</tt> value is permitted, and * indicates that the cause is nonexistent or * unknown.) */ public ServiceException(Throwable cause) { super( (cause == null) ? null : cause.toString() ); this.cause = cause; } /** * Gets the linked cause. * * @return the cause of this Exception or <code>null</code> * if the cause is noexistent or unknown */ public Throwable getLinkedCause() { return cause; } }
1,816
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/NamespaceConstants.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc; /** * Constants used in JAX-RPC for namespace prefixes and URIs. * * @version $Rev$ $Date$ */ public class NamespaceConstants { // fixme: we should have a private constructor and/or be final /** * Constructor NamespaceConstants. */ public NamespaceConstants() {} /** Namespace prefix for SOAP Envelope. */ public static final String NSPREFIX_SOAP_ENVELOPE = "soapenv"; /** Namespace prefix for SOAP Encoding. */ public static final String NSPREFIX_SOAP_ENCODING = "soapenc"; /** Namespace prefix for XML schema XSD. */ public static final String NSPREFIX_SCHEMA_XSD = "xsd"; /** Namespace prefix for XML Schema XSI. */ public static final String NSPREFIX_SCHEMA_XSI = "xsi"; /** Nameapace URI for SOAP 1.1 Envelope. */ public static final String NSURI_SOAP_ENVELOPE = "http://schemas.xmlsoap.org/soap/envelope/"; /** Nameapace URI for SOAP 1.1 Encoding. */ public static final String NSURI_SOAP_ENCODING = "http://schemas.xmlsoap.org/soap/encoding/"; /** Nameapace URI for SOAP 1.1 next actor role. */ public static final String NSURI_SOAP_NEXT_ACTOR = "http://schemas.xmlsoap.org/soap/actor/next"; /** Namespace URI for XML Schema XSD. */ public static final String NSURI_SCHEMA_XSD = "http://www.w3.org/2001/XMLSchema"; /** Namespace URI for XML Schema XSI. */ public static final String NSURI_SCHEMA_XSI = "http://www.w3.org/2001/XMLSchema-instance"; }
1,817
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/Stub.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc; import java.util.Iterator; /** * The interface <code>javax.xml.rpc.Stub</code> is the common base interface * for the stub classes. All generated stub classes are required to * implement the <code>javax.xml.rpc.Stub</code> interface. An instance * of a stub class represents a client side proxy or stub instance for * the target service endpoint. * * <p>The <code>javax.xml.rpc.Stub</code> interface provides an * extensible property mechanism for the dynamic configuration of * a stub instance. * * @version $Rev$ $Date$ */ public interface Stub { // Constants for the standard properties /** * Standard property: User name for authentication. * <p>Type: java.lang.String */ public static final String USERNAME_PROPERTY = Call.USERNAME_PROPERTY; /** * Standard property: Password for authentication. * <p>Type: java.lang.String */ public static final String PASSWORD_PROPERTY = Call.PASSWORD_PROPERTY; /** * Standard property: Target service endpoint address. The * URI scheme for the endpoint address specification must * correspond to the protocol/transport binding for this * stub class. * <p>Type: java.lang.String */ public static final String ENDPOINT_ADDRESS_PROPERTY = "javax.xml.rpc.service.endpoint.address"; /** * Standard property: This boolean property is used by a service * client to indicate whether or not it wants to participate in * a session with a service endpoint. If this property is set to * true, the service client indicates that it wants the session * to be maintained. If set to false, the session is not maintained. * The default value for this property is false. * <p>Type: java.lang.Boolean */ public static final String SESSION_MAINTAIN_PROPERTY = Call.SESSION_MAINTAIN_PROPERTY; /** * Sets the name and value of a configuration property * for this Stub instance. If the Stub instances contains * a value of the same property, the old value is replaced. * <p>Note that the <code>_setProperty</code> method may not * perform validity check on a configured property value. An * example is the standard property for the target service * endpoint address that is not checked for validity in the * <code>_setProperty</code> method. * In this case, stub configuration errors are detected at * the remote method invocation. * * @param name Name of the configuration property * @param value Value of the property * @throws JAXRPCException <ul> * <li>If an optional standard property name is * specified, however this Stub implementation * class does not support the configuration of * this property. * <li>If an invalid or unsupported property name is * specified or if a value of mismatched property * type is passed. * <li>If there is any error in the configuration of * a valid property. * </ul> */ public void _setProperty(String name, Object value); /** * Gets the value of a specific configuration property. * * @param name Name of the property whose value is to be * retrieved * @return Value of the configuration property * @throws JAXRPCException if an invalid or * unsupported property name is passed. */ public Object _getProperty(String name); /** * Returns an <code>Iterator</code> view of the names of the properties * that can be configured on this stub instance. * * @return Iterator for the property names of the type * <code>java.lang.String</code> */ public Iterator _getPropertyNames(); } // interface Stub
1,818
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/ParameterMode.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc; /** * The <code>javax.xml.rpc.ParameterMode</code> is a type-safe * enumeration for parameter mode. This class is used in the * <code>Call</code>API to specify parameter passing modes. * * @version $Rev$ $Date$ */ public class ParameterMode { /** Mode name. */ private final String mode; /** The mode is 'IN'. */ public static final ParameterMode IN = new ParameterMode("IN"); /** The mode is 'INOUT'. */ public static final ParameterMode INOUT = new ParameterMode("INOUT"); /** The mode is 'OUT'. */ public static final ParameterMode OUT = new ParameterMode("OUT"); /** * Make a new mode. * * @param mode name for the mode */ private ParameterMode(String mode) { this.mode = mode; } public String toString() { return mode; } }
1,819
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/FactoryFinder.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.InputStream; import java.io.InputStreamReader; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Properties; import org.apache.geronimo.osgi.locator.ProviderLocator; /** * This code is designed to implement the pluggability * feature and is designed to both compile and run on JDK version 1.1 and * later. The code also runs both as part of an unbundled jar file and * when bundled as part of the JDK. * * This class is duplicated for each subpackage so keep it in sync. * It is package private and therefore is not exposed as part of the JAXRPC * API. * * @version $Rev$ $Date$ */ class FactoryFinder { /** Set to true for debugging. */ private static final boolean debug = false; private static void debugPrintln(String msg) { if (debug) { System.err.println("JAXRPC: " + msg); } } /** * Figure out which ClassLoader to use. For JDK 1.2 and later use * the context ClassLoader. * * @return the <code>ClassLoader</code> * @throws ConfigurationError if this class is unable to work with the * host JDK */ private static ClassLoader findClassLoader() throws ConfigurationError { Method m = null; try { m = Thread.class.getMethod("getContextClassLoader", null); } catch (NoSuchMethodException e) { // Assume that we are running JDK 1.1, use the current ClassLoader debugPrintln("assuming JDK 1.1"); return FactoryFinder.class.getClassLoader(); } try { return (ClassLoader) m.invoke(Thread.currentThread(), null); } catch (IllegalAccessException e) { // assert(false) throw new ConfigurationError("Unexpected IllegalAccessException", e); } catch (InvocationTargetException e) { // assert(e.getTargetException() instanceof SecurityException) throw new ConfigurationError("Unexpected InvocationTargetException", e); } } /** * Create an instance of a class using the specified * <code>ClassLoader</code>, or if that fails from the * <code>ClassLoader</code> that loaded this class. * * @param className the name of the class to instantiate * @param classLoader a <code>ClassLoader</code> to load the class from * * @return a new <code>Object</code> that is an instance of the class of * the given name from the given class loader * @throws ConfigurationError if the class could not be found or * instantiated */ private static Object newInstance(String className, ClassLoader classLoader) throws ConfigurationError { try { return ProviderLocator.loadClass(className, FactoryFinder.class, classLoader).newInstance(); } catch (ClassNotFoundException x) { throw new ConfigurationError( "Provider " + className + " not found", x); } catch (Exception x) { throw new ConfigurationError( "Provider " + className + " could not be instantiated: " + x, x); } } /** * Finds the implementation Class object in the specified order. Main * entry point. * @return Class object of factory, never null * * @param factoryId Name of the factory to find, same as * a property name * @param fallbackClassName Implementation class name, if nothing else * is found. Use null to mean no fallback. * * @exception FactoryFinder.ConfigurationError * * Package private so this code can be shared. */ static Object find(Class<?> factoryType, String fallbackClassName) throws ConfigurationError { String factoryId = factoryType.getName(); debugPrintln("debug is on"); // NOTE: The spec does not identify the search order for this, // other than to note it can be overridden by the system property. The // STAX ordering is used here. ClassLoader classLoader = findClassLoader(); // Use the system property first try { String systemProp = System.getProperty( factoryId ); if( systemProp!=null) { debugPrintln("found system property " + systemProp); return newInstance(systemProp, classLoader); } } catch (SecurityException se) { } try { // try to read from $java.home/lib/jaxrpc.properties String factoryClassName = ProviderLocator.lookupByJREPropertyFile("lib" + File.separator + "jaxrpc.properties", factoryId); if (factoryClassName != null) { debugPrintln("found java.home property " + factoryClassName); return newInstance(factoryClassName, classLoader); } } catch (Exception ex) { if( debug ) ex.printStackTrace(); } try { // check the META-INF/services definitions, and return it if // we find something. Object service = ProviderLocator.getService(factoryId, FactoryFinder.class, classLoader); if (service != null) { return service; } } catch (Exception ex) { if( debug ) ex.printStackTrace(); } if (fallbackClassName == null) { throw new ConfigurationError( "Provider for " + factoryId + " cannot be found", null); } debugPrintln("loaded from fallback value: " + fallbackClassName); return newInstance(fallbackClassName, classLoader); } static class ConfigurationError extends Error { // fixme: should this be refactored to use the jdk1.4 exception // wrapping? private Exception exception; /** * Construct a new instance with the specified detail string and * exception. * * @param msg the Message for this error * @param x an Exception that caused this failure, or null */ ConfigurationError(String msg, Exception x) { super(msg); this.exception = x; } Exception getException() { return exception; } } }
1,820
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/ServiceFactory.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc; import javax.xml.namespace.QName; import java.net.URL; /** * The <code>javax.xml.rpc.ServiceFactory</code> is an abstract class * that provides a factory for the creation of instances of the type * <code>javax.xml.rpc.Service</code>. This abstract class follows the * abstract static factory design pattern. This enables a J2SE based * client to create a <code>Service instance</code> in a portable manner * without using the constructor of the <code>Service</code> * implementation class. * <p> * The ServiceFactory implementation class is set using the * system property <code>SERVICEFACTORY_PROPERTY</code>. * * @version $Rev$ $Date$ */ public abstract class ServiceFactory { /** Protected constructor. */ protected ServiceFactory() {} /** * A constant representing the property used to lookup the * name of a <code>ServiceFactory</code> implementation * class. */ public static final java.lang.String SERVICEFACTORY_PROPERTY = "javax.xml.rpc.ServiceFactory"; /** * Gets an instance of the <code>ServiceFactory</code> * * <p>Only one copy of a factory exists and is returned to the * application each time this method is called. * * <p> The implementation class to be used can be overridden by * setting the javax.xml.rpc.ServiceFactory system property. * * @return ServiceFactory. * @throws ServiceException */ public static ServiceFactory newInstance() throws ServiceException { try { return (ServiceFactory) FactoryFinder.find( /* The default property name according to the JAXRPC spec */ ServiceFactory.class, /* The fallback implementation class name */ "org.apache.axis.client.ServiceFactory"); } catch (FactoryFinder.ConfigurationError e) { throw new ServiceException(e.getException()); } } /** * Create a <code>Service</code> instance. * * @param wsdlDocumentLocation URL for the WSDL document location * @param serviceName QName for the service. * @return Service. * @throws ServiceException If any error in creation of the * specified service */ public abstract Service createService( URL wsdlDocumentLocation, QName serviceName) throws ServiceException; /** * Create a <code>Service</code> instance. * * @param serviceName QName for the service * @return Service. * @throws ServiceException If any error in creation of the specified service */ public abstract Service createService(QName serviceName) throws ServiceException; public abstract Service loadService(java.lang.Class class1) throws ServiceException; public abstract Service loadService(java.net.URL url, java.lang.Class class1, java.util.Properties properties) throws ServiceException; public abstract Service loadService(java.net.URL url, QName qname, java.util.Properties properties) throws ServiceException; }
1,821
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/Call.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc; import javax.xml.namespace.QName; import java.util.Iterator; import java.util.List; import java.util.Map; /** * The <code>javax.xml.rpc.Call</code> interface provides support * for the dynamic invocation of a service endpoint. The * <code>javax.xml.rpc.Service</code> interface acts as a factory * for the creation of <code>Call</code> instances. * <p> * Once a <code>Call</code> instance is created, various setter * and getter methods may be used to configure this <code>Call</code> * instance. * * @version $Rev$ $Date$ */ public interface Call { /** * Standard property: User name for authentication * <p>Type: <code>java.lang.String */ public static final String USERNAME_PROPERTY = "javax.xml.rpc.security.auth.username"; /** * Standard property: Password for authentication * <p>Type: <code>java.lang.String</code> */ public static final String PASSWORD_PROPERTY = "javax.xml.rpc.security.auth.password"; /** * Standard property for operation style. This property is * set to "rpc" if the operation style is rpc; "document" * if the operation style is document. * <p>Type: <code>java.lang.String</code> */ public static final String OPERATION_STYLE_PROPERTY = "javax.xml.rpc.soap.operation.style"; /** * Standard property for SOAPAction. This boolean property * indicates whether or not SOAPAction is to be used. The * default value of this property is false indicating that * the SOAPAction is not used. * <p>Type: <code>java.lang.Boolean</code> */ public static final String SOAPACTION_USE_PROPERTY = "javax.xml.rpc.soap.http.soapaction.use"; /** * Standard property for SOAPAction. Indicates the SOAPAction * URI if the <code>javax.xml.rpc.soap.http.soapaction.use</code> * property is set to <code>true</code>. * <p>Type: <code>java.lang.String</code> */ public static final String SOAPACTION_URI_PROPERTY = "javax.xml.rpc.soap.http.soapaction.uri"; /** * Standard property for encoding Style: Encoding style specified * as a namespace URI. The default value is the SOAP 1.1 encoding * <code>http://schemas.xmlsoap.org/soap/encoding/</code> * <p>Type: <code>java.lang.String</code> */ public static final String ENCODINGSTYLE_URI_PROPERTY = "javax.xml.rpc.encodingstyle.namespace.uri"; /** * Standard property: This boolean property is used by a service * client to indicate whether or not it wants to participate in * a session with a service endpoint. If this property is set to * true, the service client indicates that it wants the session * to be maintained. If set to false, the session is not maintained. * The default value for this property is <code>false</code>. * <p>Type: <code>java.lang.Boolean</code> */ public static final String SESSION_MAINTAIN_PROPERTY = "javax.xml.rpc.session.maintain"; /** * Indicates whether <code>addParameter</code> and * <code>setReturnType</code> methods * are to be invoked to specify the parameter and return type * specification for a specific operation. * * @param operationName Qualified name of the operation * * @return Returns true if the Call implementation class * requires addParameter and setReturnType to be * invoked in the client code for the specified * operation. This method returns false otherwise. */ public boolean isParameterAndReturnSpecRequired(QName operationName); /** * Adds a parameter type and mode for a specific operation. * Note that the client code may not call any * <code>addParameter</code> and <code>setReturnType</code> * methods before calling the <code>invoke</code> method. In * this case, the Call implementation class determines the * parameter types by using reflection on parameters, using * the WSDL description and configured type mapping registry. * * @param paramName Name of the parameter * @param xmlType XML datatype of the parameter * @param parameterMode Mode of the parameter-whether * <code>ParameterMode.IN</code>, * <code>ParameterMode.OUT</code>, * or <code>ParameterMode.INOUT * @throws JAXRPCException This exception may * be thrown if the method <code>isParameterAndReturnSpecRequired</code> * returns <code>false</code> for this operation. * @throws java.lang.IllegalArgumentException If any illegal * parameter name or XML type is specified */ public void addParameter(String paramName, QName xmlType, ParameterMode parameterMode); /** * Adds a parameter type and mode for a specific operation. * This method is used to specify the Java type for either * OUT or INOUT parameters. * * @param paramName Name of the parameter * @param xmlType XML datatype of the parameter * @param javaType The Java class of the parameter * @param parameterMode Mode of the parameter-whether * ParameterMode.IN, OUT or INOUT * @throws JAXRPCException <ul> * * <li>This exception may be thrown if this method is * invoked when the method <code>isParameterAndReturnSpecRequired</code> * returns <code>false</code>. * <li>If specified XML type and Java type mapping * is not valid. For example, <code>TypeMappingRegistry</code> * has no serializers for this mapping. * </ul> * @throws java.lang.IllegalArgumentException If any illegal * parameter name or XML type is specified * @throws java.lang.UnsupportedOperationException If this * method is not supported */ public void addParameter(String paramName, QName xmlType, Class javaType, ParameterMode parameterMode); /** * Gets the XML type of a parameter by name. * * @param paramName name of the parameter * * @return Returns XML type for the specified parameter */ public QName getParameterTypeByName(String paramName); /** * Sets the return type for a specific operation. Invoking * <code>setReturnType(null)</code> removes the return * type for this Call object. * * @param xmlType XML data type of the return value * @throws JAXRPCException This exception * may be thrown when the method * <code>isParameterAndReturnSpecRequired</code> returns * <code>false</code>. * @throws java.lang.IllegalArgumentException If an illegal * XML type is specified */ public void setReturnType(QName xmlType); /** * Sets the return type for a specific operation. * * @param xmlType XML data type of the return value * @param javaType Java class of the return value * @throws JAXRPCException <ul> * <li>This exception may be thrown if this method is * invoked when the method <code>isParameterAndReturnSpecRequired</code> * returns <code>false</code>. * <li>If XML type and Java type cannot be mapped * using the standard type mapping or TypeMapping * registry * </ul> * @throws java.lang.UnsupportedOperationException If this * method is not supported * @throws java.lang.IllegalArgumentException If an illegal * XML type is specified */ public void setReturnType(QName xmlType, Class javaType); /** * Gets the return type for a specific operation. * * @return the XML type for the return value */ public QName getReturnType(); /** * Removes all specified parameters from this <code>Call</code> instance. * Note that this method removes only the parameters and not * the return type. The <code>setReturnType(null)</code> is * used to remove the return type. * * @throws JAXRPCException This exception may be * thrown If this method is called when the method * <code>isParameterAndReturnSpecRequired</code> * returns <code>false</code> for this Call's operation. */ public void removeAllParameters(); /** * Gets the name of the operation to be invoked using this Call instance. * * @return Qualified name of the operation */ public QName getOperationName(); /** * Sets the name of the operation to be invoked using this * <code>Call</code> instance. * * @param operationName QName of the operation to be * invoked using the Call instance */ public void setOperationName(QName operationName); /** * Gets the qualified name of the port type. * * @return Qualified name of the port type */ public QName getPortTypeName(); /** * Sets the qualified name of the port type. * * @param portType Qualified name of the port type */ public void setPortTypeName(QName portType); /** * Sets the address of the target service endpoint. * This address must correspond to the transport specified * in the binding for this <code>Call</code> instance. * * @param address Address of the target service endpoint; * specified as an URI */ public void setTargetEndpointAddress(String address); /** * Gets the address of a target service endpoint. * * @return Endpoint address of the target service port as an URI */ public String getTargetEndpointAddress(); /** * Sets the value for a named property. JAX-RPC specification * specifies a standard set of properties that may be passed * to the <code>Call.setProperty</code> method. * * @param name Name of the property * @param value Value of the property * @throws JAXRPCException <ul> * <li>If an optional standard property name is * specified, however this <code>Call</code> implementation * class does not support the configuration of * this property. * <li>If an invalid (or unsupported) property name is * specified or if a value of mismatched property * type is passed. * <li>If there is any error in the configuration of * a valid property. * </ul> */ public void setProperty(String name, Object value); /** * Gets the value of a named property. * * @param name Name of the property * * @return Value of the named property * @throws JAXRPCException if an invalid or * unsupported property name is passed. */ public Object getProperty(String name); /** * Removes a named property. * * @param name Name of the property * @throws JAXRPCException if an invalid or * unsupported property name is passed. */ public void removeProperty(String name); /** * Gets the names of configurable properties supported by * this <code>Call</code> object. * * @return Iterator for the property names */ public Iterator getPropertyNames(); // Remote Method Invocation methods /** * Invokes a specific operation using a synchronous request-response * interaction mode. * * @param inputParams Object[]--Parameters for this invocation. This * includes only the input params * * @return Returns the return value or <code>null</code> * * @throws java.rmi.RemoteException if there is any error in the remote * method invocation or if the Call * object is not configured properly. * @throws javax.xml.rpc.soap.SOAPFaultException Indicates a SOAP fault * @throws JAXRPCException <ul> * * <li>If there is an error in the configuration of the * <code>Call</code> object * <li>If <code>inputParams</code> do not match the required parameter * set (as specified through the <code>addParameter</code> * invocations or in the corresponding WSDL) * <li>If parameters and return type are incorrectly * specified * </ul> */ public Object invoke(Object[] inputParams) throws java.rmi.RemoteException; /** * Invokes a specific operation using a synchronous request-response * interaction mode. * * @param operationName QName of the operation * @param inputParams Object[]--Parameters for this invocation. This * includes only the input params. * * @return Return value or null * * @throws java.rmi.RemoteException if there is any error in the * remote method invocation. * @throws javax.xml.rpc.soap.SOAPFaultException Indicates a SOAP fault * @throws JAXRPCException <ul> * <li>If there is an error in the configuration of the * <code>Cal</code>l object * <li>If <code>inputParam</code>s do not match the required parameter * set (as specified through the <code>addParameter</code> * invocations or in the corresponding WSDL) * <li>If parameters and return type are incorrectly * specified * </ul> */ public Object invoke(QName operationName, Object[] inputParams) throws java.rmi.RemoteException; /** * Invokes a remote method using the one-way interaction mode. The * client thread does not block waiting for the completion of the * server processing for this remote method invocation. This method * must not throw any remote exceptions. This method may throw a * <code>JAXRPCException</code> during the processing of the one-way * remote call. * * @param params Object[]--Parameters for this invocation. This * includes only the input params. * * @throws JAXRPCException if there is an error in the * configuration of the <code>Call</code> object (example: a * non-void return type has been incorrectly specified for the * one-way call) or if there is any error during the * invocation of the one-way remote call */ public void invokeOneWay(Object[] params); /** * Returns a <code>Map</code> of {name, value} for the output parameters of * the last invoked operation. The parameter names in the * returned Map are of type <code>java.lang.String</code>. * * @return Map Output parameters for the last <code>Call.invoke()</code>. * Empty <code>Map</code> is returned if there are no output * parameters. * @throws javax.xml.rpc.JAXRPCException If this method is invoked for a * one-way operation or is invoked before any * <code>invoke</code> method has been called. */ public Map getOutputParams(); /** * Returns a <code>List</code> values for the output parameters * of the last invoked operation. * * @return java.util.List Values for the output parameters. An * empty <code>List</code> is returned if there are * no output values. * * @throws JAXRPCException If this method is invoked for a * one-way operation or is invoked before any * <code>invoke</code> method has been called. */ public List getOutputValues(); }
1,822
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/Service.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc; import javax.xml.namespace.QName; import javax.xml.rpc.encoding.TypeMappingRegistry; import javax.xml.rpc.handler.HandlerRegistry; /** * <code>Service</code> class acts as a factory of the following: * <ul> * <li>Dynamic proxy for the target service endpoint. * <li>Instance of the type <code>javax.xml.rpc.Call</code> for * the dynamic invocation of a remote operation on the * target service endpoint. * <li>Instance of a generated stub class * </ul> * * @version $Rev$ $Date$ */ public interface Service { /** * The getPort method returns either an instance of a generated * stub implementation class or a dynamic proxy. A service client * uses this dynamic proxy to invoke operations on the target * service endpoint. The <code>serviceEndpointInterface</code> * specifies the service endpoint interface that is supported by * the created dynamic proxy or stub instance. * * @param portName Qualified name of the service endpoint in * the WSDL service description * @param serviceEndpointInterface Service endpoint interface * supported by the dynamic proxy or stub * instance * @return java.rmi.Remote Stub instance or dynamic proxy that * supports the specified service endpoint * interface * @throws ServiceException This exception is thrown in the * following cases: * <ul> * <li>If there is an error in creation of * the dynamic proxy or stub instance * <li>If there is any missing WSDL metadata * as required by this method * <li>Optionally, if an illegal * <code>serviceEndpointInterface</code> * or <code>portName</code> is specified * </ul> */ public java.rmi .Remote getPort(QName portName, Class serviceEndpointInterface) throws ServiceException; /** * The getPort method returns either an instance of a generated * stub implementation class or a dynamic proxy. The parameter * <code>serviceEndpointInterface</code> specifies the service * endpoint interface that is supported by the returned stub or * proxy. In the implementation of this method, the JAX-RPC * runtime system takes the responsibility of selecting a protocol * binding (and a port) and configuring the stub accordingly. * The returned <code>Stub</code> instance should not be * reconfigured by the client. * * @param serviceEndpointInterface Service endpoint interface * @return Stub instance or dynamic proxy that supports the * specified service endpoint interface * * @throws ServiceException <ul> * <li>If there is an error during creation * of stub instance or dynamic proxy * <li>If there is any missing WSDL metadata * as required by this method * <li>Optionally, if an illegal * <code>serviceEndpointInterface</code> * * is specified * </ul> */ public java.rmi.Remote getPort(Class serviceEndpointInterface) throws ServiceException; /** * Gets an array of preconfigured <code>Call</code> objects for * invoking operations on the specified port. There is one * <code>Call</code> object per operation that can be invoked * on the specified port. Each <code>Call</code> object is * pre-configured and does not need to be configured using * the setter methods on <code>Call</code> interface. * * <p>Each invocation of the <code>getCalls</code> method * returns a new array of preconfigured <code>Call</code> * * objects * * <p>This method requires the <code>Service</code> implementation * class to have access to the WSDL related metadata. * * @param portName Qualified name for the target service endpoint * @return Call[] Array of pre-configured Call objects * @throws ServiceException If this Service class does not * have access to the required WSDL metadata * or if an illegal <code>portName</code> is * specified. */ public Call[] getCalls(QName portName) throws ServiceException; /** * Creates a <code>Call</code> instance. * * @param portName Qualified name for the target service endpoint * @return Call instance * @throws ServiceException If any error in the creation of * the <code>Call</code> object */ public Call createCall(QName portName) throws ServiceException; /** * Creates a <code>Call</code> instance. * * @param portName Qualified name for the target service * endpoint * @param operationName Qualified Name of the operation for * which this <code>Call</code> object is to * be created. * @return Call instance * @throws ServiceException If any error in the creation of * the <code>Call</code> object */ public Call createCall(QName portName, QName operationName) throws ServiceException; /** * Creates a <code>Call</code> instance. * * @param portName Qualified name for the target service * endpoint * @param operationName Name of the operation for which this * <code>Call</code> object is to be * created. * @return Call instance * @throws ServiceException If any error in the creation of * the <code>Call</code> object */ public Call createCall(QName portName, String operationName) throws ServiceException; /** * Creates a <code>Call</code> object not associated with * specific operation or target service endpoint. This * <code>Call</code> object needs to be configured using the * setter methods on the <code>Call</code> interface. * * @return Call object * @throws ServiceException If any error in the creation of * the <code>Call</code> object */ public Call createCall() throws ServiceException; /** * Gets the name of this Service. * * @return Qualified name of this service */ public QName getServiceName(); /** * Returns an <code>Iterator</code> for the list of * <code>QName</code>s of service endpoints grouped by this * service. * * @return Returns <code>java.util.Iterator</code> with elements * of type <code>javax.xml.namespace.QName</code> * @throws ServiceException If this Service class does not * have access to the required WSDL metadata */ public java.util.Iterator getPorts() throws ServiceException; /** * Gets location of the WSDL document for this Service. * * @return URL for the location of the WSDL document for * this service */ public java.net.URL getWSDLDocumentLocation(); /** * Gets the <code>TypeMappingRegistry</code> for this * <code>Service</code> object. The returned * <code>TypeMappingRegistry</code> instance is pre-configured * to support the standard type mapping between XML and Java * types types as required by the JAX-RPC specification. * * @return The TypeMappingRegistry for this Service object. * @throws java.lang.UnsupportedOperationException if the <code>Service</code> class does not support * the configuration of <code>TypeMappingRegistry</code>. */ public TypeMappingRegistry getTypeMappingRegistry(); /** * Returns the configured <code>HandlerRegistry</code> instance * for this <code>Service</code> instance. * * @return HandlerRegistry * @throws java.lang.UnsupportedOperationException - if the <code>Service</code> class does not support * the configuration of a <code>HandlerRegistry</code> */ public HandlerRegistry getHandlerRegistry(); }
1,823
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/JAXRPCException.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc; /** * The <code>javax.xml.rpc.JAXRPCException</code> is thrown from * the core JAX-RPC APIs to indicate an exception related to the * JAX-RPC runtime mechanisms. * * @version $Rev$ $Date$ */ public class JAXRPCException extends RuntimeException { // fixme: Why doesn't this use the jdk1.4 exception wrapping APIs? /** The cause of this error. */ Throwable cause; /** * Constructs a new exception with <code>null</code> as its * detail message. The cause is not initialized. */ public JAXRPCException() {} /** * Constructs a new exception with the specified detail * message. The cause is not initialized. * * @param message The detail message which is later * retrieved using the getMessage method */ public JAXRPCException(String message) { super(message); } /** * Constructs a new exception with the specified detail * message and cause. * * @param message The detail message which is later retrieved * using the getMessage method * @param cause The cause which is saved for the later * retrieval throw by the getCause method */ public JAXRPCException(String message, Throwable cause) { super(message); this.cause = cause; } /** * Constructs a new JAXRPCException with the specified cause * and a detail message of <tt>(cause==null ? null : * cause.toString())</tt> (which typically contains the * class and detail message of <tt>cause</tt>). * * @param cause The cause which is saved for the later * retrieval throw by the getCause method. * (A <tt>null</tt> value is permitted, and * indicates that the cause is nonexistent or * unknown.) */ public JAXRPCException(Throwable cause) { super( (cause == null) ? null : cause.toString() ); this.cause = cause; } /** * Gets the linked cause. * * @return The cause of this Exception or <code>null</code> * if the cause is noexistent or unknown */ public Throwable getLinkedCause() { return cause; } }
1,824
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/handler/MessageContext.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc.handler; import java.util.Iterator; /** * The interface <code>MessageContext</code> abstracts the message * context that is processed by a handler in the <code>handle</code> * method. * * <p>The <code>MessageContext</code> interface provides methods to * manage a property set. <code>MessageContext</code> properties * enable handlers in a handler chain to share processing related * state. * * @version $Rev$ $Date$ */ public interface MessageContext { /** * Sets the name and value of a property associated with the * <code>MessageContext</code>. If the <code>MessageContext</code> * contains a value of the same property, the old value is replaced. * * @param name ame of the property associated with the * <code>MessageContext</code> * @param value Value of the property * @throws java.lang.IllegalArgumentException If some aspect * the property is prevents it from being stored * in the context * @throws java.lang.UnsupportedOperationException If this method is * not supported. */ public abstract void setProperty(String name, Object value); /** * Gets the value of a specific property from the * <code>MessageContext</code>. * * @param name the name of the property whose value is to be * retrieved * @return the value of the property * @throws java.lang.IllegalArgumentException if an illegal * property name is specified */ public abstract Object getProperty(String name); /** * Removes a property (name-value pair) from the * <code>MessageContext</code>. * * @param name the name of the property to be removed * * @throws java.lang.IllegalArgumentException if an illegal * property name is specified */ public abstract void removeProperty(String name); /** * Returns true if the <code>MessageContext</code> contains a property * with the specified name. * @param name Name of the property whose presense is to be tested * @return Returns true if the MessageContext contains the * property; otherwise false */ public abstract boolean containsProperty(String name); /** * Returns an Iterator view of the names of the properties * in this <code>MessageContext</code>. * * @return Iterator for the property names */ public abstract Iterator getPropertyNames(); }
1,825
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/handler/Handler.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc.handler; import javax.xml.namespace.QName; /** * The <code>javax.xml.rpc.handler.Handler</code> interface is * required to be implemented by a SOAP message handler. The * <code>handleRequest</code>, <code>handleResponse</code> * and <code>handleFault</code> methods for a SOAP message * handler get access to the <code>SOAPMessage</code> from the * <code>SOAPMessageContext</code>. The implementation of these * methods can modify the <code>SOAPMessage</code> including the * headers and body elements. * * @version $Rev$ $Date$ */ public interface Handler { /** * The <code>handleRequest</code> method processes the request message. * * @param context MessageContext parameter provides access to the request * message. * @return boolean boolean Indicates the processing mode * <ul> * <li>Return <code>true</code> to indicate continued * processing of the request handler chain. The * <code>HandlerChain</code> * takes the responsibility of invoking the next * entity. The next entity may be the next handler * in the <code>HandlerChain</code> or if this * handler is the last handler in the chain, the * next entity is the service endpoint object. * <li>Return <code>false</code> to indicate blocking * of the request handler chain. In this case, * further processing of the request handler chain * is blocked and the target service endpoint is * not dispatched. The JAX-RPC runtime system takes * the responsibility of invoking the response * handler chain next with the SOAPMessageContext. * The Handler implementation class has the the * responsibility of setting the appropriate response * SOAP message in either handleRequest and/or * handleResponse method. In the default processing * model, the response handler chain starts processing * from the same Handler instance (that returned false) * and goes backward in the execution sequence. * </ul> * * @throws javax.xml.rpc.JAXRPCException * indicates a handler-specific * runtime error. If <code>JAXRPCException</code> is thrown * by a handleRequest method, the HandlerChain * terminates the further processing of this handler * chain. On the server side, the HandlerChain * generates a SOAP fault that indicates that the * message could not be processed for reasons not * directly attributable to the contents of the * message itself but rather to a runtime error * during the processing of the message. On the * client side, the exception is propagated to * the client code * @throws javax.xml.rpc.soap.SOAPFaultException * indicates a SOAP fault. The Handler * implementation class has the the responsibility * of setting the SOAP fault in the SOAP message in * either handleRequest and/or handleFault method. * If SOAPFaultException is thrown by a server-side * request handler's handleRequest method, the * HandlerChain terminates the further processing * of the request handlers in this handler chain * and invokes the handleFault method on the * HandlerChain with the SOAP message context. Next, * the HandlerChain invokes the handleFault method * on handlers registered in the handler chain, * beginning with the Handler instance that threw * the exception and going backward in execution. The * client-side request handler's handleRequest method * should not throw the SOAPFaultException. */ public boolean handleRequest(MessageContext context); /** * The <code>handleResponse</code> method processes the response SOAP message. * * @param context MessageContext parameter provides access to * the response SOAP message * * @return boolean Indicates the processing mode * <ul> * <li>Return <code>true</code> to indicate continued * processing ofthe response handler chain. The * HandlerChain invokes the <code>handleResponse</code> * method on the next <code>Handler</code> in * the handler chain. * <li>Return <code>false</code> to indicate blocking * of the response handler chain. In this case, no * other response handlers in the handler chain * are invoked. * </ul> * * @throws javax.xml.rpc.JAXRPCException * indicates a handler specific runtime error. * If JAXRPCException is thrown by a handleResponse * method, the HandlerChain terminates the further * processing of this handler chain. On the server side, * the HandlerChain generates a SOAP fault that * indicates that the message could not be processed * for reasons not directly attributable to the contents * of the message itself but rather to a runtime error * during the processing of the message. On the client * side, the runtime exception is propagated to the * client code. */ public boolean handleResponse(MessageContext context); /** * The <code>handleFault</code> method processes the SOAP faults * based on the SOAP message processing model. * * @param context MessageContext parameter provides access to * the SOAP message * @return boolean Indicates the processing mode * <ul> * <li>Return <code>true</code> to indicate continued * processing of SOAP Fault. The HandlerChain invokes * the <code>handleFault</code> method on the * next <code>Handler</code> in the handler chain. * <li>Return <code>false</code> to indicate end * of the SOAP fault processing. In this case, no * other handlers in the handler chain * are invoked. * </ul> * @throws javax.xml.rpc.JAXRPCException indicates handler specific runtime * error. If JAXRPCException is thrown by a handleFault * method, the HandlerChain terminates the further * processing of this handler chain. On the server side, * the HandlerChain generates a SOAP fault that * indicates that the message could not be processed * for reasons not directly attributable to the contents * of the message itself but rather to a runtime error * during the processing of the message. On the client * side, the JAXRPCException is propagated to the * client code. */ public boolean handleFault(MessageContext context); /** * The <code>init</code> method enables the Handler instance to * initialize itself. The <code>init</code> method passes the * handler configuration as a <code>HandlerInfo</code> instance. * The HandlerInfo is used to configure the Handler (for example: * setup access to an external resource or service) during the * initialization. * <p> * In the init method, the Handler class may get access to * any resources (for example; access to a logging service or * database) and maintain these as part of its instance variables. * Note that these instance variables must not have any state * specific to the SOAP message processing performed in the * various handle method. * * @param config HandlerInfo configuration for the initialization of this * handler * * @param config * @throws javax.xml.rpc.JAXRPCException if initialization of the handler * fails */ public abstract void init(HandlerInfo config); /** * The <code>destroy</code> method indicates the end of lifecycle * for a Handler instance. The Handler implementation class should * release its resources and perform cleanup in the implementation * of the <code>destroy</code> method. * * @throws javax.xml.rpc.JAXRPCException if there was any error during * destroy */ public abstract void destroy(); /** * Gets the header blocks processed by this Handler instance. * * @return Array of QNames of header blocks processed by this * handler instance. <code>QName</code> is the qualified * name of the outermost element of the Header block. */ public QName[] getHeaders(); }
1,826
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/handler/HandlerChain.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc.handler; import java.util.List; import java.util.Map; /** * The <code>javax.xml.rpc.handler.HandlerChain</code> represents * a list of handlers. All elements in the HandlerChain are of * the type <code>javax.xml.rpc.handler.Handler</code>. * <p> * An implementation class for the <code>HandlerChain</code> * interface abstracts the policy and mechanism for the invocation * of the registered handlers. * * @version $Rev$ $Date$ */ public interface HandlerChain extends List { /** * The <code>handleRequest</code> method initiates the request * processing for this handler chain. * @param context MessageContext parameter provides access to * the request SOAP message. * @return boolean Returns <code>true</code> if all handlers in * chain have been processed. Returns <code>false</code> * * if a handler in the chain returned * <code>false</code> from its handleRequest * method. * @throws javax.xml.rpc.JAXRPCException if any processing error happens */ public boolean handleRequest(MessageContext context); /** * The <code>handleResponse</code> method initiates the response * processing for this handler chain. * * @param context MessageContext parameter provides access to the response * SOAP message. * @return boolean Returns <code>true</code> if all handlers in * chain have been processed. Returns <code>false</code> * if a handler in the chain returned * <code>false</code> from its handleResponse method. * @throws javax.xml.rpc.JAXRPCException if any processing error happens */ public boolean handleResponse(MessageContext context); /** * The <code>handleFault</code> method initiates the SOAP * fault processing for this handler chain. * * @param context MessageContext parameter provides access to the SOAP * message. * @return Returns boolean Returns <code>true</code> if all handlers in * chain have been processed. Returns <code>false</code> * if a handler in the chain returned * <code>false</code> from its handleFault method. * @throws javax.xml.rpc.JAXRPCException if any processing error happens */ public boolean handleFault(MessageContext context); /** * Initializes the configuration for a HandlerChain. * * @param config Configuration for the initialization of this handler * chain * * @throws javax.xml.rpc.JAXRPCException if there is any error that prevents * initialization */ public void init(Map config); /** * Indicates the end of lifecycle for a HandlerChain. * * @throws javax.xml.rpc.JAXRPCException if there was any error that * prevented destroy from completing */ public void destroy(); /** * Sets SOAP Actor roles for this <code>HandlerChain</code>. This * specifies the set of roles in which this HandlerChain is to act * for the SOAP message processing at this SOAP node. These roles * assumed by a HandlerChain must be invariant during the * processing of an individual SOAP message through the HandlerChain. * <p> * A <code>HandlerChain</code> always acts in the role of the * special SOAP actor <code>next</code>. Refer to the SOAP * specification for the URI name for this special SOAP actor. * There is no need to set this special role using this method. * * @param soapActorNames URIs for SOAP actor name */ public void setRoles(String[] soapActorNames); /** * Gets SOAP actor roles registered for this HandlerChain at * this SOAP node. The returned array includes the special * SOAP actor <code>next</code>. * @return String[] SOAP Actor roles as URIs */ public java.lang.String[] getRoles(); }
1,827
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/handler/GenericHandler.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc.handler; import javax.xml.namespace.QName; /** * The <code>javax.xml.rpc.handler.GenericHandler</code> class * implements the <code>Handler</code> interface. SOAP Message * Handler developers should typically subclass * <code>GenericHandler</code> class unless the Handler class * needs another class as a superclass. * * <p> * The <code>GenericHandler</code> class is a convenience abstract * class that makes writing Handlers easy. This class provides * default implementations of the lifecycle methods <code>init</code> * and <code>destroy</code> and also different handle methods. * A Handler developer should only override methods that it needs * to specialize as part of the derived <code>Handler</code> * implementation class. * * @version $Rev$ $Date$ */ public abstract class GenericHandler implements Handler { /** * Default constructor. */ protected GenericHandler() {} /** * The <code>handleRequest</code> method processes the request * SOAP message. The default implementation of this method returns * <code>true</code>. This indicates that the handler chain * should continue processing of the request SOAP message. * This method should be overridden if the derived Handler class * needs to specialize implementation of this method. * * @param context the message context * @return true/false */ public boolean handleRequest(MessageContext context) { return true; } /** * The <code>handleResponse</code> method processes the response * message. The default implementation of this method returns * <code>true</code>. This indicates that the handler chain * should continue processing of the response SOAP message. * This method should be overridden if the derived Handler class * needs to specialize implementation of this method. * * @param context the message context * @return true/false */ public boolean handleResponse(MessageContext context) { return true; } /** * The <code>handleFault</code> method processes the SOAP faults * based on the SOAP message processing model. The default * implementation of this method returns <code>true</code>. This * indicates that the handler chain should continue processing * of the SOAP fault. This method should be overridden if * the derived Handler class needs to specialize implementation * of this method. * * @param context the message context * @return true/false */ public boolean handleFault(MessageContext context) { return true; } /** * The <code>init</code> method to enable the Handler instance to * initialize itself. This method should be overridden if * the derived Handler class needs to specialize implementation * of this method. * * @param config handler configuration */ public void init(HandlerInfo config) {} /** * The <code>destroy</code> method indicates the end of lifecycle * for a Handler instance. This method should be overridden if * the derived Handler class needs to specialize implementation * of this method. */ public void destroy() {} /** * Gets the header blocks processed by this Handler instance. * * @return Array of QNames of header blocks processed by this handler instance. * <code>QName</code> is the qualified name of the outermost element of the Header block. */ public abstract QName[] getHeaders(); }
1,828
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/handler/HandlerRegistry.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc.handler; import javax.xml.namespace.QName; import java.io.Serializable; /** * The <code>javax.xml.rpc.handler.HandlerRegistry</code> * provides support for the programmatic configuration of * handlers in a <code>HandlerRegistry</code>. * <p> * A handler chain is registered per service endpoint, as * indicated by the qualified name of a port. The getHandlerChain * returns the handler chain (as a java.util.List) for the * specified service endpoint. The returned handler chain is * configured using the java.util.List interface. Each element * in this list is required to be of the Java type * <code>javax.xml.rpc.handler.HandlerInfo</code> * * @version $Rev$ $Date$ */ public interface HandlerRegistry extends Serializable { /** * Gets the handler chain for the specified service endpoint. * The returned <code>List</code> is used to configure this * specific handler chain in this <code>HandlerRegistry</code>. * Each element in this list is required to be of the Java type * <code>javax.xml.rpc.handler.HandlerInfo</code>. * * @param portName Qualified name of the target service * @return HandlerChain java.util.List Handler chain * @throws java.lang.IllegalArgumentException If an invalid <code>portName</code> is specified */ public java.util.List getHandlerChain(QName portName); /** * Sets the handler chain for the specified service endpoint * as a <code>java.util.List</code>. Each element in this list * is required to be of the Java type * <code>javax.xml.rpc.handler.HandlerInfo</code>. * * @param portName Qualified name of the target service endpoint * @param chain a List representing configuration for the * handler chain * @throws javax.xml.rpc.JAXRPCException if there is any error in the * configuration of the handler chain * @throws java.lang.UnsupportedOperationException if this * set operation is not supported. This is done to * avoid any overriding of a pre-configured handler * chain. * @throws java.lang.IllegalArgumentException If an invalid * <code>portName</code> is specified */ public abstract void setHandlerChain(QName portName, java.util.List chain); }
1,829
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/handler/HandlerInfo.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc.handler; import javax.xml.namespace.QName; import java.io.Serializable; import java.util.HashMap; import java.util.Map; /** * The <code>javax.xml.rpc.handler.HandlerInfo</code> represents * information about a handler in the HandlerChain. A HandlerInfo * instance is passed in the <code>Handler.init</code> method to * initialize a <code>Handler</code> instance. * * @version $Rev$ $Date$ * @see HandlerChain */ public class HandlerInfo implements Serializable { /** Default constructor. */ public HandlerInfo() { handlerClass = null; config = new HashMap(); } /** * Constructor for HandlerInfo. * * @param handlerClass Java Class for the Handler * @param config Handler Configuration as a java.util.Map * @param headers QNames for the header blocks processed * by this Handler. QName is the qualified name * of the outermost element of a header block */ public HandlerInfo(Class handlerClass, Map config, QName[] headers) { this.handlerClass = handlerClass; this.config = config; this.headers = headers; } /** * Sets the Handler class. * * @param handlerClass Class for the Handler */ public void setHandlerClass(Class handlerClass) { this.handlerClass = handlerClass; } /** * Gets the Handler class. * * @return Returns null if no Handler class has been * set; otherwise the set handler class */ public Class getHandlerClass() { return handlerClass; } /** * Sets the Handler configuration as <code>java.util.Map</code> * @param config Configuration map */ public void setHandlerConfig(Map config) { this.config = config; } /** * Gets the Handler configuration. * * @return Returns empty Map if no configuration map * has been set; otherwise returns the set configuration map */ public Map getHandlerConfig() { return config; } /** * Sets the header blocks processed by this Handler. * @param headers QNames of the header blocks. QName * is the qualified name of the outermost * element of the SOAP header block */ public void setHeaders(QName[] headers) { this.headers = headers; } /** * Gets the header blocks processed by this Handler. * @return Array of QNames for the header blocks. Returns * <code>null</code> if no header blocks have been * set using the <code>setHeaders</code> method. */ public QName[] getHeaders() { return headers; } /** Handler Class. */ private Class handlerClass; /** Configuration Map. */ private Map config; /** Headers. */ private QName[] headers; }
1,830
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/handler
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/handler/soap/SOAPMessageContext.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc.handler.soap; import javax.xml.rpc.handler.MessageContext; import javax.xml.soap.SOAPMessage; /** * The interface <code>javax.xml.rpc.soap.SOAPMessageContext</code> * provides access to the SOAP message for either RPC request or * response. The <code>javax.xml.soap.SOAPMessage</code> specifies * the standard Java API for the representation of a SOAP 1.1 message * with attachments. * * @version $Rev$ $Date$ * @see javax.xml.soap.SOAPMessage */ public interface SOAPMessageContext extends MessageContext { /** * Gets the SOAPMessage from this message context. * * @return the <code>SOAPMessage</code>; <code>null</code> if no request * <code>SOAPMessage</code> is present in this * <code>SOAPMessageContext</code> */ public abstract SOAPMessage getMessage(); /** * Sets the <code>SOAPMessage</code> for this message context. * * @param message SOAP message * @throws javax.xml.rpc.JAXRPCException if any error during the setting * of the SOAPMessage in this message context * @throws java.lang.UnsupportedOperationException if this * operation is not supported */ public abstract void setMessage(SOAPMessage message); /** * Gets the SOAP actor roles associated with an execution * of the HandlerChain and its contained Handler instances. * Note that SOAP actor roles apply to the SOAP node and * are managed using <code>HandlerChain.setRoles</code> and * <code>HandlerChain.getRoles</code>. Handler instances in * the HandlerChain use this information about the SOAP actor * roles to process the SOAP header blocks. Note that the * SOAP actor roles are invariant during the processing of * SOAP message through the HandlerChain. * * @return Array of URIs for SOAP actor roles * @see javax.xml.rpc.handler.HandlerChain#setRoles(java.lang.String[]) HandlerChain.setRoles(java.lang.String[]) * @see javax.xml.rpc.handler.HandlerChain#getRoles() HandlerChain.getRoles() */ public abstract String[] getRoles(); }
1,831
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/holders/BooleanHolder.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc.holders; /** * Holder for <code>boolean</code>s. * * @version $Rev$ $Date$ */ public final class BooleanHolder implements Holder { /** The <code>boolean</code> contained by this holder. */ public boolean value; /** * Make a new <code>BooleanHolder</code> with a <code>null</code> value. */ public BooleanHolder() {} /** * Make a new <code>BooleanHolder</code> with <code>value</code> as * the value. * * @param value the <code>boolean</code> to hold */ public BooleanHolder(boolean value) { this.value = value; } }
1,832
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/holders/ShortWrapperHolder.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc.holders; /** * Holder for <code>Short</code>s. * * @version $Rev$ $Date$ */ public final class ShortWrapperHolder implements Holder { /** The <code>Short</code> contained by this holder. */ public Short value; /** * Make a new <code>ShortWrapperHolder</code> with a <code>null</code> value. */ public ShortWrapperHolder() {} /** * Make a new <code>ShortWrapperHolder</code> with <code>value</code> as * the value. * * @param value the <code>Short</code> to hold */ public ShortWrapperHolder(Short value) { this.value = value; } }
1,833
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/holders/ByteArrayHolder.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc.holders; /** * Holder for <code>byte[]</code>s. * * @version $Rev$ $Date$ */ public final class ByteArrayHolder implements Holder { /** The <code>byte[]</code> contained by this holder. */ public byte[] value; /** * Make a new <code>ByteArrayHolder</code> with a <code>null</code> value. */ public ByteArrayHolder() {} /** * Make a new <code>ByteArrayHolder</code> with <code>value</code> as * the value. * * @param value the <code>byte[]</code> to hold */ public ByteArrayHolder(byte[] value) { this.value = value; } }
1,834
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/holders/CalendarHolder.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc.holders; import java.util.Calendar; /** * Holder for <code>Calendar</code>s. * * @version $Rev$ $Date$ */ public final class CalendarHolder implements Holder { /** The <code>Calendar</code> that is held. */ public Calendar value; /** * Make a new <code>CalendarHolder</code> with a <code>null</code> value.r */ public CalendarHolder() {} /** * Make a new <code>CalendarHolder</code> with <code>value</code> as * the value. * * @param value the <code>Calendar</code> to hold */ public CalendarHolder(Calendar value) { this.value = value; } }
1,835
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/holders/DoubleHolder.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc.holders; /** * Holder for <code>double</code>s. * * @version $Rev$ $Date$ */ public final class DoubleHolder implements Holder { /** The <code>double</code> contained by this holder. */ public double value; /** * Make a new <code>DoubleHolder</code> with a <code>null</code> value. */ public DoubleHolder() {} /** * Make a new <code>DoubleHolder</code> with <code>value</code> as * the value. * * @param value the <code>double</code> to hold */ public DoubleHolder(double value) { this.value = value; } }
1,836
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/holders/Holder.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc.holders; /** * The <code>java.xml.rpc.holders.Holder</code> interface represents the base interface for both standard and * generated Holder classes. A generated Holder class is required to implement this Holder interface. * * @version $Rev$ $Date$ */ public interface Holder {}
1,837
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/holders/ShortHolder.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc.holders; /** * Holder for <code>short</code>s. * * @version $Rev$ $Date$ */ public final class ShortHolder implements Holder { /** The <code>short</code> contained by this holder. */ public short value; /** * Make a new <code>ShortHolder</code> with a <code>null</code> value. */ public ShortHolder() {} /** * Make a new <code>ShortHolder</code> with <code>value</code> as * the value. * * @param value the <code>short</code> to hold */ public ShortHolder(short value) { this.value = value; } }
1,838
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/holders/ByteHolder.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc.holders; /** * Holder for <code>byte</code>s. * * @version $Rev$ $Date$ */ public final class ByteHolder implements Holder { /** The <code>byte</code> contained by this holder. */ public byte value; /** * Make a new <code>ByteHolder</code> with a <code>null</code> value. */ public ByteHolder() {} /** * Make a new <code>ByteHolder</code> with <code>value</code> as * the value. * * @param value the <code>byte</code> to hold */ public ByteHolder(byte value) { this.value = value; } }
1,839
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/holders/BigDecimalHolder.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc.holders; import java.math.BigDecimal; /** * Holder for <code>BigDecimal</code>s. * * @version $Rev$ $Date$ */ public final class BigDecimalHolder implements Holder { /** The <code>BigDecimal</code> contained by this holder. */ public BigDecimal value; /** * Make a new <code>BigDecimalHolder</code> with a <code>null</code> value. */ public BigDecimalHolder() {} /** * Make a new <code>BigDecimalHolder</code> with <code>value</code> as * the value. * * @param value the <code>BigDecimal</code> to hold */ public BigDecimalHolder(BigDecimal value) { this.value = value; } }
1,840
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/holders/QNameHolder.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc.holders; import javax.xml.namespace.QName; /** * Holder for <code>QName</code>s. * * @version $Rev$ $Date$ */ public final class QNameHolder implements Holder { /** The <code>QName</code> contained by this holder. */ public QName value; /** * Make a new <code>QNameHolder</code> with a <code>null</code> value. */ public QNameHolder() {} /** * Make a new <code>QNameHolder</code> with <code>value</code> as * the value. * * @param value the <code>QName</code> to hold */ public QNameHolder(QName value) { this.value = value; } }
1,841
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/holders/LongWrapperHolder.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc.holders; /** * Holder for <code>Long</code>s. * * @version $Rev$ $Date$ */ public final class LongWrapperHolder implements Holder { /** The <code>Long</code> contained by this holder. */ public Long value; /** * Make a new <code>LongWrapperHolder</code> with a <code>null</code> value. */ public LongWrapperHolder() {} /** * Make a new <code>LongWrapperHolder</code> with <code>value</code> as * the value. * * @param value the <code>Long</code> to hold */ public LongWrapperHolder(Long value) { this.value = value; } }
1,842
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/holders/BooleanWrapperHolder.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc.holders; /** * Holder for <code>Boolean</code>s. * * @version $Rev$ $Date$ */ public final class BooleanWrapperHolder implements Holder { /** The <code>Boolean</code> contained by this holder. */ public Boolean value; /** * Make a new <code>BooleanWrapperHolder</code> with a <code>null</code> value. */ public BooleanWrapperHolder() {} /** * Make a new <code>BooleanWrapperHolder</code> with <code>value</code> as * the value. * * @param value the <code>Boolean</code> to hold */ public BooleanWrapperHolder(Boolean value) { this.value = value; } }
1,843
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/holders/ObjectHolder.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc.holders; /** * Holder for <code>Object</code>s. * * @version $Rev$ $Date$ */ public final class ObjectHolder implements Holder { /** The <code>Object</code> contained by this holder. */ public Object value; /** * Make a new <code>ObjectHolder</code> with a <code>null</code> value. */ public ObjectHolder() {} /** * Make a new <code>ObjectHolder</code> with <code>value</code> as * the value. * * @param value the <code>Object</code> to hold */ public ObjectHolder(Object value) { this.value = value; } }
1,844
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/holders/BigIntegerHolder.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc.holders; import java.math.BigInteger; /** * Holder for <code>BigInteger</code>s. * * @version $Rev$ $Date$ */ public final class BigIntegerHolder implements Holder { /** The <code>BigInteger</code> that is held. */ public BigInteger value; /** * Make a new <code>BigIntegerHolder</code> with a <code>null</code> value. */ public BigIntegerHolder() {} /** * Make a new <code>BigIntegerHolder</code> with <code>value</code> as * the value. * * @param value the <code>BigInteger</code> to hold */ public BigIntegerHolder(BigInteger value) { this.value = value; } }
1,845
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/holders/ByteWrapperHolder.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc.holders; /** * Holder for <code>Byte</code>s. * * @version $Rev$ $Date$ */ public final class ByteWrapperHolder implements Holder { /** The <code>Byte</code> contained by this holder. */ public Byte value; /** * Make a new <code>ByteWrapperHolder</code> with a <code>null</code> value. */ public ByteWrapperHolder() {} /** * Make a new <code>ByteWrapperHolder</code> with <code>value</code> as * the value. * * @param value the <code>Byte</code> to hold */ public ByteWrapperHolder(Byte value) { this.value = value; } }
1,846
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/holders/FloatWrapperHolder.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc.holders; /** * Holder for <code>Float</code>s. * * @version $Rev$ $Date$ */ public final class FloatWrapperHolder implements Holder { /** The <code>Float</code> contained by this holder. */ public Float value; /** * Make a new <code>FloatWrapperHolder</code> with a <code>null</code> value. */ public FloatWrapperHolder() {} /** * Make a new <code>FloatWrapperHolder</code> with <code>value</code> as * the value. * * @param value the <code>Float</code> to hold */ public FloatWrapperHolder(Float value) { this.value = value; } }
1,847
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/holders/StringHolder.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc.holders; /** * Holder for <code>String</code>s. * * @version $Rev$ $Date$ */ public final class StringHolder implements Holder { /** The <code>String</code> contained by this holder. */ public String value; /** * Make a new <code>StringHolder</code> with a <code>null</code> value. */ public StringHolder() {} /** * Make a new <code>StringHolder</code> with <code>value</code> as * the value. * * @param value the <code>String</code> to hold */ public StringHolder(String value) { this.value = value; } }
1,848
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/holders/FloatHolder.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc.holders; /** * Holder for <code>float</code>s. * * @version $Rev$ $Date$ */ public final class FloatHolder implements Holder { /** The <code>byte</code> contained by this holder. */ public float value; /** * Make a new <code>FloatHolder</code> with a <code>null</code> value. */ public FloatHolder() {} /** * Make a new <code>FloatHolder</code> with <code>value</code> as * the value. * * @param value the <code>float</code> to hold */ public FloatHolder(float value) { this.value = value; } }
1,849
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/holders/DoubleWrapperHolder.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc.holders; /** * Holder for <code>Double</code>s. * * @version $Rev$ $Date$ */ public final class DoubleWrapperHolder implements Holder { /** The <code>Double</code> contained by this holder. */ public Double value; /** * Make a new <code>DoubleWrapperHolder</code> with a <code>null</code> value. */ public DoubleWrapperHolder() {} /** * Make a new <code>DoubleWrapperHolder</code> with <code>value</code> as * the value. * * @param value the <code>Double</code> to hold */ public DoubleWrapperHolder(Double value) { this.value = value; } }
1,850
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/holders/IntegerWrapperHolder.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc.holders; /** * Holder for <code>Integer</code>s. * * @version $Rev$ $Date$ */ public final class IntegerWrapperHolder implements Holder { /** The <code>Integer</code> contained by this holder. */ public Integer value; /** * Make a new <code>IntegerWrapperHolder</code> with a <code>null</code> value. */ public IntegerWrapperHolder() {} /** * Make a new <code>IntegerWrapperHolder</code> with <code>value</code> as * the value. * * @param value the <code>Integer</code> to hold */ public IntegerWrapperHolder(Integer value) { this.value = value; } }
1,851
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/holders/LongHolder.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc.holders; /** * Holder for <code>long</code>s. * * @version $Rev$ $Date$ */ public final class LongHolder implements Holder { /** The <code>long</code> contained by this holder. */ public long value; /** * Make a new <code>LongHolder</code> with a <code>null</code> value. */ public LongHolder() {} /** * Make a new <code>LongHolder</code> with <code>value</code> as * the value. * * @param value the <code>long</code> to hold */ public LongHolder(long value) { this.value = value; } }
1,852
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/holders/IntHolder.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc.holders; /** * Holder for <code>int</code>s. * * @version $Rev$ $Date$ */ public final class IntHolder implements Holder { /** The <code>int</code> contained by this holder. */ public int value; /** * Make a new <code>IntHolder</code> with a <code>null</code> value. */ public IntHolder() {} /** * Make a new <code>IntHolder</code> with <code>value</code> as * the value. * * @param value the <code>int</code> to hold */ public IntHolder(int value) { this.value = value; } }
1,853
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/encoding/Deserializer.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc.encoding; /** * The javax.xml.rpc.encoding.Deserializer interface defines a * base interface for deserializers. A Deserializer converts * an XML representation to a Java object using a specific XML * processing mechanism and based on the specified type * mapping and encoding style. * * @version $Rev$ $Date$ */ public interface Deserializer extends java.io.Serializable { /** * Gets the type of the XML processing mechanism and * representation used by this Deserializer. * * @return XML processing mechanism type */ public String getMechanismType(); }
1,854
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/encoding/TypeMappingRegistry.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc.encoding; /** * The interface <code>javax.xml.rpc.encoding.TypeMappingRegistry</code> * defines a registry of TypeMapping instances for various encoding * styles. * * @version $Rev$ $Date$ */ public interface TypeMappingRegistry extends java.io.Serializable { /** * Registers a <code>TypeMapping</code> instance with the * <code>TypeMappingRegistry</code>. This method replaces any * existing registered <code>TypeMapping</code> instance for * the specified <code>encodingStyleURI</code>. * * @param encodingStyleURI An encoding style specified as an URI. * An example is "http://schemas.xmlsoap.org/soap/encoding/" * @param mapping TypeMapping instance * * @return Previous TypeMapping associated with the specified * <code>encodingStyleURI</code>, or <code>null</code> * if there was no TypeMapping associated with the specified * <code>encodingStyleURI</code> * * @throws javax.xml.rpc.JAXRPCException if there is any error that prevents * the registration of the <code>TypeMapping</code> for * the specified <code>encodingStyleURI</code> */ public TypeMapping register(String encodingStyleURI, TypeMapping mapping); /** * Registers the <code>TypeMapping</code> instance that is default * for all encoding styles supported by the * <code>TypeMappingRegistry</code>. A default <code>TypeMapping</code> * should include serializers and deserializers that are independent * of and usable with any encoding style. Successive invocations * of the <code>registerDefault</code> method replace any existing * default <code>TypeMapping</code> instance. * <p> * If the default <code>TypeMapping</code> is registered, any * other TypeMapping instances registered through the * <code>TypeMappingRegistry.register</code> method (for a set * of encodingStyle URIs) override the default <code>TypeMapping</code>. * * @param mapping TypeMapping instance * * @throws javax.xml.rpc.JAXRPCException if there is any error that * prevents the registration of the default * <code>TypeMapping</code> */ public void registerDefault(TypeMapping mapping); /** * Gets the registered default <code>TypeMapping</code> instance. * This method returns <code>null</code> if there is no registered * default TypeMapping in the registry. * * @return The registered default <code>TypeMapping</code> instance * or <code>null</code> */ public TypeMapping getDefaultTypeMapping(); /** * Returns a list of registered encodingStyle URIs in this * <code>TypeMappingRegistry</code> instance. * * @return Array of the registered encodingStyle URIs */ public String[] getRegisteredEncodingStyleURIs(); /** * Returns the registered <code>TypeMapping</code> for the specified * encodingStyle URI. If there is no registered <code>TypeMapping</code> * for the specified <code>encodingStyleURI</code>, this method * returns <code>null</code>. * * @param encodingStyleURI Encoding style specified as an URI * @return TypeMapping for the specified encodingStyleURI or * <code>null</code> */ public TypeMapping getTypeMapping(String encodingStyleURI); /** * Creates a new empty <code>TypeMapping</code> object. * * @return TypeMapping instance. */ public TypeMapping createTypeMapping(); /** * Unregisters a TypeMapping instance, if present, from the specified * encodingStyleURI. * * @param encodingStyleURI Encoding style specified as an URI * @return <code>TypeMapping</code> instance that has been unregistered * or <code>null</code> if there was no TypeMapping * registered for the specified <code>encodingStyleURI</code> */ public TypeMapping unregisterTypeMapping(String encodingStyleURI); /** * Removes a <code>TypeMapping</code> from the TypeMappingRegistry. A * <code>TypeMapping</code> is associated with 1 or more * encodingStyleURIs. This method unregisters the specified * <code>TypeMapping</code> instance from all associated * <code>encodingStyleURIs</code> and then removes this * TypeMapping instance from the registry. * * @param mapping TypeMapping to remove * @return <code>true</code> if specified <code>TypeMapping</code> * is removed from the TypeMappingRegistry; <code>false</code> * if the specified <code>TypeMapping</code> was not in the * <code>TypeMappingRegistry</code> */ public boolean removeTypeMapping(TypeMapping mapping); /** * Removes all registered TypeMappings and encodingStyleURIs * from this TypeMappingRegistry. */ public void clear(); }
1,855
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/encoding/DeserializationContext.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc.encoding; /** * The javax.xml.rpc.encoding.DeserializationContext interface is implemented by the JAX-RPC runtime system in an XML * processing mechanism specific manner. A deserializer uses this interface to access and maintain context information * during the deserialization.. * * @version $Rev$ $Date$ */ public interface DeserializationContext {}
1,856
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/encoding/XMLType.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc.encoding; import javax.xml.namespace.QName; /** * Constants representing XML Types. * * @version $Rev$ $Date$ */ public class XMLType { // fixme: Thsi is a constants class - should be final and/or have a private // constructor public XMLType() {} /** XSD type for string. */ public static final QName XSD_STRING = new QName("http://www.w3.org/2001/XMLSchema", "string"); /** XSD type for float. */ public static final QName XSD_FLOAT = new QName("http://www.w3.org/2001/XMLSchema", "float"); /** XSD type for boolean. */ public static final QName XSD_BOOLEAN = new QName("http://www.w3.org/2001/XMLSchema", "boolean"); /** XSD type for double. */ public static final QName XSD_DOUBLE = new QName("http://www.w3.org/2001/XMLSchema", "double"); /** XSD type for integer. */ public static final QName XSD_INTEGER = new QName("http://www.w3.org/2001/XMLSchema", "integer"); /** XSD type for int. */ public static final QName XSD_INT = new QName("http://www.w3.org/2001/XMLSchema", "int"); /** XSD type for long. */ public static final QName XSD_LONG = new QName("http://www.w3.org/2001/XMLSchema", "long"); /** XSD type for short. */ public static final QName XSD_SHORT = new QName("http://www.w3.org/2001/XMLSchema", "short"); /** XSD type for decimal. */ public static final QName XSD_DECIMAL = new QName("http://www.w3.org/2001/XMLSchema", "decimal"); /** XSD type for base64Binary. */ public static final QName XSD_BASE64 = new QName("http://www.w3.org/2001/XMLSchema", "base64Binary"); /** XSD type for hexBinary. */ public static final QName XSD_HEXBINARY = new QName("http://www.w3.org/2001/XMLSchema", "hexBinary"); /** XSD type for byte. */ public static final QName XSD_BYTE = new QName("http://www.w3.org/2001/XMLSchema", "byte"); /** XSD type for dateTime. */ public static final QName XSD_DATETIME = new QName("http://www.w3.org/2001/XMLSchema", "dateTime"); /** XSD type for QName. */ public static final QName XSD_QNAME = new QName("http://www.w3.org/2001/XMLSchema", "QName"); /** SOAP type for string. */ public static final QName SOAP_STRING = new QName("http://schemas.xmlsoap.org/soap/encoding/", "string"); /** SOAP type for boolean. */ public static final QName SOAP_BOOLEAN = new QName("http://schemas.xmlsoap.org/soap/encoding/", "boolean"); /** SOAP type for double. */ public static final QName SOAP_DOUBLE = new QName("http://schemas.xmlsoap.org/soap/encoding/", "double"); /** SOAP type for base64. */ public static final QName SOAP_BASE64 = new QName("http://schemas.xmlsoap.org/soap/encoding/", "base64"); /** SOAP type for float. */ public static final QName SOAP_FLOAT = new QName("http://schemas.xmlsoap.org/soap/encoding/", "float"); /** SOAP type for int. */ public static final QName SOAP_INT = new QName("http://schemas.xmlsoap.org/soap/encoding/", "int"); /** SOAP type for long. */ public static final QName SOAP_LONG = new QName("http://schemas.xmlsoap.org/soap/encoding/", "long"); /** SOAP type for short. */ public static final QName SOAP_SHORT = new QName("http://schemas.xmlsoap.org/soap/encoding/", "short"); /** SOAP type for byte. */ public static final QName SOAP_BYTE = new QName("http://schemas.xmlsoap.org/soap/encoding/", "byte"); /** SOAP type for Array. */ public static final QName SOAP_ARRAY = new QName("http://schemas.xmlsoap.org/soap/encoding/", "Array"); }
1,857
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/encoding/TypeMapping.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc.encoding; import javax.xml.namespace.QName; /** * The <code>javax.xml.rpc.encoding.TypeMapping</code> is the base * interface for the representation of a type mapping. A TypeMapping * implementation class may support one or more encoding styles. * <p> * For its supported encoding styles, a TypeMapping instance * maintains a set of tuples of the type {Java type, * <code>SerializerFactory</code>, * <code>DeserializerFactory</code>, XML type}. * * @version $Rev$ $Date$ */ public interface TypeMapping { /** * Returns the encodingStyle URIs (as String[]) supported by * this TypeMapping instance. A TypeMapping that contains only * encoding style independent serializers and deserializers * returns <code>null</code> from this method. * * @return Array of encodingStyle URIs for the supported * encoding styles */ public String[] getSupportedEncodings(); /** * Sets the encodingStyle URIs supported by this TypeMapping * instance. A TypeMapping that contains only encoding * independent serializers and deserializers requires * <code>null</code> as the parameter for this method. * * @param encodingStyleURIs Array of encodingStyle URIs for the * supported encoding styles */ public void setSupportedEncodings(String[] encodingStyleURIs); /** * Checks whether or not type mapping between specified XML * type and Java type is registered. * * @param javaType Class of the Java type * @param xmlType Qualified name of the XML data type * @return boolean; <code>true</code> if type mapping between the * specified XML type and Java type is registered; * otherwise <code>false</code> */ public boolean isRegistered(Class javaType, QName xmlType); /** * Registers SerializerFactory and DeserializerFactory for a * specific type mapping between an XML type and Java type. * This method replaces any existing registered SerializerFactory * DeserializerFactory instances. * * @param javaType Class of the Java type * @param xmlType Qualified name of the XML data type * @param sf SerializerFactory * @param dsf DeserializerFactory * * @throws javax.xml.rpc.JAXRPCException if there are any errors that * prevent registration */ public void register(Class javaType, QName xmlType, SerializerFactory sf, DeserializerFactory dsf); /** * Gets the SerializerFactory registered for the specified * pair of Java type and XML data type. * * @param javaType Class of the Java type * @param xmlType Qualified name of the XML data type * * @return Registered SerializerFactory or <code>null</code> * if there is no registered factory */ public SerializerFactory getSerializer(Class javaType, QName xmlType); /** * Gets the DeserializerFactory registered for the specified pair * of Java type and XML data type. * * @param javaType Class of the Java type * @param xmlType Qualified name of the XML data type * * @return Registered SerializerFactory or <code>null</code> * if there is no registered factory */ public DeserializerFactory getDeserializer(Class javaType, QName xmlType); /** * Removes the SerializerFactory registered for the specified * pair of Java type and XML data type. * * @param javaType Class of the Java type * @param xmlType Qualified name of the XML data type * * @throws javax.xml.rpc.JAXRPCException if there is any error that prevents * removal of the registered SerializerFactory */ public void removeSerializer(Class javaType, QName xmlType); /** * Removes the DeserializerFactory registered for the specified * pair of Java type and XML data type. * * @param javaType Class of the Java type * @param xmlType Qualified name of the XML data type * * @throws javax.xml.rpc.JAXRPCException if there is any error in removing * the registered DeserializerFactory */ public void removeDeserializer(Class javaType, QName xmlType); }
1,858
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/encoding/DeserializerFactory.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc.encoding; /** * The javax.xml.rpc.encoding.DeserializerFactory is a factory of * deserializers. A DeserializerFactory is registered with a * TypeMapping instance as part of the TypeMappingRegistry. * * @version $Rev$ $Date$ */ public interface DeserializerFactory extends java.io.Serializable { /** * Returns a Deserializer for the specified XML processing mechanism type. * * @param mechanismType XML processing mechanism type [TBD: definition of * valid constants] * * @return a Deserializer for the specified XML processing mechanism type * * @throws javax.xml.rpc.JAXRPCException if DeserializerFactory does not * support the specified XML processing mechanism */ public Deserializer getDeserializerAs(String mechanismType); /** * Returns an <code>Iterator</code> over the list of all XML processing * mechanism types supported by this <code>DeserializerFactory</code>. * * @return an <code>Iterator</code> over the unique identifiers for the * supported XML processing mechanism types (as * <code>String</code>s?) */ public java.util.Iterator getSupportedMechanismTypes(); }
1,859
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/encoding/Serializer.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc.encoding; /** * The javax.xml.rpc.encoding.Serializer interface defines the * base interface for serializers. A Serializer converts * a Java object to an XML representation using a specific XML * processing mechanism and based on the specified type * mapping and encoding style. * * @version $Rev$ $Date$ */ public interface Serializer extends java.io.Serializable { /** * Gets the type of the XML processing mechanism and representation used by this Serializer. * * @return XML processing mechanism type */ public String getMechanismType(); }
1,860
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/encoding/SerializerFactory.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc.encoding; import java.util.Iterator; /** * The javax.xml.rpc.encoding.SerializerFactory is a factory of * the serializers. A SerializerFactory is registered with a * TypeMapping object as part of the TypeMappingRegistry. * * @version $Rev$ $Date$ */ public interface SerializerFactory extends java.io.Serializable { /** * Returns a Serializer for the specified XML processing mechanism type. * * @param mechanismType - XML processing mechanism type [TBD: definition * of valid constants] * * @return a <code>Serializer</code> for the specified XML processing * mechanism type * * @throws javax.xml.rpc.JAXRPCException * if <code>SerializerFactory</code> does not support the * specified XML processing mechanism * @throws java.lang.IllegalArgumentException * if an invalid mechanism type is specified */ public Serializer getSerializerAs(String mechanismType); /** * Returns an Iterator over all XML processing mechanism types supported by * this <code>SerializerFactory</code>. * * @return an Iterator over the mechanism types (<Code>String</code>s?) */ public Iterator getSupportedMechanismTypes(); }
1,861
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/encoding/SerializationContext.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc.encoding; /** * The javax.xml.rpc.encoding.SerializationContext interface is * implemented by the JAX-RPC runtime system in an XML processing * mechanism specific manner. A serializer uses the * SerializationContext interface during the serialization to get * the context information related to the XML processing mechanism * and to manage information specific to serialization. * * @version $Rev$ $Date$ */ public interface SerializationContext {}
1,862
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/server/ServletEndpointContext.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc.server; import javax.servlet.ServletContext; import javax.servlet.http.HttpSession; import javax.xml.rpc.handler.MessageContext; import java.security.Principal; /** * The <code>ServletEndpointContext</code> provides an endpoint * context maintained by the underlying servlet container based * JAX-RPC runtime system. For service endpoints deployed on a * servlet container based JAX-RPC runtime system, the context * parameter in the <code>ServiceLifecycle.init</code> method is * required to be of the Java type * <code>javax.xml.rpc.server.ServletEndpointContext</code>. * <p> * A servlet container based JAX-RPC runtime system implements * the <code>ServletEndpointContext</code> interface. The JAX-RPC * runtime system is required to provide appropriate session, * message context, servlet context and user principal information * per method invocation on the endpoint class. * * @version $Rev$ $Date$ */ public interface ServletEndpointContext { /** * The method <code>getMessageContext</code> returns the * <code>MessageContext</code> targeted for this endpoint instance. * This enables the service endpoint instance to acccess the * <code>MessageContext</code> propagated by request * <code>HandlerChain</code> (and its contained <code>Handler</code> * instances) to the target endpoint instance and to share any * SOAP message processing related context. The endpoint instance * can access and manipulate the <code>MessageContext</code> * and share the SOAP message processing related context with * the response <code>HandlerChain</code>. * * @return MessageContext; If there is no associated * <code>MessageContext</code>, this method returns * <code>null</code>. * @throws java.lang.IllegalStateException if this method is invoked outside a * remote method implementation by a service endpoint instance. */ public MessageContext getMessageContext(); /** * Returns a <code>java.security.Principal</code> instance that * contains the name of the authenticated user for the current * method invocation on the endpoint instance. This method returns * <code>null</code> if there is no associated principal yet. * The underlying JAX-RPC runtime system takes the responsibility * of providing the appropriate authenticated principal for a * remote method invocation on the service endpoint instance. * * @return A <code>java.security.Principal</code> for the * authenticated principal associated with the current * invocation on the servlet endpoint instance; * Returns <code>null</code> if there no authenticated * user associated with a method invocation. */ public Principal getUserPrincipal(); /** * The <code>getHttpSession</code> method returns the current * HTTP session (as a <code>javax.servlet.http.HTTPSession</code>). * When invoked by the service endpoint within a remote method * implementation, the <code>getHttpSession</code> returns the * HTTP session associated currently with this method invocation. * This method returns <code>null</code> if there is no HTTP * session currently active and associated with this service * endpoint. An endpoint class should not rely on an active * HTTP session being always there; the underlying JAX-RPC * runtime system is responsible for managing whether or not * there is an active HTTP session. * <p> * The getHttpSession method throws <code>JAXRPCException</code> * if invoked by an non HTTP bound endpoint. * * @return The HTTP session associated with the current * invocation or <code>null</code> if there is no active session. * @throws javax.xml.rpc.JAXRPCException - If this method invoked by a non-HTTP bound * endpoints. */ public HttpSession getHttpSession(); /** * The method <code>getServletContext</code> returns the * <code>ServletContex</code>t associated with the web * application that contain this endpoint. According to * the Servlet specification, There is one context per web * application (installed as a WAR) per JVM . A servlet * based service endpoint is deployed as part of a web * application. * * @return the current <code>ServletContext</code> */ public ServletContext getServletContext(); public boolean isUserInRole(java.lang.String s); }
1,863
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/server/ServiceLifecycle.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc.server; import javax.xml.rpc.ServiceException; /** * The <code>javax.xml.rpc.server.ServiceLifecycle</code> defines a lifecycle interface for a * JAX-RPC service endpoint. If the service endpoint class implements the * <code>ServiceLifeycle</code> interface, the servlet container based JAX-RPC runtime system * is required to manage the lifecycle of the corresponding service endpoint objects. * * @version $Rev$ $Date$ */ public interface ServiceLifecycle { /** * Used for initialization of a service endpoint. After a service * endpoint instance (an instance of a service endpoint class) is * instantiated, the JAX-RPC runtime system invokes the * <code>init</code> method. The service endpoint class uses the * <code>init</code> method to initialize its configuration * and setup access to any external resources. The context parameter * in the <code>init</code> method enables the endpoint instance to * access the endpoint context provided by the underlying JAX-RPC * runtime system. * <p> * The init method implementation should typecast the context * parameter to an appropriate Java type. For service endpoints * deployed on a servlet container based JAX-RPC runtime system, * the <code>context</code> parameter is of the Java type * <code>javax.xml.rpc.server.ServletEndpointContext</code>. The * <code>ServletEndpointContext</code> provides an endpoint context * maintained by the underlying servlet container based JAX-RPC * runtime system * <p> * @param context Endpoint context for a JAX-RPC service endpoint * @throws ServiceException If any error in initialization of the service endpoint; or if any * illegal context has been provided in the init method */ public abstract void init(Object context) throws ServiceException; /** * JAX-RPC runtime system ends the lifecycle of a service endpoint instance by * invoking the destroy method. The service endpoint releases its resources in * the implementation of the destroy method. */ public abstract void destroy(); }
1,864
0
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc
Create_ds/geronimo-specs/geronimo-jaxrpc_1.1_spec/src/main/java/javax/xml/rpc/soap/SOAPFaultException.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.xml.rpc.soap; import javax.xml.namespace.QName; import javax.xml.soap.Detail; /** * The <code>SOAPFaultException</code> exception represents a * SOAP fault. * <p> * The message part in the SOAP fault maps to the contents of * <code>faultdetail</code> element accessible through the * <code>getDetail</code> method on the <code>SOAPFaultException</code>. * The method <code>createDetail</code> on the * <code>javax.xml.soap.SOAPFactory</code> creates an instance * of the <code>javax.xml.soap.Detail</code>. * <p> * The <code>faultstring</code> provides a human-readable * description of the SOAP fault. The <code>faultcode</code> * element provides an algorithmic mapping of the SOAP fault. * <p> * Refer to SOAP 1.1 and WSDL 1.1 specifications for more * details of the SOAP faults. * * @version $Rev$ $Date$ */ public class SOAPFaultException extends RuntimeException { /** * Constructor for SOAPFaultException. * * @param faultcode <code>QName</code> for the SOAP faultcode * @param faultstring <code>faultstring</code> element of SOAP fault * @param faultactor <code>faultactor</code> element of SOAP fault * @param detail <code>faultdetail</code> element of SOAP fault */ public SOAPFaultException(QName faultcode, String faultstring, String faultactor, Detail detail) { super(faultstring); this.faultcode = faultcode; this.faultstring = faultstring; this.faultactor = faultactor; this.detail = detail; } /** * Gets the <code>faultcode</code> element. The <code>faultcode</code> element provides an algorithmic * mechanism for identifying the fault. SOAP defines a small set of SOAP fault codes covering * basic SOAP faults. * @return QName of the faultcode element */ public QName getFaultCode() { return faultcode; } /** * Gets the <code>faultstring</code> element. The faultstring provides a human-readable description of * the SOAP fault and is not intended for algorithmic processing. * @return <code>faultstring</code> element of the SOAP fault */ public String getFaultString() { return faultstring; } /** * Gets the <code>faultactor</code> element. The <code>faultactor</code> * element provides information about which SOAP node on the SOAP message * path caused the fault to happen. It indicates the source of the fault. * * @return <code>faultactor</code> element of the SOAP fault */ public String getFaultActor() { return faultactor; } /** * Gets the detail element. The detail element is intended for carrying * application specific error information related to the SOAP Body. * * @return <code>detail</code> element of the SOAP fault */ public Detail getDetail() { return detail; } /** Qualified name of the faultcode. */ private QName faultcode; /** The faultstring element of the SOAP fault. */ private String faultstring; /** Faultactor element of the SOAP fault. */ private String faultactor; /** Detail element of the SOAP fault. */ private Detail detail; }
1,865
0
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail/SimpleTextMessage.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.mail; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.Arrays; import java.util.Date; import java.util.Enumeration; import java.util.LinkedList; import java.util.List; import javax.activation.DataHandler; import javax.mail.internet.InternetAddress; /** * @version $Rev$ $Date$ */ public class SimpleTextMessage extends Message { public static final Address[] ADDRESS_ARRAY = new Address[0]; private final List _bcc = new LinkedList(); private final List _cc = new LinkedList(); private String _description; private final Flags _flags = new Flags(); private final List _from = new LinkedList(); private Date _received; private Date _sent; private String _subject; private String _text; private List _to = new LinkedList(); /** * @param folder * @param number */ public SimpleTextMessage(final Folder folder, final int number) { super(folder, number); } /* (non-Javadoc) * @see javax.mail.Message#addFrom(javax.mail.Address[]) */ @Override public void addFrom(final Address[] addresses) throws MessagingException { _from.addAll(Arrays.asList(addresses)); } /* (non-Javadoc) * @see javax.mail.Part#addHeader(java.lang.String, java.lang.String) */ public void addHeader(final String name, final String value) throws MessagingException { throw new UnsupportedOperationException("Method not implemented"); } /* (non-Javadoc) * @see javax.mail.Message#addRecipients(javax.mail.Message.RecipientType, javax.mail.Address[]) */ @Override public void addRecipients(final RecipientType type, final Address[] addresses) throws MessagingException { getList(type).addAll(Arrays.asList(addresses)); } /* (non-Javadoc) * @see javax.mail.Part#getAllHeaders() */ public Enumeration getAllHeaders() throws MessagingException { throw new UnsupportedOperationException("Method not implemented"); } /* (non-Javadoc) * @see javax.mail.Part#getContent() */ public Object getContent() throws IOException, MessagingException { return _text; } /* (non-Javadoc) * @see javax.mail.Part#getContentType() */ public String getContentType() throws MessagingException { return "text/plain"; } /* (non-Javadoc) * @see javax.mail.Part#getDataHandler() */ public DataHandler getDataHandler() throws MessagingException { throw new UnsupportedOperationException("Method not implemented"); } /* (non-Javadoc) * @see javax.mail.Part#getDescription() */ public String getDescription() throws MessagingException { return _description; } /* (non-Javadoc) * @see javax.mail.Part#getDisposition() */ public String getDisposition() throws MessagingException { return Part.INLINE; } /* (non-Javadoc) * @see javax.mail.Part#getFileName() */ public String getFileName() throws MessagingException { return null; } /* (non-Javadoc) * @see javax.mail.Message#getFlags() */ @Override public Flags getFlags() throws MessagingException { return _flags; } /* (non-Javadoc) * @see javax.mail.Message#getFrom() */ @Override public Address[] getFrom() throws MessagingException { return (Address[]) _from.toArray(ADDRESS_ARRAY); } /* (non-Javadoc) * @see javax.mail.Part#getHeader(java.lang.String) */ public String[] getHeader(final String name) throws MessagingException { throw new UnsupportedOperationException("Method not implemented"); } /* (non-Javadoc) * @see javax.mail.Part#getInputStream() */ public InputStream getInputStream() throws IOException, MessagingException { throw new UnsupportedOperationException("Method not implemented"); } /* (non-Javadoc) * @see javax.mail.Part#getLineCount() */ public int getLineCount() throws MessagingException { throw new UnsupportedOperationException("Method not implemented"); } private List getList(final RecipientType type) throws MessagingException { List list; if (type == RecipientType.TO) { list = _to; } else if (type == RecipientType.CC) { list = _cc; } else if (type == RecipientType.BCC) { list = _bcc; } else { throw new MessagingException("Address type not understood"); } return list; } /* (non-Javadoc) * @see javax.mail.Part#getMatchingHeaders(java.lang.String[]) */ public Enumeration getMatchingHeaders(final String[] names) throws MessagingException { throw new UnsupportedOperationException("Method not implemented"); } /* (non-Javadoc) * @see javax.mail.Part#getNonMatchingHeaders(java.lang.String[]) */ public Enumeration getNonMatchingHeaders(final String[] names) throws MessagingException { throw new UnsupportedOperationException("Method not implemented"); } /* (non-Javadoc) * @see javax.mail.Message#getReceivedDate() */ @Override public Date getReceivedDate() throws MessagingException { return _received; } /* (non-Javadoc) * @see javax.mail.Message#getRecipients(javax.mail.Message.RecipientType) */ @Override public Address[] getRecipients(final RecipientType type) throws MessagingException { return (Address[]) getList(type).toArray(ADDRESS_ARRAY); } /* (non-Javadoc) * @see javax.mail.Message#getSentDate() */ @Override public Date getSentDate() throws MessagingException { return _sent; } /* (non-Javadoc) * @see javax.mail.Part#getSize() */ public int getSize() throws MessagingException { return _text.length(); } /* (non-Javadoc) * @see javax.mail.Message#getSubject() */ @Override public String getSubject() throws MessagingException { return _subject; } /* (non-Javadoc) * @see javax.mail.Part#isMimeType(java.lang.String) */ public boolean isMimeType(final String mimeType) throws MessagingException { return mimeType.equals("text/plain") || mimeType.equals("text/*"); } /* (non-Javadoc) * @see javax.mail.Part#removeHeader(java.lang.String) */ public void removeHeader(final String name) throws MessagingException { throw new UnsupportedOperationException("Method not implemented"); } /* (non-Javadoc) * @see javax.mail.Message#reply(boolean) */ @Override public Message reply(final boolean replyToAll) throws MessagingException { try { final SimpleTextMessage reply = (SimpleTextMessage) this.clone(); reply._to = new LinkedList(_from); if (replyToAll) { reply._to.addAll(_cc); } return reply; } catch (final CloneNotSupportedException e) { throw new MessagingException(e.getMessage()); } } /* (non-Javadoc) * @see javax.mail.Message#saveChanges() */ @Override public void saveChanges() throws MessagingException { throw new UnsupportedOperationException("Method not implemented"); } /* (non-Javadoc) * @see javax.mail.Part#setContent(javax.mail.Multipart) */ public void setContent(final Multipart content) throws MessagingException { throw new UnsupportedOperationException("Method not implemented"); } /* (non-Javadoc) * @see javax.mail.Part#setContent(java.lang.Object, java.lang.String) */ public void setContent(final Object content, final String type) throws MessagingException { setText((String) content); } /* (non-Javadoc) * @see javax.mail.Part#setDataHandler(javax.activation.DataHandler) */ public void setDataHandler(final DataHandler handler) throws MessagingException { throw new UnsupportedOperationException("Method not implemented"); } /* (non-Javadoc) * @see javax.mail.Part#setDescription(java.lang.String) */ public void setDescription(final String description) throws MessagingException { _description = description; } /* (non-Javadoc) * @see javax.mail.Part#setDisposition(java.lang.String) */ public void setDisposition(final String disposition) throws MessagingException { throw new UnsupportedOperationException("Method not implemented"); } /* (non-Javadoc) * @see javax.mail.Part#setFileName(java.lang.String) */ public void setFileName(final String name) throws MessagingException { throw new UnsupportedOperationException("Method not implemented"); } /* (non-Javadoc) * @see javax.mail.Message#setFlags(javax.mail.Flags, boolean) */ @Override public void setFlags(final Flags flags, final boolean set) throws MessagingException { if (set) { _flags.add(flags); } else { _flags.remove(flags); } } /* (non-Javadoc) * @see javax.mail.Message#setFrom() */ @Override public void setFrom() throws MessagingException { setFrom(new InternetAddress("root@localhost")); } /* (non-Javadoc) * @see javax.mail.Message#setFrom(javax.mail.Address) */ @Override public void setFrom(final Address address) throws MessagingException { _from.clear(); _from.add(address); } /* (non-Javadoc) * @see javax.mail.Part#setHeader(java.lang.String, java.lang.String) */ public void setHeader(final String name, final String value) throws MessagingException { throw new UnsupportedOperationException("Method not implemented"); } /* (non-Javadoc) * @see javax.mail.Message#setRecipients(javax.mail.Message.RecipientType, javax.mail.Address[]) */ @Override public void setRecipients(final RecipientType type, final Address[] addresses) throws MessagingException { final List list = getList(type); list.clear(); list.addAll(Arrays.asList(addresses)); } /* (non-Javadoc) * @see javax.mail.Message#setSentDate(java.util.Date) */ @Override public void setSentDate(final Date sent) throws MessagingException { _sent = sent; } /* (non-Javadoc) * @see javax.mail.Message#setSubject(java.lang.String) */ @Override public void setSubject(final String subject) throws MessagingException { _subject = subject; } /* (non-Javadoc) * @see javax.mail.Part#setText(java.lang.String) */ public void setText(final String content) throws MessagingException { _text = content; } /* (non-Javadoc) * @see javax.mail.Part#writeTo(java.io.OutputStream) */ public void writeTo(final OutputStream out) throws IOException, MessagingException { throw new UnsupportedOperationException("Method not implemented"); } }
1,866
0
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail/AllTests.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.mail; import javax.mail.event.AllEventTests; import javax.mail.internet.AllInternetTests; import junit.framework.Test; import junit.framework.TestSuite; /** * @version $Revision $ $Date$ */ public class AllTests { public static Test suite() { final TestSuite suite = new TestSuite("Test for javax.mail"); //$JUnit-BEGIN$ suite.addTest(new TestSuite(FlagsTest.class)); suite.addTest(new TestSuite(HeaderTest.class)); suite.addTest(new TestSuite(MessagingExceptionTest.class)); suite.addTest(new TestSuite(URLNameTest.class)); suite.addTest(new TestSuite(PasswordAuthenticationTest.class)); suite.addTest(AllEventTests.suite()); suite.addTest(AllInternetTests.suite()); //$JUnit-END$ return suite; } }
1,867
0
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail/HeaderTest.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.mail; import junit.framework.TestCase; /** * @version $Rev$ $Date$ */ public class HeaderTest extends TestCase { public HeaderTest(final String name) { super(name); } public void testHeader() { final Header header = new Header("One", "Two"); assertEquals("One", header.getName()); assertEquals("Two", header.getValue()); } }
1,868
0
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail/MessagingExceptionTest.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.mail; import junit.framework.TestCase; /** * @version $Revision $ $Date$ */ public class MessagingExceptionTest extends TestCase { private RuntimeException e; private MessagingException d; private MessagingException c; private MessagingException b; private MessagingException a; public MessagingExceptionTest(final String name) { super(name); } @Override protected void setUp() throws Exception { super.setUp(); //Initialize cause with null, make sure the getCause will not be affected a = new MessagingException("A", null); b = new MessagingException("B"); c = new MessagingException("C"); d = new MessagingException("D"); e = new RuntimeException("E"); } public void testMessagingExceptionString() { assertEquals("A", a.getMessage()); } public void testNextException() { assertTrue(a.setNextException(b)); assertEquals(b, a.getNextException()); assertEquals(b, a.getCause()); assertTrue(a.setNextException(c)); assertEquals(b, a.getNextException()); assertEquals(c, b.getNextException()); assertEquals(c, b.getCause()); assertTrue(a.setNextException(d)); assertEquals(b, a.getNextException()); assertEquals(b, a.getCause()); assertEquals(c, b.getNextException()); assertEquals(c, b.getCause()); assertEquals(d, c.getNextException()); assertEquals(d, c.getCause()); final String message = a.getMessage(); final int ap = message.indexOf("A"); final int bp = message.indexOf("B"); final int cp = message.indexOf("C"); assertTrue("A does not contain 'A'", ap != -1); assertTrue("B does not contain 'B'", bp != -1); assertTrue("C does not contain 'C'", cp != -1); } public void testNextExceptionWrong() { assertTrue(a.setNextException(e)); assertFalse(a.setNextException(b)); } public void testNextExceptionWrong2() { assertTrue(a.setNextException(e)); assertFalse(a.setNextException(b)); } public void testMessagingExceptionStringException() { final MessagingException x = new MessagingException("X", a); assertEquals("X (javax.mail.MessagingException: A)", x.getMessage()); assertEquals(a, x.getNextException()); assertEquals(a, x.getCause()); } }
1,869
0
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail/PasswordAuthenticationTest.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.mail; import junit.framework.TestCase; /** * @version $Rev$ $Date$ */ public class PasswordAuthenticationTest extends TestCase { public PasswordAuthenticationTest(final String name) { super(name); } public void testPA() { final String user = String.valueOf(System.currentTimeMillis()); final String password = "JobbyJobbyJobby" + user; final PasswordAuthentication pa = new PasswordAuthentication(user, password); assertEquals(user, pa.getUserName()); assertEquals(password, pa.getPassword()); } public void testPasswordAuthentication() { final PasswordAuthentication pa = new PasswordAuthentication("Alex", "xelA"); assertEquals("Alex", pa.getUserName()); assertEquals("xelA", pa.getPassword()); } }
1,870
0
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail/SimpleFolder.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.mail; import java.util.Iterator; import java.util.LinkedList; import java.util.List; /** * @version $Rev$ $Date$ */ public class SimpleFolder extends Folder { private static final Message[] MESSAGE_ARRAY = new Message[0]; private List _messages = new LinkedList(); private String _name; public SimpleFolder(final Store store) { this(store, "SimpleFolder"); } SimpleFolder(final Store store, final String name) { super(store); _name = name; } /* (non-Javadoc) * @see javax.mail.Folder#appendMessages(javax.mail.Message[]) */ @Override public void appendMessages(final Message[] messages) throws MessagingException { for (int i = 0; i < messages.length; i++) { final Message message = messages[i]; _messages.add(message); } } /* (non-Javadoc) * @see javax.mail.Folder#close(boolean) */ @Override public void close(final boolean expunge) throws MessagingException { if (expunge) { expunge(); } } /* (non-Javadoc) * @see javax.mail.Folder#create(int) */ @Override public boolean create(final int type) throws MessagingException { if (type == HOLDS_MESSAGES) { return true; } else { throw new MessagingException("Cannot create folders that hold folders"); } } /* (non-Javadoc) * @see javax.mail.Folder#delete(boolean) */ @Override public boolean delete(final boolean recurse) throws MessagingException { _messages = new LinkedList(); return true; } /* (non-Javadoc) * @see javax.mail.Folder#exists() */ @Override public boolean exists() throws MessagingException { return true; } /* (non-Javadoc) * @see javax.mail.Folder#expunge() */ @Override public Message[] expunge() throws MessagingException { final Iterator it = _messages.iterator(); final List result = new LinkedList(); while (it.hasNext()) { final Message message = (Message) it.next(); if (message.isSet(Flags.Flag.DELETED)) { it.remove(); result.add(message); } } // run through and renumber the messages for (int i = 0; i < _messages.size(); i++) { final Message message = (Message) _messages.get(i); message.setMessageNumber(i); } return (Message[]) result.toArray(MESSAGE_ARRAY); } /* (non-Javadoc) * @see javax.mail.Folder#getFolder(java.lang.String) */ @Override public Folder getFolder(final String name) throws MessagingException { return null; } /* (non-Javadoc) * @see javax.mail.Folder#getFullName() */ @Override public String getFullName() { return getName(); } /* (non-Javadoc) * @see javax.mail.Folder#getMessage(int) */ @Override public Message getMessage(final int id) throws MessagingException { return (Message) _messages.get(id); } /* (non-Javadoc) * @see javax.mail.Folder#getMessageCount() */ @Override public int getMessageCount() throws MessagingException { return _messages.size(); } /* (non-Javadoc) * @see javax.mail.Folder#getName() */ @Override public String getName() { return _name; } /* (non-Javadoc) * @see javax.mail.Folder#getParent() */ @Override public Folder getParent() throws MessagingException { return null; } /* (non-Javadoc) * @see javax.mail.Folder#getPermanentFlags() */ @Override public Flags getPermanentFlags() { return null; } /* (non-Javadoc) * @see javax.mail.Folder#getSeparator() */ @Override public char getSeparator() throws MessagingException { return '/'; } /* (non-Javadoc) * @see javax.mail.Folder#getType() */ @Override public int getType() throws MessagingException { return HOLDS_MESSAGES; } /* (non-Javadoc) * @see javax.mail.Folder#hasNewMessages() */ @Override public boolean hasNewMessages() throws MessagingException { return false; } /* (non-Javadoc) * @see javax.mail.Folder#isOpen() */ @Override public boolean isOpen() { return true; } /* (non-Javadoc) * @see javax.mail.Folder#list(java.lang.String) */ @Override public Folder[] list(final String pattern) throws MessagingException { return null; } /* (non-Javadoc) * @see javax.mail.Folder#open(int) */ @Override public void open(final int mode) throws MessagingException { if (mode != HOLDS_MESSAGES) { throw new MessagingException("SimpleFolder can only be opened with HOLDS_MESSAGES"); } } /* (non-Javadoc) * @see javax.mail.Folder#renameTo(javax.mail.Folder) */ @Override public boolean renameTo(final Folder newName) throws MessagingException { _name = newName.getName(); return true; } }
1,871
0
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail/SessionTest.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.mail; import java.util.Properties; import junit.framework.TestCase; /** * @version $Rev$ $Date$ */ public class SessionTest extends TestCase { public void testAddProvider() throws MessagingException { final Properties props = System.getProperties(); // Get a Session object final Session mailSession = Session.getDefaultInstance(props, null); mailSession.addProvider(new Provider(Provider.Type.TRANSPORT, "foo", NullTransport.class.getName(), "Apache", "Java 1.4 Test")); // retrieve the transport Transport trans = mailSession.getTransport("foo"); assertTrue(trans instanceof NullTransport); mailSession.setProtocolForAddress("foo", "foo"); trans = mailSession.getTransport(new FooAddress()); assertTrue(trans instanceof NullTransport); } static public class NullTransport extends Transport { public NullTransport(final Session session, final URLName urlName) { super(session, urlName); } @Override public void sendMessage(final Message message, final Address[] addresses) throws MessagingException { // do nothing } @Override protected boolean protocolConnect(final String host, final int port, final String user, final String password) throws MessagingException { return true; // always connect } } static public class FooAddress extends Address { public FooAddress() { } @Override public String getType() { return "foo"; } @Override public String toString() { return "yada"; } @Override public boolean equals(final Object other) { return true; } } }
1,872
0
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail/EventQueueTest.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.mail; import java.util.Vector; import javax.mail.event.FolderEvent; import javax.mail.event.FolderListener; import junit.framework.TestCase; /** * @version $Rev$ $Date$ */ public class EventQueueTest extends TestCase { protected EventQueue queue; @Override public void setUp() throws Exception { queue = new EventQueue(); } @Override public void tearDown() throws Exception { queue.stop(); } public void testEvent() { doEventTests(FolderEvent.CREATED); doEventTests(FolderEvent.RENAMED); doEventTests(FolderEvent.DELETED); } private void doEventTests(final int type) { // These tests are essentially the same as the // folder event tests, but done using the asynchronous // event queue. final FolderEvent event = new FolderEvent(this, null, type); assertEquals(this, event.getSource()); assertEquals(type, event.getType()); final FolderListenerTest listener = new FolderListenerTest(); final Vector listeners = new Vector(); listeners.add(listener); queue.queueEvent(event, listeners); // we need to make sure the queue thread has a chance to dispatch // this before we check. try { Thread.currentThread(); Thread.sleep(1000); } catch (final InterruptedException e ) { } assertEquals("Unexpcted method dispatched", type, listener.getState()); } public static class FolderListenerTest implements FolderListener { private int state = 0; public void folderCreated(final FolderEvent event) { if (state != 0) { fail("Recycled Listener"); } state = FolderEvent.CREATED; } public void folderDeleted(final FolderEvent event) { if (state != 0) { fail("Recycled Listener"); } state = FolderEvent.DELETED; } public void folderRenamed(final FolderEvent event) { if (state != 0) { fail("Recycled Listener"); } state = FolderEvent.RENAMED; } public int getState() { return state; } } }
1,873
0
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail/MessageContextTest.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.mail; import junit.framework.TestCase; /** * @version $Rev$ $Date$ */ public class MessageContextTest extends TestCase { public void testNothing() { } /* public void testMessageContext() { Part p; MessageContext mc; p = new TestPart(); mc = new MessageContext(p); assertSame(p, mc.getPart()); assertNull(mc.getMessage()); assertNull(mc.getSession()); Session s = Session.getDefaultInstance(null); MimeMessage m = new MimeMessage(s); p = new TestMultipart(m); mc = new MessageContext(p); assertSame(p, mc.getPart()); assertSame(m,mc.getMessage()); assertSame(s,mc.getSession()); } private static class TestMultipart extends Multipart implements Part { public TestMultipart(Part p) { parent = p; } public void writeTo(OutputStream out) throws IOException, MessagingException { } public void addHeader(String name, String value) throws MessagingException { } public Enumeration getAllHeaders() throws MessagingException { return null; } public Object getContent() throws IOException, MessagingException { return null; } public DataHandler getDataHandler() throws MessagingException { return null; } public String getDescription() throws MessagingException { return null; } public String getDisposition() throws MessagingException { return null; } public String getFileName() throws MessagingException { return null; } public String[] getHeader(String name) throws MessagingException { return null; } public InputStream getInputStream() throws IOException, MessagingException { return null; } public int getLineCount() throws MessagingException { return 0; } public Enumeration getMatchingHeaders(String[] names) throws MessagingException { return null; } public Enumeration getNonMatchingHeaders(String[] names) throws MessagingException { return null; } public int getSize() throws MessagingException { return 0; } public boolean isMimeType(String mimeType) throws MessagingException { return false; } public void removeHeader(String name) throws MessagingException { } public void setContent(Multipart content) throws MessagingException { } public void setContent(Object content, String type) throws MessagingException { } public void setDataHandler(DataHandler handler) throws MessagingException { } public void setDescription(String description) throws MessagingException { } public void setDisposition(String disposition) throws MessagingException { } public void setFileName(String name) throws MessagingException { } public void setHeader(String name, String value) throws MessagingException { } public void setText(String content) throws MessagingException { } } private static class TestBodyPart extends BodyPart { public TestBodyPart(Multipart p) { super(); parent = p; } public void addHeader(String name, String value) throws MessagingException { } public Enumeration getAllHeaders() throws MessagingException { return null; } public Object getContent() throws IOException, MessagingException { return null; } public String getContentType() throws MessagingException { return null; } public DataHandler getDataHandler() throws MessagingException { return null; } public String getDescription() throws MessagingException { return null; } public String getDisposition() throws MessagingException { return null; } public String getFileName() throws MessagingException { return null; } public String[] getHeader(String name) throws MessagingException { return null; } public InputStream getInputStream() throws IOException, MessagingException { return null; } public int getLineCount() throws MessagingException { return 0; } public Enumeration getMatchingHeaders(String[] names) throws MessagingException { return null; } public Enumeration getNonMatchingHeaders(String[] names) throws MessagingException { return null; } public int getSize() throws MessagingException { return 0; } public boolean isMimeType(String mimeType) throws MessagingException { return false; } public void removeHeader(String name) throws MessagingException { } public void setContent(Multipart content) throws MessagingException { } public void setContent(Object content, String type) throws MessagingException { } public void setDataHandler(DataHandler handler) throws MessagingException { } public void setDescription(String description) throws MessagingException { } public void setDisposition(String disposition) throws MessagingException { } public void setFileName(String name) throws MessagingException { } public void setHeader(String name, String value) throws MessagingException { } public void setText(String content) throws MessagingException { } public void writeTo(OutputStream out) throws IOException, MessagingException { } } private static class TestPart implements Part { public void addHeader(String name, String value) throws MessagingException { } public Enumeration getAllHeaders() throws MessagingException { return null; } public Object getContent() throws IOException, MessagingException { return null; } public String getContentType() throws MessagingException { return null; } public DataHandler getDataHandler() throws MessagingException { return null; } public String getDescription() throws MessagingException { return null; } public String getDisposition() throws MessagingException { return null; } public String getFileName() throws MessagingException { return null; } public String[] getHeader(String name) throws MessagingException { return null; } public InputStream getInputStream() throws IOException, MessagingException { return null; } public int getLineCount() throws MessagingException { return 0; } public Enumeration getMatchingHeaders(String[] names) throws MessagingException { return null; } public Enumeration getNonMatchingHeaders(String[] names) throws MessagingException { return null; } public int getSize() throws MessagingException { return 0; } public boolean isMimeType(String mimeType) throws MessagingException { return false; } public void removeHeader(String name) throws MessagingException { } public void setContent(Multipart content) throws MessagingException { } public void setContent(Object content, String type) throws MessagingException { } public void setDataHandler(DataHandler handler) throws MessagingException { } public void setDescription(String description) throws MessagingException { } public void setDisposition(String disposition) throws MessagingException { } public void setFileName(String name) throws MessagingException { } public void setHeader(String name, String value) throws MessagingException { } public void setText(String content) throws MessagingException { } public void writeTo(OutputStream out) throws IOException, MessagingException { } } */ }
1,874
0
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail/QuotaTest.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.mail; import junit.framework.TestCase; /** * @version $Rev$ $Date$ */ public class QuotaTest extends TestCase { public void testQuota() throws MessagingException { final Quota quota = new Quota("Fred"); assertEquals(quota.quotaRoot, "Fred"); assertNull(quota.resources); quota.setResourceLimit("Storage", 20000); assertNotNull(quota.resources); assertTrue(quota.resources.length == 1); assertEquals(quota.resources[0].name, "Storage"); assertEquals(quota.resources[0].usage, 0); assertEquals(quota.resources[0].limit, 20000); quota.setResourceLimit("Storage", 30000); assertNotNull(quota.resources); assertTrue(quota.resources.length == 1); assertEquals(quota.resources[0].name, "Storage"); assertEquals(quota.resources[0].usage, 0); assertEquals(quota.resources[0].limit, 30000); quota.setResourceLimit("Folders", 5); assertNotNull(quota.resources); assertTrue(quota.resources.length == 2); assertEquals(quota.resources[0].name, "Storage"); assertEquals(quota.resources[0].usage, 0); assertEquals(quota.resources[0].limit, 30000); assertEquals(quota.resources[1].name, "Folders"); assertEquals(quota.resources[1].usage, 0); assertEquals(quota.resources[1].limit, 5); } }
1,875
0
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail/TestData.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.mail; import javax.mail.internet.MimeMessage; public class TestData { public static Store getTestStore() { return new Store( getTestSession(), new URLName("http://alex@test.com")) { @Override public Folder getDefaultFolder() throws MessagingException { return getTestFolder(); } @Override public Folder getFolder(final String name) throws MessagingException { if (name.equals("test")) { return getTestFolder(); } else { return null; } } @Override public Folder getFolder(final URLName name) throws MessagingException { return getTestFolder(); } }; } public static Session getTestSession() { return Session.getDefaultInstance(System.getProperties()); } public static Folder getTestFolder() { return new Folder(getTestStore()) { @Override public void appendMessages(final Message[] messages) throws MessagingException { } @Override public void close(final boolean expunge) throws MessagingException { } @Override public boolean create(final int type) throws MessagingException { return false; } @Override public boolean delete(final boolean recurse) throws MessagingException { return false; } @Override public boolean exists() throws MessagingException { return false; } @Override public Message[] expunge() throws MessagingException { return null; } @Override public Folder getFolder(final String name) throws MessagingException { return null; } @Override public String getFullName() { return null; } @Override public Message getMessage(final int id) throws MessagingException { return null; } @Override public int getMessageCount() throws MessagingException { return 0; } @Override public String getName() { return null; } @Override public Folder getParent() throws MessagingException { return null; } @Override public Flags getPermanentFlags() { return null; } @Override public char getSeparator() throws MessagingException { return 0; } @Override public int getType() throws MessagingException { return 0; } @Override public boolean hasNewMessages() throws MessagingException { return false; } @Override public boolean isOpen() { return false; } @Override public Folder[] list(final String pattern) throws MessagingException { return null; } @Override public void open(final int mode) throws MessagingException { } @Override public boolean renameTo(final Folder newName) throws MessagingException { return false; } }; } public static Transport getTestTransport() { return new Transport( getTestSession(), new URLName("http://host.name")) { @Override public void sendMessage(final Message message, final Address[] addresses) throws MessagingException { } }; } public static Message getMessage() { return new MimeMessage(getTestFolder(), 1) { }; } }
1,876
0
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail/URLNameTest.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.mail; import java.net.MalformedURLException; import java.net.URL; import junit.framework.TestCase; /** * @version $Rev$ $Date$ */ public class URLNameTest extends TestCase { public URLNameTest(final String name) { super(name); } public void testURLNameString() { String s; URLName name; s = "http://www.apache.org"; name = new URLName(s); assertEquals(s, name.toString()); assertEquals("http", name.getProtocol()); assertEquals("www.apache.org", name.getHost()); assertEquals(-1, name.getPort()); assertNull(name.getFile()); assertNull(name.getRef()); assertNull(name.getUsername()); assertNull(name.getPassword()); try { assertEquals(new URL(s), name.getURL()); } catch (final MalformedURLException e) { fail(); } s = "http://www.apache.org/file/file1#ref"; name = new URLName(s); assertEquals(s, name.toString()); assertEquals("http", name.getProtocol()); assertEquals("www.apache.org", name.getHost()); assertEquals(-1, name.getPort()); assertEquals("file/file1", name.getFile()); assertEquals("ref", name.getRef()); assertNull(name.getUsername()); assertNull(name.getPassword()); try { assertEquals(new URL(s), name.getURL()); } catch (final MalformedURLException e) { fail(); } s = "http://www.apache.org/file/"; name = new URLName(s); assertEquals(s, name.toString()); assertEquals("http", name.getProtocol()); assertEquals("www.apache.org", name.getHost()); assertEquals(-1, name.getPort()); assertEquals("file/", name.getFile()); assertNull(name.getRef()); assertNull(name.getUsername()); assertNull(name.getPassword()); try { assertEquals(new URL(s), name.getURL()); } catch (final MalformedURLException e) { fail(); } s = "http://john@www.apache.org/file/"; name = new URLName(s); assertEquals(s, name.toString()); assertEquals("http", name.getProtocol()); assertEquals("www.apache.org", name.getHost()); assertEquals(-1, name.getPort()); assertEquals("file/", name.getFile()); assertNull(name.getRef()); assertEquals("john", name.getUsername()); assertNull(name.getPassword()); try { assertEquals(new URL(s), name.getURL()); } catch (final MalformedURLException e) { fail(); } s = "http://john:doe@www.apache.org/file/"; name = new URLName(s); assertEquals(s, name.toString()); assertEquals("http", name.getProtocol()); assertEquals("www.apache.org", name.getHost()); assertEquals(-1, name.getPort()); assertEquals("file/", name.getFile()); assertNull(name.getRef()); assertEquals("john", name.getUsername()); assertEquals("doe", name.getPassword()); try { assertEquals(new URL(s), name.getURL()); } catch (final MalformedURLException e) { fail(); } s = "http://john%40gmail.com:doe@www.apache.org/file/"; name = new URLName(s); assertEquals(s, name.toString()); assertEquals("http", name.getProtocol()); assertEquals("www.apache.org", name.getHost()); assertEquals(-1, name.getPort()); assertEquals("file/", name.getFile()); assertNull(name.getRef()); assertEquals("john@gmail.com", name.getUsername()); assertEquals("doe", name.getPassword()); try { assertEquals(new URL(s), name.getURL()); } catch (final MalformedURLException e) { fail(); } s = "file/file2"; name = new URLName(s); assertNull(name.getProtocol()); assertNull(name.getHost()); assertEquals(-1, name.getPort()); assertEquals("file/file2", name.getFile()); assertNull(name.getRef()); assertNull(name.getUsername()); assertNull(name.getPassword()); try { name.getURL(); fail(); } catch (final MalformedURLException e) { // OK } name = new URLName((String) null); assertNull( name.getProtocol()); assertNull(name.getHost()); assertEquals(-1, name.getPort()); assertNull(name.getFile()); assertNull(name.getRef()); assertNull(name.getUsername()); assertNull(name.getPassword()); try { name.getURL(); fail(); } catch (final MalformedURLException e) { // OK } name = new URLName(""); assertNull( name.getProtocol()); assertNull(name.getHost()); assertEquals(-1, name.getPort()); assertNull(name.getFile()); assertNull(name.getRef()); assertNull(name.getUsername()); assertNull(name.getPassword()); try { name.getURL(); fail(); } catch (final MalformedURLException e) { // OK } } public void testURLNameAll() { URLName name; name = new URLName(null, null, -1, null, null, null); assertNull(name.getProtocol()); assertNull(name.getHost()); assertEquals(-1, name.getPort()); assertNull(name.getFile()); assertNull(name.getRef()); assertNull(name.getUsername()); assertNull(name.getPassword()); try { name.getURL(); fail(); } catch (final MalformedURLException e) { // OK } name = new URLName("", "", -1, "", "", ""); assertNull(name.getProtocol()); assertNull(name.getHost()); assertEquals(-1, name.getPort()); assertNull(name.getFile()); assertNull(name.getRef()); assertNull(name.getUsername()); assertNull(name.getPassword()); try { name.getURL(); fail(); } catch (final MalformedURLException e) { // OK } name = new URLName("http", "www.apache.org", -1, null, null, null); assertEquals("http://www.apache.org", name.toString()); assertEquals("http", name.getProtocol()); assertEquals("www.apache.org", name.getHost()); assertEquals(-1, name.getPort()); assertNull(name.getFile()); assertNull(name.getRef()); assertNull(name.getUsername()); assertNull(name.getPassword()); try { assertEquals(new URL("http://www.apache.org"), name.getURL()); } catch (final MalformedURLException e) { fail(); } name = new URLName("http", "www.apache.org", 8080, "", "", ""); assertEquals("http://www.apache.org:8080", name.toString()); assertEquals("http", name.getProtocol()); assertEquals("www.apache.org", name.getHost()); assertEquals(8080, name.getPort()); assertNull(name.getFile()); assertNull(name.getRef()); assertNull(name.getUsername()); assertNull(name.getPassword()); try { assertEquals(new URL("http://www.apache.org:8080"), name.getURL()); } catch (final MalformedURLException e) { fail(); } name = new URLName("http", "www.apache.org", -1, "file/file2", "", ""); assertEquals("http://www.apache.org/file/file2", name.toString()); assertEquals("http", name.getProtocol()); assertEquals("www.apache.org", name.getHost()); assertEquals(-1, name.getPort()); assertEquals("file/file2", name.getFile()); assertNull(name.getRef()); assertNull(name.getUsername()); assertNull(name.getPassword()); try { assertEquals(new URL("http://www.apache.org/file/file2"), name.getURL()); } catch (final MalformedURLException e) { fail(); } name = new URLName("http", "www.apache.org", -1, "file/file2", "john", ""); assertEquals("http://john@www.apache.org/file/file2", name.toString()); assertEquals("http", name.getProtocol()); assertEquals("www.apache.org", name.getHost()); assertEquals(-1, name.getPort()); assertEquals("file/file2", name.getFile()); assertNull(name.getRef()); assertEquals("john", name.getUsername()); assertNull(name.getPassword()); try { assertEquals(new URL("http://john@www.apache.org/file/file2"), name.getURL()); } catch (final MalformedURLException e) { fail(); } name = new URLName("http", "www.apache.org", -1, "file/file2", "john", "doe"); assertEquals("http://john:doe@www.apache.org/file/file2", name.toString()); assertEquals("http", name.getProtocol()); assertEquals("www.apache.org", name.getHost()); assertEquals(-1, name.getPort()); assertEquals("file/file2", name.getFile()); assertNull(name.getRef()); assertEquals("john", name.getUsername()); assertEquals("doe", name.getPassword()); try { assertEquals(new URL("http://john:doe@www.apache.org/file/file2"), name.getURL()); } catch (final MalformedURLException e) { fail(); } name = new URLName("http", "www.apache.org", -1, "file/file2", "john@gmail.com", "doe"); assertEquals("http://john%40gmail.com:doe@www.apache.org/file/file2", name.toString()); assertEquals("http", name.getProtocol()); assertEquals("www.apache.org", name.getHost()); assertEquals(-1, name.getPort()); assertEquals("file/file2", name.getFile()); assertNull(name.getRef()); assertEquals("john@gmail.com", name.getUsername()); assertEquals("doe", name.getPassword()); try { assertEquals(new URL("http://john%40gmail.com:doe@www.apache.org/file/file2"), name.getURL()); } catch (final MalformedURLException e) { fail(); } name = new URLName("http", "www.apache.org", -1, "file/file2", "", "doe"); assertEquals("http://www.apache.org/file/file2", name.toString()); assertEquals("http", name.getProtocol()); assertEquals("www.apache.org", name.getHost()); assertEquals(-1, name.getPort()); assertEquals("file/file2", name.getFile()); assertNull(name.getRef()); assertNull(name.getUsername()); assertNull(name.getPassword()); try { assertEquals(new URL("http://www.apache.org/file/file2"), name.getURL()); } catch (final MalformedURLException e) { fail(); } } public void testURLNameURL() throws MalformedURLException { URL url; URLName name; url = new URL("http://www.apache.org"); name = new URLName(url); assertEquals("http", name.getProtocol()); assertEquals("www.apache.org", name.getHost()); assertEquals(-1, name.getPort()); assertNull(name.getFile()); assertNull(name.getRef()); assertNull(name.getUsername()); assertNull(name.getPassword()); try { assertEquals(url, name.getURL()); } catch (final MalformedURLException e) { fail(); } } public void testEquals() throws MalformedURLException { URLName name1 = new URLName("http://www.apache.org"); assertEquals(name1, new URLName("http://www.apache.org")); assertEquals(name1, new URLName(new URL("http://www.apache.org"))); assertEquals(name1, new URLName("http", "www.apache.org", -1, null, null, null)); assertEquals(name1, new URLName("http://www.apache.org#foo")); // wierd but ref is not part of the equals contract assertTrue(!name1.equals(new URLName("http://www.apache.org:8080"))); assertTrue(!name1.equals(new URLName("http://cvs.apache.org"))); assertTrue(!name1.equals(new URLName("https://www.apache.org"))); name1 = new URLName("http://john:doe@www.apache.org"); assertEquals(name1, new URLName(new URL("http://john:doe@www.apache.org"))); assertEquals(name1, new URLName("http", "www.apache.org", -1, null, "john", "doe")); assertTrue(!name1.equals(new URLName("http://john:xxx@www.apache.org"))); assertTrue(!name1.equals(new URLName("http://xxx:doe@www.apache.org"))); assertTrue(!name1.equals(new URLName("http://www.apache.org"))); assertEquals(new URLName("http://john@www.apache.org"), new URLName("http", "www.apache.org", -1, null, "john", null)); assertEquals(new URLName("http://www.apache.org"), new URLName("http", "www.apache.org", -1, null, null, "doe")); } public void testHashCode() { final URLName name1 = new URLName("http://www.apache.org/file"); final URLName name2 = new URLName("http://www.apache.org/file#ref"); assertTrue(name1.equals(name2)); assertTrue(name1.hashCode() == name2.hashCode()); } public void testNullProtocol() { final URLName name1 = new URLName(null, "www.apache.org", -1, null, null, null); final URLName name2 = new URLName(null, "www.apache.org", -1, null, null, null); assertTrue(!name2.equals(name1)); } public void testOpaqueSchemes() { String s; URLName name; // not strictly opaque but no protocol handler installed s = "foo://jdoe@apache.org/INBOX"; name = new URLName(s); assertEquals(s, name.toString()); assertEquals("foo", name.getProtocol()); assertEquals("apache.org", name.getHost()); assertEquals(-1, name.getPort()); assertEquals("INBOX", name.getFile()); assertNull(name.getRef()); assertEquals("jdoe", name.getUsername()); assertNull(name.getPassword()); // TBD as I am not sure what other URL formats to use } }
1,877
0
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail/FlagsTest.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.mail; import java.util.Collections; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import junit.framework.TestCase; /** * @version $Rev$ $Date$ */ public class FlagsTest extends TestCase { private List flagtypes; private Flags flags; /** * Constructor for FlagsTest. * @param arg0 */ public FlagsTest(final String name) { super(name); } /* * @see TestCase#setUp() */ @Override protected void setUp() throws Exception { super.setUp(); flags = new Flags(); flagtypes = new LinkedList(); flagtypes.add(Flags.Flag.ANSWERED); flagtypes.add(Flags.Flag.DELETED); flagtypes.add(Flags.Flag.DRAFT); flagtypes.add(Flags.Flag.FLAGGED); flagtypes.add(Flags.Flag.RECENT); flagtypes.add(Flags.Flag.SEEN); Collections.shuffle(flagtypes); } public void testHashCode() { final int before = flags.hashCode(); flags.add("Test"); assertTrue( "Before: " + before + ", now " + flags.hashCode(), flags.hashCode() != before); assertTrue(flags.hashCode() != 0); } /* * Test for void add(Flag) */ public void testAddAndRemoveFlag() { Iterator it = flagtypes.iterator(); while (it.hasNext()) { final Flags.Flag flag = (Flags.Flag) it.next(); assertFalse(flags.contains(flag)); flags.add(flag); assertTrue(flags.contains(flag)); } it = flagtypes.iterator(); while (it.hasNext()) { final Flags.Flag flag = (Flags.Flag) it.next(); flags.remove(flag); assertFalse(flags.contains(flag)); } } /* * Test for void add(String) */ public void testAddString() { assertFalse(flags.contains("Frog")); flags.add("Frog"); assertTrue(flags.contains("Frog")); flags.remove("Frog"); assertFalse(flags.contains("Frog")); } /* * Test for void add(Flags) */ public void testAddFlags() { final Flags other = new Flags(); other.add("Stuff"); other.add(Flags.Flag.RECENT); flags.add(other); assertTrue(flags.contains("Stuff")); assertTrue(flags.contains(Flags.Flag.RECENT)); assertTrue(flags.contains(other)); assertTrue(flags.contains(flags)); flags.add("Thing"); assertTrue(flags.contains("Thing")); flags.remove(other); assertFalse(flags.contains("Stuff")); assertFalse(flags.contains(Flags.Flag.RECENT)); assertFalse(flags.contains(other)); assertTrue(flags.contains("Thing")); } /* * Test for boolean equals(Object) */ public void testEqualsObject() { final Flags other = new Flags(); other.add("Stuff"); other.add(Flags.Flag.RECENT); flags.add(other); assertEquals(flags, other); } public void testGetSystemFlags() { flags.add("Stuff"); flags.add("Another"); flags.add(Flags.Flag.FLAGGED); flags.add(Flags.Flag.RECENT); final Flags.Flag[] array = flags.getSystemFlags(); assertEquals(2, array.length); assertTrue( (array[0] == Flags.Flag.FLAGGED && array[1] == Flags.Flag.RECENT) || (array[0] == Flags.Flag.RECENT && array[1] == Flags.Flag.FLAGGED)); } public void testGetUserFlags() { final String stuff = "Stuff"; final String another = "Another"; flags.add(stuff); flags.add(another); flags.add(Flags.Flag.FLAGGED); flags.add(Flags.Flag.RECENT); final String[] array = flags.getUserFlags(); assertEquals(2, array.length); assertTrue( (array[0] == stuff && array[1] == another) || (array[0] == another && array[1] == stuff)); } public void testClone() throws CloneNotSupportedException { flags.add("Thing"); flags.add(Flags.Flag.RECENT); final Flags other = (Flags) flags.clone(); assertTrue(other != flags); assertEquals(other, flags); } }
1,878
0
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail/util/SharedFileInputStreamTest.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.mail.util; import java.io.File; import java.io.IOException; import junit.framework.TestCase; /** * @version $Rev$ $Date$ */ public class SharedFileInputStreamTest extends TestCase { File basedir = new File(System.getProperty("basedir", ".")); File testInput = new File(basedir, "src/test/resources/test.dat"); public SharedFileInputStreamTest(final String arg0) { super(arg0); } public void testInput() throws Exception { doTestInput(new SharedFileInputStream(testInput)); doTestInput(new SharedFileInputStream(testInput.getPath())); doTestInput(new SharedFileInputStream(testInput, 16)); doTestInput(new SharedFileInputStream(testInput.getPath(), 16)); } public void doTestInput(final SharedFileInputStream in) throws Exception { assertEquals(in.read(), '0'); assertEquals(in.getPosition(), 1); final byte[] bytes = new byte[10]; assertEquals(in.read(bytes), 10); assertEquals(new String(bytes), "123456789a"); assertEquals(in.getPosition(), 11); assertEquals(in.read(bytes, 5, 5), 5); assertEquals(new String(bytes), "12345bcdef"); assertEquals(in.getPosition(), 16); assertEquals(in.skip(5), 5); assertEquals(in.getPosition(), 21); assertEquals(in.read(), 'l'); while (in.read() != '\n' ) { } assertEquals(in.read(), -1); in.close(); } public void testNewStream() throws Exception { final SharedFileInputStream in = new SharedFileInputStream(testInput); final SharedFileInputStream sub = (SharedFileInputStream)in.newStream(10, 10 + 26); assertEquals(sub.getPosition(), 0); assertEquals(in.read(), '0'); assertEquals(sub.read(), 'a'); sub.skip(1); assertEquals(sub.getPosition(), 2); while (sub.read() != 'z') { } assertEquals(sub.read(), -1); final SharedFileInputStream sub2 = (SharedFileInputStream)sub.newStream(5, 10); sub.close(); // should not close in or sub2 assertEquals(sub2.getPosition(), 0); assertEquals(sub2.read(), 'f'); assertEquals(in.read(), '1'); // should still work sub2.close(); assertEquals(in.read(), '2'); // should still work in.close(); } public void testMark() throws Exception { doMarkTest(new SharedFileInputStream(testInput, 10)); final SharedFileInputStream in = new SharedFileInputStream(testInput, 10); final SharedFileInputStream sub = (SharedFileInputStream)in.newStream(5, -1); doMarkTest(sub); } private void doMarkTest(final SharedFileInputStream in) throws Exception { assertTrue(in.markSupported()); final byte[] buffer = new byte[60]; in.read(); in.read(); in.mark(50); final int markSpot = in.read(); in.read(buffer, 0, 20); in.reset(); assertEquals(markSpot, in.read()); in.read(buffer, 0, 40); in.reset(); assertEquals(markSpot, in.read()); in.read(buffer, 0, 51); try { in.reset(); fail(); } catch (final IOException e) { } } }
1,879
0
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail/util/SharedByteArrayInputStreamTest.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.mail.util; import junit.framework.TestCase; /** * @version $Rev$ $Date$ */ public class SharedByteArrayInputStreamTest extends TestCase { private final String testString = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; private final byte[] testData = testString.getBytes(); public SharedByteArrayInputStreamTest(final String arg0) { super(arg0); } public void testInput() throws Exception { final SharedByteArrayInputStream in = new SharedByteArrayInputStream(testData); assertEquals(in.read(), '0'); assertEquals(in.getPosition(), 1); final byte[] bytes = new byte[10]; assertEquals(in.read(bytes), 10); assertEquals(new String(bytes), "123456789a"); assertEquals(in.getPosition(), 11); assertEquals(in.read(bytes, 5, 5), 5); assertEquals(new String(bytes), "12345bcdef"); assertEquals(in.getPosition(), 16); assertEquals(in.skip(5), 5); assertEquals(in.getPosition(), 21); assertEquals(in.read(), 'l'); while (in.read() != 'Z') { } assertEquals(in.read(), -1); } public void testNewStream() throws Exception { final SharedByteArrayInputStream in = new SharedByteArrayInputStream(testData); final SharedByteArrayInputStream sub = (SharedByteArrayInputStream)in.newStream(10, 10 + 26); assertEquals(sub.getPosition(), 0); assertEquals(in.read(), '0'); assertEquals(sub.read(), 'a'); sub.skip(1); assertEquals(sub.getPosition(), 2); while (sub.read() != 'z') { } assertEquals(sub.read(), -1); final SharedByteArrayInputStream sub2 = (SharedByteArrayInputStream)sub.newStream(5, 10); assertEquals(sub2.getPosition(), 0); assertEquals(sub2.read(), 'f'); } }
1,880
0
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail/util/ByteArrayDataSourceTest.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.mail.util; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import junit.framework.TestCase; /** * @version $Rev$ $Date$ */ public class ByteArrayDataSourceTest extends TestCase { public ByteArrayDataSourceTest(final String arg0) { super(arg0); } public void testByteArray() throws Exception { doDataSourceTest(new ByteArrayDataSource("0123456789", "text/plain"), "text/plain"); doDataSourceTest(new ByteArrayDataSource("0123456789".getBytes(), "text/xml"), "text/xml"); final ByteArrayInputStream in = new ByteArrayInputStream("0123456789".getBytes()); doDataSourceTest(new ByteArrayDataSource(in, "text/html"), "text/html"); try { final ByteArrayDataSource source = new ByteArrayDataSource("01234567890", "text/plain"); source.getOutputStream(); fail(); } catch (final IOException e) { } final ByteArrayDataSource source = new ByteArrayDataSource("01234567890", "text/plain"); assertEquals(source.getName(), ""); source.setName("fred"); assertEquals(source.getName(), "fred"); } private void doDataSourceTest(final ByteArrayDataSource source, final String type) throws Exception { assertEquals(type, source.getContentType()); final InputStream in = source.getInputStream(); final byte[] bytes = new byte[10]; final int count = in.read(bytes); assertEquals(count, bytes.length); assertEquals("0123456789", new String(bytes)); } }
1,881
0
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail/internet/MimeMessageTest.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.mail.internet; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.Properties; import javax.activation.CommandMap; import javax.activation.MailcapCommandMap; import javax.mail.Address; import javax.mail.Flags.Flag; import javax.mail.Message; import javax.mail.Message.RecipientType; import javax.mail.MessagingException; import javax.mail.Session; import junit.framework.TestCase; /** * @version $Rev$ $Date$ */ public class MimeMessageTest extends TestCase { private CommandMap defaultMap; private Session session; public void testWriteTo() throws MessagingException, IOException { final MimeMessage msg = new MimeMessage(session); msg.setSender(new InternetAddress("foo")); msg.setHeader("foo", "bar"); final MimeMultipart mp = new MimeMultipart(); final MimeBodyPart part1 = new MimeBodyPart(); part1.setHeader("foo", "bar"); part1.setContent("Hello World", "text/plain"); mp.addBodyPart(part1); final MimeBodyPart part2 = new MimeBodyPart(); part2.setContent("Hello Again", "text/plain"); mp.addBodyPart(part2); msg.setContent(mp); final ByteArrayOutputStream out = new ByteArrayOutputStream(); msg.writeTo(out); final InputStream in = new ByteArrayInputStream(out.toByteArray()); MimeMessage newMessage = new MimeMessage(session, in); assertEquals(((InternetAddress)newMessage.getSender()).getAddress(), "foo"); final String[] headers = newMessage.getHeader("foo"); assertTrue(headers.length == 1); assertEquals(headers[0], "bar"); newMessage = new MimeMessage(msg); assertEquals(((InternetAddress)newMessage.getSender()).getAddress(), "foo"); assertEquals(newMessage.getHeader("foo")[0], "bar"); } public void testFrom() throws MessagingException { final MimeMessage msg = new MimeMessage(session); final InternetAddress dev = new InternetAddress("geronimo-dev@apache.org"); final InternetAddress user = new InternetAddress("geronimo-user@apache.org"); msg.setSender(dev); Address[] from = msg.getFrom(); assertTrue(from.length == 1); assertEquals(from[0], dev); msg.setFrom(user); from = msg.getFrom(); assertTrue(from.length == 1); assertEquals(from[0], user); msg.addFrom(new Address[] { dev }); from = msg.getFrom(); assertTrue(from.length == 2); assertEquals(from[0], user); assertEquals(from[1], dev); msg.setFrom(); final InternetAddress local = InternetAddress.getLocalAddress(session); from = msg.getFrom(); assertTrue(from.length == 1); assertEquals(local, from[0]); msg.setFrom((Address) null); from = msg.getFrom(); assertTrue(from.length == 1); assertEquals(dev, from[0]); msg.setSender(null); from = msg.getFrom(); assertNull(from); } public void testSender() throws MessagingException { final MimeMessage msg = new MimeMessage(session); final InternetAddress dev = new InternetAddress("geronimo-dev@apache.org"); final InternetAddress user = new InternetAddress("geronimo-user@apache.org"); msg.setSender(dev); final Address[] from = msg.getFrom(); assertTrue(from.length == 1); assertEquals(from[0], dev); assertEquals(msg.getSender(), dev); msg.setSender(null); assertNull(msg.getSender()); } public void testJavaMail15GetSession() throws MessagingException { final MimeMessage msg = new MimeMessage(session); assertTrue(session == msg.getSession()); final MimeMessage msg2 = new MimeMessage((Session) null); assertTrue(null == msg2.getSession()); } public void testJava15From() throws MessagingException { final MimeMessage msg = new MimeMessage(session); final InternetAddress dev = new InternetAddress("geronimo-dev@apache.org"); final InternetAddress user = new InternetAddress("geronimo-user@apache.org"); msg.setFrom("geronimo-dev@apache.org,geronimo-user@apache.org"); Address[] from = msg.getFrom(); assertTrue(from.length == 2); assertEquals(from[0], dev); assertEquals(from[1], user); msg.setFrom("test@apache.org"); from = msg.getFrom(); assertTrue(from.length == 1); assertEquals(from[0], new InternetAddress("test@apache.org")); } public void testGetAllRecipients() throws MessagingException { final MimeMessage msg = new MimeMessage(session); final InternetAddress dev = new InternetAddress("geronimo-dev@apache.org"); final InternetAddress user = new InternetAddress("geronimo-user@apache.org"); final InternetAddress user1 = new InternetAddress("geronimo-user1@apache.org"); final InternetAddress user2 = new InternetAddress("geronimo-user2@apache.org"); final NewsAddress group = new NewsAddress("comp.lang.rexx"); Address[] recipients = msg.getAllRecipients(); assertNull(recipients); msg.setRecipients(Message.RecipientType.TO, new Address[] { dev }); recipients = msg.getAllRecipients(); assertTrue(recipients.length == 1); assertEquals(recipients[0], dev); msg.addRecipients(Message.RecipientType.BCC, new Address[] { user }); recipients = msg.getAllRecipients(); assertTrue(recipients.length == 2); assertEquals(recipients[0], dev); assertEquals(recipients[1], user); msg.addRecipients(Message.RecipientType.CC, new Address[] { user1, user2} ); recipients = msg.getAllRecipients(); assertTrue(recipients.length == 4); assertEquals(recipients[0], dev); assertEquals(recipients[1], user1); assertEquals(recipients[2], user2); assertEquals(recipients[3], user); msg.addRecipients(MimeMessage.RecipientType.NEWSGROUPS, new Address[] { group } ); recipients = msg.getAllRecipients(); assertTrue(recipients.length == 5); assertEquals(recipients[0], dev); assertEquals(recipients[1], user1); assertEquals(recipients[2], user2); assertEquals(recipients[3], user); assertEquals(recipients[4], group); msg.setRecipients(Message.RecipientType.CC, (String)null); recipients = msg.getAllRecipients(); assertTrue(recipients.length == 3); assertEquals(recipients[0], dev); assertEquals(recipients[1], user); assertEquals(recipients[2], group); } public void testGetRecipients() throws MessagingException { doRecipientTest(Message.RecipientType.TO); doRecipientTest(Message.RecipientType.CC); doRecipientTest(Message.RecipientType.BCC); doNewsgroupRecipientTest(MimeMessage.RecipientType.NEWSGROUPS); } private void doRecipientTest(final Message.RecipientType type) throws MessagingException { final MimeMessage msg = new MimeMessage(session); final InternetAddress dev = new InternetAddress("geronimo-dev@apache.org"); final InternetAddress user = new InternetAddress("geronimo-user@apache.org"); Address[] recipients = msg.getRecipients(type); assertNull(recipients); msg.setRecipients(type, "geronimo-dev@apache.org"); recipients = msg.getRecipients(type); assertTrue(recipients.length == 1); assertEquals(recipients[0], dev); msg.addRecipients(type, "geronimo-user@apache.org"); recipients = msg.getRecipients(type); assertTrue(recipients.length == 2); assertEquals(recipients[0], dev); assertEquals(recipients[1], user); msg.setRecipients(type, (String)null); recipients = msg.getRecipients(type); assertNull(recipients); msg.setRecipients(type, new Address[] { dev }); recipients = msg.getRecipients(type); assertTrue(recipients.length == 1); assertEquals(recipients[0], dev); msg.addRecipients(type, new Address[] { user }); recipients = msg.getRecipients(type); assertTrue(recipients.length == 2); assertEquals(recipients[0], dev); assertEquals(recipients[1], user); msg.setRecipients(type, (Address[])null); recipients = msg.getRecipients(type); assertNull(recipients); msg.setRecipients(type, new Address[] { dev, user }); recipients = msg.getRecipients(type); assertTrue(recipients.length == 2); assertEquals(recipients[0], dev); assertEquals(recipients[1], user); } private void doNewsgroupRecipientTest(final Message.RecipientType type) throws MessagingException { final MimeMessage msg = new MimeMessage(session); final Address dev = new NewsAddress("geronimo-dev"); final Address user = new NewsAddress("geronimo-user"); Address[] recipients = msg.getRecipients(type); assertNull(recipients); msg.setRecipients(type, "geronimo-dev"); recipients = msg.getRecipients(type); assertTrue(recipients.length == 1); assertEquals(recipients[0], dev); msg.addRecipients(type, "geronimo-user"); recipients = msg.getRecipients(type); assertTrue(recipients.length == 2); assertEquals(recipients[0], dev); assertEquals(recipients[1], user); msg.setRecipients(type, (String)null); recipients = msg.getRecipients(type); assertNull(recipients); msg.setRecipients(type, new Address[] { dev }); recipients = msg.getRecipients(type); assertTrue(recipients.length == 1); assertEquals(recipients[0], dev); msg.addRecipients(type, new Address[] { user }); recipients = msg.getRecipients(type); assertTrue(recipients.length == 2); assertEquals(recipients[0], dev); assertEquals(recipients[1], user); msg.setRecipients(type, (Address[])null); recipients = msg.getRecipients(type); assertNull(recipients); msg.setRecipients(type, new Address[] { dev, user }); recipients = msg.getRecipients(type); assertTrue(recipients.length == 2); assertEquals(recipients[0], dev); assertEquals(recipients[1], user); } public void testReplyTo() throws MessagingException { final MimeMessage msg = new MimeMessage(session); final InternetAddress dev = new InternetAddress("geronimo-dev@apache.org"); final InternetAddress user = new InternetAddress("geronimo-user@apache.org"); msg.setReplyTo(new Address[] { dev }); Address[] recipients = msg.getReplyTo(); assertTrue(recipients.length == 1); assertEquals(recipients[0], dev); msg.setReplyTo(new Address[] { dev, user }); recipients = msg.getReplyTo(); assertTrue(recipients.length == 2); assertEquals(recipients[0], dev); assertEquals(recipients[1], user); msg.setReplyTo(null); recipients = msg.getReplyTo(); assertNull(recipients); } public void testJavaMail15Reply() throws MessagingException { final MimeMessage msg = new MimeMessage(session); final InternetAddress dev = new InternetAddress("geronimo-dev@apache.org"); msg.setFrom("test@apache.org"); msg.setRecipient(RecipientType.TO, dev); final Message replyMsg = msg.reply(true, true); assertNotNull(replyMsg); assertTrue(msg.isSet(Flag.ANSWERED)); assertEquals(new InternetAddress("test@apache.org"), replyMsg.getRecipients(RecipientType.TO)[0]); } public void testJavaMail15Reply2() throws MessagingException { final MimeMessage msg = new MimeMessage(session); final InternetAddress dev = new InternetAddress("geronimo-dev@apache.org"); msg.setFrom("test@apache.org"); msg.setRecipient(RecipientType.TO, dev); final Message replyMsg = msg.reply(false, false); assertNotNull(replyMsg); assertFalse(msg.isSet(Flag.ANSWERED)); assertEquals(new InternetAddress("test@apache.org"), replyMsg.getRecipients(RecipientType.TO)[0]); } public void testSetSubject() throws MessagingException { final MimeMessage msg = new MimeMessage(session); final String simpleSubject = "Yada, yada"; final String complexSubject = "Yada, yada\u0081"; final String mungedSubject = "Yada, yada\u003F"; msg.setSubject(simpleSubject); assertEquals(msg.getSubject(), simpleSubject); msg.setSubject(complexSubject, "UTF-8"); assertEquals(msg.getSubject(), complexSubject); msg.setSubject(null); assertNull(msg.getSubject()); } public void testSetDescription() throws MessagingException { final MimeMessage msg = new MimeMessage(session); final String simpleSubject = "Yada, yada"; final String complexSubject = "Yada, yada\u0081"; final String mungedSubject = "Yada, yada\u003F"; msg.setDescription(simpleSubject); assertEquals(msg.getDescription(), simpleSubject); msg.setDescription(complexSubject, "UTF-8"); assertEquals(msg.getDescription(), complexSubject); msg.setDescription(null); assertNull(msg.getDescription()); } public void testGetContentType() throws MessagingException { final MimeMessage msg = new MimeMessage(session); assertEquals(msg.getContentType(), "text/plain"); msg.setHeader("Content-Type", "text/xml"); assertEquals(msg.getContentType(), "text/xml"); } public void testSetText() throws MessagingException { MimeMessage msg = new MimeMessage(session); msg.setText("Yada, yada"); msg.saveChanges(); ContentType type = new ContentType(msg.getContentType()); assertTrue(type.match("text/plain")); msg = new MimeMessage(session); msg.setText("Yada, yada", "UTF-8"); msg.saveChanges(); type = new ContentType(msg.getContentType()); assertTrue(type.match("text/plain")); assertEquals(type.getParameter("charset"), "UTF-8"); msg = new MimeMessage(session); msg.setText("Yada, yada", "UTF-8", "xml"); msg.saveChanges(); type = new ContentType(msg.getContentType()); assertTrue(type.match("text/xml")); assertEquals(type.getParameter("charset"), "UTF-8"); } @Override protected void setUp() throws Exception { defaultMap = CommandMap.getDefaultCommandMap(); final MailcapCommandMap myMap = new MailcapCommandMap(); myMap.addMailcap("text/plain;; x-java-content-handler=" + MimeMultipartTest.DummyTextHandler.class.getName()); myMap.addMailcap("multipart/*;; x-java-content-handler=" + MimeMultipartTest.DummyMultipartHandler.class.getName()); CommandMap.setDefaultCommandMap(myMap); final Properties props = new Properties(); props.put("mail.user", "tester"); props.put("mail.host", "apache.org"); session = Session.getInstance(props); } @Override protected void tearDown() throws Exception { CommandMap.setDefaultCommandMap(defaultMap); } }
1,882
0
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail/internet/ContentTypeTest.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.mail.internet; import java.util.Arrays; import java.util.HashSet; import java.util.Set; import junit.framework.TestCase; /** * @version $Rev$ $Date$ */ public class ContentTypeTest extends TestCase { public ContentTypeTest(final String arg0) { super(arg0); } public void testContentType() throws ParseException { final ContentType type = new ContentType(); assertNull(type.getPrimaryType()); assertNull(type.getSubType()); assertNull(type.getParameter("charset")); } public void testContentTypeStringStringParameterList() throws ParseException { ContentType type; final ParameterList list = new ParameterList(";charset=us-ascii"); type = new ContentType("text", "plain", list); assertEquals("text", type.getPrimaryType()); assertEquals("plain", type.getSubType()); assertEquals("text/plain", type.getBaseType()); final ParameterList parameterList = type.getParameterList(); assertEquals("us-ascii", parameterList.get("charset")); assertEquals("us-ascii", type.getParameter("charset")); } public void testContentTypeString() throws ParseException { ContentType type; type = new ContentType("text/plain"); assertEquals("text", type.getPrimaryType()); assertEquals("plain", type.getSubType()); assertEquals("text/plain", type.getBaseType()); assertNotNull(type.getParameterList()); assertNull(type.getParameter("charset")); type = new ContentType("image/audio;charset=us-ascii"); final ParameterList parameterList = type.getParameterList(); assertEquals("image", type.getPrimaryType()); assertEquals("audio", type.getSubType()); assertEquals("image/audio", type.getBaseType()); assertEquals("us-ascii", parameterList.get("charset")); assertEquals("us-ascii", type.getParameter("charset")); } public void testGetPrimaryType() throws ParseException { } public void testGetSubType() throws ParseException { } public void testGetBaseType() throws ParseException { } public void testGetParameter() throws ParseException { } public void testGetParameterList() throws ParseException { } public void testSetPrimaryType() throws ParseException { final ContentType type = new ContentType("text/plain"); type.setPrimaryType("binary"); assertEquals("binary", type.getPrimaryType()); assertEquals("plain", type.getSubType()); assertEquals("binary/plain", type.getBaseType()); } public void testSetSubType() throws ParseException { final ContentType type = new ContentType("text/plain"); type.setSubType("html"); assertEquals("text", type.getPrimaryType()); assertEquals("html", type.getSubType()); assertEquals("text/html", type.getBaseType()); } public void testSetParameter() throws ParseException { } public void testSetParameterList() throws ParseException { } public void testToString() throws ParseException { final ContentType type = new ContentType("text/plain"); assertEquals("text/plain", type.toString()); type.setParameter("foo", "bar"); assertEquals("text/plain; foo=bar", type.toString()); type.setParameter("bar", "me@apache.org"); String[] tokens = type.toString().split(";"); assertEquals(3, tokens.length); Set<String> parameters = new HashSet<String>(); for (String s : tokens) { parameters.add(s.replaceAll("\\s+","")); } assertTrue(parameters.contains("text/plain")); assertTrue(parameters.contains("foo=bar")); assertTrue(parameters.contains("bar=\"me@apache.org\"")); } public void testMatchContentType() throws ParseException { final ContentType type = new ContentType("text/plain"); ContentType test = new ContentType("text/plain"); assertTrue(type.match(test)); test = new ContentType("TEXT/plain"); assertTrue(type.match(test)); assertTrue(test.match(type)); test = new ContentType("text/PLAIN"); assertTrue(type.match(test)); assertTrue(test.match(type)); test = new ContentType("text/*"); assertTrue(type.match(test)); assertTrue(test.match(type)); test = new ContentType("text/xml"); assertFalse(type.match(test)); assertFalse(test.match(type)); test = new ContentType("binary/plain"); assertFalse(type.match(test)); assertFalse(test.match(type)); test = new ContentType("*/plain"); assertFalse(type.match(test)); assertFalse(test.match(type)); } public void testMatchString() throws ParseException { final ContentType type = new ContentType("text/plain"); assertTrue(type.match("text/plain")); assertTrue(type.match("TEXT/plain")); assertTrue(type.match("text/PLAIN")); assertTrue(type.match("TEXT/PLAIN")); assertTrue(type.match("TEXT/*")); assertFalse(type.match("text/xml")); assertFalse(type.match("binary/plain")); assertFalse(type.match("*/plain")); assertFalse(type.match("")); assertFalse(type.match("text/plain/yada")); } public void testSOAP12ContentType() throws ParseException { final ContentType type = new ContentType("multipart/related; type=\"application/xop+xml\"; start=\"<rootpart@soapui.org>\"; start-info=\"application/soap+xml; action=\\\"urn:upload\\\"\"; boundary=\"----=_Part_10_5804917.1223557742343\""); assertEquals("multipart/related", type.getBaseType()); assertEquals("application/xop+xml", type.getParameter("type")); assertEquals("<rootpart@soapui.org>", type.getParameter("start")); assertEquals("application/soap+xml; action=\"urn:upload\"", type.getParameter("start-info")); assertEquals("----=_Part_10_5804917.1223557742343", type.getParameter("boundary")); } }
1,883
0
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail/internet/MimeMultipartTest.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.mail.internet; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.UnsupportedFlavorException; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.Properties; import javax.activation.CommandMap; import javax.activation.DataContentHandler; import javax.activation.DataHandler; import javax.activation.DataSource; import javax.activation.MailcapCommandMap; import javax.mail.BodyPart; import javax.mail.Message; import javax.mail.MessagingException; import javax.mail.Session; import junit.framework.TestCase; /** * @version $Rev$ $Date$ */ public class MimeMultipartTest extends TestCase { private CommandMap defaultMap; public void testWriteTo() throws MessagingException, IOException, Exception { writeToSetUp(); final MimeMultipart mp = new MimeMultipart(); final MimeBodyPart part1 = new MimeBodyPart(); part1.setHeader("foo", "bar"); part1.setContent("Hello World", "text/plain"); mp.addBodyPart(part1); final MimeBodyPart part2 = new MimeBodyPart(); part2.setContent("Hello Again", "text/plain"); mp.addBodyPart(part2); //mp.writeTo(System.out); writeToTearDown(); } public void testPreamble() throws MessagingException, IOException { final Properties props = new Properties(); final Session session = Session.getDefaultInstance(props); session.setDebug(true); final MimeMessage message = new MimeMessage(session); message.setFrom(new InternetAddress("rickmcg@gmail.com")); message.setRecipients(Message.RecipientType.TO, InternetAddress.parse("rick@us.ibm.com")); message.setSubject("test subject"); final BodyPart messageBodyPart1 = new MimeBodyPart(); messageBodyPart1.setHeader("Content-Type", "text/xml"); messageBodyPart1.setHeader("Content-Transfer-Encoding", "binary"); messageBodyPart1.setText("This is a test"); final MimeMultipart multipart = new MimeMultipart(); multipart.addBodyPart(messageBodyPart1); multipart.setPreamble("This is a preamble"); assertEquals("This is a preamble", multipart.getPreamble()); message.setContent(multipart); final ByteArrayOutputStream out = new ByteArrayOutputStream(); message.writeTo(out); //out.writeTo(System.out); final ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); final MimeMessage newMessage = new MimeMessage(session, in); assertEquals("This is a preamble\r\n", ((MimeMultipart)newMessage.getContent()).getPreamble()); } public void testMIMEWriting() throws IOException, MessagingException { final File basedir = new File(System.getProperty("basedir", ".")); final File testInput = new File(basedir, "src/test/resources/wmtom.bin"); final FileInputStream inStream = new FileInputStream(testInput); final Properties props = new Properties(); final javax.mail.Session session = javax.mail.Session .getInstance(props, null); final MimeMessage mimeMessage = new MimeMessage(session, inStream); final DataHandler dh = mimeMessage.getDataHandler(); final MimeMultipart multiPart = new MimeMultipart(dh.getDataSource()); final MimeBodyPart mimeBodyPart0 = (MimeBodyPart) multiPart.getBodyPart(0); final Object object0 = mimeBodyPart0.getContent(); assertNotNull(object0); final MimeBodyPart mimeBodyPart1 = (MimeBodyPart) multiPart.getBodyPart(1); final Object object1 = mimeBodyPart1.getContent(); assertNotNull(object1); assertEquals(multiPart.getCount(), 2); } public void testJavaMail15NewConstrucor() throws IOException, MessagingException { final File basedir = new File(System.getProperty("basedir", ".")); final File testInput = new File(basedir, "src/test/resources/wmtom.bin"); final BodyPart[] bps = new BodyPart[2]; bps[0] = new MimeBodyPart(new FileInputStream(testInput)); bps[1] = new MimeBodyPart(new FileInputStream(testInput)); final MimeMultipart multiPart = new MimeMultipart(bps); final MimeBodyPart mimeBodyPart0 = (MimeBodyPart) multiPart.getBodyPart(0); final Object object0 = mimeBodyPart0.getContent(); assertNotNull(object0); final MimeBodyPart mimeBodyPart1 = (MimeBodyPart) multiPart.getBodyPart(1); final Object object1 = mimeBodyPart1.getContent(); assertNotNull(object1); assertEquals(multiPart.getCount(), 2); assertTrue(multiPart.getContentType().startsWith("multipart/mixed")); } public void testJavaMail15NewConstrucor2() throws IOException, MessagingException { final File basedir = new File(System.getProperty("basedir", ".")); final File testInput = new File(basedir, "src/test/resources/wmtom.bin"); final BodyPart[] bps = new BodyPart[2]; bps[0] = new MimeBodyPart(new FileInputStream(testInput)); bps[1] = new MimeBodyPart(new FileInputStream(testInput)); final MimeMultipart multiPart = new MimeMultipart("alternative",bps); final MimeBodyPart mimeBodyPart0 = (MimeBodyPart) multiPart.getBodyPart(0); final Object object0 = mimeBodyPart0.getContent(); assertNotNull(object0); final MimeBodyPart mimeBodyPart1 = (MimeBodyPart) multiPart.getBodyPart(1); final Object object1 = mimeBodyPart1.getContent(); assertNotNull(object1); assertEquals(multiPart.getCount(), 2); assertTrue(multiPart.getContentType().startsWith("multipart/alternative")); } public void testJavaMail15CachedContent() throws IOException, MessagingException { final File basedir = new File(System.getProperty("basedir", ".")); final InputStream source = new FileInputStream(new File(basedir, "src/test/resources/multipart_msg_normal.eml")); final MimeMessage message = new MimeMessage(null, source); message.saveChanges(); assertEquals("Sample message", message.getSubject()); assertTrue(message.getContent() instanceof MimeMultipart); assertNotNull(message.cachedContent); final MimeMultipart mmp = (MimeMultipart) message.getContent(); assertTrue(message.cachedContent == mmp); final MimeBodyPart bp = (MimeBodyPart) mmp.getBodyPart(0); final String c = (String) bp.getContent(); assertNotNull(c); assertNull(bp.cachedContent); message.setDataHandler(new DataHandler("","text/plain")); assertNull(message.cachedContent); } public void testJavaMail15MultipartParsingNormal() throws IOException, MessagingException { try { setMultipartSystemPropsToDefault(); checkMultipartParsing("multipart_msg_normal.eml", 2); setMultipartSystemProps(false, false, true, true); checkMultipartParsing("multipart_msg_normal.eml", 2); } finally{ setMultipartSystemPropsToDefault(); } } public void testJavaMail15MultipartParsingEmpty() throws IOException, MessagingException { /* * When writing out such a MimeMultipart, a single empty part will be * included. When reading such a multipart, a MimeMultipart will be created * with no body parts. */ try { setMultipartSystemPropsToDefault(); checkMultipartParsing("multipart_msg_empty.eml",-1); //-1 indicates expected exception MimeMultipart mmp0 = new MimeMultipart(); ByteArrayOutputStream out = new ByteArrayOutputStream(); try { mmp0.writeTo(out); fail("MessagingException excpected"); } catch (final MessagingException e) { //expected } setMultipartSystemProps(false, false, true, true); mmp0 = new MimeMultipart(); out = new ByteArrayOutputStream(); mmp0.writeTo(out); assertTrue(out.toString().startsWith("--")); final MimeMultipart mmp = checkMultipartParsing("multipart_msg_empty.eml",0); out = new ByteArrayOutputStream(); mmp.writeTo(out); assertTrue(out.toString().startsWith("--simple")); } finally{ setMultipartSystemPropsToDefault(); } } public void testJavaMail1MultipartParsingMissingBoundaryParameter() throws IOException, MessagingException { try { setMultipartSystemPropsToDefault(); checkMultipartParsing("multipart_msg_missing_boundary_param.eml",2); setMultipartSystemProps(false, false, false, true); checkMultipartParsing("multipart_msg_missing_boundary_param.eml",-1); } finally{ setMultipartSystemPropsToDefault(); } } public void testJavaMail1MultipartParsingMissingEndBoundary() throws IOException, MessagingException { try { setMultipartSystemPropsToDefault(); setMultipartSystemProps(true, false, false, false); checkMultipartParsing("multipart_msg_missing_end_boundary.eml",1); setMultipartSystemProps(false, false, false, false); checkMultipartParsing("multipart_msg_missing_end_boundary.eml",-1); } finally{ setMultipartSystemPropsToDefault(); } } public void testJavaMail15MultipartParsingWrongBoundary() throws IOException, MessagingException { try { setMultipartSystemPropsToDefault(); checkMultipartParsing("multipart_msg_wrong_boundary_param.eml",-1); setMultipartSystemProps(false, false, true, true); checkMultipartParsing("multipart_msg_wrong_boundary_param.eml",2); } finally{ setMultipartSystemPropsToDefault(); } } protected void setMultipartSystemPropsToDefault() { setMultipartSystemProps(true, true, false, false); } protected void setMultipartSystemProps(final boolean ignoremissingendboundary, final boolean ignoremissingboundaryparameter, final boolean ignoreexistingboundaryparameter, final boolean allowempty) { System.setProperty("mail.mime.multipart.ignoremissingendboundary", String.valueOf(ignoremissingendboundary)); System.setProperty("mail.mime.multipart.ignoremissingboundaryparameter", String.valueOf(ignoremissingboundaryparameter)); System.setProperty("mail.mime.multipart.ignoreexistingboundaryparameter", String.valueOf(ignoreexistingboundaryparameter)); System.setProperty("mail.mime.multipart.allowempty", String.valueOf(allowempty)); } protected MimeMultipart checkMultipartParsing(final String filename, final int count) throws IOException, MessagingException { final File basedir = new File(System.getProperty("basedir", ".")); final InputStream source = new FileInputStream(new File(basedir, "src/test/resources/"+filename)); final MimeMessage message = new MimeMessage(null, source); try { //message.saveChanges(); assertTrue(message.getContent() instanceof MimeMultipart); final MimeMultipart mmp = (MimeMultipart) message.getContent(); assertEquals(count, mmp.getCount()); return mmp; } catch (final MessagingException e) { if(count > -1) { fail(e.toString()); } } return null; } protected void writeToSetUp() throws Exception { defaultMap = CommandMap.getDefaultCommandMap(); final MailcapCommandMap myMap = new MailcapCommandMap(); myMap.addMailcap("text/plain;; x-java-content-handler=" + DummyTextHandler.class.getName()); myMap.addMailcap("multipart/*;; x-java-content-handler=" + DummyMultipartHandler.class.getName()); CommandMap.setDefaultCommandMap(myMap); } protected void writeToTearDown() throws Exception { CommandMap.setDefaultCommandMap(defaultMap); } public static class DummyTextHandler implements DataContentHandler { public DataFlavor[] getTransferDataFlavors() { return new DataFlavor[0]; //To change body of implemented methods use File | Settings | File Templates. } public Object getTransferData(final DataFlavor df, final DataSource ds) throws UnsupportedFlavorException, IOException { return null; //To change body of implemented methods use File | Settings | File Templates. } public Object getContent(final DataSource ds) throws IOException { return null; //To change body of implemented methods use File | Settings | File Templates. } public void writeTo(final Object obj, final String mimeType, final OutputStream os) throws IOException { os.write(((String)obj).getBytes("ISO8859-1")); } } public static class DummyMultipartHandler implements DataContentHandler { public DataFlavor[] getTransferDataFlavors() { throw new UnsupportedOperationException(); } public Object getTransferData(final DataFlavor df, final DataSource ds) throws UnsupportedFlavorException, IOException { throw new UnsupportedOperationException(); } public Object getContent(final DataSource ds) throws IOException { throw new UnsupportedOperationException(); } public void writeTo(final Object obj, final String mimeType, final OutputStream os) throws IOException { final MimeMultipart mp = (MimeMultipart) obj; try { mp.writeTo(os); } catch (final MessagingException e) { throw (IOException) new IOException(e.getMessage()).initCause(e); } } } }
1,884
0
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail/internet/ParameterListTest.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.mail.internet; import junit.framework.TestCase; /** * @version $Rev$ $Date$ */ public class ParameterListTest extends TestCase { public ParameterListTest(final String arg0) { super(arg0); } public void testParameters() throws ParseException { final ParameterList list = new ParameterList(";thing=value;thong=vulue;thung=git"); assertEquals("value", list.get("thing")); assertEquals("vulue", list.get("thong")); assertEquals("git", list.get("thung")); } public void testQuotedParameter() throws ParseException { final ParameterList list = new ParameterList(";foo=one;bar=\"two\""); assertEquals("one", list.get("foo")); assertEquals("two", list.get("bar")); } public void testQuotedParameterSet() throws ParseException { final ParameterList list = new ParameterList(); list.set("foo", "one"); list.set("bar", "\"two\""); assertEquals("one", list.get("foo")); assertEquals("\"two\"", list.get("bar")); } public void testMultisegmentParameter() throws ParseException { final ParameterList list = new ParameterList(";foo*0=one;foo*1=\"two\""); assertEquals("onetwo", list.get("foo")); } public void testMultisegmentParameterSet() throws ParseException { final ParameterList list = new ParameterList(); list.set("foo*0", "one"); list.set("foo*1", "\"two\""); list.combineSegments(); assertEquals("one\"two\"", list.get("foo")); } public void testMultisegmentParameterMoreSet() throws ParseException { final ParameterList list = new ParameterList(); list.set("foo*0", "one"); list.set("foo*1", "two"); list.set("foo*2", "three"); list.set("bar", "four"); list.set("test2*0", "seven"); list.set("test*1", "six"); list.set("test*0", "five"); list.combineSegments(); assertEquals("onetwothree", list.get("foo")); assertEquals("four", list.get("bar")); assertEquals("fivesix", list.get("test")); assertEquals("seven", list.get("test2")); } public void testMultisegmentParameterMore() throws ParseException { final ParameterList list = new ParameterList(";foo*0=one;foo*1=two;foo*2=three;bar=four;test2*0=seven;test*1=six;test*0=five"); assertEquals("onetwothree", list.get("foo")); assertEquals("four", list.get("bar")); assertEquals("fivesix", list.get("test")); assertEquals("seven", list.get("test2")); } public void testMultisegmentParameterEncodedMore() throws ParseException { final String value = " '*% abc \u0081\u0082\r\n\t"; final String encodedTest = "UTF-8''%20%27%2A%25%20abc%20%C2%81%C2%82%0D%0A%09"; final ParameterList list = new ParameterList(";foo*0=one;foo*1=two;foo*2*="+encodedTest+";bar=four;test2*0=seven;test*1=six;test*0=five"); assertEquals("onetwo"+value, list.get("foo")); assertEquals("four", list.get("bar")); assertEquals("fivesix", list.get("test")); assertEquals("seven", list.get("test2")); } public void testMultisegmentParameterEncodedMoreFail() throws ParseException { //final String value = " '*% abc \u0081\u0082\r\n\t"; final String encodedTest = "UTF-8''%20%27%2A%25%20abc%20%C2%81%C2%82%0D%0A%09"; final ParameterList list = new ParameterList(";foo*0=one;foo*1=two;foo*2="+encodedTest+";bar=four;test2*0=seven;test*1=six;test*0=five"); assertEquals("onetwo"+encodedTest, list.get("foo")); assertEquals("four", list.get("bar")); assertEquals("fivesix", list.get("test")); assertEquals("seven", list.get("test2")); } public void testMultisegmentParameterMoreMixedEncodedSet() throws ParseException { final String value = " '*% abc \u0081\u0082\r\n\t"; final String encodedTest = "UTF-8''%20%27%2A%25%20abc%20%C2%81%C2%82%0D%0A%09"; final ParameterList list = new ParameterList(); list.set("foo*0", "one"); list.set("foo*1", "two"); list.set("foo*2*", encodedTest, "UTF-8"); list.set("bar", "four"); list.set("test2*0", "seven"); list.set("test*1", "six"); list.set("test*0", "five"); list.set("test3*", encodedTest, "UTF-8"); list.combineSegments(); assertEquals("onetwo"+value, list.get("foo")); assertEquals("four", list.get("bar")); assertEquals("fivesix", list.get("test")); assertEquals("seven", list.get("test2")); //assertEquals(value, list.get("test3")); } public void emptyParameter() throws ParseException { final ParameterList list = new ParameterList(""); assertEquals(0, list.size()); } public void testEncodeDecode() throws Exception { //since JavaMail 1.5 encodeparameters/decodeparameters are enabled by default //System.setProperty("mail.mime.encodeparameters", "true"); //System.setProperty("mail.mime.decodeparameters", "true"); final String value = " '*% abc \u0081\u0082\r\n\t"; final String encodedTest = "; one*=UTF-8''%20%27%2A%25%20abc%20%C2%81%C2%82%0D%0A%09"; final ParameterList list = new ParameterList(); list.set("one", value, "UTF-8"); assertEquals(value, list.get("one")); final String encoded = list.toString(); assertEquals(encoded, encodedTest); final ParameterList list2 = new ParameterList(encoded); assertEquals(value, list.get("one")); assertEquals(list2.toString(), encodedTest); } }
1,885
0
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail/internet/MimeTest.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.mail.internet; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.Properties; import javax.activation.DataHandler; import javax.activation.DataSource; import javax.mail.Session; import junit.framework.TestCase; import org.apache.geronimo.mail.util.Base64; public class MimeTest extends TestCase { public void testWriteRead() throws Exception { System.setProperty("mail.mime.decodefilename", "true"); final Session session = Session.getDefaultInstance(new Properties(), null); final MimeMessage mime = new MimeMessage(session); final MimeMultipart parts = new MimeMultipart("related; type=\"text/xml\"; start=\"<xml>\""); final MimeBodyPart xmlPart = new MimeBodyPart(); xmlPart.setContentID("<xml>"); xmlPart.setDataHandler(new DataHandler(new ByteArrayDataSource("<hello/>".getBytes(), "text/xml"))); parts.addBodyPart(xmlPart); final MimeBodyPart jpegPart = new MimeBodyPart(); jpegPart.setContentID("<jpeg>"); final String filename = "filename"; final String encodedFilename = "=?UTF-8?B?" + new String(Base64.encode(filename.getBytes()), "ISO8859-1") + "?="; jpegPart.setFileName(encodedFilename); jpegPart.setDataHandler(new DataHandler(new ByteArrayDataSource(new byte[] { 0, 1, 2, 3, 4, 5 }, "image/jpeg"))); parts.addBodyPart(jpegPart); mime.setContent(parts); mime.setHeader("Content-Type", parts.getContentType()); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); mime.writeTo(baos); final MimeMessage mime2 = new MimeMessage(session, new ByteArrayInputStream(baos.toByteArray())); assertTrue(mime2.getContent() instanceof MimeMultipart); final MimeMultipart parts2 = (MimeMultipart) mime2.getContent(); assertEquals(mime.getContentType(), mime2.getContentType()); assertEquals(parts.getCount(), parts2.getCount()); assertTrue(parts2.getBodyPart(0) instanceof MimeBodyPart); assertTrue(parts2.getBodyPart(1) instanceof MimeBodyPart); final MimeBodyPart xmlPart2 = (MimeBodyPart) parts2.getBodyPart(0); assertEquals(xmlPart.getContentID(), xmlPart2.getContentID()); final ByteArrayOutputStream xmlBaos = new ByteArrayOutputStream(); copyInputStream(xmlPart.getDataHandler().getInputStream(), xmlBaos); final ByteArrayOutputStream xmlBaos2 = new ByteArrayOutputStream(); copyInputStream(xmlPart2.getDataHandler().getInputStream(), xmlBaos2); assertEquals(xmlBaos.toString(), xmlBaos2.toString()); final MimeBodyPart jpegPart2 = (MimeBodyPart) parts2.getBodyPart(1); assertEquals(jpegPart.getContentID(), jpegPart2.getContentID()); assertEquals(jpegPart.getFileName(), jpegPart2.getDataHandler().getName()); assertEquals(filename, jpegPart2.getDataHandler().getName()); final ByteArrayOutputStream jpegBaos = new ByteArrayOutputStream(); copyInputStream(jpegPart.getDataHandler().getInputStream(), jpegBaos); final ByteArrayOutputStream jpegBaos2 = new ByteArrayOutputStream(); copyInputStream(jpegPart2.getDataHandler().getInputStream(), jpegBaos2); assertEquals(jpegBaos.toString(), jpegBaos2.toString()); } public static class ByteArrayDataSource implements DataSource { private final byte[] data; private final String type; private String name = "unused"; public ByteArrayDataSource(final byte[] data, final String type) { this.data = data; this.type = type; } public InputStream getInputStream() throws IOException { if (data == null) { throw new IOException("no data"); } return new ByteArrayInputStream(data); } public OutputStream getOutputStream() throws IOException { throw new IOException("getOutputStream() not supported"); } public String getContentType() { return type; } public String getName() { return name; } public void setName(final String name) { this.name = name; } } public static void copyInputStream(final InputStream in, final OutputStream out) throws IOException { final byte[] buffer = new byte[1024]; int len; while ((len = in.read(buffer)) >= 0) { out.write(buffer, 0, len); } in.close(); out.close(); } }
1,886
0
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail/internet/ContentDispositionTest.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.mail.internet; import junit.framework.TestCase; /** * @version $Rev$ $Date$ */ public class ContentDispositionTest extends TestCase { public ContentDispositionTest(final String name) { super(name); } public void testContentDisposition() throws ParseException { ContentDisposition c; c = new ContentDisposition(); assertNotNull(c.getParameterList()); assertNull(c.getParameterList().get("nothing")); assertNull(c.getDisposition()); assertEquals("", c.toString()); c.setDisposition("inline"); assertEquals("inline",c.getDisposition()); c.setParameter("file","file.txt"); assertEquals("file.txt",c.getParameterList().get("file")); assertEquals("inline; file=file.txt",c.toString()); c = new ContentDisposition("inline"); assertNotNull(c.getParameterList()); assertEquals(0,c.getParameterList().size()); assertEquals("inline",c.getDisposition()); c = new ContentDisposition("inline",new ParameterList(";charset=us-ascii;content-type=\"text/plain\"")); assertEquals("inline",c.getDisposition()); assertEquals("us-ascii",c.getParameter("charset")); assertEquals("text/plain",c.getParameter("content-type")); c = new ContentDisposition("attachment;content-type=\"text/html\";charset=UTF-8"); assertEquals("attachment",c.getDisposition()); assertEquals("UTF-8",c.getParameter("charset")); assertEquals("text/html",c.getParameter("content-type")); } }
1,887
0
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail/internet/HeaderTokenizerTest.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.mail.internet; import javax.mail.internet.HeaderTokenizer.Token; import junit.framework.TestCase; /** * @version $Rev$ $Date$ */ public class HeaderTokenizerTest extends TestCase { public void testTokenizer() throws ParseException { HeaderTokenizer ht = new HeaderTokenizer("To: \"Geronimo List\" <geronimo-dev@apache.org>, \n\r Geronimo User <geronimo-user@apache.org>"); validateToken(ht.peek(), Token.ATOM, "To"); validateToken(ht.next(), Token.ATOM, "To"); validateToken(ht.peek(), ':', ":"); validateToken(ht.next(), ':', ":"); validateToken(ht.next(), Token.QUOTEDSTRING, "Geronimo List"); validateToken(ht.next(), '<', "<"); validateToken(ht.next(), Token.ATOM, "geronimo-dev"); validateToken(ht.next(), '@', "@"); validateToken(ht.next(), Token.ATOM, "apache"); validateToken(ht.next(), '.', "."); validateToken(ht.next(), Token.ATOM, "org"); validateToken(ht.next(), '>', ">"); validateToken(ht.next(), ',', ","); validateToken(ht.next(), Token.ATOM, "Geronimo"); validateToken(ht.next(), Token.ATOM, "User"); validateToken(ht.next(), '<', "<"); validateToken(ht.next(), Token.ATOM, "geronimo-user"); validateToken(ht.next(), '@', "@"); validateToken(ht.next(), Token.ATOM, "apache"); validateToken(ht.next(), '.', "."); assertEquals("org>", ht.getRemainder()); validateToken(ht.peek(), Token.ATOM, "org"); validateToken(ht.next(), Token.ATOM, "org"); validateToken(ht.next(), '>', ">"); assertEquals(Token.EOF, ht.next().getType()); ht = new HeaderTokenizer(" "); assertEquals(Token.EOF, ht.next().getType()); ht = new HeaderTokenizer("J2EE"); validateToken(ht.next(), Token.ATOM, "J2EE"); assertEquals(Token.EOF, ht.next().getType()); // test comments doComment(true); doComment(false); } public void testErrors() throws ParseException { checkParseError("(Geronimo"); checkParseError("((Geronimo)"); checkParseError("\"Geronimo"); checkParseError("\"Geronimo\\"); } public void testQuotedLiteral() throws ParseException { checkTokenParse("\"\"", Token.QUOTEDSTRING, ""); checkTokenParse("\"\\\"\"", Token.QUOTEDSTRING, "\""); checkTokenParse("\"\\\"\"", Token.QUOTEDSTRING, "\""); checkTokenParse("\"A\r\nB\"", Token.QUOTEDSTRING, "AB"); checkTokenParse("\"A\nB\"", Token.QUOTEDSTRING, "A\nB"); } public void testComment() throws ParseException { checkTokenParse("()", Token.COMMENT, ""); checkTokenParse("(())", Token.COMMENT, "()"); checkTokenParse("(Foo () Bar)", Token.COMMENT, "Foo () Bar"); checkTokenParse("(\"Foo () Bar)", Token.COMMENT, "\"Foo () Bar"); checkTokenParse("(\\()", Token.COMMENT, "("); checkTokenParse("(Foo \r\n Bar)", Token.COMMENT, "Foo Bar"); checkTokenParse("(Foo \n Bar)", Token.COMMENT, "Foo \n Bar"); } public void testJavaMail15NextMethod() throws ParseException{ HeaderTokenizer ht = new HeaderTokenizer("To: \"Geronimo List\\\" <geronimo-dev@apache.org>, \n\r Geronimo User <geronimo-user@apache.org>"); validateToken(ht.next('>', false), Token.QUOTEDSTRING, "To: \"Geronimo List\" <geronimo-dev@apache.org"); } public void testJavaMail15NextMethodEscapes() throws ParseException{ HeaderTokenizer ht = new HeaderTokenizer("To: \"Geronimo List\\\" <geronimo-dev@apache.org>, \n\r Geronimo User <geronimo-user@apache.org>"); validateToken(ht.next('<', true), Token.QUOTEDSTRING, "To: \"Geronimo List\\\" "); } public void testJavaMail15NextMethodEscapes2() throws ParseException{ HeaderTokenizer ht = new HeaderTokenizer("To: \"Geronimo List\" <geronimo-dev@apac\\he.org>, \n\r Geronimo User <geronimo-user@apache.org>"); ht.next(); ht.next(); ht.next(); validateToken(ht.next(',', false), Token.QUOTEDSTRING, "<geronimo-dev@apache.org>"); } public void testJavaMail15NextMethodEscapes3() throws ParseException{ HeaderTokenizer ht = new HeaderTokenizer("To: \"Geronimo List\" <geronimo-dev@apac\\he.org>, \n\r Geronimo User <geronimo-user@apache.org>"); ht.next(); ht.next(); ht.next(); validateToken(ht.next(',', true), Token.QUOTEDSTRING, "<geronimo-dev@apac\\he.org>"); } public void checkTokenParse(final String text, final int type, final String value) throws ParseException { HeaderTokenizer ht = new HeaderTokenizer(text, HeaderTokenizer.RFC822, false); validateToken(ht.next(), type, value); } public void checkParseError(final String text) throws ParseException { HeaderTokenizer ht = new HeaderTokenizer(text); doNextError(ht); ht = new HeaderTokenizer(text); doPeekError(ht); } public void doNextError(final HeaderTokenizer ht) { try { ht.next(); fail("Expected ParseException"); } catch (final ParseException e) { } } public void doPeekError(final HeaderTokenizer ht) { try { ht.peek(); fail("Expected ParseException"); } catch (final ParseException e) { } } public void doComment(final boolean ignore) throws ParseException { HeaderTokenizer ht; ht = new HeaderTokenizer( "Apache(Geronimo)J2EE", HeaderTokenizer.RFC822, ignore); validateToken(ht.next(), Token.ATOM, "Apache"); if (!ignore) { validateToken(ht.next(), Token.COMMENT, "Geronimo"); } validateToken(ht.next(), Token.ATOM, "J2EE"); assertEquals(Token.EOF, ht.next().getType()); ht = new HeaderTokenizer( "Apache(Geronimo (Project))J2EE", HeaderTokenizer.RFC822, ignore); validateToken(ht.next(), Token.ATOM, "Apache"); if (!ignore) { validateToken(ht.next(), Token.COMMENT, "Geronimo (Project)"); } validateToken(ht.next(), Token.ATOM, "J2EE"); assertEquals(Token.EOF, ht.next().getType()); } private void validateToken(final HeaderTokenizer.Token token, final int type, final String value) { assertEquals(type, token.getType()); assertEquals(value, token.getValue()); } private transient TestCase[] testCases = { new TestCase(';', "a=b c", "b c"), new TestCase(';', "a=b c; d=e f", "b c"), new TestCase(';', "a=\"b c\"; d=e f", "b c") }; private transient TestCase[] testCasesEsc = { new TestCase(';', "a=b \\c", "b \\c"), new TestCase(';', "a=b c; d=e f", "b c"), new TestCase(';', "a=\"b \\c\"; d=e f", "b \\c") }; public void testNext() throws Exception { final String value = "ggere, /tmp/mail.out, +mailbox, ~user/mailbox, ~/mailbox, /PN=x400.address/PRMD=ibmmail/ADMD=ibmx400/C=us/@mhs-mci.ebay, " + "C'est bien moche <paris@france>, Mad Genius <george@boole>, two@weeks (It Will Take), /tmp/mail.out, laborious (But Bug Free), " + "cannot@waste (My, Intellectual, Cycles), users:get,what,they,deserve;, it (takes, no (time, at) all), " + "if@you (could, see (almost, as, (badly, you) would) agree), famous <French@physicists>, " + "it@is (brilliant (genius, and) superb), confused (about, being, french)"; // Create HeaderTokenizer object HeaderTokenizer ht = new HeaderTokenizer(value, HeaderTokenizer.RFC822, true); HeaderTokenizer.Token token; while ((token = ht.next()).getType() != HeaderTokenizer.Token.EOF) { // API if (token.getType() == 0 || token.getValue() == null) { fail(type(token.getType()) + "\t" + token.getValue()); } } } public void testNext2() throws Exception { // Create HeaderTokenizer object HeaderTokenizer ht; HeaderTokenizer.Token token; for (TestCase tc : testCases) { ht = new HeaderTokenizer(tc.test, HeaderTokenizer.MIME, true); token = ht.next(); if (token.getType() != HeaderTokenizer.Token.ATOM || !token.getValue().equals("a")) { System.out.println("\t" + type(token.getType()) + "\t" + token.getValue()); fail(); } else { token = ht.next(); if (token.getType() != '=') { System.out.println("\t" + type(token.getType()) + "\t" + token.getValue()); fail(); } else { token = ht.next(tc.endOfAtom); if (token.getType() != HeaderTokenizer.Token.QUOTEDSTRING || !token.getValue().equals(tc.expected)) { fail(type(token.getType()) + "\t" + token.getValue()); } } } } } public void testNext3() throws Exception { // Create HeaderTokenizer object HeaderTokenizer ht; HeaderTokenizer.Token token; for (TestCase tc : testCasesEsc) { ht = new HeaderTokenizer(tc.test, HeaderTokenizer.MIME, true); token = ht.next(); if (token.getType() != HeaderTokenizer.Token.ATOM || !token.getValue().equals("a")) { System.out.println("\t" + type(token.getType()) + "\t" + token.getValue()); fail(); } else { token = ht.next(); if (token.getType() != '=') { System.out.println("\t" + type(token.getType()) + "\t" + token.getValue()); fail(); } else { token = ht.next(tc.endOfAtom, true); if (token.getType() != HeaderTokenizer.Token.QUOTEDSTRING || !token.getValue().equals(tc.expected)) { fail(type(token.getType()) + "\t" + token.getValue()); } } } } } private static String type(int t) { if (t == HeaderTokenizer.Token.ATOM) return "ATOM"; else if (t == HeaderTokenizer.Token.QUOTEDSTRING) return "QUOTEDSTRING"; else if (t == HeaderTokenizer.Token.COMMENT) return "COMMENT"; else if (t == HeaderTokenizer.Token.EOF) return "EOF"; else if (t < 0) return "UNKNOWN"; else return "SPECIAL"; } static class TestCase { public TestCase(final char endOfAtom, final String test, String expected) { this.endOfAtom = endOfAtom; this.test = test; this.expected = expected; } public char endOfAtom; public String test; public String expected; }; }
1,888
0
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail/internet/AllInternetTests.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.mail.internet; import junit.framework.Test; import junit.framework.TestSuite; /** * @version $Rev$ $Date$ */ public class AllInternetTests { public static Test suite() { final TestSuite suite = new TestSuite("Test for javax.mail.internet"); //$JUnit-BEGIN$ suite.addTest(new TestSuite(ContentTypeTest.class)); suite.addTest(new TestSuite(ParameterListTest.class)); suite.addTest(new TestSuite(InternetAddressTest.class)); //$JUnit-END$ return suite; } }
1,889
0
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail/internet/MailDateFormatTest.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.mail.internet; import java.text.ParseException; import java.util.Calendar; import java.util.Date; import java.util.Locale; import java.util.SimpleTimeZone; import junit.framework.TestCase; /** * @version $Rev$ $Date$ */ public class MailDateFormatTest extends TestCase { public void testMailDateFormat() throws ParseException { final MailDateFormat mdf = new MailDateFormat(); Date date = mdf.parse("Wed, 27 Aug 2003 13:43:38 +0100 (BST)"); // don't we just love the Date class? Calendar cal = Calendar.getInstance(new SimpleTimeZone(+1 * 60 * 60 * 1000, "BST"), Locale.getDefault()); cal.setTime(date); assertEquals(2003, cal.get(Calendar.YEAR)); assertEquals(Calendar.AUGUST, cal.get(Calendar.MONTH)); assertEquals(27, cal.get(Calendar.DAY_OF_MONTH)); assertEquals(Calendar.WEDNESDAY, cal.get(Calendar.DAY_OF_WEEK)); assertEquals(13, cal.get(Calendar.HOUR_OF_DAY)); assertEquals(43, cal.get(Calendar.MINUTE)); assertEquals(38, cal.get(Calendar.SECOND)); date = mdf.parse("Wed, 27-Aug-2003 13:43:38 +0100"); // don't we just love the Date class? cal = Calendar.getInstance(new SimpleTimeZone(+1 * 60 * 60 * 1000, "BST"), Locale.getDefault()); cal.setTime(date); assertEquals(2003, cal.get(Calendar.YEAR)); assertEquals(Calendar.AUGUST, cal.get(Calendar.MONTH)); assertEquals(27, cal.get(Calendar.DAY_OF_MONTH)); assertEquals(Calendar.WEDNESDAY, cal.get(Calendar.DAY_OF_WEEK)); assertEquals(13, cal.get(Calendar.HOUR_OF_DAY)); assertEquals(43, cal.get(Calendar.MINUTE)); assertEquals(38, cal.get(Calendar.SECOND)); date = mdf.parse("27-Aug-2003 13:43:38 EST"); // don't we just love the Date class? cal = Calendar.getInstance(new SimpleTimeZone(-5 * 60 * 60 * 1000, "EST"), Locale.getDefault()); cal.setTime(date); assertEquals(2003, cal.get(Calendar.YEAR)); assertEquals(Calendar.AUGUST, cal.get(Calendar.MONTH)); assertEquals(27, cal.get(Calendar.DAY_OF_MONTH)); assertEquals(Calendar.WEDNESDAY, cal.get(Calendar.DAY_OF_WEEK)); assertEquals(13, cal.get(Calendar.HOUR_OF_DAY)); assertEquals(43, cal.get(Calendar.MINUTE)); assertEquals(38, cal.get(Calendar.SECOND)); date = mdf.parse("27 Aug 2003 13:43 EST"); // don't we just love the Date class? cal = Calendar.getInstance(new SimpleTimeZone(-5 * 60 * 60 * 1000, "EST"), Locale.getDefault()); cal.setTime(date); assertEquals(2003, cal.get(Calendar.YEAR)); assertEquals(Calendar.AUGUST, cal.get(Calendar.MONTH)); assertEquals(27, cal.get(Calendar.DAY_OF_MONTH)); assertEquals(Calendar.WEDNESDAY, cal.get(Calendar.DAY_OF_WEEK)); assertEquals(13, cal.get(Calendar.HOUR_OF_DAY)); assertEquals(43, cal.get(Calendar.MINUTE)); assertEquals(00, cal.get(Calendar.SECOND)); date = mdf.parse("27 Aug 03 13:43 EST"); // don't we just love the Date class? cal = Calendar.getInstance(new SimpleTimeZone(-5 * 60 * 60 * 1000, "EST"), Locale.getDefault()); cal.setTime(date); assertEquals(2003, cal.get(Calendar.YEAR)); assertEquals(Calendar.AUGUST, cal.get(Calendar.MONTH)); assertEquals(27, cal.get(Calendar.DAY_OF_MONTH)); assertEquals(Calendar.WEDNESDAY, cal.get(Calendar.DAY_OF_WEEK)); assertEquals(13, cal.get(Calendar.HOUR_OF_DAY)); assertEquals(43, cal.get(Calendar.MINUTE)); assertEquals(00, cal.get(Calendar.SECOND)); } }
1,890
0
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail/internet/MimeBodyPartTest.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.mail.internet; import junit.framework.TestCase; import javax.activation.DataHandler; import javax.mail.EncodingAware; import javax.mail.MessagingException; import javax.mail.Part; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.UnsupportedEncodingException; /** * @version $Rev$ $Date$ */ public class MimeBodyPartTest extends TestCase { File basedir = new File(System.getProperty("basedir", ".")); File testInput = new File(basedir, "src/test/resources/test.dat"); public void testGetSize() throws MessagingException { MimeBodyPart part = new MimeBodyPart(); assertEquals(part.getSize(), -1); part = new MimeBodyPart(new InternetHeaders(), new byte[] {'a', 'b', 'c'}); assertEquals(part.getSize(), 3); } public void testGetLineCount() throws MessagingException { MimeBodyPart part = new MimeBodyPart(); assertEquals(part.getLineCount(), -1); part = new MimeBodyPart(new InternetHeaders(), new byte[] {'a', 'b', 'c'}); assertEquals(part.getLineCount(), -1); } public void testGetContentType() throws MessagingException { MimeBodyPart part = new MimeBodyPart(); assertEquals(part.getContentType(), "text/plain"); part.setHeader("Content-Type", "text/xml"); assertEquals(part.getContentType(), "text/xml"); part = new MimeBodyPart(); part.setText("abc"); assertEquals(part.getContentType(), "text/plain"); } public void testIsMimeType() throws MessagingException { final MimeBodyPart part = new MimeBodyPart(); assertTrue(part.isMimeType("text/plain")); assertTrue(part.isMimeType("text/*")); part.setHeader("Content-Type", "text/xml"); assertTrue(part.isMimeType("text/xml")); assertTrue(part.isMimeType("text/*")); } public void testGetDisposition() throws MessagingException { final MimeBodyPart part = new MimeBodyPart(); assertNull(part.getDisposition()); part.setDisposition("inline"); assertEquals(part.getDisposition(), "inline"); } public void testJavaMail15AttachmentDisposition() throws MessagingException, IOException { final MimeBodyPart part = new MimeBodyPart(); assertNull(part.getDisposition()); final File testInput = new File(basedir, "src/test/resources/test.dat"); part.attachFile(testInput); assertEquals(Part.ATTACHMENT, part.getDisposition()); } public void testJavaMail15EncodingAware() throws MessagingException, IOException { final File testInput = new File(basedir, "src/test/resources/test.dat"); final MimeBodyPart part = new MimeBodyPart(); part.attachFile(testInput, "application/octet-stream", "7bit"); // depending on the OS encoding can change part.updateHeaders(); assertTrue(part.getDataHandler().getContentType().equals("application/octet-stream")); assertEquals("7bit", part.getEncoding()); final MimeBodyPart part2 = new MimeBodyPart(); part2.attachFile(testInput,"application/pdf","base64"); part2.updateHeaders(); assertTrue(part2.getDataHandler().getContentType().equals("application/pdf")); assertEquals("base64", part2.getEncoding()); } public void testSetDescription() throws MessagingException, UnsupportedEncodingException { final MimeBodyPart part = new MimeBodyPart(); final String simpleSubject = "Yada, yada"; final String complexSubject = "Yada, yada\u0081"; final String mungedSubject = "Yada, yada\u003F"; part.setDescription(simpleSubject); assertEquals(part.getDescription(), simpleSubject); part.setDescription(complexSubject, "UTF-8"); assertEquals(part.getDescription(), complexSubject); assertEquals(part.getHeader("Content-Description", null), MimeUtility.encodeText(complexSubject, "UTF-8", null)); part.setDescription(null); assertNull(part.getDescription()); } public void testSetFileName() throws Exception { final MimeBodyPart part = new MimeBodyPart(); part.setFileName("test.dat"); assertEquals("test.dat", part.getFileName()); final ContentDisposition disp = new ContentDisposition(part.getHeader("Content-Disposition", null)); assertEquals("test.dat", disp.getParameter("filename")); final ContentType type = new ContentType(part.getHeader("Content-Type", null)); assertEquals("test.dat", type.getParameter("name")); final MimeBodyPart part2 = new MimeBodyPart(); part2.setHeader("Content-Type", type.toString()); assertEquals("test.dat", part2.getFileName()); part2.setHeader("Content-Type", null); part2.setHeader("Content-Disposition", disp.toString()); assertEquals("test.dat", part2.getFileName()); } public void testAttachments() throws Exception { MimeBodyPart part = new MimeBodyPart(); final byte[] testData = getFileData(testInput); part.attachFile(testInput); assertEquals(part.getFileName(), testInput.getName()); part.updateHeaders(); File temp1 = File.createTempFile("MIME", ".dat"); temp1.deleteOnExit(); part.saveFile(temp1); byte[] tempData = getFileData(temp1); compareFileData(testData, tempData); ByteArrayOutputStream out = new ByteArrayOutputStream(); part.writeTo(out); ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); MimeBodyPart part2 = new MimeBodyPart(in); temp1 = File.createTempFile("MIME", ".dat"); temp1.deleteOnExit(); part2.saveFile(temp1); tempData = getFileData(temp1); compareFileData(testData, tempData); part = new MimeBodyPart(); part.attachFile(testInput.getPath()); assertEquals(part.getFileName(), testInput.getName()); part.updateHeaders(); temp1 = File.createTempFile("MIME", ".dat"); temp1.deleteOnExit(); part.saveFile(temp1.getPath()); tempData = getFileData(temp1); compareFileData(testData, tempData); out = new ByteArrayOutputStream(); part.writeTo(out); in = new ByteArrayInputStream(out.toByteArray()); part2 = new MimeBodyPart(in); temp1 = File.createTempFile("MIME", ".dat"); temp1.deleteOnExit(); part2.saveFile(temp1.getPath()); tempData = getFileData(temp1); compareFileData(testData, tempData); } private byte[] getFileData(final File source) throws Exception { final FileInputStream testIn = new FileInputStream(source); final byte[] testData = new byte[(int)source.length()]; testIn.read(testData); testIn.close(); return testData; } private void compareFileData(final byte[] file1, final byte [] file2) { assertEquals(file1.length, file2.length); for (int i = 0; i < file1.length; i++) { assertEquals(file1[i], file2[i]); } } class TestMimeBodyPart extends MimeBodyPart { public TestMimeBodyPart() { super(); } @Override public void updateHeaders() throws MessagingException { super.updateHeaders(); } } }
1,891
0
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail/internet/InternetAddressTest.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.mail.internet; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.Properties; import javax.mail.Session; import junit.framework.TestCase; /** * @version $Rev$ $Date$ */ public class InternetAddressTest extends TestCase { private InternetAddress address; public void testQuotedLiterals() throws Exception { parseHeaderTest("\"Foo\t\n\\\\\\\"\" <foo@apache.org>", true, "foo@apache.org", "Foo\t\n\\\"", "\"Foo\t\n\\\\\\\"\" <foo@apache.org>", false); parseHeaderTest("<\"@,:;<>.[]()\"@apache.org>", true, "\"@,:;<>.[]()\"@apache.org", null, "<\"@,:;<>.[]()\"@apache.org>", false); parseHeaderTest("<\"\\F\\o\\o\"@apache.org>", true, "\"Foo\"@apache.org", null, "<\"Foo\"@apache.org>", false); parseHeaderErrorTest("\"Foo <foo@apache.org>", true); parseHeaderErrorTest("\"Foo\r\" <foo@apache.org>", true); } public void testDomainLiterals() throws Exception { parseHeaderTest("<foo@[apache].org>", true, "foo@[apache].org", null, "<foo@[apache].org>", false); parseHeaderTest("<foo@[@()<>.,:;\"\\\\].org>", true, "foo@[@()<>.,:;\"\\\\].org", null, "<foo@[@()<>.,:;\"\\\\].org>", false); parseHeaderTest("<foo@[\\[\\]].org>", true, "foo@[\\[\\]].org", null, "<foo@[\\[\\]].org>", false); parseHeaderErrorTest("<foo@[[].org>", true); parseHeaderErrorTest("<foo@[foo.org>", true); parseHeaderErrorTest("<foo@[\r].org>", true); } public void testComments() throws Exception { parseHeaderTest("Foo Bar (Fred) <foo@apache.org>", true, "foo@apache.org", "Foo Bar (Fred)", "\"Foo Bar (Fred)\" <foo@apache.org>", false); parseHeaderTest("(Fred) foo@apache.org", true, "foo@apache.org", "Fred", "Fred <foo@apache.org>", false); parseHeaderTest("(\\(Fred\\)) foo@apache.org", true, "foo@apache.org", "(Fred)", "\"(Fred)\" <foo@apache.org>", false); parseHeaderTest("(Fred (Jones)) foo@apache.org", true, "foo@apache.org", "Fred (Jones)", "\"Fred (Jones)\" <foo@apache.org>", false); parseHeaderErrorTest("(Fred foo@apache.org", true); parseHeaderErrorTest("(Fred\r) foo@apache.org", true); } public void testParseHeader() throws Exception { parseHeaderTest("<@apache.org,@apache.net:foo@apache.org>", false, "@apache.org,@apache.net:foo@apache.org", null, "<@apache.org,@apache.net:foo@apache.org>", false); parseHeaderTest("<@apache.org:foo@apache.org>", false, "@apache.org:foo@apache.org", null, "<@apache.org:foo@apache.org>", false); parseHeaderTest("Foo Bar:;", false, "Foo Bar:;", null, "Foo Bar:;", true); parseHeaderTest("\"\\\"Foo Bar\" <foo.bar@apache.org>", false, "foo.bar@apache.org", "\"Foo Bar", "\"\\\"Foo Bar\" <foo.bar@apache.org>", false); parseHeaderTest("\"Foo Bar\" <foo.bar@apache.org>", false, "foo.bar@apache.org", "Foo Bar", "Foo Bar <foo.bar@apache.org>", false); parseHeaderTest("(Foo) (Bar) foo.bar@apache.org", false, "foo.bar@apache.org", "Foo", "Foo <foo.bar@apache.org>", false); parseHeaderTest("<foo@apache.org>", false, "foo@apache.org", null, "foo@apache.org", false); parseHeaderTest("Foo Bar <foo.bar@apache.org>", false, "foo.bar@apache.org", "Foo Bar", "Foo Bar <foo.bar@apache.org>", false); parseHeaderTest("foo", false, "foo", null, "foo", false); parseHeaderTest("\"foo\"", false, "\"foo\"", null, "<\"foo\">", false); parseHeaderTest("foo@apache.org", false, "foo@apache.org", null, "foo@apache.org", false); parseHeaderTest("\"foo\"@apache.org", false, "\"foo\"@apache.org", null, "<\"foo\"@apache.org>", false); parseHeaderTest("foo@[apache].org", false, "foo@[apache].org", null, "<foo@[apache].org>", false); parseHeaderTest("foo@[apache].[org]", false, "foo@[apache].[org]", null, "<foo@[apache].[org]>", false); parseHeaderTest("foo.bar@apache.org", false, "foo.bar@apache.org", null, "foo.bar@apache.org", false); parseHeaderTest("(Foo Bar) <foo.bar@apache.org>", false, "foo.bar@apache.org", null, "foo.bar@apache.org", false); parseHeaderTest("(Foo) (Bar) <foo.bar@apache.org>", false, "foo.bar@apache.org", null, "foo.bar@apache.org", false); parseHeaderTest("\"Foo\" Bar <foo.bar@apache.org>", false, "foo.bar@apache.org", "\"Foo\" Bar", "\"\\\"Foo\\\" Bar\" <foo.bar@apache.org>", false); parseHeaderTest("(Foo Bar) foo.bar@apache.org", false, "foo.bar@apache.org", "Foo Bar", "Foo Bar <foo.bar@apache.org>", false); parseHeaderTest("apache.org", false, "apache.org", null, "apache.org", false); } public void testValidate() throws Exception { validateTest("@apache.org,@apache.net:foo@apache.org"); validateTest("@apache.org:foo@apache.org"); validateTest("Foo Bar:;"); validateTest("foo.bar@apache.org"); validateTest("bar@apache.org"); validateTest("foo"); validateTest("foo.bar"); validateTest("\"foo\""); validateTest("\"foo\"@apache.org"); validateTest("foo@[apache].org"); validateTest("foo@[apache].[org]"); } public void testStrictParseHeader() throws Exception { parseHeaderTest("<@apache.org,@apache.net:foo@apache.org>", true, "@apache.org,@apache.net:foo@apache.org", null, "<@apache.org,@apache.net:foo@apache.org>", false); parseHeaderTest("<@apache.org:foo@apache.org>", true, "@apache.org:foo@apache.org", null, "<@apache.org:foo@apache.org>", false); parseHeaderTest("Foo Bar:;", true, "Foo Bar:;", null, "Foo Bar:;", true); parseHeaderTest("\"\\\"Foo Bar\" <foo.bar@apache.org>", true, "foo.bar@apache.org", "\"Foo Bar", "\"\\\"Foo Bar\" <foo.bar@apache.org>", false); parseHeaderTest("\"Foo Bar\" <foo.bar@apache.org>", true, "foo.bar@apache.org", "Foo Bar", "Foo Bar <foo.bar@apache.org>", false); parseHeaderTest("(Foo) (Bar) foo.bar@apache.org", true, "foo.bar@apache.org", "Foo", "Foo <foo.bar@apache.org>", false); parseHeaderTest("<foo@apache.org>", true, "foo@apache.org", null, "foo@apache.org", false); parseHeaderTest("Foo Bar <foo.bar@apache.org>", true, "foo.bar@apache.org", "Foo Bar", "Foo Bar <foo.bar@apache.org>", false); parseHeaderTest("foo", true, "foo", null, "foo", false); parseHeaderTest("\"foo\"", true, "\"foo\"", null, "<\"foo\">", false); parseHeaderTest("foo@apache.org", true, "foo@apache.org", null, "foo@apache.org", false); parseHeaderTest("\"foo\"@apache.org", true, "\"foo\"@apache.org", null, "<\"foo\"@apache.org>", false); parseHeaderTest("foo@[apache].org", true, "foo@[apache].org", null, "<foo@[apache].org>", false); parseHeaderTest("foo@[apache].[org]", true, "foo@[apache].[org]", null, "<foo@[apache].[org]>", false); parseHeaderTest("foo.bar@apache.org", true, "foo.bar@apache.org", null, "foo.bar@apache.org", false); parseHeaderTest("(Foo Bar) <foo.bar@apache.org>", true, "foo.bar@apache.org", null, "foo.bar@apache.org", false); parseHeaderTest("(Foo) (Bar) <foo.bar@apache.org>", true, "foo.bar@apache.org", null, "foo.bar@apache.org", false); parseHeaderTest("\"Foo\" Bar <foo.bar@apache.org>", true, "foo.bar@apache.org", "\"Foo\" Bar", "\"\\\"Foo\\\" Bar\" <foo.bar@apache.org>", false); parseHeaderTest("(Foo Bar) foo.bar@apache.org", true, "foo.bar@apache.org", "Foo Bar", "Foo Bar <foo.bar@apache.org>", false); parseHeaderTest("apache.org", true, "apache.org", null, "apache.org", false); } public void testParse() throws Exception { parseTest("<@apache.org,@apache.net:foo@apache.org>", false, "@apache.org,@apache.net:foo@apache.org", null, "<@apache.org,@apache.net:foo@apache.org>", false); parseTest("<@apache.org:foo@apache.org>", false, "@apache.org:foo@apache.org", null, "<@apache.org:foo@apache.org>", false); parseTest("Foo Bar:;", false, "Foo Bar:;", null, "Foo Bar:;", true); parseTest("\"\\\"Foo Bar\" <foo.bar@apache.org>", false, "foo.bar@apache.org", "\"Foo Bar", "\"\\\"Foo Bar\" <foo.bar@apache.org>", false); parseTest("\"Foo Bar\" <foo.bar@apache.org>", false, "foo.bar@apache.org", "Foo Bar", "Foo Bar <foo.bar@apache.org>", false); parseTest("(Foo) (Bar) foo.bar@apache.org", false, "foo.bar@apache.org", "Foo", "Foo <foo.bar@apache.org>", false); parseTest("<foo@apache.org>", false, "foo@apache.org", null, "foo@apache.org", false); parseTest("Foo Bar <foo.bar@apache.org>", false, "foo.bar@apache.org", "Foo Bar", "Foo Bar <foo.bar@apache.org>", false); parseTest("foo", false, "foo", null, "foo", false); parseTest("\"foo\"", false, "\"foo\"", null, "<\"foo\">", false); parseTest("foo@apache.org", false, "foo@apache.org", null, "foo@apache.org", false); parseTest("\"foo\"@apache.org", false, "\"foo\"@apache.org", null, "<\"foo\"@apache.org>", false); parseTest("foo@[apache].org", false, "foo@[apache].org", null, "<foo@[apache].org>", false); parseTest("foo@[apache].[org]", false, "foo@[apache].[org]", null, "<foo@[apache].[org]>", false); parseTest("foo.bar@apache.org", false, "foo.bar@apache.org", null, "foo.bar@apache.org", false); parseTest("(Foo Bar) <foo.bar@apache.org>", false, "foo.bar@apache.org", null, "foo.bar@apache.org", false); parseTest("(Foo) (Bar) <foo.bar@apache.org>", false, "foo.bar@apache.org", null, "foo.bar@apache.org", false); parseTest("\"Foo\" Bar <foo.bar@apache.org>", false, "foo.bar@apache.org", "\"Foo\" Bar", "\"\\\"Foo\\\" Bar\" <foo.bar@apache.org>", false); parseTest("(Foo Bar) foo.bar@apache.org", false, "foo.bar@apache.org", "Foo Bar", "Foo Bar <foo.bar@apache.org>", false); parseTest("apache.org", false, "apache.org", null, "apache.org", false); } public void testDefaultParse() throws Exception { parseDefaultTest("<@apache.org,@apache.net:foo@apache.org>", "@apache.org,@apache.net:foo@apache.org", null, "<@apache.org,@apache.net:foo@apache.org>", false); parseDefaultTest("<@apache.org:foo@apache.org>", "@apache.org:foo@apache.org", null, "<@apache.org:foo@apache.org>", false); parseDefaultTest("Foo Bar:;", "Foo Bar:;", null, "Foo Bar:;", true); parseDefaultTest("\"\\\"Foo Bar\" <foo.bar@apache.org>", "foo.bar@apache.org", "\"Foo Bar", "\"\\\"Foo Bar\" <foo.bar@apache.org>", false); parseDefaultTest("\"Foo Bar\" <foo.bar@apache.org>", "foo.bar@apache.org", "Foo Bar", "Foo Bar <foo.bar@apache.org>", false); parseDefaultTest("(Foo) (Bar) foo.bar@apache.org", "foo.bar@apache.org", "Foo", "Foo <foo.bar@apache.org>", false); parseDefaultTest("<foo@apache.org>", "foo@apache.org", null, "foo@apache.org", false); parseDefaultTest("Foo Bar <foo.bar@apache.org>", "foo.bar@apache.org", "Foo Bar", "Foo Bar <foo.bar@apache.org>", false); parseDefaultTest("foo", "foo", null, "foo", false); parseDefaultTest("\"foo\"", "\"foo\"", null, "<\"foo\">", false); parseDefaultTest("foo@apache.org", "foo@apache.org", null, "foo@apache.org", false); parseDefaultTest("\"foo\"@apache.org", "\"foo\"@apache.org", null, "<\"foo\"@apache.org>", false); parseDefaultTest("foo@[apache].org", "foo@[apache].org", null, "<foo@[apache].org>", false); parseDefaultTest("foo@[apache].[org]", "foo@[apache].[org]", null, "<foo@[apache].[org]>", false); parseDefaultTest("foo.bar@apache.org", "foo.bar@apache.org", null, "foo.bar@apache.org", false); parseDefaultTest("(Foo Bar) <foo.bar@apache.org>", "foo.bar@apache.org", null, "foo.bar@apache.org", false); parseDefaultTest("(Foo) (Bar) <foo.bar@apache.org>", "foo.bar@apache.org", null, "foo.bar@apache.org", false); parseDefaultTest("\"Foo\" Bar <foo.bar@apache.org>", "foo.bar@apache.org", "\"Foo\" Bar", "\"\\\"Foo\\\" Bar\" <foo.bar@apache.org>", false); parseDefaultTest("(Foo Bar) foo.bar@apache.org", "foo.bar@apache.org", "Foo Bar", "Foo Bar <foo.bar@apache.org>", false); parseDefaultTest("apache.org", "apache.org", null, "apache.org", false); } public void testStrictParse() throws Exception { parseTest("<@apache.org,@apache.net:foo@apache.org>", true, "@apache.org,@apache.net:foo@apache.org", null, "<@apache.org,@apache.net:foo@apache.org>", false); parseTest("<@apache.org:foo@apache.org>", true, "@apache.org:foo@apache.org", null, "<@apache.org:foo@apache.org>", false); parseTest("Foo Bar:;", true, "Foo Bar:;", null, "Foo Bar:;", true); parseTest("\"\\\"Foo Bar\" <foo.bar@apache.org>", true, "foo.bar@apache.org", "\"Foo Bar", "\"\\\"Foo Bar\" <foo.bar@apache.org>", false); parseTest("\"Foo Bar\" <foo.bar@apache.org>", true, "foo.bar@apache.org", "Foo Bar", "Foo Bar <foo.bar@apache.org>", false); parseTest("(Foo) (Bar) foo.bar@apache.org", true, "foo.bar@apache.org", "Foo", "Foo <foo.bar@apache.org>", false); parseTest("<foo@apache.org>", true, "foo@apache.org", null, "foo@apache.org", false); parseTest("Foo Bar <foo.bar@apache.org>", true, "foo.bar@apache.org", "Foo Bar", "Foo Bar <foo.bar@apache.org>", false); parseTest("foo", true, "foo", null, "foo", false); parseTest("\"foo\"", true, "\"foo\"", null, "<\"foo\">", false); parseTest("foo@apache.org", true, "foo@apache.org", null, "foo@apache.org", false); parseTest("\"foo\"@apache.org", true, "\"foo\"@apache.org", null, "<\"foo\"@apache.org>", false); parseTest("foo@[apache].org", true, "foo@[apache].org", null, "<foo@[apache].org>", false); parseTest("foo@[apache].[org]", true, "foo@[apache].[org]", null, "<foo@[apache].[org]>", false); parseTest("foo.bar@apache.org", true, "foo.bar@apache.org", null, "foo.bar@apache.org", false); parseTest("(Foo Bar) <foo.bar@apache.org>", true, "foo.bar@apache.org", null, "foo.bar@apache.org", false); parseTest("(Foo) (Bar) <foo.bar@apache.org>", true, "foo.bar@apache.org", null, "foo.bar@apache.org", false); parseTest("\"Foo\" Bar <foo.bar@apache.org>", true, "foo.bar@apache.org", "\"Foo\" Bar", "\"\\\"Foo\\\" Bar\" <foo.bar@apache.org>", false); parseTest("(Foo Bar) foo.bar@apache.org", true, "foo.bar@apache.org", "Foo Bar", "Foo Bar <foo.bar@apache.org>", false); parseTest("apache.org", true, "apache.org", null, "apache.org", false); } public void testConstructor() throws Exception { constructorTest("(Foo) (Bar) foo.bar@apache.org", false, "foo.bar@apache.org", "Foo", "Foo <foo.bar@apache.org>", false); constructorTest("<@apache.org,@apache.net:foo@apache.org>", false, "@apache.org,@apache.net:foo@apache.org", null, "<@apache.org,@apache.net:foo@apache.org>", false); constructorTest("<@apache.org:foo@apache.org>", false, "@apache.org:foo@apache.org", null, "<@apache.org:foo@apache.org>", false); constructorTest("Foo Bar:;", false, "Foo Bar:;", null, "Foo Bar:;", true); constructorTest("\"\\\"Foo Bar\" <foo.bar@apache.org>", false, "foo.bar@apache.org", "\"Foo Bar", "\"\\\"Foo Bar\" <foo.bar@apache.org>", false); constructorTest("\"Foo Bar\" <foo.bar@apache.org>", false, "foo.bar@apache.org", "Foo Bar", "Foo Bar <foo.bar@apache.org>", false); constructorTest("<foo@apache.org>", false, "foo@apache.org", null, "foo@apache.org", false); constructorTest("Foo Bar <foo.bar@apache.org>", false, "foo.bar@apache.org", "Foo Bar", "Foo Bar <foo.bar@apache.org>", false); constructorTest("foo", false, "foo", null, "foo", false); constructorTest("\"foo\"", false, "\"foo\"", null, "<\"foo\">", false); constructorTest("foo@apache.org", false, "foo@apache.org", null, "foo@apache.org", false); constructorTest("\"foo\"@apache.org", false, "\"foo\"@apache.org", null, "<\"foo\"@apache.org>", false); constructorTest("foo@[apache].org", false, "foo@[apache].org", null, "<foo@[apache].org>", false); constructorTest("foo@[apache].[org]", false, "foo@[apache].[org]", null, "<foo@[apache].[org]>", false); constructorTest("foo.bar@apache.org", false, "foo.bar@apache.org", null, "foo.bar@apache.org", false); constructorTest("(Foo Bar) <foo.bar@apache.org>", false, "foo.bar@apache.org", null, "foo.bar@apache.org", false); constructorTest("(Foo) (Bar) <foo.bar@apache.org>", false, "foo.bar@apache.org", null, "foo.bar@apache.org", false); constructorTest("\"Foo\" Bar <foo.bar@apache.org>", false, "foo.bar@apache.org", "\"Foo\" Bar", "\"\\\"Foo\\\" Bar\" <foo.bar@apache.org>", false); constructorTest("(Foo Bar) foo.bar@apache.org", false, "foo.bar@apache.org", "Foo Bar", "Foo Bar <foo.bar@apache.org>", false); constructorTest("apache.org", false, "apache.org", null, "apache.org", false); } public void testDefaultConstructor() throws Exception { constructorDefaultTest("<@apache.org,@apache.net:foo@apache.org>", "@apache.org,@apache.net:foo@apache.org", null, "<@apache.org,@apache.net:foo@apache.org>", false); constructorDefaultTest("<@apache.org:foo@apache.org>", "@apache.org:foo@apache.org", null, "<@apache.org:foo@apache.org>", false); constructorDefaultTest("Foo Bar:;", "Foo Bar:;", null, "Foo Bar:;", true); constructorDefaultTest("\"\\\"Foo Bar\" <foo.bar@apache.org>", "foo.bar@apache.org", "\"Foo Bar", "\"\\\"Foo Bar\" <foo.bar@apache.org>", false); constructorDefaultTest("\"Foo Bar\" <foo.bar@apache.org>", "foo.bar@apache.org", "Foo Bar", "Foo Bar <foo.bar@apache.org>", false); constructorDefaultTest("(Foo) (Bar) foo.bar@apache.org", "foo.bar@apache.org", "Foo", "Foo <foo.bar@apache.org>", false); constructorDefaultTest("<foo@apache.org>", "foo@apache.org", null, "foo@apache.org", false); constructorDefaultTest("Foo Bar <foo.bar@apache.org>", "foo.bar@apache.org", "Foo Bar", "Foo Bar <foo.bar@apache.org>", false); constructorDefaultTest("foo", "foo", null, "foo", false); constructorDefaultTest("\"foo\"", "\"foo\"", null, "<\"foo\">", false); constructorDefaultTest("foo@apache.org", "foo@apache.org", null, "foo@apache.org", false); constructorDefaultTest("\"foo\"@apache.org", "\"foo\"@apache.org", null, "<\"foo\"@apache.org>", false); constructorDefaultTest("foo@[apache].org", "foo@[apache].org", null, "<foo@[apache].org>", false); constructorDefaultTest("foo@[apache].[org]", "foo@[apache].[org]", null, "<foo@[apache].[org]>", false); constructorDefaultTest("foo.bar@apache.org", "foo.bar@apache.org", null, "foo.bar@apache.org", false); constructorDefaultTest("(Foo Bar) <foo.bar@apache.org>", "foo.bar@apache.org", null, "foo.bar@apache.org", false); constructorDefaultTest("(Foo) (Bar) <foo.bar@apache.org>", "foo.bar@apache.org", null, "foo.bar@apache.org", false); constructorDefaultTest("\"Foo\" Bar <foo.bar@apache.org>", "foo.bar@apache.org", "\"Foo\" Bar", "\"\\\"Foo\\\" Bar\" <foo.bar@apache.org>", false); constructorDefaultTest("(Foo Bar) foo.bar@apache.org", "foo.bar@apache.org", "Foo Bar", "Foo Bar <foo.bar@apache.org>", false); constructorDefaultTest("apache.org", "apache.org", null, "apache.org", false); } public void testStrictConstructor() throws Exception { constructorTest("<@apache.org,@apache.net:foo@apache.org>", true, "@apache.org,@apache.net:foo@apache.org", null, "<@apache.org,@apache.net:foo@apache.org>", false); constructorTest("<@apache.org:foo@apache.org>", true, "@apache.org:foo@apache.org", null, "<@apache.org:foo@apache.org>", false); constructorTest("Foo Bar:;", true, "Foo Bar:;", null, "Foo Bar:;", true); constructorTest("\"\\\"Foo Bar\" <foo.bar@apache.org>", true, "foo.bar@apache.org", "\"Foo Bar", "\"\\\"Foo Bar\" <foo.bar@apache.org>", false); constructorTest("\"Foo Bar\" <foo.bar@apache.org>", true, "foo.bar@apache.org", "Foo Bar", "Foo Bar <foo.bar@apache.org>", false); constructorTest("(Foo) (Bar) foo.bar@apache.org", true, "foo.bar@apache.org", "Foo", "Foo <foo.bar@apache.org>", false); constructorTest("<foo@apache.org>", true, "foo@apache.org", null, "foo@apache.org", false); constructorTest("Foo Bar <foo.bar@apache.org>", true, "foo.bar@apache.org", "Foo Bar", "Foo Bar <foo.bar@apache.org>", false); constructorTest("foo", true, "foo", null, "foo", false); constructorTest("\"foo\"", true, "\"foo\"", null, "<\"foo\">", false); constructorTest("foo@apache.org", true, "foo@apache.org", null, "foo@apache.org", false); constructorTest("\"foo\"@apache.org", true, "\"foo\"@apache.org", null, "<\"foo\"@apache.org>", false); constructorTest("foo@[apache].org", true, "foo@[apache].org", null, "<foo@[apache].org>", false); constructorTest("foo@[apache].[org]", true, "foo@[apache].[org]", null, "<foo@[apache].[org]>", false); constructorTest("foo.bar@apache.org", true, "foo.bar@apache.org", null, "foo.bar@apache.org", false); constructorTest("(Foo Bar) <foo.bar@apache.org>", true, "foo.bar@apache.org", null, "foo.bar@apache.org", false); constructorTest("(Foo) (Bar) <foo.bar@apache.org>", true, "foo.bar@apache.org", null, "foo.bar@apache.org", false); constructorTest("\"Foo\" Bar <foo.bar@apache.org>", true, "foo.bar@apache.org", "\"Foo\" Bar", "\"\\\"Foo\\\" Bar\" <foo.bar@apache.org>", false); constructorTest("(Foo Bar) foo.bar@apache.org", true, "foo.bar@apache.org", "Foo Bar", "Foo Bar <foo.bar@apache.org>", false); constructorTest("apache.org", true, "apache.org", null, "apache.org", false); } public void testParseHeaderList() throws Exception { InternetAddress[] addresses = InternetAddress.parseHeader("foo@apache.org,bar@apache.org", true); assertTrue("Expecting 2 addresses", addresses.length == 2); validateAddress(addresses[0], "foo@apache.org", null, "foo@apache.org", false); validateAddress(addresses[1], "bar@apache.org", null, "bar@apache.org", false); addresses = InternetAddress.parseHeader("Foo <foo@apache.org>,,Bar <bar@apache.org>", true); assertTrue("Expecting 2 addresses", addresses.length == 2); validateAddress(addresses[0], "foo@apache.org", "Foo", "Foo <foo@apache.org>", false); validateAddress(addresses[1], "bar@apache.org", "Bar", "Bar <bar@apache.org>", false); addresses = InternetAddress.parseHeader("foo@apache.org, bar@apache.org", true); assertTrue("Expecting 2 addresses", addresses.length == 2); validateAddress(addresses[0], "foo@apache.org", null, "foo@apache.org", false); validateAddress(addresses[1], "bar@apache.org", null, "bar@apache.org", false); addresses = InternetAddress.parseHeader("Foo <foo@apache.org>, Bar <bar@apache.org>", true); assertTrue("Expecting 2 addresses", addresses.length == 2); validateAddress(addresses[0], "foo@apache.org", "Foo", "Foo <foo@apache.org>", false); validateAddress(addresses[1], "bar@apache.org", "Bar", "Bar <bar@apache.org>", false); addresses = InternetAddress.parseHeader("Foo <foo@apache.org>,(yada),Bar <bar@apache.org>", true); assertTrue("Expecting 2 addresses", addresses.length == 2); validateAddress(addresses[0], "foo@apache.org", "Foo", "Foo <foo@apache.org>", false); validateAddress(addresses[1], "bar@apache.org", "Bar", "Bar <bar@apache.org>", false); } public void testParseHeaderErrors() throws Exception { parseHeaderErrorTest("foo@apache.org bar@apache.org", true); parseHeaderErrorTest("Foo foo@apache.org", true); parseHeaderErrorTest("Foo foo@apache.org", true); parseHeaderErrorTest("Foo <foo@apache.org", true); parseHeaderErrorTest("[foo]@apache.org", true); parseHeaderErrorTest("@apache.org", true); parseHeaderErrorTest("foo@[apache.org", true); } public void testValidateErrors() throws Exception { validateErrorTest("foo@apache.org bar@apache.org"); validateErrorTest("Foo foo@apache.org"); validateErrorTest("Foo foo@apache.org"); validateErrorTest("Foo <foo@apache.org"); validateErrorTest("[foo]@apache.org"); validateErrorTest("@apache.org"); validateErrorTest("foo@[apache.org"); } public void testGroup() throws Exception { parseHeaderTest("Foo:foo@apache.org;", true, "Foo:foo@apache.org;", null, "Foo:foo@apache.org;", true); parseHeaderTest("Foo:foo@apache.org,bar@apache.org;", true, "Foo:foo@apache.org,bar@apache.org;", null, "Foo:foo@apache.org,bar@apache.org;", true); parseHeaderTest("Foo Bar:<foo@apache.org>,bar@apache.org;", true, "Foo Bar:<foo@apache.org>,bar@apache.org;", null, "Foo Bar:<foo@apache.org>,bar@apache.org;", true); parseHeaderTest("Foo Bar:Foo <foo@apache.org>,bar@apache.org;", true, "Foo Bar:Foo<foo@apache.org>,bar@apache.org;", null, "Foo Bar:Foo<foo@apache.org>,bar@apache.org;", true); parseHeaderTest("Foo:<foo@apache.org>,,bar@apache.org;", true, "Foo:<foo@apache.org>,,bar@apache.org;", null, "Foo:<foo@apache.org>,,bar@apache.org;", true); parseHeaderTest("Foo:foo,bar;", true, "Foo:foo,bar;", null, "Foo:foo,bar;", true); parseHeaderTest("Foo:;", true, "Foo:;", null, "Foo:;", true); parseHeaderTest("\"Foo\":foo@apache.org;", true, "\"Foo\":foo@apache.org;", null, "\"Foo\":foo@apache.org;", true); parseHeaderErrorTest("Foo:foo@apache.org,bar@apache.org", true); parseHeaderErrorTest("Foo:foo@apache.org,Bar:bar@apache.org;;", true); parseHeaderErrorTest(":foo@apache.org;", true); parseHeaderErrorTest("Foo Bar:<foo@apache.org,bar@apache.org;", true); } public void testGetGroup() throws Exception { InternetAddress[] addresses = getGroup("Foo:foo@apache.org;", true); assertTrue("Expecting 1 address", addresses.length == 1); validateAddress(addresses[0], "foo@apache.org", null, "foo@apache.org", false); addresses = getGroup("Foo:foo@apache.org,bar@apache.org;", true); assertTrue("Expecting 2 addresses", addresses.length == 2); validateAddress(addresses[0], "foo@apache.org", null, "foo@apache.org", false); validateAddress(addresses[1], "bar@apache.org", null, "bar@apache.org", false); addresses = getGroup("Foo:<foo@apache.org>,bar@apache.org;", true); assertTrue("Expecting 2 addresses", addresses.length == 2); validateAddress(addresses[0], "foo@apache.org", null, "foo@apache.org", false); validateAddress(addresses[1], "bar@apache.org", null, "bar@apache.org", false); addresses = getGroup("Foo:<foo@apache.org>,,bar@apache.org;", true); assertTrue("Expecting 2 addresses", addresses.length == 2); validateAddress(addresses[0], "foo@apache.org", null, "foo@apache.org", false); validateAddress(addresses[1], "bar@apache.org", null, "bar@apache.org", false); addresses = getGroup("Foo:Foo <foo@apache.org>,bar@apache.org;", true); assertTrue("Expecting 2 addresses", addresses.length == 2); validateAddress(addresses[0], "foo@apache.org", "Foo", "Foo <foo@apache.org>", false); validateAddress(addresses[1], "bar@apache.org", null, "bar@apache.org", false); addresses = getGroup("Foo:Foo <@apache.org:foo@apache.org>,bar@apache.org;", true); assertTrue("Expecting 2 addresses", addresses.length == 2); validateAddress(addresses[0], "@apache.org:foo@apache.org", "Foo", "Foo <@apache.org:foo@apache.org>", false); validateAddress(addresses[1], "bar@apache.org", null, "bar@apache.org", false); addresses = getGroup("Foo:;", true); assertTrue("Expecting 0 addresses", addresses.length == 0); addresses = getGroup("Foo:foo@apache.org;", false); assertTrue("Expecting 1 address", addresses.length == 1); validateAddress(addresses[0], "foo@apache.org", null, "foo@apache.org", false); addresses = getGroup("Foo:foo@apache.org,bar@apache.org;", false); assertTrue("Expecting 2 addresses", addresses.length == 2); validateAddress(addresses[0], "foo@apache.org", null, "foo@apache.org", false); validateAddress(addresses[1], "bar@apache.org", null, "bar@apache.org", false); addresses = getGroup("Foo:<foo@apache.org>,bar@apache.org;", false); assertTrue("Expecting 2 addresses", addresses.length == 2); validateAddress(addresses[0], "foo@apache.org", null, "foo@apache.org", false); validateAddress(addresses[1], "bar@apache.org", null, "bar@apache.org", false); addresses = getGroup("Foo:<foo@apache.org>,,bar@apache.org;", false); assertTrue("Expecting 2 addresses", addresses.length == 2); validateAddress(addresses[0], "foo@apache.org", null, "foo@apache.org", false); validateAddress(addresses[1], "bar@apache.org", null, "bar@apache.org", false); addresses = getGroup("Foo:Foo <foo@apache.org>,bar@apache.org;", false); assertTrue("Expecting 2 addresses", addresses.length == 2); validateAddress(addresses[0], "foo@apache.org", "Foo", "Foo <foo@apache.org>", false); validateAddress(addresses[1], "bar@apache.org", null, "bar@apache.org", false); addresses = getGroup("Foo:Foo <@apache.org:foo@apache.org>,bar@apache.org;", false); assertTrue("Expecting 2 addresses", addresses.length == 2); validateAddress(addresses[0], "@apache.org:foo@apache.org", "Foo", "Foo <@apache.org:foo@apache.org>", false); validateAddress(addresses[1], "bar@apache.org", null, "bar@apache.org", false); addresses = getGroup("Foo:;", false); assertTrue("Expecting 0 addresses", addresses.length == 0); } public void testLocalAddress() throws Exception { System.getProperties().remove("user.name"); assertNull(InternetAddress.getLocalAddress(null)); System.setProperty("user.name", "dev"); InternetAddress localHost = null; String user = null; String host = null; try { user = System.getProperty("user.name"); host = InetAddress.getLocalHost().getHostName(); localHost = new InternetAddress(user + "@" + host); } catch (final AddressException e) { // ignore } catch (final UnknownHostException e) { // ignore } catch (final SecurityException e) { // ignore } assertEquals(InternetAddress.getLocalAddress(null), localHost); final Properties props = new Properties(); Session session = Session.getInstance(props, null); assertEquals(InternetAddress.getLocalAddress(session), localHost); props.put("mail.host", "apache.org"); session = Session.getInstance(props, null); assertEquals(InternetAddress.getLocalAddress(session), new InternetAddress(user + "@apache.org")); props.put("mail.user", "user"); props.remove("mail.host"); session = Session.getInstance(props, null); assertEquals(InternetAddress.getLocalAddress(session), new InternetAddress("user@" + host)); props.put("mail.host", "apache.org"); session = Session.getInstance(props, null); assertEquals(InternetAddress.getLocalAddress(session), new InternetAddress("user@apache.org")); props.put("mail.from", "tester@incubator.apache.org"); session = Session.getInstance(props, null); assertEquals(InternetAddress.getLocalAddress(session), new InternetAddress("tester@incubator.apache.org")); } private InternetAddress[] getGroup(final String address, final boolean strict) throws AddressException { final InternetAddress group = new InternetAddress(address); return group.getGroup(strict); } @Override protected void setUp() throws Exception { address = new InternetAddress(); } private void parseHeaderTest(final String address, final boolean strict, final String resultAddr, final String personal, final String toString, final boolean group) throws Exception { final InternetAddress[] addresses = InternetAddress.parseHeader(address, strict); assertTrue(addresses.length == 1); validateAddress(addresses[0], resultAddr, personal, toString, group); } private void parseHeaderErrorTest(final String address, final boolean strict) throws Exception { try { InternetAddress.parseHeader(address, strict); fail("Expected AddressException"); } catch (final AddressException e) { } } private void constructorTest(final String address, final boolean strict, final String resultAddr, final String personal, final String toString, final boolean group) throws Exception { validateAddress(new InternetAddress(address, strict), resultAddr, personal, toString, group); } private void constructorDefaultTest(final String address, final String resultAddr, final String personal, final String toString, final boolean group) throws Exception { validateAddress(new InternetAddress(address), resultAddr, personal, toString, group); } private void constructorErrorTest(final String address, final boolean strict) throws Exception { try { final InternetAddress foo = new InternetAddress(address, strict); fail("Expected AddressException"); } catch (final AddressException e) { } } private void parseTest(final String address, final boolean strict, final String resultAddr, final String personal, final String toString, final boolean group) throws Exception { final InternetAddress[] addresses = InternetAddress.parse(address, strict); assertTrue(addresses.length == 1); validateAddress(addresses[0], resultAddr, personal, toString, group); } private void parseErrorTest(final String address, final boolean strict) throws Exception { try { InternetAddress.parse(address, strict); fail("Expected AddressException"); } catch (final AddressException e) { } } private void parseDefaultTest(final String address, final String resultAddr, final String personal, final String toString, final boolean group) throws Exception { final InternetAddress[] addresses = InternetAddress.parse(address); assertTrue(addresses.length == 1); validateAddress(addresses[0], resultAddr, personal, toString, group); } private void parseDefaultErrorTest(final String address) throws Exception { try { InternetAddress.parse(address); fail("Expected AddressException"); } catch (final AddressException e) { } } private void validateTest(final String address) throws Exception { final InternetAddress test = new InternetAddress(); test.setAddress(address); test.validate(); } private void validateErrorTest(final String address) throws Exception { final InternetAddress test = new InternetAddress(); test.setAddress(address); try { test.validate(); fail("Expected AddressException"); } catch (final AddressException e) { } } private void validateAddress(final InternetAddress a, final String address, final String personal, final String toString, final boolean group) { assertEquals("Invalid address:", a.getAddress(), address); if (personal == null) { assertNull("Personal must be null", a.getPersonal()); } else { assertEquals("Invalid Personal:", a.getPersonal(), personal); } assertEquals("Invalid string value:", a.toString(), toString); assertTrue("Incorrect group value:", group == a.isGroup()); } }
1,892
0
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail/internet/NewsAddressTest.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.mail.internet; import junit.framework.TestCase; /** * @version $Rev$ $Date$ */ public class NewsAddressTest extends TestCase { public void testNewsAddress() throws AddressException { final NewsAddress na = new NewsAddress("geronimo-dev", "news.apache.org"); assertEquals("geronimo-dev", na.getNewsgroup()); assertEquals("news.apache.org", na.getHost()); assertEquals("news", na.getType()); assertEquals("geronimo-dev", na.toString()); final NewsAddress[] nas = NewsAddress.parse( "geronimo-dev@news.apache.org, geronimo-user@news.apache.org"); assertEquals(2, nas.length); assertEquals("geronimo-dev", nas[0].getNewsgroup()); assertEquals("news.apache.org", nas[0].getHost()); assertEquals("geronimo-user", nas[1].getNewsgroup()); assertEquals("news.apache.org", nas[1].getHost()); } }
1,893
0
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail/internet/MimeUtilityTest.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.mail.internet; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.io.OutputStream; import javax.mail.util.ByteArrayDataSource; import junit.framework.TestCase; public class MimeUtilityTest extends TestCase { private final byte[] encodeBytes = new byte[] { 32, 104, -61, -87, 33, 32, -61, -96, -61, -88, -61, -76, 117, 32, 33, 33, 33 }; public void testEncodeDecode() throws Exception { final byte [] data = new byte[256]; for (int i = 0; i < data.length; i++) { data[i] = (byte)i; } // different lengths test boundary conditions doEncodingTest(data, 256, "uuencode"); doEncodingTest(data, 255, "uuencode"); doEncodingTest(data, 254, "uuencode"); doEncodingTest(data, 256, "binary"); doEncodingTest(data, 256, "7bit"); doEncodingTest(data, 256, "8bit"); doEncodingTest(data, 256, "base64"); doEncodingTest(data, 255, "base64"); doEncodingTest(data, 254, "base64"); doEncodingTest(data, 256, "x-uuencode"); doEncodingTest(data, 256, "x-uue"); doEncodingTest(data, 256, "quoted-printable"); doEncodingTest(data, 255, "quoted-printable"); doEncodingTest(data, 254, "quoted-printable"); } public void testFoldUnfold() throws Exception { doFoldTest(0, "This is a short string", "This is a short string"); doFoldTest(0, "The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog.", "The quick brown fox jumped over the lazy dog. The quick brown fox jumped\r\n over the lazy dog. The quick brown fox jumped over the lazy dog."); doFoldTest(50, "The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog.", "The quick brown fox jumped\r\n over the lazy dog. The quick brown fox jumped over the lazy dog. The quick\r\n brown fox jumped over the lazy dog."); doFoldTest(20, "======================================================================================================================= break should be here", "=======================================================================================================================\r\n break should be here"); } public void doEncodingTest(final byte[] data, final int length, final String encoding) throws Exception { final ByteArrayOutputStream out = new ByteArrayOutputStream(); final OutputStream encoder = MimeUtility.encode(out, encoding); encoder.write(data, 0, length); encoder.flush(); final byte[] encodedData = out.toByteArray(); final ByteArrayInputStream in = new ByteArrayInputStream(encodedData); final InputStream decoder = MimeUtility.decode(in, encoding); final byte[] decodedData = new byte[length]; final int count = decoder.read(decodedData); assertEquals(length, count); for (int i = 0; i < length; i++) { assertEquals(data[i], decodedData[i]); } } public void doFoldTest(final int used, final String source, final String folded) throws Exception { final String newFolded = MimeUtility.fold(used, source); final String newUnfolded = MimeUtility.unfold(newFolded); assertEquals(folded, newFolded); assertEquals(source, newUnfolded); } public void testEncodeWord() throws Exception { assertEquals("abc", MimeUtility.encodeWord("abc")); final String encodeString = new String(encodeBytes, "UTF-8"); // default code page dependent, hard to directly test the encoded results // The following disabled because it will not succeed on all locales because the // code points used in the test string won't round trip properly for all code pages. // assertEquals(encodeString, MimeUtility.decodeWord(MimeUtility.encodeWord(encodeString))); String encoded = MimeUtility.encodeWord(encodeString, "UTF-8", "Q"); assertEquals("=?UTF-8?Q?_h=C3=A9!_=C3=A0=C3=A8=C3=B4u_!!!?=", encoded); assertEquals(encodeString, MimeUtility.decodeWord(encoded)); encoded = MimeUtility.encodeWord(encodeString, "UTF-8", "B"); assertEquals("=?UTF-8?B?IGjDqSEgw6DDqMO0dSAhISE=?=", encoded); assertEquals(encodeString, MimeUtility.decodeWord(encoded)); } public void testEncodeText() throws Exception { assertEquals("abc", MimeUtility.encodeWord("abc")); final String encodeString = new String(encodeBytes, "UTF-8"); // default code page dependent, hard to directly test the encoded results // The following disabled because it will not succeed on all locales because the // code points used in the test string won't round trip properly for all code pages. // assertEquals(encodeString, MimeUtility.decodeText(MimeUtility.encodeText(encodeString))); String encoded = MimeUtility.encodeText(encodeString, "UTF-8", "Q"); assertEquals("=?UTF-8?Q?_h=C3=A9!_=C3=A0=C3=A8=C3=B4u_!!!?=", encoded); assertEquals(encodeString, MimeUtility.decodeText(encoded)); encoded = MimeUtility.encodeText(encodeString, "UTF-8", "B"); assertEquals("=?UTF-8?B?IGjDqSEgw6DDqMO0dSAhISE=?=", encoded); assertEquals(encodeString, MimeUtility.decodeText(encoded)); // this has multiple byte characters and is longer than the 76 character grouping, so this // hits a lot of different boundary conditions final String subject = "\u03a0\u03a1\u03a2\u03a3\u03a4\u03a5\u03a6\u03a7 \u03a8\u03a9\u03aa\u03ab \u03ac\u03ad\u03ae\u03af\u03b0 \u03b1\u03b2\u03b3\u03b4\u03b5 \u03b6\u03b7\u03b8\u03b9\u03ba \u03bb\u03bc\u03bd\u03be\u03bf\u03c0 \u03c1\u03c2\u03c3\u03c4\u03c5\u03c6\u03c7 \u03c8\u03c9\u03ca\u03cb\u03cd\u03ce \u03cf\u03d0\u03d1\u03d2"; encoded = MimeUtility.encodeText(subject, "utf-8", "Q"); assertEquals(subject, MimeUtility.decodeText(encoded)); encoded = MimeUtility.encodeText(subject, "utf-8", "B"); assertEquals(subject, MimeUtility.decodeText(encoded)); } public void testGetEncoding() throws Exception { ByteArrayDataSource source = new ByteArrayDataSource(new byte[] { 'a', 'b', 'c'}, "text/plain"); assertEquals("7bit", MimeUtility.getEncoding(source)); source = new ByteArrayDataSource(new byte[] { 'a', 'b', (byte)0x81}, "text/plain"); assertEquals("quoted-printable", MimeUtility.getEncoding(source)); source = new ByteArrayDataSource(new byte[] { 'a', (byte)0x82, (byte)0x81}, "text/plain"); assertEquals("base64", MimeUtility.getEncoding(source)); source = new ByteArrayDataSource(new byte[] { 'a', 'b', 'c'}, "application/binary"); assertEquals("7bit", MimeUtility.getEncoding(source)); source = new ByteArrayDataSource(new byte[] { 'a', 'b', (byte)0x81}, "application/binary"); assertEquals("base64", MimeUtility.getEncoding(source)); source = new ByteArrayDataSource(new byte[] { 'a', (byte)0x82, (byte)0x81}, "application/binary"); assertEquals("base64", MimeUtility.getEncoding(source)); } public void testQuote() throws Exception { assertEquals("abc", MimeUtility.quote("abc", "&*%")); assertEquals("\"abc&\"", MimeUtility.quote("abc&", "&*%")); assertEquals("\"abc\\\"\"", MimeUtility.quote("abc\"", "&*%")); assertEquals("\"abc\\\\\"", MimeUtility.quote("abc\\", "&*%")); assertEquals("\"abc\\\r\"", MimeUtility.quote("abc\r", "&*%")); assertEquals("\"abc\\\n\"", MimeUtility.quote("abc\n", "&*%")); } }
1,894
0
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail/internet/PreencodedMimeBodyPartTest.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.mail.internet; import java.io.ByteArrayOutputStream; import javax.mail.MessagingException; import junit.framework.TestCase; /** * @version $Rev$ $Date$ */ public class PreencodedMimeBodyPartTest extends TestCase { public void testEncoding() throws Exception { final PreencodedMimeBodyPart part = new PreencodedMimeBodyPart("base64"); assertEquals("base64", part.getEncoding()); } public void testUpdateHeaders() throws Exception { final TestBodyPart part = new TestBodyPart("base64"); part.updateHeaders(); assertEquals("base64", part.getHeader("Content-Transfer-Encoding", null)); } public void testWriteTo() throws Exception { final PreencodedMimeBodyPart part = new PreencodedMimeBodyPart("binary"); final byte[] content = new byte[] { 81, 82, 83, 84, 85, 86 }; part.setContent(new String(content, "UTF-8"), "text/plain; charset=\"UTF-8\""); final ByteArrayOutputStream out = new ByteArrayOutputStream(); part.writeTo(out); final byte[] data = out.toByteArray(); // we need to scan forward to the actual content and verify it has been written without additional // encoding. Our marker is a "crlfcrlf" sequence. for (int i = 0; i < data.length; i++) { if (data[i] == '\r') { if (data[i + 1] == '\n' && data[i + 2] == '\r' && data[i + 3] == '\n') { for (int j = 0; j < content.length; j++) { assertEquals(data[i + 4 + j], content[j]); } } } } } public class TestBodyPart extends PreencodedMimeBodyPart { public TestBodyPart(final String encoding) { super(encoding); } @Override public void updateHeaders() throws MessagingException { super.updateHeaders(); } } }
1,895
0
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail/internet/InternetHeadersTest.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.mail.internet; import java.io.ByteArrayInputStream; import javax.mail.MessagingException; import junit.framework.TestCase; /** * @version $Rev$ $Date$ */ public class InternetHeadersTest extends TestCase { private InternetHeaders headers; public void testLoadSingleHeader() throws MessagingException { final String stream = "content-type: text/plain\r\n\r\n"; headers.load(new ByteArrayInputStream(stream.getBytes())); final String[] header = headers.getHeader("content-type"); assertNotNull(header); assertEquals("text/plain", header[0]); } @Override protected void setUp() throws Exception { headers = new InternetHeaders(); } }
1,896
0
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail/event/StoreEventTest.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.mail.event; import javax.mail.Store; import javax.mail.TestData; import junit.framework.TestCase; /** * @version $Rev$ $Date$ */ public class StoreEventTest extends TestCase { public StoreEventTest(final String name) { super(name); } public void testEvent() { doEventTests(StoreEvent.ALERT); doEventTests(StoreEvent.NOTICE); try { final StoreEvent event = new StoreEvent(null, -12345, "Hello World"); fail( "Expected exception due to invalid type " + event.getMessageType()); } catch (final IllegalArgumentException e) { } } private void doEventTests(final int type) { final Store source = TestData.getTestStore(); final StoreEvent event = new StoreEvent(source, type, "Hello World"); assertEquals(source, event.getSource()); assertEquals("Hello World", event.getMessage()); assertEquals(type, event.getMessageType()); final StoreListenerTest listener = new StoreListenerTest(); event.dispatch(listener); assertEquals("Unexpcted method dispatched", type, listener.getState()); } public static class StoreListenerTest implements StoreListener { private int state = 0; public void notification(final StoreEvent event) { if (state != 0) { fail("Recycled Listener"); } state = event.getMessageType(); } public int getState() { return state; } } }
1,897
0
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail/event/TransportEventTest.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.mail.event; import javax.mail.Address; import javax.mail.Folder; import javax.mail.Message; import javax.mail.TestData; import javax.mail.Transport; import javax.mail.internet.AddressException; import javax.mail.internet.InternetAddress; import junit.framework.TestCase; /** * @version $Rev$ $Date$ */ public class TransportEventTest extends TestCase { public TransportEventTest(final String name) { super(name); } public void testEvent() throws AddressException { doEventTests(TransportEvent.MESSAGE_DELIVERED); doEventTests(TransportEvent.MESSAGE_PARTIALLY_DELIVERED); doEventTests(TransportEvent.MESSAGE_NOT_DELIVERED); } private void doEventTests(final int type) throws AddressException { final Folder folder = TestData.getTestFolder(); final Message message = TestData.getMessage(); final Transport transport = TestData.getTestTransport(); final Address[] sent = new Address[] { new InternetAddress("alex@here.com")}; final Address[] empty = new Address[0]; final TransportEvent event = new TransportEvent(transport, type, sent, empty, empty, message); assertEquals(transport, event.getSource()); assertEquals(type, event.getType()); final TransportListenerTest listener = new TransportListenerTest(); event.dispatch(listener); assertEquals("Unexpcted method dispatched", type, listener.getState()); } public static class TransportListenerTest implements TransportListener { private int state = 0; public void messageDelivered(final TransportEvent event) { if (state != 0) { fail("Recycled Listener"); } state = TransportEvent.MESSAGE_DELIVERED; } public void messagePartiallyDelivered(final TransportEvent event) { if (state != 0) { fail("Recycled Listener"); } state = TransportEvent.MESSAGE_PARTIALLY_DELIVERED; } public void messageNotDelivered(final TransportEvent event) { if (state != 0) { fail("Recycled Listener"); } state = TransportEvent.MESSAGE_NOT_DELIVERED; } public int getState() { return state; } } }
1,898
0
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail
Create_ds/geronimo-specs/geronimo-javamail_1.5_spec/src/test/java/javax/mail/event/MessageChangedEventTest.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.mail.event; import junit.framework.TestCase; /** * @version $Rev$ $Date$ */ public class MessageChangedEventTest extends TestCase { public MessageChangedEventTest(final String name) { super(name); } public void testEvent() { doEventTests(MessageChangedEvent.ENVELOPE_CHANGED); doEventTests(MessageChangedEvent.FLAGS_CHANGED); } private void doEventTests(final int type) { final MessageChangedEvent event = new MessageChangedEvent(this, type, null); assertEquals(this, event.getSource()); assertEquals(type, event.getMessageChangeType()); final MessageChangedListenerTest listener = new MessageChangedListenerTest(); event.dispatch(listener); assertEquals("Unexpcted method dispatched", type, listener.getState()); } public static class MessageChangedListenerTest implements MessageChangedListener { private int state = 0; public void messageChanged(final MessageChangedEvent event) { if (state != 0) { fail("Recycled Listener"); } state = event.getMessageChangeType(); } public int getState() { return state; } } }
1,899