### Question:
SharedObjectSyncUtil { public synchronized void synchronizeConnections( DatabaseMeta database ) { synchronizeConnections( database, database.getName() ); } SharedObjectSyncUtil( Spoon spoon ); synchronized void synchronizeConnections( DatabaseMeta database ); synchronized void synchronizeConnections( DatabaseMeta database, String originalName ); synchronized void synchronizeSlaveServers( SlaveServer slaveServer ); synchronized void synchronizeSlaveServers( SlaveServer slaveServer, String originalName ); synchronized void deleteSlaveServer( SlaveServer removed ); synchronized void deleteClusterSchema( ClusterSchema removed ); synchronized void deletePartitionSchema( PartitionSchema removed ); synchronized void reloadTransformationRepositoryObjects( boolean includeActive ); synchronized void reloadJobRepositoryObjects( boolean includeActive ); synchronized void reloadSharedObjects(); synchronized void synchronizeClusterSchemas( ClusterSchema clusterSchema ); synchronized void synchronizeClusterSchemas( ClusterSchema clusterSchema, String originalName ); synchronized void synchronizePartitionSchemas( PartitionSchema partitionSchema ); synchronized void synchronizePartitionSchemas( PartitionSchema partitionSchema, String originalName ); synchronized void synchronizeSteps( StepMeta step ); synchronized void synchronizeSteps( StepMeta step, String originalName );  }### Answer:
@Test public void synchronizeConnections() throws Exception { final String databaseName = "SharedDB"; DatabaseMeta sharedDB0 = createDatabaseMeta( databaseName, true ); saveSharedObjects( SHARED_OBJECTS_FILE, sharedDB0 ); JobMeta job1 = createJobMeta(); spoonDelegates.jobs.addJob( job1 ); JobMeta job2 = createJobMeta(); spoonDelegates.jobs.addJob( job2 ); DatabaseMeta sharedDB2 = job2.getDatabase( 0 ); assertEquals( databaseName, sharedDB2.getName() ); DatabaseMeta sharedDB1 = job1.getDatabase( 0 ); assertEquals( databaseName, sharedDB1.getName() ); assertTrue( sharedDB1 != sharedDB2 ); assertThat( sharedDB1.getHostname(), equalTo( BEFORE_SYNC_VALUE ) ); sharedDB2.setHostname( AFTER_SYNC_VALUE ); sharedUtil.synchronizeConnections( sharedDB2, sharedDB2.getName() ); assertThat( sharedDB1.getHostname(), equalTo( AFTER_SYNC_VALUE ) ); }
@Test public void synchronizeConnections_should_not_sync_unshared() throws Exception { final String databaseName = "DB"; JobMeta job1 = createJobMeta(); DatabaseMeta sharedDB1 = createDatabaseMeta( databaseName, true ); job1.addDatabase( sharedDB1 ); spoonDelegates.jobs.addJob( job1 ); DatabaseMeta db2 = createDatabaseMeta( databaseName, false ); JobMeta job2 = createJobMeta(); spoonDelegates.jobs.addJob( job2 ); job2.addDatabase( db2 ); db2.setHostname( AFTER_SYNC_VALUE ); sharedUtil.synchronizeConnections( db2, db2.getName() ); assertThat( sharedDB1.getHostname(), equalTo( BEFORE_SYNC_VALUE ) ); }
@Test public void synchronizeConnections_use_case_sensitive_name() throws Exception { JobMeta job1 = createJobMeta(); DatabaseMeta sharedDB1 = createDatabaseMeta( "DB", true ); job1.addDatabase( sharedDB1 ); spoonDelegates.jobs.addJob( job1 ); DatabaseMeta sharedDB2 = createDatabaseMeta( "Db", true ); JobMeta job2 = createJobMeta(); spoonDelegates.jobs.addJob( job2 ); job2.addDatabase( sharedDB2 ); sharedDB2.setHostname( AFTER_SYNC_VALUE ); sharedUtil.synchronizeConnections( sharedDB2, sharedDB2.getName() ); assertThat( sharedDB1.getHostname(), equalTo( BEFORE_SYNC_VALUE ) ); }