Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.j256.ormlite.db;
  
  import static org.easymock.EasyMock.createMock;
  import static org.easymock.EasyMock.expect;
  import static org.easymock.EasyMock.isA;
  import static org.easymock.EasyMock.replay;
  import static org.easymock.EasyMock.verify;
  import static org.junit.Assert.assertEquals;
  import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 import java.util.List;
 
 import org.junit.Test;
 
 
 
 	protected void setDatabaseParams() throws SQLException {
 		 = "jdbc:oracle:ormliteoracle";
 	}
 
 	protected boolean isDriverClassExpected() {
 		return false;
 	}
 
 	@Test
 	public void testEscapedEntityName() {
 		String word = "word";
 		assertEquals("\"" + word + "\"", TestUtils.appendEscapedEntityName(word));
 	}
 
 	@Test(expected = IllegalStateException.class)
 	public void testBadGeneratedId() throws Exception {
 		Field field = GeneratedId.class.getField("id");
 		DatabaseType mockDb = createMock(DatabaseType.class);
 		replay(mockDb);
 		try {
 			FieldType fieldType = FieldType.createFieldType("foo"fieldGeneratedId.class);
 			verify(mockDb);
 			StringBuilder sb = new StringBuilder();
 			List<StringstatementsBefore = new ArrayList<String>();
 			.appendColumnArg(nullsbfieldTypenullstatementsBeforenullnull);
 		} finally {
 		}
 	}
 
 	@Test
 	public void testDropSequence() throws Exception {
 		Field field = GeneratedId.class.getField("id");
 		FieldType fieldType = FieldType.createFieldType("foo"fieldGeneratedId.class);
 		List<StringstatementsBefore = new ArrayList<String>();
 		List<StringstatementsAfter = new ArrayList<String>();
 		.dropColumnArg(fieldTypestatementsBeforestatementsAfter);
 		assertEquals(0, statementsBefore.size());
 		assertEquals(1, statementsAfter.size());
 		assertTrue(statementsAfter.get(0).contains("DROP SEQUENCE "));
 	}
 
 	@Test
 	public void testGeneratedIdSequence() throws Exception {
 		assertEquals(2, tableInfo.getFieldTypes().length);
 		StringBuilder sb = new StringBuilder();
 		List<StringadditionalArgs = new ArrayList<String>();
 		List<StringstatementsBefore = new ArrayList<String>();
 		.appendColumnArg(nullsbtableInfo.getFieldTypes()[0], additionalArgsstatementsBeforenull,
 				null);
 		assertTrue(sb.toString().contains(" PRIMARY KEY"));
 		assertEquals(1, statementsBefore.size());
 		assertTrue(statementsBefore.get(0).contains());
 		assertEquals(0, additionalArgs.size());
 	}
 
 	@Test
 	public void testGeneratedIdSequenceAutoName() throws Exception {
		assertEquals(2, tableInfo.getFieldTypes().length);
		FieldType idField = tableInfo.getFieldTypes()[0];
		List<StringadditionalArgs = new ArrayList<String>();
		List<StringstatementsBefore = new ArrayList<String>();
		.appendColumnArg(nullsbidFieldadditionalArgsstatementsBeforenullnull);
		assertTrue(sb.toString().contains(" PRIMARY KEY"));
		assertEquals(1, statementsBefore.size());
		String seqName =
						idField);
		assertTrue(statementsBefore.get(0).contains(seqName));
		assertEquals(0, additionalArgs.size());
	}
	public void testByte() throws Exception {
		TableInfo<AllTypesIntegertableInfo =
		assertEquals(9, tableInfo.getFieldTypes().length);
		FieldType byteField = tableInfo.getFieldTypes()[3];
		assertEquals("byteField"byteField.getColumnName());
		List<StringadditionalArgs = new ArrayList<String>();
		List<StringstatementsBefore = new ArrayList<String>();
		.appendColumnArg(nullsbbyteFieldadditionalArgsstatementsBeforenullnull);
		assertTrue(sb.toString().contains("SMALLINT"));
	}
	public void testLong() throws Exception {
		TableInfo<AllTypesIntegertableInfo =
		assertEquals(9, tableInfo.getFieldTypes().length);
		FieldType booleanField = tableInfo.getFieldTypes()[6];
		assertEquals("longField"booleanField.getColumnName());
		List<StringadditionalArgs = new ArrayList<String>();
		List<StringstatementsBefore = new ArrayList<String>();
		.appendColumnArg(nullsbbooleanFieldadditionalArgsstatementsBeforenullnull);
		assertTrue(sb.toString().contains("NUMERIC"));
	}
	public void testObject() {
		dbType.appendByteArrayType(sb, 0);
		assertEquals("LONG RAW"sb.toString());
	}
	public void testSelectNextVal() {
		String sequenceName = "stuff_seq";
		dbType.appendSelectNextValFromSequence(sbsequenceName);
		assertEquals("SELECT \"" + sequenceName + "\".nextval FROM dual"sb.toString());
	}
	public void testOffsetSupport() {
	}
New to GrepCode? Check out our FAQ X