当前位置: 首页>>代码示例>>Java>>正文


Java Assert类代码示例

本文整理汇总了Java中org.pentaho.di.core.util.Assert的典型用法代码示例。如果您正苦于以下问题:Java Assert类的具体用法?Java Assert怎么用?Java Assert使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Assert类属于org.pentaho.di.core.util包,在下文中一共展示了Assert类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testingLocalFileLockingByAcquiring2Locks

import org.pentaho.di.core.util.Assert; //导入依赖的package包/类
@Test public void testingLocalFileLockingByAcquiring2Locks() {

	CarbonTableIdentifier carbonTableIdentifier = new CarbonTableIdentifier("databaseName", "tableName", "tableId");
    LocalFileLock localLock1 =
        new LocalFileLock(carbonTableIdentifier,
            LockUsage.METADATA_LOCK);
    Assert.assertTrue(localLock1.lock());
    LocalFileLock localLock2 =
        new LocalFileLock(carbonTableIdentifier,
            LockUsage.METADATA_LOCK);
    Assert.assertTrue(!localLock2.lock());

    Assert.assertTrue(localLock1.unlock());
    Assert.assertTrue(localLock2.lock());

  }
 
开发者ID:carbondata,项目名称:carbondata,代码行数:17,代码来源:LocalFileLockTest.java

示例2: define

import org.pentaho.di.core.util.Assert; //导入依赖的package包/类
/**
 * @param targetTableFields
 *            ...
 * @param dataFile
 *            ...
 * @return this
 */
public FastloadControlBuilder define(final RowMetaInterface targetTableFields, final String dataFile) {
    Assert.assertNotNull(targetTableFields, "fields cannot be null");
    Assert.assertNotNull(dataFile, "dataFile cannot be null");

    this.builder.append("DEFINE ");
    for (int i = 0; i < targetTableFields.size(); i++) {
        ValueMetaInterface value = targetTableFields.getValueMeta(i);
        this.builder.append(value.getName());
        // all fields of type VARCHAR. converted by fastload if necessary
        int length = 0;
        if (value.getType() == ValueMetaInterface.TYPE_DATE) {
            length = DEFAULT_DATE_FORMAT.length();
        } else {
            length = value.getLength();
        }
        this.builder.append("(" + "VARCHAR(" + length + "), nullif = '" + String.format("%1$#" + length + "s", DEFAULT_NULL_VALUE) + "'), ");
        this.builder.append(SystemUtils.LINE_SEPARATOR);
    }
    this.builder.append(" NEWLINECHAR(VARCHAR(" + SystemUtils.LINE_SEPARATOR.length() + "))");
    this.builder.append(" FILE=" + dataFile);
    return this.newline();
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:30,代码来源:FastloadControlBuilder.java

示例3: testRecordWriter

import org.pentaho.di.core.util.Assert; //导入依赖的package包/类
/**
 * Write all the rows in the rowData array to an orc file
 *
 * @throws Exception
 */
private void testRecordWriter() throws Exception {
  IPentahoOutputFormat.IPentahoRecordWriter orcRecordWriter = orcOutputFormat.createRecordWriter();
  Assert.assertNotNull( orcRecordWriter, "orcRecordWriter should NOT be null!" );
  Assert.assertTrue( orcRecordWriter instanceof PentahoOrcRecordWriter,
    "orcRecordWriter should be instance of PentahoOrcRecordWriter" );

  for ( int i = 0; i < rowData.length; i++ ) {
    orcRecordWriter.write( new RowMetaAndData( rowMeta, rowData[ i ] ) );
  }
  try {
    orcRecordWriter.close();
  } catch ( Exception e ) {
    e.printStackTrace();
  }
}
 
开发者ID:pentaho,项目名称:pentaho-hadoop-shims,代码行数:21,代码来源:PentahoOrcReadWriteTest.java

示例4: testRecordWriter

import org.pentaho.di.core.util.Assert; //导入依赖的package包/类
private void testRecordWriter( List<AvroOutputField> avroOutputFields, RowMeta rowMeta, Object[] rowData,
                               IPentahoAvroOutputFormat.COMPRESSION compressionType, String filePath )
  throws Exception {

  PentahoAvroOutputFormat avroOutputFormat = new PentahoAvroOutputFormat();
  avroOutputFormat.setNameSpace( "nameSpace" );
  avroOutputFormat.setRecordName( "recordName" );
  avroOutputFormat.setFields( avroOutputFields );
  avroOutputFormat.setCompression( compressionType );
  avroOutputFormat.setOutputFile( filePath );

  IPentahoOutputFormat.IPentahoRecordWriter avroRecordWriter = avroOutputFormat.createRecordWriter();
  Assert.assertNotNull( avroRecordWriter, "avroRecordWriter should NOT be null!" );
  Assert.assertTrue( avroRecordWriter instanceof PentahoAvroRecordWriter,
    "avroRecordWriter should be instance of PentahoAvroRecordWriter" );

  avroRecordWriter.write( new RowMetaAndData( rowMeta, rowData ) );

  try {
    avroRecordWriter.close();
  } catch ( Exception e ) {
    e.printStackTrace();
  }
}
 
开发者ID:pentaho,项目名称:pentaho-hadoop-shims,代码行数:25,代码来源:PentahoAvroReadWriteTest.java

示例5: initParquetWriteSupportWhenSchemaIsNotNull

import org.pentaho.di.core.util.Assert; //导入依赖的package包/类
@Test
public void initParquetWriteSupportWhenSchemaIsNotNull() {

  int pentahoValueMetaTypeFirstRow = 2;
  boolean allowNullFirstRow = false;
  int pentahoValueMetaTypeSecondRow = 5;
  boolean allowNullSecondRow = false;

  String schemaFromString = ParquetUtils
    .createSchema( pentahoValueMetaTypeFirstRow, allowNullFirstRow, pentahoValueMetaTypeSecondRow,
      allowNullSecondRow ).marshall();

  SchemaDescription schema = SchemaDescription.unmarshall( schemaFromString );
  PentahoParquetWriteSupport writeSupport = new PentahoParquetWriteSupport( schema );

  Configuration conf = new Configuration();
  conf.set( "fs.defaultFS", "file:///" );

  WriteSupport.WriteContext writeContext = writeSupport.init( conf );

  Assert.assertNotNull( writeContext );
}
 
开发者ID:pentaho,项目名称:pentaho-hadoop-shims,代码行数:23,代码来源:PentahoParquetWriteSupportTest.java

示例6: insert

import org.pentaho.di.core.util.Assert; //导入依赖的package包/类
/**
 * @param targetTableFields
 *          ...
 * @param tableFieldList
 * @param tableName
 *          ...
 * @return ...
 */
public FastloadControlBuilder insert( final RowMetaInterface targetTableFields,
  StringListPluginProperty tableFieldList, final String tableName ) {
  Assert.assertNotNull( targetTableFields, "targetTableFields cannot be null." );
  Assert.assertNotNull( tableName, "TableName cannot be null." );

  this.builder.append( "INSERT INTO " + tableName + "(" );
  for ( int i = 0; i < targetTableFields.size(); i++ ) {
    int tableIndex = tableFieldList.getValue().indexOf( targetTableFields.getValueMeta( i ).getName() );
    if ( tableIndex >= 0 ) {
      this.builder.append( ":" + targetTableFields.getValueMeta( i ).getName() );
      if ( targetTableFields.getValueMeta( i ).getType() == ValueMetaInterface.TYPE_DATE ) {
        this.builder.append( "(DATE, FORMAT '" );
        this.builder.append( DEFAULT_DATE_FORMAT );
        this.builder.append( "')" );
      }
      if ( i < tableFieldList.size() - 1 ) {
        this.builder.append( "," );
      }
    }
  }
  this.builder.append( ")" );
  return this.newline();
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:32,代码来源:FastloadControlBuilder.java

示例7: beginLoading

import org.pentaho.di.core.util.Assert; //导入依赖的package包/类
/**
 * Issue begin loading with default error tables.
 *
 * @param table
 *          the target table.
 * @return this.
 * @throws IllegalArgumentException
 *           if table is invalid.
 */
public FastloadControlBuilder beginLoading( final String schemaName, final String table ) throws IllegalArgumentException {
  Assert.assertNotBlank( table );
  this.builder.append( "BEGIN LOADING " );
  this.builder.append( table );
  this.builder.append( " ERRORFILES " );
  if ( !Utils.isEmpty( schemaName ) ) {
    this.builder.append( schemaName );
    this.builder.append( "." );
    this.builder.append( DEFAULT_ERROR_TABLE1 );
    this.builder.append( "," );
    this.builder.append( schemaName );
    this.builder.append( "." );
    this.builder.append( DEFAULT_ERROR_TABLE2 );
  } else {
    this.builder.append( DEFAULT_ERROR_TABLE1 );
    this.builder.append( "," );
    this.builder.append( DEFAULT_ERROR_TABLE2 );
  }
  return this.newline();
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:30,代码来源:FastloadControlBuilder.java

示例8: testMillisecondWait

import org.pentaho.di.core.util.Assert; //导入依赖的package包/类
/**
 * Test whether a Millisecond-level timeout actually waits for N milliseconds, instead of N seconds
 */
@Test( timeout = 10000 )
public void testMillisecondWait() {
  int waitMilliseconds = 15;
  Job mockedJob = Mockito.mock( Job.class );
  Mockito.when( mockedJob.isStopped() ).thenReturn( false );

  JobEntryCheckDbConnections meta = new JobEntryCheckDbConnections();
  meta.setParentJob( mockedJob );
  meta.setLogLevel( LogLevel.BASIC );

  DatabaseMeta db = new DatabaseMeta( "InMemory H2", "H2", null, null, H2_DATABASE, "-1", null, null );
  meta.setConnections( new DatabaseMeta[]{ db } );
  meta.setWaittimes( new int[]{ JobEntryCheckDbConnections.UNIT_TIME_MILLI_SECOND } );
  meta.setWaitfors( new String[]{ String.valueOf( waitMilliseconds ) } );
  Result result = meta.execute( new Result(), 0 );
  Assert.assertTrue( result.getResult() );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:21,代码来源:JobEntryCheckDbConnectionsIT.java

示例9: testWaitingtime

import org.pentaho.di.core.util.Assert; //导入依赖的package包/类
@Test( timeout = 5000 )
public void testWaitingtime() {
  int waitTimes = 3;
  Job mockedJob = Mockito.mock( Job.class );
  Mockito.when( mockedJob.isStopped() ).thenReturn( false );

  JobEntryCheckDbConnections meta = new JobEntryCheckDbConnections();
  meta.setParentJob( mockedJob );
  meta.setLogLevel( LogLevel.DETAILED );

  DatabaseMeta db = new DatabaseMeta( "InMemory H2", "H2", null, null, H2_DATABASE, "-1", null, null );
  meta.setConnections( new DatabaseMeta[]{ db } );
  meta.setWaittimes( new int[]{ JobEntryCheckDbConnections.UNIT_TIME_SECOND } );
  meta.setWaitfors( new String[]{ String.valueOf( waitTimes ) } );

  Result result = meta.execute( new Result(), 0 );

  Assert.assertTrue( meta.getNow() - meta.getTimeStart() >= waitTimes * 1000 );
  Assert.assertTrue( result.getResult() );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:21,代码来源:JobEntryCheckDbConnectionsIT.java

示例10: test204Answer

import org.pentaho.di.core.util.Assert; //导入依赖的package包/类
@Test
public void test204Answer() throws Exception {
  startHttpServer( get204AnswerHandler() );
  HTTPData data = new HTTPData();
  int[] index = { 0, 1 };
  RowMeta meta = new RowMeta();
  meta.addValueMeta( new ValueMetaString( "fieldName" ) );
  meta.addValueMeta( new ValueMetaInteger( "codeFieldName" ) );
  Object[] expectedRow = new Object[] { "", 204L };
  HTTP http =
    new HTTPHandler( stepMockHelper.stepMeta, data, 0, stepMockHelper.transMeta, stepMockHelper.trans, false );
  RowMetaInterface inputRowMeta = mock( RowMetaInterface.class );
  http.setInputRowMeta( inputRowMeta );
  when( inputRowMeta.clone() ).thenReturn( inputRowMeta );
  when( stepMockHelper.processRowsStepMetaInterface.getUrl() ).thenReturn( HTTP_LOCALHOST_9998 );
  when( stepMockHelper.processRowsStepMetaInterface.getHeaderField() ).thenReturn( new String[] {} );
  when( stepMockHelper.processRowsStepMetaInterface.getArgumentField() ).thenReturn( new String[] {} );
  when( stepMockHelper.processRowsStepMetaInterface.getResultCodeFieldName() ).thenReturn( "ResultCodeFieldName" );
  when( stepMockHelper.processRowsStepMetaInterface.getFieldName() ).thenReturn( "ResultFieldName" );
  http.init( stepMockHelper.processRowsStepMetaInterface, data );
  Assert.assertTrue( http.processRow( stepMockHelper.processRowsStepMetaInterface, data ) );
  Object[] out = ( (HTTPHandler) http ).getOutputRow();
  Assert.assertTrue( meta.equals( out, expectedRow, index ) );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:25,代码来源:HTTPIT.java

示例11: testNoContent

import org.pentaho.di.core.util.Assert; //导入依赖的package包/类
@Test
public void testNoContent() throws Exception {
  RestData data = new RestData();
  int[] index = { 0, 1 };
  RowMeta meta = new RowMeta();
  meta.addValueMeta( new ValueMetaString( "fieldName" ) );
  meta.addValueMeta( new ValueMetaInteger( "codeFieldName" ) );
  Object[] expectedRow = new Object[] { "", 204L };
  Rest rest =
    new RestHandler( stepMockHelper.stepMeta, data, 0, stepMockHelper.transMeta, stepMockHelper.trans, false );
  RowMetaInterface inputRowMeta = mock( RowMetaInterface.class );
  rest.setInputRowMeta( inputRowMeta );
  when( inputRowMeta.clone() ).thenReturn( inputRowMeta );
  when( stepMockHelper.processRowsStepMetaInterface.getUrl() ).thenReturn(
    HTTP_LOCALHOST_9998 + "restTest/restNoContentAnswer" );
  when( stepMockHelper.processRowsStepMetaInterface.getMethod() ).thenReturn( RestMeta.HTTP_METHOD_GET );
  rest.init( stepMockHelper.processRowsStepMetaInterface, data );
  data.resultFieldName = "ResultFieldName";
  data.resultCodeFieldName = "ResultCodeFieldName";
  Assert.assertTrue( rest.processRow( stepMockHelper.processRowsStepMetaInterface, data ) );
  Object[] out = ( (RestHandler) rest ).getOutputRow();
  Assert.assertTrue( meta.equals( out, expectedRow, index ) );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:24,代码来源:RestIT.java

示例12: test204Answer

import org.pentaho.di.core.util.Assert; //导入依赖的package包/类
@Test
public void test204Answer() throws Exception {
  startHttpServer( get204AnswerHandler() );
  HTTPPOSTData data = new HTTPPOSTData();
  int[] index = { 0, 1 };
  RowMeta meta = new RowMeta();
  meta.addValueMeta( new ValueMetaString( "fieldName" ) );
  meta.addValueMeta( new ValueMetaInteger( "codeFieldName" ) );
  Object[] expectedRow = new Object[] { "", 204L };
  HTTPPOST HTTPPOST = new HTTPPOSTHandler(
    stepMockHelper.stepMeta, data, 0, stepMockHelper.transMeta, stepMockHelper.trans, false );
  RowMetaInterface inputRowMeta = mock( RowMetaInterface.class );
  HTTPPOST.setInputRowMeta( inputRowMeta );
  when( inputRowMeta.clone() ).thenReturn( inputRowMeta );
  when( stepMockHelper.processRowsStepMetaInterface.getUrl() ).thenReturn( HTTP_LOCALHOST_9998 );
  when( stepMockHelper.processRowsStepMetaInterface.getQueryField() ).thenReturn( new String[] {} );
  when( stepMockHelper.processRowsStepMetaInterface.getArgumentField() ).thenReturn( new String[] {} );
  when( stepMockHelper.processRowsStepMetaInterface.getResultCodeFieldName() ).thenReturn( "ResultCodeFieldName" );
  when( stepMockHelper.processRowsStepMetaInterface.getFieldName() ).thenReturn( "ResultFieldName" );
  HTTPPOST.init( stepMockHelper.processRowsStepMetaInterface, data );
  Assert.assertTrue( HTTPPOST.processRow( stepMockHelper.processRowsStepMetaInterface, data ) );
  Object[] out = ( (HTTPPOSTHandler) HTTPPOST ).getOutputRow();
  Assert.assertTrue( meta.equals( out, expectedRow, index ) );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:25,代码来源:HTTPPOSTIT.java

示例13: testServerReturnsCorrectlyEncodedParams

import org.pentaho.di.core.util.Assert; //导入依赖的package包/类
public void testServerReturnsCorrectlyEncodedParams( String testString, String testCharset ) throws Exception {
  AtomicBoolean testStatus = new AtomicBoolean();
  startHttpServer( getEncodingCheckingHandler( testString, testCharset, testStatus ) );
  HTTPPOSTData data = new HTTPPOSTData();
  RowMeta meta = new RowMeta();
  meta.addValueMeta( new ValueMetaString( "fieldName" ) );
  HTTPPOSTHandler httpPost = new HTTPPOSTHandler(
    stepMockHelper.stepMeta, data, 0, stepMockHelper.transMeta, stepMockHelper.trans, false );
  RowMetaInterface inputRowMeta = mock( RowMetaInterface.class );
  httpPost.setInputRowMeta( inputRowMeta );
  httpPost.row = new Object[] { testString };
  when( inputRowMeta.clone() ).thenReturn( inputRowMeta );
  when( inputRowMeta.getString( httpPost.row, 0 ) ).thenReturn( testString );
  when( stepMockHelper.processRowsStepMetaInterface.getUrl() ).thenReturn( HTTP_LOCALHOST_9998 );
  when( stepMockHelper.processRowsStepMetaInterface.getQueryField() ).thenReturn( new String[] {} );
  when( stepMockHelper.processRowsStepMetaInterface.getArgumentField() )
    .thenReturn( new String[] { "testBodyField" } );
  when( stepMockHelper.processRowsStepMetaInterface.getArgumentParameter() )
    .thenReturn( new String[] { "testBodyParam" } );
  when( stepMockHelper.processRowsStepMetaInterface.getArgumentHeader() ).thenReturn( new boolean[] { false } );
  when( stepMockHelper.processRowsStepMetaInterface.getFieldName() ).thenReturn( "ResultFieldName" );
  when( stepMockHelper.processRowsStepMetaInterface.getEncoding() ).thenReturn( testCharset );
  httpPost.init( stepMockHelper.processRowsStepMetaInterface, data );
  Assert.assertTrue( httpPost.processRow( stepMockHelper.processRowsStepMetaInterface, data ) );
  Assert.assertTrue( testStatus.get(), "Test failed" );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:27,代码来源:HTTPPOSTIT.java

示例14: GoogleAnalyticsApiFacade

import org.pentaho.di.core.util.Assert; //导入依赖的package包/类
public GoogleAnalyticsApiFacade( HttpTransport httpTransport, JsonFactory jsonFactory, String application,
                                 String oathServiceEmail, File keyFile )
  throws IOException, GeneralSecurityException {

  Assert.assertNotNull( httpTransport, "HttpTransport cannot be null" );
  Assert.assertNotNull( jsonFactory, "JsonFactory cannot be null" );
  Assert.assertNotBlank( application, "Application name cannot be empty" );
  Assert.assertNotBlank( oathServiceEmail, "OAuth Service Email name cannot be empty" );
  Assert.assertNotNull( keyFile, "OAuth secret key file cannot be null" );

  this.httpTransport = httpTransport;

  Credential credential = new GoogleCredential.Builder()
    .setTransport( httpTransport )
    .setJsonFactory( jsonFactory )
    .setServiceAccountScopes( AnalyticsScopes.all() )
    .setServiceAccountId( oathServiceEmail )
    .setServiceAccountPrivateKeyFromP12File( keyFile )
    .build();

  analytics = new Analytics.Builder( httpTransport, jsonFactory, credential )
    .setApplicationName( application )
    .build();
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:25,代码来源:GoogleAnalyticsApiFacade.java

示例15: logon

import org.pentaho.di.core.util.Assert; //导入依赖的package包/类
/**
 * Append log on.
 * 
 * @param dbhost
 *            DB host, e.g localtd
 * @param user
 *            the user.
 * @param password
 *            the password.
 * @return this
 * @throws IllegalArgumentException
 *             if input is invalid.
 */
public FastloadControlBuilder logon(final String dbhost, final String user, final String password)
        throws IllegalArgumentException {
    Assert.assertNotBlank(dbhost, "DB host must not be blank");
    Assert.assertNotBlank(user, "User must not be blank");
    Assert.assertNotNull(password, "Password must not be null");
    this.builder.append("LOGON ");
    this.builder.append(dbhost);
    this.builder.append('/');
    this.builder.append(user);
    this.builder.append(',');
    this.builder.append(password);
    return this.newline();
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:27,代码来源:FastloadControlBuilder.java


注:本文中的org.pentaho.di.core.util.Assert类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。