use of org.pentaho.di.core.exception.KettlePluginException in project pentaho-kettle by pentaho.
the class ValueMetaFactoryTest method testCreateValueMeta.
@Test
public void testCreateValueMeta() throws KettlePluginException {
ValueMetaInterface testObject;
try {
testObject = ValueMetaFactory.createValueMeta(Integer.MIN_VALUE);
fail();
} catch (KettlePluginException expected) {
// Do nothing, Integer.MIN_VALUE is not a valid option
}
try {
testObject = ValueMetaFactory.createValueMeta(null, Integer.MIN_VALUE);
fail();
} catch (KettlePluginException expected) {
// Do nothing, Integer.MIN_VALUE is not a valid option
}
try {
testObject = ValueMetaFactory.createValueMeta(null, Integer.MIN_VALUE, 10, 10);
fail();
} catch (KettlePluginException expected) {
// Do nothing, Integer.MIN_VALUE is not a valid option
}
testObject = ValueMetaFactory.createValueMeta(ValueMetaInterface.TYPE_NONE);
assertTrue(testObject instanceof ValueMetaNone);
assertEquals(null, testObject.getName());
assertEquals(-1, testObject.getLength());
assertEquals(-1, testObject.getPrecision());
testObject = ValueMetaFactory.createValueMeta("testNone", ValueMetaInterface.TYPE_NONE);
assertTrue(testObject instanceof ValueMetaNone);
assertEquals("testNone", testObject.getName());
assertEquals(-1, testObject.getLength());
assertEquals(-1, testObject.getPrecision());
testObject = ValueMetaFactory.createValueMeta("testNone", ValueMetaInterface.TYPE_NONE, 10, 20);
assertTrue(testObject instanceof ValueMetaNone);
assertEquals("testNone", testObject.getName());
assertEquals(10, testObject.getLength());
assertEquals(20, testObject.getPrecision());
testObject = ValueMetaFactory.createValueMeta(ValueMetaInterface.TYPE_NUMBER);
assertTrue(testObject instanceof ValueMetaNumber);
assertEquals(null, testObject.getName());
assertEquals(-1, testObject.getLength());
assertEquals(-1, testObject.getPrecision());
testObject = ValueMetaFactory.createValueMeta("testNumber", ValueMetaInterface.TYPE_NUMBER);
assertTrue(testObject instanceof ValueMetaNumber);
assertEquals("testNumber", testObject.getName());
assertEquals(-1, testObject.getLength());
assertEquals(-1, testObject.getPrecision());
testObject = ValueMetaFactory.createValueMeta("testNumber", ValueMetaInterface.TYPE_NUMBER, 10, 20);
assertTrue(testObject instanceof ValueMetaNumber);
assertEquals("testNumber", testObject.getName());
assertEquals(10, testObject.getLength());
assertEquals(20, testObject.getPrecision());
testObject = ValueMetaFactory.createValueMeta(ValueMetaInterface.TYPE_STRING);
assertTrue(testObject instanceof ValueMetaString);
assertEquals(null, testObject.getName());
assertEquals(-1, testObject.getLength());
assertEquals(-1, testObject.getPrecision());
testObject = ValueMetaFactory.createValueMeta("testString", ValueMetaInterface.TYPE_STRING);
assertTrue(testObject instanceof ValueMetaString);
assertEquals("testString", testObject.getName());
assertEquals(-1, testObject.getLength());
assertEquals(-1, testObject.getPrecision());
testObject = ValueMetaFactory.createValueMeta("testString", ValueMetaInterface.TYPE_STRING, 1000, 50);
assertTrue(testObject instanceof ValueMetaString);
assertEquals("testString", testObject.getName());
assertEquals(1000, testObject.getLength());
// Special case for String
assertEquals(-1, testObject.getPrecision());
testObject = ValueMetaFactory.createValueMeta(ValueMetaInterface.TYPE_DATE);
assertTrue(testObject instanceof ValueMetaDate);
assertEquals(null, testObject.getName());
assertEquals(-1, testObject.getLength());
assertEquals(-1, testObject.getPrecision());
testObject = ValueMetaFactory.createValueMeta("testDate", ValueMetaInterface.TYPE_DATE);
assertTrue(testObject instanceof ValueMetaDate);
assertEquals("testDate", testObject.getName());
assertEquals(-1, testObject.getLength());
assertEquals(-1, testObject.getPrecision());
testObject = ValueMetaFactory.createValueMeta("testDate", ValueMetaInterface.TYPE_DATE, 10, 20);
assertTrue(testObject instanceof ValueMetaDate);
assertEquals("testDate", testObject.getName());
assertEquals(10, testObject.getLength());
assertEquals(20, testObject.getPrecision());
testObject = ValueMetaFactory.createValueMeta(ValueMetaInterface.TYPE_BOOLEAN);
assertTrue(testObject instanceof ValueMetaBoolean);
assertEquals(null, testObject.getName());
assertEquals(-1, testObject.getLength());
assertEquals(-1, testObject.getPrecision());
testObject = ValueMetaFactory.createValueMeta("testBoolean", ValueMetaInterface.TYPE_BOOLEAN);
assertTrue(testObject instanceof ValueMetaBoolean);
assertEquals("testBoolean", testObject.getName());
assertEquals(-1, testObject.getLength());
assertEquals(-1, testObject.getPrecision());
testObject = ValueMetaFactory.createValueMeta("testBoolean", ValueMetaInterface.TYPE_BOOLEAN, 10, 20);
assertTrue(testObject instanceof ValueMetaBoolean);
assertEquals("testBoolean", testObject.getName());
assertEquals(10, testObject.getLength());
assertEquals(-1, testObject.getPrecision());
testObject = ValueMetaFactory.createValueMeta(ValueMetaInterface.TYPE_INTEGER);
assertTrue(testObject instanceof ValueMetaInteger);
assertEquals(null, testObject.getName());
assertEquals(-1, testObject.getLength());
// Special case for Integer
assertEquals(0, testObject.getPrecision());
testObject = ValueMetaFactory.createValueMeta("testInteger", ValueMetaInterface.TYPE_INTEGER);
assertTrue(testObject instanceof ValueMetaInteger);
assertEquals("testInteger", testObject.getName());
assertEquals(-1, testObject.getLength());
// Special case for Integer
assertEquals(0, testObject.getPrecision());
testObject = ValueMetaFactory.createValueMeta("testInteger", ValueMetaInterface.TYPE_INTEGER, 10, 20);
assertTrue(testObject instanceof ValueMetaInteger);
assertEquals("testInteger", testObject.getName());
assertEquals(10, testObject.getLength());
// Special case for Integer
assertEquals(0, testObject.getPrecision());
testObject = ValueMetaFactory.createValueMeta(ValueMetaInterface.TYPE_BIGNUMBER);
assertTrue(testObject instanceof ValueMetaBigNumber);
assertEquals(null, testObject.getName());
assertEquals(-1, testObject.getLength());
assertEquals(-1, testObject.getPrecision());
testObject = ValueMetaFactory.createValueMeta("testBigNumber", ValueMetaInterface.TYPE_BIGNUMBER);
assertTrue(testObject instanceof ValueMetaBigNumber);
assertEquals("testBigNumber", testObject.getName());
assertEquals(-1, testObject.getLength());
assertEquals(-1, testObject.getPrecision());
testObject = ValueMetaFactory.createValueMeta("testBigNumber", ValueMetaInterface.TYPE_BIGNUMBER, 10, 20);
assertTrue(testObject instanceof ValueMetaBigNumber);
assertEquals("testBigNumber", testObject.getName());
assertEquals(10, testObject.getLength());
assertEquals(20, testObject.getPrecision());
testObject = ValueMetaFactory.createValueMeta(ValueMetaInterface.TYPE_SERIALIZABLE);
assertTrue(testObject instanceof ValueMetaSerializable);
assertEquals(null, testObject.getName());
assertEquals(-1, testObject.getLength());
assertEquals(-1, testObject.getPrecision());
testObject = ValueMetaFactory.createValueMeta("testSerializable", ValueMetaInterface.TYPE_SERIALIZABLE);
assertTrue(testObject instanceof ValueMetaSerializable);
assertEquals("testSerializable", testObject.getName());
assertEquals(-1, testObject.getLength());
assertEquals(-1, testObject.getPrecision());
testObject = ValueMetaFactory.createValueMeta("testSerializable", ValueMetaInterface.TYPE_SERIALIZABLE, 10, 20);
assertTrue(testObject instanceof ValueMetaSerializable);
assertEquals("testSerializable", testObject.getName());
assertEquals(10, testObject.getLength());
assertEquals(20, testObject.getPrecision());
testObject = ValueMetaFactory.createValueMeta(ValueMetaInterface.TYPE_BINARY);
assertTrue(testObject instanceof ValueMetaBinary);
assertEquals(null, testObject.getName());
assertEquals(-1, testObject.getLength());
// Special case for Binary
assertEquals(0, testObject.getPrecision());
testObject = ValueMetaFactory.createValueMeta("testBinary", ValueMetaInterface.TYPE_BINARY);
assertTrue(testObject instanceof ValueMetaBinary);
assertEquals("testBinary", testObject.getName());
assertEquals(-1, testObject.getLength());
// Special case for Binary
assertEquals(0, testObject.getPrecision());
testObject = ValueMetaFactory.createValueMeta("testBinary", ValueMetaInterface.TYPE_BINARY, 10, 20);
assertTrue(testObject instanceof ValueMetaBinary);
assertEquals("testBinary", testObject.getName());
assertEquals(10, testObject.getLength());
// Special case for Binary
assertEquals(0, testObject.getPrecision());
testObject = ValueMetaFactory.createValueMeta(ValueMetaInterface.TYPE_TIMESTAMP);
assertTrue(testObject instanceof ValueMetaTimestamp);
assertEquals(null, testObject.getName());
assertEquals(-1, testObject.getLength());
assertEquals(-1, testObject.getPrecision());
testObject = ValueMetaFactory.createValueMeta("testTimestamp", ValueMetaInterface.TYPE_TIMESTAMP);
assertTrue(testObject instanceof ValueMetaTimestamp);
assertEquals("testTimestamp", testObject.getName());
assertEquals(-1, testObject.getLength());
assertEquals(-1, testObject.getPrecision());
testObject = ValueMetaFactory.createValueMeta("testTimestamp", ValueMetaInterface.TYPE_TIMESTAMP, 10, 20);
assertTrue(testObject instanceof ValueMetaTimestamp);
assertEquals("testTimestamp", testObject.getName());
assertEquals(10, testObject.getLength());
assertEquals(20, testObject.getPrecision());
testObject = ValueMetaFactory.createValueMeta(ValueMetaInterface.TYPE_INET);
assertTrue(testObject instanceof ValueMetaInternetAddress);
assertEquals(null, testObject.getName());
assertEquals(-1, testObject.getLength());
assertEquals(-1, testObject.getPrecision());
testObject = ValueMetaFactory.createValueMeta("testInternetAddress", ValueMetaInterface.TYPE_INET);
assertTrue(testObject instanceof ValueMetaInternetAddress);
assertEquals("testInternetAddress", testObject.getName());
assertEquals(-1, testObject.getLength());
assertEquals(-1, testObject.getPrecision());
testObject = ValueMetaFactory.createValueMeta("testInternetAddress", ValueMetaInterface.TYPE_INET, 10, 20);
assertTrue(testObject instanceof ValueMetaInternetAddress);
assertEquals("testInternetAddress", testObject.getName());
assertEquals(10, testObject.getLength());
assertEquals(20, testObject.getPrecision());
}
use of org.pentaho.di.core.exception.KettlePluginException in project pentaho-kettle by pentaho.
the class CartePluginType method registerXmlPlugins.
protected void registerXmlPlugins() throws KettlePluginException {
for (PluginFolderInterface folder : pluginFolders) {
if (folder.isPluginXmlFolder()) {
List<FileObject> pluginXmlFiles = findPluginXmlFiles(folder.getFolder());
for (FileObject file : pluginXmlFiles) {
try {
Document document = XMLHandler.loadXMLFile(file);
Node pluginNode = XMLHandler.getSubNode(document, "plugin");
if (pluginNode != null) {
registerPluginFromXmlResource(pluginNode, KettleVFS.getFilename(file.getParent()), this.getClass(), false, file.getParent().getURL());
}
} catch (Exception e) {
// We want to report this plugin.xml error, perhaps an XML typo or
// something like that...
//
log.logError("Error found while reading step plugin.xml file: " + file.getName().toString(), e);
}
}
}
}
}
use of org.pentaho.di.core.exception.KettlePluginException in project pentaho-kettle by pentaho.
the class RepositoryPluginType method registerXmlPlugins.
protected void registerXmlPlugins() throws KettlePluginException {
for (PluginFolderInterface folder : pluginFolders) {
if (folder.isPluginXmlFolder()) {
List<FileObject> pluginXmlFiles = findPluginXmlFiles(folder.getFolder());
for (FileObject file : pluginXmlFiles) {
try {
Document document = XMLHandler.loadXMLFile(file);
Node pluginNode = XMLHandler.getSubNode(document, "plugin");
registerPluginFromXmlResource(pluginNode, KettleVFS.getFilename(file.getParent()), this.getClass(), false, file.getParent().getURL());
} catch (Exception e) {
// We want to report this plugin.xml error, perhaps an XML typo or something like that...
//
log.logError("Error found while reading repository plugin.xml file: " + file.getName().toString(), e);
}
}
}
}
}
use of org.pentaho.di.core.exception.KettlePluginException in project pentaho-kettle by pentaho.
the class StepPluginType method registerXmlPlugins.
protected void registerXmlPlugins() throws KettlePluginException {
for (PluginFolderInterface folder : pluginFolders) {
if (folder.isPluginXmlFolder()) {
List<FileObject> pluginXmlFiles = findPluginXmlFiles(folder.getFolder());
for (FileObject file : pluginXmlFiles) {
try {
Document document = XMLHandler.loadXMLFile(file);
Node pluginNode = XMLHandler.getSubNode(document, "plugin");
if (pluginNode != null) {
registerPluginFromXmlResource(pluginNode, KettleVFS.getFilename(file.getParent()), this.getClass(), false, file.getParent().getURL());
}
} catch (Exception e) {
// We want to report this plugin.xml error, perhaps an XML typo or something like that...
//
log.logError("Error found while reading step plugin.xml file: " + file.getName().toString(), e);
}
}
}
}
}
use of org.pentaho.di.core.exception.KettlePluginException in project pentaho-kettle by pentaho.
the class LogTablePluginType method registerXmlPlugins.
protected void registerXmlPlugins() throws KettlePluginException {
for (PluginFolderInterface folder : pluginFolders) {
if (folder.isPluginXmlFolder()) {
List<FileObject> pluginXmlFiles = findPluginXmlFiles(folder.getFolder());
for (FileObject file : pluginXmlFiles) {
try {
Document document = XMLHandler.loadXMLFile(file);
Node pluginNode = XMLHandler.getSubNode(document, "plugin");
if (pluginNode != null) {
registerPluginFromXmlResource(pluginNode, KettleVFS.getFilename(file.getParent()), this.getClass(), false, file.getParent().getURL());
}
} catch (Exception e) {
// We want to report this plugin.xml error, perhaps an XML typo or something like that...
//
log.logError("Error found while reading logging plugin.xml file: " + file.getName().toString(), e);
}
}
}
}
}
Aggregations