alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

jforum example source code file (BanlistTestCase.java)

This example jforum source code file (BanlistTestCase.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - jforum tags/keywords

banlist, banlist, banlisttestcase, banlisttestcase, string, string, testcase, testcase

The jforum BanlistTestCase.java source code

package net.jforum.entities;

import junit.framework.Assert;
import junit.framework.TestCase;

/**
 * @author Rafael Steil
 * @version $Id: BanlistTestCase.java,v 1.1 2006/12/12 00:44:50 rafaelsteil Exp $
 */
public class BanlistTestCase extends TestCase {
	public void testMatchIpUsingOnlyStarsExpectsFalse() {
		Banlist b = this.newBanlist(0, null, "*.*.*.*");
		Assert.assertFalse(b.matches(this.newBanlist(0, null, "172.55.7.2")));
	}
	
	public void testMatchIpUsingStarExpectsTrue2() {
		Banlist b = this.newBanlist(0, null, "172.*.7.2");
		Assert.assertTrue(b.matches(this.newBanlist(0, null, "172.55.7.2")));
	}
	
	public void testMatchIpUsingStarExpectsTrue() {
		Banlist b = this.newBanlist(0, null, "*.168.7.*");
		Assert.assertTrue(b.matches(this.newBanlist(0, null, "172.168.7.2")));
	}
	
	public void testMatchIpUsingStarExpectsFalse2() {
		Banlist b = this.newBanlist(0, null, "*.168.7.*");
		Assert.assertFalse(b.matches(this.newBanlist(0, null, "172.168.1.2")));
	}
	
	public void testMatchIpUsingStarExpectsFalse() {
		Banlist b = this.newBanlist(0, null, "192.168.7.*");
		Assert.assertFalse(b.matches(this.newBanlist(0, null, "192.168.1.2")));
	}
	
	public void testMatchIpUsingDifferentLengthExpectsFalse() {
		Banlist b = this.newBanlist(0, null, "192.168.7");
		Assert.assertFalse(b.matches(this.newBanlist(0, null, "192.168.1.2")));
	}
	
	public void testMatchIpExpectsTrue() {
		Banlist b = this.newBanlist(0, "email@3", "192.168.1.1");
		Assert.assertTrue(b.matches(this.newBanlist(0, "email@2", "192.168.1.1")));
	}
	
	public void testMatchIpExpectsFalse() {
		Banlist b = this.newBanlist(0, null, "192.168.1.1");
		Assert.assertFalse(b.matches(this.newBanlist(0, null, "192.168.1.2")));
	}
	
	public void testMatchEmailExpectsTrue() {
		Banlist b = this.newBanlist(0, "email@2", null);
		Assert.assertTrue(b.matches(this.newBanlist(0, "email@2", null)));
	}
	
	public void testMatchEmailExpectsFalse() {
		Banlist b = this.newBanlist(0, "email@1", null);
		Assert.assertFalse(b.matches(this.newBanlist(0, "email@2", null)));
	}
	
	public void testMatchUserIdExpectsTrue() {
		Banlist b = this.newBanlist(2, null, null);
		Assert.assertTrue(b.matches(this.newBanlist(2, null, null)));
	}
	
	public void testMatchUserIdExpectsFalse() {
		Banlist b = this.newBanlist(1, null, null);
		Assert.assertFalse(b.matches(this.newBanlist(2, null, null)));
	}
	
	private Banlist newBanlist(int userId, String email, String ip) {
		Banlist b = new Banlist();
		
		b.setUserId(userId);
		b.setEmail(email);
		b.setIp(ip);
		
		return b;
	}
}

Other jforum examples (source code examples)

Here is a short list of links related to this jforum BanlistTestCase.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.