@Test public void testDefer() throws Throwable { Supplier<Observable<String>> factory = mock(Supplier.class); Observable<String> firstObservable = Observable.just("one", "two"); Observable<String> secondObservable = Observable.just("three", "four"); when(factory.get()).thenReturn(firstObservable, secondObservable); Observable<String> deferred = Observable.defer(factory); verifyZeroInteractions(factory); Subscriber<String> firstObserver = TestHelper.mockSubscriber(); deferred.subscribe(firstObserver); verify(factory, times(1)).get(); verify(firstObserver, times(1)).onNext("one"); verify(firstObserver, times(1)).onNext("two"); verify(firstObserver, times(0)).onNext("three"); verify(firstObserver, times(0)).onNext("four"); verify(firstObserver, times(1)).onComplete(); Subscriber<String> secondObserver = TestHelper.mockSubscriber(); deferred.subscribe(secondObserver); verify(factory, times(2)).get(); verify(secondObserver, times(0)).onNext("one"); verify(secondObserver, times(0)).onNext("two"); verify(secondObserver, times(1)).onNext("three"); verify(secondObserver, times(1)).onNext("four"); verify(secondObserver, times(1)).onComplete(); }
/** Helper method use to add some textField to the edge. */ public void addTextFieldToEdge() { graphNode1 = new GraphNode(); graphNode1.setContainer(graphEdge); graphNode1.setPosition(TestHelper.getWaypoint(25, 13)); textField1 = test.addTextField(graphNode1, text, AnchorType.LeftEnding); graphNode2 = new GraphNode(); graphNode2.setContainer(graphEdge); graphNode2.setPosition(TestHelper.getWaypoint(12, 13)); // the anchorage will be set to (12, 10). textField2 = test.addTextField(graphNode2, text, AnchorType.Line); graphNode3 = new GraphNode(); graphNode3.setContainer(graphEdge); graphNode3.setPosition(TestHelper.getWaypoint(8, 6)); // the anchorage will be set to (7, 7). textField3 = test.addTextField(graphNode3, text, AnchorType.Line); graphNode4 = new GraphNode(); graphNode4.setContainer(graphEdge); graphNode4.setPosition(TestHelper.getWaypoint(5, 7)); textField4 = test.addTextField(graphNode4, text, AnchorType.RightEnding); }
public void testUInt() { final int[][] values = new int[][] { TestHelper.createUInts( new long[] { 2147483644L, 2147483645L, 2147483646L, 2147483647L, 2147483648L, 2147483649L, 2147483650L, 2147483651L }), TestHelper.createUInts(new long[] {2147483645L, 2147483647L, 2147483649L, 2147483651L}), TestHelper.createUInts(new long[] {2147483647L, 2147483648L, 2147483649L}) }; final boolean unsigned = true; final Histogram histogram = new Histogram(new int[6], 2147483645, 2147483650L); for (int i = 0; i < values.length; i++) { histogram.aggregate(values[i], unsigned, IndexValidator.TRUE, ProgressMonitor.NULL); } final int[] exp = new int[] {2, 1, 3, 2, 3, 1}; assertEquals("", equal(exp, histogram.getBinCounts())); }
/** * Run method for this thread: if this thread is set to stop, then stop a VM and wait for it to * stop. If this thread is set to start then start a VM and wait for it to start. Any errors are * placed in the blackboard errStr. */ public void run() { try { Log.getLogWriter().info("Started " + getName()); try { if (stop) { ClientVmMgr.stop( "Test is synchronously stopping " + targetVm + " with " + ClientVmMgr.toStopModeString(stopMode), stopMode, ClientVmMgr.ON_DEMAND, targetVm); } VMotionUtil.doVMotion(targetVm); if (start) { ClientVmMgr.start("Test is synchronously starting " + targetVm, targetVm); } } catch (hydra.ClientVmNotFoundException e) { Log.getLogWriter() .info("Caught in thread " + getName() + ":" + TestHelper.getStackTrace(e)); StopStartBB.getBB().getSharedMap().put(StopStartBB.errKey, TestHelper.getStackTrace(e)); } } catch (Throwable e) { Log.getLogWriter().info("Caught in thread " + getName() + ":" + TestHelper.getStackTrace(e)); StopStartBB.getBB().getSharedMap().put(StopStartBB.errKey, TestHelper.getStackTrace(e)); } Log.getLogWriter().info(getName() + " terminating"); }
/** * Verify step 2 form validation is working well(Invalid amount on "Yes, Post Now" section) . * * @throws Exception if any error */ public void testFTC51() throws Exception { browser.click("link=Get A Copilot"); browser.waitForPageToLoad(TestHelper.getTimeout()); browser.click("link=Work with a Copilot"); browser.waitForPageToLoad(TestHelper.getTimeout()); browser.select("id=projects", "label=Client 1 Billing Account 1 Project 2"); browser.type( "dom=document.getElementById('allDescription_ifr').contentDocument.body", "Test Public Description"); browser.type( "dom=document.getElementById('privateDescription_ifr').contentDocument.body", "Test Specification Description"); String contest = "Contest " + System.currentTimeMillis(); browser.type("id=contestName", contest); browser.click("css=div.BottomBar > a.nextStepButton"); Thread.sleep(TestHelper.SLEEP * 10); browser.click("link=YES, POST NOW"); Thread.sleep(TestHelper.SLEEP); browser.click( "//div[@id='stepContainer']/div[4]/div/div[5]/div/div[2]/div[3]/div[2]/div/ul/li[2]/input"); browser.type("css=input.amountText", "fffff"); browser.click("css=div.BottomBar > a.nextStepButton"); Thread.sleep(TestHelper.SLEEP); assertTrue("error popup should be displayed", browser.isVisible("errortModal")); assertTrue("error popup should be displayed", browser.isTextPresent("The amount is invalid.")); }
@Test public void failOnWrongDestination() throws Exception { response.setStatus(SAMLUtil.createStatus(StatusCode.SUCCESS_URI)); response.setDestination("http://consumer"); Assertion assertion = TestHelper.buildAssertion( spMetadata.getAssertionConsumerServiceLocation(0), spMetadata.getEntityID()); response.getAssertions().add(assertion); final String xml = TestHelper.signObject(response, credential); context.checking( new Expectations() { { atLeast(1).of(req).getParameter(Constants.SAML_SAMLRESPONSE); will(returnValue(Base64.encodeBytes(xml.getBytes()))); allowing(req).getParameter(Constants.SAML_RELAYSTATE); will(returnValue("")); } }); try { sh.handlePost(ctx); fail("Wrong destination, should fail"); } catch (RuntimeException e) { } }
/** * Destroy a key in region REGION_NAME. The keys to destroy are specified in keyIntervals. * * @return true if all keys to be destroyed have been completed. */ protected boolean destroy() { SharedCounters sc = CQUtilBB.getBB().getSharedCounters(); long nextKey = sc.incrementAndRead(CQUtilBB.LASTKEY_DESTROY); if (!keyIntervals.keyInRange(KeyIntervals.DESTROY, nextKey)) { Log.getLogWriter().info("All destroys completed; returning from destroy"); return true; } Object key = NameFactory.getObjectNameForCounter(nextKey); Log.getLogWriter().info("Destroying " + key); checkContainsValueForKey(key, true, "before destroy"); try { aRegion.destroy(key); Log.getLogWriter() .info( "Done Destroying " + key + ", num remaining: " + (keyIntervals.getLastKey(KeyIntervals.DESTROY) - nextKey)); } catch (CacheWriterException e) { throw new TestException(TestHelper.getStackTrace(e)); } catch (TimeoutException e) { throw new TestException(TestHelper.getStackTrace(e)); } catch (EntryNotFoundException e) { throw new TestException(TestHelper.getStackTrace(e)); } return (nextKey >= keyIntervals.getLastKey(KeyIntervals.DESTROY)); }
/** * Do a get on a key in region REGION_NAME. Keys to get are specified in keyIntervals. * * @return true if all keys to have get performaed have been completed. */ protected boolean get() { SharedCounters sc = CQUtilBB.getBB().getSharedCounters(); long nextKey = sc.incrementAndRead(CQUtilBB.LASTKEY_GET); if (!keyIntervals.keyInRange(KeyIntervals.GET, nextKey)) { Log.getLogWriter().info("All gets completed; returning from get"); return true; } Object key = NameFactory.getObjectNameForCounter(nextKey); Log.getLogWriter().info("Getting " + key); try { Object existingValue = aRegion.get(key); Log.getLogWriter() .info( "Done getting " + key + ", num remaining: " + (keyIntervals.getLastKey(KeyIntervals.GET) - nextKey)); if (existingValue == null) throw new TestException("Get of key " + key + " returned unexpected " + existingValue); } catch (TimeoutException e) { throw new TestException(TestHelper.getStackTrace(e)); } catch (CacheLoaderException e) { throw new TestException(TestHelper.getStackTrace(e)); } return (nextKey >= keyIntervals.getLastKey(KeyIntervals.GET)); }
/** * Update an existing key in region REGION_NAME. The keys to update are specified in keyIntervals. * * @return true if all keys to be updated have been completed. */ protected boolean updateExistingKey() { long nextKey = CQUtilBB.getBB().getSharedCounters().incrementAndRead(CQUtilBB.LASTKEY_UPDATE_EXISTING_KEY); if (!keyIntervals.keyInRange(KeyIntervals.UPDATE_EXISTING_KEY, nextKey)) { Log.getLogWriter().info("All existing keys updated; returning from updateExistingKey"); return true; } Object key = NameFactory.getObjectNameForCounter(nextKey); QueryObject existingValue = (QueryObject) aRegion.get(key); if (existingValue == null) throw new TestException("Get of key " + key + " returned unexpected " + existingValue); QueryObject newValue = existingValue.modifyWithNewInstance(QueryObject.NEGATE, 0, true); newValue.extra = key; // encode the key in the object for later validation if (existingValue.aPrimitiveLong < 0) throw new TestException( "Trying to update a key which was already updated: " + existingValue.toStringFull()); Log.getLogWriter() .info("Updating existing key " + key + " with value " + TestHelper.toString(newValue)); aRegion.put(key, newValue); Log.getLogWriter() .info( "Done updating existing key " + key + " with value " + TestHelper.toString(newValue) + ", num remaining: " + (keyIntervals.getLastKey(KeyIntervals.UPDATE_EXISTING_KEY) - nextKey)); return (nextKey >= keyIntervals.getLastKey(KeyIntervals.UPDATE_EXISTING_KEY)); }
/** * Invalidate a key in region REGION_NAME. The keys to invalidate are specified in keyIntervals. * * @return true if all keys to be invalidated have been completed. */ protected boolean invalidate() { SharedCounters sc = CQUtilBB.getBB().getSharedCounters(); long nextKey = sc.incrementAndRead(CQUtilBB.LASTKEY_INVALIDATE); if (!keyIntervals.keyInRange(KeyIntervals.INVALIDATE, nextKey)) { Log.getLogWriter().info("All existing keys invalidated; returning from invalidate"); return true; } Object key = NameFactory.getObjectNameForCounter(nextKey); Log.getLogWriter().info("Invalidating " + key); checkContainsValueForKey(key, true, "before invalidate"); try { aRegion.invalidate(key); Log.getLogWriter() .info( "Done invalidating " + key + ", num remaining: " + (keyIntervals.getLastKey(KeyIntervals.INVALIDATE) - nextKey)); } catch (TimeoutException e) { throw new TestException(TestHelper.getStackTrace(e)); } catch (EntryNotFoundException e) { throw new TestException(TestHelper.getStackTrace(e)); } return (nextKey >= keyIntervals.getLastKey(KeyIntervals.INVALIDATE)); }
public void testUInt_withValidator() { final int[][] values = new int[][] { TestHelper.createUInts( new long[] { 2147483644L, 2147483645L, 2147483646L, 2147483647L, 2147483648L, 2147483649L, 2147483650L, 2147483651L }), TestHelper.createUInts(new long[] {2147483645L, 2147483647L, 2147483649L, 2147483651L}), TestHelper.createUInts(new long[] {2147483647L, 2147483648L, 2147483649L}) }; final boolean unsigned = true; final IndexValidator validator = new IndexValidator() { public boolean validateIndex(int index) { return index % 3 != 0; } }; final Histogram histogram = new Histogram(new int[6], 2147483645, 2147483650L); for (int i = 0; i < values.length; i++) { histogram.aggregate(values[i], unsigned, validator, ProgressMonitor.NULL); } final int[] exp = new int[] {1, 1, 1, 2, 3, 0}; assertEquals("", equal(exp, histogram.getBinCounts())); }
/** * This method check DefaultExpandedSideMenuPanel. * * @param collapseIcon the collapse icon * @param pinIcon the pin icon */ private void checkDefaultExpandedSideMenuPanel(Icon collapseIcon, Icon pinIcon) { assertEquals("sideMenuModel", sideMenuModel, target.getSideMenuModel()); ActionListener buttonListener = (ActionListener) TestHelper.getPrivateField( DefaultExpandedSideMenuPanel.class, target, "buttonListener"); // check buttonListener assertNotNull("buttonListener", buttonListener); // ((JToggleButton) target.getPinButton()).setSelected(true); // buttonListener.actionPerformed(new ActionEvent(target.getPinButton(), 1, "xxx")); // assertEquals("should be floating", true, sideMenuModel.isFloating()); ((JToggleButton) target.getPinButton()).setSelected(false); buttonListener.actionPerformed(new ActionEvent(target.getPinButton(), 1, "xxx")); assertEquals("should not be floating", false, sideMenuModel.isFloating()); buttonListener.actionPerformed(new ActionEvent(target.getCollapseButton(), 1, "xxx")); assertEquals("should not be expanded", false, sideMenuModel.isExpanded()); // check other fields assertEquals("content", TestHelper.CONTENT, target.getContent()); TestHelper.checkButton(target.getCollapseButton(), buttonListener, collapseIcon); TestHelper.checkButton(target.getPinButton(), buttonListener, pinIcon); assertEquals("Selected status", sideMenuModel.isFloating(), target.getPinButton().isSelected()); JLabel textLabel = (JLabel) TestHelper.getPrivateField(DefaultExpandedSideMenuPanel.class, target, "textLabel"); assertEquals("text of textLabel", sideMenuModel.getTitle(), textLabel.getText()); assertEquals( "HorizontalAlignment of textLabel", SwingConstants.CENTER, textLabel.getHorizontalAlignment()); }
/** * Verify step 2 form validation is working well(Start Date before current time) . * * @throws Exception if any error */ public void testFTC55() throws Exception { browser.click("link=Get A Copilot"); browser.waitForPageToLoad(TestHelper.getTimeout()); browser.click("link=Work with a Copilot"); browser.waitForPageToLoad(TestHelper.getTimeout()); browser.select("id=projects", "label=Client 1 Billing Account 1 Project 2"); browser.type( "dom=document.getElementById('allDescription_ifr').contentDocument.body", "Test Public Description"); browser.type( "dom=document.getElementById('privateDescription_ifr').contentDocument.body", "Test Specification Description"); String contest = "Contest " + System.currentTimeMillis(); browser.type("id=contestName", contest); browser.click("css=div.BottomBar > a.nextStepButton"); Thread.sleep(TestHelper.SLEEP * 10); browser.click("link=YES, DO IT LATER"); Thread.sleep(TestHelper.SLEEP); browser.click("css=div.BottomBar > a.nextStepButton"); Thread.sleep(TestHelper.SLEEP); assertTrue("error popup should be displayed", browser.isVisible("errortModal")); assertTrue( "error popup should be displayed", browser.isTextPresent("The start date should after current time")); }
/** * Verify breadcrumb is correct on Get a copilot step 2 page . * * @throws Exception if any error */ public void testFTC42() throws Exception { browser.click("link=Get A Copilot"); browser.waitForPageToLoad(TestHelper.getTimeout()); browser.click("link=Work with a Copilot"); browser.waitForPageToLoad(TestHelper.getTimeout()); browser.select("id=projects", "label=Client 1 Billing Account 1 Project 2"); browser.type( "dom=document.getElementById('allDescription_ifr').contentDocument.body", "Test Public Description"); browser.type( "dom=document.getElementById('privateDescription_ifr').contentDocument.body", "Test Specification Description"); String contest = "Contest " + System.currentTimeMillis(); browser.type("id=contestName", contest); browser.click("css=div.BottomBar > a.nextStepButton"); Thread.sleep(TestHelper.SLEEP * 10); assertTrue( "the page content is incorrect", browser.isTextPresent("Dashboard > Copilots > Post a Copilot")); browser.click("//a[contains(text(),'Copilots')]"); browser.waitForPageToLoad(TestHelper.getTimeout()); assertTrue( "the introduction must exist", browser.isTextPresent( "A Copilot is a TopCoder Member who manages the TopCoder process for a customer in order to" + " deliver a requested asset. For example, a customer may ask to build a website. A Copilot" + " will work with that customer to agree on a plan and pricing to build that website and" + " then they would manage the process using the TopCoder Platform to deliver the website" + " back to the customer.")); }
/** * Verify "Save As Draft" button on get a copilot step 2 page is working well . * * @throws Exception if any error */ public void testFTC50() throws Exception { browser.click("link=Get A Copilot"); browser.waitForPageToLoad(TestHelper.getTimeout()); browser.click("link=Work with a Copilot"); browser.waitForPageToLoad(TestHelper.getTimeout()); browser.select("id=projects", "label=Client 1 Billing Account 1 Project 2"); browser.type( "dom=document.getElementById('allDescription_ifr').contentDocument.body", "Test Public Description"); browser.type( "dom=document.getElementById('privateDescription_ifr').contentDocument.body", "Test Specification Description"); String contest = "Contest " + System.currentTimeMillis(); browser.type("id=contestName", contest); browser.click("css=div.BottomBar > a.nextStepButton"); Thread.sleep(TestHelper.SLEEP * 10); browser.click("css=span.right"); Thread.sleep(TestHelper.SLEEP * 10); assertTrue("the page content is incorrect", browser.isVisible("demoModal")); assertTrue( "the page content is incorrect", browser.isTextPresent( "Your Copilot Posting " + contest + " has been saved as draft successfully.")); browser.click("css=span.btnC"); assertFalse("the page content is incorrect", browser.isVisible("demoModal")); }
@Test public void handleSuccess() throws Exception { response.setStatus(SAMLUtil.createStatus(StatusCode.SUCCESS_URI)); response.setDestination(spMetadata.getAssertionConsumerServiceLocation(0)); Assertion assertion = TestHelper.buildAssertion( spMetadata.getAssertionConsumerServiceLocation(0), spMetadata.getEntityID()); response.getAssertions().add(assertion); final String xml = TestHelper.signObject(response, credential); context.checking( new Expectations() { { atLeast(1).of(req).getParameter(Constants.SAML_SAMLRESPONSE); will(returnValue(Base64.encodeBytes(xml.getBytes()))); allowing(req).getParameter(Constants.SAML_RELAYSTATE); will( returnValue( handler.saveRequest( new Request("uri", "query", "GET", new HashMap<String, String[]>())))); one(session) .setAttribute( with(equal(Constants.SESSION_USER_ASSERTION)), with(any(UserAssertion.class))); one(res).sendRedirect("uri?query"); one(req).getCookies(); will(returnValue(null)); one(session).getMaxInactiveInterval(); will(returnValue(30)); } }); expectCacheHeaders(); sh.handlePost(ctx); }
/** * Verify there will be some elements displayed after click "Yes, Post Now" button . * * @throws Exception if any error */ public void testFTC48() throws Exception { browser.click("link=Get A Copilot"); browser.waitForPageToLoad(TestHelper.getTimeout()); browser.click("link=Work with a Copilot"); browser.waitForPageToLoad(TestHelper.getTimeout()); browser.select("id=projects", "label=Client 1 Billing Account 1 Project 2"); browser.type( "dom=document.getElementById('allDescription_ifr').contentDocument.body", "Test Public Description"); browser.type( "dom=document.getElementById('privateDescription_ifr').contentDocument.body", "Test Specification Description"); String contest = "Contest " + System.currentTimeMillis(); browser.type("id=contestName", contest); browser.click("css=div.BottomBar > a.nextStepButton"); Thread.sleep(TestHelper.SLEEP * 10); browser.click("link=YES, POST NOW"); Thread.sleep(TestHelper.SLEEP); assertTrue( "the page content is incorrect", browser.isTextPresent( "Most copilot postings are listed with $150 first place and $75 second place" + " payments for a total cost of $225.")); assertTrue( "the page content is incorrect", browser.isTextPresent( "Would you like to proceed with this amount or set your own amount?")); assertTrue("the page content is incorrect", browser.isElementPresent("amount")); }
/** * Verify "Back to Dashboard" button on Get a copilot step 2 page is working well . * * @throws Exception if any error */ public void testFTC44() throws Exception { browser.click("link=Get A Copilot"); browser.waitForPageToLoad(TestHelper.getTimeout()); browser.click("link=Work with a Copilot"); browser.waitForPageToLoad(TestHelper.getTimeout()); browser.select("id=projects", "label=Client 1 Billing Account 1 Project 2"); browser.type( "dom=document.getElementById('allDescription_ifr').contentDocument.body", "Test Public Description"); browser.type( "dom=document.getElementById('privateDescription_ifr').contentDocument.body", "Test Specification Description"); String contest = "Contest " + System.currentTimeMillis(); browser.type("id=contestName", contest); browser.click("css=div.BottomBar > a.nextStepButton"); Thread.sleep(TestHelper.SLEEP * 10); browser.click("link=Back to Dashboard"); browser.waitForPageToLoad(TestHelper.getTimeout()); assertTrue( "the page content is incorrect", browser.isTextPresent("Dashboard > All Active Contests")); assertTrue( "the page content is incorrect", browser.isElementPresent("//img[@src='/images/dashboard_logo.png']")); }
@Test public void testCommitsSurviveShutDown() throws Exception { GeoGIG geogig = helper.getGeogig(); insert(); update(); List<RevCommit> expected = ImmutableList.copyOf(geogig.command(LogOp.class).call()); File repoDir = helper.getRepositoryDirectory(); assertTrue(repoDir.exists() && repoDir.isDirectory()); // shut down server destroyGeoServer(); TestPlatform testPlatform = new TestPlatform(repoDir); Context context = new CLITestContextBuilder(testPlatform).build(); geogig = new GeoGIG(context); try { assertNotNull(geogig.getRepository()); List<RevCommit> actual = ImmutableList.copyOf(geogig.command(LogOp.class).call()); assertEquals(expected, actual); } finally { geogig.close(); } }
private void configureGeogigDataStore() throws Exception { helper.insertAndAdd(helper.lines1); helper.getGeogig().command(CommitOp.class).call(); Catalog catalog = getCatalog(); CatalogFactory factory = catalog.getFactory(); NamespaceInfo ns = factory.createNamespace(); ns.setPrefix(WORKSPACE); ns.setURI(NAMESPACE); catalog.add(ns); WorkspaceInfo ws = factory.createWorkspace(); ws.setName(ns.getName()); catalog.add(ws); DataStoreInfo ds = factory.createDataStore(); ds.setEnabled(true); ds.setDescription("Test Geogig DataStore"); ds.setName(STORE); ds.setType(GeoGigDataStoreFactory.DISPLAY_NAME); ds.setWorkspace(ws); Map<String, Serializable> connParams = ds.getConnectionParameters(); Optional<URI> geogigDir = helper.getGeogig().command(ResolveGeogigURI.class).call(); File repositoryUrl = new File(geogigDir.get()).getParentFile(); assertTrue(repositoryUrl.exists() && repositoryUrl.isDirectory()); connParams.put(GeoGigDataStoreFactory.REPOSITORY.key, repositoryUrl); connParams.put(GeoGigDataStoreFactory.DEFAULT_NAMESPACE.key, ns.getURI()); catalog.add(ds); DataStoreInfo dsInfo = catalog.getDataStoreByName(WORKSPACE, STORE); assertNotNull(dsInfo); assertEquals(GeoGigDataStoreFactory.DISPLAY_NAME, dsInfo.getType()); DataAccess<? extends FeatureType, ? extends Feature> dataStore = dsInfo.getDataStore(null); assertNotNull(dataStore); assertTrue(dataStore instanceof GeoGigDataStore); FeatureTypeInfo fti = factory.createFeatureType(); fti.setNamespace(ns); fti.setCatalog(catalog); fti.setStore(dsInfo); fti.setSRS("EPSG:4326"); fti.setName("Lines"); fti.setAdvertised(true); fti.setEnabled(true); fti.setCqlFilter("INCLUDE"); fti.setProjectionPolicy(ProjectionPolicy.FORCE_DECLARED); ReferencedEnvelope bounds = new ReferencedEnvelope(-180, 180, -90, 90, CRS.decode("EPSG:4326")); fti.setNativeBoundingBox(bounds); fti.setLatLonBoundingBox(bounds); catalog.add(fti); fti = catalog.getFeatureType(fti.getId()); FeatureSource<? extends FeatureType, ? extends Feature> featureSource; featureSource = fti.getFeatureSource(null, null); assertNotNull(featureSource); }
@Override protected TestCaseFiles getTestCaseFiles(Benchmark prog) { return TestHelper.compileToLLVMIRWithClang( prog.getFile(), TestHelper.getTempLLFile(prog.getFile(), "_main"), prog.getFlags(), ClangOptions.builder().optimizationLevel(OptimizationLevel.O1)); }
@Override protected void setUp() throws Exception { super.setUp(); // To change body of overridden methods use File | Settings | File Templates. TestHelper.setupLogging(); final File fileLocation = new File(TestHelper.getParameter("pwmDBlocation")); pwmDB = LocalDBFactory.getInstance(fileLocation, false, null, null); pwmDB.truncate(TEST_DB); Assert.assertEquals(0, pwmDB.size(TEST_DB)); }
/** Start all cqs running for this VM, and create a CQHistory instance for each CQ. */ private void startCQsWithHistory() { initializeQueryService(); CqAttributesFactory cqFac = new CqAttributesFactory(); cqFac.addCqListener(new CQHistoryListener()); cqFac.addCqListener(new CQGatherListener()); CqAttributes cqAttr = cqFac.create(); Iterator it = queryMap.keySet().iterator(); while (it.hasNext()) { String queryName = (String) (it.next()); String query = (String) (queryMap.get(queryName)); try { CqQuery cq = qService.newCq(queryName, query, cqAttr); CQHistory history = new CQHistory(cq.getName()); CQHistoryListener.recordHistory(history); Log.getLogWriter() .info( "Creating CQ with name " + queryName + ": " + query + ", cq attributes: " + cqAttr); Log.getLogWriter().info("Calling executeWithInitialResults on " + cq); CqResults rs = cq.executeWithInitialResults(); SelectResults sr = CQUtil.getSelectResults(rs); if (sr == null) { throw new TestException( "For cq " + cq + " with name " + cq.getName() + " executeWithInitialResults returned " + sr); } Log.getLogWriter() .info( "Done calling executeWithInitializResults on " + cq + " with name " + queryName + ", select results size is " + sr.size()); history.setSelectResults(sr); logNumOps(); // log the select results List srList = sr.asList(); StringBuffer aStr = new StringBuffer(); aStr.append("SelectResults returned from " + queryName + " is\n"); for (int i = 0; i < srList.size(); i++) { aStr.append(srList.get(i) + "\n"); } Log.getLogWriter().info(aStr.toString()); } catch (CqExistsException e) { throw new TestException(TestHelper.getStackTrace(e)); } catch (RegionNotFoundException e) { throw new TestException(TestHelper.getStackTrace(e)); } catch (CqException e) { throw new TestException(TestHelper.getStackTrace(e)); } } }
void executeNonTransactionTest() { TestHelper.assertNotInTransaction(); helper.execute("INSERT INTO Foo VALUES('g', 'G')"); assertData("g", "G"); TestHelper.assertNotInTransaction(); helper.execute("INSERT INTO Foo VALUES('h', 'H')"); assertData("h", "H"); TestHelper.assertNotInTransaction(); }
protected void compareFiles(Map<String, TestSourceFile> testResourceFiles) throws Exception { for (String fileName : testResourceFiles.keySet()) { TestSourceFile file = testResourceFiles.get(fileName); IFile iFile = project.getFile(new Path(fileName)); StringBuilder code = getCodeFromFile(iFile); assertEquals( TestHelper.unifyNewLines(file.getExpectedSource()), TestHelper.unifyNewLines(code.toString())); } }
@Transactional private void executeTestNested(ConnectionInfo info) { helper.execute("INSERT INTO Foo VALUES('e', 'E')"); assertData("e", "E"); TestHelper.assertInTransaction(info); helper.execute("INSERT INTO Foo VALUES('f', 'F')"); assertData("f", "F"); TestHelper.assertInTransaction(info); executeNestedNonTransactionTest(info); }
@AfterClass public static void tearDown() { try { TestHelper.clearFeed(client, feed); client.feeds().delete(feed).execute(); } catch (LocomatixException le) { System.out.println(le.getMessage()); } TestHelper.shutdownClient(client); }
/** Set up the context for a scenario. */ @Override protected void setUp() throws Exception { if (helper == null) { helper = new TestHelper(); helper.doSetup(); repoProvider = new GeoServerRepositoryProvider(); RepositoryManager.get().setCatalog(helper.getCatalog()); } }
public static void testBroken() { int[][] s = { {1, 0, 0, 0}, {1, 1, 1, 0}, {1, 1, 1, 1} }; Robot r = TestHelper.makeBot(s); ExpandAll e = new ExpandAll(r); TestHelper.runMove(e); r.drawUnit(); }
@Transactional void executeTest() { TestHelper.assertInTransaction(); helper.execute("INSERT INTO Foo VALUES('c', 'C')"); assertData("c", "C"); ConnectionInfo info = TestHelper.getConnectionInfo(); helper.execute("INSERT INTO Foo VALUES('d', 'D')"); assertData("d", "D"); TestHelper.assertInTransaction(info); executeTestNested(info); }