}
catch (IllegalStateException ise) {
// expected
}
final RepositoryAdminLoginContext loginContext1 = m_repositoryAdmin.createLoginContext(user1);
loginContext1
.add(loginContext1.createShopRepositoryContext()
.setLocation(m_endpoint).setCustomer("apache").setName("store").setWriteable())
.add(loginContext1.createTargetRepositoryContext()
.setLocation(m_endpoint).setCustomer("apache").setName("target").setWriteable());
m_repositoryAdmin.login(loginContext1);
assertFalse("When first logging in without checking out, the repository cannot be current.", m_repositoryAdmin.isCurrent());
assertFalse("Immediately after login, the repository not is modified.", m_repositoryAdmin.isModified());
try {
m_repositoryAdmin.commit();
fail("We should not be able to commit before we check something out.");
}
catch (IllegalStateException e) {
// expected
}
runAndWaitForEvent(new Callable<Object>() {
public Object call() throws Exception {
m_repositoryAdmin.checkout();
return null;
}
}, false, RepositoryAdmin.TOPIC_REFRESH);
assertTrue("After initial checkout, the repository is current.", m_repositoryAdmin.isCurrent());
assertFalse("Immediately after login, the repository cannot be modified.", m_repositoryAdmin.isModified());
ArtifactObject b1 = runAndWaitForEvent(new Callable<ArtifactObject>() {
public ArtifactObject call() throws Exception {
return createBasicBundleObject("bundle1");
}
}, false, ArtifactObject.TOPIC_ADDED, RepositoryAdmin.TOPIC_STATUSCHANGED);
assertTrue("After initial checkout, the repository is current.", m_repositoryAdmin.isCurrent());
assertTrue("We have added a bundle, so the repository is modified.", m_repositoryAdmin.isModified());
assertEquals(1, m_artifactRepository.get().size());
assertEquals("We expect the working state of our bundle to be New;", WorkingState.New, m_repositoryAdmin.getWorkingState(b1));
assertEquals("We expect one bundle object in working state New;", 1, m_repositoryAdmin.getNumberWithWorkingState(ArtifactObject.class, WorkingState.New));
assertEquals("We expect 0 bundle objects in working state Changed;", 0, m_repositoryAdmin.getNumberWithWorkingState(ArtifactObject.class, WorkingState.Changed));
assertEquals("We expect 0 bundle objects in working state Unchanged;", 0, m_repositoryAdmin.getNumberWithWorkingState(ArtifactObject.class, WorkingState.Unchanged));
runAndWaitForEvent(new Callable<Object>() {
public Object call() throws Exception {
m_repositoryAdmin.logout(false);
return null;
}
}, false, RepositoryAdmin.TOPIC_LOGOUT);
cleanUp();
assertEquals(0, m_artifactRepository.get().size());
runAndWaitForEvent(new Callable<Object>() {
public Object call() throws Exception {
m_repositoryAdmin.login(loginContext1);
return null;
}
}, false, RepositoryAdmin.TOPIC_LOGIN);
assertTrue("There has not been another commit in between, so we are still current.", m_repositoryAdmin.isCurrent());
assertTrue("We have made changes since the last commit, so the repository must be modified.", m_repositoryAdmin.isModified());
assertEquals(1, m_artifactRepository.get().size());
assertEquals("We expect the working state of our bundle to be New;", WorkingState.New, m_repositoryAdmin.getWorkingState(b1));
assertEquals("We expect one bundle object in working state New;", 1, m_repositoryAdmin.getNumberWithWorkingState(ArtifactObject.class, WorkingState.New));
assertEquals("We expect 0 bundle objects in working state Changed;", 0, m_repositoryAdmin.getNumberWithWorkingState(ArtifactObject.class, WorkingState.Changed));
assertEquals("We expect 0 bundle objects in working state Unchanged;", 0, m_repositoryAdmin.getNumberWithWorkingState(ArtifactObject.class, WorkingState.Unchanged));
m_repositoryAdmin.commit();
assertTrue("After a commit, the repository must be current.", m_repositoryAdmin.isCurrent());
assertFalse("After a commit, the repository cannot be modified.", m_repositoryAdmin.isModified());
runAndWaitForEvent(new Callable<Object>() {
public Object call() throws Exception {
m_repositoryAdmin.logout(false);
return null;
}
}, false, RepositoryAdmin.TOPIC_LOGOUT);
cleanUp();
final RepositoryAdminLoginContext loginContext2 = m_repositoryAdmin.createLoginContext(user2);
loginContext2
.add(loginContext2.createShopRepositoryContext()
.setLocation(m_endpoint).setCustomer("apache").setName("store").setWriteable())
.add(loginContext2.createTargetRepositoryContext()
.setLocation(m_endpoint).setCustomer("apache").setName("target").setWriteable());
runAndWaitForEvent(new Callable<Object>() {
public Object call() throws Exception {
m_repositoryAdmin.login(loginContext2);