Field Injection When Mocking Frameworks Fail

Also published on DZone

Challenge

You use Dependency Injection (CDI) in your application and you want to unit test your Java classes without making it an integration test by using Weld of Arquillian. You use a Mocking framework like Mockito or EasyMock but still have trouble getting all your dependencies injected into the class because one or the injections is a String type or another final class.

more >>

How to let iTunes Backup to external disk including the Mobile sync

Problem

  1. You have a large iTunes library and want to move it to an external disk.
  2. You also have an iPhone that you backup regularly but it takes up to much space.

Solution 1

You need to consolidate the iTunes library and then move it to an external disk

Steps

  • open iTunes
  • File > Library > Organize Library…
  • Check the Consolidate files
  • OK

This step can take a while… When done do:

  • Quit iTunes
  • Attach an external drive (in this example called ‘EXTDRIVE’)
  • with Finder move the ~/Music/iTunes folder to /Volumes/EXTDRIVE/iTunes

This step can take a while again… When done do:

  • If you copied iTunes in stead of moved then rename the ~/Music/iTunes folder to ~/Music/iTunes.bak
  • Open iTunes
  • iTunes will tell you that it can’t find the library…
  • Choose Library by navigating to the EXTDRIVE and opening the iTunes folder
  • iTunes will nog see the library again.

Solution 2

Right now you have the complete library on an external disk but backups will still be made on your own drive (~/Library/Application Support/MobileSync).
If you have an iPhone with 128Gb space this can take up a lot of space.
This is how you can let iTunes make these backups to external disk to.

Steps

  • Quit iTunes if it was running
  • open Finder
  • press Cmd+Shift+G
  • enter: ~/Library/Application Support/MobileSync
  • Go
  • Now you will see a folder called Backup
  • Open a new Finder window (cmd+n)
  • Navigate to the EXTDRIVE
  • Create Folder called MobileSync on the EXTDRIVE
  • now move the Backup folder (other Finder window) into the MobileSync folder

This step can take a while if you have lots of backups… When done do

  • open a Terminal window and enter the following command
  • ln -s /Volumes/EXTDRIVE/MobileSync/Backup/ ~/Library/Application\ Support/MobileSync/
  • this will create a symlink called Backup from the local disk to the external disk
  • Start iTumes and see if it worked by pressing cmd+, > Devices
  • If You see your former backups there it worked.

Conclusion

Now the whole iTunes library and backups are made to the EXTDRIVE. This should free up some space, at least if you delete the iTunes.bak folder after verifying the whole change :-)
Note that changing the the name of the drive will invalidate the symlink and it should be created anew with the new name.