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/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc/holders/QNameHolder.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.xml.rpc.holders;
import javax.xml.namespace.QName;
/**
* Holder for <code>QName</code>s.
*
* @version 1.0
*/
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;
}
}
| 7,100 |
0 | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc/holders/LongWrapperHolder.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.xml.rpc.holders;
/**
* Holder for <code>Long</code>s.
*
* @version 1.0
*/
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;
}
}
| 7,101 |
0 | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc/holders/BooleanWrapperHolder.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.xml.rpc.holders;
/**
* Holder for <code>Boolean</code>s.
*
* @version 1.0
*/
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;
}
}
| 7,102 |
0 | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc/holders/ObjectHolder.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.xml.rpc.holders;
/**
* Holder for <code>Object</code>s.
*
* @version 1.0
*/
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;
}
}
| 7,103 |
0 | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc/holders/BigIntegerHolder.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.xml.rpc.holders;
import java.math.BigInteger;
/**
* Holder for <code>BigInteger</code>s.
*
* @version 1.0
*/
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;
}
}
| 7,104 |
0 | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc/holders/ByteWrapperHolder.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.xml.rpc.holders;
/**
* Holder for <code>Byte</code>s.
*
* @version 1.0
*/
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;
}
}
| 7,105 |
0 | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc/holders/FloatWrapperHolder.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.xml.rpc.holders;
/**
* Holder for <code>Float</code>s.
*
* @version 1.0
*/
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;
}
}
| 7,106 |
0 | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc/holders/StringHolder.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.xml.rpc.holders;
/**
* Holder for <code>String</code>s.
*
* @version 1.0
*/
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;
}
}
| 7,107 |
0 | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc/holders/FloatHolder.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.xml.rpc.holders;
/**
* Holder for <code>float</code>s.
*
* @version 1.0
*/
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;
}
}
| 7,108 |
0 | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc/holders/DoubleWrapperHolder.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.xml.rpc.holders;
/**
* Holder for <code>Double</code>s.
*
* @version 1.0
*/
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;
}
}
| 7,109 |
0 | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc/holders/IntegerWrapperHolder.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.xml.rpc.holders;
/**
* Holder for <code>Integer</code>s.
*
* @version 1.0
*/
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;
}
}
| 7,110 |
0 | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc/holders/LongHolder.java |
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.xml.rpc.holders;
/**
* Holder for <code>long</code>s.
*
* @version 1.0
*/
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;
}
}
| 7,111 |
0 | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc/holders/IntHolder.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.xml.rpc.holders;
/**
* Holder for <code>int</code>s.
*
* @version 1.0
*/
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;
}
}
| 7,112 |
0 | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc/encoding/Deserializer.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.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 1.0
*/
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();
}
| 7,113 |
0 | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc/encoding/TypeMappingRegistry.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.xml.rpc.encoding;
/**
* The interface <code>javax.xml.rpc.encoding.TypeMappingRegistry</code>
* defines a registry of TypeMapping instances for various encoding
* styles.
*
* @version 1.0
*/
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();
}
| 7,114 |
0 | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc/encoding/DeserializationContext.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.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 1.0
*/
public interface DeserializationContext {}
| 7,115 |
0 | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc/encoding/XMLType.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.xml.rpc.encoding;
import javax.xml.namespace.QName;
/**
* Constants representing XML Types.
*
* @version 1.0
*/
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");
}
| 7,116 |
0 | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc/encoding/TypeMapping.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.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 1.0
*/
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);
}
| 7,117 |
0 | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc/encoding/DeserializerFactory.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.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 1.0
*/
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();
}
| 7,118 |
0 | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc/encoding/Serializer.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.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 1.0
*/
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();
}
| 7,119 |
0 | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc/encoding/SerializerFactory.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.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 1.0
*/
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();
}
| 7,120 |
0 | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc/encoding/SerializationContext.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.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 1.0
*/
public interface SerializationContext {}
| 7,121 |
0 | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc/server/ServletEndpointContext.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.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 1.0
*/
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);
}
| 7,122 |
0 | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc/server/ServiceLifecycle.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.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 1.0
*/
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();
}
| 7,123 |
0 | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/rpc/soap/SOAPFaultException.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.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 1.0
*/
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;
}
| 7,124 |
0 | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/messaging/URLEndpoint.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.xml.messaging;
/**
* A special case of the <code>Endpoint</code> class used for simple applications that want to communicate directly
* with another SOAP-based application in a point-to-point fashion instead of going through a messaging provider.
* <P>
* A <code>URLEndpoint</code> object contains a URL, which is used to make connections to the remote party.
* A standalone client can pass a <code>URLEndpoint</code> object to the <code>SOAPConnection</code> method <code>call</code> to
* send a message synchronously.
*/
public class URLEndpoint extends Endpoint {
/**
* Constructs a new <code>URLEndpoint</code> object using the given URL.
* @param url a <code>String</code> giving the URL to use in constructing the new <code>URLEndpoint</code> object
*/
public URLEndpoint(String url) {
super(url);
}
/**
* Gets the URL associated with this <code>URLEndpoint</code> object.
* @return a <code>String</code> giving the URL associated with this <code>URLEndpoint</code> object
*/
public String getURL() {
return super.id;
}
}
| 7,125 |
0 | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml | Create_ds/axis-axis1-java/axis-jaxrpc/src/main/java/javax/xml/messaging/Endpoint.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.xml.messaging;
/**
* An opaque representation of an application endpoint. Typically, an
* <code>Endpoint</code> object represents a business entity, but it
* may represent a party of any sort. Conceptually, an
* <code>Endpoint</code> object is the mapping of a logical name
* (example, a URI) to a physical location, such as a URL.
* <P>
* For messaging using a provider that supports profiles, an application
* does not need to specify an endpoint when it sends a message because
* destination information will be contained in the profile-specific header.
* However, for point-to-point plain SOAP messaging, an application must supply
* an <code>Endpoint</code> object to
* the <code>SOAPConnection</code> method <code>call</code>
* to indicate the intended destination for the message.
* The subclass {@link URLEndpoint URLEndpoint} can be used when an application
* wants to send a message directly to a remote party without using a
* messaging provider.
* <P>
* The default identification for an <code>Endpoint</code> object
* is a URI. This defines what JAXM messaging
* providers need to support at minimum for identification of
* destinations. A messaging provider
* needs to be configured using a deployment-specific mechanism with
* mappings from an endpoint to the physical details of that endpoint.
* <P>
* <code>Endpoint</code> objects can be created using the constructor, or
* they can be looked up in a naming
* service. The latter is more flexible because logical identifiers
* or even other naming schemes (such as DUNS numbers)
* can be bound and rebound to specific URIs.
*/
public class Endpoint {
/**
* Constructs an <code>Endpoint</code> object using the given string identifier.
* @param uri a string that identifies the party that this <code>Endpoint</code> object represents; the default is a URI
*/
public Endpoint(String uri) {
id = uri;
}
/**
* Retrieves a string representation of this <code>Endpoint</code> object. This string is likely to be provider-specific, and
* programmers are discouraged from parsing and programmatically interpreting the contents of this string.
* @return a <code>String</code> with a provider-specific representation of this <code>Endpoint</code> object
*/
public String toString() {
return id;
}
/** A string that identifies the party that this <code>Endpoint</code> object represents; a URI is the default. */
protected String id;
}
| 7,126 |
0 | Create_ds/axis-axis1-java/axis-war/src/test/java/test | Create_ds/axis-axis1-java/axis-war/src/test/java/test/httpunit/HttpUnitTestBase.java | /*
* Copyright 2002-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.httpunit;
import junit.framework.TestCase;
import com.meterware.httpunit.*;
import java.io.*;
import java.net.MalformedURLException;
import org.apache.axis.war.Utils;
import org.xml.sax.SAXException;
/**
* class to make it that much easier to validate httpunit requests
*/
public class HttpUnitTestBase extends TestCase {
/**
* our url
*
*/
protected String url;
public HttpUnitTestBase(String s) {
super(s);
}
/**
* The JUnit setup method
*
*/
public void setUp() throws Exception {
url = Utils.getWebappUrl();
HttpUnitOptions.setExceptionsThrownOnErrorStatus(true);
HttpUnitOptions.setMatchesIgnoreCase(true);
HttpUnitOptions.setParserWarningsEnabled(true);
}
/**
* assert that the response contains a string
* @param response
* @param searchfor
* @param url
* @throws IOException
*/
public void assertStringInBody(WebResponse response,String searchfor, String url)
throws IOException {
String body=response.getText();
boolean found=body.indexOf(searchfor)>=0;
if(!found) {
String message;
message="failed to find ["+searchfor+"] at "+url;
fail(message);
}
}
/**
* assert that a named string is in the request body of the
* response to a request
* @param request what we ask
* @param searchfor string to look for
* @throws IOException when the fetch fails
* @throws org.xml.sax.SAXException
*/
protected void assertStringInBody( WebRequest request,
String searchfor
)
throws IOException, org.xml.sax.SAXException {
WebResponse response = makeRequest(request);
assertStringInBody(response,searchfor,request.getURL().toString());
}
/**
* make a request in a new session
* @param request request to make
* @return the response
* @throws IOException
* @throws SAXException
*/
protected WebResponse makeRequest(WebRequest request) throws IOException, SAXException {
WebConversation session = new WebConversation();
WebResponse response=session.getResponse(request);
return response;
}
/**
* assert that a string is not in a response
* @param response
* @param searchfor
* @param url
* @throws IOException
*/
protected void assertStringNotInBody(WebResponse response,
String searchfor,
String url)
throws IOException {
String body=response.getText();
boolean found=body.indexOf(searchfor)>=0;
if(found) {
String message;
message="unexpectedly found "+searchfor+" at "+url;
fail(message);
}
}
/**
* assert that a string is not in the response to a request
* @param request
* @param searchfor
* @throws IOException
* @throws org.xml.sax.SAXException
*/
protected void assertStringNotInBody( WebRequest request,
String searchfor)
throws IOException, org.xml.sax.SAXException {
WebConversation session = new WebConversation();
WebResponse response=session.getResponse(request);
assertStringNotInBody(response,searchfor,
request.getURL().toString());
}
/**
* here we expect an errorCode other than 200, and look for it
* checking for text is omitted as it doesnt work. It would never work on
* java1.3, but one may have expected java1.4+ to have access to the
* error stream in responses. clearly not
* @param request
* @param errorCode
* @param errorText optional text string to search for
* @throws MalformedURLException
* @throws IOException
* @throws SAXException
*/
protected void expectErrorCode(WebRequest request,
int errorCode, String errorText)
throws MalformedURLException, IOException, SAXException {
WebConversation session = new WebConversation();
String failureText="Expected error "+errorCode+" from "+request.getURL();
try {
session.getResponse(request);
fail(errorText+" -got success instead");
} catch (HttpException e) {
assertEquals(failureText,errorCode,e.getResponseCode());
/* checking for text omitted as it doesnt work.
if(errorText!=null) {
assertTrue(
"Failed to find "+errorText+" in "+ e.getResponseMessage(),
e.getMessage().indexOf(errorText)>=0);
}
*/
}
}
}
| 7,127 |
0 | Create_ds/axis-axis1-java/axis-war/src/test/java/test | Create_ds/axis-axis1-java/axis-war/src/test/java/test/httpunit/ServicesTest.java | /*
* Copyright 2002-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.httpunit;
import com.meterware.httpunit.WebRequest;
import com.meterware.httpunit.GetMethodWebRequest;
import com.meterware.httpunit.WebResponse;
/**
* test the services
* @author Steve Loughran
* @created Jul 10, 2002 12:09:06 AM
*/
public class ServicesTest extends HttpUnitTestBase {
private String services;
private String invalid_service;
public ServicesTest(String name) {
super(name);
}
/**
* The JUnit setup method
*
*/
public void setUp() throws Exception {
super.setUp();
services=url+"/services/";
invalid_service=services+"invalid-name";
}
/**
* what string do we take as meaning services are present.
*/
private final static String services_text="Some Services";
private final static String hi_there="Hi there, this is an AXIS service!";
/**
* verify the /servlet url is there
* @throws Exception
*/
public void testServlet() throws Exception {
WebRequest request = new GetMethodWebRequest(url+"/servlet/AxisServlet");
assertStringInBody(request,services_text);
}
/**
* verify the services url works
*/
public void testServices() throws Exception {
WebRequest request = new GetMethodWebRequest(services);
expectErrorCode(request,404, null);
}
/**
* @todo decide on the exception to throw in the servlet, write the
* test then fix the servlet
* @throws Exception
*/
public void testInvalidServiceRaisesError() throws Exception {
WebRequest request = new GetMethodWebRequest(invalid_service);
expectErrorCode(request,404, null);
}
/**
* A missing wsdl page should be a 404 error;
* @throws Exception
*/
public void testInvalidServiceWsdlRaisesError() throws Exception {
WebRequest request = new GetMethodWebRequest(invalid_service+"?wsdl");
// "The AXIS engine could not find a target service to invoke!");
expectErrorCode(request,404, null);
}
/**
* test version call
* @throws Exception
*/
public void testVersionWSDL() throws Exception {
WebRequest request = new GetMethodWebRequest(services
+"Version?wsdl");
assertStringInBody(request,"<wsdl:definitions");
}
/**
* test version call
* @throws Exception
*/
public void testVersionMethod() throws Exception {
WebRequest request = new GetMethodWebRequest(services
+ "Version?method=getVersion");
WebResponse response=makeRequest(request);
String body = response.getText();
assertTrue(body.indexOf("<?xml") ==0);
assertTrue(body.indexOf("<getVersionReturn")>0);
}
/**
* test a get without any method
* @throws Exception
*/
// TODO: Nowadays, Axis simply responds with the "Hi there, this is an AXIS service!" page in this case
public void _testVersionNoMethod() throws Exception {
WebRequest request = new GetMethodWebRequest(services
+ "Version?arg1=foo&arg2=bar");
expectErrorCode(request, 400, null);
}
}
| 7,128 |
0 | Create_ds/axis-axis1-java/axis-war/src/test/java/test | Create_ds/axis-axis1-java/axis-war/src/test/java/test/httpunit/AdminTest.java | /*
* Copyright 2002-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.httpunit;
import com.meterware.httpunit.*;
/**
* test the services
* @author Steve Loughran
* @created Jul 10, 2002 12:09:06 AM
*/
public class AdminTest extends HttpUnitTestBase {
private String servlet;
private String invalid_service;
private boolean isProduction=false;
public AdminTest(String name) {
super(name);
}
/**
* The JUnit setup method
*
*/
public void setUp() throws Exception {
super.setUp();
servlet = url + "/servlet/AdminServlet";
}
/**
* verify the page is there
* @throws Exception
*/
public void testPage() throws Exception {
WebRequest request = new GetMethodWebRequest(servlet);
assertStringInBody(request, "Server");
}
/**
* dev systems have commands
* @throws Exception
*/
public void testPageHasCommands() throws Exception {
WebRequest request = new GetMethodWebRequest(servlet);
assertStringInBody(request, "Server");
WebConversation session = new WebConversation();
WebResponse response = session.getResponse(request);
String body = response.getText();
assertTrue("start server", body.indexOf("start server")>0);
assertTrue("stop server", body.indexOf("stop server") > 0);
assertTrue("Current Load",body.indexOf("Current load") > 0);
}
/**
* test stop command
* @throws Exception
*/
public void testStop() throws Exception {
WebRequest request = new GetMethodWebRequest(servlet);
request.setParameter("cmd", "stop");
assertStringInBody(request, "Server is stopped");
}
/**
* test start command
* @throws Exception
*/
public void testStart() throws Exception {
WebRequest request = new GetMethodWebRequest(servlet);
request.setParameter("cmd", "start");
assertStringInBody(request, "Server is running");
}
}
| 7,129 |
0 | Create_ds/axis-axis1-java/axis-war/src/test/java/test | Create_ds/axis-axis1-java/axis-war/src/test/java/test/httpunit/JwsTest.java | /*
* Copyright 2002-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.httpunit;
import java.net.URLEncoder;
import com.meterware.httpunit.WebRequest;
import com.meterware.httpunit.GetMethodWebRequest;
import com.meterware.httpunit.WebResponse;
/**
* test for JWS pages being processed
* @author Steve Loughran
* @created Jul 10, 2002 12:09:20 AM
*/
public class JwsTest extends HttpUnitTestBase {
public JwsTest(String name) {
super(name);
}
public void testStockQuote() throws Exception {
WebRequest request = new GetMethodWebRequest(url+"/StockQuoteService.jws?wsdl");
assertStringInBody(request,"<wsdl:definitions");
}
public void testEchoHeadersWsdl() throws Exception {
WebRequest request = new GetMethodWebRequest(url + "/EchoHeaders.jws?wsdl");
assertStringInBody(request, "<wsdl:definitions");
}
public void testEchoHeaders() throws Exception {
WebRequest request = new GetMethodWebRequest(url + "/EchoHeaders.jws");
assertStringInBody(request, "Web Service");
}
/**
* see that we get a hello back
* @throws Exception
*/
public void testEchoHeadersWhoami() throws Exception {
WebRequest request = new GetMethodWebRequest(url
+ "/EchoHeaders.jws");
request.setParameter("method", "whoami");
assertStringInBody(request, "Hello");
}
/**
* do we get a list of headers back?
* @throws Exception
*/
public void testEchoHeadersList() throws Exception {
WebRequest request = new GetMethodWebRequest(url
+ "/EchoHeaders.jws");
request.setHeaderField("x-header","echo-header-test");
request.setParameter("method", "list");
assertStringInBody(request, "echo-header-test");
}
/**
* send an echo with a space down
* @throws Exception
*/
public void testEchoHeadersEcho() throws Exception {
WebRequest request = new GetMethodWebRequest(url
+ "/EchoHeaders.jws?method=echo¶m=foo+bar");
assertStringInBody(request, "foo bar");
}
/**
* we throw an error on missing JWS pages
* @throws Exception
*/
public void testMissingJWSRaisesException() throws Exception {
WebRequest request = new GetMethodWebRequest(url
+ "/EchoHeaders-not-really-there.jws");
expectErrorCode(request,404, "No service");
}
/**
* axis faults.
* @throws Exception
*/
public void testAxisFaultIsXML() throws Exception {
WebRequest request = new GetMethodWebRequest(url
+ "/EchoHeaders.jws?method=throwAxisFault¶m=oops!");
expectErrorCode(request, 500,
"<faultcode>soapenv:Server.generalException</faultcode>");
}
/**
* exceptions are user faults
* @throws Exception
*/
public void testExceptionIsXML() throws Exception {
WebRequest request = new GetMethodWebRequest(url
+ "/EchoHeaders.jws?method=throwAxisFault¶m=oops!");
expectErrorCode(request, 500,
"<faultcode>soapenv:Server.userException</faultcode>");
}
/**
*
*/
/**
* send a complex unicode round the loop and see what happens
* @throws Exception
*/
public void testEchoHeadersEchoUnicode() throws Exception {
WebRequest request = new GetMethodWebRequest(url
+ "/EchoHeaders.jws?method=echo¶m=" + URLEncoder.encode("\u221a", "UTF-8"));
// TODO: Axis actually returns a character entity; may be related to AXIS-2342
// assertStringInBody(request, "\u221a");
assertStringInBody(request, "√");
}
}
| 7,130 |
0 | Create_ds/axis-axis1-java/axis-war/src/test/java/test | Create_ds/axis-axis1-java/axis-war/src/test/java/test/httpunit/JspTest.java | /*
* Copyright 2002-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.httpunit;
import com.meterware.httpunit.*;
/**
* test the basic system is there
*
*@author steve loughran
*/
public class JspTest extends HttpUnitTestBase {
public JspTest(String name) {
super(name);
}
/**
* base page
*/
public void testIndex() throws Exception {
WebRequest request = new GetMethodWebRequest(url+"/");
assertStringInBody(request,"Apache-Axis");
}
/**
* happiness test
*/
public void testAxisHappy() throws Exception {
WebRequest request = new GetMethodWebRequest(url+"/happyaxis.jsp");
assertStringInBody(request,"The core axis libraries are present");
}
/**
* fingerprint
*/
public void testFingerprint() throws Exception {
WebRequest request = new GetMethodWebRequest(url+"/fingerprint.jsp");
assertStringInBody(request,"System Fingerprint");
}
}
| 7,131 |
0 | Create_ds/axis-axis1-java/axis-war/src/test/java/org/apache/axis | Create_ds/axis-axis1-java/axis-war/src/test/java/org/apache/axis/war/Utils.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 org.apache.axis.war;
import static org.junit.Assert.assertNotNull;
public final class Utils {
private static String URL_PROPERTY = "test.functional.webapp.url";
private Utils() {}
public static String getWebappUrl() {
String url = System.getProperty(URL_PROPERTY);
assertNotNull(URL_PROPERTY + " not set", url);
return url;
}
}
| 7,132 |
0 | Create_ds/axis-axis1-java/axis-war/src/test/java/org/apache/axis | Create_ds/axis-axis1-java/axis-war/src/test/java/org/apache/axis/war/XssTest.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 org.apache.axis.war;
import static com.google.common.truth.Truth.assertThat;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import org.apache.commons.io.IOUtils;
import org.junit.Test;
public class XssTest {
/**
* Tests for potential XSS vulnerability in the Version service.
* <p>
* The Version service returns a body with whatever namespace URI was used in the request. If
* the namespace URI is not properly encoded in the response, then this creates a potential
* XSS vulnerability.
*
* @throws Exception
*/
@Test
public void testGetVersion() throws Exception {
HttpURLConnection conn = (HttpURLConnection)new URL(Utils.getWebappUrl() + "/services/Version").openConnection();
conn.setDoInput(true);
conn.setDoOutput(true);
conn.setRequestProperty("SOAPAction", "");
conn.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
InputStream payload = XssTest.class.getResourceAsStream("getVersion-xss.xml");
OutputStream out = conn.getOutputStream();
IOUtils.copy(payload, out);
payload.close();
out.close();
assertThat(conn.getResponseCode()).isEqualTo(200);
InputStream in = conn.getInputStream();
assertThat(IOUtils.toString(in, "UTF-8")).doesNotContain("<script");
}
}
| 7,133 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/AxisTestBase.java | /*
* Copyright 2002-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test;
import org.custommonkey.xmlunit.XMLTestCase;
/**
* base test class for Axis test cases.
* @author steve loughran
*/
public abstract class AxisTestBase extends XMLTestCase {
public AxisTestBase() {
}
public AxisTestBase(String s) {
super(s);
}
/**
* probe for a property being set in ant terms.
* @param propertyname
* @return true if the system property is set and set to true or yes
*/
public static boolean isPropertyTrue(String propertyname) {
String setting = System.getProperty(propertyname);
return "true".equalsIgnoreCase(setting) ||
"yes".equalsIgnoreCase(setting);
}
/**
* test for the online tests being enabled
* @return true if 'online' tests are allowed.
*/
public static boolean isOnline() {
return isPropertyTrue("test.functional.online");
}
}
| 7,134 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/GenericLocalTest.java | /*
* Copyright 2002-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test;
import junit.framework.TestCase;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.configuration.BasicServerConfig;
import org.apache.axis.configuration.SimpleProvider;
import org.apache.axis.constants.Style;
import org.apache.axis.constants.Use;
import org.apache.axis.handlers.soap.SOAPService;
import org.apache.axis.providers.java.RPCProvider;
import org.apache.axis.server.AxisServer;
import org.apache.axis.transport.local.LocalTransport;
import org.apache.axis.Handler;
/**
* This is a framework class which handles all the basic stuff necessary
* to set up a local "roundtrip" test to an AxisServer.
*
* To use it - extend this class with your own test. Make sure if you
* override setUp() that you call super.setUp() so that the engine gets
* initialized correctly. The method deploy() needs to be called to deploy
* a target service and set up the transport to talk to it - note that this
* is done by default in the no-argument setUp(). If you don't want this
* behavior, or want to tweak names/classes, just call super.setUp(false)
* instead of super.setUp() and the deploy() call won't happen.
*
* Then you get a Call object by calling getCall() and you're ready to rock.
*
* @author Glen Daniels (gdaniels@apache.org)
*/
public abstract class GenericLocalTest extends TestCase {
protected AxisServer server;
protected SimpleProvider config;
protected LocalTransport transport;
protected SOAPService service = null;
public GenericLocalTest() {
}
public GenericLocalTest(String s) {
super(s);
}
/**
* Default setUp, which automatically deploys the current class
* as a service named "service". Override to switch this off.
*
* @throws Exception
*/
protected void setUp() throws Exception {
setUp(true);
}
/**
* setUp which allows controlling whether or not deploy() is called.
*
* @param deploy indicates whether we should call deploy()
* @throws Exception
*/
protected void setUp(boolean deploy) throws Exception {
super.setUp();
config = new BasicServerConfig();
server = new AxisServer(config);
transport = new LocalTransport(server);
if (deploy)
deploy();
}
/**
* Get an initialized Call, ready to invoke us over the local transport.
*
* @return an initialized Call object.
*/
public Call getCall() {
Call call = new Call(new Service());
call.setTransport(transport);
return call;
}
/**
* Convenience method to deploy ourselves as a service
*/
public void deploy() {
deploy("service", this.getClass(), Style.RPC);
}
/**
* Deploy a service to the local server we've set up, and point the
* cached local transport object to the desired service name.
*
* After calling this method, the "service" field will contain the
* deployed service, on which you could set other options if
* desired.
*
* @param serviceName the name under which to deploy the service.
* @param target class of the service.
*/
public void deploy(String serviceName, Class target, Style style) {
String className = target.getName();
service = new SOAPService(new RPCProvider());
service.setStyle(style);
service.setOption("className", className);
service.setOption("allowedMethods", "*");
config.deployService(serviceName, service);
transport.setRemoteService(serviceName);
}
public void deploy(String serviceName, Class target, Style style, Use use) {
String className = target.getName();
service = new SOAPService(new RPCProvider());
service.setStyle(style);
service.setUse(use);
service.setOption("className", className);
service.setOption("allowedMethods", "*");
config.deployService(serviceName, service);
transport.setRemoteService(serviceName);
}
/**
* Deploy a service to the local server we've set up, using a
* Handler we provide as the pivot.
*
* @param serviceName
* @param handler
*/
public void deploy(String serviceName, Handler handler) {
service = new SOAPService(handler);
config.deployService(serviceName, service);
transport.setRemoteService(serviceName);
}
} | 7,135 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/holders/TestBook.java | /*
* Copyright 2002-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.holders;
import org.apache.axis.client.Call;
import org.apache.axis.encoding.TypeMapping;
import org.apache.axis.encoding.ser.BeanDeserializerFactory;
import org.apache.axis.encoding.ser.BeanSerializerFactory;
import org.apache.axis.constants.Style;
import org.apache.axis.constants.Use;
import test.GenericLocalTest;
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import java.rmi.RemoteException;
import java.util.List;
/**
* Confirm that faults using beans work
*/
public class TestBook extends GenericLocalTest {
private QName TYPE_ARRAY_OF_BOOK =
new QName("http://holdertest.org/xsd", "ArrayOfBook");
private QName TYPE_BOOK = new QName("http://holdertest.org/xsd", "Book");
protected void setUp() throws Exception {
super.setUp(false); // don't deploy here
TypeMapping tm = (TypeMapping)config.getTypeMappingRegistry().
getDefaultTypeMapping();
tm.register(Book.class, TYPE_BOOK,
new BeanSerializerFactory(Book.class, TYPE_BOOK),
new BeanDeserializerFactory(Book.class, TYPE_BOOK));
tm.register(ArrayOfBook.class, TYPE_ARRAY_OF_BOOK,
new BeanSerializerFactory(ArrayOfBook.class,
TYPE_ARRAY_OF_BOOK),
new BeanDeserializerFactory(ArrayOfBook.class,
TYPE_ARRAY_OF_BOOK));
deploy("service", this.getClass(), Style.RPC, Use.LITERAL);
}
public void testInOutBook() throws Exception {
Call call = getCall();
call.setOperationStyle("rpc");
call.setOperationUse("literal");
call.setEncodingStyle("");
call.registerTypeMapping(Book.class, TYPE_BOOK,
new BeanSerializerFactory(Book.class, TYPE_BOOK),
new BeanDeserializerFactory(Book.class, TYPE_BOOK));
call.setReturnType(org.apache.axis.encoding.XMLType.AXIS_VOID);
call.addParameter("varBook", TYPE_BOOK, ParameterMode.INOUT);
Book data = new Book();
data.setAuthor("author1");
data.setTitle("title1");
data.setIsbn(1);
call.invoke("echoInOutBook", new Object []{data});
List l = call.getOutputValues();
assertEquals(1, l.size());
assertEquals("author2", ((Book)l.get(0)).getAuthor());
assertEquals("title2", ((Book)l.get(0)).getTitle());
assertEquals(2, ((Book)l.get(0)).getIsbn());
}
public void testInOutBookArray() throws Exception {
Call call = getCall();
call.setOperationStyle("rpc");
call.setOperationUse("literal");
call.setEncodingStyle("");
call.registerTypeMapping(ArrayOfBook.class, TYPE_ARRAY_OF_BOOK,
new BeanSerializerFactory(ArrayOfBook.class,
TYPE_ARRAY_OF_BOOK),
new BeanDeserializerFactory(ArrayOfBook.class,
TYPE_ARRAY_OF_BOOK));
call.setReturnType(org.apache.axis.encoding.XMLType.AXIS_VOID);
call.addParameter("varBook", TYPE_ARRAY_OF_BOOK, ParameterMode.INOUT);
Book b0 = new Book();
b0.setAuthor("author0");
b0.setTitle("title0");
b0.setIsbn(0);
Book b1 = new Book();
b1.setAuthor("author1");
b1.setTitle("title1");
b1.setIsbn(1);
Book b[] = new Book[2];
b[0] = b0;
b[1] = b1;
ArrayOfBook aob = new ArrayOfBook();
aob.setArrayOfBook(b);
call.invoke("echoInOutBookArray", new Object []{aob});
List l = call.getOutputValues();
assertEquals(1, l.size());
ArrayOfBook aob2 = (ArrayOfBook)l.get(0);
Book b2[] = aob2.getArrayOfBook();
assertEquals(2, b2.length);
assertEquals(b2[0].getAuthor(), b[1].getAuthor());
assertEquals(b2[1].getTitle(), b[0].getTitle());
}
public void echoInOutBook(test.holders.holders.BookHolder varBook)
throws java.rmi.RemoteException {
Book b = varBook.value;
b.setAuthor("author2");
b.setTitle("title2");
b.setIsbn(2);
varBook.value = b;
}
public void echoInOutBookArray(test.holders.holders.ArrayOfBookHolder varBook)
throws java.rmi.RemoteException {
ArrayOfBook v = varBook.value;
Book[] b = v.getArrayOfBook();
if (b.length != 2) throw new RemoteException("array size not 2");
String author = b[0].getAuthor();
String title = b[0].getTitle();
int isbn = b[0].getIsbn();
b[0].setAuthor(b[1].getAuthor());
b[0].setTitle(b[1].getTitle());
b[0].setIsbn(b[1].getIsbn());
b[1].setAuthor(author);
b[1].setTitle(title);
b[1].setIsbn(isbn);
v.setArrayOfBook(b);
varBook.value = v;
}
}
| 7,136 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/holders/Book.java | package test.holders;
public class Book implements java.io.Serializable {
private java.lang.String author;
private java.lang.String title;
private int isbn;
public Book() {
}
public Book(
java.lang.String author,
int isbn,
java.lang.String title) {
this.author = author;
this.title = title;
this.isbn = isbn;
}
/**
* Gets the author value for this Book.
*
* @return author
*/
public java.lang.String getAuthor() {
return author;
}
/**
* Sets the author value for this Book.
*
* @param author
*/
public void setAuthor(java.lang.String author) {
this.author = author;
}
/**
* Gets the title value for this Book.
*
* @return title
*/
public java.lang.String getTitle() {
return title;
}
/**
* Sets the title value for this Book.
*
* @param title
*/
public void setTitle(java.lang.String title) {
this.title = title;
}
/**
* Gets the isbn value for this Book.
*
* @return isbn
*/
public int getIsbn() {
return isbn;
}
/**
* Sets the isbn value for this Book.
*
* @param isbn
*/
public void setIsbn(int isbn) {
this.isbn = isbn;
}
}
| 7,137 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/holders/ArrayOfBook.java | package test.holders;
public class ArrayOfBook implements java.io.Serializable {
private test.holders.Book[] arrayOfBook;
public ArrayOfBook() {
}
public ArrayOfBook(
test.holders.Book[] arrayOfBook) {
this.arrayOfBook = arrayOfBook;
}
public test.holders.Book[] getArrayOfBook() {
return arrayOfBook;
}
public void setArrayOfBook(test.holders.Book[] arrayOfBook) {
this.arrayOfBook = arrayOfBook;
}
// public test.holders.Book getArrayOfBook(int i) {
// return this.arrayOfBook[i];
// }
//
// public void setArrayOfBook(int i, test.holders.Book _value) {
// this.arrayOfBook[i] = _value;
// }
}
| 7,138 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/holders | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/holders/holders/ArrayOfBookHolder.java | package test.holders.holders;
public final class ArrayOfBookHolder implements javax.xml.rpc.holders.Holder {
public test.holders.ArrayOfBook value;
public ArrayOfBookHolder() {
}
public ArrayOfBookHolder(test.holders.ArrayOfBook value) {
this.value = value;
}
}
| 7,139 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/holders | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/holders/holders/BookHolder.java | package test.holders.holders;
public final class BookHolder implements javax.xml.rpc.holders.Holder {
public test.holders.Book value;
public BookHolder() {
}
public BookHolder(test.holders.Book value) {
this.value = value;
}
}
| 7,140 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/types/TestNormalizedString.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.types;
import junit.framework.TestCase;
import org.apache.axis.types.NormalizedString;
/**
* Test validation of encoding.NormalizedString
*/
public class TestNormalizedString extends TestCase {
/**
* Run a failure test. value should be invalid.
*/
private void runFailTest(String value) throws Exception {
NormalizedString oNormalizedString = null;
try {
oNormalizedString = new NormalizedString(value);
}
catch (Exception e) { // catch the validation exception
}
// object is not iNstantiated on bad data value
assertNull("validation restriction failed [" +
value + "]. did not restrict bad value.", oNormalizedString);
}
/**
* Run a successful test. value should be valid.
*/
private void runPassTest(String value) throws Exception {
NormalizedString oNormalizedString = null;
try {
oNormalizedString = new NormalizedString(value);
}
catch (Exception e) { // catch the validation exception
}
assertEquals("normalized string not equal" +
value, oNormalizedString.toString(), value);
}
/**
* Test that "a simple string" succeeds.
*/
public void testNsSimpleString() throws Exception {
runPassTest("a simple string");
}
/**
* Test that "this has \r carriage return" fails.
*/
public void testNsCarriageReturn() throws Exception {
runFailTest("this has \r carriage return");
}
/**
* Test that "this has \n line feed" fails.
*/
public void testNsLineFeed() throws Exception {
runFailTest("this has \n line feed");
}
/**
* Test that "this has \t a tab" fails.
*/
public void testNsStringWithTabs() throws Exception {
runFailTest("this has \t a tab");
}
/**
* differentiate from xsd:token
*/
public void testNsStringWithLeadingSpaces() throws Exception {
runPassTest(" a failure case");
}
/*
* differentiate from xsd:token
*/
public void testNsStringWithTrailingSpaces() throws Exception {
runPassTest("this is a ");
}
/*
* differentiate from xsd:token
*/
public void testNsStringWithLeadingAndTrailingSpaces() throws Exception {
runPassTest(" centered ");
}
/*
* differentiate from xsd:token
*/
public void testNsDoubleSpace() throws Exception {
runPassTest("a B"); // note: \r fails
}
}
| 7,141 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/types/TestURI.java | /*
* Copyright 2002-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.types;
import junit.framework.TestCase;
import org.apache.axis.types.URI;
/**
* Test validation of types.Day
*/
public class TestURI extends TestCase {
/**
* Bug AXIS-814
*/
public void testAxis814() throws Exception {
URI uri1 = new URI("urn:foobar");
URI uri2 = new URI("urn:foobar");
assertEquals(uri1,uri2);
assertEquals(uri1.hashCode(),uri2.hashCode());
}
/**
* Bug AXIS-2015
*/
public void testAxis2015() throws Exception {
URI uri1 = new URI("abc://@10");
URI uri2 = new URI("abc://@20");
assertFalse(uri1.equals(uri2));
assertFalse(uri1.hashCode() == uri2.hashCode());
}
}
| 7,142 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/types/TestNMToken.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.types;
import junit.framework.TestCase;
import org.apache.axis.types.NMToken;
/**
* Test validation of types.NMToken
*/
public class TestNMToken extends TestCase {
/**
* Run a failure test. value should be invalid.
*/
private void runFailTest(String value) throws Exception {
NMToken oToken = null;
try {
oToken = new NMToken(value);
}
catch (Exception e) { // catch the validation exception
}
assertNull(
"NMToken validation restriction failed. did not restrict bad value [" +
value + "] did not restrict bad value", oToken);
}
/**
* Run a successful test. value should be valid.
*/
private void runPassTest(String value) throws Exception {
NMToken oToken = null;
try {
oToken = new NMToken(value);
}
catch (Exception e) { // catch the validation exception
}
assertEquals("NMToken strings not equal. orig value:" + value, oToken.toString(), value);
}
/**
* Test a simple string.
*/
public void testSimpleString() throws Exception {
runPassTest("Atlanta1234567890");
}
/**
* Test a simple string.
*/
public void testPunctuationString() throws Exception {
runPassTest("Atlanta.-_:");
}
/**
* this is to differentiate from normalized string which cannot accept a \n
*/
public void testLineFeed() throws Exception {
runFailTest("line one\n line two");
}
/**
* this is to differentiate from normalized string which cannot accept a \t
*/
public void testStringWithTabs() throws Exception {
runFailTest("this has \t a tab");
}
/**
* this is to differentiate from normalized string which cannot accept leading spaces.
*/
public void testStringWithLeadingSpaces() throws Exception {
runFailTest(" a failure case");
}
/**
* this is to differentiate from normalized string which cannot accept trailing spaces.
*/
public void testStringWithTrailingSpaces() throws Exception {
runFailTest("this is a ");
}
/**
* this is to differentiate from normalized string which cannot accept
* leading and trailing spaces.
*/
public void testStringWithLeadingAndTrailingSpaces() throws Exception {
runFailTest(" centered ");
}
/**
* this is to differentiate from normalized string which cannot accept double spaces.
*/
public void testDoubleSpace() throws Exception {
runFailTest("a B"); // note: \r fails
}
}
| 7,143 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/types/TestNonNegativeInteger.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.types;
import junit.framework.TestCase;
import org.apache.axis.types.NonNegativeInteger;
/**
* Test validation of types.NonNegativeInteger
*/
public class TestNonNegativeInteger extends TestCase {
/**
* Run a failure test. value should be invalid.
*/
private void runFailTest(String value) throws Exception {
NonNegativeInteger oNonNegativeInteger = null;
try {
oNonNegativeInteger = new NonNegativeInteger(value);
}
catch (Exception e) { // catch the validation exception
}
// object is not iNstantiated on bad data value
assertNull("validation restriction failed [" +
value + "]. did not restrict bad value.", oNonNegativeInteger);
}
/**
* Run a successful test. value should be valid.
*/
private void runPassTest(String value) throws Exception {
NonNegativeInteger oNonNegativeInteger = null;
try {
oNonNegativeInteger = new NonNegativeInteger(value);
}
catch (Exception e) { // catch the validation exception
}
assertEquals("unsigned int not equal" +
value, oNonNegativeInteger.toString(), value);
}
/**
* Test that a positive value succeeeds
*/
public void testPositiveValue() throws Exception {
runPassTest("12345678901234567890");
}
/**
* Test that a negative number fails
*/
public void testNegativeValue() throws Exception {
runFailTest("-123");
}
/**
* Test that a number at MinInclusive succeeds
*/
public void testMinExclusive() throws Exception {
runPassTest("0");
}
/**
* Test that a number below MinInclusive fails
*/
public void testBelowMinExclusive() throws Exception {
runFailTest("-1");
}
}
| 7,144 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/types/TestNegativeInteger.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.types;
import junit.framework.TestCase;
import org.apache.axis.types.NegativeInteger;
/**
* Test validation of types.NonNegativeInteger
*/
public class TestNegativeInteger extends TestCase {
/**
* Run a failure test. value should be invalid.
*/
private void runFailTest(String value) throws Exception {
NegativeInteger oNegativeInteger = null;
try {
oNegativeInteger = new NegativeInteger(value);
}
catch (Exception e) { // catch the validation exception
}
// object is not iNstantiated on bad data value
assertNull("validation restriction failed [" +
value + "]. did not restrict bad value.", oNegativeInteger);
}
/**
* Run a successful test. value should be valid.
*/
private void runPassTest(String value) throws Exception {
NegativeInteger oNegativeInteger = null;
try {
oNegativeInteger = new NegativeInteger(value);
}
catch (Exception e) { // catch the validation exception
}
assertEquals("unsigned int not equal" +
value, oNegativeInteger.toString(), value);
}
/**
* Test that a Negative value succeeeds
*/
public void testNegativeValue() throws Exception {
runPassTest("-12345678901234567890");
}
/**
* Test that a positive number fails
*/
public void testPositiveValue() throws Exception {
runFailTest("123");
}
/**
* Test that a number at MaxInclusive succeeds
*/
public void testMaxInclusive() throws Exception {
runPassTest("-1");
}
/**
* Test that a number above MaxInclusive fails
*/
public void testAboveMaxInclusive() throws Exception {
runFailTest("0");
}
}
| 7,145 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/types/TestNonPositiveInteger.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.types;
import junit.framework.TestCase;
import org.apache.axis.types.NonPositiveInteger;
/**
* Test validation of types.NonNegativeInteger
*/
public class TestNonPositiveInteger extends TestCase {
/**
* Run a failure test. value should be invalid.
*/
private void runFailTest(String value) throws Exception {
NonPositiveInteger oNonPositiveInteger = null;
try {
oNonPositiveInteger = new NonPositiveInteger(value);
}
catch (Exception e) { // catch the validation exception
}
// object is not iNstantiated on bad data value
assertNull("validation restriction failed [" +
value + "]. did not restrict bad value.", oNonPositiveInteger);
}
/**
* Run a successful test. value should be valid.
*/
private void runPassTest(String value) throws Exception {
NonPositiveInteger oNonPositiveInteger = null;
try {
oNonPositiveInteger = new NonPositiveInteger(value);
}
catch (Exception e) { // catch the validation exception
}
assertEquals("unsigned int not equal" +
value, oNonPositiveInteger.toString(), value);
}
/**
* Test that a Negative value succeeeds
*/
public void testnonPositiveValue() throws Exception {
runPassTest("-12345678901234567890");
}
/**
* Test that a positive number fails
*/
public void testPositiveValue() throws Exception {
runFailTest("123");
}
/**
* Test that a number at MaxInclusive succeeds
*/
public void testMaxInclusive() throws Exception {
runPassTest("0");
}
/**
* Test that a number above MaxInclusive fails
*/
public void testAboveMaxInclusive() throws Exception {
runFailTest("1");
}
}
| 7,146 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/types/TestPositiveInteger.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.types;
import junit.framework.TestCase;
import org.apache.axis.types.PositiveInteger;
/**
* Test validation of types.positiveInteger
*/
public class TestPositiveInteger extends TestCase {
/**
* Run a failure test. value should be invalid.
*/
private void runFailTest(String value) throws Exception {
PositiveInteger oPositiveInteger = null;
try {
oPositiveInteger = new PositiveInteger(value);
}
catch (Exception e) { // catch the validation exception
}
// object is not iNstantiated on bad data value
assertNull("validation restriction failed [" +
value + "]. did not restrict bad value.", oPositiveInteger);
}
/**
* Run a successful test. value should be valid.
*/
private void runPassTest(String value) throws Exception {
PositiveInteger oPositiveInteger = null;
try {
oPositiveInteger = new PositiveInteger(value);
}
catch (Exception e) { // catch the validation exception
}
assertEquals("positive integer not equal" +
value, oPositiveInteger.toString(), value);
}
/**
* Test that a positive value succeeeds
*/
public void TestPositiveValue() throws Exception {
runPassTest("12345678901234567890");
}
/**
* Test that a negative number fails
*/
public void testNegativeValue() throws Exception {
runFailTest("-123");
}
/**
* Test that a number at MinInclusive succeeds
*/
public void testMinExclusive() throws Exception {
runPassTest("1");
}
/**
* Test that a number less than MinInclusive fails
*/
public void testBelowMinExclusive() throws Exception {
runFailTest("0");
}
}
| 7,147 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/types/TestUnsignedShort.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.types;
import junit.framework.TestCase;
import org.apache.axis.types.UnsignedShort;
/**
* Test validation of types.UnsignedShort
*/
public class TestUnsignedShort extends TestCase {
/**
* Run a failure test. value should be invalid.
*/
private void runFailTest(long value) throws Exception {
UnsignedShort oUnsignedShort = null;
try {
oUnsignedShort = new UnsignedShort(value);
}
catch (Exception e) { // catch the validation exception
}
// object is not iNstantiated on bad data value
assertNull("validation restriction failed [" +
String.valueOf(value) + "]. did not restrict bad value.", oUnsignedShort);
}
/**
* Run a successful test. value should be valid.
*/
private void runPassTest(long value) throws Exception {
UnsignedShort oUnsignedShort = null;
try {
oUnsignedShort = new UnsignedShort(value);
}
catch (Exception e) { // catch the validation exception
}
assertEquals("unsigned short not equal" +
String.valueOf(value), oUnsignedShort.toString(), String.valueOf(value));
}
/**
* Test that a positive value succeeeds
*/
public void testPositiveValue() throws Exception {
runPassTest(100);
}
/**
* Test that a negative number fails
*/
public void testNegativeValue() throws Exception {
runFailTest(-100);
}
/**
* Test that a number at MaxInclusive succeeds
*/
public void testMaxInclusive() throws Exception {
runPassTest(65535);
}
/**
* Test that a number over MaxInclusive fails
*/
public void testMaxOver() throws Exception {
runFailTest(65536);
}
/**
* Test that a number at MinInclusive succeeds
*/
public void testMinExclusive() throws Exception {
runPassTest(0L);
}
}
| 7,148 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/types/TestName.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.types;
import junit.framework.TestCase;
import org.apache.axis.types.Name;
/**
* Test validation of types.Name
*/
public class TestName extends TestCase {
/**
* Run a failure test. value should be invalid.
*/
private void runFailTest(String value) throws Exception {
Name oToken = null;
try {
oToken = new Name(value);
}
catch (Exception e) { // catch the validation exception
}
assertNull(
"Name validation restriction failed. did not restrict bad value [" +
value + "] did not restrict bad value", oToken);
}
/**
* Run a successful test. value should be valid.
*/
private void runPassTest(String value) throws Exception {
Name oToken = null;
try {
oToken = new Name(value);
}
catch (Exception e) { // catch the validation exception
}
assertEquals("Name strings not equal. orig value:" + value, oToken.toString(), value);
}
/**
* Test a simple string.
*/
public void testSimpleString() throws Exception {
runPassTest("Atlanta");
}
/**
* Test a simple string with allowed punctuation.
*/
public void testPunctuationString() throws Exception {
runPassTest("Atlanta:_Braves.Home-Team10");
}
/**
* Test a start character ':'
*/
public void testStartColon() throws Exception {
runPassTest(":_Braves.Home-Team:1");
}
/**
* Test a start character '_'
*/
public void testStartUnderscore() throws Exception {
runPassTest("_Braves.Home-Team:1");
}
/**
* Test a start Digit
*/
public void testStartDigit() throws Exception {
runFailTest("1_Braves");
}
/**
* this is to differentiate from normalized string which cannot accept a \n
*/
public void testLineFeed() throws Exception {
runFailTest("line one\n line two");
}
/**
* this is to differentiate from normalized string which cannot accept a \t
*/
public void testStringWithTabs() throws Exception {
runFailTest("this has \t a tab");
}
/**
* this is to differentiate from normalized string which cannot accept leading spaces.
*/
public void testStringWithLeadingSpaces() throws Exception {
runFailTest(" a failure case");
}
/**
* this is to differentiate from normalized string which cannot accept trailing spaces.
*/
public void testStringWithTrailingSpaces() throws Exception {
runFailTest("this is a ");
}
/**
* this is to differentiate from normalized string which cannot accept
* leading and trailing spaces.
*/
public void testStringWithLeadingAndTrailingSpaces() throws Exception {
runFailTest(" centered ");
}
/**
* this is to differentiate from normalized string which cannot accept double spaces.
*/
public void testDoubleSpace() throws Exception {
runFailTest("a B"); // note: \r fails
}
}
| 7,149 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/types/TestYear.java | /*
* Copyright 2002-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.types;
import junit.framework.TestCase;
import org.apache.axis.types.Year;
/**
* Test validation of types.Year
*/
public class TestYear extends TestCase {
/**
* Run a failure test. values should be invalid.
*/
private void runFailTest(int year, String tz) throws Exception {
Year oYear = null;
try {
oYear = new Year(year, tz);
}
catch (Exception e) { // catch the validation exception
}
// object is not instantiated on bad data value
assertNull("validation restriction failed [ year=" +
String.valueOf(year) +
",tz=" + tz + "]. did not restrict bad value.", oYear);
}
private void runFailTest(String source) throws Exception {
Year oYear = null;
try {
oYear = new Year(source);
}
catch (Exception e) { // catch the validation exception
}
// object is not instantiated on bad data value
assertNull("validation restriction failed [ " + source +
"]. did not restrict bad value.", oYear);
}
/**
* Run a successful test. values should be valid.
*/
private void runPassTest(int year, String tz) throws Exception {
Year oYear = null;
try {
oYear = new Year(year, tz);
}
catch (Exception e) { // catch the validation exception
assertTrue("Validation exception thrown on valid input", true);
}
assertEquals("Year year not equal", year, oYear.getYear());
assertEquals("Year timezone not equal", tz, oYear.getTimezone());
}
private void runPassTest(String source) throws Exception {
Year oYear = null;
try {
oYear = new Year(source);
}
catch (Exception e) { // catch the validation exception
assertTrue("Validation exception thrown on valid input", false);
}
assertEquals("Year.toString() not equal", source, oYear.toString());
}
/**
* Test that a normal date succeeeds
*/
public void testNormal() throws Exception {
runPassTest(2002, null);
}
public void testNormalString() throws Exception {
runPassTest("9999");
}
public void testNormalString2() throws Exception {
// check for leading zeros in toString().
runPassTest("0001Z");
}
public void testNegativeYear() throws Exception {
runPassTest(-1955, null);
}
public void testNegativeYearString() throws Exception {
runPassTest("-1955+05:00");
}
public void testNegativeYearString2() throws Exception {
// negative year with leading zeros
runPassTest("-0055+05:00");
}
public void testBigYear() throws Exception {
// Big year should be allowed (per Schema, not ISO).
runPassTest(12000, null);
}
public void testBigYearString() throws Exception {
runPassTest("-27000+05:00");
}
/**
* Test that a bad year fails
* Schema says the year can have any number of digits
*/
public void testBadYear() throws Exception {
runFailTest(0, null);
}
public void testBadYearString() throws Exception {
runFailTest("0000");
}
/**
* Test that a bad timezone fails
*/
public void testBadTimezone() throws Exception {
runFailTest(1966, "badzone");
}
public void testBadTimezoneString() throws Exception {
runFailTest("1966+EDT");
}
/**
* Test that a year at MaxInclusive succeeds
*/
public void testMaxYear() throws Exception {
runPassTest(9999, null);
}
}
| 7,150 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/types/TestMonthDay.java | /*
* Copyright 2002-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.types;
import junit.framework.TestCase;
import org.apache.axis.types.MonthDay;
import java.text.NumberFormat;
/**
* Test validation of types.MonthDay
*/
public class TestMonthDay extends TestCase {
/**
* Run a failure test. values should be invalid.
*/
private void runFailTest(int month, int day, String tz) throws Exception {
MonthDay oMonthDay = null;
try {
oMonthDay = new MonthDay(month, day, tz);
}
catch (Exception e) { // catch the validation exception
}
// object is not instantiated on bad data value
assertNull("validation restriction failed [ month=" +
String.valueOf(month) + ",day=" + String.valueOf(day) +
",tz=" + tz + "]. did not restrict bad value.", oMonthDay);
}
private void runFailTest(String source) throws Exception {
MonthDay oMonthDay = null;
try {
oMonthDay = new MonthDay(source);
}
catch (Exception e) { // catch the validation exception
}
// object is not instantiated on bad data value
assertNull("validation restriction failed [ " + source +
"]. did not restrict bad value.", oMonthDay);
}
/**
* Run a successful test. values should be valid.
*/
private void runPassTest(int month, int day, String tz) throws Exception {
MonthDay oMonthDay = null;
try {
oMonthDay = new MonthDay(month, day, tz);
}
catch (Exception e) { // catch the validation exception
assertTrue("Validation exception thrown on valid input", false);
}
assertEquals("MonthDay month not equal", month, oMonthDay.getMonth());
assertEquals("MonthDay day not equal", day, oMonthDay.getDay());
assertEquals("MonthDay timezone not equal", tz, oMonthDay.getTimezone());
}
private void runPassTest(String source) throws Exception {
MonthDay oMonthDay = null;
try {
oMonthDay = new MonthDay(source);
}
catch (Exception e) { // catch the validation exception
assertTrue("Validation exception thrown on valid input", false);
}
assertEquals("MonthDay.toString() not equal", source, oMonthDay.toString());
}
/**
* Test that a normal date succeeeds
*/
public void testNormal() throws Exception {
// test all twelve months (1/1, 2/2, etc)
for (int m=1; m < 13; m++) {
runPassTest(m, m, null);
}
}
public void testNormalString() throws Exception {
// test all twelve months
// use NumberFormat to ensure leading zeros
NumberFormat nf = NumberFormat.getInstance();
nf.setMinimumIntegerDigits(2);
for (int m=1; m < 13; m++) {
String s = "--" + nf.format(m) + "-05";
runPassTest(s);
}
}
public void testNormalString2() throws Exception {
// check for leading zeros in toString().
runPassTest("--01-01");
}
public void testNormalTimezone() throws Exception {
runPassTest("--01-01Z");
}
public void testNormalPositiveTimezone() throws Exception {
runPassTest("--02-11+05:00");
}
public void testNormalNegativeTimezone() throws Exception {
runPassTest("--03-11-11:00");
}
/**
* Test that badly formatted strings fail
*/
public void testBadString() throws Exception {
runFailTest("07-13Z");
runFailTest("-07-13");
runFailTest("xx07-13");
runFailTest("garbage");
}
/**
* Test that a bad month fails
*/
public void testBadMonth() throws Exception {
runFailTest(13, 20, null);
}
public void testBadMonthString() throws Exception {
runFailTest("--13-13");
}
public void testBadMonthString2() throws Exception {
runFailTest("--1-01");
}
/**
* Test that a bad day fails
*/
public void testBadDay() throws Exception {
runFailTest(1, 32, null);
}
public void testBadDayString() throws Exception {
runFailTest("--08-32");
}
public void testBadDayString2() throws Exception {
runFailTest("--1-01");
}
public void testEndOfMonthDays() throws Exception {
runFailTest(1, 32, null);
runPassTest(1, 31, null);
runFailTest(2, 30, null);
runPassTest(2, 29, null);
runFailTest(3, 32, null);
runPassTest(3, 31, null);
runFailTest(4, 31, null);
runPassTest(4, 30, null);
runFailTest(5, 32, null);
runPassTest(5, 30, null);
runFailTest(6, 31, null);
runPassTest(6, 30, null);
runFailTest(7, 32, null);
runPassTest(7, 31, null);
runFailTest(8, 32, null);
runPassTest(8, 31, null);
runFailTest(9, 31, null);
runPassTest(9, 30, null);
runFailTest(10, 32, null);
runPassTest(10, 31, null);
runFailTest(11, 31, null);
runPassTest(11, 30, null);
runFailTest(12, 32, null);
runPassTest(12, 31, null);
}
/**
* Test that a bad timezone fails
*/
public void testBadTimezone() throws Exception {
runFailTest(12, 31, "badzone");
}
public void testBadTimezoneString() throws Exception {
runFailTest("--07-23+EDT");
}
}
| 7,151 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/types/TestDay.java | /*
* Copyright 2002-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.types;
import junit.framework.TestCase;
import org.apache.axis.types.Day;
import java.text.NumberFormat;
/**
* Test validation of types.Day
*/
public class TestDay extends TestCase {
/**
* Run a failure test. values should be invalid.
*/
private void runFailTest(int day, String tz) throws Exception {
Day oDay = null;
try {
oDay = new Day(day, tz);
}
catch (Exception e) { // catch the validation exception
}
// object is not instantiated on bad data value
assertNull("validation restriction failed [ day=" + String.valueOf(day) +
",tz=" + tz + "]. did not restrict bad value.", oDay);
}
private void runFailTest(String source) throws Exception {
Day oDay = null;
try {
oDay = new Day(source);
}
catch (Exception e) { // catch the validation exception
}
// object is not instantiated on bad data value
assertNull("validation restriction failed [ " + source +
"]. did not restrict bad value.", oDay);
}
/**
* Run a successful test. values should be valid.
*/
private void runPassTest(int day, String tz) throws Exception {
Day oDay = null;
try {
oDay = new Day(day, tz);
}
catch (Exception e) { // catch the validation exception
assertTrue("Validation exception thrown on valid input", false);
}
assertEquals("Day day not equal", day, oDay.getDay());
assertEquals("Day timezone not equal", tz, oDay.getTimezone());
}
private void runPassTest(String source) throws Exception {
Day oDay = null;
try {
oDay = new Day(source);
}
catch (Exception e) { // catch the validation exception
assertTrue("Validation exception thrown on valid input", false);
}
assertEquals("Day.toString() not equal", source, oDay.toString());
}
/**
* Test that a normal date succeeeds
*/
public void testNormal() throws Exception {
// test all days
for (int d=1; d < 32; d++) {
runPassTest(d, null);
}
}
public void testNormalString() throws Exception {
// test all 31 days
// use NumberFormat to ensure leading zeros
NumberFormat nf = NumberFormat.getInstance();
nf.setMinimumIntegerDigits(2);
for (int d=1; d < 13; d++) {
String s = "---" + nf.format(d);
runPassTest(s);
}
}
public void testNormalString2() throws Exception {
// check for leading zeros in toString().
runPassTest("---01");
}
public void testNormalTimezone() throws Exception {
runPassTest("---01Z");
}
public void testNormalPositiveTimezone() throws Exception {
runPassTest("---11+05:00");
}
public void testNormalNegativeTimezone() throws Exception {
runPassTest("---11-11:00");
}
/**
* Test that badly formatted strings fail
*/
public void testBadString() throws Exception {
runFailTest("13Z");
runFailTest("-13");
runFailTest("--13");
runFailTest("xxx13");
runFailTest("garbage");
}
/**
* Test that a bad day fails
*/
public void testBadDay() throws Exception {
runFailTest(32, null);
}
public void testBadDayString() throws Exception {
runFailTest("---32");
}
public void testBadDayString2() throws Exception {
runFailTest("---1");
}
/**
* Test that a bad timezone fails
*/
public void testBadTimezone() throws Exception {
runFailTest( 31, "badzone");
}
public void testBadTimezoneString() throws Exception {
runFailTest("---23+EDT");
}
}
| 7,152 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/types/TestUnsignedLong.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.types;
import junit.framework.TestCase;
import org.apache.axis.types.UnsignedLong;
import java.math.BigInteger;
/**
* Test validation of types.UnsignedLong
*/
public class TestUnsignedLong extends TestCase {
/**
* Run a failure test. value should be invalid.
*/
private void runFailTest(BigInteger value) throws Exception {
UnsignedLong oUnsignedLong = null;
try {
oUnsignedLong = new UnsignedLong(value);
} catch (Exception e) { // catch the validation exception
}
// object is not iNstantiated on bad data value
assertNull("validation restriction failed [" +
String.valueOf(value) + "]. did not restrict bad value.",
oUnsignedLong);
}
/**
* Run a successful test. value should be valid. String should come out
* as expected.
*/
private void runPassTest(BigInteger value, String strValue)
throws Exception {
UnsignedLong oUnsignedLong = null;
try {
oUnsignedLong = new UnsignedLong(value);
} catch (Exception e) { // catch the validation exception
// error!
assertTrue("validation error thrown and it shouldn't be", false);
}
assertEquals("unsigned long not equal: " +
String.valueOf(value), strValue, oUnsignedLong.toString());
}
/**
* Test that a positive value succeeeds
*/
public void testPositiveValue() throws Exception {
runPassTest(new BigInteger("100"), "100");
}
/**
* Test that a negative number fails
*/
public void testNegativeValue() throws Exception {
runFailTest(new BigInteger("-100"));
}
/**
* Test Max unsigned long
*/
public void testMaxInclusive() throws Exception {
runPassTest(new BigInteger("18446744073709551615"),
"18446744073709551615");
}
public void testTooLarge() throws Exception {
runFailTest(new BigInteger("184467440737095516152"));
}
/**
* Test that a number at MinInclusive succeeds
*/
public void testMinExclusive() throws Exception {
runPassTest(BigInteger.ZERO, "0");
}
}
| 7,153 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/types/TestMonth.java | /*
* Copyright 2002-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.types;
import junit.framework.TestCase;
import org.apache.axis.types.Month;
import java.text.NumberFormat;
/**
* Test validation of types.Month
*/
public class TestMonth extends TestCase {
/**
* Run a failure test. values should be invalid.
*/
private void runFailTest(int month, String tz) throws Exception {
Month oMonth = null;
try {
oMonth = new Month(month, tz);
}
catch (Exception e) { // catch the validation exception
}
// object is not instantiated on bad data value
assertNull("validation restriction failed [ month=" + String.valueOf(month) +
",tz=" + tz + "]. did not restrict bad value.", oMonth);
}
private void runFailTest(String source) throws Exception {
Month oMonth = null;
try {
oMonth = new Month(source);
}
catch (Exception e) { // catch the validation exception
}
// object is not instantiated on bad data value
assertNull("validation restriction failed [ " + source +
"]. did not restrict bad value.", oMonth);
}
/**
* Run a successful test. values should be valid.
*/
private void runPassTest(int month, String tz) throws Exception {
Month oMonth = null;
try {
oMonth = new Month(month, tz);
}
catch (Exception e) { // catch the validation exception
assertTrue("Validation exception thrown on valid input", false);
}
assertEquals("Month month not equal", month, oMonth.getMonth());
assertEquals("Month timezone not equal", tz, oMonth.getTimezone());
}
private void runPassTest(String source) throws Exception {
Month oMonth = null;
try {
oMonth = new Month(source);
}
catch (Exception e) { // catch the validation exception
assertTrue("Validation exception thrown on valid input", false);
}
assertEquals("Month.toString() not equal", source, oMonth.toString());
}
/**
* Test that a normal date succeeeds
*/
public void testNormal() throws Exception {
// test all twelve months
for (int m=1; m < 13; m++) {
runPassTest(m, null);
}
}
public void testNormalString() throws Exception {
// test all twelve months
// use NumberFormat to ensure leading zeros
NumberFormat nf = NumberFormat.getInstance();
nf.setMinimumIntegerDigits(2);
for (int m=1; m < 13; m++) {
String s = "--" + nf.format(m) + "--";
runPassTest(s);
}
}
public void testNormalTimezone() throws Exception {
runPassTest("--01--Z");
}
public void testNormalPositiveTimezone() throws Exception {
runPassTest("--11--+05:00");
}
public void testNormalNegativeTimezone() throws Exception {
runPassTest("--11---11:00");
}
/**
* Test that badly formatted strings fail
*/
public void testBadString() throws Exception {
runFailTest("11--");
runFailTest("-11--");
runFailTest("--11-");
runFailTest("--11");
runFailTest("xx07-13");
runFailTest("garbage");
}
/**
* Test that a bad month fails
*/
public void testBadMonth() throws Exception {
runFailTest(13, null);
}
public void testBadMonthString() throws Exception {
runFailTest("--13--");
}
public void testBadMonthString2() throws Exception {
runFailTest("--1--");
}
/**
* Test that a bad timezone fails
*/
public void testBadTimezone() throws Exception {
runFailTest(7, "badzone");
}
public void testBadTimezoneString() throws Exception {
runFailTest("--07--+EDT");
}
}
| 7,154 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/types/TestId.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.types;
import junit.framework.TestCase;
import org.apache.axis.types.Id;
/**
* Test validation of types.Id
*/
public class TestId extends TestCase {
// This needs to be extended to test ID specific things
/**
* Run a failure test. value should be invalid.
*/
private void runFailTest(String value) throws Exception {
Id oToken = null;
try {
oToken = new Id(value);
}
catch (Exception e) { // catch the validation exception
}
assertNull(
"Id validation restriction failed. did not restrict bad value [" +
value + "] did not restrict bad value", oToken);
}
/**
* Run a successful test. value should be valid.
*/
private void runPassTest(String value) throws Exception {
Id oToken = null;
try {
oToken = new Id(value);
}
catch (Exception e) { // catch the validation exception
}
assertEquals("Id strings not equal. orig value:" + value, oToken.toString(), value);
}
/**
* Test a simple string.
*/
public void testSimpleString() throws Exception {
runPassTest("Atlanta");
}
/**
* Test a simple string with allowed punctuation.
*/
public void testPunctuationString() throws Exception {
runPassTest("Atlanta_Braves.Home-Team10");
}
/**
* Test a start character '_'
*/
public void testStartUnderscore() throws Exception {
runPassTest("_Braves");
}
/**
* Test a simple string with allowed punctuation.
*/
public void testMidColon() throws Exception {
runFailTest("Atlanta:_Braves.Home-Team10");
}
/**
* Test a start Digit
*/
public void testStartDigit() throws Exception {
runFailTest("1_Braves");
}
/**
* Test a start character ':'
*/
public void testStartColon() throws Exception {
runFailTest(":_Braves.Home-Team:1");
}
/**
* this is to differentiate from normalized string which cannot accept a \n
*/
public void testLineFeed() throws Exception {
runFailTest("line one\n line two");
}
/**
* this is to differentiate from normalized string which cannot accept a \t
*/
public void testStringWithTabs() throws Exception {
runFailTest("this has \t a tab");
}
/**
* this is to differentiate from normalized string which cannot accept leading spaces.
*/
public void testStringWithLeadingSpaces() throws Exception {
runFailTest(" a failure case");
}
/**
* this is to differentiate from normalized string which cannot accept trailing spaces.
*/
public void testStringWithTrailingSpaces() throws Exception {
runFailTest("this is a ");
}
/**
* this is to differentiate from normalized string which cannot accept
* leading and trailing spaces.
*/
public void testStringWithLeadingAndTrailingSpaces() throws Exception {
runFailTest(" centered ");
}
/**
* this is to differentiate from normalized string which cannot accept double spaces.
*/
public void testDoubleSpace() throws Exception {
runFailTest("a B"); // note: \r fails
}
}
| 7,155 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/types/TestToken.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.types;
import junit.framework.TestCase;
import org.apache.axis.types.Token;
/**
* Test validation of encoding.Token
*/
public class TestToken extends TestCase {
/**
* Run a failure test. value should be invalid.
*/
private void runFailTest(String value) throws Exception {
Token oToken = null;
try {
oToken = new Token(value);
}
catch (Exception e) { // catch the validation exception
}
assertNull(
"Token validation restriction failed. did not restrict bad value [" +
value + "] did not restrict bad value", oToken);
}
/**
* Run a successful test. value should be valid.
*/
private void runPassTest(String value) throws Exception {
Token oToken = null;
try {
oToken = new Token(value);
}
catch (Exception e) { // catch the validation exception
}
assertEquals("Token strings not equal. orig value:" + value, oToken.toString(), value);
}
/**
* Test a simple string.
*/
public void testSimpleString() throws Exception {
runPassTest("a simple string");
}
/**
* this is to differentiate from normalized string which cannot accept a CR
*/
public void testCarriageString() throws Exception {
runPassTest("a carriage return\r string\r");
}
/**
* this is to differentiate from normalized string which cannot accept a \n
*/
public void testLineFeed() throws Exception {
runFailTest("line one\n line two");
}
/**
* this is to differentiate from normalized string which cannot accept a \t
*/
public void testStringWithTabs() throws Exception {
runFailTest("this has \t a tab");
}
/**
* this is to differentiate from normalized string which cannot accept leading spaces.
*/
public void testStringWithLeadingSpaces() throws Exception {
runFailTest(" a failure case");
}
/**
* this is to differentiate from normalized string which cannot accept trailing spaces.
*/
public void testStringWithTrailingSpaces() throws Exception {
runFailTest("this is a ");
}
/**
* this is to differentiate from normalized string which cannot accept
* leading and trailing spaces.
*/
public void testStringWithLeadingAndTrailingSpaces() throws Exception {
runFailTest(" centered ");
}
/**
* this is to differentiate from normalized string which cannot accept double spaces.
*/
public void testDoubleSpace() throws Exception {
runFailTest("a B"); // note: \r fails
}
/**
* Test an empty string
*/
public void testEmptyString() throws Exception {
runPassTest("");
}
/**
* Test an empty string
*/
public void testNull() throws Exception {
runPassTest(null);
}
}
| 7,156 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/types/TestUnsignedInt.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.types;
import junit.framework.TestCase;
import org.apache.axis.types.UnsignedInt;
/**
* Test validation of types.UnsignedInt
*/
public class TestUnsignedInt extends TestCase {
/**
* Run a failure test. value should be invalid.
*/
private void runFailTest(long value) throws Exception {
UnsignedInt oUnsignedInt = null;
try {
oUnsignedInt = new UnsignedInt(value);
}
catch (Exception e) { // catch the validation exception
}
// object is not iNstantiated on bad data value
assertNull("validation restriction failed [" +
String.valueOf(value) + "]. did not restrict bad value.", oUnsignedInt);
}
/**
* Run a successful test. value should be valid.
*/
private void runPassTest(long value) throws Exception {
UnsignedInt oUnsignedInt = null;
try {
oUnsignedInt = new UnsignedInt(value);
}
catch (Exception e) { // catch the validation exception
}
assertEquals("unsigned int not equal" +
String.valueOf(value), oUnsignedInt.toString(), String.valueOf(value));
}
/**
* Test that a positive value succeeeds
*/
public void testPositiveValue() throws Exception {
runPassTest(100);
}
/**
* Test that a negative number fails
*/
public void testNegativeValue() throws Exception {
runFailTest(-100);
}
/**
* Test that a number at MaxInclusive succeeds
*/
public void testMaxInclusive() throws Exception {
runPassTest(4294967295L);
}
/**
* Test that a number over MaxInclusive fails
*/
public void testMaxOver() throws Exception {
runFailTest(4294967296L);
}
/**
* Test that a number at MinInclusive succeeds
*/
public void testMinExclusive() throws Exception {
runPassTest(0L);
}
}
| 7,157 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/types/TestUnsignedByte.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.types;
import junit.framework.TestCase;
import org.apache.axis.types.UnsignedByte;
/**
* Test validation of types.UnsignedByte
*/
public class TestUnsignedByte extends TestCase {
/**
* Run a failure test. value should be invalid.
*/
private void runFailTest(long value) throws Exception {
UnsignedByte oUnsignedByte = null;
try {
oUnsignedByte = new UnsignedByte(value);
}
catch (Exception e) { // catch the validation exception
}
// object is not iNstantiated on bad data value
assertNull("validation restriction failed [" +
String.valueOf(value) + "]. did not restrict bad value.", oUnsignedByte);
}
/**
* Run a successful test. value should be valid.
*/
private void runPassTest(long value) throws Exception {
UnsignedByte oUnsignedByte = null;
try {
oUnsignedByte = new UnsignedByte(value);
}
catch (Exception e) { // catch the validation exception
}
assertEquals("unsigned byte not equal" +
String.valueOf(value), oUnsignedByte.toString(), String.valueOf(value));
}
/**
* Test that a positive value succeeeds
*/
public void testPositiveValue() throws Exception {
runPassTest(100);
}
/**
* Test that a negative number fails
*/
public void testNegativeValue() throws Exception {
runFailTest(-100);
}
/**
* Test that a number at MaxInclusive succeeds
*/
public void testMaxInclusive() throws Exception {
runPassTest(255);
}
/**
* Test that a number over MaxInclusive fails
*/
public void testMaxOver() throws Exception {
runFailTest(256);
}
/**
* Test that a number at MinInclusive succeeds
*/
public void testMinExclusive() throws Exception {
runPassTest(0L);
}
}
| 7,158 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/types/TestDuration.java | /*
* Copyright 2002-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.types;
import junit.framework.TestCase;
import org.apache.axis.types.Duration;
import java.util.Calendar;
import java.util.GregorianCalendar;
/**
* <p>Title: </p>
* <p>Description: </p>
* @author Dominik Kacprzak <dominik@opentoolbox.com>
* @version $Id$
*
* @todo try to find original author, add more docs
*/
public class TestDuration extends TestCase {
public void testValidDurations() throws Exception {
// invoke the web service as if it was a local java object
String[] durationStrings = new String[11];
durationStrings[0] = "P2Y3M8DT8H1M3.3S";
durationStrings[1] = "P2Y3M8DT8H1M3S";
durationStrings[2] = "PT8H1M3.3S";
durationStrings[3] = "P2Y3M8D";
durationStrings[4] = "P2YT8H";
durationStrings[5] = "P8DT3.3S";
durationStrings[6] = "P3MT1M";
durationStrings[7] = "PT0.3S";
durationStrings[8] = "P1M";
durationStrings[9] = "-P1M";
durationStrings[10] = "-P2Y3M8DT8H1M3.3S";
for (int i = 0; i < durationStrings.length; i++) {
String durationString = durationStrings[i];
Duration duration = new Duration(durationString);
assertTrue("Duration string \"" + durationString +
"\" not equal to returned: " + duration.toString(),
durationString.equals(duration.toString()));
}
}
public void testInvalidDurations() throws Exception {
// make sure that using invalid duration strings results in an
// exception
String[] invalidDurationStrings = {"P", "T", "P-2Y3M8D", "P8H1M3S",
"P8Y1MT", "PT8Y1M3D", "PYMDTHMS"};
// each of the above strings should result in an exception
for (int i = 0; i < invalidDurationStrings.length; i++) {
String durationString = invalidDurationStrings[i];
try {
Duration duration = new Duration(durationString);
throw new junit.framework.AssertionFailedError(
"org.apache.axis.types.Duration constructor accepted invalid string: " +
durationString);
} catch (IllegalArgumentException e) {
// this is good
}
}
/* need to test setTime(String) and setDate(String) for handling
* invalid time and date strings. A handling of properly formatted
* time and date strings is tested as part of testValidDurations()
* test case.
* NOTE: the code below can be removed if/when
* parseDate(String) and parseTime(String) methods are changed
* to private ones.
*/
String[] invalidTimeStrings = {"", "-8H1M3.3S", "8Y1M3D", "HMS"};
Duration duration = new Duration();
for (int i = 0; i < invalidTimeStrings.length; i++) {
String durationString = invalidTimeStrings[i];
try {
duration.parseTime(durationString);
throw new junit.framework.AssertionFailedError(
"parseTime(String) method accepted invalid string: " +
durationString);
} catch (IllegalArgumentException e) {
// this is good
}
}
String[] invalidDateStrings = {"", "-2Y3M8D", "8H1M3S", "-8Y1M"};
for (int i = 0; i < invalidDateStrings.length; i++) {
String durationString = invalidDateStrings[i];
try {
duration.parseDate(durationString);
throw new junit.framework.AssertionFailedError(
"parseDate(String) method accepted invalid string: " +
durationString);
} catch (IllegalArgumentException e) {
// this is good
}
}
}
/**
* Test if duration object is properly created from a Calendar.
* @throws Exception
*/
public void testDurationFromCalendar() throws Exception {
// negative date
Calendar calendar = new GregorianCalendar(1, 3, 20);
Duration duration = new Duration(true, calendar);
assertTrue("Negative flag does not match", duration.isNegative());
assertTrue("Years do not match", duration.getYears() == 1);
assertTrue("Months do not match", duration.getMonths() == 3);
assertTrue("Days do not match", duration.getDays() == 20);
assertEquals("String representation does not match", duration.toString(),
"-P1Y3M20D");
// positive date and time
calendar.clear();
calendar.set(1, 2, 20, 10, 3, 11);
duration = new Duration(false, calendar);
assertTrue("Negative flag does not match", !duration.isNegative());
assertTrue("Years do not match", duration.getYears() == 1);
assertTrue("Months do not match", duration.getMonths() == 2);
assertTrue("Days do not match", duration.getDays() == 20);
assertTrue("Hours do not match", duration.getHours() == 10);
assertTrue("Minutes do not match", duration.getMinutes() == 3);
assertTrue("Seconds do not match", duration.getSeconds() == 11);
assertEquals("String representation does not match", duration.toString(),
"P1Y2M20DT10H3M11S");
}
public void testCalendarFromDuration() throws Exception {
// Check if a calendar object used to create a duration object and
// a calendar object created from the same duration are equal
// that's good test for handling of miliseconds
Calendar calendar = new GregorianCalendar(1, 2, 20, 10, 3, 11);
calendar.set(Calendar.MILLISECOND, 15);
Duration duration = new Duration(true, calendar);
Calendar durationCalendar = duration.getAsCalendar();
assertTrue("Negative flag does not match", duration.isNegative());
assertEquals("Years do not match",
calendar.get(Calendar.YEAR),
durationCalendar.get(Calendar.YEAR));
assertEquals("Months do not match",
calendar.get(Calendar.MONTH),
durationCalendar.get(Calendar.MONTH));
assertEquals("Days do not match",
calendar.get(Calendar.DATE),
durationCalendar.get(Calendar.DATE));
assertEquals("Hours do not match",
calendar.get(Calendar.HOUR),
durationCalendar.get(Calendar.HOUR));
assertEquals("Minutes do not match",
calendar.get(Calendar.MINUTE),
durationCalendar.get(Calendar.MINUTE));
assertEquals("Seconds do not match",
calendar.get(Calendar.SECOND),
durationCalendar.get(Calendar.SECOND));
assertEquals("Miliseconds do not match",
calendar.get(Calendar.MILLISECOND),
durationCalendar.get(Calendar.MILLISECOND));
// test for overflows - Calendar class does automatic conversion
// of dates
duration.setMonths(20);
durationCalendar = duration.getAsCalendar();
assertEquals("Years do not match",
duration.getYears() + 1,
durationCalendar.get(Calendar.YEAR));
assertEquals("Months do not match",
duration.getMonths() - 12,
durationCalendar.get(Calendar.MONTH));
// make sure that Duration enforces milliseconds precision
duration.setSeconds(10.1234);
assertTrue("Milliseconds precision is not enforced",
duration.getSeconds() == 10.12);
}
public void testHash() {
// test if hash is taking milliseconds in account
Duration d1 = new Duration(false, 10, 1, 2, 1, 20, 2.51);
Duration d2 = new Duration(false, 10, 1, 2, 1, 20, 2.51);
Duration d3 = new Duration(false, 10, 1, 2, 1, 20, 2);
Duration d4 = new Duration(false, 10, 1, 2, 1, 20, 2.51233);
assertEquals("Hash code values do not match", d1.hashCode(),
d2.hashCode());
assertFalse("Hash code values match", d1.hashCode() == d3.hashCode());
// test precistion
assertEquals("Hash code values do not match", d1.hashCode(),
d4.hashCode());
}
public void testEquals() {
// test if equals is taking milliseconds in account
Duration d1 = new Duration(false, 10, 1, 2, 1, 20, 2.51);
Duration d2 = new Duration(false, 10, 1, 2, 1, 20, 2.51);
Duration d3 = new Duration(true, 10, 1, 2, 1, 20, 2.51);
Duration d4 = new Duration(false, 8, 25, 2, 0, 80, 2.51);
Duration d5 = new Duration(false, 8, 25, 2, 0, 80, 2.51);
// the durations are equal: testing precision
assertTrue("Comparison failed", d1.equals(d2));
// the durations are equal, except of the sign
assertFalse("Comparison failed", d1.equals(d3));
// the durations are equal, but represented differently
assertTrue("Comparison failed", d1.equals(d4));
// test precision
assertTrue("Comparison failed", d1.equals(d5));
}
}
| 7,159 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/types/TestYearMonth.java | /*
* Copyright 2002-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.types;
import junit.framework.TestCase;
import org.apache.axis.types.YearMonth;
/**
* Test validation of types.YearMonth
*/
public class TestYearMonth extends TestCase {
/**
* Run a failure test. values should be invalid.
*/
private void runFailTest(int year, int month, String tz) throws Exception {
YearMonth oYearMonth = null;
try {
oYearMonth = new YearMonth(year, month, tz);
}
catch (Exception e) { // catch the validation exception
}
// object is not instantiated on bad data value
assertNull("validation restriction failed [ year=" +
String.valueOf(year) + ",month=" + String.valueOf(month) +
",tz=" + tz + "]. did not restrict bad value.", oYearMonth);
}
private void runFailTest(String source) throws Exception {
YearMonth oYearMonth = null;
try {
oYearMonth = new YearMonth(source);
}
catch (Exception e) { // catch the validation exception
}
// object is not instantiated on bad data value
assertNull("validation restriction failed [ " + source +
"]. did not restrict bad value.", oYearMonth);
}
/**
* Run a successful test. values should be valid.
*/
private void runPassTest(int year, int month, String tz) throws Exception {
YearMonth oYearMonth = null;
try {
oYearMonth = new YearMonth(year, month, tz);
}
catch (Exception e) { // catch the validation exception
assertTrue("Validation exception thrown on valid input", false);
}
assertEquals("YearMonth year not equal", year, oYearMonth.getYear());
assertEquals("YearMonth month not equal", month, oYearMonth.getMonth());
assertEquals("YearMonth timezone not equal", tz, oYearMonth.getTimezone());
}
private void runPassTest(String source) throws Exception {
YearMonth oYearMonth = null;
try {
oYearMonth = new YearMonth(source);
}
catch (Exception e) { // catch the validation exception
assertTrue("Validation exception thrown on valid input", false);
}
assertEquals("YearMonth.toString() not equal", source, oYearMonth.toString());
}
/**
* Test that a normal date succeeeds
*/
public void testNormal() throws Exception {
runPassTest(2002, 8, null);
}
public void testNormalString() throws Exception {
runPassTest("9999-12");
}
public void testNormalString2() throws Exception {
// check for leading zeros in toString().
runPassTest("0001-01Z");
}
public void testNegativeYear() throws Exception {
runPassTest(-1955, 4, null);
}
public void testNegativeYearString() throws Exception {
runPassTest("-1955-04+05:00");
}
public void testNegativeYearString2() throws Exception {
// negative year with leading zeros
runPassTest("-0055-04+05:00");
}
public void testBigYear() throws Exception {
// Big year should be allowed (per Schema, not ISO).
runPassTest(12000, 4, null);
}
public void testBigYearString() throws Exception {
runPassTest("-27000-04+05:00");
}
/**
* Test that a bad year fails
* Schema says the year can have any number of digits
*/
public void testBadYear() throws Exception {
runFailTest(0, 7, null);
}
public void testBadYearString() throws Exception {
runFailTest("0000-7");
}
/**
* Test that a bad month fails
*/
public void testBadMonth() throws Exception {
runFailTest(1999, 13, null);
}
public void testBadMonthString() throws Exception {
runFailTest("1999-13");
}
/**
* Test that a bad timezone fails
*/
public void testBadTimezone() throws Exception {
runFailTest(1966, 7, "badzone");
}
public void testBadTimezoneString() throws Exception {
runFailTest("1966-07+EDT");
}
/**
* Test that a year at MaxInclusive succeeds
*/
public void testMaxYear() throws Exception {
runPassTest(9999, 1, null);
}
}
| 7,160 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/types/TestNCName.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.types;
import junit.framework.TestCase;
import org.apache.axis.types.NCName;
/**
* Test validation of types.NCName
*/
public class TestNCName extends TestCase {
/**
* Run a failure test. value should be invalid.
*/
private void runFailTest(String value) throws Exception {
NCName oToken = null;
try {
oToken = new NCName(value);
}
catch (Exception e) { // catch the validation exception
}
assertNull(
"NCName validation restriction failed. did not restrict bad value [" +
value + "] did not restrict bad value", oToken);
}
/**
* Run a successful test. value should be valid.
*/
private void runPassTest(String value) throws Exception {
NCName oToken = null;
try {
oToken = new NCName(value);
}
catch (Exception e) { // catch the validation exception
}
assertEquals("NCName strings not equal. orig value:" + value, oToken.toString(), value);
}
/**
* Test a simple string.
*/
public void testSimpleString() throws Exception {
runPassTest("Atlanta");
}
/**
* Test a simple string with allowed punctuation.
*/
public void testPunctuationString() throws Exception {
runPassTest("Atlanta_Braves.Home-Team10");
}
/**
* Test a start character '_'
*/
public void testStartUnderscore() throws Exception {
runPassTest("_Braves");
}
/**
* Test a simple string with allowed punctuation.
*/
public void testMidColon() throws Exception {
runFailTest("Atlanta:_Braves.Home-Team10");
}
/**
* Test a start Digit
*/
public void testStartDigit() throws Exception {
runFailTest("1_Braves");
}
/**
* Test a start character ':'
*/
public void testStartColon() throws Exception {
runFailTest(":_Braves.Home-Team:1");
}
/**
* this is to differentiate from normalized string which cannot accept a \n
*/
public void testLineFeed() throws Exception {
runFailTest("line one\n line two");
}
/**
* this is to differentiate from normalized string which cannot accept a \t
*/
public void testStringWithTabs() throws Exception {
runFailTest("this has \t a tab");
}
/**
* this is to differentiate from normalized string which cannot accept leading spaces.
*/
public void testStringWithLeadingSpaces() throws Exception {
runFailTest(" a failure case");
}
/**
* this is to differentiate from normalized string which cannot accept trailing spaces.
*/
public void testStringWithTrailingSpaces() throws Exception {
runFailTest("this is a ");
}
/**
* this is to differentiate from normalized string which cannot accept
* leading and trailing spaces.
*/
public void testStringWithLeadingAndTrailingSpaces() throws Exception {
runFailTest(" centered ");
}
/**
* this is to differentiate from normalized string which cannot accept double spaces.
*/
public void testDoubleSpace() throws Exception {
runFailTest("a B"); // note: \r fails
}
}
| 7,161 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/servicedesc/CustomFault.java | /*
* Copyright 2002-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.servicedesc;
public class CustomFault extends BaseFault {
}
| 7,162 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/servicedesc/TestServiceDesc.java | /*
* Copyright 2002-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.servicedesc;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import junit.framework.TestCase;
import org.apache.axis.description.JavaServiceDesc;
import org.apache.axis.description.OperationDesc;
import org.apache.axis.encoding.DefaultTypeMappingImpl;
public class TestServiceDesc extends TestCase {
public void testFaultSynch() throws Exception {
JavaServiceDesc desc = new JavaServiceDesc();
desc.setTypeMapping(DefaultTypeMappingImpl.getSingletonDelegate());
desc.loadServiceDescByIntrospection(ServiceClass.class);
OperationDesc[] operations = (OperationDesc[])desc.getOperations().toArray(new OperationDesc[0]);
Arrays.sort(operations, new Comparator() {
public int compare(Object o1, Object o2) {
return ((OperationDesc)o1).getName().compareTo(((OperationDesc)o2).getName());
}
});
assertTrue(operations != null);
assertEquals("invalid number of registered operations",
2, operations.length);
OperationDesc operation;
List faults;
operation = operations[0];
assertEquals("doIt1", operation.getName());
faults = operation.getFaults();
assertTrue(faults != null);
assertEquals("invalid number of registered faults",
2, faults.size());
operation = operations[1];
assertEquals("doIt2", operation.getName());
faults = operation.getFaults();
assertTrue(faults != null);
assertEquals("invalid number of registered faults",
2, faults.size());
}
}
| 7,163 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/servicedesc/ServiceClass.java | /*
* Copyright 2002-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.servicedesc;
import java.rmi.RemoteException;
public class ServiceClass {
public void doIt1(String in)
throws RemoteException, BaseFault, CustomFault {
}
public void doIt2(String in)
throws RemoteException, CustomFault, BaseFault {
}
}
| 7,164 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/servicedesc/BaseFault.java | /*
* Copyright 2002-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.servicedesc;
import org.apache.axis.AxisFault;
public class BaseFault extends AxisFault {
}
| 7,165 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/faults/FaultEncode.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.faults;
import junit.framework.TestCase;
import org.apache.axis.AxisFault;
import org.apache.axis.Message;
import org.apache.axis.MessageContext;
import org.apache.axis.server.AxisServer;
/**
* This class tests Fault deserialization.
*
* @author Sam Ruby (rubys@us.ibm.com)
*/
public class FaultEncode extends TestCase {
public FaultEncode(String name) {
super(name);
} // ctor
public void testFault() throws Exception {
AxisFault fault = new AxisFault("<code>", "<string>", "<actor>", null);
fault.setFaultDetailString("<detail>");
AxisServer server = new AxisServer();
Message message = new Message(fault);
message.setMessageContext(new MessageContext(server));
String data = message.getSOAPPartAsString();
assertTrue("Fault code not encoded correctly",
data.indexOf("<code>")>=0);
assertTrue("Fault string not encoded correctly",
data.indexOf("<string>")>=0);
assertTrue("Fault actor not encoded correctly",
data.indexOf("<actor>")>=0);
assertTrue("Fault detail not encoded correctly",
data.indexOf("<detail>")>=0);
} // testFault
}
| 7,166 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/faults/TestBeans.java | /*
* Copyright 2002-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.faults;
import org.apache.axis.client.Call;
import org.apache.axis.encoding.TypeMapping;
import org.apache.axis.encoding.ser.BeanDeserializerFactory;
import org.apache.axis.encoding.ser.BeanSerializerFactory;
import org.apache.axis.constants.Style;
import org.apache.axis.Constants;
import org.apache.axis.AxisFault;
import test.GenericLocalTest;
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
/**
* Confirm that faults using beans work
*/
public class TestBeans extends GenericLocalTest {
private QName TYPE_QNAME = new QName("ns", "dataType");
protected void setUp() throws Exception {
super.setUp(false); // don't deploy here
TypeMapping tm = (TypeMapping)config.getTypeMappingRegistry().
getDefaultTypeMapping();
tm.register(BeanFault.class, TYPE_QNAME,
new BeanSerializerFactory(BeanFault.class, TYPE_QNAME),
new BeanDeserializerFactory(BeanFault.class, TYPE_QNAME));
deploy("service", this.getClass(), Style.WRAPPED);
//tm.register(BeanFault2.class, TYPE_QNAME,
// new BeanSerializerFactory(BeanFault2.class, TYPE_QNAME),
// new BeanDeserializerFactory(BeanFault2.class, TYPE_QNAME));
}
public void testBeanFault() throws Exception {
Call call = getCall();
call.setOperationStyle("wrapped");
call.setOperationUse("literal");
call.setEncodingStyle("");
call.registerTypeMapping(BeanFault.class, TYPE_QNAME,
new BeanSerializerFactory(BeanFault.class, TYPE_QNAME),
new BeanDeserializerFactory(BeanFault.class, TYPE_QNAME));
call.setReturnClass(BeanFault.class);
call.addParameter("arg0", Constants.XSD_STRING, ParameterMode.IN);
String data = "bean fault test - 1";
try {
call.invoke("echoString", new Object [] { data });
} catch (AxisFault af){
assertNotNull(af.detail);
assertEquals(BeanFault.class,af.detail.getClass());
assertEquals(data,((BeanFault)af.detail).getMessage());
return;
}
fail("did not catch fault");
}
public void testBeanFault2() throws Exception {
Call call = getCall();
call.setOperationStyle("wrapped");
call.setOperationUse("literal");
call.setEncodingStyle("");
call.registerTypeMapping(BeanFault2.class, TYPE_QNAME,
new BeanSerializerFactory(BeanFault2.class, TYPE_QNAME),
new BeanDeserializerFactory(BeanFault2.class, TYPE_QNAME));
call.setReturnClass(BeanFault2.class);
call.addParameter("arg0", Constants.XSD_STRING, ParameterMode.IN);
String data = "bean fault test - 2";
try {
call.invoke("echoString2", new Object [] { data });
} catch (AxisFault af){
assertNotNull(af.detail);
assertEquals(BeanFault2.class,af.detail.getClass());
assertEquals(data,((BeanFault2)af.detail).getMessage());
return;
}
fail("did not catch fault");
}
public String echoString(String data) throws BeanFault {
BeanFault f = new BeanFault();
f.setMessage(data);
throw f;
}
public String echoString2(String data) throws BeanFault2 {
BeanFault2 f = new BeanFault2(data);
throw f;
}
}
| 7,167 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/faults/FaultDecode.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.faults;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import junit.textui.TestRunner;
import org.apache.axis.AxisFault;
import org.apache.axis.Message;
import org.apache.axis.MessageContext;
import org.apache.axis.message.SOAPBodyElement;
import org.apache.axis.message.SOAPEnvelope;
import org.apache.axis.message.SOAPFault;
import org.apache.axis.server.AxisServer;
import org.w3c.dom.Element;
import org.w3c.dom.Text;
import javax.xml.namespace.QName;
/**
* This class tests Fault deserialization.
*
* @author Mark Roder <mroder@wamnet.com>
* @author Glen Daniels (gdaniels@apache.org)
*/
public class FaultDecode extends TestCase {
public static final String FAULT_CODE = "Some.FaultCode";
public static final String FAULT_STRING = "This caused a fault";
public static final String DETAIL_ENTRY_TEXT =
"This was a really bad thing";
public FaultDecode(String name) {
super(name);
} // ctor
public static Test suite() {
return new TestSuite(FaultDecode.class);
}
public void testFault() throws Exception {
String messageText = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" soap:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
+ "<soap:Header>"
+ ""
+ "</soap:Header> "
+ "<soap:Body> "
+ " <soap:Fault>"
+ " <faultcode>" + FAULT_CODE + "</faultcode>"
+ " <faultstring>" + FAULT_STRING + "</faultstring>"
+ " <detail><d1>" + DETAIL_ENTRY_TEXT + "</d1></detail>"
+ " </soap:Fault>"
+ "</soap:Body>"
+ "</soap:Envelope>";
AxisServer server = new AxisServer();
Message message = new Message(messageText);
message.setMessageContext(new MessageContext(server));
SOAPEnvelope envelope = (SOAPEnvelope) message.getSOAPEnvelope();
assertNotNull("envelope", envelope);
SOAPBodyElement respBody = envelope.getFirstBody();
assertTrue("respBody should be a SOAPFaultElement", respBody
instanceof SOAPFault);
AxisFault aFault = ((SOAPFault) respBody).getFault();
assertNotNull("Fault should not be null", aFault);
QName faultCode = aFault.getFaultCode();
assertNotNull("faultCode should not be null", faultCode);
assertEquals("faultCode should match",
faultCode.getLocalPart(),
"Some.FaultCode");
String faultString = aFault.getFaultString();
assertNotNull("faultString should not be null", faultString);
assertEquals("faultString should match", faultString,
FAULT_STRING);
Element [] details = aFault.getFaultDetails();
assertNotNull("faultDetails should not be null", details);
assertEquals("details should have exactly one element", details.length,
1);
Element el = details[0];
assertEquals("detail entry tag name should match",
el.getLocalName(), "d1");
Text text = (Text)el.getFirstChild();
assertEquals("detail entry string should match",
text.getData(), DETAIL_ENTRY_TEXT);
} // testFault
public static void main(String[] args) throws Exception {
FaultDecode tester = new FaultDecode("test");
TestRunner runner = new TestRunner();
runner.doRun(tester.suite(), false);
}
}
| 7,168 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/faults/TestSOAPFaultException.java | /*
* Copyright 2002-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.faults;
import junit.framework.TestCase;
import org.apache.axis.AxisFault;
import org.apache.axis.Constants;
import org.apache.axis.Message;
import org.apache.axis.MessageContext;
import org.apache.axis.deployment.wsdd.WSDDConstants;
import org.apache.axis.deployment.wsdd.WSDDDeployment;
import org.apache.axis.deployment.wsdd.WSDDService;
import org.apache.axis.handlers.soap.SOAPService;
import org.apache.axis.message.RPCElement;
import org.apache.axis.message.SOAPBody;
import org.apache.axis.message.SOAPEnvelope;
import org.apache.axis.server.AxisServer;
import org.apache.axis.soap.SOAP11Constants;
import org.apache.axis.soap.SOAPConstants;
import org.apache.axis.transport.local.LocalTransport;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.w3c.dom.Text;
import javax.xml.namespace.QName;
import javax.xml.rpc.soap.SOAPFaultException;
import javax.xml.soap.Detail;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFactory;
/**
* Tests for the conversion of a JAX-RPC SOAPFaultException to an AxisFault
*
* @author Thomas Bayer (bayer@oio.de)
*/
public class TestSOAPFaultException extends TestCase {
private static final SOAPConstants soapConsts = new SOAP11Constants();
private static final QName QNAME_FAULT_SERVER_USER = new QName(soapConsts.getEnvelopeURI(), Constants.FAULT_SERVER_USER);
private static final String SERVICE_NAME = "FailingService";
/**
* Tests the defaults generated from a SOAPFaultException
*/
public void testDefaults() {
SOAPFaultException soapFaultException = new SOAPFaultException(null, null, null, null);
AxisFault axisFault = AxisFault.makeFault(soapFaultException);
assertEquals(QNAME_FAULT_SERVER_USER, axisFault.getFaultCode());
assertNotNull(axisFault.getFaultString());
}
/**
* Tests if an AxisFault is initialized with the values from a SOAPFaultException
*/
public void testMakeFaultOutOfSOAPFaultException() {
QName faultcode = new QName(soapConsts.getEnvelopeURI(), "Server.MySubClass");
SOAPFaultException soapFaultException = new SOAPFaultException(faultcode, "MyFaultString", "http://myactor", null);
AxisFault axisFault = AxisFault.makeFault(soapFaultException);
assertEquals(faultcode, axisFault.getFaultCode());
}
/**
* Tests if SOAP fault details are passed to AxisFault objects
*/
public void testDetails() {
SOAPFaultException soapFaultException = new SOAPFaultException(QNAME_FAULT_SERVER_USER, "MyFaultString", "http://myactor", getTestDetail());
AxisFault axisFault = AxisFault.makeFault(soapFaultException);
assertNotNull(axisFault.getFaultDetails());
checkDetailAgainstTestDetail(axisFault);
}
/**
* Tests if a SOAPFaultException can be thrown from within a service
* method and the faultcode, faultstring and detail are passed to
* the AxisFault object.
* @throws Exception
*/
public void testThrowingSOAPFaultExceptionFromServiceMethod() throws Exception {
WSDDDeployment conf = new WSDDDeployment();
WSDDService service = new WSDDService();
service.setName(SERVICE_NAME);
service.setProviderQName(new QName(WSDDConstants.URI_WSDD_JAVA, "RPC"));
service.setParameter("className", this.getClass().getName());
service.setParameter("allowedMethods", "doSth");
service.deployToRegistry(conf);
AxisServer engine = new AxisServer(conf);
LocalTransport transport = new LocalTransport(engine);
transport.setRemoteService(SERVICE_NAME);
// create messageContext
MessageContext mc = new MessageContext(engine);
mc.setService((SOAPService) service.getInstance(conf));
mc.setProperty(MessageContext.TRANS_URL, "local");
// create SOAP envelope
SOAPEnvelope env = new SOAPEnvelope();
SOAPBody body = (SOAPBody) env.getBody();
body.addChildElement(new RPCElement("doSth"));
Message reqMsg = new Message(env);
mc.setRequestMessage(reqMsg);
// invoke the engine and test if the fault contains everything as
try {
engine.invoke(mc);
} catch (AxisFault af) {
checkDetailAgainstTestDetail(af);
}
}
/**
* Service method which is called with an axis engine. Its used to test if a service
* can throw an SOAPFaultException and all the information as faultcode and faultactor
* is passed to the caller
* @throws Exception
*/
public void doSth() throws Exception {
throw new SOAPFaultException(QNAME_FAULT_SERVER_USER, "MyFaultString", "http://myactor", getTestDetail());
}
/**
* Produces a Detail object filled with test data
* @return a Detail object filled with test data
*/
private Detail getTestDetail() {
Detail detail = null;
try {
detail = SOAPFactory.newInstance().createDetail();
detail.addChildElement("MyDetails").addTextNode("hossa");
detail.addChildElement("foo").addChildElement("baz");
} catch (SOAPException e) {
fail("Can't create detail");
}
return detail;
}
/**
* Checks if the AxisFault contains the expected detail elements
*
* @param axisFault
*/
private void checkDetailAgainstTestDetail(AxisFault axisFault) {
Element[] details = axisFault.getFaultDetails();
assertEquals("wrong name for detail element", "MyDetails", details[0].getNodeName());
assertEquals("wrong node value for detail element", "hossa", ((Text) details[0].getChildNodes().item(0)).getData());
assertEquals("wrong name for foo element", "foo", details[1].getNodeName());
boolean found = false;
NodeList childs = details[1].getChildNodes();
for (int i = 0; i < childs.getLength(); i++) {
if ("baz".equals(childs.item(i).getNodeName()))
found = true;
}
assertTrue("subelement baz not found in details", found);
}
}
| 7,169 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/faults/BeanFault2.java | package test.faults;
public class BeanFault2 extends Exception {
public BeanFault2(String s)
{
super(s);
message = s;
}
public String getMessage()
{
return message;
}
private String message;
}
| 7,170 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/faults/TestAxisFault.java | /*
* Copyright 2002-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.faults;
import junit.framework.TestCase;
import org.apache.axis.AxisFault;
import org.apache.axis.Constants;
import org.apache.axis.NoEndPointException;
import org.apache.axis.utils.XMLUtils;
import org.w3c.dom.Element;
import org.w3c.dom.Document;
import org.w3c.dom.Text;
import javax.xml.namespace.QName;
import javax.xml.parsers.ParserConfigurationException;
/**
* unit tests for the ubiquitous AxisFault
*/
public class TestAxisFault extends TestCase {
/**
* test that exceptions are filled in
*/
public void testExceptionFillIn() {
Exception e=new Exception("foo");
AxisFault af=AxisFault.makeFault(e);
Element stackTrace;
stackTrace = af.lookupFaultDetail(Constants.QNAME_FAULTDETAIL_STACKTRACE);
assertNotNull(stackTrace);
Element exceptionName;
exceptionName = af.lookupFaultDetail(Constants.QNAME_FAULTDETAIL_EXCEPTIONNAME);
assertNull(exceptionName);
QName faultCode=af.getFaultCode();
assertEquals(faultCode.getLocalPart(), Constants.FAULT_SERVER_USER);
}
/**
* test that making an axis fault from an axis fault retains it
*/
public void testAxisFaultFillIn() {
AxisFault af1=new AxisFault("fault1");
AxisFault af2=AxisFault.makeFault(af1);
assertSame(af1,af2);
}
/**
* test we can remove some detail
*/
public void testDetailRemoval() {
Exception e = new Exception("foo");
AxisFault af = AxisFault.makeFault(e);
assertTrue(af.removeFaultDetail(Constants.QNAME_FAULTDETAIL_STACKTRACE));
Element stackTrace;
stackTrace = af.lookupFaultDetail(Constants.QNAME_FAULTDETAIL_STACKTRACE);
assertNull(stackTrace);
String text=af.getFaultString();
assertNotNull(text);
text=af.toString();
assertNotNull(text);
}
/**
* test what happens with subclasses. We expect the classname to be preserved
* in the details
*/
public void testSubclassProcessing() {
AxisFault af=new NoEndPointException();
Element exceptionName;
exceptionName = af.lookupFaultDetail(Constants.QNAME_FAULTDETAIL_EXCEPTIONNAME);
assertNotNull(exceptionName);
String exceptionClassname= XMLUtils.getInnerXMLString(exceptionName);
assertTrue(exceptionClassname.indexOf("NoEndPointException")>=0);
}
/**
* verify we can properly lookup empty namespace stuff
*/
public void testEmptyNamespaceLookup() {
AxisFault af=new AxisFault();
af.addFaultDetailString("alles geht gut");
Element match=af.lookupFaultDetail(new QName(null,"string"));
assertNotNull(match);
}
public void testArrayAddWorks() {
AxisFault af = new AxisFault();
af.addFaultDetailString("alles geht gut");
Element array[]=new Element[2];
array[0] = createElement("ein","un");
array[1] = createElement("zwei", "deux");
af.setFaultDetail(array);
Element match = af.lookupFaultDetail(new QName(null, "zwei"));
assertNotNull(match);
Element old = af.lookupFaultDetail(new QName(null, "string"));
assertNull(old);
}
public void testEmptyArrayAddWorks() {
AxisFault af = new AxisFault();
af.addFaultDetailString("alles geht gut");
Element array[] = new Element[0];
af.setFaultDetail(array);
Element old = af.lookupFaultDetail(new QName(null, "string"));
assertNull(old);
}
public Element createElement(String tag,String child) {
Document doc = null;
try {
doc = XMLUtils.newDocument();
} catch (ParserConfigurationException e) {
throw new RuntimeException("xml trouble");
}
Element element = doc.createElement(tag);
Text text = doc.createTextNode(child);
element.appendChild(text);
return element;
}
/**
* helper method to stick in when diagnosing stuff
* @param af
*/
private void dumpFault(AxisFault af) {
String s=af.dumpToString();
System.out.println(s);
}
}
| 7,171 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/faults/BeanFault.java | package test.faults;
public class BeanFault extends Exception {
private String message;
public BeanFault() {
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
| 7,172 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/typedesc/ComplexBean3.java | /*
* Copyright 2002-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.typedesc;
import org.apache.axis.description.AttributeDesc;
import org.apache.axis.description.FieldDesc;
import org.apache.axis.description.TypeDesc;
import org.apache.axis.encoding.SimpleType;
import javax.xml.namespace.QName;
public class ComplexBean3 extends SimpleBean2 implements java.io.Serializable {
public String c;
public String d;
private static TypeDesc typeDesc = new TypeDesc(ComplexBean3.class);
static {
FieldDesc fd = new AttributeDesc();
fd.setFieldName("c");
fd.setXmlName(new QName("foo", "c"));
typeDesc.addFieldDesc(fd);
fd = new AttributeDesc();
fd.setFieldName("d");
fd.setXmlName(new QName("foo", "d"));
typeDesc.addFieldDesc(fd);
}
public static TypeDesc getTypeDesc() { return typeDesc; }
public ComplexBean3() {}
public void setC(String value) {
}
public String getC() {
return null;
}
public void setD(String value) {
}
public String getD() {
return null;
}
}
| 7,173 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/typedesc/ComplexBean2.java | /*
* Copyright 2002-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.typedesc;
import org.apache.axis.description.AttributeDesc;
import org.apache.axis.description.FieldDesc;
import org.apache.axis.description.TypeDesc;
import org.apache.axis.encoding.SimpleType;
import javax.xml.namespace.QName;
public class ComplexBean2 extends SimpleBean2 implements java.io.Serializable {
public String c;
public String d;
public String e;
private static TypeDesc typeDesc = new TypeDesc(ComplexBean2.class);
static {
FieldDesc fd = new AttributeDesc();
fd.setFieldName("c");
fd.setXmlName(new QName("foo", "c"));
typeDesc.addFieldDesc(fd);
fd = new AttributeDesc();
fd.setFieldName("d");
fd.setXmlName(new QName("foo", "d"));
typeDesc.addFieldDesc(fd);
fd = new AttributeDesc();
fd.setFieldName("e");
((AttributeDesc)fd).setAttributeName("ffffff");
fd.setXmlName(new QName("foo", "e"));
typeDesc.addFieldDesc(fd);
}
public static TypeDesc getTypeDesc() { return typeDesc; }
public ComplexBean2() {}
public void setC(String value) {
}
public String getC() {
return null;
}
public void setD(String value) {
}
public String getD() {
return null;
}
public void setE(String value) {
}
public String getE() {
return null;
}
}
| 7,174 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/typedesc/TestTypeDescSynch.java | /*
* Copyright 2002-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.typedesc;
import junit.framework.TestCase;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.description.TypeDesc;
import org.apache.axis.encoding.ser.BeanSerializerFactory;
import org.apache.axis.encoding.ser.BeanDeserializerFactory;
import javax.xml.namespace.QName;
/**
* Confirm TypeDesc bugs are indeed fixed.
*
* See http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22819 for details
*
* @author gawor@mcs.anl.gov
*/
public class TestTypeDescSynch extends TestCase {
// with won't fail
public void testFields() throws Exception {
TypeDesc desc= TypeDesc.getTypeDescForClass(ComplexBean2.class);
for (int i=0; i < 10; i++) {
desc.getFields(true);
// Check to make sure we keep to the constant 5 fields (this
// used to grow each time we called getFields(true)).
assertEquals(5, desc.getFields().length);
}
}
// this should fail
public void testFields2() throws Exception {
Service service = new Service();
Call call = (Call)service.createCall();
call.registerTypeMapping(ComplexBean3.class,
new QName("foo2", "bar2"),
BeanSerializerFactory.class,
BeanDeserializerFactory.class,
false);
TypeDesc desc= TypeDesc.getTypeDescForClass(ComplexBean3.class);
assertEquals(4, desc.getFields().length);
}
// this might fail
public void testSynch() throws Exception {
int threads = 30;
ThreadTest[] thread = new ThreadTest[threads];
for (int i=0;i<threads;i++) {
thread[i] = new ThreadTest();
thread[i].start();
}
Throwable ex = null;
for (int i=0;i<threads;i++) {
thread[i].join();
if (ex == null && thread[i].getException() != null) {
ex = thread[i].getException();
}
}
// either assertion will fail or ArrayIndexOutOfBoundException will
// be raised (or it might be ok)
TypeDesc desc= TypeDesc.getTypeDescForClass(ComplexBean.class);
assertEquals(6, desc.getFields().length);
if (ex != null) {
fail(ex.getMessage());
}
}
class ThreadTest extends Thread {
Throwable ex = null;
public Throwable getException() {
return this.ex;
}
public void run() {
try {
/*
Service service = new Service();
Call call = (Call)service.createCall();
call.registerTypeMapping(ComplexBean.class,
new QName("foo", "bar"),
BeanSerializerFactory.class,
BeanDeserializerFactory.class,
false);
*/
// this - demonstrates the same problem as above
// just can check the ArrayIndexOutOfBoundsException
BeanSerializerFactory f =
new BeanSerializerFactory(ComplexBean.class,
new QName("foo", "bar"));
} catch (Exception e) {
ex = e;
}
}
}
}
| 7,175 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/typedesc/ComplexBean.java | /*
* Copyright 2002-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.typedesc;
import org.apache.axis.description.AttributeDesc;
import org.apache.axis.description.FieldDesc;
import org.apache.axis.description.TypeDesc;
import org.apache.axis.encoding.SimpleType;
import javax.xml.namespace.QName;
public class ComplexBean extends SimpleBean implements java.io.Serializable {
public String c;
public String d;
public String e;
public String f;
private static TypeDesc typeDesc = new TypeDesc(ComplexBean.class);
static {
FieldDesc fd = new AttributeDesc();
fd.setFieldName("c");
fd.setXmlName(new QName("foo", "c"));
typeDesc.addFieldDesc(fd);
fd = new AttributeDesc();
fd.setFieldName("d");
fd.setXmlName(new QName("foo", "d"));
typeDesc.addFieldDesc(fd);
fd = new AttributeDesc();
fd.setFieldName("e");
((AttributeDesc)fd).setAttributeName("ffffff");
fd.setXmlName(new QName("foo", "e"));
typeDesc.addFieldDesc(fd);
fd = new AttributeDesc();
fd.setFieldName("f");
fd.setXmlName(new QName("foo", "f"));
typeDesc.addFieldDesc(fd);
}
public static TypeDesc getTypeDesc() { return typeDesc; }
public ComplexBean() {}
public void setC(String value) {
}
public String getC() {
return null;
}
public void setD(String value) {
}
public String getD() {
return null;
}
public void setE(String value) {
}
public String getE() {
return null;
}
public void setF(String value) {
}
public String getF() {
return null;
}
}
| 7,176 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/typedesc/SimpleBean.java | /*
* Copyright 2002-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.typedesc;
import org.apache.axis.description.AttributeDesc;
import org.apache.axis.description.FieldDesc;
import org.apache.axis.description.TypeDesc;
import org.apache.axis.encoding.SimpleType;
import javax.xml.namespace.QName;
public class SimpleBean implements java.io.Serializable {
public String a;
public String b;
private static TypeDesc typeDesc = new TypeDesc(SimpleBean.class);
static {
FieldDesc fd = new AttributeDesc();
fd.setFieldName("a");
fd.setXmlName(new QName("foo", "a"));
typeDesc.addFieldDesc(fd);
fd = new AttributeDesc();
fd.setFieldName("b");
fd.setXmlName(new QName("foo", "b"));
typeDesc.addFieldDesc(fd);
}
public static TypeDesc getTypeDesc() { return typeDesc; }
public SimpleBean() {}
public void setA(String value) {
}
public String getA() {
return null;
}
public void setB(String value) {
}
public String getB() {
return null;
}
}
| 7,177 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/typedesc/TestTypesNonBeanCompatible.java | /*
* Copyright 2002-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.typedesc;
import java.util.ArrayList;
import javax.wsdl.Definition;
import javax.wsdl.factory.WSDLFactory;
import org.apache.axis.description.JavaServiceDesc;
import org.apache.axis.description.ServiceDesc;
import org.apache.axis.encoding.DefaultTypeMappingImpl;
import org.apache.axis.encoding.TypeMapping;
import org.apache.axis.wsdl.fromJava.Namespaces;
import org.apache.axis.wsdl.fromJava.Types;
import junit.framework.TestCase;
public class TestTypesNonBeanCompatible extends TestCase {
private Types types;
protected void setUp() throws Exception {
Definition def = WSDLFactory.newInstance().newDefinition();
TypeMapping tm = DefaultTypeMappingImpl.getSingletonDelegate();
Namespaces namespaces = new Namespaces();
ServiceDesc serviceDesc = new JavaServiceDesc();
types = new Types(def, tm, tm, namespaces, "any:name.space", new ArrayList(), serviceDesc);
}
/*
Commented out for now because the suggested patch breaks Object arrays
// Tests for Axis-1720 - http://nagoya.apache.org/jira/browse/AXIS-1720
public void testWriteTypeNonBeanCompatibleOnce() throws Exception {
String schema = types.writeType(Locale.class);
assertEquals("Schema should be null for non-bean-compatible types", null, schema);
}
public void testWriteTypeNonBeanCompatibleTwice() throws Exception {
String schema = types.writeType(Locale.class);
assertEquals("Schema should be null for non-bean-compatible types", null, schema);
schema = types.writeType(Locale.class);
assertEquals("Schema should be null for non-bean-compatible types", null, schema);
}
public void testWriteTypeNonBeanCompatibleDifferent() throws Exception {
String schema = types.writeType(Locale.class);
assertEquals("Schema should be null for non-bean-compatible types", null, schema);
schema = types.writeType(Locale.class);
assertEquals("Schema should be null for non-bean-compatible types", null, schema);
}
*/
public void testWriteObjectType() throws Exception {
String schema = types.writeType(Object.class);
assertNotNull("Schema should NOT be null for Object class", schema);
schema = types.writeType(Object[].class);
assertNotNull("Schema should NOT be be null for Object[] class", schema);
}
}
| 7,178 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/typedesc/SimpleBean2.java | /*
* Copyright 2002-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.typedesc;
import org.apache.axis.description.AttributeDesc;
import org.apache.axis.description.FieldDesc;
import org.apache.axis.description.TypeDesc;
import org.apache.axis.encoding.SimpleType;
import javax.xml.namespace.QName;
public class SimpleBean2 implements java.io.Serializable {
public String a;
public String b;
private static TypeDesc typeDesc = new TypeDesc(SimpleBean2.class);
static {
FieldDesc fd = new AttributeDesc();
fd.setFieldName("a");
fd.setXmlName(new QName("foo", "a"));
typeDesc.addFieldDesc(fd);
fd = new AttributeDesc();
fd.setFieldName("b");
fd.setXmlName(new QName("foo", "b"));
typeDesc.addFieldDesc(fd);
}
public static TypeDesc getTypeDesc() { return typeDesc; }
public SimpleBean2() {}
public void setA(String value) {
}
public String getA() {
return null;
}
public void setB(String value) {
}
public String getB() {
return null;
}
}
| 7,179 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/providers/WSDDDummyProvider.java | /*
* Copyright 2002-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.providers;
import org.apache.axis.*;
import org.apache.axis.deployment.wsdd.*;
import org.apache.axis.deployment.wsdd.WSDDProvider;
/**
* Factory for WSDDProvider
*/
public class WSDDDummyProvider extends WSDDProvider {
public static final String NAME = "DUMMY";
public Handler newProviderInstance(
WSDDService arg0,
EngineConfiguration arg1)
throws Exception {
return new DummyProvider();
}
public String getName() {
return NAME;
}
}
| 7,180 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/providers/DummyProvider.java | /*
* Copyright 2002-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.providers;
import org.apache.axis.*;
import org.apache.axis.handlers.soap.SOAPService;
import org.apache.axis.message.SOAPEnvelope;
import org.apache.axis.providers.BasicProvider;
/**
* Provider for the testGenerateWSDL method in TestBasicProvider
*/
public class DummyProvider extends BasicProvider {
public void initServiceDesc(
SOAPService service,
MessageContext msgContext)
throws AxisFault {
}
public void invoke(MessageContext msgContext)
throws AxisFault {
Message requestMessage = msgContext.getRequestMessage();
SOAPEnvelope requestEnvelope =
requestMessage.getSOAPEnvelope();
Message responseMessage = new Message(requestEnvelope);
msgContext.setResponseMessage(responseMessage);
}
}
| 7,181 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/providers/TestBasicProvider.java | /*
* Copyright 2002-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.providers;
import javax.wsdl.*;
import javax.wsdl.Definition;
import javax.wsdl.Input;
import javax.wsdl.Operation;
import javax.wsdl.PortType;
import javax.wsdl.factory.WSDLFactory;
import javax.xml.namespace.QName;
import org.apache.axis.MessageContext;
import org.apache.axis.configuration.XMLStringProvider;
import org.apache.axis.deployment.wsdd.WSDDConstants;
import org.apache.axis.deployment.wsdd.WSDDProvider;
import org.apache.axis.handlers.soap.SOAPService;
import org.apache.axis.providers.BasicProvider;
import org.apache.axis.server.AxisServer;
import org.apache.axis.transport.local.LocalTransport;
import org.w3c.dom.Document;
import junit.framework.TestCase;
/**
* Test if BasicProvider can generate WSDL out of metainformation provided in the
* WSDD descriptor.
*
* @author Thomas Bayer (bayer@oio.de)
*
*/
public class TestBasicProvider extends TestCase {
static final QName PROVIDERQNAME = new QName( WSDDConstants.URI_WSDD_JAVA, WSDDDummyProvider.NAME);
static final String TNS = "http://axis.apache.org/test/provider/";
static final String SERVICE_NAME = "DummyProviderService";
static final String PORTTYPE = "DummyPort";
static final QName PORTTYPEQNAME = new QName( TNS, PORTTYPE);
private static AxisServer server;
static final String wsdd =
"<deployment xmlns=\"" + WSDDConstants.URI_WSDD + "\" "
+ "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" "
+ "xmlns:java=\"" + WSDDConstants.URI_WSDD_JAVA + "\">\n"
+ " <service name=\"" + SERVICE_NAME + "\" provider=\"java:DUMMY\">\n"
+ " <parameter name=\"className\" value=\"" + TestBasicProvider.class.getName() + "\"/>"
+ " <parameter name=\"wsdlPortType\" value=\"" + PORTTYPE + "\"/>"
+ " <parameter name=\"wsdlTargetNamespace\" value=\"" + TNS + "\"/>"
+ " <operation name=\"method1\">"
+ " <parameter name=\"param1\" type=\"xsd:string\"/>"
+ " </operation>"
+ " </service>\n"
+ "</deployment>";
protected void setUp() throws Exception {
server = new AxisServer(new XMLStringProvider(wsdd));
LocalTransport transport;
transport = new LocalTransport(server);
transport.setRemoteService(SERVICE_NAME);
WSDDProvider.registerProvider( PROVIDERQNAME, new WSDDDummyProvider());
}
public void testGenerateWSDL() throws Exception {
SOAPService soapService = server.getService(SERVICE_NAME);
BasicProvider provider = (BasicProvider) soapService.getPivotHandler();
MessageContext mc = new MessageContext(server);
mc.setService(soapService);
mc.setProperty(MessageContext.TRANS_URL, "local");
provider.generateWSDL(mc);
Document wsdl = (Document) mc.getProperty("WSDL");
assertNotNull( "cannot create WSDL", wsdl);
Definition def = WSDLFactory.newInstance().newWSDLReader().readWSDL( null, wsdl);
PortType portType = def.getPortType( PORTTYPEQNAME);
assertNotNull( "cannot find porttype " + PORTTYPEQNAME, portType);
Operation operation = portType.getOperation( "method1", null, null);
assertNotNull( "cannot find operation ", operation);
Input input = operation.getInput();
javax.wsdl.Message message = def.getMessage( new QName( TNS, input.getName()));
assertNotNull( "cannot find message " + input.getName(), message);
Part part = message.getPart("param1");
assertEquals( "wrong type for part", part.getTypeName().getLocalPart(), "string");
}
}
| 7,182 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/outparams/ServiceHandler.java | /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.outparams;
import org.apache.axis.AxisFault;
import org.apache.axis.Message;
import org.apache.axis.MessageContext;
import org.apache.axis.handlers.BasicHandler;
import org.apache.axis.message.RPCElement;
import org.apache.axis.message.RPCParam;
import org.apache.axis.message.SOAPEnvelope;
public class ServiceHandler extends BasicHandler {
public static final String OUTPARAM1 = "Output param value";
public static final Float OUTPARAM2 = new Float(4.56);
public static final Integer RESPONSE = new Integer(5);
public void invoke(MessageContext msgContext) throws AxisFault {
SOAPEnvelope env = new SOAPEnvelope();
RPCParam retVal = new RPCParam("return", RESPONSE);
RPCParam outParam1 = new RPCParam("out1", OUTPARAM1);
RPCParam outParam2 = new RPCParam("out2", OUTPARAM2);
RPCElement rpc = new RPCElement("namespace", "response", new Object []
{ retVal, outParam1, outParam2 });
env.addBodyElement(rpc);
msgContext.setResponseMessage(new Message(env));
}
}
| 7,183 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/outparams/TestOutParams.java | package test.outparams;
import junit.framework.TestCase;
import org.apache.axis.Constants;
import org.apache.axis.Handler;
import org.apache.axis.Message;
import org.apache.axis.MessageContext;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.configuration.SimpleProvider;
import org.apache.axis.encoding.XMLType;
import org.apache.axis.handlers.soap.SOAPService;
import org.apache.axis.message.SOAPEnvelope;
import org.apache.axis.server.AxisServer;
import org.apache.axis.transport.local.LocalTransport;
import javax.xml.namespace.QName;
import java.util.Map;
/**
* Test org.apache.axis.handlers.RPCDispatcher
*
* @author Sam Ruby <rubys@us.ibm.com>
*/
public class TestOutParams extends TestCase {
private final String serviceURN = "urn:X-test-outparams";
/** A fixed message, since the return is hardcoded */
private final String message =
"<?xml version=\"1.0\"?>\n" +
"<soap:Envelope " +
"xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" " +
"xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\" " +
"xmlns:xsi=\"" + Constants.URI_DEFAULT_SCHEMA_XSI + "\" " +
"xmlns:xsd=\"" + Constants.URI_DEFAULT_SCHEMA_XSD + "\">\n" +
"<soap:Body>\n" +
"<ns:someMethod xmlns:ns=\"" + serviceURN + "\"/>\n" +
"</soap:Body>\n" +
"</soap:Envelope>\n";
private Service s_service = null ;
private Call client = null ;
private SimpleProvider provider = new SimpleProvider();
private AxisServer server = new AxisServer(provider);
public TestOutParams(String name) {
super(name);
server.init();
}
/**
* Test returning output params
*/
public void testOutputParams() throws Exception {
// Register the service
Handler h = new ServiceHandler();
s_service = new Service();
client = (Call) s_service.createCall();
// ??? Do we need to register the handler?
SOAPService service = new SOAPService(h);
provider.deployService(serviceURN, service);
// Make sure the local transport uses the server we just configured
client.setTransport(new LocalTransport(server));
// Create the message context
MessageContext msgContext = new MessageContext(server);
// Construct the soap request
SOAPEnvelope envelope = new SOAPEnvelope();
msgContext.setRequestMessage(new Message(envelope));
client.addParameter(
new QName("", "string"),
XMLType.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);
client.addParameter(
new QName("", "out1"),
XMLType.XSD_STRING,
javax.xml.rpc.ParameterMode.OUT);
client.addParameter(
new QName("", "out2"),
XMLType.XSD_FLOAT,
javax.xml.rpc.ParameterMode.OUT);
client.setReturnType(XMLType.XSD_INT);
// Invoke the Axis server
Object ret = client.invoke(serviceURN, "method",
new Object [] { "test" });
Map outParams = client.getOutputParams();
assertNotNull("No output Params returned!", outParams);
Object param = outParams.get(new QName(null, "out1"));
assertEquals("Param out1 does not equal expected value", ServiceHandler.OUTPARAM1, param);
param = outParams.get(new QName(null, "out2"));
assertEquals("Param out2 does not equal expected value", ServiceHandler.OUTPARAM2, param);
assertEquals("Return value does not equal expected value", ((Integer)ret).intValue(), ServiceHandler.RESPONSE.intValue());
}
public static void main(String args[])
{
try {
TestOutParams tester = new TestOutParams("RPC test");
tester.testOutputParams();
} catch (Exception e) {
e.printStackTrace();
}
}
}
| 7,184 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/RPCDispatch/TestSerializedRPC.java | package test.RPCDispatch;
import junit.framework.TestCase;
import org.apache.axis.AxisFault;
import org.apache.axis.Constants;
import org.apache.axis.Message;
import org.apache.axis.MessageContext;
import org.apache.axis.configuration.SimpleProvider;
import org.apache.axis.description.OperationDesc;
import org.apache.axis.description.JavaServiceDesc;
import org.apache.axis.encoding.TypeMapping;
import org.apache.axis.encoding.TypeMappingRegistry;
import org.apache.axis.encoding.ser.BeanDeserializerFactory;
import org.apache.axis.encoding.ser.BeanSerializerFactory;
import org.apache.axis.handlers.soap.SOAPService;
import org.apache.axis.message.RPCElement;
import org.apache.axis.message.RPCParam;
import org.apache.axis.message.SOAPEnvelope;
import org.apache.axis.providers.java.RPCProvider;
import org.apache.axis.server.AxisServer;
import org.xml.sax.SAXException;
import javax.xml.namespace.QName;
import java.util.Vector;
import org.custommonkey.xmlunit.XMLTestCase;
import org.apache.axis.AxisEngine;
/**
* Test org.apache.axis.handlers.RPCDispatcher
*
* @author Sam Ruby <rubys@us.ibm.com>
*/
public class TestSerializedRPC extends XMLTestCase {
private final String header =
"<?xml version=\"1.0\"?>\n" +
"<soap:Envelope " +
"xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" " +
"xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\" " +
"xmlns:xsi=\"" + Constants.URI_DEFAULT_SCHEMA_XSI + "\" " +
"xmlns:xsd=\"" + Constants.URI_DEFAULT_SCHEMA_XSD + "\">\n" +
"<soap:Body>\n";
private final String footer =
"</soap:Body>\n" +
"</soap:Envelope>\n";
private SimpleProvider provider = new SimpleProvider();
private AxisServer engine = new AxisServer(provider);
QName firstParamName = null;
QName secondParamName = null;
private String SOAPAction = "urn:reverse";
public TestSerializedRPC(String name) throws Exception {
super(name);
engine.init();
// And deploy the type mapping
Class javaType = Data.class;
QName xmlType = new QName("urn:foo", "Data");
BeanSerializerFactory sf = new BeanSerializerFactory(javaType, xmlType);
BeanDeserializerFactory df = new BeanDeserializerFactory(javaType, xmlType);
TypeMappingRegistry tmr = engine.getTypeMappingRegistry();
TypeMapping tm =
tmr.getOrMakeTypeMapping(Constants.URI_DEFAULT_SOAP_ENC);
tm.register(javaType, xmlType, sf, df);
// Register the reverseString service
SOAPService reverse = new SOAPService(new RPCProvider());
reverse.setOption("className", "test.RPCDispatch.Service");
reverse.setOption("allowedMethods", "*");
JavaServiceDesc desc = new JavaServiceDesc();
desc.loadServiceDescByIntrospection(Service.class, tm);
reverse.setServiceDescription(desc);
provider.deployService(SOAPAction, reverse);
// Now we've got the service description loaded up. We're going to
// be testing parameter dispatch by name, so if debug info isn't
// compiled into the Service class, the names are going to be "in0",
// etc. Make sure they match.
OperationDesc oper = desc.getOperationByName("concatenate");
assertNotNull(oper);
firstParamName = oper.getParameter(0).getQName();
secondParamName = oper.getParameter(1).getQName();
}
/**
* Invoke a given RPC method, and return the result
* @param method action to be performed
* @param bodyStr XML body of the request
* @return Deserialized result
*/
private final Object rpc(String method, String bodyStr,
boolean setService)
throws AxisFault, SAXException
{
// Create the message context
MessageContext msgContext = new MessageContext(engine);
// Set the dispatch either by SOAPAction or methodNS
String methodNS = "urn:dont.match.me";
if (setService) {
msgContext.setTargetService(SOAPAction);
} else {
methodNS = SOAPAction;
}
String bodyElemHead = "<m:" + method + " xmlns:m=\"" +
methodNS + "\">";
String bodyElemFoot = "</m:" + method + ">";
// Construct the soap request
String msgStr = header + bodyElemHead + bodyStr +
bodyElemFoot + footer;
msgContext.setRequestMessage(new Message(msgStr));
msgContext.setTypeMappingRegistry(engine.getTypeMappingRegistry());
// Invoke the Axis engine
engine.invoke(msgContext);
// Extract the response Envelope
Message message = msgContext.getResponseMessage();
assertNotNull("Response message was null!", message);
SOAPEnvelope envelope = message.getSOAPEnvelope();
assertNotNull("SOAP envelope was null", envelope);
// Extract the body from the envelope
RPCElement body = (RPCElement)envelope.getFirstBody();
assertNotNull("SOAP body was null", body);
// Extract the list of parameters from the body
Vector arglist = body.getParams();
assertNotNull("SOAP argument list was null", arglist);
assertTrue("param.size()<=0 {Should be > 0}", arglist.size()>0);
// Return the first parameter
RPCParam param = (RPCParam) arglist.get(0);
return param.getObjectValue();
}
/**
* Test a simple method that reverses a string
*/
public void testSerReverseString() throws Exception {
String arg = "<arg0 xsi:type=\"xsd:string\">abc</arg0>";
// invoke the service and verify the result
assertEquals("Did not reverse the string as expected", "cba", rpc("reverseString", arg, true));
}
public void testSerReverseBodyDispatch() throws Exception {
String arg = "<arg0 xsi:type=\"xsd:string\">abc</arg0>";
// invoke the service and verify the result
assertEquals("Did not reverse the string as expected", "cba", rpc("reverseString", arg, false));
}
/**
* Test a method that reverses a data structure
*/
public void testSerReverseData() throws Exception {
// invoke the service and verify the result
String arg = "<arg0 xmlns:foo=\"urn:foo\" xsi:type=\"foo:Data\">";
arg += "<field1>5</field1><field2>abc</field2><field3>3</field3>";
arg += "</arg0>";
Data expected = new Data(3, "cba", 5);
assertEquals("Did not reverse data as expected", expected, rpc("reverseData", arg, true));
}
/**
* Test a method that reverses a data structure
*/
public void testReverseDataWithUntypedParam() throws Exception {
// invoke the service and verify the result
String arg = "<arg0 xmlns:foo=\"urn:foo\">";
arg += "<field1>5</field1><field2>abc</field2><field3>3</field3>";
arg += "</arg0>";
Data expected = new Data(3, "cba", 5);
assertEquals("Did not reverse data as expected", expected, rpc("reverseData", arg, true));
}
/**
* Test out-of-order parameters, using the names to match
*/
public void testOutOfOrderParams() throws Exception {
String body = "<" + secondParamName.getLocalPart() + " xmlns=\""+ secondParamName.getNamespaceURI() + "\">world!</" +
secondParamName.getLocalPart() + ">" +
"<" + firstParamName.getLocalPart() + " xmlns=\""+ firstParamName.getNamespaceURI() + "\">Hello, </" +
firstParamName.getLocalPart() + ">";
String expected = "Hello, world!";
assertEquals("Concatenated value was wrong",
expected,
rpc("concatenate", body, true));
}
/**
* Test DOM round tripping
*/
public void testArgAsDOM() throws Exception {
// invoke the service and verify the result
String arg = "<arg0 xmlns:foo=\"urn:foo\">";
arg += "<field1>5</field1><field2>abc</field2><field3>3</field3>";
arg += "</arg0>";
// invoke the service and verify the result
engine.setOption(AxisEngine.PROP_SEND_XSI, Boolean.FALSE);
assertXMLEqual("Did not echo arg correctly.", arg, rpc("argAsDOM", arg, true).toString());
}
public void testWrappedTypes() throws Exception
{
// boolean
String arg = "<arg0>true</arg0>";
Object expected = Boolean.TRUE;
assertEquals("method test failed with a boolean",
expected,
rpc("testBoolean", arg, true));
// boolean
arg = "<arg0>1</arg0>";
expected = Boolean.TRUE;
assertEquals("method test failed with a boolean",
expected,
rpc("testBoolean", arg, true));
// float
arg = "<arg0>NaN</arg0>";
expected = new Float(Float.NaN);
assertEquals("method test failed with a float",
expected,
rpc("testFloat", arg, true));
arg = "<arg0>INF</arg0>";
expected = new Float(Float.POSITIVE_INFINITY);
assertEquals("method test failed with a float",
expected,
rpc("testFloat", arg, true));
arg = "<arg0>-INF</arg0>";
expected = new Float(Float.NEGATIVE_INFINITY);
assertEquals("method test failed with a float",
expected,
rpc("testFloat", arg, true));
// double
arg = "<arg0>NaN</arg0>";
expected = new Double(Double.NaN);
assertEquals("method test failed with a double",
expected,
rpc("testDouble", arg, true));
arg = "<arg0>INF</arg0>";
expected = new Double(Double.POSITIVE_INFINITY);
assertEquals("method test failed with a double",
expected,
rpc("testDouble", arg, true));
arg = "<arg0>-INF</arg0>";
expected = new Double(Double.NEGATIVE_INFINITY);
assertEquals("method test failed with a double",
expected,
rpc("testDouble", arg, true));
}
/**
* Test overloaded method dispatch without the benefit of xsi:types
*/
public void testOverloadedMethodDispatch() throws Exception
{
// invoke the service for each overloaded method, and verify the results
// boolean
String arg = "<arg0>true</arg0>";
Object expected = Boolean.TRUE;
assertEquals("Overloaded method test failed with a boolean",
expected,
rpc("overloaded", arg, true));
// boolean, string
arg = "<arg0>true</arg0><arg1>hello world</arg1>";
expected = Boolean.TRUE + "hello world";
assertEquals("Overloaded method test failed with boolean, string",
expected,
rpc("overloaded", arg, true));
// string, boolean
arg = "<arg0>hello world</arg0><arg1>true</arg1>";
expected = "hello world" + Boolean.TRUE;
assertEquals("Overloaded method test failed with string, boolean",
expected,
rpc("overloaded", arg, true));
// int
arg = "<arg0>5</arg0>";
expected = new Integer(5);
assertEquals("Overloaded method test failed with an int",
expected,
rpc("overloaded", arg, true));
// int, string
arg = "<arg0>5</arg0><arg1>hello world</arg1>";
expected = 5 + "hello world";
assertEquals("Overloaded method test failed with int, string",
expected,
rpc("overloaded", arg, true));
}
// public void testEncodedArrayConversion() throws Exception {
// String arg = "<arg0>a simple string</arg0>";
// AxisFault fault = (AxisFault)rpc("arrayMethod", arg, true);
// assertTrue("Erroneous conversion occurred!",
// !fault.getFaultString().equals("You shouldn't have called me!"));
// }
}
| 7,185 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/RPCDispatch/Data.java | package test.RPCDispatch;
/**
* Test structure used by the RPCDispatch test
*
* @author Sam Ruby <rubys@us.ibm.com>
*/
public class Data {
// items of the structure. Defined as Objects so as to permit nulls
private int field1;
private String field2;
private int field3;
/**
* null constructor
*/
public Data() {}
/**
* convenience constructor that sets all of the fields
*/
public Data(int field1, String field2, int field3) {
this.field1=field1;
this.field2=field2;
this.field3=field3;
}
/**
* bean getter for field1
*/
public int getField1() {
return field1;
}
/**
* bean setter for field1
*/
public void setField1 (int field1) {
this.field1=field1;
}
/**
* bean getter for field2
*/
public String getField2() {
return field2;
}
/**
* bean setter for field2
*/
public void setField2 (String field2) {
this.field2=field2;
}
/**
* bean getter for field3
*/
public int getField3() {
return field3;
}
/**
* bean setter for field3
*/
public void setField3 (int field3) {
this.field3=field3;
}
/**
* Equality comparison.
*/
public boolean equals(Object object) {
if (!(object instanceof Data)) return false;
Data that= (Data) object;
if (this.field1 != that.field1) return false;
if (this.field3 != that.field3) return false;
if (this.field2 == null) {
if (that.field2 != null) return false;
} else {
if (!this.field2.equals(that.field2)) return false;
}
return true;
};
}
| 7,186 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/RPCDispatch/TestRPC.java | package test.RPCDispatch;
import junit.framework.TestCase;
import org.apache.axis.AxisFault;
import org.apache.axis.Constants;
import org.apache.axis.Message;
import org.apache.axis.MessageContext;
import org.apache.axis.configuration.SimpleProvider;
import org.apache.axis.handlers.soap.SOAPService;
import org.apache.axis.message.RPCElement;
import org.apache.axis.message.RPCParam;
import org.apache.axis.message.SOAPEnvelope;
import org.apache.axis.providers.java.RPCProvider;
import org.apache.axis.server.AxisServer;
import org.xml.sax.SAXException;
import javax.xml.namespace.QName;
import java.util.Vector;
/**
* Test org.apache.axis.handlers.RPCDispatcher
*
* @author Sam Ruby <rubys@us.ibm.com>
*/
public class TestRPC extends TestCase {
private final String header =
"<?xml version=\"1.0\"?>\n" +
"<soap:Envelope " +
"xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" " +
"xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\" " +
"xmlns:xsi=\"" + Constants.URI_DEFAULT_SCHEMA_XSI + "\" " +
"xmlns:xsd=\"" + Constants.URI_DEFAULT_SCHEMA_XSD + "\">\n" +
"<soap:Body>\n";
private final String footer =
"</soap:Body>\n" +
"</soap:Envelope>\n";
private SimpleProvider provider = new SimpleProvider();
private AxisServer engine = new AxisServer(provider);
private String SOAPAction = "urn:reverse";
public TestRPC(String name) {
super(name);
engine.init();
}
/**
* Invoke a given RPC method, and return the result
* @return Deserialized result
*/
private final Object rpc(String method, Object[] parms)
throws AxisFault, SAXException
{
// Create the message context
MessageContext msgContext = new MessageContext(engine);
// Set the dispatch either by SOAPAction or methodNS
String methodNS = null;
msgContext.setTargetService(SOAPAction);
// Construct the soap request
SOAPEnvelope envelope = new SOAPEnvelope();
msgContext.setRequestMessage(new Message(envelope));
RPCElement body = new RPCElement(methodNS, method, parms);
envelope.addBodyElement(body);
// Invoke the Axis engine
engine.invoke(msgContext);
// Extract the response Envelope
Message message = msgContext.getResponseMessage();
envelope = (SOAPEnvelope)message.getSOAPEnvelope();
assertNotNull("SOAP envelope was null", envelope);
// Extract the body from the envelope
body = (RPCElement)envelope.getFirstBody();
assertNotNull("SOAP body was null", body);
// Extract the list of parameters from the body
Vector arglist = body.getParams();
assertNotNull("SOAP argument list was null", arglist);
if (arglist.size()==0) return null;
// Return the first parameter
RPCParam param = (RPCParam) arglist.get(0);
return param.getObjectValue();
}
/**
* Test a simple method that reverses a string
*/
public void testReverseString() throws Exception {
// Register the reverseString service
SOAPService reverse = new SOAPService(new RPCProvider());
reverse.setOption("className", "test.RPCDispatch.Service");
reverse.setOption("allowedMethods", "reverseString");
provider.deployService(new QName(null,SOAPAction), reverse);
// invoke the service and verify the result
assertEquals("Did not reverse the string correctly.", "cba",
rpc("reverseString", new Object[] {"abc"}));
}
/**
* Test a simple method that reverses a string (but fails)
*/
public void testReverseStringThatShouldFail() throws Exception {
try {
// Register the reverseString service
SOAPService reverse = new SOAPService(new RPCProvider());
reverse.setOption("className", "test.RPCDispatch.Service");
reverse.setOption("allowedMethods", "reverseString2");
provider.deployService(new QName(null,SOAPAction), reverse);
// invoke the service and verify the result
rpc("reverseString", new Object[] {"abc"});
throw new junit.framework.AssertionFailedError("Should not reach here");
} catch (AxisFault af){
//This test should cause an exception.
return;
}
}
/**
* Test a simple method that reverses a string (with a comma delimiter
*/
public void testReverseStringWithCommaDelimiter() throws Exception {
// Register the reverseString service
SOAPService reverse = new SOAPService(new RPCProvider());
reverse.setOption("className", "test.RPCDispatch.Service");
reverse.setOption("allowedMethods", "reverseString2,reverseString");
provider.deployService(new QName(null,SOAPAction), reverse);
// invoke the service and verify the result
assertEquals("Did not reverse the string correctly.", "cba", rpc("reverseString", new Object[] {"abc"}));
}
/**
* Test a simple method that reverses a string (with a space delimiter
*/
public void testReverseStringWithSpaceDelimiter() throws Exception {
// Register the reverseString service
SOAPService reverse = new SOAPService(new RPCProvider());
reverse.setOption("className", "test.RPCDispatch.Service");
reverse.setOption("allowedMethods", "reverseString2 reverseString");
provider.deployService(new QName(null,SOAPAction), reverse);
// invoke the service and verify the result
assertEquals("Did not reverse the string correctly.", "cba", rpc("reverseString", new Object[] {"abc"}));
}
/**
* Test a simple method that reverses a string (with a '*'
*/
public void testReverseStringWithStar() throws Exception {
// Register the reverseString service
SOAPService reverse = new SOAPService(new RPCProvider());
reverse.setOption("className", "test.RPCDispatch.Service");
reverse.setOption("allowedMethods", "*");
provider.deployService(new QName(null,SOAPAction), reverse);
// invoke the service and verify the result
assertEquals("Did not reverse the string correctly.", "cba",
rpc("reverseString", new Object[] {"abc"}));
}
/**
* Test a method that reverses a data structure
*/
public void testReverseData() throws Exception {
// Register the reverseData service
SOAPService reverse = new SOAPService(new RPCProvider());
reverse.setOption("className", "test.RPCDispatch.Service");
reverse.setOption("allowedMethods", "reverseData");
provider.deployService(new QName(null, SOAPAction), reverse);
// invoke the service and verify the result
Data input = new Data(5, "abc", 3);
Data expected = new Data(3, "cba", 5);
assertEquals("Did not reverse the data as expected.", expected, rpc("reverseData", new Object[] {input}));
}
/**
* Test a simple method that returns a field from the message context
*/
public void testMessageContextImplicit() throws Exception {
// Register the targetService service
SOAPService tgtSvc = new SOAPService(new RPCProvider());
tgtSvc.setOption("className", "test.RPCDispatch.Service");
tgtSvc.setOption("allowedMethods", "targetServiceImplicit");
provider.deployService(new QName(null, SOAPAction), tgtSvc);
// invoke the service and verify the result
assertEquals("SOAP Action did not equal the targetService.",
SOAPAction, rpc("targetServiceImplicit", new Object[] {}));
}
/**
* Test a simple method that accepts and returns a null
*/
public void testNull() throws Exception {
// Register the echoInt service
SOAPService echoInt = new SOAPService(new RPCProvider());
echoInt.setOption("className", "test.RPCDispatch.Service");
echoInt.setOption("allowedMethods", "echoInt");
provider.deployService(new QName(null, SOAPAction), echoInt);
// invoke the service and verify the result
assertNull("The result was not null as expected.", rpc("echoInt", new Object[] {null}));
}
/**
* Test faults
*/
public void testSimpleFault() throws Exception {
// Register the reverseData service
SOAPService simpleFault = new SOAPService(new RPCProvider());
simpleFault.setOption("className", "test.RPCDispatch.Service");
simpleFault.setOption("allowedMethods", "simpleFault");
provider.deployService(new QName(null, SOAPAction), simpleFault);
try {
rpc("simpleFault", new Object[] {"foobar"});
} catch (AxisFault result) {
assertEquals("faultString was not set correctly.",
"test.RPCDispatch.Service$TestFault: foobar",
result.getFaultString());
return;
}
fail("Did not get an expected fault!");
}
public static void main(String args[])
{
try {
TestRPC tester = new TestRPC("RPC test");
tester.testReverseString();
tester.testReverseData();
tester.testSimpleFault();
tester.testReverseStringThatShouldFail();
tester.testReverseStringWithCommaDelimiter();
tester.testReverseStringWithSpaceDelimiter();
tester.testReverseStringWithStar();
} catch (Exception e) {
e.printStackTrace();
}
}
}
| 7,187 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/RPCDispatch/Service.java | package test.RPCDispatch;
import org.apache.axis.Message;
import org.apache.axis.MessageContext;
import org.apache.axis.AxisFault;
import org.apache.axis.message.RPCElement;
import org.apache.axis.utils.DOM2Writer;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
* Test WebService
*/
public class Service {
/**
* Reverse the order of characters in a string
*/
public String reverseString(String input) throws Exception {
String result = "";
for (int i=input.length(); i>0; ) result+=input.charAt(--i);
return result;
}
/**
* Concatenate two strings - used to test out-of-order parameter
* matching.
*/
public String concatenate(String a1, String a2)
{
return a1 + a2;
}
/**
* Reverse the order of a struct
*/
public Data reverseData(Data input) throws Exception {
Data result = new Data();
result.setField1(input.getField3());
result.setField2(reverseString(input.getField2()));
result.setField3(input.getField1());
return result;
}
/**
* Return the target service (should be this!)
*/
public String targetServiceImplicit() throws Exception {
return MessageContext.getCurrentContext().getTargetService();
}
/**
* Return the target service (should be this!)
*/
public String argAsDOM(Data input) throws Exception {
// get the first parameter
Message message = MessageContext.getCurrentContext().getRequestMessage();
RPCElement body = (RPCElement)message.getSOAPEnvelope().getFirstBody();
NodeList parms = body.getAsDOM().getChildNodes();
Node parm1 = null;
for (int i=0; i<parms.getLength(); i++) {
parm1 = parms.item(i);
if (parm1.getNodeType() == Node.ELEMENT_NODE) break;
}
// convert it to a DOM and back to a string, and return the result.
return DOM2Writer.nodeToString(parm1, true);
}
/**
* Return the value passed (including nulls!)
*/
public Integer echoInt(Integer value) throws Exception {
return value;
}
/**
* Return the boolean and String arguments concatenated
*/
public String overloaded(boolean b, String s)
{
return b + s;
}
/**
* Return the String and boolean arguments concatenated
*/
public String overloaded(String s, boolean b)
{
return s + b;
}
/**
* Return the boolean value passed in
*/
public boolean overloaded(boolean b)
{
return b;
}
/**
* Return the Boolean value passed in
*/
public Boolean testBoolean(Boolean b)
{
return b;
}
/**
* Return the Float value passed in
*/
public Float testFloat(Float b)
{
return b;
}
/**
* Return the Double value passed in
*/
public Double testDouble(Double b)
{
return b;
}
/**
* Return the int passed in (this and the function above test overloaded
* method dispatch)
*/
public int overloaded(int i)
{
return i;
}
/**
* Return the int and String arguments concatenated
*/
public String overloaded(int i, String s)
{
return i + s;
}
/**
* Echo a string array (this is for testing that String->String[]
* conversions do NOT happen when using encoded arrays)
*/
public void arrayMethod(String [] arg) throws AxisFault {
throw new AxisFault("You shouldn't have called me!");
}
/**
* Simple exception to be used in generating faults
*/
class TestFault extends Exception {
TestFault(String msg) throws Exception {
super(msg);
if (msg == null) throw new Exception("default value");
}
}
/**
* Simple fault.
*/
public String simpleFault(String value) throws Exception {
TestFault fault = new TestFault(value);
throw fault;
}
}
| 7,188 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/outparams2/TestOutParams.java | package test.outparams2;
import junit.framework.TestCase;
import org.apache.axis.EngineConfiguration;
import org.apache.axis.Message;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.description.ServiceDesc;
import org.apache.axis.description.OperationDesc;
import org.apache.axis.description.ParameterDesc;
import org.apache.axis.configuration.EngineConfigurationFactoryFinder;
import org.apache.axis.configuration.SimpleProvider;
import org.apache.axis.handlers.soap.SOAPService;
import org.apache.axis.message.SOAPEnvelope;
import org.apache.axis.providers.java.RPCProvider;
import org.apache.axis.server.AxisServer;
import org.apache.axis.transport.local.LocalTransport;
import javax.xml.rpc.holders.StringHolder;
import javax.xml.namespace.QName;
public class TestOutParams extends TestCase {
/** A fixed message, with no parameters */
private final String message =
"<?xml version=\"1.0\"?>\n" +
"<soapenv:Envelope " +
"xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" " +
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
"<soapenv:Body>\n" +
"<ns1:serviceMethod soapenv:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" " +
"xmlns:ns1=\"outParamsTest\"> </ns1:serviceMethod>\n" +
"</soapenv:Body></soapenv:Envelope>\n";
private Service s_service = null ;
private Call client = null ;
private SimpleProvider provider = new SimpleProvider();
private AxisServer server = new AxisServer(provider);
private static boolean called = false;
public TestOutParams(String name) {
super(name);
server.init();
}
public TestOutParams() {
super("Test Out Params");
}
public void testOutputParams() throws Exception {
// Register the service
s_service = new Service();
client = (Call) s_service.createCall();
SOAPService service = new SOAPService(null,
new RPCProvider(),
null);
service.setName("TestOutParamsService");
service.setOption("className", "test.outparams2.TestOutParams");
service.setOption("allowedMethods", "serviceMethod");
EngineConfiguration defaultConfig =
EngineConfigurationFactoryFinder.newFactory().getServerEngineConfig();
SimpleProvider config = new SimpleProvider(defaultConfig);
config.deployService("outParamsTest", service);
provider.deployService("outParamsTest", service);
// Make sure the local transport uses the server we just configured
client.setTransport(new LocalTransport(server));
Message msg = new Message(message, false);
SOAPEnvelope env = msg.getSOAPEnvelope();
// test invocation. test Holder parameter defaults to INOUT type
client.invoke(env);
// method was succesfully invoked
assertTrue(called);
ServiceDesc description = null;
OperationDesc operation = null;
ParameterDesc parameter = null;
description = service.getServiceDescription();
operation = description.getOperationByName("serviceMethod");
parameter = operation.getParamByQName(new QName("", "out1"));
assertEquals(ParameterDesc.INOUT, parameter.getMode());
// Changing output parameter to OUT type.
parameter.setMode(ParameterDesc.OUT);
// rest called
called = false;
// invoke again
client.invoke(env);
assertTrue(this.called);
}
public void serviceMethod(String in1, StringHolder out1) {
called = true;
}
public static void main(String args[])
{
try {
TestOutParams tester = new TestOutParams("OutParams Test");
tester.testOutputParams();
} catch (Exception e) {
e.printStackTrace();
}
}
}
| 7,189 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/outparams2/TestOutParams2.java | package test.outparams2;
import javax.xml.rpc.holders.StringHolder;
import junit.framework.TestCase;
import org.apache.axis.EngineConfiguration;
import org.apache.axis.Message;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.configuration.EngineConfigurationFactoryFinder;
import org.apache.axis.configuration.SimpleProvider;
import org.apache.axis.description.JavaServiceDesc;
import org.apache.axis.description.OperationDesc;
import org.apache.axis.description.ParameterDesc;
import org.apache.axis.description.ServiceDesc;
import org.apache.axis.handlers.soap.SOAPService;
import org.apache.axis.message.SOAPEnvelope;
import org.apache.axis.providers.java.RPCProvider;
import org.apache.axis.server.AxisServer;
import org.apache.axis.transport.local.LocalTransport;
/**
* Test if operation is invoked with parameters in good order when out parameter
* is not the last parameter. <br>
* It makes sure that bug described at
* http://issues.apache.org/jira/browse/AXIS-1975 is corrected.
*
* @author Cedric Chabanois (cchabanois@natsystem.fr)
*/
public class TestOutParams2 extends TestCase {
/** A fixed message, with one parameter */
private final String message = "<?xml version=\"1.0\"?>\n"
+ "<soapenv:Envelope "
+ "xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" "
+ "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" "
+ "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"
+ "<soapenv:Body>\n"
+ "<ns1:serviceMethod soapenv:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" "
+ "xmlns:ns1=\"outParamsTest\"><in1>18</in1></ns1:serviceMethod>\n"
+ "</soapenv:Body></soapenv:Envelope>\n";
private Service s_service = null;
private Call client = null;
private SimpleProvider provider = new SimpleProvider();
private AxisServer server = new AxisServer(provider);
private static boolean called = false;
public TestOutParams2(String name) {
super(name);
server.init();
}
public TestOutParams2() {
super("Test Out Params");
}
public void testOutputParams() throws Exception {
// Register the service
s_service = new Service();
client = (Call) s_service.createCall();
SOAPService service = new SOAPService(null, new RPCProvider(), null);
service.setName("TestOutParamsService");
service.setOption("className", "test.outparams2.TestOutParams2");
service.setOption("allowedMethods", "serviceMethod");
ServiceDesc description = new JavaServiceDesc();
OperationDesc operation = new OperationDesc();
operation.setName("serviceMethod");
ParameterDesc out1 = new ParameterDesc();
out1.setName("out1");
out1.setMode(ParameterDesc.OUT);
operation.addParameter(out1);
ParameterDesc in1 = new ParameterDesc();
in1.setName("in1");
in1.setMode(ParameterDesc.IN);
operation.addParameter(in1);
description.addOperationDesc(operation);
service.setServiceDescription(description);
EngineConfiguration defaultConfig = EngineConfigurationFactoryFinder.newFactory()
.getServerEngineConfig();
SimpleProvider config = new SimpleProvider(defaultConfig);
config.deployService("outParamsTest", service);
provider.deployService("outParamsTest", service);
// Make sure the local transport uses the server we just configured
client.setTransport(new LocalTransport(server));
Message msg = new Message(message, false);
SOAPEnvelope env = msg.getSOAPEnvelope();
// invoke
client.invoke(env);
assertTrue(this.called);
}
public void serviceMethod(StringHolder out1, byte in1) {
called = true;
}
public static void main(String args[]) {
try {
TestOutParams2 tester = new TestOutParams2("OutParams Test");
tester.testOutputParams();
} catch (Exception e) {
e.printStackTrace();
}
}
}
| 7,190 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/soap12/TestHeaderAttrs.java | /*
* Copyright 2002-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @author Glen Daniels (gdaniels@apache.org)
*/
package test.soap12;
import org.apache.axis.soap.SOAPConstants;
public class TestHeaderAttrs extends test.soap.TestHeaderAttrs {
/**
* Use SOAP version 1.2. Otherwise, run the same tests.
*/
public void setUp() throws Exception {
soapVersion = SOAPConstants.SOAP12_CONSTANTS;
super.setUp();
}
}
| 7,191 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/soap12/TestVersionMismatch.java | /*
* Copyright 2002-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @author Andras Avar (andras.avar@nokia.com)
*/
package test.soap12;
import java.lang.reflect.*;
import java.util.*;
import javax.xml.namespace.*;
import junit.framework.*;
import org.apache.axis.*;
import org.apache.axis.encoding.*;
import org.apache.axis.message.*;
import org.apache.axis.server.*;
import org.apache.axis.soap.*;
import org.apache.axis.utils.*;
/**
* Test VersionMismatch fault generation
*/
public class TestVersionMismatch extends TestCase {
private AxisServer server = null;
public TestVersionMismatch(String name) {
super(name);
server = new AxisServer();
}
private final String SOAP_MESSAGE =
"<?xml version=\"1.0\"?>\n" +
"<soap:Envelope " +
"xmlns:soap=\"http://www.w3.org/2002/wrong-envelope-version\" " +
"xmlns:soapenc=\"http://www.w3.org/2003/05/soap-encoding\" " +
"xmlns:this=\"http://encoding.test\" " +
"xmlns:xsi=\"" + Constants.URI_DEFAULT_SCHEMA_XSI + "\" " +
"xmlns:xsd=\"" + Constants.URI_DEFAULT_SCHEMA_XSD + "\">\n" +
"<item xsi:type=\"xsd:string\">abc</item>\n" +
"<soap:Body>\n" +
"<methodResult xmlns=\"http://tempuri.org/\">\n" +
"<hello/>" +
"</methodResult>\n" +
"</soap:Body>\n" +
"</soap:Envelope>\n";
public void testVersionMismatch() throws Exception {
Message message = new Message(SOAP_MESSAGE);
MessageContext context = new MessageContext(server);
context.setSOAPConstants(SOAPConstants.SOAP12_CONSTANTS);
message.setMessageContext(context);
boolean expectedExceptionThrown = false;
try {
SOAPEnvelope envelope = message.getSOAPEnvelope();
} catch (AxisFault af) {
if (Constants.FAULT_VERSIONMISMATCH.equals(af.getFaultCode()))
expectedExceptionThrown = true;
}
assertTrue(expectedExceptionThrown);
}
}
| 7,192 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/soap12/TestFault.java | package test.soap12;
import junit.framework.TestCase;
import org.apache.axis.AxisFault;
import org.apache.axis.Message;
import org.apache.axis.MessageContext;
import org.apache.axis.Constants;
import org.apache.axis.encoding.SerializationContext;
import org.apache.axis.message.SOAPBodyElement;
import org.apache.axis.message.SOAPEnvelope;
import org.apache.axis.message.SOAPFault;
import org.apache.axis.server.AxisServer;
import org.apache.axis.soap.SOAPConstants;
import javax.xml.namespace.QName;
import java.io.StringWriter;
import java.io.Writer;
/**
* A test of soap 1.2 fault serialization and deserialization.
*
* @author Andras Avar (andras.avar@nokia.com)
*/
public class TestFault extends TestCase {
public static final QName FAULTCODE = new QName("http://c","faultcode_c");
public static final QName FAULTSUBCODE[] = { new QName("http://a","subcode_a"),
new QName("http://b","subcode_b") };
public static final String FAULTREASON = "reason";
public static final String FAULTROLE = "role";
public static final String FAULTNODE = "node";
public void testFault() throws Exception
{
// Serialize
MessageContext msgContext = new MessageContext(new AxisServer());
msgContext.setSOAPConstants(SOAPConstants.SOAP12_CONSTANTS);
msgContext.setProperty(Constants.MC_NO_OPERATION_OK, Boolean.TRUE);
SOAPEnvelope msg = new SOAPEnvelope(SOAPConstants.SOAP12_CONSTANTS);
SOAPFault fault = new SOAPFault(new AxisFault(FAULTCODE, FAULTSUBCODE,
FAULTREASON, FAULTROLE,
FAULTNODE, null));
msg.addBodyElement(fault);
Writer stringWriter = new StringWriter();
SerializationContext context =
new SerializationContext(stringWriter, msgContext);
context.setDoMultiRefs(false);
msg.output(context);
String msgString = stringWriter.toString();
// Deserialize and check
AxisServer server = new AxisServer();
Message message = new Message(msgString);
message.setMessageContext(new MessageContext(server));
SOAPEnvelope envelope = message.getSOAPEnvelope();
assertNotNull("envelope should not be null", envelope);
SOAPBodyElement respBody = envelope.getFirstBody();
assertTrue("respBody should be a SOAPFaultElement", respBody
instanceof SOAPFault);
AxisFault aFault = ((SOAPFault) respBody).getFault();
assertNotNull("Fault should not be null", aFault);
assertEquals(FAULTCODE, aFault.getFaultCode());
assertEquals(FAULTREASON, aFault.getFaultReason());
assertEquals(FAULTROLE, aFault.getFaultRole());
assertEquals(FAULTNODE, aFault.getFaultNode());
QName q[] = aFault.getFaultSubCodes();
for (int i = 0; i < q.length; i++)
assertEquals(FAULTSUBCODE[i], q[i]);
}
}
| 7,193 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/soap12/TestSer.java | package test.soap12;
import junit.framework.TestCase;
import org.apache.axis.Constants;
import org.apache.axis.MessageContext;
import org.apache.axis.components.logger.LogFactory;
import org.apache.axis.encoding.DeserializationContext;
import org.apache.axis.encoding.SerializationContext;
import org.apache.axis.encoding.SerializationContext;
import org.apache.axis.encoding.TypeMapping;
import org.apache.axis.encoding.TypeMappingRegistry;
import org.apache.axis.message.RPCElement;
import org.apache.axis.message.RPCParam;
import org.apache.axis.message.SOAPEnvelope;
import org.apache.axis.server.AxisServer;
import org.apache.axis.soap.SOAPConstants;
import org.apache.axis.utils.XMLUtils;
import org.apache.commons.logging.Log;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import test.encoding.Data;
import test.encoding.DataDeserFactory;
import test.encoding.DataSerFactory;
import javax.xml.namespace.QName;
import java.io.StringReader;
import java.io.StringWriter;
import java.io.Writer;
/** Little serialization test with a struct.
*/
public class TestSer extends TestCase {
Log log =
LogFactory.getLog(TestSer.class.getName());
public static final String myNS = "urn:myNS";
public void testDataNoHrefs () throws Exception {
doTestData(false);
}
public void testDataWithHrefs () throws Exception {
doTestData(true);
}
public void doTestData (boolean multiref) throws Exception {
MessageContext msgContext = new MessageContext(new AxisServer());
msgContext.setSOAPConstants(SOAPConstants.SOAP12_CONSTANTS);
msgContext.setProperty(Constants.MC_NO_OPERATION_OK, Boolean.TRUE);
SOAPEnvelope msg = new SOAPEnvelope(SOAPConstants.SOAP12_CONSTANTS);
RPCParam arg1 = new RPCParam("urn:myNamespace", "testParam", "this is a string");
Data data = new Data();
data.stringMember = "String member";
data.floatMember = new Float("4.54");
RPCParam arg2 = new RPCParam("", "struct", data);
RPCElement body = new RPCElement("urn:myNamespace", "method1", new Object[]{ arg1, arg2 });
msg.addBodyElement(body);
Writer stringWriter = new StringWriter();
SerializationContext context = new SerializationContext(stringWriter, msgContext);
context.setDoMultiRefs(multiref);
// Create a TypeMapping and register the specialized Type Mapping
TypeMappingRegistry reg = context.getTypeMappingRegistry();
TypeMapping tm = (TypeMapping) reg.createTypeMapping();
tm.setSupportedEncodings(new String[] {Constants.URI_SOAP12_ENC});
reg.register(Constants.URI_SOAP12_ENC, tm);
QName dataQName = new QName("typeNS", "Data");
tm.register(Data.class, dataQName, new DataSerFactory(), new DataDeserFactory());
msg.output(context);
String msgString = stringWriter.toString();
log.debug("---");
log.debug(msgString);
log.debug("---");
StringReader reader = new StringReader(msgString);
DeserializationContext dser = new DeserializationContext(
new InputSource(reader), msgContext, org.apache.axis.Message.REQUEST);
dser.parse();
SOAPEnvelope env = dser.getEnvelope();
RPCElement rpcElem = (RPCElement)env.getFirstBody();
RPCParam struct = rpcElem.getParam("struct");
assertNotNull("No <struct> param", struct);
Data val = (Data)struct.getObjectValue();
assertNotNull("No value for struct param", val);
assertEquals("Data and Val string members are not equal", data.stringMember, val.stringMember);
assertEquals("Data and Val float members are not equal",data.floatMember.floatValue(),
val.floatMember.floatValue(), 0.00001F);
}
/**
* Test RPC element serialization when we have no MessageContext
*/
public void testRPCElement()
{
try {
SOAPEnvelope env = new SOAPEnvelope();
RPCElement method = new RPCElement("ns",
"method",
new Object [] { "argument" });
env.addBodyElement(method);
String soapStr = env.toString();
} catch (Exception e) {
fail(e.getMessage());
}
// If there was no exception, we succeeded in serializing it.
}
public void testEmptyXMLNS()
{
try {
MessageContext msgContext = new MessageContext(new AxisServer());
msgContext.setSOAPConstants(SOAPConstants.SOAP12_CONSTANTS);
msgContext.setProperty(Constants.MC_NO_OPERATION_OK, Boolean.TRUE);
String req =
"<xsd1:A xmlns:xsd1=\"urn:myNamespace\">"
+ "<xsd1:B>"
+ "<xsd1:C>foo bar</xsd1:C>"
+ "</xsd1:B>"
+ "</xsd1:A>";
StringWriter stringWriter=new StringWriter();
StringReader reqReader = new StringReader(req);
InputSource reqSource = new InputSource(reqReader);
Document document = XMLUtils.newDocument(reqSource);
String msgString = null;
SOAPEnvelope msg = new SOAPEnvelope(SOAPConstants.SOAP12_CONSTANTS);
RPCParam arg1 = new RPCParam("urn:myNamespace", "testParam", document.getFirstChild());
arg1.setXSITypeGeneration(Boolean.FALSE);
RPCElement body = new RPCElement("urn:myNamespace", "method1", new Object[] { arg1 });
msg.addBodyElement(body);
body.setEncodingStyle(Constants.URI_LITERAL_ENC);
SerializationContext context = new SerializationContext(stringWriter, msgContext);
msg.output(context);
msgString = stringWriter.toString();
assertTrue(msgString.indexOf("xmlns=\"\"")==-1);
} catch (Exception e) {
fail(e.getMessage());
}
}
}
| 7,194 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/soap12/TestRPC.java | package test.soap12;
import junit.framework.TestCase;
import org.apache.axis.AxisFault;
import org.apache.axis.Message;
import org.apache.axis.MessageContext;
import org.apache.axis.constants.Use;
import org.apache.axis.configuration.SimpleProvider;
import org.apache.axis.description.ServiceDesc;
import org.apache.axis.handlers.soap.SOAPService;
import org.apache.axis.message.RPCElement;
import org.apache.axis.message.RPCParam;
import org.apache.axis.message.SOAPEnvelope;
import org.apache.axis.providers.java.RPCProvider;
import org.apache.axis.server.AxisServer;
import org.apache.axis.soap.SOAPConstants;
import org.apache.axis.transport.local.LocalTransport;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import java.util.Vector;
/**
* A test for RPC response
*
* @author Andras Avar (andras.avar@nokia.com)
*/
public class TestRPC extends TestCase {
private SimpleProvider provider = new SimpleProvider();
private AxisServer server = new AxisServer(provider);
public TestRPC(String name) {
super(name);
server.init();
}
private RPCElement rpc(String method, Object[] params)
throws AxisFault, SAXException
{
String SERVICE_NAME = "echoservice";
LocalTransport transport = new LocalTransport(server);
SOAPService service = new SOAPService(new RPCProvider());
service.setEngine(server);
service.setOption("className", "test.soap12.Echo");
service.setOption("allowedMethods", "*");
service.setOption("use", Use.ENCODED);
ServiceDesc desc = service.getInitializedServiceDesc(null);
desc.setDefaultNamespace(method);
provider.deployService(SERVICE_NAME, service);
MessageContext msgContext = new MessageContext(server);
msgContext.setSOAPConstants(SOAPConstants.SOAP12_CONSTANTS);
msgContext.setEncodingStyle(SOAPConstants.SOAP12_CONSTANTS.getEncodingURI());
String methodNS = null;
msgContext.setTargetService(SERVICE_NAME);
// Construct the soap request
SOAPEnvelope envelope = new SOAPEnvelope(msgContext.getSOAPConstants());
msgContext.setRequestMessage(new Message(envelope));
RPCElement body = new RPCElement(methodNS, method, params);
envelope.addBodyElement(body);
server.invoke(msgContext);
Message message = msgContext.getResponseMessage();
envelope = (SOAPEnvelope)message.getSOAPEnvelope();
assertNotNull("SOAP envelope was null", envelope);
body = (RPCElement)envelope.getFirstBody();
return body;
}
public void testRPCReturn() throws Exception {
RPCElement body = rpc("echo", new Object[] {"abc"});
assertNotNull("SOAP body was null", body);
// Check RPC result
Vector arglist = body.getParams();
assertNotNull("SOAP argument list was null", arglist);
RPCParam param = (RPCParam) arglist.get(1);
assertTrue("Not expected result", ((String)param.getObjectValue()).equals("abc"));
// Check DOM
Element e = body.getAsDOM();
NodeList l = e.getElementsByTagNameNS("http://www.w3.org/2003/05/soap-rpc","result");
assertTrue("No result element was fount", l.getLength() == 1);
String ptr = l.item(0).getFirstChild().getNodeValue();
assertNotNull("Ptr to the result value was null", ptr);
l = e.getElementsByTagName(ptr);
assertTrue("No return element was fount", l.getLength() == 1);
String res = l.item(0).getFirstChild().getNodeValue();
assertTrue("Not expected result", res.equals("abc"));
}
}
| 7,195 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/soap12/TestDeser.java | package test.soap12;
import junit.framework.TestCase;
import org.apache.axis.Constants;
import org.apache.axis.Message;
import org.apache.axis.MessageContext;
import org.apache.axis.encoding.TypeMapping;
import org.apache.axis.encoding.TypeMappingRegistry;
import org.apache.axis.message.RPCElement;
import org.apache.axis.message.RPCParam;
import org.apache.axis.message.SOAPEnvelope;
import org.apache.axis.server.AxisServer;
import org.apache.axis.soap.SOAPConstants;
import org.apache.axis.utils.JavaUtils;
import org.apache.axis.utils.Messages;
import javax.xml.namespace.QName;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Vector;
/**
* Test deserialization of SOAP responses
*/
public class TestDeser extends TestCase {
private AxisServer server = null;
public TestDeser(String name) {
super(name);
server = new AxisServer();
TypeMappingRegistry tmr = server.getTypeMappingRegistry();
TypeMapping tm = (TypeMapping) tmr.createTypeMapping();
tm.setSupportedEncodings(new String[] {Constants.URI_SOAP12_ENC});
tmr.register(Constants.URI_SOAP12_ENC, tm);
tm.register(java.lang.String[].class,
new QName("http://soapinterop.org/xsd", "ArrayOfString"),
new org.apache.axis.encoding.ser.ArraySerializerFactory(),
new org.apache.axis.encoding.ser.ArrayDeserializerFactory());
}
private final String SOAP_HEAD =
"<?xml version=\"1.0\"?>\n" +
"<soap:Envelope " +
"xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" " +
"xmlns:soapenc=\"http://www.w3.org/2003/05/soap-encoding\" " +
"xmlns:this=\"http://encoding.test\" " +
"xmlns:xsi=\"" + Constants.URI_DEFAULT_SCHEMA_XSI + "\" " +
"xmlns:xsd=\"" + Constants.URI_DEFAULT_SCHEMA_XSD + "\">\n";
private final String ITEM =
"<item xsi:type=\"xsd:string\">abc</item>\n";
private final String BODY_HEAD =
"<soap:Body>\n";
private final String METHOD_HEAD =
"<methodResult xmlns=\"http://tempuri.org/\">\n";
private final String METHOD_TAIL =
"</methodResult>\n";
private final String BODY_TAIL =
"</soap:Body>\n";
private final String SOAP_TAIL =
"</soap:Envelope>\n";
private final String HEAD = SOAP_HEAD + BODY_HEAD + METHOD_HEAD;
private final String TAIL = METHOD_TAIL + BODY_TAIL + SOAP_TAIL;
private static boolean equals(Object obj1, Object obj2) {
if ( (obj1 == null) || (obj2 == null) ) return (obj1 == obj2);
if (obj1.equals(obj2)) return true;
if (obj2.getClass().isArray() && obj1.getClass().isArray()) {
if (Array.getLength(obj1) != Array.getLength(obj2)) return false;
for (int i=0; i<Array.getLength(obj1); i++)
if (!equals(Array.get(obj1,i),Array.get(obj2,i))) return false;
return true;
}
if ((obj1 instanceof List) && (obj2 instanceof List)) {
List list1 = (List)obj1;
List list2 = (List)obj2;
if (list1.size() != list2.size()) return false;
for (int i=0; i < list1.size(); i++) {
if (!equals(list1.get(i), list2.get(i))) return false;
}
return true;
}
if ((obj1 instanceof Map) && (obj2 instanceof Map)) {
Map map1 = (Map)obj1;
Map map2 = (Map)obj2;
Set keys1 = map1.keySet();
Set keys2 = map2.keySet();
if (!(keys1.equals(keys2))) return false;
Iterator i = keys1.iterator();
while (i.hasNext()) {
Object key = i.next();
if (!map1.get(key).equals(map2.get(key)))
return false;
}
return true;
}
return false;
}
public void deserialize(String soap, Object expected, boolean tryConvert) throws Exception {
Message message = new Message(soap);
MessageContext context = new MessageContext(server);
context.setSOAPConstants(SOAPConstants.SOAP12_CONSTANTS);
context.setProperty(Constants.MC_NO_OPERATION_OK, Boolean.TRUE);
message.setMessageContext(context);
SOAPEnvelope envelope = message.getSOAPEnvelope();
assertNotNull("SOAP envelope should not be null", envelope);
RPCElement body = (RPCElement)envelope.getFirstBody();
assertNotNull("SOAP body should not be null", body);
Vector arglist = body.getParams();
assertNotNull("arglist", arglist);
assertTrue("param.size()<=0 {Should be > 0}", arglist.size()>0);
RPCParam param = (RPCParam) arglist.get(0);
assertNotNull("SOAP param should not be null", param);
Object result = param.getObjectValue();
if (!equals(result, expected)) {
// Try to convert to the expected class
if (tryConvert) {
Object result2 = JavaUtils.convert(result, expected.getClass());
if (!equals(result2, expected)) {
assertEquals("The result is not what is expected.", expected, result);
}
} else {
assertEquals("The result is not what is expected.", expected, result);
}
}
}
public void testDeser1() throws Exception {
deserialize(SOAP_HEAD + BODY_HEAD + METHOD_HEAD + ITEM + METHOD_TAIL + BODY_TAIL + SOAP_TAIL, "abc", false);
}
public void testDeser2() throws Exception {
boolean expectedExceptionThrown = false;
try {
deserialize(SOAP_HEAD + BODY_HEAD + METHOD_HEAD + ITEM + METHOD_TAIL + BODY_TAIL + "<hello/>" + SOAP_TAIL, null, false);
} catch (org.apache.axis.AxisFault af) {
String expected = Messages.getMessage("noElemAfterBody12");
if(af.getFaultString().indexOf(expected)!=-1)
expectedExceptionThrown = true;
}
assertTrue(expectedExceptionThrown);
}
public void testAfterBody() throws Exception {
boolean expectedExceptionThrown = false;
try {
deserialize(SOAP_HEAD + BODY_HEAD + METHOD_HEAD + ITEM + METHOD_TAIL + "<hello/>" + BODY_TAIL + SOAP_TAIL, null, false);
} catch (org.apache.axis.AxisFault af) {
// Should drop an ex about soap 1.2 doesn't permit any element after body
String expected = Messages.getMessage("onlyOneBodyFor12");
if(af.getFaultString().indexOf(expected)!=-1)
expectedExceptionThrown = true;
}
assertTrue(expectedExceptionThrown);
}
public void testArray() throws Exception {
Vector v = new Vector();
v.addElement("abc");
v.addElement("def");
deserialize(HEAD +
"<result xsi:type=\"soapenc:Array\" " +
"soapenc:itemType=\"xsd:string\" soapenc:arraySize=\"2\"> " +
"<item xsi:type=\"xsd:string\">abc</item>" +
"<item xsi:type=\"xsd:string\">def</item>" +
"</result>" +
TAIL,
v, true);
}
public void testSparseArray1() throws Exception {
ArrayList list = new ArrayList(4);
list.add(null);
list.add(null);
list.add("abc");
list.add("def");
boolean expectedExceptionThrown = false;
try {
deserialize(HEAD +
"<result xsi:type=\"soapenc:Array\" " +
"soapenc:itemType=\"xsd:string\" soapenc:arraySize=\"4\" " +
" soapenc:offset=\"[2]\">" +
"<item xsi:type=\"xsd:string\">abc</item>" +
"<item xsi:type=\"xsd:string\">def</item>" +
"</result>" +
TAIL,
list, true);
} catch (Exception af) {
String expected = Messages.getMessage("noSparseArray");
if(af.toString().indexOf(expected)!=-1)
expectedExceptionThrown = true;
}
assertTrue(expectedExceptionThrown);
}
public void testSparseArray2() throws Exception {
ArrayList list = new ArrayList(4);
list.add("abc");
list.add(null);
list.add("def");
list.add(null);
boolean expectedExceptionThrown = false;
try {
deserialize(HEAD +
"<result xsi:type=\"soapenc:Array\" " +
"soapenc:itemType=\"xsd:string\" soapenc:arraySize=\"4\">" +
"<item soapenc:position=\"[0]\" xsi:type=\"xsd:string\">abc</item>" +
"<item soapenc:position=\"[2]\" xsi:type=\"xsd:string\">def</item>" +
"</result>" +
TAIL,
list, true);
} catch (Exception af) {
String expected = Messages.getMessage("noSparseArray");
if(af.toString().indexOf(expected)!=-1)
expectedExceptionThrown = true;
}
assertTrue(expectedExceptionThrown);
}
public void testNoSizeDefinedArray() throws Exception {
ArrayList a = new ArrayList();
a.add("abc");
a.add("def");
deserialize(HEAD +
"<result xsi:type=\"soapenc:Array\" " +
"soapenc:itemType=\"xsd:string\" soapenc:arraySize=\"*\">" +
"<item xsi:type=\"xsd:string\">abc</item>" +
"<item xsi:type=\"xsd:string\">def</item>" +
"</result>" +
TAIL,
a, true);
}
}
| 7,196 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/soap12/TestExceptions.java | package test.soap12;
import org.apache.axis.AxisFault;
import org.apache.axis.Constants;
import org.apache.axis.soap.SOAPConstants;
import org.apache.axis.client.Call;
import test.GenericLocalTest;
import javax.xml.namespace.QName;
/**
* Ensure that SOAP 1.2's FAULT_SUBCODE_PROC_NOT_PRESENT is thrown if the method is not found
*/
public class TestExceptions extends GenericLocalTest {
/**
* base test ensure that SOAP1.2 works :)
* @throws Exception
*/
public void testEcho() throws Exception {
Object result = null;
Call call = getCall();
call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS);
result = call.invoke("echo", null);
assertEquals(result.toString(), "hello world");
}
/**
* call a method that does not exist and check if the correct exception
* is thrown from the server.
* @throws Exception
*/
public void testNoSuchProcedure() throws Exception {
Object result = null;
try {
Call call = getCall();
call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS);
result = call.invoke("unknownFreakyMethod", null);
} catch (AxisFault fault){
assertEquals(Constants.FAULT_SOAP12_SENDER, fault.getFaultCode());
QName [] subCodes = fault.getFaultSubCodes();
assertNotNull(subCodes);
assertEquals(1, subCodes.length);
assertEquals(Constants.FAULT_SUBCODE_PROC_NOT_PRESENT, subCodes[0]);
return;
}
fail("Didn't catch expected fault");
}
/**
* Service method. Returns a string
*
* @return a string
*/
public String echo() {
return "hello world";
}
}
| 7,197 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/soap12/Echo.java | package test.soap12;
public class Echo {
public String echo(String text) {
return text;
}
}
| 7,198 |
0 | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test | Create_ds/axis-axis1-java/axis-rt-core/src/test/java/test/soap12/TestHrefs.java | package test.soap12;
import junit.framework.TestCase;
import org.apache.axis.AxisFault;
import org.apache.axis.Constants;
import org.apache.axis.Message;
import org.apache.axis.MessageContext;
import org.apache.axis.message.RPCElement;
import org.apache.axis.message.RPCParam;
import org.apache.axis.message.SOAPEnvelope;
import org.apache.axis.server.AxisServer;
import org.apache.axis.utils.Messages;
import java.util.Vector;
/**
* Test deserialization of SOAP 1.2 messages with references, by putting the
* actual value in various places in the message.
*/
public class TestHrefs extends TestCase {
private String HEAD;
private String HEADERT;
private String BODYT;
public TestHrefs(String name) {
this(name, Constants.URI_DEFAULT_SCHEMA_XSI,
Constants.URI_DEFAULT_SCHEMA_XSD);
}
public TestHrefs(String name, String NS_XSI, String NS_XSD) {
super(name);
HEAD =
"<?xml version=\"1.0\"?>\n" +
"<soap:Envelope " +
"xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" " +
"xmlns:soapenc=\"http://www.w3.org/2003/05/soap-encoding\" " +
"xmlns:xsi=\"" + NS_XSI + "\" " +
"xmlns:xsd=\"" + NS_XSD + "\">\n" +
"<soap:Header>\n";
HEADERT = "</soap:Header>\n" +
"<soap:Body>\n" +
"<methodResult xmlns=\"http://tempuri.org/\">\n";
BODYT = "</methodResult>\n" +
"</soap:Body>\n" +
"</soap:Envelope>\n";
}
private void deserialize(String data, Object expected, int pos)
throws Exception
{
Message message = new Message(data);
MessageContext context = new MessageContext(new AxisServer());
message.setMessageContext(context);
context.setProperty(Constants.MC_NO_OPERATION_OK, Boolean.TRUE);
SOAPEnvelope envelope = (SOAPEnvelope)message.getSOAPEnvelope();
assertNotNull("SOAP envelope should not be null", envelope);
RPCElement body = (RPCElement)envelope.getFirstBody();
assertNotNull("SOAP body should not be null", body);
Vector arglist = body.getParams();
assertNotNull("arglist", arglist);
assertTrue("SOAP param.size()<=0 {Should be > 0}", arglist.size()>0);
RPCParam param = (RPCParam) arglist.get(pos);
assertNotNull("SOAP param should not be null", param);
Object result = param.getObjectValue();
assertEquals("Expected result not received", expected, result);
}
public void testStringReference1() throws Exception {
String result = HEAD + HEADERT +
"<result root=\"0\" id=\"1\" xsi:type=\"xsd:string\">abc</result>" +
"<reference ref=\"#1\"/>\n" +
BODYT;
deserialize(result, "abc", 1);
}
public void testIntReference1() throws Exception {
String result = HEAD + HEADERT +
"<result root=\"0\" id=\"1\" xsi:type=\"xsd:int\">567</result>" +
"<reference ref=\"#1\"/>\n" +
BODYT;
deserialize(result, new Integer(567), 1);
}
public void testStringReferenceInHeader() throws Exception {
String result = HEAD +
"<result root=\"0\" id=\"1\" xsi:type=\"xsd:string\">abc</result>" +
HEADERT +
"<reference ref=\"#1\"/>\n" +
BODYT;
deserialize(result, "abc", 0);
}
public void testIDANDHREF() throws Exception {
String result = HEAD +
HEADERT +
"<result root=\"0\" ref=\"#1\" id=\"1\" xsi:type=\"xsd:string\">abc</result>" +
BODYT;
try {
deserialize(result, "abc", 0);
} catch (AxisFault af) {
assertTrue(af.getFaultString().indexOf(Messages.getMessage("noIDandHREFonSameElement")) != -1 &&
Constants.FAULT_SOAP12_SENDER.equals(af.getFaultCode()));
return;
}
fail("Didn't got the expected fault");
}
} | 7,199 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.