Java Code Examples for javax.xml.datatype.DatatypeFactory#newXMLGregorianCalendar()

The following examples show how to use javax.xml.datatype.DatatypeFactory#newXMLGregorianCalendar() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public static XMLGregorianCalendar transformToXMLGregorianCalendar(Date date) throws GFDDPPException {
   if (date == null) {
      return null;
   } else {
      DatatypeFactory dataTypeFactory;
      try {
         dataTypeFactory = DatatypeFactory.newInstance();
      } catch (DatatypeConfigurationException var3) {
         throw new GFDDPPException(StatusCode.COMMON_ERROR_DATATYPECONFIGURATION);
      }

      GregorianCalendar gregorianCalendar = new GregorianCalendar();
      gregorianCalendar.setTimeInMillis(date.getTime());
      return dataTypeFactory.newXMLGregorianCalendar(gregorianCalendar);
   }
}
 
Example 2
/**
 * main method.
 *
 * @param args Standard args.
 */
public static void main(String[] args) {
    try {
        String dateTimeString = "2006-11-22T00:00:00.0+01:02";
        DatatypeFactory dtf = DatatypeFactory.newInstance();
        XMLGregorianCalendar cal = dtf.newXMLGregorianCalendar( dateTimeString );
        System.out.println( "XMLGregCal:" + cal.toString() );
        System.out.println( "GregCal:" + cal.toGregorianCalendar() );
        String toGCal = cal.toGregorianCalendar().toString();
        if (toGCal.indexOf("GMT+12:00") > -1) {
            throw new RuntimeException("Expected GMT+01:02");
        }
    } catch (DatatypeConfigurationException ex) {
        throw new RuntimeException(ex.getMessage());
    }
}
 
Example 3
Source Project: juddi   File: TypeConvertor.java    License: Apache License 2.0 6 votes vote down vote up
public static XMLGregorianCalendar convertDateToXMLGregorianCalendar(Date date) throws DispositionReportFaultMessage {
	XMLGregorianCalendar result = null;
	try { 
		if (date!=null) {
			GregorianCalendar gc = new GregorianCalendar();
			gc.setTimeInMillis(date.getTime());
			
			DatatypeFactory df = DatatypeFactory.newInstance();
			result = df.newXMLGregorianCalendar(gc);
		}
	}
	catch(DatatypeConfigurationException ce) { 
		throw new FatalErrorException(new ErrorMessage("errors.Unspecified"));
	}
	
	return result;
}
 
Example 4
Source Project: photon   File: IMFUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * A utility method to create an XMLGregorianCalendar
 * @return the constructed XMLGregorianCalendar
 */
@Nullable
public static XMLGregorianCalendar createXMLGregorianCalendar(){
    XMLGregorianCalendar result = null;
    try {
        DatatypeFactory datatypeFactory = DatatypeFactory.newInstance();
        TimeZone utc = TimeZone.getTimeZone("UTC");
        GregorianCalendar now = new GregorianCalendar(utc);
        result = datatypeFactory.newXMLGregorianCalendar(now);
    }
    catch (DatatypeConfigurationException e){
        throw new IMFException("Could not create a XMLGregorianCalendar instance");
    }
    return result;
}
 
Example 5
private XMLGregorianCalendar getXMLGregorianCalendarNow() throws IntegrationModuleException {
   String procedure = "getXMLGregorianCalendarNow";

   try {
      GregorianCalendar gregorianCalendar = new GregorianCalendar();
      DatatypeFactory datatypeFactory = DatatypeFactory.newInstance();
      XMLGregorianCalendar now = datatypeFactory.newXMLGregorianCalendar(gregorianCalendar);
      return now;
   } catch (DatatypeConfigurationException var5) {
      LOG.error("SingleMessageInfo=-----= ----- " + procedure + " =$=" + this.info + "error: error.technical");
      throw new IntegrationModuleException(I18nHelper.getLabel("error.technical"));
   }
}
 
Example 6
Source Project: tutorials   File: GregorianCalendarTester.java    License: MIT License 5 votes vote down vote up
@Test
public void test_toDate() throws DatatypeConfigurationException {
    GregorianCalendar calendarActual = new GregorianCalendar(2018, 6, 28);
    DatatypeFactory datatypeFactory = DatatypeFactory.newInstance();
    XMLGregorianCalendar expectedXMLGregorianCalendar = datatypeFactory
        .newXMLGregorianCalendar(calendarActual);
    expectedXMLGregorianCalendar.toGregorianCalendar().getTime();
    assertEquals(calendarActual.getTime(), 
        expectedXMLGregorianCalendar.toGregorianCalendar().getTime() );
}
 
Example 7
/**
 * invalid expiration time
 *
 * @throws DatatypeConfigurationException
 */
@Test
public void JUDDI_606_2() throws DatatypeConfigurationException {
     Assume.assumeTrue(TckPublisher.isEnabled());
        logger.info("JUDDI_606_2");
        Assume.assumeTrue(TckPublisher.isSubscriptionEnabled());
        // invalid expiration time
        DatatypeFactory df = DatatypeFactory.newInstance();
        GregorianCalendar gcal = new GregorianCalendar();
        gcal.setTimeInMillis(System.currentTimeMillis());
        gcal.add(Calendar.DATE, -1);
        XMLGregorianCalendar newXMLGregorianCalendar = df.newXMLGregorianCalendar(gcal);

        Subscription sub = new Subscription();
        Holder<List<Subscription>> data = new Holder<List<Subscription>>();
        data.value = new ArrayList<Subscription>();
        sub.setBrief(true);
        sub.setExpiresAfter(newXMLGregorianCalendar);
        sub.setMaxEntities(1);
        sub.setNotificationInterval(null);
        sub.setBindingKey(null);
        sub.setSubscriptionFilter(new SubscriptionFilter());
        sub.getSubscriptionFilter().setFindService(new FindService());
        sub.getSubscriptionFilter().getFindService().setFindQualifiers(new FindQualifiers());
        sub.getSubscriptionFilter().getFindService().getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
        sub.getSubscriptionFilter().getFindService().getName().add(new Name("%", null));
        data.value.add(sub);
        try {
                tckSubscriptionJoe.subscription.saveSubscription(authInfoJoe, data);
                Assert.fail();
        } catch (Exception ex) {
                //HandleException(ex);
                logger.info("Expected exception: " + ex.getMessage());
        }
}
 
Example 8
/**
 * Converts a calendar object
 * 
 * @param calendar gregorian calendar
 * 
 * @return an XML gregorian calendar
 */
public static XMLGregorianCalendar convertCalendar(GregorianCalendar calendar) {
	if (calendar == null) {
		return null;
	}

	DatatypeFactory df;
	try {
		df = DatatypeFactory.newInstance();
	} catch (DatatypeConfigurationException e) {
		throw new CmisRuntimeException("Convert exception: " + e.getMessage(), e);
	}

	return df.newXMLGregorianCalendar(calendar);
}
 
Example 9
Source Project: cxf   File: XsDateTimeFormat.java    License: Apache License 2.0 5 votes vote down vote up
public Object parseObject(String pString, ParsePosition pParsePosition) {
    if (pString == null) {
        throw new NullPointerException("The String argument must not be null.");
    }
    if (pParsePosition == null) {
        throw new NullPointerException("The ParsePosition argument must not be null.");
    }
    int offset = pParsePosition.getIndex();
    int idxSpc = pString.indexOf(' ', offset);
    int idxCom = pString.indexOf(',', offset);

    if (idxCom != -1 && idxCom < idxSpc) {
        idxSpc = idxCom;
    }
    String newVal = null;
    if (idxSpc == -1) {
        newVal = pString.substring(offset);
    } else {
        newVal = pString.substring(offset, idxSpc);
    }
    DatatypeFactory factory;
    try {
        factory = DatatypeFactory.newInstance();
        XMLGregorianCalendar cal = factory.newXMLGregorianCalendar(newVal);

        pParsePosition.setIndex(idxSpc);
        return cal.toGregorianCalendar();
    } catch (DatatypeConfigurationException e) {
        pParsePosition.setErrorIndex(offset);
    }
    return null;
}
 
Example 10
Source Project: cxf   File: SubscriptionManagerImpl.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Decide what expiration time to grant to the subscription, if
 * the client did not specify any particular wish for subscription length.
 */
public XMLGregorianCalendar grantExpiration() {
    try { // by default, we grant an expiration time of 2 years
        DatatypeFactory factory = DatatypeFactory.newInstance();
        XMLGregorianCalendar granted = factory.newXMLGregorianCalendar(new GregorianCalendar());
        granted.add(factory.newDurationYearMonth(true, 2, 0));
        return granted;
    } catch (DatatypeConfigurationException ex) {
        throw new Error(ex);
    }
}
 
Example 11
@Test
public void testToString() {
    try {
        String inputDateTime = "2006-10-23T22:15:01.000000135+08:00";
        DatatypeFactory factory = DatatypeFactory.newInstance();
        XMLGregorianCalendar calendar = factory.newXMLGregorianCalendar(inputDateTime);
        String toStr = calendar.toString();
        Assert.assertTrue(toStr.indexOf("E") == -1, "String value cannot contain exponent");
    } catch (DatatypeConfigurationException dce) {
        dce.printStackTrace();
        Assert.fail("Failed to create instance of DatatypeFactory " + dce.getMessage());
    }
}
 
Example 12
@Test
public void test() throws DatatypeConfigurationException {
    DatatypeFactory dtf = DatatypeFactory.newInstance();
    XMLGregorianCalendar c1 = dtf.newXMLGregorianCalendar("1999-12-31T24:00:00");
    XMLGregorianCalendar c2 = dtf.newXMLGregorianCalendar("2000-01-01T00:00:00");
    System.out.println("c1: " + c1.getYear() + "-" + c1.getMonth() + "-" + c1.getDay() + "T" + c1.getHour());
    System.out.println(c1.equals(c2) ? "pass" : "fail"); // fails
    if (!c1.equals(c2))
        Assert.fail("hour 24 needs to be treated as equal to hour 0 of the next day");
    if (c1.getYear() != 2000 && c1.getHour() != 0)
        Assert.fail("hour 24 needs to be treated as equal to hour 0 of the next day");

}
 
Example 13
/**
 * Creates a new XMLGregorianCalendar from the given milliseconds time.
 * 
 * @param time
 *            The time in ms to convert.
 * @return The XML calendar object representing the given timestamp.
 * @throws ImplementationExceptionResponse
 *             If an error occurred when parsing the given timestamp into a
 *             calendar instance.
 */
private XMLGregorianCalendar timeToXmlCalendar(long time) throws ImplementationExceptionResponse {
    try {
        DatatypeFactory factory = DatatypeFactory.newInstance();
        Calendar cal = GregorianCalendar.getInstance();
        cal.setTimeInMillis(time);
        return factory.newXMLGregorianCalendar((GregorianCalendar) cal);
    } catch (DatatypeConfigurationException e) {
        String msg = "Unable to instantiate an XML representation for a date/time datatype.";
        ImplementationException iex = new ImplementationException();
        iex.setReason(msg);
        iex.setSeverity(ImplementationExceptionSeverity.SEVERE);
        throw new ImplementationExceptionResponse(msg, iex, e);
    }
}
 
Example 14
/**
 * Parse string date in format "YYYY-MM-DDThh:mm:ss.SSSTZD"
 */
public static Calendar parseExtended(String value) {
	if (value == null) {
		return null;
	} else {
		try {
			DatatypeFactory dtf = DatatypeFactory.newInstance();
			XMLGregorianCalendar xml = dtf.newXMLGregorianCalendar(value);
			return xml.toGregorianCalendar();
		} catch (DatatypeConfigurationException e) {
			throw new IllegalArgumentException(value);
		}
	}
}
 
Example 15
Source Project: tutorials   File: GregorianCalendarExample.java    License: MIT License 4 votes vote down vote up
public XMLGregorianCalendar toXMLGregorianCalendar(GregorianCalendar calendar) throws DatatypeConfigurationException {
    DatatypeFactory datatypeFactory = DatatypeFactory.newInstance();
    return datatypeFactory.newXMLGregorianCalendar(calendar);
}
 
Example 16
Source Project: juddi   File: UddiCustodyTransfer.java    License: Apache License 2.0 4 votes vote down vote up
public void TransferBusiness(String fromUser, String fromUserAuthToken, String toUser, String toUserAuthToken,
        String BusinessKey) throws Exception {

        System.out.println("Transfering business key " + BusinessKey);
        DatatypeFactory df = DatatypeFactory.newInstance();
        GregorianCalendar gcal = new GregorianCalendar();
        gcal.setTimeInMillis(System.currentTimeMillis());
        XMLGregorianCalendar xcal = df.newXMLGregorianCalendar(gcal);

        //Create a transfer token from fromUser to toUser
        KeyBag kb = new KeyBag();
        kb.getKey().add(BusinessKey);
        Holder<String> nodeidOUT = new Holder<String>();
        Holder<XMLGregorianCalendar> expiresOUT = new Holder<XMLGregorianCalendar>();
        Holder<byte[]> tokenOUT = new Holder<byte[]>();
        custodyTransferPortType.getTransferToken(fromUserAuthToken, kb, nodeidOUT, expiresOUT, tokenOUT);

        System.out.println("Transfer token obtained. Give this to user " + toUser);
        System.out.println("Expires " + expiresOUT.value.toXMLFormat());
        System.out.println("Node " + nodeidOUT.value);
        System.out.println("Token " + org.apache.commons.codec.binary.Base64.encodeBase64String(tokenOUT.value));

        if (toUser == null || toUser.length() == 0 || toUserAuthToken == null || toUserAuthToken.length() == 0) {
                System.out.println("The toUser parameters are either null or empty, I can't complete the transfer here");
                return;
        }

        //The magic part happens here, the user ROOT needs to give the user UDDI the token information out of band
        //in practice, all values must match exactly
        //UDDI now accepts the transfer
        TransferEntities te = new TransferEntities();
        te.setAuthInfo(toUserAuthToken);
        te.setKeyBag(kb);
        TransferToken tt = new TransferToken();
        tt.setExpirationTime(expiresOUT.value);
        tt.setNodeID(nodeidOUT.value);
        tt.setOpaqueToken(tokenOUT.value);
        te.setTransferToken(tt);
        System.out.println("Excuting transfer...");
        custodyTransferPortType.transferEntities(te);
        System.out.println("Complete! verifing ownership change...");

        //confirm the transfer
        GetOperationalInfo go = new GetOperationalInfo();
        go.setAuthInfo(fromUserAuthToken);
        go.getEntityKey().add(BusinessKey);
        OperationalInfos operationalInfo = uddiInquiryService.getOperationalInfo(go);
        boolean ok = false;
        boolean found = false;
        for (int i = 0; i < operationalInfo.getOperationalInfo().size(); i++) {
                if (operationalInfo.getOperationalInfo().get(i).getEntityKey().equalsIgnoreCase(BusinessKey)) {
                        found = true;
                        if (operationalInfo.getOperationalInfo().get(i).getAuthorizedName().equalsIgnoreCase(fromUser)) {
                                System.out.println("Transfer unexpected failed");
                        }
                        if (operationalInfo.getOperationalInfo().get(i).getAuthorizedName().equalsIgnoreCase(toUser)) {
                                ok = true;
                        }

                }
        }
        if (!found) {
                System.out.println("Could get the operational info the transfed business");
        }
        System.out.println("Transfer " + (ok ? "success" : " failed"));
}
 
Example 17
@Test
public final void testSetTime() {

    /**
     * Hour, minute, second values to test and expected result.
     */
    final int[] TEST_VALUES = { 24, 0, 0, TEST_VALUE_PASS, 24, 1, 0, TEST_VALUE_FAIL, 24, 0, 1, TEST_VALUE_FAIL, 24, DatatypeConstants.FIELD_UNDEFINED, 0,
            TEST_VALUE_FAIL, 24, 0, DatatypeConstants.FIELD_UNDEFINED, TEST_VALUE_FAIL };

    // create DatatypeFactory
    DatatypeFactory datatypeFactory = null;
    try {
        datatypeFactory = DatatypeFactory.newInstance();
    } catch (DatatypeConfigurationException datatypeConfigurationException) {
        Assert.fail(datatypeConfigurationException.toString());
    }

    if (DEBUG) {
        System.err.println("DatatypeFactory created: " + datatypeFactory.toString());
    }

    // create XMLGregorianCalendar
    XMLGregorianCalendar xmlGregorianCalendar = datatypeFactory.newXMLGregorianCalendar();

    // test each value
    for (int onTestValue = 0; onTestValue < TEST_VALUES.length; onTestValue = onTestValue + 4) {

        if (DEBUG) {
            System.err.println("testing values: (" + TEST_VALUES[onTestValue] + ", " + TEST_VALUES[onTestValue + 1] + ", " + TEST_VALUES[onTestValue + 2]
                    + ") expected (0=fail, 1=pass): " + TEST_VALUES[onTestValue + 3]);
        }

        try {
            // set time
            xmlGregorianCalendar.setTime(TEST_VALUES[onTestValue], TEST_VALUES[onTestValue + 1], TEST_VALUES[onTestValue + 2]);

            if (DEBUG) {
                System.err.println("XMLGregorianCalendar created: \"" + xmlGregorianCalendar.toString() + "\"");
            }

            // was this expected to fail?
            if (TEST_VALUES[onTestValue + 3] == TEST_VALUE_FAIL) {
                Assert.fail("the values: (" + TEST_VALUES[onTestValue] + ", " + TEST_VALUES[onTestValue + 1] + ", " + TEST_VALUES[onTestValue + 2]
                        + ") are invalid, " + "yet it created the XMLGregorianCalendar \"" + xmlGregorianCalendar.toString() + "\"");
            }
        } catch (Exception exception) {

            if (DEBUG) {
                System.err.println("Exception in creating XMLGregorianCalendar: \"" + exception.toString() + "\"");
            }

            // was this expected to succed?
            if (TEST_VALUES[onTestValue + 3] == TEST_VALUE_PASS) {
                Assert.fail("the values: (" + TEST_VALUES[onTestValue] + ", " + TEST_VALUES[onTestValue + 1] + ", " + TEST_VALUES[onTestValue + 2]
                        + ") are valid yet it failed with \"" + exception.toString() + "\"");
            }
            // expected failure
        }
    }
}
 
Example 18
@Test
public final void testSetHour() {

    /**
     * Hour values to test and expected result.
     */
    final int[] TEST_VALUES = {
            // setTime(H, M, S), hour override, expected result
            0, 0, 0, 0, TEST_VALUE_PASS, 0, 0, 0, 23, TEST_VALUE_PASS, 0, 0, 0, 24, TEST_VALUE_PASS,
            // creates invalid state
            0, 0, 0, DatatypeConstants.FIELD_UNDEFINED, TEST_VALUE_FAIL,
            // violates Schema Errata
            0, 0, 1, 24, TEST_VALUE_FAIL };

    // create DatatypeFactory
    DatatypeFactory datatypeFactory = null;
    try {
        datatypeFactory = DatatypeFactory.newInstance();
    } catch (DatatypeConfigurationException datatypeConfigurationException) {
        Assert.fail(datatypeConfigurationException.toString());
    }

    if (DEBUG) {
        System.err.println("DatatypeFactory created: " + datatypeFactory.toString());
    }

    // create XMLGregorianCalendar
    XMLGregorianCalendar xmlGregorianCalendar = datatypeFactory.newXMLGregorianCalendar();

    // test each value
    for (int onTestValue = 0; onTestValue < TEST_VALUES.length; onTestValue = onTestValue + 5) {

        if (DEBUG) {
            System.err.println("testing values: (" + TEST_VALUES[onTestValue] + ", " + TEST_VALUES[onTestValue + 1] + ", " + TEST_VALUES[onTestValue + 2]
                    + ", " + TEST_VALUES[onTestValue + 3] + ") expected (0=fail, 1=pass): " + TEST_VALUES[onTestValue + 4]);
        }

        try {
            // set time to known valid value
            xmlGregorianCalendar.setTime(TEST_VALUES[onTestValue], TEST_VALUES[onTestValue + 1], TEST_VALUES[onTestValue + 2]);
            // now explicitly set hour
            xmlGregorianCalendar.setHour(TEST_VALUES[onTestValue + 3]);

            if (DEBUG) {
                System.err.println("XMLGregorianCalendar created: \"" + xmlGregorianCalendar.toString() + "\"");
            }

            // was this expected to fail?
            if (TEST_VALUES[onTestValue + 4] == TEST_VALUE_FAIL) {
                Assert.fail("the values: (" + TEST_VALUES[onTestValue] + ", " + TEST_VALUES[onTestValue + 1] + ", " + TEST_VALUES[onTestValue + 2] + ", "
                        + TEST_VALUES[onTestValue + 3] + ") are invalid, " + "yet it created the XMLGregorianCalendar \"" + xmlGregorianCalendar.toString()
                        + "\"");
            }
        } catch (Exception exception) {

            if (DEBUG) {
                System.err.println("Exception in creating XMLGregorianCalendar: \"" + exception.toString() + "\"");
            }

            // was this expected to succed?
            if (TEST_VALUES[onTestValue + 4] == TEST_VALUE_PASS) {
                Assert.fail("the values: (" + TEST_VALUES[onTestValue] + ", " + TEST_VALUES[onTestValue + 1] + ", " + TEST_VALUES[onTestValue + 2] + ", "
                        + TEST_VALUES[onTestValue + 3] + ") are valid yet it failed with \"" + exception.toString() + "\"");
            }
            // expected failure
        }
    }
}
 
Example 19
Source Project: herd   File: ExampleXmlGenerator.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Processes a class by returning the "example" instance of the class.
 *
 * @param clazz the class.
 *
 * @return the instance of the class.
 * @throws MojoExecutionException if any errors were encountered.
 */
private Object processClass(Class<?> clazz) throws MojoExecutionException
{
    log.debug("Generating example XML for class \"" + clazz.getName() + "\".");
    Object instance = null;
    try
    {
        if (String.class.isAssignableFrom(clazz))
        {
            instance = "string";
        }
        else if (Integer.class.isAssignableFrom(clazz) || int.class.isAssignableFrom(clazz))
        {
            instance = 0;
        }
        else if (Long.class.isAssignableFrom(clazz) || long.class.isAssignableFrom(clazz))
        {
            instance = 0L;
        }
        else if (BigDecimal.class.isAssignableFrom(clazz))
        {
            instance = BigDecimal.ZERO;
        }
        else if (Double.class.isAssignableFrom(clazz))
        {
            instance = 0.0;
        }
        else if (XMLGregorianCalendar.class.isAssignableFrom(clazz))
        {
            DatatypeFactory datatypeFactory = DatatypeFactory.newInstance();
            instance = datatypeFactory.newXMLGregorianCalendar(EXAMPLE_GREGORIAN_CALENDAR);
        }
        else if (Boolean.class.isAssignableFrom(clazz) || boolean.class.isAssignableFrom(clazz))
        {
            instance = true;
        }
        else if (clazz.isEnum())
        {
            // If we have an enum, use the first value if at least one value is present.
            Enum<?>[] enums = (Enum<?>[]) clazz.getEnumConstants();
            if (enums != null && enums.length > 0)
            {
                instance = enums[0];
            }
        }
        else if (clazz.getAnnotation(XmlType.class) != null)
        {
            // We can't instantiate interfaces.
            if (!clazz.isInterface())
            {
                // Create a new instance of the class.
                instance = clazz.newInstance();

                // Process the fields of the class, but only if we haven't processed it before (via the call stack). This is to protect from an infinite
                // loop.
                if (!callStack.contains(clazz.getName()))
                {
                    // Push this class on the stack to show we've processed this class.
                    callStack.push(clazz.getName());

                    // Process all the fields of the class.
                    for (Field field : clazz.getDeclaredFields())
                    {
                        field.setAccessible(true);
                        processField(instance, field);
                    }

                    // Remove this class from the stack since we've finished processing it.
                    callStack.pop();
                }
            }
        }
        else
        {
            // Default to string in all other cases.
            instance = "string";
        }
    }
    catch (IllegalAccessException | InstantiationException | DatatypeConfigurationException e)
    {
        throw new MojoExecutionException("Unable to create example XML for class \"" + clazz.getName() + "\". Reason: " + e.getMessage(), e);
    }
    return instance;
}
 
Example 20
@Test
public void InvalidTransferTokenEmptyNullAuthToken() {
     Assume.assumeTrue(TckPublisher.isEnabled());
        String keyJoeBiz = null;
        try {
                DatatypeFactory df = DatatypeFactory.newInstance();
                GregorianCalendar gcal = new GregorianCalendar();
                gcal.setTimeInMillis(System.currentTimeMillis());
                XMLGregorianCalendar xcal = df.newXMLGregorianCalendar(gcal);


                BusinessEntity myBusEntity = new BusinessEntity();
                Name myBusName = new Name();
                myBusName.setLang("en");
                myBusName.setValue("InvalidTransferTokenEmptyNullAuthToken UDDI's Business" + " " + xcal.toString());
                myBusEntity.getName().add(myBusName);
                myBusEntity.setBusinessServices(new BusinessServices());
                myBusEntity.getBusinessServices().getBusinessService().add(CreateBusiness("UDDI"));
                SaveBusiness sb = new SaveBusiness();
                sb.getBusinessEntity().add(myBusEntity);
                sb.setAuthInfo(authInfoJoe);
                BusinessDetail bd = publishJoe.saveBusiness(sb);

                keyJoeBiz = bd.getBusinessEntity().get(0).getBusinessKey();

                //transfers from Joe to Sam
                KeyBag kb = new KeyBag();
                kb.getKey().add(keyJoeBiz);

                Holder<String> nodeidOUT = new Holder<String>();
                Holder<XMLGregorianCalendar> expiresOUT = new Holder<XMLGregorianCalendar>();
                Holder<byte[]> tokenOUT = new Holder<byte[]>();
                custodyTransferPortTypeJoe.getTransferToken(null, kb, nodeidOUT, expiresOUT, tokenOUT);

                Assert.fail();
        } catch (Exception ex) {
                logger.info("Expected exception: " + ex.getMessage());

        } finally {
                TckCommon.DeleteBusiness(keyJoeBiz, authInfoJoe, publishJoe);

        }

}