src_fm_fc_ms_ff
stringlengths
43
86.8k
target
stringlengths
20
276k
DataHandler extends AbstractXulEventHandler { public void getOptionHelp() { String message = null; DatabaseMeta database = new DatabaseMeta(); getInfo( database ); String url = database.getExtraOptionsHelpText(); if ( ( url == null ) || ( url.trim().length() == 0 ) ) { message = Messages.getString( "DataHandler.USER_NO...
@Test public void testGetOptionHelp() throws Exception { when( accessBox.getSelectedItem() ).thenReturn( "JNDI" ); when( connectionBox.getSelectedItem() ).thenReturn( "PostgreSQL" ); dataHandler.getOptionHelp(); } @Test( expected = RuntimeException.class ) public void testGetOptionHelpNoDatabase() throws Exception { wh...
SvgSupport { public static String toPngName( String name ) { if ( isSvgName( name ) ) { name = name.substring( 0, name.length() - 4 ) + PNG_EXTENSION; } return name; } static boolean isSvgEnabled(); static SvgImage loadSvgImage( InputStream in ); static boolean isSvgName( String name ); static String toPngName( String...
@Test public void testToPngName() throws Exception { assertTrue( SvgSupport.isPngName( "my_file.png" ) ); assertTrue( SvgSupport.isPngName( "my_file.PNG" ) ); assertTrue( SvgSupport.isPngName( ".png" ) ); assertFalse( SvgSupport.isPngName( "png" ) ); assertFalse( SvgSupport.isPngName( "myFile.svg" ) ); assertEquals( "m...
SvgSupport { public static String toSvgName( String name ) { if ( isPngName( name ) ) { name = name.substring( 0, name.length() - 4 ) + SVG_EXTENSION; } return name; } static boolean isSvgEnabled(); static SvgImage loadSvgImage( InputStream in ); static boolean isSvgName( String name ); static String toPngName( String...
@Test public void testToSvgName() throws Exception { assertTrue( SvgSupport.isSvgName( "my_file.svg" ) ); assertTrue( SvgSupport.isSvgName( "my_file.SVG" ) ); assertTrue( SvgSupport.isSvgName( ".svg" ) ); assertFalse( SvgSupport.isSvgName( "svg" ) ); assertFalse( SvgSupport.isSvgName( "myFile.png" ) ); assertEquals( "m...
SvgImage { public Document getDocument() { return document; } protected SvgImage( Document doc ); Document getDocument(); }
@Test public void testGetDocument() throws Exception { assertEquals( document, image.getDocument() ); }
LogMessage implements LogMessageInterface { @Override @Deprecated public String toString() { if ( message == null ) { return subject; } if ( arguments != null && arguments.length > 0 ) { return subject + " - " + MessageFormat.format( message, arguments ); } else { return subject + " - " + message; } } LogMessage( Strin...
@Test public void testToString() throws Exception { LogMessage msg = new LogMessage( "Log message", "Channel 01", LogLevel.DEBUG ); msg.setSubject( "Simple" ); assertEquals( "Simple - Log message", msg.toString( ) ); }
KettleLogLayout { public String format( KettleLoggingEvent event ) { StringBuilder line = new StringBuilder(); String dateTimeString = ""; if ( timeAdded ) { dateTimeString = LOCAL_SIMPLE_DATE_PARSER.get().format( new Date( event.timeStamp ) ) + " - "; } Object object = event.getMessage(); if ( object instanceof LogMes...
@Test public void testFormat() throws Exception { LogMessage mcg = new LogMessage( "Log message for {0}", "Channel 01", new String[]{ "Test" }, LogLevel.DEBUG ); mcg.setSubject( "Subject" ); KettleLoggingEvent event = new KettleLoggingEvent( mcg, 0, LogLevel.BASIC ); KettleLogLayout layout = new KettleLogLayout(); fina...
LoggingObject implements LoggingObjectInterface { @Override public boolean equals( Object obj ) { if ( !( obj instanceof LoggingObject ) ) { return false; } if ( obj == this ) { return true; } try { LoggingObject loggingObject = (LoggingObject) obj; boolean sameCarteFamily = ( getContainerObjectId() == null && loggingO...
@Test public void testEquals() throws Exception { LoggingObjectInterface parent = new LoggingObject( new SimpleLoggingObject( "parent", LoggingObjectType.JOB, null ) ); LoggingObject loggingObject1 = new LoggingObject( "test" ); loggingObject1.setFilename( "fileName" ); loggingObject1.setParent( parent ); loggingObject...
MetricsRegistry { public Map<String, Queue<MetricsSnapshotInterface>> getSnapshotLists() { return snapshotLists; } private MetricsRegistry(); static MetricsRegistry getInstance(); void addSnapshot( LogChannelInterface logChannel, MetricsSnapshotInterface snapshot ); Map<String, Queue<MetricsSnapshotInterface>> getSnap...
@Test( timeout = 2000 ) public void testConcurrencySnap() throws Exception { ExecutorService service = Executors.newFixedThreadPool( threadCount ); for ( int i = 0; i < threadCount; i++ ) { service.submit( new ConcurrentPutIfAbsent( logIds.get( i % 20 ) ) ); } countDownLatch.countDown(); service.shutdown(); while ( !se...
JndiUtil { public static void initJNDI() throws KettleException { String path = Const.JNDI_DIRECTORY; if ( path == null || path.equals( "" ) ) { try { File file = new File( "simple-jndi" ); path = file.getCanonicalPath(); } catch ( Exception e ) { throw new KettleException( "Error initializing JNDI", e ); } Const.JNDI_...
@Test public void testInitJNDI() throws Exception { final String factoryInitialKey = "java.naming.factory.initial"; final String factoryInitialBak = System.getProperty( factoryInitialKey ); final String sjRootKey = "org.osjava.sj.root"; final String sjRootBak = System.getProperty( sjRootKey ); final String sjDelimiterK...
RowMetaAndData implements Cloneable { public Object getAsJavaType( String valueName, Class<?> destinationType, InjectionTypeConverter converter ) throws KettleValueException { int idx = rowMeta.indexOfValue( valueName ); if ( idx < 0 ) { throw new KettleValueException( "Unknown column '" + valueName + "'" ); } ValueMet...
@Test public void testStringConversion() throws Exception { row = new RowMetaAndData( rowsMeta, "text", null, null ); assertEquals( "text", row.getAsJavaType( "str", String.class, converter ) ); row = new RowMetaAndData( rowsMeta, "7", null, null ); assertEquals( 7, row.getAsJavaType( "str", int.class, converter ) ); a...
ExtensionPointMap { public void addExtensionPoint( PluginInterface extensionPointPlugin ) { lock.writeLock().lock(); try { for ( String id : extensionPointPlugin.getIds() ) { extensionPointPluginMap.put( extensionPointPlugin.getName(), id, createLazyLoader( extensionPointPlugin ) ); } } finally { lock.writeLock().unloc...
@Test public void addExtensionPointTest() throws KettlePluginException { ExtensionPointMap.getInstance().addExtensionPoint( pluginInterface ); assertEquals( ExtensionPointMap.getInstance().getTableValue( TEST_NAME, "testID" ), extensionPoint ); assertEquals( ExtensionPointMap.getInstance().getTableValue( TEST_NAME, "te...
ExtensionPointHandler { public static void callExtensionPoint( final LogChannelInterface log, final String id, final Object object ) throws KettleException { ExtensionPointMap.getInstance().callExtensionPoint( log, id, object ); } static void callExtensionPoint( final LogChannelInterface log, final String id, final Ob...
@Test public void callExtensionPointTest() throws Exception { PluginMockInterface pluginInterface = mock( PluginMockInterface.class ); when( pluginInterface.getName() ).thenReturn( TEST_NAME ); when( pluginInterface.getMainType() ).thenReturn( (Class) ExtensionPointInterface.class ); when( pluginInterface.getIds() ).th...
Encr { public static final String encryptPassword( String password ) { return encoder.encode( password, false ); } Encr(); @Deprecated boolean init(); static void init( String encoderPluginId ); @Deprecated static final boolean checkSignatureShort( String signature, String verify ); @Deprecated static final String getS...
@Test public void testEncryptPassword() throws KettleValueException { String encryption; encryption = Encr.encryptPassword( null ); assertTrue( "".equals( encryption ) ); encryption = Encr.encryptPassword( "" ); assertTrue( "".equals( encryption ) ); encryption = Encr.encryptPassword( " " ); assertTrue( "2be98afc86aa7f...
Encr { public static final String decryptPassword( String encrypted ) { return encoder.decode( encrypted ); } Encr(); @Deprecated boolean init(); static void init( String encoderPluginId ); @Deprecated static final boolean checkSignatureShort( String signature, String verify ); @Deprecated static final String getSignat...
@Test public void testDecryptPassword() throws KettleValueException { String encryption; String decryption; encryption = Encr.encryptPassword( null ); decryption = Encr.decryptPassword( encryption ); assertTrue( "".equals( decryption ) ); encryption = Encr.encryptPassword( "" ); decryption = Encr.decryptPassword( encry...
Encr { public static final String encryptPasswordIfNotUsingVariables( String password ) { return encoder.encode( password, true ); } Encr(); @Deprecated boolean init(); static void init( String encoderPluginId ); @Deprecated static final boolean checkSignatureShort( String signature, String verify ); @Deprecated static...
@Test public void testEncryptPasswordIfNotUsingVariables() throws KettleValueException { String encryption; encryption = Encr.encryptPasswordIfNotUsingVariables( null ); assertTrue( "Encrypted ".equals( encryption ) ); encryption = Encr.encryptPasswordIfNotUsingVariables( "" ); assertTrue( "Encrypted ".equals( encrypti...
CertificateGenEncryptUtil { public static Key generateSingleKey() throws NoSuchAlgorithmException { Key key = KeyGenerator.getInstance( SINGLE_KEY_ALGORITHM ).generateKey(); return key; } static KeyPair generateKeyPair(); static Key generateSingleKey(); static byte[] encodeKeyForTransmission( Key encodingKey, Key keyT...
@Test public void testRandomSessionKeyGeneration() throws Exception { Key key = CertificateGenEncryptUtil.generateSingleKey(); Key key1 = CertificateGenEncryptUtil.generateSingleKey(); assertFalse( key.equals( key1 ) ); assertFalse( Arrays.equals( key.getEncoded(), key1.getEncoded() ) ); }
KettleTwoWayPasswordEncoder implements TwoWayPasswordEncoderInterface { @Override public String encode( String rawPassword ) { return encode( rawPassword, true ); } KettleTwoWayPasswordEncoder(); @Override void init(); @Override String encode( String rawPassword ); @Override String encode( String rawPassword, boolean i...
@Test public void testEncode1() throws KettleValueException { KettleTwoWayPasswordEncoder encoder = new KettleTwoWayPasswordEncoder(); String encryption; encryption = encoder.encode( null, false ); assertTrue( "".equals( encryption ) ); encryption = encoder.encode( "", false ); assertTrue( "".equals( encryption ) ); en...
QueueRowSet extends BaseRowSet implements Comparable<RowSet>, RowSet { @Override public boolean putRow( RowMetaInterface rowMeta, Object[] rowData ) { this.rowMeta = rowMeta; buffer.add( rowData ); return true; } QueueRowSet(); @Override Object[] getRow(); @Override Object[] getRowImmediate(); @Override Object[] getRow...
@Test public void testPutRow() throws Exception { rowSet.putRow( new RowMeta(), row ); assertSame( row, rowSet.getRow() ); }
QueueRowSet extends BaseRowSet implements Comparable<RowSet>, RowSet { @Override public boolean putRowWait( RowMetaInterface rowMeta, Object[] rowData, long time, TimeUnit tu ) { return putRow( rowMeta, rowData ); } QueueRowSet(); @Override Object[] getRow(); @Override Object[] getRowImmediate(); @Override Object[] get...
@Test public void testPutRowWait() throws Exception { rowSet.putRowWait( new RowMeta(), row, 1, TimeUnit.SECONDS ); assertSame( row, rowSet.getRowWait( 1, TimeUnit.SECONDS ) ); }
QueueRowSet extends BaseRowSet implements Comparable<RowSet>, RowSet { @Override public Object[] getRowImmediate() { return getRow(); } QueueRowSet(); @Override Object[] getRow(); @Override Object[] getRowImmediate(); @Override Object[] getRowWait( long timeout, TimeUnit tu ); @Override boolean putRow( RowMetaInterface...
@Test public void testGetRowImmediate() throws Exception { rowSet.putRow( new RowMeta(), row ); assertSame( row, rowSet.getRowImmediate() ); }
QueueRowSet extends BaseRowSet implements Comparable<RowSet>, RowSet { @Override public int size() { return buffer.size(); } QueueRowSet(); @Override Object[] getRow(); @Override Object[] getRowImmediate(); @Override Object[] getRowWait( long timeout, TimeUnit tu ); @Override boolean putRow( RowMetaInterface rowMeta, O...
@Test public void testSize() throws Exception { assertEquals( 0, rowSet.size() ); rowSet.putRow( new RowMeta(), row ); assertEquals( 1, rowSet.size() ); rowSet.putRow( new RowMeta(), row ); assertEquals( 2, rowSet.size() ); rowSet.clear(); assertEquals( 0, rowSet.size() ); }
RowMeta implements RowMetaInterface { @Override public List<ValueMetaInterface> getValueMetaList() { List<ValueMetaInterface> copy; lock.readLock().lock(); try { copy = new ArrayList<ValueMetaInterface>( valueMetaList ); } finally { lock.readLock().unlock(); } return Collections.unmodifiableList( copy ); } RowMeta(); p...
@Test public void testGetValueMetaList() { List<ValueMetaInterface> list = rowMeta.getValueMetaList(); assertTrue( list.contains( string ) ); assertTrue( list.contains( integer ) ); assertTrue( list.contains( date ) ); }
RowMeta implements RowMetaInterface { @Override public void setValueMetaList( List<ValueMetaInterface> valueMetaList ) { lock.writeLock().lock(); try { this.valueMetaList = valueMetaList; this.cache.invalidate(); for ( int i = 0, len = valueMetaList.size(); i < len; i++ ) { ValueMetaInterface valueMeta = valueMetaList....
@Test public void testSetValueMetaList() throws KettlePluginException { List<ValueMetaInterface> setList = this.generateVList( new String[]{ "alpha", "bravo" }, new int[]{ 2, 2 } ); rowMeta.setValueMetaList( setList ); assertTrue( setList.contains( rowMeta.searchValueMeta( "alpha" ) ) ); assertTrue( setList.contains( r...
RowMeta implements RowMetaInterface { @Override public boolean exists( ValueMetaInterface meta ) { return ( meta != null ) && searchValueMeta( meta.getName() ) != null; } RowMeta(); private RowMeta( RowMeta rowMeta, Integer targetType ); private RowMeta( List<ValueMetaInterface> valueMetaList, RowMetaCache rowMetaCac...
@Test public void testExists() { assertTrue( rowMeta.exists( string ) ); assertTrue( rowMeta.exists( date ) ); assertTrue( rowMeta.exists( integer ) ); }
RowMeta implements RowMetaInterface { @Override public ValueMetaInterface getValueMeta( int index ) { lock.readLock().lock(); try { if ( ( index >= 0 ) && ( index < valueMetaList.size() ) ) { return valueMetaList.get( index ); } else { return null; } } finally { lock.readLock().unlock(); } } RowMeta(); private RowMeta...
@Test public void testGetValueMeta() { assertTrue( rowMeta.getValueMeta( 1 ).equals( integer ) ); }
RowMeta implements RowMetaInterface { @Override public void setValueMeta( int index, ValueMetaInterface valueMeta ) { if ( valueMeta != null ) { lock.writeLock().lock(); try { ValueMetaInterface old = valueMetaList.get( index ); ValueMetaInterface newMeta = valueMeta; int existsIndex = indexOfValue( valueMeta.getName()...
@Test public void testSetValueMeta() throws KettlePluginException { rowMeta.setValueMeta( 1, charly ); assertEquals( 1, rowMeta.getValueMetaList().indexOf( charly ) ); assertEquals( "There is still 3 elements:", 3, rowMeta.size() ); assertEquals( -1, rowMeta.indexOfValue( "integer" ) ); }
RowMeta implements RowMetaInterface { @Override public int indexOfValue( String valueName ) { if ( valueName == null ) { return -1; } lock.readLock().lock(); try { Integer index = cache.findAndCompare( valueName, valueMetaList ); for ( int i = 0; ( index == null ) && ( i < valueMetaList.size() ); i++ ) { if ( valueName...
@Test public void testIndexOfValue() { List<ValueMetaInterface> list = rowMeta.getValueMetaList(); assertEquals( 0, list.indexOf( string ) ); assertEquals( 1, list.indexOf( integer ) ); assertEquals( 2, list.indexOf( date ) ); } @Test public void testIndexOfNullValue() { assertEquals( -1, rowMeta.indexOfValue( null ) )...
RowMeta implements RowMetaInterface { @Override public ValueMetaInterface searchValueMeta( String valueName ) { lock.readLock().lock(); try { Integer index = indexOfValue( valueName ); if ( index < 0 ) { return null; } return valueMetaList.get( index ); } finally { lock.readLock().unlock(); } } RowMeta(); private RowM...
@Test public void testSearchValueMeta() { ValueMetaInterface vmi = rowMeta.searchValueMeta( "integer" ); assertEquals( integer, vmi ); vmi = rowMeta.searchValueMeta( "string" ); assertEquals( string, vmi ); vmi = rowMeta.searchValueMeta( "date" ); assertEquals( date, vmi ); } @Test public void testLowerCaseNamesSearch(...
RowMeta implements RowMetaInterface { @Override public void addRowMeta( RowMetaInterface rowMeta ) { for ( int i = 0; i < rowMeta.size(); i++ ) { addValueMeta( rowMeta.getValueMeta( i ) ); } } RowMeta(); private RowMeta( RowMeta rowMeta, Integer targetType ); private RowMeta( List<ValueMetaInterface> valueMetaList, R...
@Test public void testAddRowMeta() throws KettlePluginException { List<ValueMetaInterface> list = this.generateVList( new String[]{ "alfa", "bravo", "charly", "delta" }, new int[]{ 2, 2, 3, 4 } ); RowMeta added = new RowMeta(); added.setValueMetaList( list ); rowMeta.addRowMeta( added ); assertEquals( 7, rowMeta.getVal...
RowMeta implements RowMetaInterface { @Override public void mergeRowMeta( RowMetaInterface r ) { mergeRowMeta( r, null ); } RowMeta(); private RowMeta( RowMeta rowMeta, Integer targetType ); private RowMeta( List<ValueMetaInterface> valueMetaList, RowMetaCache rowMetaCache ); RowMeta( DataInputStream inputStream ); ...
@Test public void testMergeRowMeta() throws KettlePluginException { List<ValueMetaInterface> list = this.generateVList( new String[]{ "phobos", "demos", "mars" }, new int[]{ 6, 6, 6 } ); list.add( 1, integer ); RowMeta toMerge = new RowMeta(); toMerge.setValueMetaList( list ); rowMeta.mergeRowMeta( toMerge ); assertEqu...
RowMeta implements RowMetaInterface { @Override public String[] getFieldNames() { lock.readLock().lock(); try { String[] retval = new String[ size() ]; for ( int i = 0; i < size(); i++ ) { String valueName = getValueMeta( i ).getName(); retval[i] = valueName == null ? "" : valueName; } return retval; } finally { lock.r...
@Test public void testGetFieldNames() { rowMeta.clear(); fillRowMeta(); String[] names = rowMeta.getFieldNames(); assertEquals( 10, names.length ); assertEquals( "sample", names[0] ); for ( int i = 1; i < names.length; i++ ) { assertEquals( "", names[i] ); } }
ValueMetaTimestamp extends ValueMetaDate { @Override public void setPreparedStatementValue( DatabaseMeta databaseMeta, PreparedStatement preparedStatement, int index, Object data ) throws KettleDatabaseException { try { if ( data != null ) { preparedStatement.setTimestamp( index, getTimestamp( data ) ); } else { prepar...
@Test public void testSetPreparedStatementValue() throws Exception { ValueMetaTimestamp vm = new ValueMetaTimestamp(); PreparedStatement ps = mock( PreparedStatement.class ); doAnswer( new Answer<Object>() { @Override public Object answer( InvocationOnMock invocationOnMock ) throws Throwable { Object ts = invocationOnM...
ValueMetaTimestamp extends ValueMetaDate { public int compare( Object data1, Object data2 ) throws KettleValueException { Timestamp timestamp1 = getTimestamp( data1 ); Timestamp timestamp2 = getTimestamp( data2 ); int cmp = 0; if ( timestamp1 == null ) { if ( timestamp2 == null ) { cmp = 0; } else { cmp = -1; } } else ...
@Test public void testCompare() throws Exception { ValueMetaTimestamp vm = new ValueMetaTimestamp(); Timestamp earlier = Timestamp.valueOf( "2012-12-12 12:12:12.121212" ); Timestamp later = Timestamp.valueOf( "2013-12-12 12:12:12.121212" ); assertTrue( vm.isSortedAscending() ); assertFalse( vm.isSortedDescending() ); a...
ValueMetaTimestamp extends ValueMetaDate { protected synchronized Timestamp convertStringToTimestamp( String string ) throws KettleValueException { string = Const.trimToType( string, getTrimType() ); if ( Utils.isEmpty( string ) ) { return null; } Timestamp returnValue; try { returnValue = Timestamp.valueOf( string ); ...
@Test public void testConvertStringToTimestamp() throws Exception { ValueMetaTimestamp valueMetaTimestamp = new ValueMetaTimestamp(); assertEquals( Timestamp.valueOf( "2012-04-05 04:03:02.123456" ), valueMetaTimestamp .convertStringToTimestamp( "2012/4/5 04:03:02.123456" ) ); assertEquals( Timestamp.valueOf( "2012-04-0...
ValueMetaTimestamp extends ValueMetaDate { protected synchronized String convertTimestampToString( Timestamp timestamp ) throws KettleValueException { if ( timestamp == null ) { return null; } return getDateFormat().format( timestamp ); } ValueMetaTimestamp(); ValueMetaTimestamp( String name ); @Override boolean isDat...
@Test public void testConvertTimestampToString() throws Exception { ValueMetaTimestamp valueMetaTimestamp = new ValueMetaTimestamp(); assertEquals( "2012/04/05 04:03:02.123456000", valueMetaTimestamp.convertTimestampToString( Timestamp .valueOf( "2012-04-05 04:03:02.123456" ) ) ); assertEquals( "2012/04/05 04:03:02.123...
ValueMetaTimestamp extends ValueMetaDate { public Timestamp convertDateToTimestamp( Date date ) throws KettleValueException { if ( date == null ) { return null; } Timestamp result = null; if ( date instanceof Timestamp ) { result = (Timestamp) date; } else { result = new Timestamp( date.getTime() ); } return result; } ...
@Test public void testConvertDateToTimestamp() throws Exception { ValueMetaTimestamp valueMetaTimestamp = new ValueMetaTimestamp(); Date date = new Date(); assertEquals( valueMetaTimestamp.convertDateToTimestamp( date ).getTime(), date.getTime() ); Timestamp timestamp = Timestamp.valueOf( "2014-04-05 04:03:02.123456789...
ValueMetaInternetAddress extends ValueMetaDate { @Override public int compare( Object data1, Object data2 ) throws KettleValueException { InetAddress inet1 = getInternetAddress( data1 ); InetAddress inet2 = getInternetAddress( data2 ); int cmp = 0; if ( inet1 == null ) { if ( inet2 == null ) { cmp = 0; } else { cmp = -...
@Test public void testCompare() throws UnknownHostException, KettleValueException { ValueMetaInternetAddress vm = new ValueMetaInternetAddress(); InetAddress smaller = InetAddress.getByName( "127.0.0.1" ); InetAddress larger = InetAddress.getByName( "127.0.1.1" ); assertTrue( vm.isSortedAscending() ); assertFalse( vm.i...
ValueMetaInternetAddress extends ValueMetaDate { @Override public byte[] getBinaryString( Object object ) throws KettleValueException { if ( isStorageBinaryString() && identicalFormat ) { return (byte[]) object; } if ( object == null ) { return null; } switch ( storageType ) { case STORAGE_TYPE_NORMAL: return convertSt...
@Test public void testGetBinaryString() throws KettleValueException, UnknownHostException { ValueMetaInternetAddress vmInet = new ValueMetaInternetAddress(); final ValueMetaString vmString = new ValueMetaString(); vmInet.setStorageMetadata( vmString ); InetAddress inetAddress = InetAddress.getByName( "127.0.0.1" ); byt...
ValueMetaFactory { public static ValueMetaInterface cloneValueMeta( ValueMetaInterface source ) throws KettlePluginException { return cloneValueMeta( source, source.getType() ); } static ValueMetaInterface createValueMeta( String name, int type, int length, int precision ); static ValueMetaInterface createValueMeta( S...
@Test public void testClone() throws KettleException { ValueMetaInterface original = new ValueMetaString(); original.setCollatorLocale( Locale.CANADA ); original.setCollatorStrength( 3 ); ValueMetaInterface cloned = ValueMetaFactory.cloneValueMeta( original ); assertNotNull( cloned ); assertNotSame( original, cloned );...
ValueMetaFactory { public static ValueMetaInterface createValueMeta( String name, int type, int length, int precision ) throws KettlePluginException { PluginInterface stringPlugin = pluginRegistry.getPlugin( ValueMetaPluginType.class, String.valueOf( type ) ); if ( stringPlugin == null ) { throw new KettlePluginExcepti...
@Test public void testCreateValueMeta() throws KettlePluginException { ValueMetaInterface testObject; try { testObject = ValueMetaFactory.createValueMeta( Integer.MIN_VALUE ); fail(); } catch ( KettlePluginException expected ) { } try { testObject = ValueMetaFactory.createValueMeta( null, Integer.MIN_VALUE ); fail(); }...
ValueMetaFactory { public static String[] getValueMetaNames() { List<String> strings = new ArrayList<String>(); List<PluginInterface> plugins = pluginRegistry.getPlugins( ValueMetaPluginType.class ); for ( PluginInterface plugin : plugins ) { int id = Integer.valueOf( plugin.getIds()[0] ); if ( id > 0 && id != ValueMet...
@Test public void testGetValueMetaNames() { List<String> dataTypes = Arrays.<String>asList( ValueMetaFactory.getValueMetaNames() ); assertTrue( dataTypes.contains( "Number" ) ); assertTrue( dataTypes.contains( "String" ) ); assertTrue( dataTypes.contains( "Date" ) ); assertTrue( dataTypes.contains( "Boolean" ) ); asser...
ValueMetaFactory { public static String[] getAllValueMetaNames() { List<String> strings = new ArrayList<String>(); List<PluginInterface> plugins = pluginRegistry.getPlugins( ValueMetaPluginType.class ); for ( PluginInterface plugin : plugins ) { String id = plugin.getIds()[0]; if ( !( "0".equals( id ) ) ) { strings.add...
@Test public void testGetAllValueMetaNames() { List<String> dataTypes = Arrays.<String>asList( ValueMetaFactory.getAllValueMetaNames() ); assertTrue( dataTypes.contains( "Number" ) ); assertTrue( dataTypes.contains( "String" ) ); assertTrue( dataTypes.contains( "Date" ) ); assertTrue( dataTypes.contains( "Boolean" ) );...
ValueMetaFactory { public static String getValueMetaName( int type ) { for ( PluginInterface plugin : pluginRegistry.getPlugins( ValueMetaPluginType.class ) ) { if ( Integer.toString( type ).equals( plugin.getIds()[0] ) ) { return plugin.getName(); } } return "-"; } static ValueMetaInterface createValueMeta( String na...
@Test public void testGetValueMetaName() { assertEquals( "-", ValueMetaFactory.getValueMetaName( Integer.MIN_VALUE ) ); assertEquals( "None", ValueMetaFactory.getValueMetaName( ValueMetaInterface.TYPE_NONE ) ); assertEquals( "Number", ValueMetaFactory.getValueMetaName( ValueMetaInterface.TYPE_NUMBER ) ); assertEquals( ...
ValueMetaFactory { public static int getIdForValueMeta( String valueMetaName ) { for ( PluginInterface plugin : pluginRegistry.getPlugins( ValueMetaPluginType.class ) ) { if ( valueMetaName != null && valueMetaName.equalsIgnoreCase( plugin.getName() ) ) { return Integer.valueOf( plugin.getIds()[0] ); } } return ValueMe...
@Test public void testGetIdForValueMeta() { assertEquals( ValueMetaInterface.TYPE_NONE, ValueMetaFactory.getIdForValueMeta( null ) ); assertEquals( ValueMetaInterface.TYPE_NONE, ValueMetaFactory.getIdForValueMeta( "" ) ); assertEquals( ValueMetaInterface.TYPE_NONE, ValueMetaFactory.getIdForValueMeta( "None" ) ); assert...
ValueMetaFactory { public static List<ValueMetaInterface> getValueMetaPluginClasses() throws KettlePluginException { List<ValueMetaInterface> list = new ArrayList<ValueMetaInterface>(); List<PluginInterface> plugins = pluginRegistry.getPlugins( ValueMetaPluginType.class ); for ( PluginInterface plugin : plugins ) { Val...
@Test public void testGetValueMetaPluginClasses() throws KettlePluginException { List<ValueMetaInterface> dataTypes = ValueMetaFactory.getValueMetaPluginClasses(); boolean numberExists = false; boolean stringExists = false; boolean dateExists = false; boolean booleanExists = false; boolean integerExists = false; boolea...
MessageEventService { public void fireEvent( final Message event ) throws MessageEventFireEventException { if ( event != null ) { if ( containsHandlerFor( event ) ) { final Collection<MessageEventHandler> handlers = getHandlersFor( event ); if ( handlers != null && handlers.size() > 0 ) { MessageEventFireEventException...
@Test( expected = MessageEventFireEventException.class ) public void testFireEventNull() throws KettleException { messageEventService.fireEvent( null ); } @Test public void testOperationFireEvent() throws KettleException { addHandlers( operationMessageEvent, messageEventHandler, messageEventHandler2 ); LogEvent logEven...
ValueMetaFactory { public static ValueMetaInterface guessValueMetaInterface( Object object ) { if ( object instanceof Number ) { if ( object instanceof BigDecimal ) { return new ValueMetaBigNumber(); } else if ( object instanceof Double ) { return new ValueMetaNumber(); } else if ( object instanceof Long ) { return new...
@Test public void testGuessValueMetaInterface() { assertTrue( ValueMetaFactory.guessValueMetaInterface( new BigDecimal( 1.0 ) ) instanceof ValueMetaBigNumber ); assertTrue( ValueMetaFactory.guessValueMetaInterface( new Double( 1.0 ) ) instanceof ValueMetaNumber ); assertTrue( ValueMetaFactory.guessValueMetaInterface( n...
ValueMetaBase implements ValueMetaInterface { @Override public String getDataXML( Object object ) throws IOException { StringBuilder xml = new StringBuilder(); String string; if ( object != null ) { try { switch ( storageType ) { case STORAGE_TYPE_NORMAL: switch ( getType() ) { case TYPE_STRING: string = (String) objec...
@Test public void testGetDataXML() throws IOException { BigDecimal bigDecimal = BigDecimal.ONE; ValueMetaBase valueDoubleMetaBase = new ValueMetaBase( String.valueOf( bigDecimal ), ValueMetaInterface.TYPE_BIGNUMBER ); assertEquals( "<value-data>" + Encode.forXml( String.valueOf( bigDecimal ) ) + "</value-data>" + Syste...
ValueMetaBase implements ValueMetaInterface { @SuppressWarnings( "fallthrough" ) @Override public ValueMetaInterface getValueFromSQLType( DatabaseMeta databaseMeta, String name, java.sql.ResultSetMetaData rm, int index, boolean ignoreLength, boolean lazyConversion ) throws KettleDatabaseException { try { int length = -...
@Test public void testGetValueFromSQLTypeTypeOverride() throws Exception { final int varbinaryColumnIndex = 2; ValueMetaBase valueMetaBase = new ValueMetaBase(), valueMetaBaseSpy = Mockito.spy( valueMetaBase ); DatabaseMeta dbMeta = Mockito.mock( DatabaseMeta.class ); DatabaseInterface databaseInterface = Mockito.mock(...
ValueMetaBase implements ValueMetaInterface { public static Boolean convertStringToBoolean( String string ) { if ( Utils.isEmpty( string ) ) { return null; } return Boolean.valueOf( "Y".equalsIgnoreCase( string ) || "TRUE".equalsIgnoreCase( string ) || "YES".equalsIgnoreCase( string ) || "1".equals( string ) ); } Value...
@Test public void testConvertStringToBoolean() { assertNull( ValueMetaBase.convertStringToBoolean( null ) ); assertNull( ValueMetaBase.convertStringToBoolean( "" ) ); assertTrue( ValueMetaBase.convertStringToBoolean( "Y" ) ); assertTrue( ValueMetaBase.convertStringToBoolean( "y" ) ); assertTrue( ValueMetaBase.convertSt...
ValueMetaBase implements ValueMetaInterface { @Override public Object convertDataFromString( String pol, ValueMetaInterface convertMeta, String nullIf, String ifNull, int trim_type ) throws KettleValueException { if ( convertMeta == null ) { throw new KettleValueException( "API coding error: convertMeta input parameter...
@Test public void testConvertDataFromStringToString() throws KettleValueException { ValueMetaBase inValueMetaString = new ValueMetaString(); ValueMetaBase outValueMetaString = new ValueMetaString(); String inputValueEmptyString = StringUtils.EMPTY; String inputValueNullString = null; String nullIf = null; String ifNull...
ValueMetaBase implements ValueMetaInterface { @Override public BigDecimal getBigNumber( Object object ) throws KettleValueException { try { if ( isNull( object ) ) { return null; } switch ( type ) { case TYPE_BIGNUMBER: switch ( storageType ) { case STORAGE_TYPE_NORMAL: return (BigDecimal) object; case STORAGE_TYPE_BIN...
@Test( expected = KettleValueException.class ) public void testGetBigDecimalThrowsKettleValueException() throws KettleValueException { ValueMetaBase valueMeta = new ValueMetaBigNumber(); valueMeta.getBigNumber( "1234567890" ); }
ValueMetaBase implements ValueMetaInterface { @Override public Long getInteger( Object object ) throws KettleValueException { try { if ( isNull( object ) ) { return null; } switch ( type ) { case TYPE_INTEGER: switch ( storageType ) { case STORAGE_TYPE_NORMAL: return (Long) object; case STORAGE_TYPE_BINARY_STRING: retu...
@Test( expected = KettleValueException.class ) public void testGetIntegerThrowsKettleValueException() throws KettleValueException { ValueMetaBase valueMeta = new ValueMetaInteger(); valueMeta.getInteger( "1234567890" ); }
ValueMetaBase implements ValueMetaInterface { @Override public Double getNumber( Object object ) throws KettleValueException { try { if ( isNull( object ) ) { return null; } switch ( type ) { case TYPE_NUMBER: switch ( storageType ) { case STORAGE_TYPE_NORMAL: return (Double) object; case STORAGE_TYPE_BINARY_STRING: re...
@Test( expected = KettleValueException.class ) public void testGetNumberThrowsKettleValueException() throws KettleValueException { ValueMetaBase valueMeta = new ValueMetaNumber(); valueMeta.getNumber( "1234567890" ); }
ValueMetaBase implements ValueMetaInterface { @Override public boolean isNumeric() { return isInteger() || isNumber() || isBigNumber(); } ValueMetaBase(); ValueMetaBase( String name ); ValueMetaBase( String name, int type ); ValueMetaBase( String name, int type, int length, int precision ); ValueMetaBase( Node node...
@Test public void testIsNumeric() { int[] numTypes = { ValueMetaInterface.TYPE_INTEGER, ValueMetaInterface.TYPE_NUMBER, ValueMetaInterface.TYPE_BIGNUMBER }; for ( int type : numTypes ) { assertTrue( Integer.toString( type ), ValueMetaBase.isNumeric( type ) ); } int[] notNumTypes = { ValueMetaInterface.TYPE_INET, ValueM...
ValueMetaBase implements ValueMetaInterface { public static final String[] getAllTypes() { return ValueMetaFactory.getAllValueMetaNames(); } ValueMetaBase(); ValueMetaBase( String name ); ValueMetaBase( String name, int type ); ValueMetaBase( String name, int type, int length, int precision ); ValueMetaBase( Node n...
@Test public void testGetAllTypes() { Assert.assertArrayEquals( ValueMetaBase.getAllTypes(), ValueMetaFactory.getAllValueMetaNames() ); }
ValueMetaBase implements ValueMetaInterface { public static final int getTrimTypeByCode( String tt ) { if ( tt == null ) { return 0; } for ( int i = 0; i < trimTypeCode.length; i++ ) { if ( trimTypeCode[i].equalsIgnoreCase( tt ) ) { return i; } } return 0; } ValueMetaBase(); ValueMetaBase( String name ); ValueMetaBas...
@Test public void testGetTrimTypeByCode() { assertEquals( ValueMetaBase.getTrimTypeByCode( "none" ), ValueMetaInterface.TRIM_TYPE_NONE ); assertEquals( ValueMetaBase.getTrimTypeByCode( "left" ), ValueMetaInterface.TRIM_TYPE_LEFT ); assertEquals( ValueMetaBase.getTrimTypeByCode( "right" ), ValueMetaInterface.TRIM_TYPE_R...
ValueMetaBase implements ValueMetaInterface { public static final String getTrimTypeCode( int i ) { if ( i < 0 || i >= trimTypeCode.length ) { return trimTypeCode[0]; } return trimTypeCode[i]; } ValueMetaBase(); ValueMetaBase( String name ); ValueMetaBase( String name, int type ); ValueMetaBase( String name, int typ...
@Test public void testGetTrimTypeCode() { assertEquals( ValueMetaBase.getTrimTypeCode( ValueMetaInterface.TRIM_TYPE_NONE ), "none" ); assertEquals( ValueMetaBase.getTrimTypeCode( ValueMetaInterface.TRIM_TYPE_LEFT ), "left" ); assertEquals( ValueMetaBase.getTrimTypeCode( ValueMetaInterface.TRIM_TYPE_RIGHT ), "right" ); ...
ValueMetaBase implements ValueMetaInterface { public static final int getTrimTypeByDesc( String tt ) { if ( tt == null ) { return 0; } for ( int i = 0; i < trimTypeDesc.length; i++ ) { if ( trimTypeDesc[i].equalsIgnoreCase( tt ) ) { return i; } } return getTrimTypeByCode( tt ); } ValueMetaBase(); ValueMetaBase( String...
@Test public void testGetTrimTypeByDesc() { assertEquals( ValueMetaBase.getTrimTypeByDesc( BaseMessages.getString( PKG, "ValueMeta.TrimType.None" ) ), ValueMetaInterface.TRIM_TYPE_NONE ); assertEquals( ValueMetaBase.getTrimTypeByDesc( BaseMessages.getString( PKG, "ValueMeta.TrimType.Left" ) ), ValueMetaInterface.TRIM_T...
ValueMetaBase implements ValueMetaInterface { public static final String getTrimTypeDesc( int i ) { if ( i < 0 || i >= trimTypeDesc.length ) { return trimTypeDesc[0]; } return trimTypeDesc[i]; } ValueMetaBase(); ValueMetaBase( String name ); ValueMetaBase( String name, int type ); ValueMetaBase( String name, int typ...
@Test public void testGetTrimTypeDesc() { assertEquals( ValueMetaBase.getTrimTypeDesc( ValueMetaInterface.TRIM_TYPE_NONE ), BaseMessages.getString( PKG, "ValueMeta.TrimType.None" ) ); assertEquals( ValueMetaBase.getTrimTypeDesc( ValueMetaInterface.TRIM_TYPE_LEFT ), BaseMessages.getString( PKG, "ValueMeta.TrimType.Left"...
ValueMetaBase implements ValueMetaInterface { @Override public int compare( Object data1, Object data2 ) throws KettleValueException { boolean n1 = isNull( data1 ); boolean n2 = isNull( data2 ); if ( n1 && !n2 ) { if ( isSortedDescending() ) { return 1; } else { return -1; } } if ( !n1 && n2 ) { if ( isSortedDescending...
@Test public void testCompareIntegerToDouble() throws KettleValueException { ValueMetaBase intMeta = new ValueMetaBase( "int", ValueMetaInterface.TYPE_INTEGER ); Long int1 = new Long( 2L ); ValueMetaBase numberMeta = new ValueMetaBase( "number", ValueMetaInterface.TYPE_NUMBER ); Double double2 = new Double( 1.5 ); asse...
ValueMetaBase implements ValueMetaInterface { @Override public void setPreparedStatementValue( DatabaseMeta databaseMeta, PreparedStatement preparedStatement, int index, Object data ) throws KettleDatabaseException { try { switch ( getType() ) { case ValueMetaInterface.TYPE_NUMBER: if ( !isNull( data ) ) { double num =...
@Test public void testSetPreparedStatementStringValueDontLogTruncated() throws KettleDatabaseException { ValueMetaBase valueMetaString = new ValueMetaBase( "LOG_FIELD", ValueMetaInterface.TYPE_STRING, LOG_FIELD.length(), 0 ); DatabaseMeta databaseMeta = Mockito.mock( DatabaseMeta.class ); PreparedStatement preparedStat...
ValueMetaBase implements ValueMetaInterface { @Override public Class<?> getNativeDataTypeClass() throws KettleValueException { throw new KettleValueException( getTypeDesc() + " does not implement this method" ); } ValueMetaBase(); ValueMetaBase( String name ); ValueMetaBase( String name, int type ); ValueMetaBase( S...
@Test public void testGetNativeDataTypeClass() { ValueMetaInterface base = new ValueMetaBase(); Class<?> clazz = null; try { clazz = base.getNativeDataTypeClass(); Assert.fail(); } catch ( KettleValueException expected ) { Assert.assertNull( clazz ); } }
ValueMetaBase implements ValueMetaInterface { @Override public Object convertDataUsingConversionMetaData( Object data ) throws KettleValueException { if ( conversionMetadata == null ) { throw new KettleValueException( "API coding error: please specify the conversion metadata before attempting to convert value " + name ...
@Test public void testConvertDataUsingConversionMetaData() throws KettleValueException, ParseException { ValueMetaString base = new ValueMetaString(); double DELTA = 1e-15; base.setConversionMetadata( new ValueMetaString( "STRING" ) ); Object defaultStringData = "STRING DATA"; String convertedStringData = (String) base...
ValueMetaBase implements ValueMetaInterface { @Override public String getCompatibleString( Object object ) throws KettleValueException { try { String string; switch ( type ) { case TYPE_DATE: switch ( storageType ) { case STORAGE_TYPE_NORMAL: string = convertDateToCompatibleString( (Date) object ); break; case STORAGE_...
@Test public void testGetCompatibleString() throws KettleValueException { ValueMetaInteger valueMetaInteger = new ValueMetaInteger( "INTEGER" ); valueMetaInteger.setType( 5 ); valueMetaInteger.setStorageType( 1 ); assertEquals( "2", valueMetaInteger.getCompatibleString( new Long( 2 ) ) ); }
ValueMetaBase implements ValueMetaInterface { protected Boolean convertBigNumberToBoolean( BigDecimal number ) { if ( number == null ) { return null; } return Boolean.valueOf( number.signum() != 0 ); } ValueMetaBase(); ValueMetaBase( String name ); ValueMetaBase( String name, int type ); ValueMetaBase( String name, ...
@Test public void testConvertBigNumberToBoolean() { ValueMetaBase vmb = new ValueMetaBase(); System.out.println( vmb.convertBigNumberToBoolean( new BigDecimal( "-234" ) ) ); System.out.println( vmb.convertBigNumberToBoolean( new BigDecimal( "234" ) ) ); System.out.println( vmb.convertBigNumberToBoolean( new BigDecimal(...
ValueMetaString extends ValueMetaBase implements ValueMetaInterface { @Override public Object getNativeDataType( Object object ) throws KettleValueException { return getString( object ); } ValueMetaString(); ValueMetaString( String name ); ValueMetaString( String name, int length, int precision ); @Override Object ge...
@Test public void testGetNativeData_emptyIsNotNull() throws Exception { meta.setNullsAndEmptyAreDifferent( true ); assertEquals( BASE_VALUE, meta.getNativeDataType( BASE_VALUE ) ); assertEquals( TEST_VALUE, meta.getNativeDataType( TEST_VALUE ) ); assertEquals( null, meta.getNativeDataType( null ) ); assertEquals( "1", ...
SimpleTimestampFormat extends SimpleDateFormat { @Override public StringBuffer format( Date timestamp, StringBuffer toAppendTo, FieldPosition pos ) { if ( compatibleToSuperPattern ) { return super.format( timestamp, toAppendTo, pos ); } StringBuffer dateBuffer; String nan; if ( timestamp instanceof Timestamp ) { Timest...
@Test public void testFormat() throws Exception { for ( Locale locale : locales ) { Locale.setDefault( Locale.Category.FORMAT, locale ); tdb = ResourceBundle.getBundle( "org/pentaho/di/core/row/value/timestamp/messages/testdates", locale ); checkFormat( "KETTLE.LONG" ); checkFormat( "LOCALE.DATE", new SimpleTimestampFo...
SimpleTimestampFormat extends SimpleDateFormat { @Override public Date parse( String text, ParsePosition pos ) { String timestampFormatDate; Date tempDate; if ( compatibleToSuperPattern ) { tempDate = super.parse( text, pos ); return new Timestamp( tempDate.getTime() ); } StringBuilder dateText = new StringBuilder( tex...
@Test public void testParse() throws Exception { for ( Locale locale : locales ) { Locale.setDefault( Locale.Category.FORMAT, locale ); tdb = ResourceBundle.getBundle( "org/pentaho/di/core/row/value/timestamp/messages/testdates", locale ); checkParseKettle(); checkParseKettleLong(); checkParseDbDefault(); checkParseLoc...
SimpleTimestampFormat extends SimpleDateFormat { @Override public String toPattern() { return originalPattern; } SimpleTimestampFormat( String pattern ); SimpleTimestampFormat( String pattern, Locale locale ); SimpleTimestampFormat( String pattern, DateFormatSymbols formatSymbols ); @Override void setDateFormatSymbol...
@Test public void testToPattern() throws Exception { for ( Locale locale : locales ) { Locale.setDefault( Locale.Category.FORMAT, locale ); tdb = ResourceBundle.getBundle( "org/pentaho/di/core/row/value/timestamp/messages/testdates", locale ); String patternExample = tdb.getString( "PATTERN.KETTLE" ); SimpleTimestampFo...
SimpleTimestampFormat extends SimpleDateFormat { @Override public String toLocalizedPattern() { if ( compatibleToSuperPattern ) { return super.toLocalizedPattern(); } else { StringBuffer pattern = new StringBuffer( super.toLocalizedPattern() ); int placeholderPosition = replaceHolder( pattern, true ); for ( int i = pla...
@Test public void testToLocalizedPattern() throws Exception { for ( Locale locale : locales ) { Locale.setDefault( Locale.Category.FORMAT, locale ); tdb = ResourceBundle.getBundle( "org/pentaho/di/core/row/value/timestamp/messages/testdates", locale ); SimpleTimestampFormat stf = new SimpleTimestampFormat( new SimpleDa...
SimpleTimestampFormat extends SimpleDateFormat { @Override public void applyPattern( String pattern ) { DateFormatSymbols formatSymbols = super.getDateFormatSymbols(); init( pattern, formatSymbols, false ); } SimpleTimestampFormat( String pattern ); SimpleTimestampFormat( String pattern, Locale locale ); SimpleTimest...
@Test public void testApplyPattern() throws Exception { for ( Locale locale : locales ) { Locale.setDefault( Locale.Category.FORMAT, locale ); tdb = ResourceBundle.getBundle( "org/pentaho/di/core/row/value/timestamp/messages/testdates", locale ); String patternExample = tdb.getString( "PATTERN.KETTLE" ); SimpleTimestam...
SimpleTimestampFormat extends SimpleDateFormat { @Override public void applyLocalizedPattern( String pattern ) { DateFormatSymbols formatSymbols = super.getDateFormatSymbols(); init( pattern, formatSymbols, true ); } SimpleTimestampFormat( String pattern ); SimpleTimestampFormat( String pattern, Locale locale ); Simp...
@Test public void testApplyLocalizedPattern() throws Exception { Locale.setDefault( Locale.Category.FORMAT, Locale.US ); SimpleTimestampFormat stf = new SimpleTimestampFormat( new SimpleDateFormat().toPattern() ); for ( Locale locale : locales ) { Locale.setDefault( Locale.Category.FORMAT, locale ); tdb = ResourceBundl...
ValueMetaAndData { public boolean loadXML( Node valnode ) { valueMeta = null; try { String valname = XMLHandler.getTagValue( valnode, "name" ); int valtype = ValueMetaBase.getType( XMLHandler.getTagValue( valnode, "type" ) ); String text = XMLHandler.getTagValue( valnode, "text" ); boolean isnull = "Y".equalsIgnoreCase...
@Test @PrepareForTest( { EnvUtil.class } ) public void testLoadXML() throws KettleValueException, KettlePluginException, ParseException { PowerMockito.mockStatic( EnvUtil.class ); Mockito.when( EnvUtil.getSystemProperty( Const.KETTLE_DEFAULT_DATE_FORMAT ) ).thenReturn( "yyyy-MM-dd HH:mm:ss.SSS" ); ValueMetaAndData valu...
WriterOutputStream extends OutputStream { @Override public void write( int b ) throws IOException { write( new byte[] { (byte) b, } ); } WriterOutputStream( Writer writer ); WriterOutputStream( Writer writer, String encoding ); @Override void write( int b ); @Override void write( byte[] b, int off, int len ); @Overrid...
@Test public void testWrite() throws IOException { WriterOutputStream stream = new WriterOutputStream( writer ); stream.write( 68 ); stream.write( "value".getBytes(), 1, 3 ); stream.write( "value".getBytes() ); stream.flush(); stream.close(); verify( writer ).append( new String( new byte[] { (byte) 68 } ) ); verify( wr...
PluginFolder implements PluginFolderInterface { @Override public FileObject[] findJarFiles() throws KettleFileException { return findJarFiles( searchLibDir ); } PluginFolder( String folder, boolean pluginXmlFolder, boolean pluginAnnotationsFolder ); PluginFolder( String folder, boolean pluginXmlFolder, boolean pluginA...
@Test public void testFindJarFiles_DirWithJarInNameNotAdded() throws IOException, KettleFileException { Files.createDirectories( PATH_TO_DIR_WITH_JAR_IN_NAME ); FileObject[] findJarFiles = plFolder.findJarFiles(); assertNotNull( findJarFiles ); assertEquals( 0, findJarFiles.length ); } @Test public void testFindJarFile...
TransMeta extends AbstractMeta implements XMLInterface, Comparator<TransMeta>, Comparable<TransMeta>, Cloneable, ResourceExportInterface, RepositoryElementInterface, LoggingObjectInterface { public Point getMinimum() { int minx = Integer.MAX_VALUE, miny = Integer.MAX_VALUE; for ( int i = 0; i < nrSteps(); i++ ) { S...
@Test public void testGetMinimum() { final Point minimalCanvasPoint = new Point( 0, 0 ); final Point stepPoint = new Point( 500, 500 ); Point point = transMeta.getMinimum(); assertEquals( minimalCanvasPoint.x, point.x ); assertEquals( minimalCanvasPoint.y, point.y ); StepMeta stepMeta = mock( StepMeta.class ); when( st...
NamedParamsDefault implements NamedParams { @Override public void addParameterDefinition( String key, String defValue, String description ) throws DuplicateParamException { if ( params.get( key ) == null ) { OneNamedParam oneParam = new OneNamedParam(); oneParam.key = key; oneParam.defaultValue = defValue; oneParam.des...
@Test( expected = DuplicateParamException.class ) public void testAddParameterDefinitionWithException() throws DuplicateParamException { namedParams.addParameterDefinition( "key", "value", "description" ); namedParams.addParameterDefinition( "key", "value", "description" ); }
NamedParamsDefault implements NamedParams { @Override public void copyParametersFrom( NamedParams aParam ) { if ( params != null && aParam != null ) { params.clear(); String[] keys = aParam.listParameters(); for ( int idx = 0; idx < keys.length; idx++ ) { String desc; try { desc = aParam.getParameterDescription( keys[i...
@Test public void testCopyParametersFromNullChecks() throws Exception { namedParams.copyParametersFrom( null ); NamedParams namedParams2 = new NamedParamsDefault(); ( (NamedParamsDefault) namedParams ).params = null; namedParams.copyParametersFrom( namedParams2 ); } @Test public void testCopyParametersFrom() throws Exc...
PDIClassLoader extends URLClassLoader { @Override protected synchronized Class<?> loadClass( String name, boolean resolve ) throws ClassNotFoundException { try { return super.loadClass( name, resolve ); } catch ( NoClassDefFoundError e ) { return super.findClass( name ); } } PDIClassLoader( URL[] url, ClassLoader paren...
@Test public void testLoadClass() throws Exception { final String classToLoad = "dummy.Class"; final AtomicBoolean loadClassCalled = new AtomicBoolean(); ClassLoader parent = new ClassLoader() { @Override protected Class<?> loadClass( String name, boolean resolve ) throws ClassNotFoundException { if ( name.equals( clas...
LongHashIndex { public void put( long key, Long value ) throws KettleValueException { int hashCode = generateHashCode( key ); int indexPointer = indexFor( hashCode, index.length ); LongHashIndexEntry check = index[indexPointer]; LongHashIndexEntry previousCheck = null; while ( check != null ) { if ( check.hashCode == h...
@Test( timeout = 2000 ) public void testNoEndlessLoop() throws KettleValueException { long[] inputData = { 3034, 2085, 1912, 9367, 8442, 783, 2839, 8610, 5152, 7388, 7511, 1251, 3043, 3889, 9543, 9353, 2241, 5416, 2127, 3513, 2171, 8633, 5594, 7228, 2225, 581, 6524, 7171, 5928, 5710, 804, 9535, 3334, 3383, 3113, 248, 4...
LongHashIndex { public Long get( long key ) throws KettleValueException { int hashCode = generateHashCode( key ); int indexPointer = indexFor( hashCode, index.length ); LongHashIndexEntry check = index[indexPointer]; while ( check != null ) { if ( check.hashCode == hashCode && check.equalsKey( key ) ) { return check.va...
@Test public void testGet() throws KettleValueException { LongHashIndex index = new LongHashIndex(); index.put( 1L, 1L ); assertThat( "Element has uncorrect value.", index.get( 1L ), equalTo( 1L ) ); }
LongHashIndex { public boolean isEmpty() { return size == 0; } LongHashIndex( int size ); LongHashIndex(); int getSize(); boolean isEmpty(); Long get( long key ); void put( long key, Long value ); static int generateHashCode( Long key ); static int indexFor( int hash, int length ); }
@Test public void testIsEmpty() throws KettleValueException { LongHashIndex index = new LongHashIndex(); assertThat( "Empty index should return true.", index.isEmpty(), is( true ) ); index.put( 1L, 1L ); assertThat( "Not empty index should return false.", index.isEmpty(), is( false ) ); } @Test public void testIsEmpty(...
ByteArrayHashIndex { public int getSize() { return size; } ByteArrayHashIndex( RowMetaInterface keyRowMeta, int size ); ByteArrayHashIndex( RowMetaInterface keyRowMeta ); int getSize(); boolean isEmpty(); byte[] get( byte[] key ); void put( byte[] key, byte[] value ); static int generateHashCode( byte[] key, RowMetaIn...
@Test public void testArraySizeConstructor() { ByteArrayHashIndex obj = new ByteArrayHashIndex( new RowMeta(), 1 ); assertEquals( 1, obj.getSize() ); obj = new ByteArrayHashIndex( new RowMeta(), 2 ); assertEquals( 2, obj.getSize() ); obj = new ByteArrayHashIndex( new RowMeta(), 3 ); assertEquals( 4, obj.getSize() ); ob...
Variables implements VariableSpace { @Override public void initializeVariablesFrom( VariableSpace parent ) { this.parent = parent; Set<String> systemPropertiesNames = System.getProperties().stringPropertyNames(); for ( String key : systemPropertiesNames ) { getProperties().put( key, System.getProperties().getProperty( ...
@Test public void testinItializeVariablesFrom() { final Variables variablesMock = mock( Variables.class ); doCallRealMethod().when( variablesMock ).initializeVariablesFrom( any( VariableSpace.class ) ); @SuppressWarnings( "unchecked" ) final Map<String, String> propertiesMock = mock( Map.class ); when( variablesMock.ge...
Variables implements VariableSpace { @Override public String fieldSubstitute( String aString, RowMetaInterface rowMeta, Object[] rowData ) throws KettleValueException { if ( aString == null || aString.length() == 0 ) { return aString; } return StringUtil.substituteField( aString, rowMeta, rowData ); } Variables(); @Ove...
@Test public void testFieldSubstitution() throws KettleValueException { Object[] rowData = new Object[]{ "DataOne", "DataTwo" }; RowMeta rm = new RowMeta(); rm.addValueMeta( new ValueMetaString( "FieldOne" ) ); rm.addValueMeta( new ValueMetaString( "FieldTwo" ) ); Variables vars = new Variables(); assertNull( vars.fiel...
TransMeta extends AbstractMeta implements XMLInterface, Comparator<TransMeta>, Comparable<TransMeta>, Cloneable, ResourceExportInterface, RepositoryElementInterface, LoggingObjectInterface { @Override public void clearChanged() { changed_steps = false; changed_hops = false; for ( int i = 0; i < nrSteps(); i++ ) { g...
@Test public void testContentChangeListener() throws Exception { ContentChangedListener listener = mock( ContentChangedListener.class ); transMeta.addContentChangedListener( listener ); transMeta.setChanged(); transMeta.setChanged( true ); verify( listener, times( 2 ) ).contentChanged( same( transMeta ) ); transMeta.cl...
DataHandler extends AbstractXulEventHandler { public void setDeckChildIndex() { getControls(); int originalSelection = ( dialogDeck == null ? -1 : dialogDeck.getSelectedIndex() ); boolean passed = true; if ( originalSelection == 3 ) { passed = checkPoolingParameters(); } if ( passed ) { int selected = deckOptionsBox.ge...
@Test public void testSetDeckChildIndex() throws Exception { }
Variables implements VariableSpace { @Override public String environmentSubstitute( String aString ) { if ( aString == null || aString.length() == 0 ) { return aString; } return StringUtil.environmentSubstitute( aString, properties ); } Variables(); @Override void copyVariablesFrom( VariableSpace space ); @Override Var...
@Test public void testEnvironmentSubstitute() { Variables vars = new Variables(); vars.setVariable( "VarOne", "DataOne" ); vars.setVariable( "VarTwo", "DataTwo" ); assertNull( vars.environmentSubstitute( (String) null ) ); assertEquals( "", vars.environmentSubstitute( "" ) ); assertEquals( "DataTwo", vars.environmentSu...
LifecycleException extends Exception { public boolean isSevere() { return severe; } LifecycleException( boolean severe ); LifecycleException( String message, boolean severe ); LifecycleException( Throwable cause, boolean severe ); LifecycleException( String message, Throwable cause, boolean severe ); boolean isSever...
@Test public void testIsSevere() throws Exception { assertTrue( exception.isSevere() ); } @Test public void testThrowableMessageCtor() { Throwable t = mock( Throwable.class ); exception = new LifecycleException( "message", t, true ); assertEquals( t, exception.getCause() ); assertEquals( "message", exception.getMessage...
LifeEventInfo { public State getState() { return state; } void setHint( Hint hint ); String getMessage(); void setMessage( String message ); boolean hasHint( Hint h ); State getState(); void setState( State state ); String getName(); void setName( String name ); }
@Test public void testGetState() throws Exception { assertNull( info.getState() ); info.setState( LifeEventInfo.State.FAIL ); assertEquals( LifeEventInfo.State.FAIL, info.getState() ); }
LifeEventInfo { public String getName() { return name; } void setHint( Hint hint ); String getMessage(); void setMessage( String message ); boolean hasHint( Hint h ); State getState(); void setState( State state ); String getName(); void setName( String name ); }
@Test public void testGetName() throws Exception { assertNull( info.getName() ); info.setName( "name" ); assertEquals( "name", info.getName() ); }
ResultFile implements Cloneable { public RowMetaAndData getRow() { RowMetaAndData row = new RowMetaAndData(); row.addValue( new ValueMetaString( "type" ), getTypeDesc() ); row.addValue( new ValueMetaString( "filename" ), file.getName().getBaseName() ); row.addValue( new ValueMetaString( "path" ), file.getName().getURI(...
@Test public void testGetRow() throws KettleFileException, FileSystemException { File tempDir = new File( new TemporaryFolder().toString() ); FileObject tempFile = KettleVFS.createTempFile( "prefix", "suffix", tempDir.toString() ); Date timeBeforeFile = Calendar.getInstance().getTime(); ResultFile resultFile = new Resu...
SlaveConnectionManager { public static SlaveConnectionManager getInstance() { if ( slaveConnectionManager == null ) { slaveConnectionManager = new SlaveConnectionManager(); } return slaveConnectionManager; } private SlaveConnectionManager(); static SlaveConnectionManager getInstance(); HttpClient createHttpClient(); H...
@Test public void shouldOverrideDefaultSSLContextByDefault() throws Exception { System.clearProperty( "javax.net.ssl.keyStore" ); SlaveConnectionManager instance = SlaveConnectionManager.getInstance(); assertNotEquals( defaultContext, SSLContext.getDefault() ); } @Test public void shouldNotOverrideDefaultSSLContextIfKe...
HttpUtil { public static String decodeBase64ZippedString( String loggingString64 ) throws IOException { if ( loggingString64 == null || loggingString64.isEmpty() ) { return ""; } StringWriter writer = new StringWriter(); byte[] bytes64 = Base64.decodeBase64( loggingString64.getBytes() ); ByteArrayInputStream zip = new ...
@Test public final void testDecodeBase64ZippedString() throws IOException, NoSuchAlgorithmException { String enc64 = this.canonicalBase64Encode( STANDART ); String decoded = HttpUtil.decodeBase64ZippedString( enc64 ); Assert.assertEquals( "Strings are the same after transformation", STANDART, decoded ); }
HttpUtil { public static String constructUrl( VariableSpace space, String hostname, String port, String webAppName, String serviceAndArguments ) throws UnsupportedEncodingException { return constructUrl( space, hostname, port, webAppName, serviceAndArguments, false ); } static String constructUrl( VariableSpace space,...
@Test public void testConstructUrl() throws Exception { Variables variables = new Variables(); String expected = "hostname:1234/webAppName?param=value"; Assert.assertEquals( "http: HttpUtil.constructUrl( variables, "hostname", String.valueOf( 1234 ), "webAppName", "?param=value" ) ); Assert.assertEquals( "http: HttpUti...
TransMeta extends AbstractMeta implements XMLInterface, Comparator<TransMeta>, Comparable<TransMeta>, Cloneable, ResourceExportInterface, RepositoryElementInterface, LoggingObjectInterface { @Override public int compare( TransMeta t1, TransMeta t2 ) { return super.compare( t1, t2 ); } TransMeta(); TransMeta( Varia...
@Test public void testCompare() throws Exception { TransMeta transMeta = new TransMeta( "aFile", "aName" ); TransMeta transMeta2 = new TransMeta( "aFile", "aName" ); assertEquals( 0, transMeta.compare( transMeta, transMeta2 ) ); transMeta2.setVariable( "myVariable", "myValue" ); assertEquals( 0, transMeta.compare( tran...
TransMeta extends AbstractMeta implements XMLInterface, Comparator<TransMeta>, Comparable<TransMeta>, Cloneable, ResourceExportInterface, RepositoryElementInterface, LoggingObjectInterface { @Override public boolean equals( Object obj ) { if ( !( obj instanceof TransMeta ) ) { return false; } return compare( this, ...
@Test public void testEquals() throws Exception { TransMeta transMeta = new TransMeta( "1", "2" ); assertFalse( transMeta.equals( "somethingelse" ) ); assertTrue( transMeta.equals( new TransMeta( "1", "2" ) ) ); }
TransMeta extends AbstractMeta implements XMLInterface, Comparator<TransMeta>, Comparable<TransMeta>, Cloneable, ResourceExportInterface, RepositoryElementInterface, LoggingObjectInterface { public RowMetaInterface getPrevInfoFields( String stepname ) throws KettleStepException { return getPrevInfoFields( findStep(...
@Test public void testGetPrevInfoFields() throws KettleStepException { DataGridMeta dgm1 = new DataGridMeta(); dgm1.setFieldName( new String[]{ "id", "colA" } ); dgm1.allocate( 2 ); dgm1.setFieldType( new String[]{ ValueMetaFactory.getValueMetaName( ValueMetaInterface.TYPE_INTEGER ), ValueMetaFactory.getValueMetaName( ...
TransMeta extends AbstractMeta implements XMLInterface, Comparator<TransMeta>, Comparable<TransMeta>, Cloneable, ResourceExportInterface, RepositoryElementInterface, LoggingObjectInterface { public void addStep( StepMeta stepMeta ) { steps.add( stepMeta ); stepMeta.setParentTransMeta( this ); StepMetaInterface ifac...
@Test public void testAddStepWithChangeListenerInterface() { StepMeta stepMeta = mock( StepMeta.class ); StepMetaChangeListenerInterfaceMock metaInterface = mock( StepMetaChangeListenerInterfaceMock.class ); when( stepMeta.getStepMetaInterface() ).thenReturn( metaInterface ); assertEquals( 0, transMeta.steps.size() ); ...