Skip to content

Commit

Permalink
CheckIn: Add support for BIRT POJO ODA connector.
Browse files Browse the repository at this point in the history
  • Loading branch information
xwu authored and mwu committed Mar 15, 2013
1 parent 9d1d8ab commit eb6ef6f
Show file tree
Hide file tree
Showing 144 changed files with 17,116 additions and 0 deletions.
8 changes: 8 additions & 0 deletions org.eclipse.birt.report.data.oda.pojo.tests/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="output" path="bin"/>
</classpath>
28 changes: 28 additions & 0 deletions org.eclipse.birt.report.data.oda.pojo.tests/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.birt.report.data.oda.pojo.tests</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
13 changes: 13 additions & 0 deletions org.eclipse.birt.report.data.oda.pojo.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Tests Plug-in
Bundle-SymbolicName: org.eclipse.birt.report.data.oda.pojo.tests
Bundle-Version: 4.2.2.qualifier
Bundle-Activator: org.eclipse.birt.report.data.oda.pojo.tests.Activator
Bundle-Vendor: Eclipse BIRT Project
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
org.eclipse.birt.report.data.oda.pojo;bundle-version="[3.7.2,5.0.0)",
org.eclipse.datatools.connectivity.oda;bundle-version="[3.1.0,4.0.0)",
org.junit4;bundle-version="[3.0.0,5.0.0)"
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ActivationPolicy: lazy
27 changes: 27 additions & 0 deletions org.eclipse.birt.report.data.oda.pojo.tests/about.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>About</title>
</head>
<body lang="EN-US"><h2>About This Content</h2>

<p>June 11, 2012</p>
<h3>License</h3>

<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
indicated below, the Content is provided to you under the terms and conditions of the
Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>

<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
apply to your use of any object code in the Content. Check the Redistributor's license that was
provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
indicated below, the terms and conditions of the EPL still apply to any source code in the Content
and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.<br />

</body>
</html>
6 changes: 6 additions & 0 deletions org.eclipse.birt.report.data.oda.pojo.tests/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
about.html
src.includes = about.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*******************************************************************************
* Copyright (c) 2013 Actuate Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Actuate Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.birt.report.data.oda.pojo.api;

import org.eclipse.datatools.connectivity.oda.OdaException;

import org.eclipse.birt.report.data.oda.pojo.api.IPojoDataSet;
import org.eclipse.birt.report.data.oda.pojo.api.PojoDataSetFromArray;

import junit.framework.TestCase;


/**
*
*/

public class PojoDataSetFromArrayTest extends TestCase
{
@SuppressWarnings("nls")
public void testNext( ) throws OdaException
{
IPojoDataSet pds = new PojoDataSetFromArray( )
{
@Override
protected Object[] fetchPojos( ) throws OdaException
{
return null;
}
};
pds.open( null, null );
assertTrue( pds.next( ) == null );
pds.close( );

pds = new PojoDataSetFromArray( )
{
@Override
protected Object[] fetchPojos( ) throws OdaException
{
return new Object[0];
}
};
pds.open( null, null );
assertTrue( pds.next( ) == null );
pds.close( );

pds = new PojoDataSetFromArray( )
{
@Override
protected Object[] fetchPojos( ) throws OdaException
{
return new Object[]{"1", "2", "3"};
}
};
pds.open( null, null );
assertTrue( pds.next( ).equals( "1" ) );
assertTrue( pds.next( ).equals( "2" ) );
assertTrue( pds.next( ).equals( "3" ) );
assertTrue( pds.next( ) == null );
pds.close( );

pds.open( null, null );
assertTrue( pds.next( ).equals( "1" ) );
assertTrue( pds.next( ).equals( "2" ) );
assertTrue( pds.next( ).equals( "3" ) );
assertTrue( pds.next( ) == null );
pds.close( );

pds = new PojoDataSetFromArray( )
{
@Override
protected Object[] fetchPojos( ) throws OdaException
{
return new Object[]{null, "1", null, null, "2", null, "3", null, null};
}
};

pds.open( null, null );
assertTrue( pds.next( ).equals( "1" ) );
assertTrue( pds.next( ).equals( "2" ) );
assertTrue( pds.next( ).equals( "3" ) );
assertTrue( pds.next( ) == null );
pds.close( );

pds.open( null, null );
assertTrue( pds.next( ).equals( "1" ) );
assertTrue( pds.next( ).equals( "2" ) );
assertTrue( pds.next( ).equals( "3" ) );
assertTrue( pds.next( ) == null );
pds.close( );
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
/*******************************************************************************
* Copyright (c) 2013 Actuate Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Actuate Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.birt.report.data.oda.pojo.api;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.eclipse.datatools.connectivity.oda.OdaException;

import org.eclipse.birt.report.data.oda.pojo.api.IPojoDataSet;
import org.eclipse.birt.report.data.oda.pojo.api.PojoDataSetFromIterator;

import junit.framework.TestCase;


/**
*
*/

public class PojoDataSetFromIteratorTest extends TestCase
{

@SuppressWarnings("nls")
public void testNext( ) throws OdaException
{
IPojoDataSet pds = new PojoDataSetFromIterator( )
{
@SuppressWarnings("unchecked")
@Override
protected Iterator fetchPojos( ) throws OdaException
{
return null;
}
};
pds.open( null, null );
assertTrue( pds.next( ) == null );
pds.close( );

pds = new PojoDataSetFromIterator( )
{
@SuppressWarnings("unchecked")
@Override
protected Iterator fetchPojos( ) throws OdaException
{
return createIteratorFromArray( new Object[0] );
}
};
pds.open( null, null );
assertTrue( pds.next( ) == null );
pds.close( );

pds = new PojoDataSetFromIterator( )
{
@SuppressWarnings({
"unchecked"
})
@Override
protected Iterator fetchPojos( ) throws OdaException
{
return createIteratorFromArray( new Object[]{"1", "2", "3"} );
}
};
pds.open( null, null );
assertTrue( pds.next( ).equals( "1" ) );
assertTrue( pds.next( ).equals( "2" ) );
assertTrue( pds.next( ).equals( "3" ) );
assertTrue( pds.next( ) == null );
pds.close( );

pds.open( null, null );
assertTrue( pds.next( ).equals( "1" ) );
assertTrue( pds.next( ).equals( "2" ) );
assertTrue( pds.next( ).equals( "3" ) );
assertTrue( pds.next( ) == null );
pds.close( );

pds = new PojoDataSetFromIterator( )
{
@SuppressWarnings("unchecked")
@Override
protected Iterator fetchPojos( ) throws OdaException
{
return createIteratorFromArray(
new Object[]{null, "1", null, null, "2", null, "3", null, null} );
}
};

pds.open( null, null );
assertTrue( pds.next( ).equals( "1" ) );
assertTrue( pds.next( ).equals( "2" ) );
assertTrue( pds.next( ).equals( "3" ) );
assertTrue( pds.next( ) == null );
pds.close( );

pds.open( null, null );
assertTrue( pds.next( ).equals( "1" ) );
assertTrue( pds.next( ).equals( "2" ) );
assertTrue( pds.next( ).equals( "3" ) );
assertTrue( pds.next( ) == null );
pds.close( );
}



@SuppressWarnings("unchecked")
private static Iterator createIteratorFromArray( Object[] array )
{
if ( array == null )
{
return null;
}
List l = new ArrayList( );
for ( Object o : array )
{
l.add( o );
}
return l.iterator( );
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

/*******************************************************************************
* Copyright (c) 2013 Actuate Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Actuate Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.birt.report.data.oda.pojo.impl;

import org.eclipse.birt.report.data.oda.pojo.testutil.PojoQueryCreator;
import org.eclipse.datatools.connectivity.oda.IParameterMetaData;
import org.eclipse.datatools.connectivity.oda.OdaException;

import org.eclipse.birt.report.data.oda.pojo.api.Constants;
import org.eclipse.birt.report.data.oda.pojo.impl.Driver;
import org.eclipse.birt.report.data.oda.pojo.impl.Query;
import org.eclipse.birt.report.data.oda.pojo.querymodel.PojoQuery;
import org.eclipse.birt.report.data.oda.pojo.util.PojoQueryWriter;

import junit.framework.TestCase;


/**
*
*/

public class QueryTest extends TestCase
{

@SuppressWarnings("nls")
public void testGetParameterMetaData( ) throws OdaException
{
PojoQuery pq = PojoQueryCreator.createWithParameters( );
Query q = new Query( null );
q.prepare( PojoQueryWriter.write( pq ) );
IParameterMetaData pmd = q.getParameterMetaData( );
assertEquals( 2, pmd.getParameterCount( ) );
assertEquals( "id", pmd.getParameterName( 1 ) );
assertEquals( "sex", pmd.getParameterName( 2 ) );
assertEquals( Driver.getNativeDataTypeCode( Constants.ODA_TYPE_Integer ),
pmd.getParameterType( 1 ) );
assertEquals( Driver.getNativeDataTypeCode( Constants.ODA_TYPE_Boolean ),
pmd.getParameterType( 2 ) );

}

}
Loading

0 comments on commit eb6ef6f

Please sign in to comment.