Package org.apache.juddi.handler

Source Code of org.apache.juddi.handler.AssertionStatusReportHandlerTests

/*
* 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 org.apache.juddi.handler;

import org.apache.juddi.datatype.KeyedReference;
import org.apache.juddi.datatype.RegistryObject;
import org.apache.juddi.datatype.response.AssertionStatusItem;
import org.apache.juddi.datatype.response.AssertionStatusReport;
import org.apache.juddi.datatype.response.CompletionStatus;
import org.apache.juddi.datatype.response.KeysOwned;
import org.apache.juddi.util.xml.XMLUtils;
import org.w3c.dom.Element;

/**
* @author anou_mana@apache.org
*/
public class AssertionStatusReportHandlerTests extends HandlerTestCase
{
  private static final String TEST_ID = "juddi.handler.AssertionStatusReport.test";
  private AssertionStatusReportHandler handler = null;

  public AssertionStatusReportHandlerTests(String arg0)
  {
    super(arg0);
  }

  public static void main(String[] args)
  {
    junit.textui.TestRunner.run(AssertionStatusReportHandlerTests.class);
  }

  public void setUp()
  {
    HandlerMaker maker = HandlerMaker.getInstance();
    handler = (AssertionStatusReportHandler)maker.lookup(AssertionStatusReportHandler.TAG_NAME);
  }

  private RegistryObject getRegistryObject()
  {

    KeysOwned keysOwned = new KeysOwned();
    keysOwned.setFromKey("fe8af00d-3a2c-4e05-b7ca-95a1259aad4f");
    keysOwned.setToKey("dfddb58c-4853-4a71-865c-f84509017cc7");

    AssertionStatusItem item = new AssertionStatusItem();
    item.setFromKey("986d9a16-5d4d-46cf-9fac-6bb80a7091f6");
    item.setToKey("dd45a24c-74fc-4e82-80c2-f99cdc76d681");
    item.setKeyedReference(new KeyedReference("uuid:8ff45356-acde-4a4c-86bf-f953611d20c6","Subsidiary","1"));
    item.setCompletionStatus(new CompletionStatus(CompletionStatus.COMPLETE));
    item.setKeysOwned(keysOwned);

    AssertionStatusReport object = new AssertionStatusReport();
    object.setGeneric("2.0");
    object.setOperator("jUDDI.org");
    object.addAssertionStatusItem(item);
    object.addAssertionStatusItem(item);

    return object;

  }

  private Element getMarshalledElement(RegistryObject regObject)
  {
    Element parent = XMLUtils.newRootElement();
    Element child = null;

    if(regObject == null)
      regObject = this.getRegistryObject();

    handler.marshal(regObject,parent);
    child = (Element)parent.getFirstChild();
    parent.removeChild(child);

    return child;
  }

  public void testMarshal()
  {
    Element child = getMarshalledElement(null);

    String marshalledString = this.getXMLString(child);

    assertNotNull("Marshalled AssertionStatusReport ", marshalledString);

  }

  public void testUnMarshal()
  {

    Element child = getMarshalledElement(null);
    RegistryObject regObject = handler.unmarshal(child);

    assertNotNull("UnMarshalled AssertionStatusReport ", regObject);

  }

  public void testMarshUnMarshal()
  {
    Element child = getMarshalledElement(null);

    String marshalledString = this.getXMLString(child);

    assertNotNull("Marshalled AssertionStatusReport ", marshalledString);

    RegistryObject regObject = handler.unmarshal(child);

    child = getMarshalledElement(regObject);

    String unMarshalledString = this.getXMLString(child);

    assertNotNull("Unmarshalled AssertionStatusReport ", unMarshalledString);

    boolean equals = marshalledString.equals(unMarshalledString);

    assertEquals("Expected result: ", marshalledString, unMarshalledString );
  }

}
TOP

Related Classes of org.apache.juddi.handler.AssertionStatusReportHandlerTests

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.