Projects >> thredds >>e43d82a20f8cd006ca64c2b02cb1183d1cdbfc20

Chunk
Conflicting content
import ucar.nc2.dataset.DatasetUrl;
import ucar.nc2.util.CommonTestUtils;
import ucar.nc2.util.EscapeStrings;
<<<<<<< HEAD
=======
import ucar.nc2.util.CommonTestUtils;
>>>>>>> a582b50007a27e64fe3d5ee6c2be86bf3936e777
import ucar.unidata.test.util.NeedsExternalResource;
import ucar.unidata.test.util.TestDir;
Solution content
import ucar.nc2.dataset.DatasetUrl;
import ucar.nc2.util.EscapeStrings;
import ucar.nc2.util.CommonTestUtils;
import ucar.unidata.test.util.NeedsExternalResource;
import ucar.unidata.test.util.TestDir;
File
TestMisc.java
Developer's decision
Version 1
Kind of conflict
Import
Chunk
Conflicting content
    }

    //////////////////////////////////////////////////
<<<<<<< HEAD
=======
    static public class Result
    {
        public int status = 0;
        public byte[] contents = null;

        public String toString()
        {
            return String.format("{status=%d |contents|=%d}",
                    status, (contents == null ? 0 : contents.length));
        }
    }

    static public void
        report(Result result)
        {
            report(result, null);
        }

        static public void
        report(Result result, Integer counter)
        {
            System.err.printf("Result: code=%d content?=%b provider-calls=%d%n",
                    result.status, result.contents.length, counter);
            System.err.flush();
        }

>>>>>>> a582b50007a27e64fe3d5ee6c2be86bf3936e777
    // Provide a non-interactive CredentialsProvider to hold
    // the user+pwd; used in several places
Solution content
    }

    //////////////////////////////////////////////////
    static public class Result
    {
        public int status = 0;
        public byte[] contents = null;

        public String toString()
        {
            return String.format("{status=%d |contents|=%d}",
                    status, (contents == null ? 0 : contents.length));
        }
    }

    static public void
        report(Result result)
        {
            report(result, null);
        }

        static public void
        report(Result result, Integer counter)
        {
            System.err.printf("Result: code=%d content?=%b provider-calls=%d%n",
                    result.status, result.contents.length, counter);
            System.err.flush();
        }

    // Provide a non-interactive CredentialsProvider to hold
    // the user+pwd; used in several places
File
TestSSH.java
Developer's decision
Version 2
Kind of conflict
Class declaration
Method declaration
Chunk
Conflicting content
import ucar.httpservices.HTTPMethod;
import ucar.httpservices.HTTPSession;
import ucar.nc2.util.CommonTestUtils;
<<<<<<< HEAD:cdm-test/src/test/java/ucar/nc2/util/net/TestTomcatAuth.java
import ucar.unidata.test.util.NotJenkins;
import ucar.unidata.test.util.NotTravis;
=======
import ucar.unidata.test.util.NeedsExternalResource;
>>>>>>> a582b50007a27e64fe3d5ee6c2be86bf3936e777:cdm-test/src/test/java/ucar/nc2/util/net/TestAuth.java
import ucar.unidata.test.util.TestDir;

import java.io.IOException;
Solution content
import ucar.httpservices.HTTPMethod;
import ucar.httpservices.HTTPSession;
import ucar.nc2.util.CommonTestUtils;
import ucar.unidata.test.util.NotJenkins;
import ucar.unidata.test.util.NotTravis;
import ucar.unidata.test.util.TestDir;

import java.io.IOException;
File
TestTomcatAuth.java
Developer's decision
Version 1
Kind of conflict
Import
Chunk
Conflicting content
 *
 */

<<<<<<< HEAD:cdm-test/src/test/java/ucar/nc2/util/net/TestTomcatAuth.java
@Category({NotJenkins.class, NotTravis.class})
public class TestTomcatAuth extends CommonTestUtils
=======
@Category(NeedsExternalResource.class)
public class TestAuth extends CommonTestUtils
>>>>>>> a582b50007a27e64fe3d5ee6c2be86bf3936e777:cdm-test/src/test/java/ucar/nc2/util/net/TestAuth.java
{
    static final String BADPASSWORD = "bad";
Solution content
 *
 */

@Category({NotJenkins.class, NotTravis.class})
public class TestTomcatAuth extends CommonTestUtils
{
    static final String BADPASSWORD = "bad";
File
TestTomcatAuth.java
Developer's decision
Version 1
Kind of conflict
Annotation
Class signature
Chunk
Conflicting content
    static protected final boolean IGNORE = true;

<<<<<<< HEAD:cdm-test/src/test/java/ucar/nc2/util/net/TestTomcatAuth.java
=======
    /**
     * Temporary data directory (for writing temporary data).
     */
    static public String TEMPROOT = "target/test/tmp/"; // relative to module root

    // Add a temporary control for remote versus localhost
    static boolean remote = false;

    static public class Counter
    {
        protected int callcount = 0;// track # of times getCredentials is called

        synchronized public void incr()
        {
            callcount++;
        }

        synchronized public void clear()
        {
            callcount = 0;
        }

        synchronized public int counter()
        {
            int c = callcount;
            callcount = 0;
            return c;
        }
    }

>>>>>>> a582b50007a27e64fe3d5ee6c2be86bf3936e777:cdm-test/src/test/java/ucar/nc2/util/net/TestAuth.java
    //////////////////////////////////////////////////
    // Provide a non-interactive TestProvider to hold
    // the user+pwd; used in several places
Solution content
    static protected final boolean IGNORE = true;

    //////////////////////////////////////////////////
    // Provide a non-interactive TestProvider to hold
    // the user+pwd; used in several places
File
TestTomcatAuth.java
Developer's decision
Version 1
Kind of conflict
Attribute
Class declaration
Comment
Chunk
Conflicting content
                result = invoke(session, data.url);
                report(result,provider.counter);
            }
<<<<<<< HEAD:cdm-test/src/test/java/ucar/nc2/util/net/TestTomcatAuth.java
            Assert.assertTrue("Incorrect return code: " + result.status, check(result.status));
            Assert.assertTrue("no content", result.contents.length > 0);
            Assert.assertTrue("Cre  dentials provider called: " + provider.counter, provider.counter == 1);
=======
            Assert.assertTrue("Incorrect return code: " + this.result.status,
                    this.result.status == 200);
            Assert.assertTrue("no content", this.result.contents.length > 0);
            if(!remote)
                Assert.assertTrue("Credentials provider called: " + provider.counter.counter(), provider.counter.counter() == 1);
>>>>>>> a582b50007a27e64fe3d5ee6c2be86bf3936e777:cdm-test/src/test/java/ucar/nc2/util/net/TestAuth.java
        }

        for(AuthDataBasic data : basictests) {
Solution content
                result = invoke(session, data.url);
                report(result,provider.counter);
            }
            Assert.assertTrue("Incorrect return code: " + result.status, check(result.status));
            Assert.assertTrue("no content", result.contents.length > 0);
            Assert.assertTrue("Cre  dentials provider called: " + provider.counter, provider.counter == 1);
        }

        for(AuthDataBasic data : basictests) {
File
TestTomcatAuth.java
Developer's decision
Version 1
Kind of conflict
Other
Chunk
Conflicting content
                result = invoke(session, data.url);
                report(result,provider.counter);
            }
<<<<<<< HEAD:cdm-test/src/test/java/ucar/nc2/util/net/TestTomcatAuth.java
            Assert.assertTrue("Incorrect return code: " + result.status, check(result.status)); // non-existence is ok
            Assert.assertTrue("no content", result.contents.length > 0);
            Assert.assertTrue("Credentials provider called: " + provider.counter, provider.counter == 1);
=======
            Assert.assertTrue("Incorrect return code: " + this.result.status, this.result.status == 200 || this.result.status == 404); // non-existence is ok
            Assert.assertTrue("no content", this.result.contents.length > 0);
            if(!remote)
                Assert.assertTrue("Credentials provider called: " + provider.counter.counter(), provider.counter.counter() == 1);
>>>>>>> a582b50007a27e64fe3d5ee6c2be86bf3936e777:cdm-test/src/test/java/ucar/nc2/util/net/TestAuth.java
        }
    }
Solution content
                result = invoke(session, data.url);
                report(result,provider.counter);
            }
            Assert.assertTrue("Incorrect return code: " + result.status, check(result.status)); // non-existence is ok
            Assert.assertTrue("no content", result.contents.length > 0);
            Assert.assertTrue("Credentials provider called: " + provider.counter, provider.counter == 1);
        }
    }
File
TestTomcatAuth.java
Developer's decision
Version 1
Kind of conflict
Comment
Chunk
Conflicting content
                result = invoke(session, data.url);
                report(result);
            }
<<<<<<< HEAD:cdm-test/src/test/java/ucar/nc2/util/net/TestTomcatAuth.java
            Assert.assertTrue("Incorrect return code: " + result.status, result.status == 401);
=======
            Assert.assertTrue("Incorrect return code: " + this.result.status, this.result.status == 401);
            if(!remote)
                Assert.assertTrue("Credentials provider called: " + provider.counter.counter(), provider.counter.counter() == 1);
>>>>>>> a582b50007a27e64fe3d5ee6c2be86bf3936e777:cdm-test/src/test/java/ucar/nc2/util/net/TestAuth.java
            // retry with correct password;
            // AuthCache should automatically clear bad one from cache.
            try (HTTPSession session = HTTPFactory.newSession(data.url)) {
Solution content
                result = invoke(session, data.url);
                report(result);
            }
            Assert.assertTrue("Incorrect return code: " + result.status, result.status == 401);
            // retry with correct password;
            // AuthCache should automatically clear bad one from cache.
            try (HTTPSession session = HTTPFactory.newSession(data.url)) {
File
TestTomcatAuth.java
Developer's decision
Version 1
Kind of conflict
Other
Chunk
Conflicting content
    //////////////////////////////////////////////////
    // Static methods

<<<<<<< HEAD
    // Walk around the directory structure to locate
    // the path to the thredds root (which may not
    // be names "thredds").
    // Same as code in CommonTestUtils, but for
    // some reason, Intellij will not let me import it.

    static String
    locateThreddsRoot()
    {
        // Walk up the user.dir path looking for a node that has
        // all the directories in SUBROOTS.

        String path = System.getProperty("user.dir");

        // clean up the path
        path = path.replace('\\', '/'); // only use forward slash
        assert (path != null);
        if(path.endsWith("/")) path = path.substring(0, path.length() - 1);

        File prefix = new File(path);
        for(; prefix != null; prefix = prefix.getParentFile()) {//walk up the tree
            int found = 0;
            String[] subdirs = prefix.list();
            for(String dirname : subdirs) {
                for(String want : DEFAULTSUBDIRS) {
                    if(dirname.equals(want)) {
                        found++;
                        break;
                    }
                }
            }
            if(found == DEFAULTSUBDIRS.length) try {// Assume this is it
                String root = prefix.getCanonicalPath();
                // clean up the root path
                root = root.replace('\\', '/'); // only use forward slash
                return root;
            } catch (IOException ioe) {
            }
        }
        return null;
    }

=======
>>>>>>> a582b50007a27e64fe3d5ee6c2be86bf3936e777
    static String
    locateDAP4Root(String threddsroot)
    {
Solution content
    //////////////////////////////////////////////////
    // Static methods

    static String
    locateDAP4Root(String threddsroot)
    {
File
DapTestCommon.java
Developer's decision
Version 2
Kind of conflict
Comment
Method declaration