@Test public void testSaveServer() throws ResourceNotFoundFault, IllegalParameterFault { logger.trace("\n@@@ testSaveServer @@@"); // Server is into DB ServerDTO serverGeoSDI = gpWSClient.getShortServer(serverUrlGeoSDI); Assert.assertNotNull(serverGeoSDI); ServerDTO serverDTO = gpWSClient.saveServer( serverGeoSDI.getId(), "geoSDI", serverUrlGeoSDI, organizationTest.getName()); Assert.assertNotNull("ServerDTO geoSDI is NULL", serverDTO); Assert.assertEquals("ServerDTO geoSDI alias is wrong", serverDTO.getAlias(), "geoSDI"); // Server is NOT into DB String serverUrlEx = "http://iws.erdas.com/ecwp/ecw_wms.dll?request=GetCapabilities"; serverDTO = gpWSClient.saveServer(null, "Erdas", serverUrlEx, organizationTest.getName()); Assert.assertNotNull("ServerDTO EX is NULL", serverDTO); // Check if the server was insert GeoPlatformServer serverEx = gpWSClient.getServerDetailByUrl(serverUrlEx); Assert.assertNotNull("Server Ex is NULL for URL", serverEx); Assert.assertEquals("Server Ex URL is NOT correct", serverUrlEx, serverEx.getServerUrl()); Assert.assertEquals("Server Ex ID is NOT correct", serverDTO.getId(), serverEx.getId()); // Delete server gpWSClient.deleteServer(serverEx.getId()); }
@Test public void withHeaderMapperStandardAndCustomHeaders() { AmqpInboundChannelAdapter adapter = context.getBean( "withHeaderMapperStandardAndCustomHeaders", AmqpInboundChannelAdapter.class); AbstractMessageListenerContainer mlc = TestUtils.getPropertyValue( adapter, "messageListenerContainer", AbstractMessageListenerContainer.class); MessageListener listener = TestUtils.getPropertyValue(mlc, "messageListener", MessageListener.class); MessageProperties amqpProperties = new MessageProperties(); amqpProperties.setAppId("test.appId"); amqpProperties.setClusterId("test.clusterId"); amqpProperties.setContentEncoding("test.contentEncoding"); amqpProperties.setContentLength(99L); amqpProperties.setContentType("test.contentType"); amqpProperties.setHeader("foo", "foo"); amqpProperties.setHeader("bar", "bar"); Message amqpMessage = new Message("hello".getBytes(), amqpProperties); listener.onMessage(amqpMessage); QueueChannel requestChannel = context.getBean("requestChannel", QueueChannel.class); org.springframework.integration.Message<?> siMessage = requestChannel.receive(0); assertEquals("foo", siMessage.getHeaders().get("foo")); assertNull(siMessage.getHeaders().get("bar")); assertNotNull(siMessage.getHeaders().get(AmqpHeaders.CONTENT_ENCODING)); assertNotNull(siMessage.getHeaders().get(AmqpHeaders.CLUSTER_ID)); assertNotNull(siMessage.getHeaders().get(AmqpHeaders.APP_ID)); assertNotNull(siMessage.getHeaders().get(AmqpHeaders.CONTENT_TYPE)); }
private void checkRenderedSelectedCells( final int selectionRowIndex, final int selectionColumnIndex, final int selectionColumnCount, final int selectionRowCount, final int minVisibleRowIndex, final int maxVisibleRowIndex) { this.model.selectCells( selectionRowIndex, selectionColumnIndex, selectionColumnCount, selectionRowCount); when(context.getMinVisibleRowIndex()).thenReturn(minVisibleRowIndex); when(context.getMaxVisibleRowIndex()).thenReturn(maxVisibleRowIndex); renderer.renderSelectedCells(model, context, rendererHelper); verify(renderer, times(1)) .renderSelectedRange( eq(model), columnsCaptor.capture(), eq(selectionColumnIndex), selectedRangeCaptor.capture()); final List<GridColumn<?>> columns = columnsCaptor.getValue(); assertNotNull(columns); assertEquals(1, columns.size()); assertEquals(column, columns.get(0)); final SelectedRange selectedRange = selectedRangeCaptor.getValue(); assertNotNull(selectedRange); assertEquals(selectionColumnIndex, selectedRange.getUiColumnIndex()); assertEquals(minVisibleRowIndex, selectedRange.getUiRowIndex()); assertEquals(selectionColumnCount, selectedRange.getWidth()); assertEquals(maxVisibleRowIndex - minVisibleRowIndex + 1, selectedRange.getHeight()); }
@Ignore // git based vfs does not yet support move @Test public void testMoveEmptyDirectory() throws NoSuchFileException { Repository repository = new VFSRepository(producer.getIoService()); ((VFSRepository) repository).setDescriptor(descriptor); Directory sourceDir = repository.createDirectory("/source"); boolean directoryExists = repository.directoryExists(sourceDir.getLocation() + sourceDir.getName()); assertTrue(directoryExists); Collection<Asset> foundAsset = repository.listAssets("/source", new FilterByExtension("bpmn2")); assertNotNull(foundAsset); assertEquals(0, foundAsset.size()); boolean copied = repository.moveDirectory("/source", "/", "target"); assertTrue(copied); boolean movedDirectoryExists = repository.directoryExists("/source"); assertFalse(movedDirectoryExists); movedDirectoryExists = repository.directoryExists("/target"); assertTrue(movedDirectoryExists); foundAsset = repository.listAssets("/target", new FilterByExtension("bpmn2")); assertNotNull(foundAsset); assertEquals(0, foundAsset.size()); }
@Test public void shouldGetVdbs() throws Exception { loadVdbs(); // get URI uri = _uriBuilder.generateVdbsUri(); this.response = request(uri).get(); assertTrue(response.hasEntity()); final String entities = response.readEntity(String.class); assertThat(entities, is(notNullValue())); // System.out.println("Response:\n" + entities); // make sure the VDB JSON document is returned for each vdb RestVdb[] vdbs = KomodoJsonMarshaller.unmarshallArray(entities, RestVdb[].class); assertEquals(4, vdbs.length); boolean foundPortfolio = false; for (RestVdb vdb : vdbs) { assertNotNull(vdb.getId()); assertNotNull(vdb.getDataPath()); assertNotNull(vdb.getkType()); if (TestUtilities.PORTFOLIO_VDB_NAME.equals(vdb.getId())) { foundPortfolio = true; assertPortfolio(vdb); } } assertTrue(foundPortfolio); }
@Test public void path() { assertNotNull(EnvironmentUtil.getValue("PATH")); if (SystemInfo.isWindows) { assertNotNull(EnvironmentUtil.getValue("Path")); } }
@Test public void testUpdateAsset() throws NoSuchFileException { Repository repository = new VFSRepository(producer.getIoService()); ((VFSRepository) repository).setDescriptor(descriptor); AssetBuilder builder = AssetBuilderFactory.getAssetBuilder(Asset.AssetType.Text); builder.content("simple content").type("bpmn2").name("process").location("/"); String id = repository.createAsset(builder.getAsset()); Collection<Asset> foundAsset = repository.listAssets("/", new FilterByExtension("bpmn2")); assertNotNull(foundAsset); assertEquals(1, foundAsset.size()); builder.content("updated content").uniqueId(id); id = repository.updateAsset(builder.getAsset(), "", ""); foundAsset = repository.listAssetsRecursively("/", new FilterByFileName("process.bpmn2")); assertNotNull(foundAsset); assertEquals(1, foundAsset.size()); String content = ((Asset<String>) repository.loadAsset(id)).getAssetContent(); assertNotNull(content); assertEquals("updated content", content); }
public void initCapability() { try { log.info("INFO: Before test, getting queue..."); Assert.assertNotNull(queueManagerFactory); queueCapability = queueManagerFactory.create(mockResource); queueCapability.initialize(); protocolManager.getProtocolSessionManagerWithContext( mockResource.getResourceId(), newSessionContextNetconf()); // Test elements not null log.info("Checking chassis factory"); Assert.assertNotNull(chassisFactory); log.info("Checking capability descriptor"); Assert.assertNotNull(mockResource.getResourceDescriptor().getCapabilityDescriptor("chassis")); log.info("Creating chassis capability"); chassisCapability = chassisFactory.create(mockResource); Assert.assertNotNull(chassisCapability); chassisCapability.initialize(); mockResource.addCapability(chassisCapability); mockResource.addCapability(queueCapability); } catch (Exception e) { e.printStackTrace(); log.error(e.getMessage()); if (ExceptionUtils.getRootCause(e) != null) log.error(ExceptionUtils.getRootCause(e).getMessage()); Assert.fail(e.getMessage()); } }
@Test @DatabaseSetup(PATH_TO_NEWS) public void testList() throws Exception { List<News> list = newsDAO.list(); Assert.assertNotNull(list); for (News news : list) { Assert.assertNotNull(news); if (news.getId() == 1L) { News newsExp = new News(); newsExp.setShortText("test short"); newsExp.setFullText("test full"); newsExp.setTitle("test title"); SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); Date date = dateFormat.parse("01/01/2015 11:10:00"); newsExp.setCreationDate(date); newsExp.setModificationDate(new Timestamp(date.getTime())); newsExp.setId(1L); assertNews(newsExp, news); } } }
@Override @Before public void setUp() throws Exception { super.setUp(); DatabaseHelper.DATABASE.setUp(); deployBundle("org.nuxeo.ecm.core.schema"); deployBundle("org.nuxeo.ecm.core"); deployBundle("org.nuxeo.ecm.core.event"); deployBundle("org.nuxeo.ecm.core.api"); deployBundle("org.nuxeo.ecm.directory.api"); deployBundle("org.nuxeo.ecm.directory"); deployBundle("org.nuxeo.ecm.directory.sql"); deployBundle("org.nuxeo.ecm.directory.types.contrib"); deployContrib("org.nuxeo.ecm.platform.query.api", "OSGI-INF/pageprovider-framework.xml"); deployBundle("org.nuxeo.ecm.platform.usermanager.api"); deployBundle("org.nuxeo.ecm.platform.usermanager"); deployContrib( "org.nuxeo.ecm.platform.usermanager.tests", "test-usermanagerimpl/directory-config.xml"); deployContrib("org.nuxeo.ecm.platform.usermanager.tests", "computedgroups-contrib.xml"); ppService = Framework.getService(PageProviderService.class); assertNotNull(ppService); userManager = Framework.getService(UserManager.class); assertNotNull(userManager); initGroups(); }
@Test @SuppressWarnings("unchecked") public void testGroupsPageProviderSearchMode() { Map<String, Serializable> properties = new HashMap<String, Serializable>(); properties.put( AbstractGroupsPageProvider.GROUPS_LISTING_MODE_PROPERTY, AbstractGroupsPageProvider.SEARCH_ONLY_MODE); PageProvider<DocumentModel> groupsProvider = (PageProvider<DocumentModel>) ppService.getPageProvider(PROVIDER_NAME, null, null, null, properties, "gr"); List<DocumentModel> groups = groupsProvider.getCurrentPage(); assertNotNull(groups); assertEquals(2, groups.size()); DocumentModel group = groups.get(0); assertEquals("group1", group.getId()); group = groups.get(1); assertEquals("group2", group.getId()); // check computed groups groupsProvider = (PageProvider<DocumentModel>) ppService.getPageProvider(PROVIDER_NAME, null, null, null, properties, "Grp"); groups = groupsProvider.getCurrentPage(); assertNotNull(groups); assertEquals(2, groups.size()); group = groups.get(0); assertEquals("Grp1", group.getId()); group = groups.get(1); assertEquals("Grp2", group.getId()); }
@Test public void testOutputSourceExpression() { // given: String source = "${a}"; ExtensionElements extensionElements = addExtensionElements(caseTask); CamundaOut sourceElement = createElement(extensionElements, null, CamundaOut.class); sourceElement.setCamundaSourceExpression(source); // when CmmnActivity activity = handler.handleElement(planItem, context); // then CaseTaskActivityBehavior behavior = (CaseTaskActivityBehavior) activity.getActivityBehavior(); CallableElement callableElement = behavior.getCallableElement(); CallableElementParameter parameter = callableElement.getOutputs().get(0); assertNotNull(parameter); assertFalse(parameter.isAllVariables()); ParameterValueProvider sourceExpressionValueProvider = parameter.getSourceValueProvider(); assertNotNull(sourceExpressionValueProvider); assertTrue(sourceExpressionValueProvider instanceof ElValueProvider); ElValueProvider valueProvider = (ElValueProvider) sourceExpressionValueProvider; assertEquals(source, valueProvider.getExpression().getExpressionText()); }
@Test public void testGetNotNullViewList() throws Exception { ViewList viewList = client.getViewList(); assertNotNull(viewList); assertNotNull(viewList.getViews()); assertNotNull(viewList.getPrimaryView()); }
@Test public void testReentrantLock() { long start = System.currentTimeMillis(); String asset = "p1"; // make sure the lock is created first PLock pc = pessimisticLockManager.findOrPersistPLock(asset); assertNotNull(pc); dbInstance.closeSession(); // test double acquisition within same transaction PLock pc1 = pessimisticLockManager.findOrPersistPLock(asset); assertNotNull(pc1); PLock pc2 = pessimisticLockManager.findOrPersistPLock(asset); assertNotNull(pc2); dbInstance.closeSession(); // and without explicit transaction boundary. PLock p1 = pessimisticLockManager.findOrPersistPLock(asset); assertNotNull(p1); PLock p2 = pessimisticLockManager.findOrPersistPLock(asset); assertNotNull(p2); long stop = System.currentTimeMillis(); long diff = stop - start; assertTrue( "5 select's took longer than 10 seconds -> deadlock / lock timeout ? dur in ms was:" + diff, diff < 10000); }
@Test public void testGetANDPermissions() { // given a new user User u1 = new User(); String login = "******"; String password = "******"; u1.setLogin(login); u1.setPassword(password); ArrayList<String> permissions = new ArrayList<String>(); permissions.add("ADMIN"); permissions.add("USER"); u1.getPermissions().addAll(permissions); dao.save(u1); // when we search him by his login and password List<User> l = dao.findEquals("Login", login); assertNotNull(l); u1 = l.get(0); // we get the user as response assertNotNull(u1); assertEquals(login, u1.getLogin()); assertEquals(u1.getPermissions().get(0), "ADMIN"); // TODO : remove this when we will use DBunit u1.getPermissions().clear(); }
/** * In this test we try to test :<br> * - if the formula engine picks the 2 specified columns from 2 different business tables<br> * - if we calculate the multiplication of the sums <br> */ @Test public void testMultiTableColumnFormulasAggregate2() throws Exception { LogicalColumn quantityOrdered = getOrdersModel().findLogicalColumn("BC_ORDER_DETAILS_QUANTITYORDERED"); Assert.assertNotNull( "Expected to find the business column 'quantity ordered'", quantityOrdered); LogicalColumn buyPrice = getOrdersModel().findLogicalColumn("BC_PRODUCTS_BUYPRICE"); Assert.assertNotNull("Expected to find the business column 'buy price'", buyPrice); // let's enable the aggregations of the quantity ordered... // AggregationType qaBackup = quantityOrdered.getAggregationType(); AggregationType paBackup = buyPrice.getAggregationType(); quantityOrdered.setAggregationType(AggregationType.SUM); buyPrice.setAggregationType(AggregationType.SUM); // This changes the expected result... // String formula = "[BT_ORDER_DETAILS.BC_ORDER_DETAILS_QUANTITYORDERED] * [BT_PRODUCTS.BC_PRODUCTS_BUYPRICE]"; String sql = "SUM(BT_ORDER_DETAILS.QUANTITYORDERED) * SUM(BT_PRODUCTS.BUYPRICE)"; handleFormula(getOrdersModel(), "Hypersonic", formula, sql); // Set it back to the way it was for further testing. quantityOrdered.setAggregationType(qaBackup); buyPrice.setAggregationType(paBackup); }
@Test public void testAutowireCandidateByName() { GoldCustomer customer = applicationContext.getBean("goldCustomer", GoldCustomer.class); assertNotNull(customer); assertNotNull(customer.getGoldOrder()); }
@SuppressWarnings("unused") public void methodOne(@Observes Object event) { Assert.assertNotNull(event); Assert.assertNotNull(stringEvent); stringEvent.fire("some string"); methodOneWasCalled = true; }
@Test public void testDirectoryExists() { Repository repository = new VFSRepository(producer.getIoService()); ((VFSRepository) repository).setDescriptor(descriptor); boolean rootFolderExists = repository.directoryExists("/test"); assertFalse(rootFolderExists); Directory directoryId = repository.createDirectory("/test"); assertNotNull(directoryId); assertEquals("test", directoryId.getName()); assertEquals("/", directoryId.getLocation()); assertNotNull(directoryId.getUniqueId()); rootFolderExists = repository.directoryExists("/test"); assertTrue(rootFolderExists); AssetBuilder builder = AssetBuilderFactory.getAssetBuilder(Asset.AssetType.Byte); builder.content("simple content".getBytes()).type("png").name("test").location("/test"); String id = repository.createAsset(builder.getAsset()); assertNotNull(id); boolean assetPathShouldNotExists = repository.directoryExists("/test/test.png"); assertFalse(assetPathShouldNotExists); }
@Test @WrapInMockProbeExecution public void testCombination() throws ServletException, IOException { Filter filter = new MockFilterWithServlet(); MockHttpServletRequest request = new MockHttpServletRequest("GET", "/test"); MockHttpServletResponse response = new MockHttpServletResponse(); MockFilterChain chain = new MockFilterChain(); filter.doFilter(request, response, chain); // perform assertions OperationSafeImpl operation = Agent.getInstance().getCurrentOperation(); Iterator<TraceEventSafeImpl> iterator = operation.getTrace().getEvents().iterator(); assertTrue(iterator.hasNext()); ProbeExecution mockProbeExecution = iterator.next().getProbeExecution(); assertNotNull(mockProbeExecution); assertTrue(mockProbeExecution instanceof MockProbeExecution); assertTrue(iterator.hasNext()); ProbeExecution probeExecution = iterator.next().getProbeExecution(); assertTrue(probeExecution instanceof ServletProbeExecution); ServletProbeExecution filterProbeExecution = (ServletProbeExecution) probeExecution; assertTrue(filterProbeExecution.getClazz().equals(MockFilterWithServlet.class)); assertNotNull(filterProbeExecution.getRequestURI()); assertTrue(iterator.hasNext()); ProbeExecution nestedProbeExecution = iterator.next().getProbeExecution(); assertTrue(nestedProbeExecution instanceof ServletProbeExecution); ServletProbeExecution servletProbeExecution = (ServletProbeExecution) nestedProbeExecution; assertEquals(MockServlet.class, servletProbeExecution.getClazz()); }
@Ignore // git based vfs does not yet support move @Test public void testMoveDirectory() throws NoSuchFileException { Repository repository = new VFSRepository(producer.getIoService()); ((VFSRepository) repository).setDescriptor(descriptor); Directory sourceDir = repository.createDirectory("/source"); AssetBuilder builder = AssetBuilderFactory.getAssetBuilder(Asset.AssetType.Text); builder.content("simple content").type("bpmn2").name("process").location("/source"); String id = repository.createAsset(builder.getAsset()); Collection<Asset> foundAsset = repository.listAssets("/source", new FilterByExtension("bpmn2")); assertNotNull(foundAsset); assertEquals(1, foundAsset.size()); boolean assetExistsBeforeDelete = repository.assetExists(id); assertTrue(assetExistsBeforeDelete); boolean copied = repository.moveDirectory("/source", "/target", null); assertTrue(copied); foundAsset = repository.listAssets("/target/source", new FilterByExtension("bpmn2")); assertNotNull(foundAsset); assertEquals(1, foundAsset.size()); boolean assetExists = repository.assetExists("/target/source/process.bpmn2"); assertTrue(assetExists); boolean movedDirectoryExists = repository.directoryExists("/source"); assertFalse(movedDirectoryExists); }
@Test public void updateWithoutApproval() { // 1. create user as admin UserTO created = createUser(UserITCase.getUniqueSampleTO("*****@*****.**")).getEntity(); assertNotNull(created); assertFalse(created.getUsername().endsWith("XX")); // 2. self-update (username) - works UserPatch userPatch = new UserPatch(); userPatch.setKey(created.getKey()); userPatch.setUsername( new StringReplacePatchItem.Builder().value(created.getUsername() + "XX").build()); SyncopeClient authClient = clientFactory.create(created.getUsername(), "password123"); UserTO updated = authClient .getService(UserSelfService.class) .update(userPatch) .readEntity(new GenericType<ProvisioningResult<UserTO>>() {}) .getEntity(); assertNotNull(updated); assertEquals( ActivitiDetector.isActivitiEnabledForUsers(syncopeService) ? "active" : "created", updated.getStatus()); assertTrue(updated.getUsername().endsWith("XX")); }
/** @throws DSLException . */ @Test public void testBasicExtendParsing() throws DSLException { final File testParsingBaseDslFile = new File(TEST_PARSING_RESOURCE_PATH + "test_parsing_base-service.groovy"); final File testParsingBaseWorkDir = new File(TEST_PARSING_RESOURCE_PATH); final Service baseService = ServiceReader.getServiceFromFile(testParsingBaseDslFile, testParsingBaseWorkDir) .getService(); Assert.assertFalse(baseService.getName().equals("test parsing extend")); final ServiceLifecycle baseLifecycle = baseService.getLifecycle(); Assert.assertFalse(baseLifecycle.getInit().equals("test_parsing_extend_install.groovy")); Assert.assertNull(baseLifecycle.getStop()); final File testParsingExtendDslFile = new File(TEST_PARSING_RESOURCE_PATH + "test_parsing_extend-service.groovy"); final File testParsingExtendWorkDir = new File(TEST_PARSING_RESOURCE_PATH); final Service service = ServiceReader.getServiceFromFile(testParsingExtendDslFile, testParsingExtendWorkDir) .getService(); Assert.assertEquals("test parsing extend", service.getName()); final ServiceLifecycle lifecycle = service.getLifecycle(); Assert.assertEquals(ExecutableDSLEntryType.STRING, lifecycle.getInit().getEntryType()); Assert.assertEquals( "test_parsing_extend_install.groovy", ((StringExecutableEntry) lifecycle.getInit()).getCommand()); Assert.assertNotNull(lifecycle.getStart()); Assert.assertNotNull(lifecycle.getPostStart()); Assert.assertNotNull(lifecycle.getPreStop()); Assert.assertNotNull(lifecycle.getStop()); Assert.assertEquals(1, service.getExtendedServicesPaths().size()); Assert.assertEquals( new File(TEST_PARSING_RESOURCE_PATH, "test_parsing_base-service.groovy").getAbsolutePath(), service.getExtendedServicesPaths().getFirst()); }
@Test public void targetIsNotNull() { assertNotNull(target); assertNotNull(target.theNameForTheMeter); Meter meter = (Meter) forInjectMetricField( metricRegistry, InjectMetricTest.Target.class, "theNameForTheMeter"); assertSame(target.theNameForTheMeter, meter); assertNotNull(target.timer); Timer timer = (Timer) forInjectMetricField(metricRegistry, InjectMetricTest.Target.class, "timer"); assertSame(target.timer, timer); assertNotNull(target.counter); Counter ctr = (Counter) forInjectMetricField(metricRegistry, InjectMetricTest.Target.class, "counter"); assertSame(target.counter, ctr); assertNotNull(target.histogram); Histogram hist = (Histogram) forInjectMetricField(metricRegistry, InjectMetricTest.Target.class, "histogram"); assertSame(target.histogram, hist); }
/** Tests that a third-party service that fails in dispose */ @Test public void testFailingInDisposeThirdPartyService() { ServiceLocator locator = LocatorHelper.getServiceLocator(RecordingErrorService.class); AlwaysFailInDisposeActiveDescriptor thirdPartyDescriptor = new AlwaysFailInDisposeActiveDescriptor(); ServiceLocatorUtilities.addOneDescriptor(locator, thirdPartyDescriptor); ActiveDescriptor<?> serviceDescriptor = locator.getBestDescriptor( BuilderHelper.createContractFilter(SimpleService.class.getName())); Assert.assertNotNull(serviceDescriptor); ServiceHandle<SimpleService> handle = locator.getServiceHandle(SimpleService.class); Assert.assertNotNull(handle); Assert.assertNotNull(handle.getService()); handle.destroy(); List<ErrorInformation> errors = locator.getService(RecordingErrorService.class).getAndClearErrors(); Assert.assertEquals(1, errors.size()); ErrorInformation ei = errors.get(0); Assert.assertEquals(ErrorType.SERVICE_DESTRUCTION_FAILURE, ei.getErrorType()); Assert.assertEquals(serviceDescriptor, ei.getDescriptor()); Assert.assertNull(ei.getInjectee()); Throwable associatedException = ei.getAssociatedException(); Assert.assertTrue(associatedException.getMessage().contains(ERROR_STRING)); }
/** 先增加,再查找,再删除,再查找 */ @Test public void operateUser() { // 先新增一个对象 User user = new User(username, password, cellphone, levelId, userStatus); // 1. 保存 User userNew = userService.saveUser(user); // 更新属性 // 2. 更新 String newCellphone = "13999999999"; userNew.setCellphone(newCellphone); userService.updateUser(userNew); // 3. 查找 // 3.1 通过用户ID查找 User userDB = userService.findUserByUsernameAndPassword(username, password); Assert.assertNotNull(userDB); // 3.2 查找(通过手机号码查找用户) userDB = userService.findUserByCellphone(newCellphone); Assert.assertNotNull(userDB); Assert.assertEquals(newCellphone, userDB.getCellphone()); // 3.3 通过用户名查找用户 userDB = userService.findUserByUserName(userNew.getUsername()); Assert.assertNotNull(userDB); // 4. 删除 userService.removeUser(userDB.getUserId()); // 5.通过用户名密码查找用户 userDB = userService.loadUser(userNew.getUserId()); Assert.assertNull(userDB); }
/** Test method read */ @Test public void testReadPodcast() { final Feed readPodcast = feedManager.getFeed(feed); assertNotNull(readPodcast); assertNotNull(readPodcast.getId()); assertEquals(PODCAST_TITLE, readPodcast.getTitle()); }
public void testTakeBlockedByProperty() throws Exception { Slave slave = createSlave(); FreeStyleProject project = createFreeStyleProject(); // First, attempt to run our project before adding the property Future<FreeStyleBuild> build = project.scheduleBuild2(0); assertBuildStatus(Result.SUCCESS, build.get(20, TimeUnit.SECONDS)); // Add the build-blocker property and try again slave.getNodeProperties().add(new RejectAllTasksProperty()); build = project.scheduleBuild2(0); try { build.get(10, TimeUnit.SECONDS); fail("Expected timeout exception"); } catch (TimeoutException e) { List<BuildableItem> buildables = jenkins.getQueue().getBuildableItems(); assertNotNull(buildables); assertEquals(1, buildables.size()); BuildableItem item = buildables.get(0); assertEquals(project, item.task); assertNotNull(item.getCauseOfBlockage()); assertEquals( Messages.Queue_WaitingForNextAvailableExecutor(), item.getCauseOfBlockage().getShortDescription()); } }
@Test public void testConstraints() throws ApiException { final Range<Integer> r = Livre.mLivre.nombreDePages.getConstraintRange(); assertNotNull(r); assertNotNull(r.getMin()); assertNotNull(r.getMax()); }
/** Test new values are visible on reload */ @Test public void testEnums1() throws Exception { String t = "enumtests.Colours"; String runner = "enumtests.RunnerA"; // Class<?> enumClazz = binLoader.loadClass(t); Class<?> runnerClazz = binLoader.loadClass(runner); assertNotNull(runnerClazz); // Check we loaded it as reloadable ReloadableType rtype = TypeRegistry.getTypeRegistryFor(binLoader).getReloadableType(toSlash(t), false); assertNotNull(rtype); String output = runMethodAndCollectOutput(runnerClazz, "run1"); assertContains("Red", output); assertContains("Green", output); assertContains("Blue", output); assertContains("[Red Green Blue]", output); assertContains("value count = 3", output); rtype.loadNewVersion(retrieveRename(t, t + "2")); output = runMethodAndCollectOutput(runnerClazz, "run1"); assertContains("Red", output); assertContains("Green", output); assertContains("Blue", output); assertContains("[Red Green Blue Yellow]", output); assertContains("value count = 4", output); }