/**
  * Returns the target platform service or <code>null</code> if none
  *
  * @return target platform service
  */
 protected ITargetPlatformService getTargetService() {
   ServiceReference reference =
       MacroPlugin.getBundleContext().getServiceReference(ITargetPlatformService.class.getName());
   assertNotNull("Missing target platform service", reference);
   if (reference == null) return null;
   return (ITargetPlatformService) MacroPlugin.getBundleContext().getService(reference);
 }
 /**
  * Reads a target definition file from the tests/targets/target-files location with the given
  * name. Note that ".target" will be appended.
  *
  * @param name
  * @return target definition
  * @throws Exception
  */
 protected ITargetDefinition readOldTarget(String name) throws Exception {
   URL url =
       MacroPlugin.getBundleContext()
           .getBundle()
           .getEntry("/tests/targets/target-files/" + name + ".target");
   File file = new File(FileLocator.toFileURL(url).getFile());
   ITargetDefinition target = getNewTarget();
   FileInputStream stream = new FileInputStream(file);
   TargetDefinitionPersistenceHelper.initFromXML(target, stream);
   stream.close();
   return target;
 }