dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #08095
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2412: Added new class called MockI18n to support in testing.
------------------------------------------------------------
revno: 2412
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Fri 2010-10-22 14:08:36 +0700
message:
Added new class called MockI18n to support in testing.
Increasing unit test - PdfServiceTest in dhis-service-reporting
added:
dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/mock/MockI18n.java
modified:
dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/pdf/PdfServiceTest.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/pdf/PdfServiceTest.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/pdf/PdfServiceTest.java 2010-06-03 08:06:09 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/pdf/PdfServiceTest.java 2010-10-22 07:08:36 +0000
@@ -27,7 +27,11 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import java.io.BufferedOutputStream;
+import java.io.ByteArrayInputStream;
import java.io.FileOutputStream;
import java.io.OutputStream;
@@ -36,9 +40,9 @@
import org.hisp.dhis.i18n.I18n;
import org.hisp.dhis.indicator.IndicatorService;
import org.hisp.dhis.indicator.IndicatorType;
+import org.hisp.dhis.mock.MockI18n;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.system.util.StreamUtils;
-import org.junit.Ignore;
import org.junit.Test;
/**
@@ -62,11 +66,6 @@
private I18n i18n;
- public void setI18n( I18n i18n )
- {
- this.i18n = i18n;
- }
-
// -------------------------------------------------------------------------
// Fixture
// -------------------------------------------------------------------------
@@ -74,6 +73,8 @@
@Override
public void setUpTest()
{
+ i18n = new MockI18n();
+
pdfService = (PdfService) getBean( PdfService.ID );
dataElementService = (DataElementService) getBean( DataElementService.ID );
@@ -96,6 +97,7 @@
organisationUnitService.addOrganisationUnit( createOrganisationUnit( 'A' ) );
organisationUnitService.addOrganisationUnit( createOrganisationUnit( 'B' ) );
organisationUnitService.addOrganisationUnit( createOrganisationUnit( 'C' ) );
+
}
// -------------------------------------------------------------------------
@@ -103,19 +105,19 @@
// -------------------------------------------------------------------------
@Test
- @Ignore
public void testWriteAllDataElements()
throws Exception
{
- OutputStream outputStream = new BufferedOutputStream( new FileOutputStream( "dataElementsTest.pdf" ) );
-
- pdfService.writeAllDataElements( outputStream, i18n );
-
- StreamUtils.closeOutputStream( outputStream );
+ OutputStream outputStreamA = new BufferedOutputStream( new FileOutputStream( "dataElementsTest.pdf" ) );
+
+ pdfService.writeAllDataElements( outputStreamA, i18n );
+
+ assertNotNull( outputStreamA );
+
+ StreamUtils.closeOutputStream( outputStreamA );
}
@Test
- @Ignore
public void testWriteAllIndicators()
throws Exception
{
@@ -123,18 +125,21 @@
pdfService.writeAllIndicators( outputStreamB, i18n );
+ assertNotNull( outputStreamB );
+
StreamUtils.closeOutputStream( outputStreamB );
}
@Test
- @Ignore
public void testWriteAllOrganisationUnits()
throws Exception
{
- OutputStream outputStream = new BufferedOutputStream( new FileOutputStream( "organisationUnitsTest.pdf" ) );
-
- pdfService.writeAllOrganisationUnits( outputStream, i18n );
-
- StreamUtils.closeOutputStream( outputStream );
+ OutputStream outputStreamC = new BufferedOutputStream( new FileOutputStream( "organisationUnitsTest.pdf" ) );
+
+ pdfService.writeAllOrganisationUnits( outputStreamC, i18n );
+
+ assertNotNull( outputStreamC );
+
+ StreamUtils.closeOutputStream( outputStreamC );
}
}
=== added file 'dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/mock/MockI18n.java'
--- dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/mock/MockI18n.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/mock/MockI18n.java 2010-10-22 07:08:36 +0000
@@ -0,0 +1,44 @@
+package org.hisp.dhis.mock;
+
+/*
+ * Copyright (c) 2004-2010, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.hisp.dhis.i18n.I18n;
+
+/**
+ * @author Dang Duy Hieu
+ * @version $Id$
+ */
+public class MockI18n
+ extends I18n
+{
+ public MockI18n()
+ {
+ super( null, null );
+ }
+
+}