Author: chinthaka
Date: Tue Jul 26 01:26:50 2005
New Revision: 225256

URL: http://svn.apache.org/viewcvs?rev=225256&view=rev
Log:
Fixed OMBlankTest related to JIRA AXIS2-99.

Added:
    
webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/om/OMBlankElementTest.java
Modified:
    
webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMElementImpl.java

Modified: 
webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMElementImpl.java
URL: 
http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMElementImpl.java?rev=225256&r1=225255&r2=225256&view=diff
==============================================================================
--- 
webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMElementImpl.java
 (original)
+++ 
webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMElementImpl.java
 Tue Jul 26 01:26:50 2005
@@ -108,6 +108,9 @@
      */
     public OMElementImpl(String localName, OMNamespace ns) {
         super(null);
+        if(localName == null || "".equals(localName)){
+            throw new OMException("localname can not be null or empty");
+        }
         this.localName = localName;
         this.done = true;
         if (ns != null) {

Added: 
webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/om/OMBlankElementTest.java
URL: 
http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/om/OMBlankElementTest.java?rev=225256&view=auto
==============================================================================
--- 
webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/om/OMBlankElementTest.java
 (added)
+++ 
webservices/axis/trunk/java/modules/xml/test/org/apache/axis2/om/OMBlankElementTest.java
 Tue Jul 26 01:26:50 2005
@@ -0,0 +1,64 @@
+package org.apache.axis2.om;

+

+/*

+ * Copyright 2004,2005 The Apache Software Foundation.

+ *

+ * Licensed under the Apache License, Version 2.0 (the "License");

+ * you may not use this file except in compliance with the License.

+ * You may obtain a copy of the License at

+ *

+ *      http://www.apache.org/licenses/LICENSE-2.0

+ *

+ * Unless required by applicable law or agreed to in writing, software

+ * distributed under the License is distributed on an "AS IS" BASIS,

+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

+ * See the License for the specific language governing permissions and

+ * limitations under the License.

+ *

+ * author : Eran Chinthaka ([EMAIL PROTECTED])

+ */

+

+import java.io.StringWriter;

+

+import javax.xml.stream.XMLOutputFactory;

+import javax.xml.stream.XMLStreamException;

+

+import junit.framework.TestCase;

+

+import org.apache.axis2.om.impl.OMOutputImpl;

+

+

+public class OMBlankElementTest extends TestCase {

+

+

+       public OMBlankElementTest(String name) {

+               super(name);

+       }

+

+       public void testBlankOMElem() {

+               try {

+                       //We should not get anything as the return value here: 
the output of the serialization

+                       String value = buildBlankOMElem();

+                       System.out.println(value);

+                       assertNull("There's a serialized output for a blank XML 
element that cannot exist", value);

+               } catch (Exception e) {

+                       //An exception is thrown trying to serialize a blank 
element

+                       assertTrue(true);

+               }

+       }

+

+

+

+       String buildBlankOMElem() throws XMLStreamException {

+               OMFactory factory = OMAbstractFactory.getOMFactory();

+               OMNamespace namespace1 = factory.createOMNamespace("","");

+               OMElement elem1 = factory.createOMElement("",namespace1);

+

+               StringWriter writer = new StringWriter();

+               elem1.build();

+               elem1.serializeWithCache(new OMOutputImpl(XMLOutputFactory

+                               .newInstance().createXMLStreamWriter(writer)));

+               writer.flush();

+               return writer.toString();

+       }

+}



Reply via email to