How to use assertNotNull method of org.testng.AssertJUnit class

Best Testng code snippet using org.testng.AssertJUnit.assertNotNull

Source:LDAPDataConnectorParserTest.java Github

copy

Full Screen

...112 }113 @Test public void v2Config() throws Exception {114 LDAPDataConnector dataConnector =115 getLdapDataConnector(new String[] {"net/shibboleth/idp/attribute/resolver/spring/dc/ldap/ldap-attribute-resolver-v2.xml"});116 Assert.assertNotNull(dataConnector);117 doTest(dataConnector);118 final StringAttributeValueMappingStrategy mappingStrategy =119 (StringAttributeValueMappingStrategy) dataConnector.getMappingStrategy();120 Assert.assertEquals(mappingStrategy.getResultRenamingMap().size(), 1);121 Assert.assertEquals(mappingStrategy.getResultRenamingMap().get("homephone"), "phonenumber");122 dataConnector.initialize();123 AttributeResolutionContext context =124 TestSources.createResolutionContext(TestSources.PRINCIPAL_ID, TestSources.IDP_ENTITY_ID,125 TestSources.SP_ENTITY_ID);126 Map<String, IdPAttribute> attrs = dataConnector.resolve(context);127 Assert.assertNotNull(attrs);128 Assert.assertNotNull(attrs.get("entryDN"));129 }130 @Test public void v2PropsConfig() throws Exception {131 final Resource props = new ClassPathResource("net/shibboleth/idp/attribute/resolver/spring/dc/ldap/ldap-v2.properties");132 LDAPDataConnector dataConnector =133 getLdapDataConnector(props, new String[] {134 "net/shibboleth/idp/attribute/resolver/spring/dc/ldap/ldap-attribute-resolver-v2-props.xml",});135 Assert.assertNotNull(dataConnector);136 doTest(dataConnector);137 dataConnector.initialize();138 AttributeResolutionContext context =139 TestSources.createResolutionContext(TestSources.PRINCIPAL_ID, TestSources.IDP_ENTITY_ID,140 TestSources.SP_ENTITY_ID);141 Map<String, IdPAttribute> attrs = dataConnector.resolve(context);142 Assert.assertNotNull(attrs);143 Assert.assertEquals(attrs.size(), 4);144 Assert.assertNotNull(attrs.get("uid"));145 Assert.assertNotNull(attrs.get("homephone"));146 Assert.assertNotNull(attrs.get("mail"));147 Assert.assertNotNull(attrs.get("entryDN"));148 }149 @Test public void springConfig() throws Exception {150 LDAPDataConnector dataConnector =151 getLdapDataConnector(new String[] {"net/shibboleth/idp/attribute/resolver/spring/dc/ldap/ldap-attribute-resolver-spring.xml"});152 Assert.assertNotNull(dataConnector);153 doTest(dataConnector);154 dataConnector.initialize();155 AttributeResolutionContext context =156 TestSources.createResolutionContext(TestSources.PRINCIPAL_ID, TestSources.IDP_ENTITY_ID,157 TestSources.SP_ENTITY_ID);158 Map<String, IdPAttribute> attrs = dataConnector.resolve(context);159 Assert.assertNotNull(attrs);160 }161 @Test public void springPropsConfig() throws Exception,162 ResolutionException {163 final Resource props = new ClassPathResource("net/shibboleth/idp/attribute/resolver/spring/dc/ldap/ldap-v3.properties");164 final LDAPDataConnector dataConnector =165 getLdapDataConnector(props, new String[] {"net/shibboleth/idp/attribute/resolver/spring/dc/ldap/ldap-attribute-resolver-spring-props.xml"});166 Assert.assertNotNull(dataConnector);167 doTest(dataConnector);168 dataConnector.initialize();169 AttributeResolutionContext context =170 TestSources.createResolutionContext(TestSources.PRINCIPAL_ID, TestSources.IDP_ENTITY_ID,171 TestSources.SP_ENTITY_ID);172 Map<String, IdPAttribute> attrs = dataConnector.resolve(context);173 Assert.assertNotNull(attrs);174 Assert.assertEquals(attrs.size(), 3);175 Assert.assertNotNull(attrs.get("uid"));176 Assert.assertNotNull(attrs.get("phonenumber"));177 Assert.assertNotNull(attrs.get("mail"));178 }179 /**180 * This test will fail when it is time to revert the fixes put in for181 * https://issues.shibboleth.net/jira/browse/IDP-338.182 */183 @Test public void IdP338Canary() {184 GenericApplicationContext context = new FilesystemGenericApplicationContext();185 setTestContext(context);186 context.setDisplayName("ApplicationContext: " + LDAPDataConnectorParserTest.class);187 XmlBeanDefinitionReader configReader = new XmlBeanDefinitionReader(context);188 configReader.loadBeanDefinitions("net/shibboleth/idp/attribute/resolver/spring/dc/IdP338.xml");189 context.refresh();190 Object cbc, cc = null, cb, c;191 cbc = context.getBean(CacheBuilder.class);192 cc = context.getBean(Cache.class);193 cb = context.getBean("cacheBuilder");194 c = context.getBean("cache");195 Object ccc = context.getBean(Cache.class);196 Assert.assertNotNull(cb);197 Assert.assertNotNull(c);198 Assert.assertNotNull(cbc);199 Assert.assertNotNull(ccc);200 Assert.assertNotNull(cc,201 "The Spring bug described in https://issues.shibboleth.net/jira/browse/IDP-338 has come back");202 }203 @Test public void hybridConfig() throws Exception {204 LDAPDataConnector dataConnector =205 getLdapDataConnector(new String[] {206 "net/shibboleth/idp/attribute/resolver/spring/dc/ldap/ldap-attribute-resolver-v2-hybrid.xml",207 "net/shibboleth/idp/attribute/resolver/spring/dc/ldap/ldap-attribute-resolver-spring-context.xml"});208 Assert.assertNotNull(dataConnector);209 doTest(dataConnector);210 dataConnector.initialize();211 final StringAttributeValueMappingStrategy mappingStrategy =212 (StringAttributeValueMappingStrategy) dataConnector.getMappingStrategy();213 Assert.assertEquals(mappingStrategy.getResultRenamingMap().size(), 1);214 Assert.assertEquals(mappingStrategy.getResultRenamingMap().get("homephone"), "phonenumber");215 AttributeResolutionContext context =216 TestSources.createResolutionContext(TestSources.PRINCIPAL_ID, TestSources.IDP_ENTITY_ID,217 TestSources.SP_ENTITY_ID);218 Map<String, IdPAttribute> attrs = dataConnector.resolve(context);219 Assert.assertNotNull(attrs);220 Assert.assertNull(attrs.get("homephone"));221 Assert.assertNotNull(attrs.get("phonenumber"));222 Assert.assertNotNull(attrs.get("entryDN"));223 }224 protected LDAPDataConnector getLdapDataConnector(Resource properties, final String[] beanDefinitions) throws IOException {225 GenericApplicationContext context = new FilesystemGenericApplicationContext() ;226 setTestContext(context);227 context.setDisplayName("ApplicationContext: " + LDAPDataConnectorParserTest.class);228 229 if (null != properties) {230 ConfigurableEnvironment env = context.getEnvironment();231 env.getPropertySources().replace(StandardEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME, new ResourcePropertySource(properties));232 233 env.setPlaceholderPrefix("%{");234 env.setPlaceholderSuffix("}");235 }236 XmlBeanDefinitionReader configReader = new XmlBeanDefinitionReader(context);237 configReader.loadBeanDefinitions("net/shibboleth/idp/attribute/resolver/spring/externalBeans.xml");238 SchemaTypeAwareXMLBeanDefinitionReader beanDefinitionReader =239 new SchemaTypeAwareXMLBeanDefinitionReader(context);240 beanDefinitionReader.setValidating(true);241 beanDefinitionReader.loadBeanDefinitions(beanDefinitions);242 context.refresh();243 return (LDAPDataConnector) context.getBean("myLDAP");244 }245 246 protected LDAPDataConnector getLdapDataConnector(final String[] beanDefinitions) throws IOException {247 return getLdapDataConnector(null, beanDefinitions);248 }249 protected void doTest(final LDAPDataConnector dataConnector) throws ResolutionException {250 String id = dataConnector.getId();251 AssertJUnit.assertEquals("myLDAP", id);252 PooledConnectionFactory connFactory = (PooledConnectionFactory) dataConnector.getConnectionFactory();253 AssertJUnit.assertNotNull(connFactory);254 BlockingConnectionPool connPool = (BlockingConnectionPool) connFactory.getConnectionPool();255 AssertJUnit.assertNotNull(connPool);256 AssertJUnit.assertEquals(5000, connPool.getBlockWaitTime());257 PoolConfig poolConfig = connPool.getPoolConfig();258 AssertJUnit.assertNotNull(poolConfig);259 AssertJUnit.assertEquals(5, poolConfig.getMinPoolSize());260 AssertJUnit.assertEquals(10, poolConfig.getMaxPoolSize());261 AssertJUnit.assertTrue(poolConfig.isValidatePeriodically());262 AssertJUnit.assertEquals(900, poolConfig.getValidatePeriod());263 AssertJUnit.assertFalse(connPool.getFailFastInitialize());264 SearchValidator searchValidator = (SearchValidator) connPool.getValidator();265 AssertJUnit.assertNotNull(searchValidator);266 AssertJUnit.assertEquals("dc=shibboleth,dc=net", searchValidator.getSearchRequest().getBaseDn());267 AssertJUnit.assertEquals("(ou=people)", searchValidator.getSearchRequest().getSearchFilter().getFilter());268 IdlePruneStrategy pruneStrategy = (IdlePruneStrategy) connPool.getPruneStrategy();269 AssertJUnit.assertNotNull(pruneStrategy);270 AssertJUnit.assertEquals(300, pruneStrategy.getPrunePeriod());271 AssertJUnit.assertEquals(600, pruneStrategy.getIdleTime());272 ConnectionConfig connConfig = connPool.getConnectionFactory().getConnectionConfig();273 AssertJUnit.assertNotNull(connConfig);274 AssertJUnit.assertEquals("ldap://localhost:10389", connConfig.getLdapUrl());275 AssertJUnit.assertEquals(false, connConfig.getUseSSL());276 AssertJUnit.assertEquals(true, connConfig.getUseStartTLS());277 BindConnectionInitializer connInitializer = (BindConnectionInitializer) connConfig.getConnectionInitializer();278 AssertJUnit.assertEquals("cn=Directory Manager", connInitializer.getBindDn());279 AssertJUnit.assertEquals("password", connInitializer.getBindCredential().getString());280 SslConfig sslConfig = connPool.getConnectionFactory().getConnectionConfig().getSslConfig();281 AssertJUnit.assertNotNull(sslConfig);282 CredentialConfig credentialConfig = sslConfig.getCredentialConfig();283 AssertJUnit.assertNotNull(credentialConfig);284 final Map<String, Object> providerProps = new HashMap<>();285 providerProps.put("name1", "value1");286 providerProps.put("name2", "value2");287 ProviderConfig providerConfig = connPool.getConnectionFactory().getProvider().getProviderConfig();288 AssertJUnit.assertNotNull(providerConfig);289 AssertJUnit.assertEquals(providerProps, providerConfig.getProperties());290 SearchExecutor searchExecutor = dataConnector.getSearchExecutor();291 AssertJUnit.assertNotNull(searchExecutor);292 AssertJUnit.assertEquals("ou=people,dc=shibboleth,dc=net", searchExecutor.getBaseDn());293 AssertJUnit.assertNotNull(searchExecutor.getSearchFilter().getFilter());294 ConnectionFactoryValidator validator = (ConnectionFactoryValidator) dataConnector.getValidator();295 AssertJUnit.assertNotNull(validator);296 AssertJUnit.assertTrue(validator.isThrowValidateError());297 AssertJUnit.assertNotNull(validator.getConnectionFactory());298 ExecutableSearchBuilder searchBuilder = dataConnector.getExecutableSearchBuilder();299 AssertJUnit.assertNotNull(searchBuilder);300 StringAttributeValueMappingStrategy mappingStrategy = (StringAttributeValueMappingStrategy) dataConnector.getMappingStrategy();301 AssertJUnit.assertNotNull(mappingStrategy);302 AssertJUnit.assertTrue(mappingStrategy.isNoResultAnError());303 AssertJUnit.assertTrue(mappingStrategy.isMultipleResultsAnError());304 Cache<String, Map<String, IdPAttribute>> resultCache = dataConnector.getResultsCache();305 AssertJUnit.assertNotNull(resultCache);306 }307}...

Full Screen

Full Screen

Source:CocitTest.java Github

copy

Full Screen

1package com.jiongsoft.cocitest;2import static org.testng.AssertJUnit.assertEquals;3import static org.testng.AssertJUnit.assertNotNull;4import static org.testng.AssertJUnit.assertNull;5import static org.testng.AssertJUnit.assertTrue;6import javax.servlet.http.HttpServletRequest;7import javax.servlet.http.HttpServletResponse;8import mockit.Expectations;9import mockit.Mocked;10import org.springframework.mock.web.MockHttpServletRequest;11import org.springframework.mock.web.MockHttpServletResponse;12import org.springframework.mock.web.MockServletContext;13import org.testng.annotations.BeforeMethod;14import org.testng.annotations.Test;15import com.jiongsoft.cocit.Cocit;16import com.jiongsoft.cocit.BeanFactory;17import com.jiongsoft.cocit.ActionContext;18import com.jiongsoft.cocit.service.ConfigManager;19import com.jiongsoft.cocit.sms.impl.ZrSmsClient;20import com.jiongsoft.cocit.util.Json;21import com.kmetop.demsy.Demsy;22import com.kmetop.demsy.comlib.impl.base.lib.DemsySoft;23import com.kmetop.demsy.config.SoftConfigManager;24import com.kmetop.demsy.engine.BizEngine;25import com.kmetop.demsy.engine.ModuleEngine;26public class CocitTest {27 MockServletContext context;28 @BeforeMethod29 public void setUp() {30 context = new MockServletContext();31 context.setContextPath("/");32 Cocit.init(context);33 }34 @Test35 public void destroy() {36 Cocit.destroy(context);37 assertNull(Cocit.getContextPath());38 try {39 Cocit.getBean("");40 assertTrue(false);41 } catch (NullPointerException e) {42 assertTrue(true);43 }44 assertNull(Cocit.getActionContext());45 }46 @Test47 public void getContextPath() {48 MockServletContext context = new MockServletContext();49 context.setContextPath(null);50 Cocit.init(context);51 assertEquals("", Cocit.getContextPath());52 context.setContextPath("/");53 Cocit.init(context);54 assertEquals("", Cocit.getContextPath());55 context.setContextPath("");56 Cocit.init(context);57 assertEquals("", Cocit.getContextPath());58 context.setContextPath("/test");59 Cocit.init(context);60 assertEquals("/test", Cocit.getContextPath());61 context.setContextPath("/test/");62 Cocit.init(context);63 assertEquals("/test", Cocit.getContextPath());64 context.setContextPath("test");65 Cocit.init(context);66 assertEquals("/test", Cocit.getContextPath());67 }68 @Test69 public void getBean() {70 Json json = Cocit.getBean(Json.class);71 assertNull(json);72 json = Cocit.getBean("json");73 assertNull(json);74 BeanFactory beanFactory = Cocit.getBean(BeanFactory.class);75 assertNotNull(beanFactory);76 beanFactory = Cocit.getBean("beanFactory");77 assertNotNull(beanFactory);78 assertNotNull(Cocit.getServiceFactory());79 assertNotNull(Cocit.getWidgetModelFactory());80 assertNotNull(Cocit.getWidgetRenderFactory());81 assertNull(Cocit.getOrmFactory());82 }83 @Test84 public void makeAndGetHttpContext() {85 final HttpServletRequest req = new MockHttpServletRequest();86 final HttpServletResponse res = new MockHttpServletResponse();87 new Expectations(Demsy.class, SoftConfigManager.class) {88 @Mocked89 DemsySoft mockDemsySoft;90 @Mocked91 BizEngine bizEngine;92 @Mocked93 ModuleEngine moduleEngine;94 @Mocked95 SoftConfigManager mockDemsyConfig;96 {97 Demsy.bizEngine = bizEngine;98 Demsy.moduleEngine = moduleEngine;99 moduleEngine.getSoft(anyString);100 result = mockDemsySoft;101 SoftConfigManager.me();102 result = mockDemsyConfig;103 mockDemsyConfig.get("sms.type", "");104 result = "zr";105 mockDemsyConfig.get(ConfigManager.SMS_PROXY_HOST, "");106 result = "192.168.128.3";107 mockDemsyConfig.get(ConfigManager.SMS_PROXY_PORT, "");108 result = "80";109 mockDemsyConfig.get(ConfigManager.SMS_URL, "");110 result = "http://oa.zrsms.com";111 mockDemsyConfig.get(ConfigManager.SMS_UID, "");112 result = "zlsandi";113 mockDemsyConfig.get(ConfigManager.SMS_PWD, "");114 result = "zlsandi";115 }116 };117 ActionContext ctx = Cocit.initActionContext(req, res);118 assertNotNull(ctx);119 ctx = Cocit.getActionContext();120 assertNotNull(ctx);121 assertNotNull(ctx.getSoftService());122 assertNotNull(ctx.getSoftService().getSmsClient());123 assertNotNull(ctx.getSoftService().getSmsClient() instanceof ZrSmsClient);124 }125}...

Full Screen

Full Screen

Source:PromosTest.java Github

copy

Full Screen

1package com.bestbuy.searchplatform.integrationtests.tests;2import static com.bestbuy.searchplatform.integrationtests.commons.IntegationTestConstants.PROMO_APPROVE;3import static com.bestbuy.searchplatform.integrationtests.commons.IntegationTestConstants.PROMO_CREATE;4import static org.testng.Assert.assertNotNull;5import java.io.InputStream;6import java.util.List;7import java.util.logging.Logger;8import javax.xml.bind.JAXBContext;9import javax.xml.bind.Unmarshaller;10import org.codehaus.jettison.json.JSONObject;11import org.springframework.http.HttpEntity;12import org.springframework.http.HttpMethod;13import org.springframework.http.ResponseEntity;14import org.testng.AssertJUnit;15import org.testng.annotations.AfterClass;16import org.testng.annotations.BeforeClass;17import org.testng.annotations.Test;18import com.bestbuy.searchplatform.integrationtests.model.Promos;19import com.bestbuy.searchplatform.integrationtests.model.Promos.Promo;20/**21 * 22 * Class to create and approve Promos23 *24 */25public class PromosTest extends BaseTest {26 private final static Logger log = Logger.getLogger("PromosTest");27 private static Promos promos; 28 29 /**30 * @BeforeClass The annotated method will be run before the first test method in the31 * current class is invoked to read the data in xml 32 */33 @BeforeClass34 public static void setUpBeforeClass() throws Exception{35 36 JAXBContext jaxbContext = JAXBContext.newInstance(Promos.class);37 Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();38 InputStream resourceAsStream = PromosTest.class.getResourceAsStream("/data/PositivePromoTests.xml");39 promos = (Promos) jaxbUnmarshaller.unmarshal(resourceAsStream);40 }41 42 /**43 * performs create promos test44 * @throws Exception45 */46 @Test(priority = 1)47 public void testCreate() throws Exception{48 String url = BT_REST_URL + PROMO_CREATE;49 log.info("create promo resturi = "+url);50 List<Promo> promoList = promos.getPromo();51 for (Promo promo : promoList) {52 HttpEntity<Promo> entity = new HttpEntity<Promo>(promo,getHeaders());53 ResponseEntity<String> response = getRestTemplate().exchange(url, HttpMethod.POST, entity, String.class);54 AssertJUnit.assertNotNull(response);55 String promoResponseString = response.getBody();56 JSONObject promoResponse = new JSONObject(promoResponseString);57 AssertJUnit.assertTrue(promoResponse.has("data"));58 JSONObject data = (JSONObject)promoResponse.get("data");59 AssertJUnit.assertTrue(data.has("promoId"));60 Integer promoId =(Integer)data.get("promoId");61 assertNotNull(promoId);62 log.info("created promo = "+promo.getPromoName()+" with id = "+promoId);63 getPromosMap().put(promoId, promo.getPromoName());64 }65 }66 67 /**68 * performs Approve promos Test69 * @throws Exception70 */71 @Test(priority = 2)72 public void testApprove() throws Exception{73 String url = BT_REST_URL + PROMO_APPROVE + "/";74 log.info("approve promo resturi = "+url);75 for (Integer promoId : getPromosMap().keySet()) {76 HttpEntity<Integer> entity = new HttpEntity<Integer>(getHeaders());77 ResponseEntity<String> response = getRestTemplate().exchange(url+promoId, HttpMethod.PUT, entity, String.class);78 AssertJUnit.assertNotNull(response);79 String promoResponseString = response.getBody();80 log.info("approve promo response = "+promoResponseString);81 JSONObject promoResponse = new JSONObject(promoResponseString);82 AssertJUnit.assertTrue(promoResponse.has("data"));83 JSONObject data = (JSONObject)promoResponse.get("data");84 AssertJUnit.assertTrue(data.has("statusId"));85 Integer statusId = (Integer)data.get("statusId");86 log.info("approve promo status = "+promoId+" status = "+statusId);87 assertNotNull(statusId);88 AssertJUnit.assertTrue(statusId == 3);89 }90 }91 92 /**93 * @AfterClass The annotated method will be run after all the test methods 94 * in the current class have been run to set promos null. 95 * @throws Exception96 */97 @AfterClass98 public void tearDownAfterClass() throws Exception {99 promos=null;100 }101}...

Full Screen

Full Screen

Source:SimpleTreeTest.java Github

copy

Full Screen

1package org.molgenis.util;2import static org.testng.AssertJUnit.assertEquals;3import static org.testng.AssertJUnit.assertFalse;4import static org.testng.AssertJUnit.assertNotNull;5import static org.testng.AssertJUnit.assertNull;6import static org.testng.AssertJUnit.assertTrue;7import static org.testng.AssertJUnit.fail;8import org.testng.annotations.Test;9public class SimpleTreeTest10{11 @Test12 public void testCreate()13 {14 String name = "test";15 TestTree tree = new TestTree(name, null);16 assertEquals(name, tree.getName());17 assertFalse(tree.hasChildren());18 assertNotNull(tree.getChildren());19 assertTrue(tree.getChildren().isEmpty());20 assertNull(tree.getParent());21 assertEquals(tree, tree.getRoot());22 assertNotNull(tree.getAllChildren());23 assertTrue(tree.getAllChildren().isEmpty());24 assertNotNull(tree.getAllChildren(true));25 assertEquals(1, tree.getAllChildren(true).size());26 assertEquals(tree, tree.getAllChildren(true).get(0));27 assertNull(tree.getChild("xxx"));28 assertNull(tree.getChild(name));29 assertNull(tree.get("xxx"));30 assertNotNull(tree.get(name));31 assertEquals(tree, tree.get(name));32 assertNull(tree.getValue());33 assertNotNull(tree.getPath(","));34 assertEquals(name, tree.getPath(","));35 }36 @Test37 public void testCreateWithParent()38 {39 TestTree parent = new TestTree("parent", null);40 TestTree child = new TestTree("child", parent);41 assertTrue(parent.hasChildren());42 assertEquals(1, parent.getAllChildren().size());43 assertEquals(child, parent.getAllChildren().get(0));44 assertNotNull(child.getParent());45 assertEquals(child.getParent(), parent);46 assertEquals("parent,child", child.getPath(","));47 assertNotNull(child.getRoot());48 assertEquals(parent, child.getRoot());49 }50 @Test51 public void testSetParent()52 {53 TestTree parent = new TestTree("parent", null);54 TestTree child = new TestTree("child", null);55 child.setParent(parent);56 assertTrue(parent.hasChildren());57 assertEquals(1, parent.getAllChildren().size());58 assertEquals(child, parent.getAllChildren().get(0));59 assertNotNull(child.getParent());60 assertEquals(child.getParent(), parent);61 assertEquals("parent,child", child.getPath(","));62 assertNotNull(child.getRoot());63 assertEquals(parent, child.getRoot());64 TestTree duplicate = new TestTree("child", null);65 try66 {67 duplicate.setParent(parent);68 fail("Should have thrown IllegalArgumentException");69 }70 catch (IllegalArgumentException e)71 {72 // Expected73 }74 }75 @Test76 public void testGetChild()77 {78 TestTree parent = new TestTree("test", null);79 TestTree child1 = new TestTree("child1", parent);80 TestTree child2 = new TestTree("child2", parent);81 assertEquals(child1, parent.getChild("child1"));82 assertEquals(child2, parent.getChild("child2"));83 }84 @Test85 public void testSetValue()86 {87 String parentValue = "parentValue";88 String childValue = "childValue";89 TestTree parent = new TestTree("parent", null);90 parent.setValue(parentValue);91 TestTree child = new TestTree("child", null);92 child.setValue(childValue);93 child.setParent(parent);94 assertNotNull(parent.getValue());95 assertNotNull(parentValue, parent.getValue());96 assertNotNull(child.getValue());97 assertNotNull(childValue, child.getValue());98 }99 @Test100 public void testRemove()101 {102 TestTree parent = new TestTree("test", null);103 TestTree child1 = new TestTree("child1", parent);104 TestTree child2 = new TestTree("child2", parent);105 assertNotNull(parent.getAllChildren());106 assertEquals(2, parent.getAllChildren().size());107 child1.remove();108 assertNotNull(parent.getAllChildren());109 assertEquals(1, parent.getAllChildren().size());110 assertEquals(child2, parent.getAllChildren().get(0));111 assertNull(parent.getChild("child1"));112 }113 private static class TestTree extends SimpleTree<TestTree>114 {115 private static final long serialVersionUID = 2697117779184102294L;116 public TestTree(String name, TestTree parent)117 {118 super(name, parent);119 }120 }121}...

Full Screen

Full Screen

Source:IBatisNamespaceRuleTest.java Github

copy

Full Screen

1package com.alibaba.cobar.client.router.rules;2import static org.testng.AssertJUnit.assertEquals;3import static org.testng.AssertJUnit.assertFalse;4import static org.testng.AssertJUnit.assertNotNull;5import static org.testng.AssertJUnit.assertTrue;6import static org.testng.AssertJUnit.fail;7import java.util.List;8import org.testng.annotations.Test;9import com.alibaba.cobar.client.router.rules.ibatis.IBatisNamespaceRule;10import com.alibaba.cobar.client.router.support.IBatisRoutingFact;11import com.alibaba.cobar.client.support.utils.CollectionUtils;12@Test13public class IBatisNamespaceRuleTest{14 public void testNamespaceRuleNormally() {15 IBatisNamespaceRule rule = new IBatisNamespaceRule("com.alibaba.cobar.client.entity.Tweet",16 "p1, p2");17 List<String> shardIds = rule.action();18 assertNotNull(shardIds);19 assertEquals(2, shardIds.size());20 IBatisRoutingFact fact = new IBatisRoutingFact(21 "com.alibaba.cobar.client.entity.Tweet.update", null);22 assertTrue(rule.isDefinedAt(fact));23 fact = new IBatisRoutingFact("com.alibaba.cobar.client.entity.Tweet.delete", null);24 assertTrue(rule.isDefinedAt(fact));25 fact = new IBatisRoutingFact("com.alibaba.cobar.client.entity.Twet.delete", null);26 assertFalse(rule.isDefinedAt(fact));27 }28 public void testNamespaceRuleNormallyWithCustomActionPatternSeparator() {29 IBatisNamespaceRule rule = new IBatisNamespaceRule("com.alibaba.cobar.client.entity.Tweet",30 "p1, p2");31 rule.setActionPatternSeparator(";");32 List<String> shards = rule.action();...

Full Screen

Full Screen

Source:AccountTests.java Github

copy

Full Screen

...18import javax.ws.rs.client.WebTarget;19import javax.ws.rs.core.MediaType;20import javax.ws.rs.core.Response;21import static org.testng.Assert.assertNotEquals;22import static org.testng.AssertJUnit.assertNotNull;23public class AccountTests {24 private static HttpServer server;25 private static WebTarget target;26 private List<String> idList= new ArrayList<>();27 @BeforeClass28 public static void setup() {29 server = ApiApplication.startServer();30 Client c = ClientBuilder.newClient();31 target = c.target(ApiApplication.BASE_URI);32 }33 @AfterClass34 public static void afterAll() {35 server.shutdownNow();36 }37 @Test(description = "Tests that all bank accounts will be returned from the database")38 public void createAccountTest() {39 AccountService bankAccountService = AccountService.getInstance();40 String OWNER_NAME = "Ranit";41 Account bankAccount = new Account(OWNER_NAME, BigDecimal.ZERO, BigDecimal.ZERO, Currency.USD);42 Response response = target.path(AccountController.BASE_URL)43 .request()44 .post(from(bankAccount));45 AssertJUnit.assertEquals(Response.Status.CREATED, response.getStatusInfo().toEnum());46 Account returnedAccount = response.readEntity(Account.class);47 Account createdAccount = bankAccountService.findAccount(returnedAccount.getId());48 assertNotNull(returnedAccount);49 assertNotNull(createdAccount);50 assertNotEquals(returnedAccount.getId(), bankAccount.getId());51 AssertJUnit.assertEquals(returnedAccount.getId(), createdAccount.getId());52 AssertJUnit.assertEquals(OWNER_NAME, createdAccount.getOwnerName());53 idList.add(returnedAccount.getId());54 }55 @Test(description = "Test if getting bank account by id is working")56 public void testGetBankAccountById() {57 Response response = target.path(AccountController.BASE_URL + "/" + idList.get(0))58 .request().get();59 AssertJUnit.assertEquals(Response.Status.OK, response.getStatusInfo().toEnum());60 Account returnedAccount = response.readEntity(Account.class);61 AssertJUnit.assertEquals(returnedAccount.getId(), idList.get(0));62 AssertJUnit.assertEquals(returnedAccount.getOwnerName(), "Ranit");63 }...

Full Screen

Full Screen

Source:ProductUnitTest.java Github

copy

Full Screen

...2223package org.jboss.mobicents.seam.test;2425import static org.testng.AssertJUnit.assertEquals;26import static org.testng.AssertJUnit.assertNotNull;27import static org.testng.AssertJUnit.assertNull;28import static org.testng.AssertJUnit.assertTrue;29import static org.testng.AssertJUnit.fail;3031import javax.persistence.EntityManager;32import javax.persistence.EntityManagerFactory;33import javax.persistence.Persistence;34import javax.persistence.PersistenceException;3536import org.jboss.mobicents.seam.model.Product;37import org.jboss.seam.mock.SeamTest;38import org.testng.annotations.Test;3940public class ProductUnitTest 41 extends SeamTest42{ 43 EntityManager em() {44 EntityManagerFactory emf = Persistence.createEntityManagerFactory("dvdDatabase");45 EntityManager em = emf.createEntityManager();46 assertNotNull("entity manager", em);47 assertTrue("entity manager open", em.isOpen());48 return em;49 }505152 @Test53 public void testRequiredAttributes()54 throws Exception55 {56 Product p = new Product();5758 EntityManager em = em();59 try {60 em.persist(p);61 fail("empty product persisted");62 } catch (PersistenceException e) {63 // good64 } finally {65 em.close();66 }67 }6869 @Test 70 public void testCreateDelete() {71 EntityManager em = em();7273 Product p = new Product();74 p.setTitle("test");7576 em.getTransaction().begin();77 em.persist(p);78 em.getTransaction().commit();7980 long id = p.getProductId();81 assertTrue("product id set", id != 0);82 83 p = em.find(Product.class ,id);84 assertNotNull("find by id", p);85 assertEquals("id", id, p.getProductId());86 assertEquals("title", "test", p.getTitle());8788 em.getTransaction().begin();89 em.remove(p);90 em.getTransaction().commit();91 92 p = em.find(Product.class, id);93 assertNull("deleted product", p);94 }95 96} ...

Full Screen

Full Screen

Source:TestNGGuru99TestPage.java Github

copy

Full Screen

...30 }31 @Test32 public void testHomeSiteNavigateBar() {33 WebElement navBarSite = homePage.getNavBarSite();34 AssertJUnit.assertNotNull("Navigation bar site not found", navBarSite);35 }36 @Test37 public void testVisibleHomeSiteNavigateBar() {38 WebElement navBarSite = homePage.getNavBarSite();39 AssertJUnit.assertNotNull("Navigation bar site not found", navBarSite);40 AssertJUnit.assertTrue("Navigation bar site not visible ", navBarSite.isDisplayed());41 }42}...

Full Screen

Full Screen

assertNotNull

Using AI Code Generation

copy

Full Screen

1import static org.testng.AssertJUnit.assertNotNull;2import static org.testng.AssertJUnit.assertEquals;3import static org.testng.AssertJUnit.assertTrue;4import static org.testng.AssertJUnit.assertFalse;5import static org.testng.AssertJUnit.assertNull;6import static org.testng.AssertJUnit.fail;7import static org.hamcrest.MatcherAssert.assertThat;8import static org.hamcrest.Matchers.is;9import static org.hamcrest.Matchers.not;10import static org.hamcrest.Matchers.containsString;11import static org.hamcrest.Matchers.hasItem;12import static org.hamcrest.Matchers.hasItems;13import static org.hamcrest.Matchers.hasEntry;14import static org.hamcrest.Matchers.hasKey;15import static org.hamcrest.Matchers.hasValue;16import static org.hamcrest.Matchers.hasSize;17import static org.hamcrest.Matchers.empty;18import static org.hamcrest.Matchers.emptyString;19import static org.hamcrest.Matchers.isA;20import static org.hamcrest.Matchers.notNullValue;21import static org.hamcrest.Matchers.nullValue;22import static org.hamcrest.Matchers.instanceOf;23import static org.hamcrest.Matchers.equalTo;24import static org.hamcrest.Matchers.equalToIgnoringCase;

Full Screen

Full Screen

assertNotNull

Using AI Code Generation

copy

Full Screen

1assertNotNull("some text", "some text");2assertNotEquals("some text", "some text");3assertNotSame("some text", "some text");4assertNotNull("some text", "some text");5assertNotEquals("some text", "some text");6assertNotSame("some text", "some text");7assertNotNull("some text", "some text");8assertNotEquals("some text", "some text");9assertNotSame("some text", "some text");10assertNotNull("some text", "some text");11assertNotEquals("some text", "some text");12assertNotSame("some text", "some text");13assertNotNull("some text", "some text");14assertNotEquals("some text", "some text");15assertNotSame("some text", "some text");16assertNotNull("some text", "some text");17assertNotEquals("some text", "some text");18assertNotSame("some text", "some text");19assertNotNull("some text", "some text");20assertNotEquals("some text", "some text");

Full Screen

Full Screen

assertNotNull

Using AI Code Generation

copy

Full Screen

1package com.mycompany.app;2import org.testng.AssertJUnit;3public class MyAssertJunit {4 public static void main(String[] args) {5 String str = "TestNG is working fine";6 AssertJUnit.assertNotNull(str);7 }8}9package com.mycompany.app;10import org.testng.AssertJUnit;11public class MyAssertJunit {12 public static void main(String[] args) {13 String str = "TestNG is working fine";14 AssertJUnit.assertEquals("TestNG is working fine", str);15 }16}17package com.mycompany.app;18import org.testng.AssertJUnit;19public class MyAssertJunit {20 public static void main(String[] args) {21 String str = "TestNG is working fine";22 AssertJUnit.assertTrue(str.contains("TestNG"));23 }24}25package com.mycompany.app;26import org.testng.AssertJUnit;27public class MyAssertJunit {28 public static void main(String[] args) {29 String str = "TestNG is working fine";30 AssertJUnit.assertFalse(str.contains("JUnit"));31 }32}33package com.mycompany.app;34import org.testng.AssertJUnit;35public class MyAssertJunit {36 public static void main(String[] args) {37 String str = "TestNG is working fine";38 AssertJUnit.assertNotSame("TestNG is not working", str);39 }40}41package com.mycompany.app;42import org.testng.AssertJUnit;43public class MyAssertJunit {44 public static void main(String[] args) {45 String str = "TestNG is working fine";46 AssertJUnit.assertSame("TestNG is working fine", str);47 }48}49package com.mycompany.app;50import org.testng.AssertJUnit;51public class MyAssertJunit {52 public static void main(String[]

Full Screen

Full Screen

TestNG tutorial

TestNG is a Java-based open-source framework for test automation that includes various test types, such as unit testing, functional testing, E2E testing, etc. TestNG is in many ways similar to JUnit and NUnit. But in contrast to its competitors, its extensive features make it a lot more reliable framework. One of the major reasons for its popularity is its ability to structure tests and improve the scripts' readability and maintainability. Another reason can be the important characteristics like the convenience of using multiple annotations, reliance, and priority that make this framework popular among developers and testers for test design. You can refer to the TestNG tutorial to learn why you should choose the TestNG framework.

Chapters

  1. JUnit 5 vs. TestNG: Compare and explore the core differences between JUnit 5 and TestNG from the Selenium WebDriver viewpoint.
  2. Installing TestNG in Eclipse: Start installing the TestNG Plugin and learn how to set up TestNG in Eclipse to begin constructing a framework for your test project.
  3. Create TestNG Project in Eclipse: Get started with creating a TestNG project and write your first TestNG test script.
  4. Automation using TestNG: Dive into how to install TestNG in this Selenium TestNG tutorial, the fundamentals of developing an automation script for Selenium automation testing.
  5. Parallel Test Execution in TestNG: Here are some essential elements of parallel testing with TestNG in this Selenium TestNG tutorial.
  6. Creating TestNG XML File: Here is a step-by-step tutorial on creating a TestNG XML file to learn why and how it is created and discover how to run the TestNG XML file being executed in parallel.
  7. Automation with Selenium, Cucumber & TestNG: Explore for an in-depth tutorial on automation using Selenium, Cucumber, and TestNG, as TestNG offers simpler settings and more features.
  8. JUnit Selenium Tests using TestNG: Start running your regular and parallel tests by looking at how to run test cases in Selenium using JUnit and TestNG without having to rewrite the tests.
  9. Group Test Cases in TestNG: Along with the explanation and demonstration using relevant TestNG group examples, learn how to group test cases in TestNG.
  10. Prioritizing Tests in TestNG: Get started with how to prioritize test cases in TestNG for Selenium automation testing.
  11. Assertions in TestNG: Examine what TestNG assertions are, the various types of TestNG assertions, and situations that relate to Selenium automated testing.
  12. DataProviders in TestNG: Deep dive into learning more about TestNG's DataProvider and how to effectively use it in our test scripts for Selenium test automation.
  13. Parameterization in TestNG: Here are the several parameterization strategies used in TestNG tests and how to apply them in Selenium automation scripts.
  14. TestNG Listeners in Selenium WebDriver: Understand the various TestNG listeners to utilize them effectively for your next plan when working with TestNG and Selenium automation.
  15. TestNG Annotations: Learn more about the execution order and annotation attributes, and refer to the prerequisites required to set up TestNG.
  16. TestNG Reporter Log in Selenium: Find out how to use the TestNG Reporter Log and learn how to eliminate the need for external software with TestNG Reporter Class to boost productivity.
  17. TestNG Reports in Jenkins: Discover how to generate TestNG reports in Jenkins if you want to know how to create, install, and share TestNG reports in Jenkins.

Certification

You can push your abilities to do automated testing using TestNG and advance your career by earning a TestNG certification. Check out our TestNG certification.

YouTube

Watch this complete tutorial to learn how you can leverage the capabilities of the TestNG framework for Selenium automation testing.

Run Testng automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful