Java Code Examples for org.springframework.test.annotation.Rollback

The following examples show how to use org.springframework.test.annotation.Rollback. 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
Source Project: OpenCue   Source File: CommentDaoTests.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@Transactional
@Rollback(true)
public void testGetComment() {

    JobDetail job = jobManager.findJobDetail("pipe-dev.cue-testuser_shell_v1");

    CommentDetail d = new CommentDetail();
    d.message = "a message";
    d.subject = "a subject";
    d.user = "user";

    commentDao.insertComment(job, d);

    CommentDetail nd = commentDao.getCommentDetail(d.getId());

    assertEquals(d.message,nd.message);
    assertEquals(d.subject,nd.subject);
    assertEquals(d.user,nd.user);
}
 
Example 2
Source Project: OpenCue   Source File: FrameDaoTests.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@Transactional
@Rollback(true)
public void testGetDispatchFrame() {
    DispatchHost host = createHost();
    JobDetail job = launchJob();
    FrameDetail frame = frameDao.findFrameDetail(job, "0001-pass_1");

    VirtualProc proc = new VirtualProc();
    proc.allocationId = host.allocationId;
    proc.coresReserved = 100;
    proc.hostId = host.id;
    proc.hostName = host.name;
    proc.jobId = job.id;
    proc.frameId = frame.id;
    proc.layerId = frame.layerId;
    proc.showId = frame.showId;

    procDao.insertVirtualProc(proc);
    procDao.verifyRunningProc(proc.getId(), frame.getId());

    DispatchFrame dframe = frameDao.getDispatchFrame(frame.id);
    assertEquals(dframe.id, frame.id);
}
 
Example 3
Source Project: OpenCue   Source File: GroupDaoTests.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@Transactional
@Rollback(true)
public void testUpdateMaxCores() {
    GroupDetail group =  createGroup();
    assertEquals(Integer.valueOf(-1), jdbcTemplate.queryForObject(
            "SELECT int_max_cores FROM folder_resource WHERE pk_folder=?",
            Integer.class, group.getGroupId()));
    groupDao.updateMaxCores(group, 100);
    assertEquals(Integer.valueOf(100), jdbcTemplate.queryForObject(
            "SELECT int_max_cores FROM folder_resource WHERE pk_folder=?",
            Integer.class, group.getGroupId()));
    groupDao.updateMaxCores(group, -5);
    assertEquals(Integer.valueOf(-1), jdbcTemplate.queryForObject(
            "SELECT int_max_cores FROM folder_resource WHERE pk_folder=?",
            Integer.class, group.getGroupId()));
}
 
Example 4
Source Project: OpenCue   Source File: GroupDaoTests.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@Transactional
@Rollback(true)
public void testUpdateGroupParent() {
    GroupDetail group =  createGroup();
    GroupDetail subgroup = createSubGroup(group);
    groupDao.updateGroupParent(subgroup,
            groupDao.getGroupDetail(
                    groupDao.getRootGroupId(getShow())));

    assertEquals(Integer.valueOf(1),jdbcTemplate.queryForObject(
            "SELECT int_level FROM folder_level WHERE pk_folder=?",
            Integer.class, subgroup.getId()));

    groupDao.updateGroupParent(subgroup, group);

    assertEquals(Integer.valueOf(2),jdbcTemplate.queryForObject(
            "SELECT int_level FROM folder_level WHERE pk_folder=?",
            Integer.class, subgroup.getId()));
}
 
Example 5
@Test @Rollback(false)
public void testCustomsUpdateDelete() {
	StudentDO studentDO = new StudentDO();
	studentDO.setName("nick");
	studentDO.setAge(29);
	dbHelper.insert(studentDO);
	
	dbHelper.updateCustom(studentDO, "age=age+1");
	dbHelper.delete(StudentDO.class, "where 1=1");
	
	studentDO = new StudentDO();
	studentDO.setName("nick");
	studentDO.setAge(29);
	dbHelper.insert(studentDO);
	dbHelper.updateAll(StudentDO.class, "age=age+1", "where 1=1");
}
 
Example 6
Source Project: OpenCue   Source File: DispatcherDaoTests.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@Transactional
@Rollback(true)
public void testFindNextDispatchFrameByHost() {
    DispatchHost host = getHost();
    JobDetail job = getJob1();

    for (LayerDetail layer: layerDao.getLayerDetails(job)) {
        assertTrue(layer.tags.contains("general"));
    }

    assertTrue(jdbcTemplate.queryForObject(
            "SELECT str_tags FROM host WHERE pk_host=?",String.class,
            host.id).contains("general"));

    DispatchFrame frame =  dispatcherDao.findNextDispatchFrame(job, host);
    assertNotNull(frame);
    assertEquals(frame.name, "0001-pass_1");
}
 
Example 7
Source Project: OpenCue   Source File: OwnerDaoTests.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@Transactional
@Rollback(true)
public void testUpdateShow() {
    ShowInterface show = adminManager.findShowEntity("pipe");
    OwnerEntity o = new OwnerEntity();
    o.name = "spongebob";
    ownerDao.insertOwner(o, show);

    ShowInterface newShow = adminManager.findShowEntity("edu");

    ownerDao.updateShow(o, newShow);

    assertEquals(newShow.getShowId(), jdbcTemplate.queryForObject(
            "SELECT pk_show FROM owner WHERE pk_owner=?",
            String.class, o.id));
}
 
Example 8
Source Project: OpenCue   Source File: DeedDaoTests.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@Transactional
@Rollback(true)
public void testInsertDeed() {

    DispatchHost host = createHost();
    ShowInterface s = adminManager.findShowEntity("pipe");
    OwnerEntity o = ownerManager.createOwner("squarepants", s);
    DeedEntity d = deedDao.insertDeed(o, host);

    assertEquals(Integer.valueOf(1), jdbcTemplate.queryForObject(
            "SELECT COUNT(1) FROM deed WHERE pk_deed=?",
            Integer.class, d.getId()));

    assertEquals(host.getName(), d.host);
}
 
Example 9
Source Project: attic-rave   Source File: JpaWidgetRepositoryTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@Transactional(readOnly = false)
@Rollback
public void saveWidgetWithLongDescription() {
    final String url = "http://example.com/doesnotexistyet";
    final String longDescription = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc dictum sodales erat consequat pulvinar. Pellentesque ut massa mi, sit amet imperdiet diam. Morbi nec magna quis nisi bibendum dignissim. Fusce et rhoncus turpis. Integer mollis magna sit amet nulla convallis placerat dignissim lorem blandit. Nulla magna justo, cursus ac semper sed, pulvinar in turpis. Donec ultricies nibh sed nulla congue ullamcorper. Fusce commodo ultrices nunc, interdum lacinia elit faucibus at. Fusce laoreet ultricies volutpat. ";

    Widget doesnotexist = repository.getByUrl(url);
    assertNull(doesnotexist);

    Widget widget = new JpaWidget();
    widget.setTitle("Widget with long description");
    widget.setUrl(url);
    widget.setDescription(longDescription);
    widget = repository.save(widget);
    assertNotNull(widget.getId());
    assertEquals(longDescription, widget.getDescription());
}
 
Example 10
Source Project: OpenCue   Source File: LayerDaoTests.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@Transactional
@Rollback(true)
public void testGetLayerDetail() {
    LayerDetail layer = getLayer();
    assertEquals(LAYER_NAME, layer.name);
    assertEquals(layer.chunkSize, 1);
    assertEquals(layer.dispatchOrder,2);
    assertNotNull(layer.id);
    assertNotNull(layer.jobId);
    assertEquals(layer.showId,ROOT_SHOW);

    LayerDetail l2 = layerDao.getLayerDetail(layer);
    LayerDetail l3 = layerDao.getLayerDetail(layer.id);
    assertEquals(l2, l3);
}
 
Example 11
Source Project: OpenCue   Source File: WhiteboardDaoTests.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@Transactional
@Rollback(true)
public void testGetFramesByFrameSearch() {
    JobEntity job = launchJob();
    FrameSearchInterface r = frameSearchFactory.create(job);
    FrameSearchCriteria criteria = r.getCriteria();
    r.setCriteria(criteria.toBuilder()
            .setPage(1)
            .setLimit(5)
            .addLayers("pass_1")
            .build());
    assertEquals(5, whiteboardDao.getFrames(r).getFramesCount());
    for (Frame f: whiteboardDao.getFrames(r).getFramesList()) {
        assertEquals(f.getLayerName(), "pass_1");
    }
}
 
Example 12
Source Project: OpenCue   Source File: PointDaoTests.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@Transactional
@Rollback(true)
public void insertDepartmentConfig() {
    ShowEntity show = new ShowEntity();
    show.name = "testtest";
    adminManager.createShow(show);
    DepartmentInterface dept = departmentDao.findDepartment("Lighting");
    PointInterface d = pointDao.insertPointConf(show, dept);

    assertEquals(show.id, jdbcTemplate.queryForObject(
            "SELECT pk_show FROM point WHERE pk_point=?",
            String.class, d.getPointId()));

    assertEquals(dept.getDepartmentId(), jdbcTemplate.queryForObject(
            "SELECT pk_dept FROM point WHERE pk_point=?",
            String.class, d.getPointId()));
}
 
Example 13
Source Project: OpenCue   Source File: DependDaoTests.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@Transactional
@Rollback(true)
public void testGetWhatDependsOnLayer() {

    JobDetail job_a = getJobA();
    JobDetail job_b = getJobB();

    LayerInterface layer_a = layerDao.findLayer(job_a, "pass_1");
    LayerInterface layer_b = layerDao.findLayer(job_b, "pass_1");

    LayerOnLayer depend = new LayerOnLayer(layer_a, layer_b);
    dependDao.insertDepend(depend);

    assertEquals(1, dependDao.getWhatDependsOn(layer_b).size());
    assertEquals(0, dependDao.getWhatDependsOn(layer_a).size());
}
 
Example 14
Source Project: OpenCue   Source File: SubscriptionDaoTests.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@Transactional
@Rollback(true)
public void testIsShowOverSize() {

    SubscriptionEntity sub = buildSubscription(getShow(), alloc);
    subscriptionDao.insertSubscription(sub);

    assertFalse(this.subscriptionDao.isShowOverSize(getShow(), alloc));

    jdbcTemplate.update(
            "UPDATE subscription SET int_cores = ? WHERE pk_subscription = ?",
            100, sub.getSubscriptionId());

    assertFalse(subscriptionDao.isShowOverSize(getShow(), alloc));

    jdbcTemplate.update(
            "UPDATE subscription SET int_cores = ? WHERE pk_subscription = ?",
            101, sub.getSubscriptionId());

    assertEquals(true, subscriptionDao.isShowOverSize(getShow(), alloc));
}
 
Example 15
/**
 * Determine whether or not to rollback transactions for the supplied
 * {@linkplain TestContext test context} by taking into consideration the
 * {@linkplain #isDefaultRollback(TestContext) default rollback} flag and a
 * possible method-level override via the {@link Rollback @Rollback}
 * annotation.
 * @param testContext the test context for which the rollback flag
 * should be retrieved
 * @return the <em>rollback</em> flag for the supplied test context
 * @throws Exception if an error occurs while determining the rollback flag
 */
protected final boolean isRollback(TestContext testContext) throws Exception {
	boolean rollback = isDefaultRollback(testContext);
	Rollback rollbackAnnotation =
			AnnotatedElementUtils.findMergedAnnotation(testContext.getTestMethod(), Rollback.class);
	if (rollbackAnnotation != null) {
		boolean rollbackOverride = rollbackAnnotation.value();
		if (logger.isDebugEnabled()) {
			logger.debug(String.format(
					"Method-level @Rollback(%s) overrides default rollback [%s] for test context %s.",
					rollbackOverride, rollback, testContext));
		}
		rollback = rollbackOverride;
	}
	else {
		if (logger.isDebugEnabled()) {
			logger.debug(String.format(
					"No method-level @Rollback override: using default rollback [%s] for test context %s.",
					rollback, testContext));
		}
	}
	return rollback;
}
 
Example 16
Source Project: OpenCue   Source File: DependDaoTests.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@Transactional
@Rollback(true)
public void testInsertFrameOnFrame() {

    JobDetail job_a = getJobA();
    JobDetail job_b = getJobB();

    FrameDetail frame_a = frameDao.findFrameDetail(job_a, "0001-pass_1");
    FrameDetail frame_b = frameDao.findFrameDetail(job_b, "0001-pass_1");

    FrameOnFrame depend = new FrameOnFrame(frame_a, frame_b);
    dependDao.insertDepend(depend);

    LightweightDependency lwd = dependDao.getDepend(depend.getId());
    assertEquals(depend.getId(), lwd.getId());
    assertEquals(DependType.FRAME_ON_FRAME, lwd.type);
    assertEquals(DependTarget.EXTERNAL, lwd.target);
    assertTrue(lwd.active);
    assertFalse(lwd.anyFrame);
}
 
Example 17
Source Project: OpenCue   Source File: DependDaoTests.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@Transactional
@Rollback(true)
public void testInsertJobOnJob() {

    JobDetail job_a = getJobA();
    JobDetail job_b = getJobB();

    JobOnJob depend = new JobOnJob(job_a, job_b);
    dependDao.insertDepend(depend);

    LightweightDependency lwd = dependDao.getDepend(depend.getId());
    assertEquals(depend.getId(), lwd.getId());
    assertEquals(DependType.JOB_ON_JOB, lwd.type);
    assertEquals(DependTarget.EXTERNAL, lwd.target);
    assertTrue(lwd.active);
    assertFalse(lwd.anyFrame);
}
 
Example 18
Source Project: OpenCue   Source File: RedirectManagerTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
@Transactional
@Rollback(true)
public void testJobRedirect() {

    JobDetail job = getJob();
    JobDetail target = getTargetJob();
    DispatchHost host = getHost();

    List<VirtualProc> procs = dispatcher.dispatchHost(host, job);
    assertEquals(1, procs.size());
    VirtualProc proc = procs.get(0);

    ProcSearchInterface search = procSearchFactory.create();
    search.setCriteria(ProcSearchCriteria.newBuilder().addJobs(job.getName()).build());

    assertTrue(redirectManager.addRedirect(proc, target,
            false, new Source()));

    assertTrue(redirectManager.hasRedirect(proc));
    assertEquals(TARGET_JOB, whiteboard.getProcs(search).getProcs(0).getRedirectTarget());

    assertTrue(redirectManager.redirect(proc));

    assertEquals(
            Convert.coreUnitsToCores(100),
            whiteboard.getJob(target.getJobId()).getJobStats().getReservedCores(),
            0);
}
 
Example 19
Source Project: OpenCue   Source File: SubscriptionDaoTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
@Transactional
@Rollback(true)
public void testDeleteSubscription() {
    SubscriptionEntity s = buildSubscription(getShow(), alloc);
    subscriptionDao.insertSubscription(s);
    subscriptionDao.deleteSubscription(s);
}
 
Example 20
Source Project: OpenCue   Source File: BookingDaoTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
@Transactional
@Rollback(true)
public void testGetRenderPartition() {

    DispatchHost h = createHost();
    JobDetail j = launchJob();

    LocalHostAssignment lja = new LocalHostAssignment();
    lja.setMaxCoreUnits(200);
    lja.setMaxMemory(CueUtil.GB4);
    lja.setThreads(2);
    lja.setMaxGpu(1);

    bookingDao.insertLocalHostAssignment(h, j, lja);

    LocalHostAssignment lja2 = bookingDao.getLocalJobAssignment(h.getHostId(),
                                                                j.getJobId());

    assertEquals(lja.getMaxCoreUnits(), lja2.getMaxCoreUnits());
    assertEquals(lja.getMaxMemory(), lja2.getMaxMemory());
    assertEquals(lja.getThreads(), lja2.getThreads());
    assertEquals(lja.getMaxGpu(), lja2.getMaxGpu());

    RenderPartition rp = whiteboard.getRenderPartition(lja2);

    assertEquals(lja2.getMaxCoreUnits(), rp.getMaxCores());
    assertEquals(lja2.getMaxMemory(), rp.getMaxMemory());
    assertEquals(lja2.getThreads(), rp.getThreads());
    logger.info("--------------------");
    logger.info(lja2.getMaxGpu());
    logger.info(rp.getMaxGpu());
    assertEquals(lja2.getMaxGpu(), rp.getMaxGpu());
    assertEquals(h.getName(), rp.getHost());
    assertEquals(j.getName(), rp.getJob());
}
 
Example 21
Source Project: OpenCue   Source File: JobDaoTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test(expected=IllegalArgumentException.class)
@Transactional
@Rollback(true)
public void testUpdateJobMaxRetriesTooLow() {
    JobDetail job = insertJob();
    jobDao.updateMaxFrameRetries(job,-1);
}
 
Example 22
Source Project: OpenCue   Source File: JobManagerTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
@Transactional
@Rollback(true)
public void testShowAlias() {
    JobSpec spec = jobLauncher.parse(new File("src/test/resources/conf/jobspec/show_alias.xml"));
    jobLauncher.launch(spec);
}
 
Example 23
Source Project: OpenCue   Source File: JobDaoTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
@Transactional
@Rollback(true)
public void testGetJobsByTask() {

    PointInterface p = pointDao.getPointConfigDetail(
            showDao.findShowDetail("pipe"),
            departmentDao.getDefaultDepartment());

    TaskEntity t = new TaskEntity(p, "dev.cue");
    taskDao.insertTask(t);
    jobDao.getJobs(t);
}
 
Example 24
Source Project: OpenCue   Source File: CoreUnitDispatcherGpuJobTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
@Transactional
@Rollback(true)
public void testDispatchRemovedGpuHostToShowPrefer() {
    DispatchHost host = getHost();
    JobDetail job = getJob();
    ShowEntity show = adminManager.findShowEntity("edu");

    List<VirtualProc> procs =  dispatcher.dispatchHost(host, show);
    assertEquals(0, procs.size());
}
 
Example 25
Source Project: OpenCue   Source File: JobSearchTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
@Transactional
@Rollback
public void testGetCriteria() {
    JobSearchCriteria criteria = JobSearchInterface.criteriaFactory();

    JobSearchInterface jobSearch = jobSearchFactory.create(criteria);

    assertEquals(criteria, jobSearch.getCriteria());
}
 
Example 26
Source Project: OpenCue   Source File: HistoricalDaoTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
@Transactional
@Rollback(true)
public void testTransferJob() {
    jobLauncher.launch(new File("src/test/resources/conf/jobspec/jobspec.xml"));
    JobDetail j = jobManager.findJobDetail("pipe-dev.cue-testuser_shell_v1");
    jobManager.shutdownJob(j);
    historicalDao.transferJob(j);

    assertEquals(Integer.valueOf(1), jdbcTemplate.queryForObject(
            "SELECT COUNT(*) FROM job_history WHERE pk_job=?",
            Integer.class, j.getJobId()));
}
 
Example 27
Source Project: OpenCue   Source File: JobDaoTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test(expected=org.springframework.jdbc.UncategorizedSQLException.class)
@Transactional
@Rollback(true)
public void testMaxCoreTrigger() {
    JobDetail job = insertJob();
    int maxCores = jdbcTemplate.queryForObject(
            "SELECT int_max_cores FROM job_resource WHERE pk_job=?",
            Integer.class, job.getJobId());

    jdbcTemplate.update(
            "UPDATE job_resource SET int_cores = ? WHERE pk_job=?",
            maxCores + 1, job.getJobId());
}
 
Example 28
Source Project: OpenCue   Source File: FrameDaoTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
@Transactional
@Rollback(true)
public void testFailUpdateFrameState() {
    JobDetail job = launchJob();
    FrameInterface f = frameDao.findFrame(job, "0001-pass_1");

    /** Change the version so the update fails **/
    jdbcTemplate.update(
            "UPDATE frame SET int_version = int_version + 1 WHERE pk_frame=?",
            f.getFrameId());

    assertEquals(false, frameDao.updateFrameState(f, FrameState.RUNNING));
}
 
Example 29
Source Project: MyUploader-Backend   Source File: FileDaoTests.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 更新成功测试
 */
@Test
@Transactional
@Rollback
public void testUpdateSuccess() {
    fileDao.save(testFile);
    testFile.setPath(UUID.randomUUID().toString());
    assertEquals(1,fileDao.update(testFile));
}
 
Example 30
Source Project: OpenCue   Source File: JobDaoTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
@Transactional
@Rollback(true)
public void testUpdateJobMaxCores() {
    JobDetail job = insertJob();
    jobDao.updateMaxCores(job, 100);
    assertEquals(Integer.valueOf(100), jdbcTemplate.queryForObject(
            "SELECT int_max_cores FROM job_resource WHERE pk_job=?",
            Integer.class, job.getJobId()));
}