Commits

Anonymous committed d4da7fd

jersey-client-test-cases..

Comments (0)

Files changed (5)

src/test/java/jhyun/mybatis_with_guice/tests/AllTests.java

 import jhyun.mybatis_with_guice.tests.test_cases.AppConfigTestCase;
 import jhyun.mybatis_with_guice.tests.test_cases.MybatisWithGuiceTestCase;
 import jhyun.mybatis_with_guice.tests.test_cases.PlusWithJsonJerseyClientTestCase;
-import jhyun.mybatis_with_guice.tests.test_cases.SimpleTransactionTestCase;
+import jhyun.mybatis_with_guice.tests.test_cases.SimpleTransactionClientTestCase;
 
 import org.junit.runner.RunWith;
 import org.junit.runners.Suite;
 
 @RunWith(Suite.class)
 @SuiteClasses({ AppConfigTestCase.class, MybatisWithGuiceTestCase.class,
-		PlusWithJsonJerseyClientTestCase.class, SimpleTransactionTestCase.class })
+		PlusWithJsonJerseyClientTestCase.class, SimpleTransactionClientTestCase.class })
 public class AllTests {
 
 }

src/test/java/jhyun/mybatis_with_guice/tests/helpers/SimpleTransactionHelper.java

+package jhyun.mybatis_with_guice.tests.helpers;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.ws.rs.core.MediaType;
+
+import org.apache.commons.lang.ObjectUtils;
+
+import com.google.common.base.Objects;
+
+public class SimpleTransactionHelper {
+
+	public List listAll() {
+		return JerseyTestingClient.webResource()
+				.path("/hello/transaction/list")
+				.accept(MediaType.APPLICATION_JSON).get(List.class);
+	}
+
+	public void resetTable() {
+		JerseyTestingClient.webResource().path("/hello/transaction/init")
+				.accept(MediaType.TEXT_PLAIN).get(String.class);
+	}
+
+	public void addSome(final String s) {
+		JerseyTestingClient.webResource().path("/hello/transaction/add")
+				.path(s).accept(MediaType.TEXT_PLAIN).get(String.class);
+	}
+
+	public boolean containsIdIn(final List l, final String s) {
+		for (Object o : l) {
+			Map m = (Map) o;
+			if (Objects.equal(ObjectUtils.toString(m.get("ID")), s))
+				return true;
+		}
+		return false;
+	}
+}

src/test/java/jhyun/mybatis_with_guice/tests/test_cases/DirtyAndCleanTransactionClientTestCase.java

+package jhyun.mybatis_with_guice.tests.test_cases;
+
+import jhyun.mybatis_with_guice.injections.Guicer;
+import jhyun.mybatis_with_guice.tests.helpers.SimpleTransactionHelper;
+
+import org.junit.Test;
+
+import com.google.inject.Inject;
+
+public class DirtyAndCleanTransactionClientTestCase {
+
+	public DirtyAndCleanTransactionClientTestCase() {
+		super();
+		Guicer.get().injectMembers(this);
+	}
+
+	@Inject
+	private SimpleTransactionHelper sth;
+
+	@Test
+	public void testSomeDirtyTransactions() {
+		// TODO:
+	}
+
+	@Test
+	public void testSomeCleanTransactions() {
+		// TODO:
+	}
+
+}

src/test/java/jhyun/mybatis_with_guice/tests/test_cases/SimpleTransactionClientTestCase.java

+package jhyun.mybatis_with_guice.tests.test_cases;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+
+import jhyun.mybatis_with_guice.injections.Guicer;
+import jhyun.mybatis_with_guice.tests.helpers.SimpleTransactionHelper;
+
+import org.junit.Test;
+
+import com.google.inject.Inject;
+
+public class SimpleTransactionClientTestCase {
+
+	public SimpleTransactionClientTestCase() {
+		super();
+		Guicer.get().injectMembers(this);
+	}
+
+	@Inject
+	private SimpleTransactionHelper sth;
+
+	@Test
+	public void testSimpleAddAndList() {
+		//
+		sth.resetTable();
+		//
+		List l = sth.listAll();
+		assertEquals(0, l.size());
+		assertFalse(sth.containsIdIn(l, "1"));
+		assertFalse(sth.containsIdIn(l, "2"));
+		assertFalse(sth.containsIdIn(l, "3"));
+		assertFalse(sth.containsIdIn(l, "4"));
+		// adds
+		sth.addSome("1");
+		sth.addSome("2");
+		sth.addSome("3");
+		//
+		List l2 = sth.listAll();
+		assertEquals(3, l2.size());
+		assertTrue(sth.containsIdIn(l2, "1"));
+		assertTrue(sth.containsIdIn(l2, "2"));
+		assertTrue(sth.containsIdIn(l2, "3"));
+		assertFalse(sth.containsIdIn(l2, "4"));
+	}
+
+}

src/test/java/jhyun/mybatis_with_guice/tests/test_cases/SimpleTransactionTestCase.java

-package jhyun.mybatis_with_guice.tests.test_cases;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.List;
-import java.util.Map;
-
-import javax.ws.rs.core.MediaType;
-
-import jhyun.mybatis_with_guice.tests.helpers.JerseyTestingClient;
-
-import org.apache.commons.lang.ObjectUtils;
-import org.junit.Test;
-
-import com.google.common.base.Objects;
-
-public class SimpleTransactionTestCase {
-
-	private List listAll() {
-		return JerseyTestingClient.webResource()
-				.path("/hello/transaction/list")
-				.accept(MediaType.APPLICATION_JSON).get(List.class);
-	}
-
-	private void resetTable() {
-		JerseyTestingClient.webResource().path("/hello/transaction/init")
-				.accept(MediaType.TEXT_PLAIN).get(String.class);
-	}
-
-	private void addSome(final String s) {
-		JerseyTestingClient.webResource().path("/hello/transaction/add")
-				.path(s).accept(MediaType.TEXT_PLAIN).get(String.class);
-	}
-
-	private boolean containsIdIn(final List l, final String s) {
-		for (Object o : l) {
-			Map m = (Map) o;
-			if (Objects.equal(ObjectUtils.toString(m.get("ID")), s))
-				return true;
-		}
-		return false;
-	}
-
-	@Test
-	public void testSimpleAddAndList() {
-		//
-		this.resetTable();
-		//
-		List l = this.listAll();
-		assertEquals(0, l.size());
-		assertFalse(this.containsIdIn(l, "1"));
-		assertFalse(this.containsIdIn(l, "2"));
-		assertFalse(this.containsIdIn(l, "3"));
-		assertFalse(this.containsIdIn(l, "4"));
-		// adds
-		this.addSome("1");
-		this.addSome("2");
-		this.addSome("3");
-		//
-		List l2 = this.listAll();
-		assertEquals(3, l2.size());
-		assertTrue(this.containsIdIn(l2, "1"));
-		assertTrue(this.containsIdIn(l2, "2"));
-		assertTrue(this.containsIdIn(l2, "3"));
-		assertFalse(this.containsIdIn(l2, "4"));
-	}
-
-}